feat(aklive2d): add directory building

- rename __dirname to __projectRoot
- rename runner.js to aklive2d.js
- add npm scripts
- add directory building commands (dev/build)
This commit is contained in:
Haoyu Xu
2023-02-20 18:15:16 -05:00
parent 0e4017351d
commit 6307bfd017
17 changed files with 389 additions and 735 deletions

View File

@@ -11,35 +11,35 @@ A project that builds showcase webpage for Arknights Live2D-equipped operators.
### Command Line Tool ### Command Line Tool
``` bash ``` bash
$ node runner.js generate {operator_name} $ npm run generate {operator_name}
To generate operator assets for showcase page To generate operator assets for showcase page
``` ```
``` bash ``` bash
$ node runner.js dev {operator_name} $ npm run dev {operator_name}
Live showcase page server for development Live showcase page server for development
``` ```
``` bash ``` bash
$ node runner.js build {operator_name} $ npm run build {operator_name}
Build showcase webpage for an operator Build showcase webpage for an operator
``` ```
``` bash ``` bash
$ node runner.js build-all $ npm run build-all
To generate all operator assets for showcase page To generate all operator assets for showcase page
``` ```
``` bash ``` bash
$ node runner.js init {operator_name} $ npm run init {operator_name}
To initialize folder and config file for an operator To initialize folder and config file for an operator
``` ```
``` bash ``` bash
$ node runner.js readme {operator_name} $ npm run readme {operator_name}
To add operator info to README.md To add operator info to README.md
``` ```
``` bash ``` bash
$ node runner.js directory $ npm run directory
To generate directory.json To generate directory.json
``` ```
``` bash ``` bash
$ node runner.js charword $ npm run charword
To generate the latest charword_table.json To generate the latest charword_table.json
``` ```
### Webpage & JavaScript ### Webpage & JavaScript

View File

@@ -14,10 +14,10 @@ import Background from './libs/background.js'
import CharwordTable from './libs/charword_table.js'; import CharwordTable from './libs/charword_table.js';
async function main() { async function main() {
global.__dirname = path.dirname(fileURLToPath(import.meta.url)) global.__projetRoot = path.dirname(fileURLToPath(import.meta.url))
global.__config = { global.__config = {
...getConfig(), ...getConfig(),
version: readSync(path.join(__dirname, 'Version')) version: readSync(path.join(__projetRoot, 'Version'))
} }
const op = process.argv[2] const op = process.argv[2]
@@ -37,7 +37,9 @@ async function main() {
*/ */
switch (op) { switch (op) {
case 'directory': case 'directory':
process.exit(0) assert(OPERATOR_NAMES.length !== 0, 'Please set a mode for Directory.')
fork(path.join(__projetRoot, 'vite.js'), [op, OPERATOR_NAMES])
return
case 'build-all': case 'build-all':
for (const [key, _] of Object.entries(__config.operators)) { for (const [key, _] of Object.entries(__config.operators)) {
OPERATOR_NAMES.push(key) OPERATOR_NAMES.push(key)
@@ -53,8 +55,8 @@ async function main() {
assert(OPERATOR_NAMES.length !== 0, 'Please set the operator name.') assert(OPERATOR_NAMES.length !== 0, 'Please set the operator name.')
for (const OPERATOR_NAME of OPERATOR_NAMES) { for (const OPERATOR_NAME of OPERATOR_NAMES) {
const OPERATOR_SOURCE_FOLDER = path.join(__dirname, __config.folder.operator) const OPERATOR_SOURCE_FOLDER = path.join(__projetRoot, __config.folder.operator)
const OPERATOR_RELEASE_FOLDER = path.join(__dirname, __config.folder.release, OPERATOR_NAME) const OPERATOR_RELEASE_FOLDER = path.join(__projetRoot, __config.folder.release, OPERATOR_NAME)
const SHOWCASE_PUBLIC_ASSSETS_FOLDER = path.join(OPERATOR_RELEASE_FOLDER, "assets") const SHOWCASE_PUBLIC_ASSSETS_FOLDER = path.join(OPERATOR_RELEASE_FOLDER, "assets")
const EXTRACTED_FOLDER = path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME, 'extracted') const EXTRACTED_FOLDER = path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME, 'extracted')
const VOICE_FOLDERS = __config.folder.voice.sub.map((sub) => path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME, __config.folder.voice.main, sub.name)) const VOICE_FOLDERS = __config.folder.voice.sub.map((sub) => path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME, __config.folder.voice.main, sub.name))
@@ -158,7 +160,7 @@ async function main() {
writeSync((new EnvGenerator(OPERATOR_NAME, { writeSync((new EnvGenerator(OPERATOR_NAME, {
backgrounds backgrounds
})).generate(), envPath) })).generate(), envPath)
fork(path.join(__dirname, 'vite.js'), [op, OPERATOR_NAME]) fork(path.join(__projetRoot, 'vite.js'), [op, OPERATOR_NAME])
} }
} }

View File

@@ -1,27 +0,0 @@
import path from 'path'
import { parse } from 'yaml'
import fs from 'fs'
function read_yaml(file_dir) {
const include = {
identify: value => value.startsWith('!include'),
tag: '!include',
resolve(str) {
const dir = path.resolve(BASEDIR, str)
const data = read_yaml(dir)
return data
}
}
const file = fs.readFileSync(file_dir, 'utf8')
return parse(file, {
customTags: [include],
})
}
const BASEDIR = path.resolve(__dirname, '..')
const CONFIG = read_yaml(path.join(BASEDIR, 'config.yaml'))
export default {
basedir: BASEDIR,
...CONFIG
}

View File

@@ -1,23 +0,0 @@
{
"name": "directory",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.6.1",
"yaml": "^2.2.1"
},
"devDependencies": {
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
"@vitejs/plugin-react-swc": "^3.0.0",
"vite": "^4.0.0"
}
}

571
directory/pnpm-lock.yaml generated
View File

@@ -1,571 +0,0 @@
lockfileVersion: 5.4
specifiers:
'@types/react': ^18.0.26
'@types/react-dom': ^18.0.9
'@vitejs/plugin-react-swc': ^3.0.0
react: ^18.2.0
react-dom: ^18.2.0
react-router-dom: ^6.6.1
vite: ^4.0.0
yaml: ^2.2.1
dependencies:
react: 18.2.0
react-dom: 18.2.0_react@18.2.0
react-router-dom: 6.6.1_biqbaboplfbrettd7655fr4n2y
yaml: 2.2.1
devDependencies:
'@types/react': 18.0.26
'@types/react-dom': 18.0.10
'@vitejs/plugin-react-swc': 3.0.1_vite@4.0.3
vite: 4.0.3
packages:
/@esbuild/android-arm/0.16.12:
resolution: {integrity: sha512-CTWgMJtpCyCltrvipZrrcjjRu+rzm6pf9V8muCsJqtKujR3kPmU4ffbckvugNNaRmhxAF1ZI3J+0FUIFLFg8KA==}
engines: {node: '>=12'}
cpu: [arm]
os: [android]
requiresBuild: true
dev: true
optional: true
/@esbuild/android-arm64/0.16.12:
resolution: {integrity: sha512-0LacmiIW+X0/LOLMZqYtZ7d4uY9fxYABAYhSSOu+OGQVBqH4N5eIYgkT7bBFnR4Nm3qo6qS3RpHKVrDASqj/uQ==}
engines: {node: '>=12'}
cpu: [arm64]
os: [android]
requiresBuild: true
dev: true
optional: true
/@esbuild/android-x64/0.16.12:
resolution: {integrity: sha512-sS5CR3XBKQXYpSGMM28VuiUnbX83Z+aWPZzClW+OB2JquKqxoiwdqucJ5qvXS8pM6Up3RtJfDnRQZkz3en2z5g==}
engines: {node: '>=12'}
cpu: [x64]
os: [android]
requiresBuild: true
dev: true
optional: true
/@esbuild/darwin-arm64/0.16.12:
resolution: {integrity: sha512-Dpe5hOAQiQRH20YkFAg+wOpcd4PEuXud+aGgKBQa/VriPJA8zuVlgCOSTwna1CgYl05lf6o5els4dtuyk1qJxQ==}
engines: {node: '>=12'}
cpu: [arm64]
os: [darwin]
requiresBuild: true
dev: true
optional: true
/@esbuild/darwin-x64/0.16.12:
resolution: {integrity: sha512-ApGRA6X5txIcxV0095X4e4KKv87HAEXfuDRcGTniDWUUN+qPia8sl/BqG/0IomytQWajnUn4C7TOwHduk/FXBQ==}
engines: {node: '>=12'}
cpu: [x64]
os: [darwin]
requiresBuild: true
dev: true
optional: true
/@esbuild/freebsd-arm64/0.16.12:
resolution: {integrity: sha512-AMdK2gA9EU83ccXCWS1B/KcWYZCj4P3vDofZZkl/F/sBv/fphi2oUqUTox/g5GMcIxk8CF1CVYTC82+iBSyiUg==}
engines: {node: '>=12'}
cpu: [arm64]
os: [freebsd]
requiresBuild: true
dev: true
optional: true
/@esbuild/freebsd-x64/0.16.12:
resolution: {integrity: sha512-KUKB9w8G/xaAbD39t6gnRBuhQ8vIYYlxGT2I+mT6UGRnCGRr1+ePFIGBQmf5V16nxylgUuuWVW1zU2ktKkf6WQ==}
engines: {node: '>=12'}
cpu: [x64]
os: [freebsd]
requiresBuild: true
dev: true
optional: true
/@esbuild/linux-arm/0.16.12:
resolution: {integrity: sha512-vhDdIv6z4eL0FJyNVfdr3C/vdd/Wc6h1683GJsFoJzfKb92dU/v88FhWdigg0i6+3TsbSDeWbsPUXb4dif2abg==}
engines: {node: '>=12'}
cpu: [arm]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@esbuild/linux-arm64/0.16.12:
resolution: {integrity: sha512-29HXMLpLklDfmw7T2buGqq3HImSUaZ1ArmrPOMaNiZZQptOSZs32SQtOHEl8xWX5vfdwZqrBfNf8Te4nArVzKQ==}
engines: {node: '>=12'}
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@esbuild/linux-ia32/0.16.12:
resolution: {integrity: sha512-JFDuNDTTfgD1LJg7wHA42o2uAO/9VzHYK0leAVnCQE/FdMB599YMH73ux+nS0xGr79pv/BK+hrmdRin3iLgQjg==}
engines: {node: '>=12'}
cpu: [ia32]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@esbuild/linux-loong64/0.16.12:
resolution: {integrity: sha512-xTGzVPqm6WKfCC0iuj1fryIWr1NWEM8DMhAIo+4rFgUtwy/lfHl+Obvus4oddzRDbBetLLmojfVZGmt/g/g+Rw==}
engines: {node: '>=12'}
cpu: [loong64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@esbuild/linux-mips64el/0.16.12:
resolution: {integrity: sha512-zI1cNgHa3Gol+vPYjIYHzKhU6qMyOQrvZ82REr5Fv7rlh5PG6SkkuCoH7IryPqR+BK2c/7oISGsvPJPGnO2bHQ==}
engines: {node: '>=12'}
cpu: [mips64el]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@esbuild/linux-ppc64/0.16.12:
resolution: {integrity: sha512-/C8OFXExoMmvTDIOAM54AhtmmuDHKoedUd0Otpfw3+AuuVGemA1nQK99oN909uZbLEU6Bi+7JheFMG3xGfZluQ==}
engines: {node: '>=12'}
cpu: [ppc64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@esbuild/linux-riscv64/0.16.12:
resolution: {integrity: sha512-qeouyyc8kAGV6Ni6Isz8hUsKMr00EHgVwUKWNp1r4l88fHEoNTDB8mmestvykW6MrstoGI7g2EAsgr0nxmuGYg==}
engines: {node: '>=12'}
cpu: [riscv64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@esbuild/linux-s390x/0.16.12:
resolution: {integrity: sha512-s9AyI/5vz1U4NNqnacEGFElqwnHusWa81pskAf8JNDM2eb6b2E6PpBmT8RzeZv6/TxE6/TADn2g9bb0jOUmXwQ==}
engines: {node: '>=12'}
cpu: [s390x]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@esbuild/linux-x64/0.16.12:
resolution: {integrity: sha512-e8YA7GQGLWhvakBecLptUiKxOk4E/EPtSckS1i0MGYctW8ouvNUoh7xnU15PGO2jz7BYl8q1R6g0gE5HFtzpqQ==}
engines: {node: '>=12'}
cpu: [x64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@esbuild/netbsd-x64/0.16.12:
resolution: {integrity: sha512-z2+kUxmOqBS+6SRVd57iOLIHE8oGOoEnGVAmwjm2aENSP35HPS+5cK+FL1l+rhrsJOFIPrNHqDUNechpuG96Sg==}
engines: {node: '>=12'}
cpu: [x64]
os: [netbsd]
requiresBuild: true
dev: true
optional: true
/@esbuild/openbsd-x64/0.16.12:
resolution: {integrity: sha512-PAonw4LqIybwn2/vJujhbg1N9W2W8lw9RtXIvvZoyzoA/4rA4CpiuahVbASmQohiytRsixbNoIOUSjRygKXpyA==}
engines: {node: '>=12'}
cpu: [x64]
os: [openbsd]
requiresBuild: true
dev: true
optional: true
/@esbuild/sunos-x64/0.16.12:
resolution: {integrity: sha512-+wr1tkt1RERi+Zi/iQtkzmMH4nS8+7UIRxjcyRz7lur84wCkAITT50Olq/HiT4JN2X2bjtlOV6vt7ptW5Gw60Q==}
engines: {node: '>=12'}
cpu: [x64]
os: [sunos]
requiresBuild: true
dev: true
optional: true
/@esbuild/win32-arm64/0.16.12:
resolution: {integrity: sha512-XEjeUSHmjsAOJk8+pXJu9pFY2O5KKQbHXZWQylJzQuIBeiGrpMeq9sTVrHefHxMOyxUgoKQTcaTS+VK/K5SviA==}
engines: {node: '>=12'}
cpu: [arm64]
os: [win32]
requiresBuild: true
dev: true
optional: true
/@esbuild/win32-ia32/0.16.12:
resolution: {integrity: sha512-eRKPM7e0IecUAUYr2alW7JGDejrFJXmpjt4MlfonmQ5Rz9HWpKFGCjuuIRgKO7W9C/CWVFXdJ2GjddsBXqQI4A==}
engines: {node: '>=12'}
cpu: [ia32]
os: [win32]
requiresBuild: true
dev: true
optional: true
/@esbuild/win32-x64/0.16.12:
resolution: {integrity: sha512-iPYKN78t3op2+erv2frW568j1q0RpqX6JOLZ7oPPaAV1VaF7dDstOrNw37PVOYoTWE11pV4A1XUitpdEFNIsPg==}
engines: {node: '>=12'}
cpu: [x64]
os: [win32]
requiresBuild: true
dev: true
optional: true
/@remix-run/router/1.2.1:
resolution: {integrity: sha512-XiY0IsyHR+DXYS5vBxpoBe/8veTeoRpMHP+vDosLZxL5bnpetzI0igkxkLZS235ldLzyfkxF+2divEwWHP3vMQ==}
engines: {node: '>=14'}
dev: false
/@swc/core-darwin-arm64/1.3.24:
resolution: {integrity: sha512-rR+9UpWm+fGXcipsjCst2hIL1GYIbo0YTLhJZWdIpQD6KRHHJMFXiydMgQQkDj2Ml7HpqUVgxj6m4ZWYL8b0OA==}
engines: {node: '>=10'}
cpu: [arm64]
os: [darwin]
requiresBuild: true
dev: true
optional: true
/@swc/core-darwin-x64/1.3.24:
resolution: {integrity: sha512-px+5vkGtgPH0m3FkkTBHynlRdS5rRz+lK+wiXIuBZFJSySWFl6RkKbvwkD+sf0MpazQlqwlv/rTOGJBw6oDffg==}
engines: {node: '>=10'}
cpu: [x64]
os: [darwin]
requiresBuild: true
dev: true
optional: true
/@swc/core-linux-arm-gnueabihf/1.3.24:
resolution: {integrity: sha512-jLs8ZOdTV4UW4J12E143QJ4mOMONQtqgAnuhBbRuWFzQ3ny1dfoC3P1jNWAJ2Xi59XdxAIXn0PggPNH4Kh34kw==}
engines: {node: '>=10'}
cpu: [arm]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@swc/core-linux-arm64-gnu/1.3.24:
resolution: {integrity: sha512-A/v0h70BekrwGpp1DlzIFGcHQ3QQ2PexXcnnuIBZeMc9gNmHlcZmg3EcwAnaUDiokhNuSUFA/wV94yk1OqmSkw==}
engines: {node: '>=10'}
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@swc/core-linux-arm64-musl/1.3.24:
resolution: {integrity: sha512-pbc9eArWPTiMrbpS/pJo0IiQNAKAQBcBIDjWBGP1tcw2iDXYLw4bruwz9kI/VjakbshWb8MoE4T5ClkeuULvSw==}
engines: {node: '>=10'}
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@swc/core-linux-x64-gnu/1.3.24:
resolution: {integrity: sha512-pP5pOLlY1xd352qo7rTlpVPUI9/9VhOd4b3Lk+LzfZDq9bTL2NDlGfyrPiwa5DGHMSzrugH56K2J68eutkxYVA==}
engines: {node: '>=10'}
cpu: [x64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@swc/core-linux-x64-musl/1.3.24:
resolution: {integrity: sha512-phNbP7zGp+Wcyxq1Qxlpe5KkxO7WLT2kVQUC7aDFGlVdCr+xdXsfH1MzheHtnr0kqTVQX1aiM8XXXHfFxR0oNA==}
engines: {node: '>=10'}
cpu: [x64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@swc/core-win32-arm64-msvc/1.3.24:
resolution: {integrity: sha512-qhbiJTWAOqyR+K9xnGmCkOWSz2EmWpDBstEJCEOTc6FZiEdbiTscDmqTcMbCKaTHGu8t+6erVA4t65/Eg6uWPA==}
engines: {node: '>=10'}
cpu: [arm64]
os: [win32]
requiresBuild: true
dev: true
optional: true
/@swc/core-win32-ia32-msvc/1.3.24:
resolution: {integrity: sha512-JfghIlscE4Rz+Lc08lSoDh+R0cWxrISed5biogFfE6vZqhaDnw3E5Qshqw7O3pIaiq8L2u1nmzuyP581ZmpbRA==}
engines: {node: '>=10'}
cpu: [ia32]
os: [win32]
requiresBuild: true
dev: true
optional: true
/@swc/core-win32-x64-msvc/1.3.24:
resolution: {integrity: sha512-3AmJRr0hwciwDBbzUNqaftvppzS8v9X/iv/Wl7YaVLBVpPfQvaZzfqLycvNMGLZb5vIKXR/u58txg3dRBGsJtw==}
engines: {node: '>=10'}
cpu: [x64]
os: [win32]
requiresBuild: true
dev: true
optional: true
/@swc/core/1.3.24:
resolution: {integrity: sha512-QMOTd0AgiUT3K1crxLRqd3gw0f3FC8hhH1vvlIlryvYqU4c+FJ/T2G4ZhMKLxQlZ/jX6Rhk0gKINZRBxy2GFyQ==}
engines: {node: '>=10'}
hasBin: true
requiresBuild: true
optionalDependencies:
'@swc/core-darwin-arm64': 1.3.24
'@swc/core-darwin-x64': 1.3.24
'@swc/core-linux-arm-gnueabihf': 1.3.24
'@swc/core-linux-arm64-gnu': 1.3.24
'@swc/core-linux-arm64-musl': 1.3.24
'@swc/core-linux-x64-gnu': 1.3.24
'@swc/core-linux-x64-musl': 1.3.24
'@swc/core-win32-arm64-msvc': 1.3.24
'@swc/core-win32-ia32-msvc': 1.3.24
'@swc/core-win32-x64-msvc': 1.3.24
dev: true
/@types/prop-types/15.7.5:
resolution: {integrity: sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==}
dev: true
/@types/react-dom/18.0.10:
resolution: {integrity: sha512-E42GW/JA4Qv15wQdqJq8DL4JhNpB3prJgjgapN3qJT9K2zO5IIAQh4VXvCEDupoqAwnz0cY4RlXeC/ajX5SFHg==}
dependencies:
'@types/react': 18.0.26
dev: true
/@types/react/18.0.26:
resolution: {integrity: sha512-hCR3PJQsAIXyxhTNSiDFY//LhnMZWpNNr5etoCqx/iUfGc5gXWtQR2Phl908jVR6uPXacojQWTg4qRpkxTuGug==}
dependencies:
'@types/prop-types': 15.7.5
'@types/scheduler': 0.16.2
csstype: 3.1.1
dev: true
/@types/scheduler/0.16.2:
resolution: {integrity: sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==}
dev: true
/@vitejs/plugin-react-swc/3.0.1_vite@4.0.3:
resolution: {integrity: sha512-3GQ2oruZO9j8dSHcI0MUeOZQBhjYyDQsF/pKY4Px+CJxn0M16OhgFeEzUjeuwci4zhhjoNIDE9aFNaV5GMQ09g==}
peerDependencies:
vite: ^4
dependencies:
'@swc/core': 1.3.24
vite: 4.0.3
dev: true
/csstype/3.1.1:
resolution: {integrity: sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw==}
dev: true
/esbuild/0.16.12:
resolution: {integrity: sha512-eq5KcuXajf2OmivCl4e89AD3j8fbV+UTE9vczEzq5haA07U9oOTzBWlh3+6ZdjJR7Rz2QfWZ2uxZyhZxBgJ4+g==}
engines: {node: '>=12'}
hasBin: true
requiresBuild: true
optionalDependencies:
'@esbuild/android-arm': 0.16.12
'@esbuild/android-arm64': 0.16.12
'@esbuild/android-x64': 0.16.12
'@esbuild/darwin-arm64': 0.16.12
'@esbuild/darwin-x64': 0.16.12
'@esbuild/freebsd-arm64': 0.16.12
'@esbuild/freebsd-x64': 0.16.12
'@esbuild/linux-arm': 0.16.12
'@esbuild/linux-arm64': 0.16.12
'@esbuild/linux-ia32': 0.16.12
'@esbuild/linux-loong64': 0.16.12
'@esbuild/linux-mips64el': 0.16.12
'@esbuild/linux-ppc64': 0.16.12
'@esbuild/linux-riscv64': 0.16.12
'@esbuild/linux-s390x': 0.16.12
'@esbuild/linux-x64': 0.16.12
'@esbuild/netbsd-x64': 0.16.12
'@esbuild/openbsd-x64': 0.16.12
'@esbuild/sunos-x64': 0.16.12
'@esbuild/win32-arm64': 0.16.12
'@esbuild/win32-ia32': 0.16.12
'@esbuild/win32-x64': 0.16.12
dev: true
/fsevents/2.3.2:
resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
os: [darwin]
requiresBuild: true
dev: true
optional: true
/function-bind/1.1.1:
resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==}
dev: true
/has/1.0.3:
resolution: {integrity: sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==}
engines: {node: '>= 0.4.0'}
dependencies:
function-bind: 1.1.1
dev: true
/is-core-module/2.11.0:
resolution: {integrity: sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==}
dependencies:
has: 1.0.3
dev: true
/js-tokens/4.0.0:
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
dev: false
/loose-envify/1.4.0:
resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==}
hasBin: true
dependencies:
js-tokens: 4.0.0
dev: false
/nanoid/3.3.4:
resolution: {integrity: sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==}
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true
dev: true
/path-parse/1.0.7:
resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==}
dev: true
/picocolors/1.0.0:
resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==}
dev: true
/postcss/8.4.20:
resolution: {integrity: sha512-6Q04AXR1212bXr5fh03u8aAwbLxAQNGQ/Q1LNa0VfOI06ZAlhPHtQvE4OIdpj4kLThXilalPnmDSOD65DcHt+g==}
engines: {node: ^10 || ^12 || >=14}
dependencies:
nanoid: 3.3.4
picocolors: 1.0.0
source-map-js: 1.0.2
dev: true
/react-dom/18.2.0_react@18.2.0:
resolution: {integrity: sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==}
peerDependencies:
react: ^18.2.0
dependencies:
loose-envify: 1.4.0
react: 18.2.0
scheduler: 0.23.0
dev: false
/react-router-dom/6.6.1_biqbaboplfbrettd7655fr4n2y:
resolution: {integrity: sha512-u+8BKUtelStKbZD5UcY0NY90WOzktrkJJhyhNg7L0APn9t1qJNLowzrM9CHdpB6+rcPt6qQrlkIXsTvhuXP68g==}
engines: {node: '>=14'}
peerDependencies:
react: '>=16.8'
react-dom: '>=16.8'
dependencies:
'@remix-run/router': 1.2.1
react: 18.2.0
react-dom: 18.2.0_react@18.2.0
react-router: 6.6.1_react@18.2.0
dev: false
/react-router/6.6.1_react@18.2.0:
resolution: {integrity: sha512-YkvlYRusnI/IN0kDtosUCgxqHeulN5je+ew8W+iA1VvFhf86kA+JEI/X/8NqYcr11hCDDp906S+SGMpBheNeYQ==}
engines: {node: '>=14'}
peerDependencies:
react: '>=16.8'
dependencies:
'@remix-run/router': 1.2.1
react: 18.2.0
dev: false
/react/18.2.0:
resolution: {integrity: sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==}
engines: {node: '>=0.10.0'}
dependencies:
loose-envify: 1.4.0
dev: false
/resolve/1.22.1:
resolution: {integrity: sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==}
hasBin: true
dependencies:
is-core-module: 2.11.0
path-parse: 1.0.7
supports-preserve-symlinks-flag: 1.0.0
dev: true
/rollup/3.9.0:
resolution: {integrity: sha512-nGGylpmblyjTpF4lEUPgmOw6OVxRvnI6Iuuh6Lz4O/X66cVOX1XJSsqP1YamxQ+mPuFE7qJxLFDSCk8rNv5dDw==}
engines: {node: '>=14.18.0', npm: '>=8.0.0'}
hasBin: true
optionalDependencies:
fsevents: 2.3.2
dev: true
/scheduler/0.23.0:
resolution: {integrity: sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==}
dependencies:
loose-envify: 1.4.0
dev: false
/source-map-js/1.0.2:
resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==}
engines: {node: '>=0.10.0'}
dev: true
/supports-preserve-symlinks-flag/1.0.0:
resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}
engines: {node: '>= 0.4'}
dev: true
/vite/4.0.3:
resolution: {integrity: sha512-HvuNv1RdE7deIfQb8mPk51UKjqptO/4RXZ5yXSAvurd5xOckwS/gg8h9Tky3uSbnjYTgUm0hVCet1cyhKd73ZA==}
engines: {node: ^14.18.0 || >=16.0.0}
hasBin: true
peerDependencies:
'@types/node': '>= 14'
less: '*'
sass: '*'
stylus: '*'
sugarss: '*'
terser: ^5.4.0
peerDependenciesMeta:
'@types/node':
optional: true
less:
optional: true
sass:
optional: true
stylus:
optional: true
sugarss:
optional: true
terser:
optional: true
dependencies:
esbuild: 0.16.12
postcss: 8.4.20
resolve: 1.22.1
rollup: 3.9.0
optionalDependencies:
fsevents: 2.3.2
dev: true
/yaml/2.2.1:
resolution: {integrity: sha512-e0WHiYql7+9wr4cWMx3TVQrNwejKaEe7/rHNmQmqRjazfOP5W8PB6Jpebb5o6fIapbz9o9+2ipcaTM2ZwDI6lw==}
engines: {node: '>= 14'}
dev: false

View File

@@ -1,25 +0,0 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import path from 'path'
import config from './config'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
build: {
outDir: path.resolve(config.basedir, config.folder.release),
assetsDir: config.folder.directory,
emptyOutDir: false,
rollupOptions: {
output: {
manualChunks: {
},
}
}
},
})

View File

@@ -3,16 +3,16 @@ import { appendSync, readSync } from './file.js'
export function appendReadme(operatorName) { export function appendReadme(operatorName) {
const operatorConfig = __config.operators[operatorName] const operatorConfig = __config.operators[operatorName]
const projectJson = JSON.parse(readSync(path.join(__dirname, __config.folder.operator, operatorName, 'project.json'))) const projectJson = JSON.parse(readSync(path.join(__projetRoot, __config.folder.operator, operatorName, 'project.json')))
appendSync( appendSync(
`\n| ${operatorConfig.title.split(' - ')[0].split('Arknights: ')[1]} | [Link](https://arknights.halyul.dev/${operatorConfig.link}/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=${projectJson.workshopid}) |`, `\n| ${operatorConfig.title.split(' - ')[0].split('Arknights: ')[1]} | [Link](https://arknights.halyul.dev/${operatorConfig.link}/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=${projectJson.workshopid}) |`,
path.join(__dirname, 'README.md') path.join(__projetRoot, 'README.md')
) )
} }
export function appendMainConfig(operatorName) { export function appendMainConfig(operatorName) {
appendSync( appendSync(
`\n ${operatorName}: !include config/${operatorName}.yaml`, `\n ${operatorName}: !include config/${operatorName}.yaml`,
path.join(__dirname, 'config.yaml') path.join(__projetRoot, 'config.yaml')
) )
} }

View File

@@ -8,7 +8,7 @@ export default class AssetsProcessor {
#operatorName #operatorName
constructor(operatorName) { constructor(operatorName) {
this.#operatorSourceFolder = path.join(__dirname, __config.folder.operator) this.#operatorSourceFolder = path.join(__projetRoot, __config.folder.operator)
this.#alphaCompositer = new AlphaComposite() this.#alphaCompositer = new AlphaComposite()
this.#operatorName = operatorName this.#operatorName = operatorName
} }

View File

@@ -8,7 +8,7 @@ export default class Background {
#files #files
constructor() { constructor() {
this.#backgroundFolder = path.join(__dirname, __config.folder.operator, __config.folder.share, __config.folder.background); this.#backgroundFolder = path.join(__projetRoot, __config.folder.operator, __config.folder.share, __config.folder.background);
this.#extractFolder = path.join(this.#backgroundFolder, 'extracted'); this.#extractFolder = path.join(this.#backgroundFolder, 'extracted');
} }

View File

@@ -18,7 +18,7 @@ const NICKNAME = {
export default class CharwordTable { export default class CharwordTable {
#operatorIDs = Object.values(__config.operators).map(operator => { return this.#getOperatorId(operator) }) #operatorIDs = Object.values(__config.operators).map(operator => { return this.#getOperatorId(operator) })
#charwordTablePath = path.join(__dirname, __config.folder.operator, __config.folder.share) #charwordTablePath = path.join(__projetRoot, __config.folder.operator, __config.folder.share)
#charwordTableFile = path.join(this.#charwordTablePath, 'charword_table.json') #charwordTableFile = path.join(this.#charwordTablePath, 'charword_table.json')
#charwordTable = JSON.parse(readSync(this.#charwordTableFile)) || { #charwordTable = JSON.parse(readSync(this.#charwordTableFile)) || {
config: { config: {
@@ -134,10 +134,10 @@ export default class CharwordTable {
console.log(`charword_table_${region}.json is updated.`) console.log(`charword_table_${region}.json is updated.`)
// remove old file // remove old file
const files = readdirSync(path.join(__dirname, __config.folder.operator, __config.folder.share)) const files = readdirSync(path.join(__projetRoot, __config.folder.operator, __config.folder.share))
for (const file of files) { for (const file of files) {
if (file.startsWith(`charword_table_${region}`) && file !== path.basename(filepath)) { if (file.startsWith(`charword_table_${region}`) && file !== path.basename(filepath)) {
rm(path.join(__dirname, __config.folder.operator, __config.folder.share, file)) rm(path.join(__projetRoot, __config.folder.operator, __config.folder.share, file))
} }
} }
return data return data
@@ -214,10 +214,10 @@ export default class CharwordTable {
console.log(`charword_table_${region}.json is updated.`) console.log(`charword_table_${region}.json is updated.`)
// remove old file // remove old file
const files = readdirSync(path.join(__dirname, __config.folder.operator, __config.folder.share)) const files = readdirSync(path.join(__projetRoot, __config.folder.operator, __config.folder.share))
for (const file of files) { for (const file of files) {
if (file.startsWith(`charword_table_${region}`) && file !== path.basename(filepath)) { if (file.startsWith(`charword_table_${region}`) && file !== path.basename(filepath)) {
rm(path.join(__dirname, __config.folder.operator, __config.folder.share, file)) rm(path.join(__projetRoot, __config.folder.operator, __config.folder.share, file))
} }
} }
output.data = data output.data = data
@@ -232,10 +232,10 @@ export default class CharwordTable {
console.log(`handbook_info_table_${region}.json is updated.`) console.log(`handbook_info_table_${region}.json is updated.`)
// remove old file // remove old file
const files = readdirSync(path.join(__dirname, __config.folder.operator, __config.folder.share)) const files = readdirSync(path.join(__projetRoot, __config.folder.operator, __config.folder.share))
for (const file of files) { for (const file of files) {
if (file.startsWith(`handbook_info_table_${region}`) && file !== path.basename(handbookFilepath)) { if (file.startsWith(`handbook_info_table_${region}`) && file !== path.basename(handbookFilepath)) {
rm(path.join(__dirname, __config.folder.operator, __config.folder.share, file)) rm(path.join(__projetRoot, __config.folder.operator, __config.folder.share, file))
} }
} }
output.handbook = data output.handbook = data

View File

@@ -2,5 +2,5 @@ import path from 'path'
import { read } from './yaml.js' import { read } from './yaml.js'
export default function () { export default function () {
return read(path.join(__dirname, 'config.yaml')) return read(path.join(__projetRoot, 'config.yaml'))
} }

View File

@@ -2,8 +2,8 @@ import path from 'path'
import { writeSync, copy, rmdir } from './file.js' import { writeSync, copy, rmdir } from './file.js'
export default function () { export default function () {
const targetFolder = path.join(__dirname, __config.folder.release, __config.folder.directory); const targetFolder = path.join(__projetRoot, __config.folder.release, __config.folder.directory);
const sourceFolder = path.join(__dirname, __config.folder.operator); const sourceFolder = path.join(__projetRoot, __config.folder.operator);
rmdir(targetFolder); rmdir(targetFolder);
const filesToCopy = []; const filesToCopy = [];
const directoryJson = [] const directoryJson = []

View File

@@ -9,9 +9,9 @@ export default function init(operatorName, extractedDir) {
mkdir(dir) mkdir(dir)
}) })
const date = new Date() const date = new Date()
const template = readYAML(path.join(__dirname, 'config', '_template.yaml')) const template = readYAML(path.join(__projetRoot, 'config', '_template.yaml'))
template.link = operatorName template.link = operatorName
template.date = `${date.getFullYear()}/${(date.getMonth() + 1).toString().padStart(2, '0') }` template.date = `${date.getFullYear()}/${(date.getMonth() + 1).toString().padStart(2, '0') }`
writeSync(stringify(template), path.join(__dirname, 'config', `${operatorName}.yaml`)) writeSync(stringify(template), path.join(__projetRoot, 'config', `${operatorName}.yaml`))
appendMainConfig(operatorName) appendMainConfig(operatorName)
} }

View File

@@ -13,7 +13,7 @@ export default class ProjectJson {
constructor(operatorName, operatorShareFolder, assets) { constructor(operatorName, operatorShareFolder, assets) {
this.#operatorName = operatorName this.#operatorName = operatorName
this.#operatorSourceFolder = path.join(__dirname, __config.folder.operator) this.#operatorSourceFolder = path.join(__projetRoot, __config.folder.operator)
this.#operatorShareFolder = operatorShareFolder this.#operatorShareFolder = operatorShareFolder
this.#assets = assets this.#assets = assets
} }
@@ -44,7 +44,7 @@ export default class ProjectJson {
return matcher.result return matcher.result
} }
} }
this.#template = readYAML(path.join(__dirname, 'config', '_project_json.yaml'), [match]) this.#template = readYAML(path.join(__projetRoot, 'config', '_project_json.yaml'), [match])
this.#process() this.#process()
return this.#json return this.#json
} }

View File

@@ -4,16 +4,28 @@
"version": "0.0.0", "version": "0.0.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "generate": "node aklive2d generate",
"build": "vite build", "dev": "node aklive2d dev",
"preview": "vite preview" "build": "node aklive2d build",
"build-all": "node aklive2d build-all",
"init": "node aklive2d init",
"readme": "node aklive2d readme",
"directory": "node aklive2d directory",
"charword": "node aklive2d charword"
}, },
"devDependencies": { "devDependencies": {
"vite": "^4.0.0" "@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@vitejs/plugin-react-swc": "^3.2.0",
"vite": "^4.1.3"
}, },
"dependencies": { "dependencies": {
"dotenv": "^16.0.3", "dotenv": "^16.0.3",
"node-fetch": "^3.3.0", "node-fetch": "^3.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-refresh": "^0.14.0",
"react-router-dom": "^6.8.1",
"sharp": "^0.31.3", "sharp": "^0.31.3",
"yaml": "^2.2.1" "yaml": "^2.2.1"
} }

251
pnpm-lock.yaml generated
View File

@@ -1,20 +1,34 @@
lockfileVersion: 5.4 lockfileVersion: 5.4
specifiers: specifiers:
'@types/react': ^18.0.28
'@types/react-dom': ^18.0.11
'@vitejs/plugin-react-swc': ^3.2.0
dotenv: ^16.0.3 dotenv: ^16.0.3
node-fetch: ^3.3.0 node-fetch: ^3.3.0
react: ^18.2.0
react-dom: ^18.2.0
react-refresh: ^0.14.0
react-router-dom: ^6.8.1
sharp: ^0.31.3 sharp: ^0.31.3
vite: ^4.0.0 vite: ^4.1.3
yaml: ^2.2.1 yaml: ^2.2.1
dependencies: dependencies:
dotenv: 16.0.3 dotenv: 16.0.3
node-fetch: 3.3.0 node-fetch: 3.3.0
react: 18.2.0
react-dom: 18.2.0_react@18.2.0
react-refresh: 0.14.0
react-router-dom: 6.8.1_biqbaboplfbrettd7655fr4n2y
sharp: 0.31.3 sharp: 0.31.3
yaml: 2.2.1 yaml: 2.2.1
devDependencies: devDependencies:
vite: 4.0.4 '@types/react': 18.0.28
'@types/react-dom': 18.0.11
'@vitejs/plugin-react-swc': 3.2.0_vite@4.1.3
vite: 4.1.3
packages: packages:
@@ -216,6 +230,149 @@ packages:
dev: true dev: true
optional: true optional: true
/@remix-run/router/1.3.2:
resolution: {integrity: sha512-t54ONhl/h75X94SWsHGQ4G/ZrCEguKSRQr7DrjTciJXW0YU1QhlwYeycvK5JgkzlxmvrK7wq1NB/PLtHxoiDcA==}
engines: {node: '>=14'}
dev: false
/@swc/core-darwin-arm64/1.3.35:
resolution: {integrity: sha512-zQUFkHx4gZpu0uo2IspvPnKsz8bsdXd5bC33xwjtoAI1cpLerDyqo4v2zIahEp+FdKZjyVsLHtfJiQiA1Qka3A==}
engines: {node: '>=10'}
cpu: [arm64]
os: [darwin]
requiresBuild: true
dev: true
optional: true
/@swc/core-darwin-x64/1.3.35:
resolution: {integrity: sha512-oOSkSGWtALovaw22lNevKD434OQTPf8X+dVPvPMrJXJpJ34dWDlFWpLntoc+arvKLNZ7LQmTuk8rR1hkrAY7cw==}
engines: {node: '>=10'}
cpu: [x64]
os: [darwin]
requiresBuild: true
dev: true
optional: true
/@swc/core-linux-arm-gnueabihf/1.3.35:
resolution: {integrity: sha512-Yie8k00O6O8BCATS/xeKStquV4OYSskUGRDXBQVDw1FrE23PHaSeHCgg4q6iNZjJzXCOJbaTCKnYoIDn9DMf7A==}
engines: {node: '>=10'}
cpu: [arm]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@swc/core-linux-arm64-gnu/1.3.35:
resolution: {integrity: sha512-Zlv3WHa/4x2p51HSvjUWXHfSe1Gl2prqImUZJc8NZOlj75BFzVuR0auhQ+LbwvIQ3gaA1LODX9lyS9wXL3yjxA==}
engines: {node: '>=10'}
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@swc/core-linux-arm64-musl/1.3.35:
resolution: {integrity: sha512-u6tCYsrSyZ8U+4jLMA/O82veBfLy2aUpn51WxQaeH7wqZGy9TGSJXoO8vWxARQ6b72vjsnKDJHP4MD8hFwcctg==}
engines: {node: '>=10'}
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@swc/core-linux-x64-gnu/1.3.35:
resolution: {integrity: sha512-Dtxf2IbeH7XlNhP1Qt2/MvUPkpEbn7hhGfpSRs4ot8D3Vf5QEX4S/QtC1OsFWuciiYgHAT1Ybjt4xZic9DSkmA==}
engines: {node: '>=10'}
cpu: [x64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@swc/core-linux-x64-musl/1.3.35:
resolution: {integrity: sha512-4XavNJ60GprjpTiESCu5daJUnmErixPAqDitJSMu4TV32LNIE8G00S9pDLXinDTW1rgcGtQdq1NLkNRmwwovtg==}
engines: {node: '>=10'}
cpu: [x64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@swc/core-win32-arm64-msvc/1.3.35:
resolution: {integrity: sha512-dNGfKCUSX2M4qVyaS80Lyos0FkXyHRCvrdQ2Y4Hrg3FVokiuw3yY6fLohpUfQ5ws3n2A39dh7jGDeh34+l0sGA==}
engines: {node: '>=10'}
cpu: [arm64]
os: [win32]
requiresBuild: true
dev: true
optional: true
/@swc/core-win32-ia32-msvc/1.3.35:
resolution: {integrity: sha512-ChuPSrDR+JBf7S7dEKPicnG8A3bM0uWPsW2vG+V2wH4iNfNxKVemESHosmYVeEZXqMpomNMvLyeHep1rjRsc0Q==}
engines: {node: '>=10'}
cpu: [ia32]
os: [win32]
requiresBuild: true
dev: true
optional: true
/@swc/core-win32-x64-msvc/1.3.35:
resolution: {integrity: sha512-/RvphT4WfuGfIK84Ha0dovdPrKB1bW/mc+dtdmhv2E3EGkNc5FoueNwYmXWRimxnU7X0X7IkcRhyKB4G5DeAmg==}
engines: {node: '>=10'}
cpu: [x64]
os: [win32]
requiresBuild: true
dev: true
optional: true
/@swc/core/1.3.35:
resolution: {integrity: sha512-KmiBin0XSVzJhzX19zTiCqmLslZ40Cl7zqskJcTDeIrRhfgKdiAsxzYUanJgMJIRjYtl9Kcg1V/Ip2o2wL8v3w==}
engines: {node: '>=10'}
requiresBuild: true
optionalDependencies:
'@swc/core-darwin-arm64': 1.3.35
'@swc/core-darwin-x64': 1.3.35
'@swc/core-linux-arm-gnueabihf': 1.3.35
'@swc/core-linux-arm64-gnu': 1.3.35
'@swc/core-linux-arm64-musl': 1.3.35
'@swc/core-linux-x64-gnu': 1.3.35
'@swc/core-linux-x64-musl': 1.3.35
'@swc/core-win32-arm64-msvc': 1.3.35
'@swc/core-win32-ia32-msvc': 1.3.35
'@swc/core-win32-x64-msvc': 1.3.35
dev: true
/@types/prop-types/15.7.5:
resolution: {integrity: sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==}
dev: true
/@types/react-dom/18.0.11:
resolution: {integrity: sha512-O38bPbI2CWtgw/OoQoY+BRelw7uysmXbWvw3nLWO21H1HSh+GOlqPuXshJfjmpNlKiiSDG9cc1JZAaMmVdcTlw==}
dependencies:
'@types/react': 18.0.28
dev: true
/@types/react/18.0.28:
resolution: {integrity: sha512-RD0ivG1kEztNBdoAK7lekI9M+azSnitIn85h4iOiaLjaTrMjzslhaqCGaI4IyCJ1RljWiLCEu4jyrLLgqxBTew==}
dependencies:
'@types/prop-types': 15.7.5
'@types/scheduler': 0.16.2
csstype: 3.1.1
dev: true
/@types/scheduler/0.16.2:
resolution: {integrity: sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==}
dev: true
/@vitejs/plugin-react-swc/3.2.0_vite@4.1.3:
resolution: {integrity: sha512-IcBoXL/mcH7JdQr/nfDlDwTdIaH8Rg7LpfQDF4nAht+juHWIuv6WhpKPCSfY4+zztAaB07qdBoFz1XCZsgo3pQ==}
peerDependencies:
vite: ^4
dependencies:
'@swc/core': 1.3.35
vite: 4.1.3
dev: true
/base64-js/1.5.1: /base64-js/1.5.1:
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
dev: false dev: false
@@ -265,6 +422,10 @@ packages:
color-string: 1.9.1 color-string: 1.9.1
dev: false dev: false
/csstype/3.1.1:
resolution: {integrity: sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw==}
dev: true
/data-uri-to-buffer/4.0.1: /data-uri-to-buffer/4.0.1:
resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==} resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==}
engines: {node: '>= 12'} engines: {node: '>= 12'}
@@ -397,6 +558,17 @@ packages:
has: 1.0.3 has: 1.0.3
dev: true dev: true
/js-tokens/4.0.0:
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
dev: false
/loose-envify/1.4.0:
resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==}
hasBin: true
dependencies:
js-tokens: 4.0.0
dev: false
/lru-cache/6.0.0: /lru-cache/6.0.0:
resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==}
engines: {node: '>=10'} engines: {node: '>=10'}
@@ -409,8 +581,8 @@ packages:
engines: {node: '>=10'} engines: {node: '>=10'}
dev: false dev: false
/minimist/1.2.7: /minimist/1.2.8:
resolution: {integrity: sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==} resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==}
dev: false dev: false
/mkdirp-classic/0.5.3: /mkdirp-classic/0.5.3:
@@ -427,8 +599,8 @@ packages:
resolution: {integrity: sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==} resolution: {integrity: sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==}
dev: false dev: false
/node-abi/3.31.0: /node-abi/3.33.0:
resolution: {integrity: sha512-eSKV6s+APenqVh8ubJyiu/YhZgxQpGP66ntzUb3lY1xB9ukSRaGnx0AIxI+IM+1+IVYC1oWobgG5L3Lt9ARykQ==} resolution: {integrity: sha512-7GGVawqyHF4pfd0YFybhv/eM9JwTtPqx0mAanQ146O3FlSh3pA24zf9IRQTOsfTSqXTNzPSP5iagAJ94jjuVog==}
engines: {node: '>=10'} engines: {node: '>=10'}
dependencies: dependencies:
semver: 7.3.8 semver: 7.3.8
@@ -483,10 +655,10 @@ packages:
detect-libc: 2.0.1 detect-libc: 2.0.1
expand-template: 2.0.3 expand-template: 2.0.3
github-from-package: 0.0.0 github-from-package: 0.0.0
minimist: 1.2.7 minimist: 1.2.8
mkdirp-classic: 0.5.3 mkdirp-classic: 0.5.3
napi-build-utils: 1.0.2 napi-build-utils: 1.0.2
node-abi: 3.31.0 node-abi: 3.33.0
pump: 3.0.0 pump: 3.0.0
rc: 1.2.8 rc: 1.2.8
simple-get: 4.0.1 simple-get: 4.0.1
@@ -507,10 +679,55 @@ packages:
dependencies: dependencies:
deep-extend: 0.6.0 deep-extend: 0.6.0
ini: 1.3.8 ini: 1.3.8
minimist: 1.2.7 minimist: 1.2.8
strip-json-comments: 2.0.1 strip-json-comments: 2.0.1
dev: false dev: false
/react-dom/18.2.0_react@18.2.0:
resolution: {integrity: sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==}
peerDependencies:
react: ^18.2.0
dependencies:
loose-envify: 1.4.0
react: 18.2.0
scheduler: 0.23.0
dev: false
/react-refresh/0.14.0:
resolution: {integrity: sha512-wViHqhAd8OHeLS/IRMJjTSDHF3U9eWi62F/MledQGPdJGDhodXJ9PBLNGr6WWL7qlH12Mt3TyTpbS+hGXMjCzQ==}
engines: {node: '>=0.10.0'}
dev: false
/react-router-dom/6.8.1_biqbaboplfbrettd7655fr4n2y:
resolution: {integrity: sha512-67EXNfkQgf34P7+PSb6VlBuaacGhkKn3kpE51+P6zYSG2kiRoumXEL6e27zTa9+PGF2MNXbgIUHTVlleLbIcHQ==}
engines: {node: '>=14'}
peerDependencies:
react: '>=16.8'
react-dom: '>=16.8'
dependencies:
'@remix-run/router': 1.3.2
react: 18.2.0
react-dom: 18.2.0_react@18.2.0
react-router: 6.8.1_react@18.2.0
dev: false
/react-router/6.8.1_react@18.2.0:
resolution: {integrity: sha512-Jgi8BzAJQ8MkPt8ipXnR73rnD7EmZ0HFFb7jdQU24TynGW1Ooqin2KVDN9voSC+7xhqbbCd2cjGUepb6RObnyg==}
engines: {node: '>=14'}
peerDependencies:
react: '>=16.8'
dependencies:
'@remix-run/router': 1.3.2
react: 18.2.0
dev: false
/react/18.2.0:
resolution: {integrity: sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==}
engines: {node: '>=0.10.0'}
dependencies:
loose-envify: 1.4.0
dev: false
/readable-stream/3.6.0: /readable-stream/3.6.0:
resolution: {integrity: sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==} resolution: {integrity: sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==}
engines: {node: '>= 6'} engines: {node: '>= 6'}
@@ -529,8 +746,8 @@ packages:
supports-preserve-symlinks-flag: 1.0.0 supports-preserve-symlinks-flag: 1.0.0
dev: true dev: true
/rollup/3.10.0: /rollup/3.17.2:
resolution: {integrity: sha512-JmRYz44NjC1MjVF2VKxc0M1a97vn+cDxeqWmnwyAF4FvpjK8YFdHpaqvQB+3IxCvX05vJxKZkoMDU8TShhmJVA==} resolution: {integrity: sha512-qMNZdlQPCkWodrAZ3qnJtvCAl4vpQ8q77uEujVCCbC/6CLB7Lcmvjq7HyiOSnf4fxTT9XgsE36oLHJBH49xjqA==}
engines: {node: '>=14.18.0', npm: '>=8.0.0'} engines: {node: '>=14.18.0', npm: '>=8.0.0'}
hasBin: true hasBin: true
optionalDependencies: optionalDependencies:
@@ -541,6 +758,12 @@ packages:
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
dev: false dev: false
/scheduler/0.23.0:
resolution: {integrity: sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==}
dependencies:
loose-envify: 1.4.0
dev: false
/semver/7.3.8: /semver/7.3.8:
resolution: {integrity: sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==} resolution: {integrity: sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==}
engines: {node: '>=10'} engines: {node: '>=10'}
@@ -633,8 +856,8 @@ packages:
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
dev: false dev: false
/vite/4.0.4: /vite/4.1.3:
resolution: {integrity: sha512-xevPU7M8FU0i/80DMR+YhgrzR5KS2ORy1B4xcX/cXLsvnUWvfHuqMmVU6N0YiJ4JWGRJJsLCgjEzKjG9/GKoSw==} resolution: {integrity: sha512-0Zqo4/Fr/swSOBmbl+HAAhOjrqNwju+yTtoe4hQX9UsARdcuc9njyOdr6xU0DDnV7YP0RT6mgTTOiRtZgxfCxA==}
engines: {node: ^14.18.0 || >=16.0.0} engines: {node: ^14.18.0 || >=16.0.0}
hasBin: true hasBin: true
peerDependencies: peerDependencies:
@@ -661,7 +884,7 @@ packages:
esbuild: 0.16.17 esbuild: 0.16.17
postcss: 8.4.21 postcss: 8.4.21
resolve: 1.22.1 resolve: 1.22.1
rollup: 3.10.0 rollup: 3.17.2
optionalDependencies: optionalDependencies:
fsevents: 2.3.2 fsevents: 2.3.2
dev: true dev: true

179
vite.js
View File

@@ -4,76 +4,139 @@ import { createServer, build, loadEnv } from 'vite'
import getConfig from './libs/config.js' import getConfig from './libs/config.js'
import { rm } from './libs/file.js' import { rm } from './libs/file.js'
global.__dirname = path.dirname(fileURLToPath(import.meta.url)) global.__projetRoot = path.dirname(fileURLToPath(import.meta.url))
const MODE = process.argv[2]
export default class Vite { export default class Vite {
#operatorName = process.argv[3] #globalConfig = getConfig()
#config = getConfig()
dev() {
; (async () => {
this.#loadEnvFromEnvFile('development')
const server = await createServer(this.#viteConfig)
await server.listen()
server.printUrls()
})()
}
build() {
; (async () => {
this.#loadEnvFromEnvFile('production')
console.log("Building", this.#operatorName, "...")
await build({
...this.#viteConfig,
logLevel: 'silent',
})
})()
}
#loadEnvFromEnvFile(mode) {
const envPath = path.join(__dirname, this.#config.folder.operator, this.#operatorName)
process.env = { ...loadEnv(mode, envPath) }
rm(path.join(envPath, '.env'))
}
get #viteConfig() {
return {
base: "",
publicDir: path.resolve(__dirname, this.#config.folder.release, this.#operatorName),
root: path.resolve(__dirname),
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'!': path.resolve(__dirname, this.#config.folder.operator, this.#operatorName),
},
},
build: {
outDir: path.resolve(__dirname, this.#config.folder.release, this.#operatorName),
emptyOutDir: false,
chunkSizeWarningLimit: 10000,
},
}
}
}
function main() {
const MODE = process.argv[2]
const vite = new Vite()
async start() {
let result;
switch (MODE) { switch (MODE) {
case 'dev': case 'dev':
vite.dev() case 'build':
case 'build-all':
result = this.operator()
break
case 'directory':
result = await this.directory()
break
default:
return
}
const mode = result.mode
const envPath = result.envPath
const viteConfig = result.viteConfig
switch (mode) {
case 'dev':
this.#dev(envPath, viteConfig)
break break
case 'build': case 'build':
case 'build-all': case 'build-all':
vite.build() this.#build(envPath, viteConfig)
break break
default: default:
break break
} }
} }
#dev(envPath, viteConfig) {
; (async () => {
this.#loadEnvFromEnvFile('development', envPath)
const server = await createServer(viteConfig)
await server.listen()
server.printUrls()
})()
}
#build(envPath, viteConfig) {
; (async () => {
this.#loadEnvFromEnvFile('production', envPath)
await build({
...viteConfig,
logLevel: 'silent',
})
})()
}
operator() {
const operatorName = process.argv[3]
const viteConfig = {
base: "",
publicDir: path.resolve(__projetRoot, this.#globalConfig.folder.release, operatorName),
root: path.resolve(__projetRoot),
server: {
host: '0.0.0.0',
},
resolve: {
alias: {
'@': path.resolve(__projetRoot, './src'),
'!': path.resolve(__projetRoot, this.#globalConfig.folder.operator, operatorName),
},
},
build: {
outDir: path.resolve(__projetRoot, this.#globalConfig.folder.release, operatorName),
emptyOutDir: false,
chunkSizeWarningLimit: 10000,
},
}
const envPath = path.join(__projetRoot, this.#globalConfig.folder.operator, operatorName)
return {
mode: MODE,
envPath,
viteConfig
}
}
async directory() {
const { default: react } = await import('@vitejs/plugin-react-swc')
const directoryDir = path.resolve(__projetRoot, 'directory')
const mode = process.argv[3]
const viteConfig = {
base: "",
plugins: [react()],
publicDir: path.resolve(__projetRoot, this.#globalConfig.folder.release),
root: directoryDir,
server: {
host: '0.0.0.0',
},
resolve: {
alias: {
'@': path.resolve(directoryDir, './src'),
'!': path.resolve(__projetRoot, this.#globalConfig.folder.release, this.#globalConfig.folder.directory),
},
},
build: {
outDir: path.resolve(__projetRoot, this.#globalConfig.folder.release),
emptyOutDir: false,
chunkSizeWarningLimit: 10000,
rollupOptions: {
output: {
manualChunks: {
},
}
}
},
}
const envPath = directoryDir
return {
mode,
envPath,
viteConfig
}
}
#loadEnvFromEnvFile(mode, envPath) {
process.env = { ...loadEnv(mode, envPath) }
rm(path.join(envPath, '.env'))
}
}
async function main() {
const vite = new Vite()
await vite.start()
}
main() main()