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
This commit is contained in:
Cohee
2026-04-01 23:34:00 +03:00
committed by GitHub
parent 04ef0632ee
commit e2d8c0200f
11 changed files with 18 additions and 13 deletions
+2
View File
@@ -0,0 +1,2 @@
ignore-scripts=true
min-release-age=7
+1 -1
View File
@@ -19,7 +19,7 @@ COPY --chown=node:node . ./
RUN \ RUN \
echo "*** Install npm packages ***" && \ echo "*** Install npm packages ***" && \
npm ci --no-audit --no-fund --loglevel=error --no-progress --omit=dev && npm cache clean --force npm ci --no-audit --no-fund --loglevel=error --no-progress --omit=dev --ignore-scripts && npm cache clean --force
# Create config directory and link config.yaml. Added hardcoded dirs(constants.js?) # Create config directory and link config.yaml. Added hardcoded dirs(constants.js?)
# that must be present for Non-Root Mode and volumeless docker runs. # that must be present for Non-Root Mode and volumeless docker runs.
+2 -1
View File
@@ -1,7 +1,8 @@
@echo off @echo off
pushd %~dp0 pushd %~dp0
set NODE_ENV=production set NODE_ENV=production
call npm install --no-save --no-audit --no-fund --loglevel=error --no-progress --omit=dev call npm install --no-save --no-audit --no-fund --loglevel=error --no-progress --omit=dev --ignore-scripts
call npm run init
node server.js %* node server.js %*
pause pause
popd popd
+2 -1
View File
@@ -20,7 +20,8 @@ if %errorlevel% neq 0 (
) )
) )
set NODE_ENV=production set NODE_ENV=production
call npm install --no-save --no-audit --no-fund --loglevel=error --no-progress --omit=dev call npm install --no-save --no-audit --no-fund --loglevel=error --no-progress --omit=dev --ignore-scripts
call npm run init
node server.js %* node server.js %*
:end :end
pause pause
+2 -1
View File
@@ -102,7 +102,8 @@ if %errorlevel% neq 0 (
echo Installing npm packages and starting server echo Installing npm packages and starting server
set NODE_ENV=production set NODE_ENV=production
call npm install --no-save --no-audit --no-fund --loglevel=error --no-progress --omit=dev call npm install --no-save --no-audit --no-fund --loglevel=error --no-progress --omit=dev --ignore-scripts
call npm run init
node server.js %* node server.js %*
:end :end
+3 -3
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# Function to handle startup logic (Config check + Postinstall + Start) # Function to handle startup logic (Config check + init + Start)
start_sillytavern() { start_sillytavern() {
local PREFIX="$1" local PREFIX="$1"
shift # Remove the first argument (PREFIX) so $@ contains the rest shift # Remove the first argument (PREFIX) so $@ contains the rest
@@ -11,8 +11,8 @@ start_sillytavern() {
$PREFIX cp "default/config.yaml" "config/config.yaml" $PREFIX cp "default/config.yaml" "config/config.yaml"
fi fi
# Execute postinstall to auto-populate config.yaml with missing values # Execute init script to auto-populate config.yaml with missing values
$PREFIX npm run postinstall $PREFIX npm run init
# Start the server # Start the server
exec $PREFIX node server.js --listen "$@" exec $PREFIX node server.js --listen "$@"
-1
View File
@@ -7,7 +7,6 @@
"": { "": {
"name": "sillytavern", "name": "sillytavern",
"version": "1.17.0", "version": "1.17.0",
"hasInstallScript": true,
"license": "AGPL-3.0", "license": "AGPL-3.0",
"dependencies": { "dependencies": {
"@adobe/css-tools": "^4.4.4", "@adobe/css-tools": "^4.4.4",
+1 -1
View File
@@ -115,6 +115,7 @@
}, },
"version": "1.17.0", "version": "1.17.0",
"scripts": { "scripts": {
"init": "node src/server-init.js",
"start": "node server.js", "start": "node server.js",
"debug": "node --inspect server.js", "debug": "node --inspect server.js",
"start:global": "node server.js --global", "start:global": "node server.js --global",
@@ -122,7 +123,6 @@
"start:deno": "deno run --allow-run --allow-net --allow-read --allow-write --allow-sys --allow-env server.js", "start:deno": "deno run --allow-run --allow-net --allow-read --allow-write --allow-sys --allow-env server.js",
"start:bun": "bun server.js", "start:bun": "bun server.js",
"start:no-csrf": "node server.js --disableCsrf", "start:no-csrf": "node server.js --disableCsrf",
"postinstall": "node post-install.js",
"lint": "eslint \"src/**/*.js\" \"public/**/*.js\" ./*.js", "lint": "eslint \"src/**/*.js\" \"public/**/*.js\" ./*.js",
"lint:fix": "eslint \"src/**/*.js\" \"public/**/*.js\" ./*.js --fix", "lint:fix": "eslint \"src/**/*.js\" \"public/**/*.js\" ./*.js --fix",
"plugins:update": "node plugins update", "plugins:update": "node plugins update",
+1 -1
View File
@@ -1,6 +1,6 @@
@echo off @echo off
pushd %~dp0 pushd %~dp0
call npm install --no-save --no-audit --no-fund --loglevel=error --no-progress --omit=dev call npm install --no-save --no-audit --no-fund --loglevel=error --no-progress --omit=dev --ignore-scripts
npm run start server.js %* npm run start server.js %*
pause pause
popd popd
+2 -2
View File
@@ -7,7 +7,7 @@ import process from 'node:process';
import yaml from 'yaml'; import yaml from 'yaml';
import chalk from 'chalk'; import chalk from 'chalk';
import { createRequire } from 'node:module'; import { createRequire } from 'node:module';
import { addMissingConfigValues } from './src/config-init.js'; import { addMissingConfigValues } from './config-init.js';
/** /**
* Colorizes console output. * Colorizes console output.
@@ -88,7 +88,7 @@ function createDefaultFiles() {
); );
} else { } else {
throw new Error( throw new Error(
'FATAL: Unexpected default file format in `post-install.js#createDefaultFiles()`.', 'FATAL: Unexpected default file format in `server-init.js#createDefaultFiles()`.',
); );
} }
} catch (error) { } catch (error) {
+2 -1
View File
@@ -10,7 +10,8 @@ fi
echo "Installing Node Modules..." echo "Installing Node Modules..."
export NODE_ENV=production export NODE_ENV=production
npm i --no-save --no-audit --no-fund --loglevel=error --no-progress --omit=dev npm install --no-save --no-audit --no-fund --loglevel=error --no-progress --omit=dev --ignore-scripts
npm run init
echo "Entering SillyTavern..." echo "Entering SillyTavern..."
node "server.js" "$@" node "server.js" "$@"