mirror of
https://github.com/tiennm99/miti99bot.git
synced 2026-10-04 18:13:44 +00:00
Replace pnpm-lock.yaml with package-lock.json. allowBuilds for esbuild becomes package.json#allowScripts. The Dockerfile installs with npm ci --omit=dev and no longer prepares pnpm through corepack; .npmrc keeps engine-strict, which npm honours natively. minimumReleaseAgeExclude is dropped rather than translated: pnpm's minimumReleaseAge was never set, so the 30-entry exclusion list had nothing to exclude from. Direct dependency versions resolve identically to the pnpm lockfile.
41 lines
1.5 KiB
JavaScript
41 lines
1.5 KiB
JavaScript
import {mkdir, writeFile} from 'node:fs/promises';
|
|
import path from 'node:path';
|
|
import {renderWheelGif} from '../src/render/render-gif.js';
|
|
import {parseRenderLocalArgs} from './render-local-args.js';
|
|
|
|
const usage = `Usage:
|
|
npm run render:local -- --option <text> --option <text> [options]
|
|
|
|
Options:
|
|
-o, --output <path> Output file (default: wheel.gif)
|
|
--option <text> Wheel option; repeat at least twice
|
|
--winner <index> Zero-based winner index (random when omitted)
|
|
--duration <ms> Spin duration, 3000-10000 (default: 6500)
|
|
--hold <ms> Winner hold, 500-2500 (default: 1200)
|
|
--fps <value> 12, 15, or 20 (default: 15)
|
|
--size <pixels> 384, 480, or 512 (default: 512)
|
|
--theme <name> classic, festival, or mono
|
|
--timeout <ms> Render timeout, minimum 7000 (default: 30000)
|
|
-h, --help Show this help`;
|
|
|
|
try {
|
|
const parsed = parseRenderLocalArgs(process.argv.slice(2));
|
|
if (parsed.help) {
|
|
console.log(usage);
|
|
process.exitCode = 0;
|
|
} else {
|
|
const output = path.resolve(parsed.output);
|
|
await mkdir(path.dirname(output), {recursive: true});
|
|
const result = await renderWheelGif(parsed.request, {
|
|
timeoutInMilliseconds: parsed.timeoutInMilliseconds,
|
|
});
|
|
await writeFile(output, result.buffer);
|
|
console.log(`${output} ${result.byteLength} bytes ${result.durationMs}ms`);
|
|
}
|
|
} catch (error) {
|
|
const message = error instanceof Error ? error.message : String(error);
|
|
console.error(`Unable to render GIF: ${message}\n\n${usage}`);
|
|
process.exitCode = 1;
|
|
}
|
|
|