Merge branch 'perf/skip-npm-install-unchanged'
@@ -6,7 +6,9 @@ On **every** service start (clean midnight restart, crash, or power loss recover
6
6
7
7
1. `git fetch` + `git reset --hard origin/<branch>`
8
8
2. `git pull --ff-only`
9
3. `npm install --omit=dev`
9
3. `npm install --omit=dev` — **skipped** when `package.json` + `package-lock.json`
10
match the stamp written under `node_modules/.questward-npm-stamp` after the last
11
successful install (node_modules survives hard-reset because it is gitignored)
10
12
4. `git submodule update --init --recursive`
11
13
5. `npm run build:client` (concatenates FrameworkV3 → `client/frameworkv3/js/framework.js`)
12
14
6. start `node --experimental-sqlite server/src/index.js`
@@ -6,7 +6,9 @@ On **every** service start (clean midnight restart, crash, or power loss recover6
6
7
1. `git fetch` + `git reset --hard origin/<branch>`7
1. `git fetch` + `git reset --hard origin/<branch>`8
2. `git pull --ff-only`8
2. `git pull --ff-only`9
3. `npm install --omit=dev`9
3. `npm install --omit=dev` — **skipped** when `package.json` + `package-lock.json`10
match the stamp written under `node_modules/.questward-npm-stamp` after the last11
successful install (node_modules survives hard-reset because it is gitignored)10
4. `git submodule update --init --recursive`12
4. `git submodule update --init --recursive`11
5. `npm run build:client` (concatenates FrameworkV3 → `client/frameworkv3/js/framework.js`)13
5. `npm run build:client` (concatenates FrameworkV3 → `client/frameworkv3/js/framework.js`)12
6. start `node --experimental-sqlite server/src/index.js`14
6. start `node --experimental-sqlite server/src/index.js`@@ -17,8 +17,39 @@ git pull --ff-only origin "$BRANCH" || true
17
17
DEPLOY_DIR="$(cd "$(dirname "$0")" && pwd)"
18
18
chmod +x "$DEPLOY_DIR/start-server.sh" "$DEPLOY_DIR/install-service.sh" "$DEPLOY_DIR/update-if-requested.mjs" 2>/dev/null || true
19
19
20
echo "[deploy] npm install…"
21
npm install --omit=dev
20
# Skip npm install when package manifests are unchanged since the last successful install.
21
# Stamp lives under node_modules/ (gitignored) so it survives hard-reset/pull.
22
NPM_STAMP="node_modules/.questward-npm-stamp"
23
npm_manifest_hash ()
24
{
25
# Prefer sha256sum; fall back to shasum (macOS) / openssl.
26
if command -v sha256sum >/dev/null 2>&1
27
then
28
cat package.json package-lock.json | sha256sum | awk '{ print $1 }'
29
elif command -v shasum >/dev/null 2>&1
30
then
31
cat package.json package-lock.json | shasum -a 256 | awk '{ print $1 }'
32
else
33
cat package.json package-lock.json | openssl dgst -sha256 | awk '{ print $NF }'
34
fi
35
}
36
37
WANT_HASH="$(npm_manifest_hash)"
38
HAVE_HASH=""
39
if [[ -f "$NPM_STAMP" ]]
40
then
41
HAVE_HASH="$(tr -d '[:space:]' < "$NPM_STAMP" || true)"
42
fi
43
44
if [[ -d node_modules && -n "$HAVE_HASH" && "$HAVE_HASH" == "$WANT_HASH" ]]
45
then
46
echo "[deploy] npm install skipped (package.json / package-lock.json unchanged)"
47
else
48
echo "[deploy] npm install…"
49
npm install --omit=dev
50
mkdir -p node_modules
51
printf '%s\n' "$WANT_HASH" > "$NPM_STAMP"
52
fi
22
53
23
54
echo "[deploy] Submodules…"
24
55
git submodule update --init --recursive
@@ -17,8 +17,39 @@ git pull --ff-only origin "$BRANCH" || true17
DEPLOY_DIR="$(cd "$(dirname "$0")" && pwd)"17
DEPLOY_DIR="$(cd "$(dirname "$0")" && pwd)"18
chmod +x "$DEPLOY_DIR/start-server.sh" "$DEPLOY_DIR/install-service.sh" "$DEPLOY_DIR/update-if-requested.mjs" 2>/dev/null || true18
chmod +x "$DEPLOY_DIR/start-server.sh" "$DEPLOY_DIR/install-service.sh" "$DEPLOY_DIR/update-if-requested.mjs" 2>/dev/null || true19
19
20
echo "[deploy] npm install…"20
# Skip npm install when package manifests are unchanged since the last successful install.21
npm install --omit=dev21
# Stamp lives under node_modules/ (gitignored) so it survives hard-reset/pull.22
NPM_STAMP="node_modules/.questward-npm-stamp"23
npm_manifest_hash ()24
{25
# Prefer sha256sum; fall back to shasum (macOS) / openssl.26
if command -v sha256sum >/dev/null 2>&127
then28
cat package.json package-lock.json | sha256sum | awk '{ print $1 }'29
elif command -v shasum >/dev/null 2>&130
then31
cat package.json package-lock.json | shasum -a 256 | awk '{ print $1 }'32
else33
cat package.json package-lock.json | openssl dgst -sha256 | awk '{ print $NF }'34
fi35
}36
37
WANT_HASH="$(npm_manifest_hash)"38
HAVE_HASH=""39
if [[ -f "$NPM_STAMP" ]]40
then41
HAVE_HASH="$(tr -d '[:space:]' < "$NPM_STAMP" || true)"42
fi43
44
if [[ -d node_modules && -n "$HAVE_HASH" && "$HAVE_HASH" == "$WANT_HASH" ]]45
then46
echo "[deploy] npm install skipped (package.json / package-lock.json unchanged)"47
else48
echo "[deploy] npm install…"49
npm install --omit=dev50
mkdir -p node_modules51
printf '%s\n' "$WANT_HASH" > "$NPM_STAMP"52
fi22
53
23
echo "[deploy] Submodules…"54
echo "[deploy] Submodules…"24
git submodule update --init --recursive55
git submodule update --init --recursive