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:
David Beccue
2026-05-18 20:34:41 +05:00
parent d5a80bb104
commit 82bb456103
4 changed files with 127 additions and 9 deletions

View File

@ -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
@ -8,40 +12,41 @@ help:
@echo " ║ AvtoAmbor — auto parts inventory (dev tasks) ║"
@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 build Production build into ./build (adapter-node)"
@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 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 clean Remove node_modules and build/ (keeps data/)"
@echo " make clean-all Also wipe data/ (destroys the DB)"
@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 ""
install:
@$(DC) run --rm app npm install
@$(NVM) && npm install
run:
@$(DC) up
@$(NVM) && npm run dev
build:
@$(DC) run --rm app npm run build
@$(NVM) && npm run build
db-init:
@if [ -f data/avtoambor.db ]; then \
echo "data/avtoambor.db already exists — skipping. Use 'make db-reset' to recreate."; \
else \
mkdir -p data && $(DC) run --rm app node scripts/init-db.js; \
mkdir -p data && $(NVM) && node scripts/init-db.js; \
fi
db-reset:
@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
@mkdir -p data
@$(DC) run --rm app node scripts/init-db.js
@$(NVM) && node scripts/init-db.js
docker-build:
@$(DC) build
@ -61,6 +66,11 @@ clean-all: clean
bundle:
@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:
@rm -rf dist
@echo "removed dist/"