Use custom init script instead of postinstall (#5384) * Use custom init script instead of postinstall * Revert changes to start scripts in src\electron * feat: add --ignore-scripts flag to npm install commands in batch and shell scripts * feat: add --ignore-scripts flag to npm ci in Dockerfile
Signed| @@ -0,0 +1,2 @@ | ||
| 1 | +ignore-scripts=true | |
| 2 | +min-release-age=7 | |
| @@ -19,7 +19,7 @@ COPY --chown=node:node . ./ | ||
| 19 | 19 | |
| 20 | 20 | RUN \ |
| 21 | 21 | echo "*** Install npm packages ***" && \ |
| 22 | 22 | npm ci --no-audit --no-fund --loglevel=error --no-progress --omit=dev --ignore-scripts && npm cache clean --force |
| 23 | 23 | |
| 24 | 24 | # Create config directory and link config.yaml. Added hardcoded dirs(constants.js?) |
| 25 | 25 | # that must be present for Non-Root Mode and volumeless docker runs. |
| @@ -1,7 +1,8 @@ | ||
| 1 | 1 | @echo off |
| 2 | 2 | pushd %~dp0 |
| 3 | 3 | set NODE_ENV=production |
| 4 | 4 | call npm install --no-save --no-audit --no-fund --loglevel=error --no-progress --omit=dev --ignore-scripts |
| 5 | +call npm run init | |
| 5 | 6 | node server.js %* |
| 6 | 7 | pause |
| 7 | 8 | popd |
| @@ -20,7 +20,8 @@ if %errorlevel% neq 0 ( | ||
| 20 | 20 | ) |
| 21 | 21 | ) |
| 22 | 22 | set NODE_ENV=production |
| 23 | 23 | call npm install --no-save --no-audit --no-fund --loglevel=error --no-progress --omit=dev --ignore-scripts |
| 24 | +call npm run init | |
| 24 | 25 | node server.js %* |
| 25 | 26 | :end |
| 26 | 27 | pause |
| @@ -102,7 +102,8 @@ if %errorlevel% neq 0 ( | ||
| 102 | 102 | |
| 103 | 103 | echo Installing npm packages and starting server |
| 104 | 104 | set NODE_ENV=production |
| 105 | 105 | call npm install --no-save --no-audit --no-fund --loglevel=error --no-progress --omit=dev --ignore-scripts |
| 106 | +call npm run init | |
| 106 | 107 | node server.js %* |
| 107 | 108 | |
| 108 | 109 | :end |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | #!/bin/sh |
| 2 | 2 | |
| 3 | 3 | # Function to handle startup logic (Config check + Postinstallinit + Start) |
| 4 | 4 | start_sillytavern() { |
| 5 | 5 | local PREFIX="$1" |
| 6 | 6 | shift # Remove the first argument (PREFIX) so $@ contains the rest |
| @@ -11,8 +11,8 @@ start_sillytavern() { | ||
| 11 | 11 | $PREFIX cp "default/config.yaml" "config/config.yaml" |
| 12 | 12 | fi |
| 13 | 13 | |
| 14 | 14 | # Execute postinstallinit script to auto-populate config.yaml with missing values |
| 15 | 15 | $PREFIX npm run postinstallinit |
| 16 | 16 | |
| 17 | 17 | # Start the server |
| 18 | 18 | exec $PREFIX node server.js --listen "$@" |
| @@ -7,7 +7,6 @@ | ||
| 7 | 7 | "": { |
| 8 | 8 | "name": "sillytavern", |
| 9 | 9 | "version": "1.17.0", |
| 10 | - "hasInstallScript": true, | |
| 11 | 10 | "license": "AGPL-3.0", |
| 12 | 11 | "dependencies": { |
| 13 | 12 | "@adobe/css-tools": "^4.4.4", |
| @@ -115,6 +115,7 @@ | ||
| 115 | 115 | }, |
| 116 | 116 | "version": "1.17.0", |
| 117 | 117 | "scripts": { |
| 118 | + "init": "node src/server-init.js", | |
| 118 | 119 | "start": "node server.js", |
| 119 | 120 | "debug": "node --inspect server.js", |
| 120 | 121 | "start:global": "node server.js --global", |
| @@ -122,7 +123,6 @@ | ||
| 122 | 123 | "start:deno": "deno run --allow-run --allow-net --allow-read --allow-write --allow-sys --allow-env server.js", |
| 123 | 124 | "start:bun": "bun server.js", |
| 124 | 125 | "start:no-csrf": "node server.js --disableCsrf", |
| 125 | - "postinstall": "node post-install.js", | |
| 126 | 126 | "lint": "eslint \"src/**/*.js\" \"public/**/*.js\" ./*.js", |
| 127 | 127 | "lint:fix": "eslint \"src/**/*.js\" \"public/**/*.js\" ./*.js --fix", |
| 128 | 128 | "plugins:update": "node plugins update", |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | @echo off |
| 2 | 2 | pushd %~dp0 |
| 3 | 3 | call npm install --no-save --no-audit --no-fund --loglevel=error --no-progress --omit=dev --ignore-scripts |
| 4 | 4 | npm run start server.js %* |
| 5 | 5 | pause |
| 6 | 6 | popd |
| @@ -7,7 +7,7 @@ import process from 'node:process'; | ||
| 7 | 7 | import yaml from 'yaml'; |
| 8 | 8 | import chalk from 'chalk'; |
| 9 | 9 | import { createRequire } from 'node:module'; |
| 10 | 10 | import { addMissingConfigValues } from './src/config-init.js'; |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * Colorizes console output. |
| @@ -88,7 +88,7 @@ function createDefaultFiles() { | ||
| 88 | 88 | ); |
| 89 | 89 | } else { |
| 90 | 90 | throw new Error( |
| 91 | 91 | 'FATAL: Unexpected default file format in `postserver-installinit.js#createDefaultFiles()`.', |
| 92 | 92 | ); |
| 93 | 93 | } |
| 94 | 94 | } catch (error) { |
| @@ -10,7 +10,8 @@ fi | ||
| 10 | 10 | |
| 11 | 11 | echo "Installing Node Modules..." |
| 12 | 12 | export NODE_ENV=production |
| 13 | 13 | npm iinstall --no-save --no-audit --no-fund --loglevel=error --no-progress --omit=dev --ignore-scripts |
| 14 | +npm run init | |
| 14 | 15 | |
| 15 | 16 | echo "Entering SillyTavern..." |
| 16 | 17 | node "server.js" "$@" |