Add "setup" script
- install deps - create env files
This commit is contained in:
@@ -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 *",
|
||||
|
||||
37
tools/scripts/setupEnvFiles.ts
Normal file
37
tools/scripts/setupEnvFiles.ts
Normal 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})`);
|
||||
});
|
||||
Reference in New Issue
Block a user