mirror of
https://github.com/Momoko-Ayase/Senbei.git
synced 2026-11-24 02:52:47 +08:00
Add folder scanning, Android library and package recovery, and the localized desktop-style workbench. Keep browser-refused outputs in a fallback ZIP and include logs with folder and ZIP exports. Align the desktop and web modal transitions and polish the desktop About and legal dialogs.
47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
// Stage the static site: the files the page loads, and nothing else.
|
|
//
|
|
// node web/tools/stage.mjs <dist>
|
|
//
|
|
// Run after `wasm-pack build --target web --out-dir ../web/pkg`. The CI
|
|
// artifact and the release deployment are both made from this directory, so
|
|
// the list of what ships is here once.
|
|
|
|
import { cpSync, existsSync, mkdirSync, readdirSync } from 'node:fs';
|
|
import { fileURLToPath } from 'node:url';
|
|
import path from 'node:path';
|
|
|
|
const web = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
|
|
/** Paths under `web/` that make up the site. */
|
|
export function siteFiles() {
|
|
const top = readdirSync(web).filter(
|
|
(name) => name.endsWith('.js') || ['index.html', 'style.css', 'LICENSE'].includes(name),
|
|
);
|
|
const catalogs = readdirSync(path.join(web, 'i18n'))
|
|
.filter((name) => name.endsWith('.js'))
|
|
.map((name) => `i18n/${name}`);
|
|
const assets = readdirSync(path.join(web, 'assets')).map((name) => `assets/${name}`);
|
|
const engine = ['pkg/senbei_wasm.js', 'pkg/senbei_wasm_bg.wasm'];
|
|
return [...top, ...catalogs, ...assets, ...engine].sort();
|
|
}
|
|
|
|
function main() {
|
|
const dist = process.argv[2];
|
|
if (!dist) {
|
|
console.error('usage: stage.mjs <dist>');
|
|
process.exit(2);
|
|
}
|
|
for (const file of siteFiles()) {
|
|
const from = path.join(web, file);
|
|
if (!existsSync(from)) {
|
|
console.error(`${file} is missing; build senbei-wasm into web/pkg first`);
|
|
process.exit(1);
|
|
}
|
|
const to = path.join(dist, file);
|
|
mkdirSync(path.dirname(to), { recursive: true });
|
|
cpSync(from, to);
|
|
}
|
|
}
|
|
|
|
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) main();
|