Run dev on host Node 16 and add deploy patch script
Switch make install/run/build/db-* off docker compose onto the host's Node (via nvm + .nvmrc). better-sqlite3 7.6.2 doesn't build against Node 20, and the Dockerfile was still pinned to node:20 while the rest of the project was downgraded to Node 16 in the Win7 bundle commit; host execution avoids that mismatch. Also adds scripts/make-patch.sh (make patch) to produce a small build-only update zip for an already-installed Win7 target, ignores dist/, and points start.bat at the installed Chrome PWA shortcut instead of opening a normal browser tab. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,7 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
.svelte-kit/
|
.svelte-kit/
|
||||||
build/
|
build/
|
||||||
|
dist/
|
||||||
data/
|
data/
|
||||||
backups/
|
backups/
|
||||||
*.log
|
*.log
|
||||||
|
|||||||
26
Makefile
26
Makefile
@ -1,4 +1,8 @@
|
|||||||
.PHONY: help install run build db-init db-reset docker-build docker-shell clean clean-all bundle bundle-clean
|
.PHONY: help install run build db-init db-reset docker-build docker-shell clean clean-all bundle patch bundle-clean
|
||||||
|
|
||||||
|
SHELL := /bin/bash
|
||||||
|
# Activate the Node version pinned in .nvmrc (16.x) for every recipe.
|
||||||
|
NVM := . $$HOME/.nvm/nvm.sh && nvm use --silent
|
||||||
|
|
||||||
DC := docker compose
|
DC := docker compose
|
||||||
|
|
||||||
@ -8,40 +12,41 @@ help:
|
|||||||
@echo " ║ AvtoAmbor — auto parts inventory (dev tasks) ║"
|
@echo " ║ AvtoAmbor — auto parts inventory (dev tasks) ║"
|
||||||
@echo " ╚════════════════════════════════════════════════╝"
|
@echo " ╚════════════════════════════════════════════════╝"
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo " make install Install npm dependencies inside the container"
|
@echo " make install Install npm dependencies (Node 16 via nvm)"
|
||||||
@echo " make run Start the dev server (http://localhost:3000)"
|
@echo " make run Start the dev server (http://localhost:3000)"
|
||||||
@echo " make build Production build into ./build (adapter-node)"
|
@echo " make build Production build into ./build (adapter-node)"
|
||||||
@echo " make db-init Create data/avtoambor.db from schema + seed (skip if exists)"
|
@echo " make db-init Create data/avtoambor.db from schema + seed (skip if exists)"
|
||||||
@echo " make db-reset DELETE and recreate data/avtoambor.db (asks first)"
|
@echo " make db-reset DELETE and recreate data/avtoambor.db (asks first)"
|
||||||
@echo " make docker-build Rebuild the Docker image"
|
@echo " make docker-build Rebuild the Docker image (legacy; dev runs on host now)"
|
||||||
@echo " make docker-shell Open an interactive bash shell in the container"
|
@echo " make docker-shell Open an interactive bash shell in the container"
|
||||||
@echo " make clean Remove node_modules and build/ (keeps data/)"
|
@echo " make clean Remove node_modules and build/ (keeps data/)"
|
||||||
@echo " make clean-all Also wipe data/ (destroys the DB)"
|
@echo " make clean-all Also wipe data/ (destroys the DB)"
|
||||||
@echo " make bundle Produce dist/avtoambor-deploy.zip for Windows 7"
|
@echo " make bundle Produce dist/avtoambor-deploy.zip for Windows 7"
|
||||||
|
@echo " make patch Produce dist/avtoambor-patch.zip (build/ only) for an installed target"
|
||||||
@echo " make bundle-clean Remove dist/"
|
@echo " make bundle-clean Remove dist/"
|
||||||
@echo ""
|
@echo ""
|
||||||
|
|
||||||
install:
|
install:
|
||||||
@$(DC) run --rm app npm install
|
@$(NVM) && npm install
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@$(DC) up
|
@$(NVM) && npm run dev
|
||||||
|
|
||||||
build:
|
build:
|
||||||
@$(DC) run --rm app npm run build
|
@$(NVM) && npm run build
|
||||||
|
|
||||||
db-init:
|
db-init:
|
||||||
@if [ -f data/avtoambor.db ]; then \
|
@if [ -f data/avtoambor.db ]; then \
|
||||||
echo "data/avtoambor.db already exists — skipping. Use 'make db-reset' to recreate."; \
|
echo "data/avtoambor.db already exists — skipping. Use 'make db-reset' to recreate."; \
|
||||||
else \
|
else \
|
||||||
mkdir -p data && $(DC) run --rm app node scripts/init-db.js; \
|
mkdir -p data && $(NVM) && node scripts/init-db.js; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
db-reset:
|
db-reset:
|
||||||
@printf "This will DELETE data/avtoambor.db. Continue? [y/N] " && read ans && [ "$$ans" = "y" ] || (echo "aborted." && exit 1)
|
@printf "This will DELETE data/avtoambor.db. Continue? [y/N] " && read ans && [ "$$ans" = "y" ] || (echo "aborted." && exit 1)
|
||||||
@rm -f data/avtoambor.db data/avtoambor.db-shm data/avtoambor.db-wal
|
@rm -f data/avtoambor.db data/avtoambor.db-shm data/avtoambor.db-wal
|
||||||
@mkdir -p data
|
@mkdir -p data
|
||||||
@$(DC) run --rm app node scripts/init-db.js
|
@$(NVM) && node scripts/init-db.js
|
||||||
|
|
||||||
docker-build:
|
docker-build:
|
||||||
@$(DC) build
|
@$(DC) build
|
||||||
@ -61,6 +66,11 @@ clean-all: clean
|
|||||||
bundle:
|
bundle:
|
||||||
@bash scripts/make-bundle.sh
|
@bash scripts/make-bundle.sh
|
||||||
|
|
||||||
|
# Small build/-only update zip for an already-installed target.
|
||||||
|
# Requires a prior `make bundle` to establish dist/avtoambor/ as the baseline.
|
||||||
|
patch:
|
||||||
|
@bash scripts/make-patch.sh
|
||||||
|
|
||||||
bundle-clean:
|
bundle-clean:
|
||||||
@rm -rf dist
|
@rm -rf dist
|
||||||
@echo "removed dist/"
|
@echo "removed dist/"
|
||||||
|
|||||||
@ -34,7 +34,8 @@ set "PORT=3000"
|
|||||||
set "HOST=0.0.0.0"
|
set "HOST=0.0.0.0"
|
||||||
set "ORIGIN=http://localhost:3000"
|
set "ORIGIN=http://localhost:3000"
|
||||||
|
|
||||||
start "" http://localhost:3000
|
REM start "" http://localhost:3000
|
||||||
|
"C:\Program Files\Google\Chrome\Application\chrome_proxy.exe" --profile-directory=Default --app-id=jndfkokbljfmkpnammckejpeijmbbhhe
|
||||||
|
|
||||||
echo Сервер запущен на http://localhost:3000
|
echo Сервер запущен на http://localhost:3000
|
||||||
echo Закройте это окно, чтобы остановить программу.
|
echo Закройте это окно, чтобы остановить программу.
|
||||||
|
|||||||
106
scripts/make-patch.sh
Executable file
106
scripts/make-patch.sh
Executable file
@ -0,0 +1,106 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Build dist/avtoambor-patch.zip — a small build/-only update for an
|
||||||
|
# already-installed Windows deployment.
|
||||||
|
#
|
||||||
|
# Use this when only application code has changed since the last full bundle.
|
||||||
|
# The patch is just the SvelteKit build output; node_modules, .bat launchers,
|
||||||
|
# and the native better-sqlite3 binary on the target stay untouched.
|
||||||
|
#
|
||||||
|
# The script compares package-lock.json and src/lib/server/*.sql against the
|
||||||
|
# staging snapshot left by scripts/make-bundle.sh (dist/avtoambor/). If those
|
||||||
|
# changed, a full re-bundle is required instead — the patch alone won't work.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
cd "$(dirname "$0")/.."
|
||||||
|
ROOT="$(pwd)"
|
||||||
|
DIST="$ROOT/dist"
|
||||||
|
BASELINE="$DIST/avtoambor"
|
||||||
|
PATCH_DIR="$DIST/patch"
|
||||||
|
ZIP="$DIST/avtoambor-patch.zip"
|
||||||
|
|
||||||
|
for cmd in npm zip rsync diff; do
|
||||||
|
command -v "$cmd" >/dev/null || { echo "make-patch.sh: missing required tool: $cmd"; exit 1; }
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "$BASELINE" ]; then
|
||||||
|
echo "make-patch.sh: no baseline at $BASELINE."
|
||||||
|
echo " Run scripts/make-bundle.sh first to establish a baseline."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- safety checks: things a build/-only patch cannot deliver ---
|
||||||
|
WARN=0
|
||||||
|
warn() { echo " ! $*"; WARN=1; }
|
||||||
|
|
||||||
|
echo "==> Checking patch safety against baseline ($BASELINE)"
|
||||||
|
if ! diff -q "$ROOT/package-lock.json" "$BASELINE/package-lock.json" >/dev/null 2>&1; then
|
||||||
|
warn "package-lock.json changed — node_modules on target is stale. Full bundle required."
|
||||||
|
fi
|
||||||
|
for f in schema.sql seed.sql; do
|
||||||
|
if ! diff -q "$ROOT/src/lib/server/$f" "$BASELINE/src/lib/server/$f" >/dev/null 2>&1; then
|
||||||
|
warn "src/lib/server/$f changed — target DB may need a migration."
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$WARN" = 1 ]; then
|
||||||
|
echo
|
||||||
|
echo "Patch may be unsafe."
|
||||||
|
echo "Either:"
|
||||||
|
echo " - run scripts/make-bundle.sh and ship the full bundle, or"
|
||||||
|
echo " - re-run this script with FORCE=1 if you know the change is harmless."
|
||||||
|
if [ "${FORCE:-0}" != "1" ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "FORCE=1 set — continuing anyway."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "==> Building production output (vite build)"
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
echo "==> Staging patch contents"
|
||||||
|
rm -rf "$PATCH_DIR"
|
||||||
|
mkdir -p "$PATCH_DIR"
|
||||||
|
rsync -a --delete build/ "$PATCH_DIR/build/"
|
||||||
|
|
||||||
|
STAMP="$(date +%Y-%m-%d)"
|
||||||
|
cat > "$PATCH_DIR/UPDATE.txt" <<EOF
|
||||||
|
Замена Масла ГП — обновление программы ($STAMP)
|
||||||
|
================================================
|
||||||
|
|
||||||
|
Этот архив содержит только новую версию программы (папка build).
|
||||||
|
Ваши данные (data\\, backups\\) и установленный Node.js не затрагиваются.
|
||||||
|
|
||||||
|
Как установить обновление:
|
||||||
|
|
||||||
|
1. Закройте чёрное окно "start.bat", если программа запущена.
|
||||||
|
|
||||||
|
2. Распакуйте этот архив в папку C:\\avtoambor\\
|
||||||
|
(туда же, где лежат install.bat и start.bat).
|
||||||
|
Windows спросит, заменить ли существующие файлы — ответьте "Да"
|
||||||
|
(или "Заменить файлы в папке назначения").
|
||||||
|
|
||||||
|
3. Снова запустите start.bat двойным щелчком.
|
||||||
|
|
||||||
|
Если после обновления программа не запускается — напишите Давиду.
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "==> Creating zip: $ZIP"
|
||||||
|
rm -f "$ZIP"
|
||||||
|
( cd "$PATCH_DIR" && zip -rq "$ZIP" build UPDATE.txt )
|
||||||
|
|
||||||
|
ZIP_SIZE="$(du -h "$ZIP" | cut -f1)"
|
||||||
|
echo
|
||||||
|
echo "═══════════════════════════════════════════════════════════════"
|
||||||
|
echo " Patch ready: $ZIP ($ZIP_SIZE)"
|
||||||
|
echo "═══════════════════════════════════════════════════════════════"
|
||||||
|
echo
|
||||||
|
echo " Next steps (you):"
|
||||||
|
echo " 1. Upload $ZIP to your server."
|
||||||
|
echo " 2. Send him the download link."
|
||||||
|
echo
|
||||||
|
echo " What he does (also written in UPDATE.txt inside the zip):"
|
||||||
|
echo " 1. Close the start.bat window."
|
||||||
|
echo " 2. Extract the zip into C:\\avtoambor\\ — choose Replace when asked."
|
||||||
|
echo " 3. Double-click start.bat."
|
||||||
|
echo
|
||||||
Reference in New Issue
Block a user