From 969caf7d5c368644951f446bd1222998bc78f542 Mon Sep 17 00:00:00 2001 From: Mark Gregory Date: Fri, 20 Nov 2026 09:51:24 +0000 Subject: [PATCH] Generate npm lockfile during production deployment --- deploy.php | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/deploy.php b/deploy.php index 651242f..619b4b8 100644 --- a/deploy.php +++ b/deploy.php @@ -177,42 +177,42 @@ desc('Build production Vite assets'); task('absdev:build', function (): void { - /* - * Deployer uses a non-interactive SSH shell. - * Explicitly load NVM so Node and npm are available. - */ - $node = <<<'SH' + $script = <<<'SH' +set -euo pipefail + export NVM_DIR="$HOME/.nvm" -if [ -s "$NVM_DIR/nvm.sh" ]; then - . "$NVM_DIR/nvm.sh" - nvm use 26 -fi - -if ! command -v node >/dev/null 2>&1; then - echo "ERROR: Node.js is not available in the deployment shell" +if [ ! -s "$NVM_DIR/nvm.sh" ]; then + echo "ERROR: NVM installation missing" exit 1 fi -if ! command -v npm >/dev/null 2>&1; then - echo "ERROR: npm is not available in the deployment shell" +. "$NVM_DIR/nvm.sh" +nvm use 26 + +cd {{release_path}} + +echo "Node: $(node --version)" +echo "npm: $(npm --version)" + +if [ ! -f package.json ]; then + echo "ERROR: package.json missing" exit 1 fi -node --version -npm --version +# Lockfile is deliberately excluded from Git. +# Generate it within this deployment release. +if [ ! -f package-lock.json ]; then + npm install --package-lock-only --ignore-scripts --no-audit --no-fund +fi + +npm ci --no-audit --no-fund +npm run build + +test -f public/build/manifest.json SH; - run( - $node - . "\ncd {{release_path}}" - . "\nnpm ci --no-audit --no-fund" - . "\nnpm run build" - ); - - run( - 'test -f {{release_path}}/public/build/manifest.json' - ); + run($script); writeln('Production Vite assets built.'); });