Add "setup" script

- install deps
- create env files
This commit is contained in:
schroda
2025-08-13 00:53:44 +02:00
parent 765799b236
commit 954fa4bf82
2 changed files with 42 additions and 3 deletions

View File

@@ -5,9 +5,11 @@
"type": "module",
"scripts": {
"ci": "yarn install --frozen-lockfile",
"dev": "vite",
"preview": "vite preview",
"build": "vite build",
"setup-env-files": "tsx tools/scripts/setupEnvFiles.ts",
"setup": "yarn ci && yarn setup-env-files",
"dev": "yarn setup && vite",
"preview": "yarn setup vite preview",
"build": "yarn setup vite build",
"test": "node -e \"console.log('imagine')\"",
"build-md5": "find build -type f | sort | xargs md5sum | awk '{ print $1 }' | tr -d '\n' | md5sum| awk '{ print $1 }' > buildZip/md5sum ",
"build-zip": "cd build && rev=$(git rev-list HEAD --count) && echo r$rev > revision && zip -9 -r ../buildZip/Suwayomi-WebUI-r$rev *",

View File

@@ -0,0 +1,37 @@
/*
* Copyright (C) Contributors to the Suwayomi project
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import fs from 'fs';
import * as path from 'path';
const filesToCreate: { id: string; templatePath: string; targetPath: string }[] = [
{
id: 'root env',
templatePath: path.resolve(import.meta.dirname, '../../.env.template'),
targetPath: path.resolve(import.meta.dirname, '../../.env'),
},
];
filesToCreate.forEach(({ id, templatePath, targetPath }) => {
if (!fs.existsSync(templatePath)) {
console.warn(
`(id= ${id}) .env.template not found. Cannot create .env file. (template: ${templatePath}, target: ${targetPath})`,
);
return;
}
if (fs.existsSync(targetPath)) {
console.log(
`(id= ${id}) .env file already exists. Skipping. (template: ${templatePath}, target: ${targetPath})`,
);
return;
}
fs.copyFileSync(templatePath, targetPath);
console.log(`(id= ${id}) .env file created from .env.template. (template: ${templatePath}, target: ${targetPath})`);
});