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:
+1
-1
@@ -19,7 +19,7 @@ COPY --chown=node:node . ./
|
||||
|
||||
RUN \
|
||||
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?)
|
||||
# that must be present for Non-Root Mode and volumeless docker runs.
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
@echo off
|
||||
pushd %~dp0
|
||||
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 %*
|
||||
pause
|
||||
popd
|
||||
|
||||
+2
-1
@@ -20,7 +20,8 @@ if %errorlevel% neq 0 (
|
||||
)
|
||||
)
|
||||
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 %*
|
||||
:end
|
||||
pause
|
||||
|
||||
@@ -102,7 +102,8 @@ if %errorlevel% neq 0 (
|
||||
|
||||
echo Installing npm packages and starting server
|
||||
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 %*
|
||||
|
||||
:end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Function to handle startup logic (Config check + Postinstall + Start)
|
||||
# Function to handle startup logic (Config check + init + Start)
|
||||
start_sillytavern() {
|
||||
local PREFIX="$1"
|
||||
shift # Remove the first argument (PREFIX) so $@ contains the rest
|
||||
@@ -11,8 +11,8 @@ start_sillytavern() {
|
||||
$PREFIX cp "default/config.yaml" "config/config.yaml"
|
||||
fi
|
||||
|
||||
# Execute postinstall to auto-populate config.yaml with missing values
|
||||
$PREFIX npm run postinstall
|
||||
# Execute init script to auto-populate config.yaml with missing values
|
||||
$PREFIX npm run init
|
||||
|
||||
# Start the server
|
||||
exec $PREFIX node server.js --listen "$@"
|
||||
|
||||
Generated
-1
@@ -7,7 +7,6 @@
|
||||
"": {
|
||||
"name": "sillytavern",
|
||||
"version": "1.17.0",
|
||||
"hasInstallScript": true,
|
||||
"license": "AGPL-3.0",
|
||||
"dependencies": {
|
||||
"@adobe/css-tools": "^4.4.4",
|
||||
|
||||
+1
-1
@@ -115,6 +115,7 @@
|
||||
},
|
||||
"version": "1.17.0",
|
||||
"scripts": {
|
||||
"init": "node src/server-init.js",
|
||||
"start": "node server.js",
|
||||
"debug": "node --inspect server.js",
|
||||
"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:bun": "bun server.js",
|
||||
"start:no-csrf": "node server.js --disableCsrf",
|
||||
"postinstall": "node post-install.js",
|
||||
"lint": "eslint \"src/**/*.js\" \"public/**/*.js\" ./*.js",
|
||||
"lint:fix": "eslint \"src/**/*.js\" \"public/**/*.js\" ./*.js --fix",
|
||||
"plugins:update": "node plugins update",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@echo off
|
||||
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 %*
|
||||
pause
|
||||
popd
|
||||
|
||||
@@ -7,7 +7,7 @@ import process from 'node:process';
|
||||
import yaml from 'yaml';
|
||||
import chalk from 'chalk';
|
||||
import { createRequire } from 'node:module';
|
||||
import { addMissingConfigValues } from './src/config-init.js';
|
||||
import { addMissingConfigValues } from './config-init.js';
|
||||
|
||||
/**
|
||||
* Colorizes console output.
|
||||
@@ -88,7 +88,7 @@ function createDefaultFiles() {
|
||||
);
|
||||
} else {
|
||||
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) {
|
||||
@@ -10,7 +10,8 @@ fi
|
||||
|
||||
echo "Installing Node Modules..."
|
||||
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..."
|
||||
node "server.js" "$@"
|
||||
|
||||
Reference in New Issue
Block a user