mirror of
https://github.com/FluxaMedia/fluxa-desktop.git
synced 2026-07-31 14:09:11 +00:00
.gitignore had a blanket "scripts/" entry from the repo's initial commit. Since then, package.json's build/typecheck scripts started depending on scripts/gen-core-methods.mjs, which was never actually committed — it only worked locally because the file happened to exist on disk. Every fresh CI checkout (and any new clone) failed at `npm run build` with MODULE_NOT_FOUND. Track gen-core-methods.mjs and bump-version.sh; neither contains secrets or machine-specific content.
42 lines
1.6 KiB
JavaScript
42 lines
1.6 KiB
JavaScript
import { readFileSync, writeFileSync, existsSync } from 'node:fs';
|
|
import { fileURLToPath } from 'node:url';
|
|
import path from 'node:path';
|
|
|
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
const ffiPath = path.resolve(here, '../../fluxa-core/src/ffi.rs');
|
|
const outPath = path.resolve(here, '../src/core/coreMethods.ts');
|
|
|
|
if (!existsSync(ffiPath)) {
|
|
console.error(`gen-core-methods: ${ffiPath} not found (fluxa-core must be checked out next to fluxa-desktop, same as the Cargo path dependency)`);
|
|
process.exit(1);
|
|
}
|
|
|
|
const source = readFileSync(ffiPath, 'utf8');
|
|
const methods = [...source.matchAll(/^ {8}"([A-Za-z.]+)" =>/gm)].map((m) => m[1]);
|
|
const unique = [...new Set(methods)].sort();
|
|
|
|
if (unique.length !== methods.length) {
|
|
const dupes = methods.filter((m, i) => methods.indexOf(m) !== i);
|
|
console.error(`gen-core-methods: duplicate method arms in ffi.rs: ${[...new Set(dupes)].join(', ')}`);
|
|
process.exit(1);
|
|
}
|
|
if (unique.length === 0) {
|
|
console.error('gen-core-methods: extracted zero methods from ffi.rs, extraction pattern is broken');
|
|
process.exit(1);
|
|
}
|
|
|
|
const body = `export const CORE_METHODS = [
|
|
${unique.map((m) => ` '${m}',`).join('\n')}
|
|
] as const;
|
|
|
|
export type CoreMethod = (typeof CORE_METHODS)[number];
|
|
`;
|
|
|
|
const header = `// Generated by scripts/gen-core-methods.mjs from fluxa-core/src/ffi.rs — do not edit.\n`;
|
|
const next = header + body;
|
|
|
|
const current = existsSync(outPath) ? readFileSync(outPath, 'utf8') : '';
|
|
if (current !== next) {
|
|
writeFileSync(outPath, next);
|
|
console.log(`gen-core-methods: wrote ${unique.length} methods to src/core/coreMethods.ts`);
|
|
}
|