mirror of
https://github.com/tiennm99/miti99bot.git
synced 2026-04-28 08:20:44 +00:00
1e01437766
Adds loldle module with classic-mode champion guessing. Ports comparison logic from tiennm99/loldle (lib/classic-mode.js) and bundles champion data from tiennm99/loldle-data. Adds GH Actions workflow that re-syncs champions.json on cross-repo dispatch from loldle-data. - Three public commands: /loldle, /loldle_giveup, /loldle_stats - Per-user daily state + streak stats in KV (3-day TTL on games) - champions-data.js wrapper sidesteps Node 24 / esbuild disagreement on JSON import attributes; generator script + npm run build:loldle-data - register script now tolerates missing .env.deploy (env-file-if-exists) so Workers Builds can inject env vars directly - fix(scripts): escape stray */ in migrate.js docstring that broke node - 16 new unit tests (compare, daily, lookup); dispatcher test updated for the new command set
28 lines
904 B
JavaScript
28 lines
904 B
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* @file build-loldle-data — wraps src/modules/loldle/champions.json
|
|
* as an ES module export to sidestep Node/esbuild disagreement on
|
|
* JSON import attributes (Node 24 requires `with { type: "json" }`,
|
|
* wrangler's bundled esbuild doesn't parse it yet).
|
|
*
|
|
* Run after any update to champions.json.
|
|
*/
|
|
|
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
import { resolve } from "node:path";
|
|
|
|
const root = resolve(import.meta.dirname, "..");
|
|
const src = resolve(root, "src/modules/loldle/champions.json");
|
|
const dst = resolve(root, "src/modules/loldle/champions-data.js");
|
|
|
|
const json = readFileSync(src, "utf8").trimEnd();
|
|
const out = [
|
|
"// Auto-generated from champions.json — do NOT edit by hand.",
|
|
"// Regenerate with: node scripts/build-loldle-data.js",
|
|
`export default ${json};`,
|
|
"",
|
|
].join("\n");
|
|
|
|
writeFileSync(dst, out);
|
|
console.log(`wrote ${dst}`);
|