From 4fa886be901738bb14ca01335832e364c43d85a5 Mon Sep 17 00:00:00 2001 From: Haoyu Xu Date: Tue, 17 Jan 2023 10:08:22 -0500 Subject: [PATCH] refactor(runner): rename preprocessing to runner and update directory structure --- .env | 14 +++++++------- README.md | 8 ++++---- lib/exec.js | 8 -------- {lib => libs}/alpha_composite.js | 0 {lib => libs}/assets_processor.js | 0 {lib => libs}/config.js | 0 {lib => libs}/content_processor.js | 0 {lib => libs}/directory.js | 0 {lib => libs}/env_generator.js | 0 libs/exec.js | 12 ++++++++++++ {lib => libs}/file.js | 0 {lib => libs}/initializer.js | 0 {lib => libs}/project_json.js | 0 {lib => libs}/yaml.js | 0 preprocessing.js => runner.js | 20 ++++++++++---------- vite.config.js | 2 +- 16 files changed, 34 insertions(+), 30 deletions(-) delete mode 100644 lib/exec.js rename {lib => libs}/alpha_composite.js (100%) rename {lib => libs}/assets_processor.js (100%) rename {lib => libs}/config.js (100%) rename {lib => libs}/content_processor.js (100%) rename {lib => libs}/directory.js (100%) rename {lib => libs}/env_generator.js (100%) create mode 100644 libs/exec.js rename {lib => libs}/file.js (100%) rename {lib => libs}/initializer.js (100%) rename {lib => libs}/project_json.js (100%) rename {lib => libs}/yaml.js (100%) rename preprocessing.js => runner.js (86%) diff --git a/.env b/.env index 0182e2a..e6c01f2 100644 --- a/.env +++ b/.env @@ -1,11 +1,11 @@ -VITE_TITLE="Arknights: Chongyue - 明日方舟:重岳" -VITE_FILENAME=dyn_illust_char_2024_chyue -VITE_LOGO_FILENAME=logo_sui -VITE_FALLBACK_FILENAME=char_2024_chyue_2 +VITE_TITLE="Arknights: Ch'en/Chen the Holungday - 明日方舟:假日威龙陈" +VITE_FILENAME=dyn_illust_char_1013_chen2 +VITE_LOGO_FILENAME=logo_rhodes_override +VITE_FALLBACK_FILENAME=char_1013_chen2_2 VITE_VIEWPORT_LEFT=0 VITE_VIEWPORT_RIGHT=0 -VITE_VIEWPORT_TOP=0 -VITE_VIEWPORT_BOTTOM=0 -VITE_INVERT_FILTER=true +VITE_VIEWPORT_TOP=1 +VITE_VIEWPORT_BOTTOM=1 +VITE_INVERT_FILTER=false VITE_IMAGE_WIDTH=2048 VITE_IMAGE_HEIGHT=2048 \ No newline at end of file diff --git a/README.md b/README.md index d82cec4..94fb976 100644 --- a/README.md +++ b/README.md @@ -11,19 +11,19 @@ A project that builds showcase webpage for Arknights Live2D-equipped operators. ### Command Line Tool ``` bash -$ O={operator_name} node preprocessing.js +$ O={operator_name} node runner.js To generate operator assets for showcase page ``` ``` bash -$ node preprocessing.js -a +$ node runner.js -a To generate all operator assets for showcase page ``` ``` bash -$ O={operator_name} node preprocessing.js -i +$ O={operator_name} node runner.js -i To initialize folder and config file for an operator ``` ``` bash -$ node preprocessing.js -d +$ node runner.js -d To generate directory.json ``` ``` bash diff --git a/lib/exec.js b/lib/exec.js deleted file mode 100644 index e5aebcc..0000000 --- a/lib/exec.js +++ /dev/null @@ -1,8 +0,0 @@ -import { execSync } from 'child_process' - -export default function (config) { - for (const [key, _] of Object.entries(config.operators)) { - if (key.startsWith('_')) break; - console.log(execSync(`O=${key} node preprocessing.js && O=${key} pnpm run build`).toString()); - } -} \ No newline at end of file diff --git a/lib/alpha_composite.js b/libs/alpha_composite.js similarity index 100% rename from lib/alpha_composite.js rename to libs/alpha_composite.js diff --git a/lib/assets_processor.js b/libs/assets_processor.js similarity index 100% rename from lib/assets_processor.js rename to libs/assets_processor.js diff --git a/lib/config.js b/libs/config.js similarity index 100% rename from lib/config.js rename to libs/config.js diff --git a/lib/content_processor.js b/libs/content_processor.js similarity index 100% rename from lib/content_processor.js rename to libs/content_processor.js diff --git a/lib/directory.js b/libs/directory.js similarity index 100% rename from lib/directory.js rename to libs/directory.js diff --git a/lib/env_generator.js b/libs/env_generator.js similarity index 100% rename from lib/env_generator.js rename to libs/env_generator.js diff --git a/libs/exec.js b/libs/exec.js new file mode 100644 index 0000000..45ccc3e --- /dev/null +++ b/libs/exec.js @@ -0,0 +1,12 @@ +import { execSync } from 'child_process' + +export function buildAll(config) { + for (const [key, _] of Object.entries(config.operators)) { + if (key.startsWith('_')) break; + console.log(execSync(`O=${key} node runner.js && O=${key} pnpm run build`).toString()); + } +} + +export function runDev(config) { + +} \ No newline at end of file diff --git a/lib/file.js b/libs/file.js similarity index 100% rename from lib/file.js rename to libs/file.js diff --git a/lib/initializer.js b/libs/initializer.js similarity index 100% rename from lib/initializer.js rename to libs/initializer.js diff --git a/lib/project_json.js b/libs/project_json.js similarity index 100% rename from lib/project_json.js rename to libs/project_json.js diff --git a/lib/yaml.js b/libs/yaml.js similarity index 100% rename from lib/yaml.js rename to libs/yaml.js diff --git a/preprocessing.js b/runner.js similarity index 86% rename from preprocessing.js rename to runner.js index a5e6378..996569c 100644 --- a/preprocessing.js +++ b/runner.js @@ -1,22 +1,22 @@ import assert from 'assert' -import getConfig from './lib/config.js' -import ProjectJson from './lib/project_json.js' -import EnvGenerator from './lib/env_generator.js' -import { write, rmdir, copy } from './lib/file.js' -import AssetsProcessor from './lib/assets_processor.js' +import getConfig from './libs/config.js' +import ProjectJson from './libs/project_json.js' +import EnvGenerator from './libs/env_generator.js' +import { write, rmdir, copy } from './libs/file.js' +import AssetsProcessor from './libs/assets_processor.js' import path from 'path' import { fileURLToPath } from 'url' -import init from './lib/initializer.js' -import directory from './lib/directory.js' -import exec from './lib/exec.js' +import init from './libs/initializer.js' +import directory from './libs/directory.js' +import { buildAll } from './libs/exec.js' let __dirname __dirname = __dirname || path.dirname(fileURLToPath(import.meta.url)) const config = getConfig(__dirname) let mode = null -const OPERATOR_NAME = process.env.O; const op = process.argv[2] +const OPERATOR_NAME = process.env.O || process.argv[3]; if (process.argv[1].endsWith('vite.js')) { mode = "VITE" @@ -26,7 +26,7 @@ if (process.argv[1].endsWith('vite.js')) { switch (op) { case '-a': - exec(config) + buildAll(config) process.exit(0) case '-d': directory(config, __dirname) diff --git a/vite.config.js b/vite.config.js index 3784388..96dceab 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,6 +1,6 @@ import { defineConfig } from 'vite' import path from 'path' -import data from './preprocessing' +import data from './runner' // https://vitejs.dev/config/ export default defineConfig({