32 lines
1.3 KiB
JavaScript
32 lines
1.3 KiB
JavaScript
import { readFileSync, readdirSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
|
|
const cbDir = 'tools/deck/cb';
|
|
const files = readdirSync(cbDir).filter((name) => name.endsWith('.mjs'));
|
|
const violations = [];
|
|
|
|
for (const file of files) {
|
|
const source = readFileSync(join(cbDir, file), 'utf8');
|
|
const matches = source.match(/["']\/ui\/[^"']*["']\s*\.\.\s*tostring\(/g) || [];
|
|
for (const match of matches) violations.push(`${file}: ${match}`);
|
|
}
|
|
|
|
const generator = readFileSync('tools/deck/gen-slaydeck.mjs', 'utf8');
|
|
if (!generator.includes('normalizeIntegerStrings(common)')) {
|
|
violations.push('gen-slaydeck.mjs: common.gamelogic integer-string normalization is missing');
|
|
}
|
|
|
|
const common = readFileSync('Global/common.gamelogic', 'utf8');
|
|
const commonIntegerDecimals = common.match(/(?<![0-9.])-?[0-9]+\.0+(?![0-9])/g) || [];
|
|
if (commonIntegerDecimals.length > 0) {
|
|
violations.push(`Global/common.gamelogic: integer decimal values ${commonIntegerDecimals.length}`);
|
|
}
|
|
|
|
if (violations.length > 0) {
|
|
console.error('UI path integer formatting violations:');
|
|
for (const violation of violations) console.error(`- ${violation}`);
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log(`integer format: UI path tostring violations 0, common integer decimals 0 (${files.length} modules checked)`);
|