Wire bake orchestrator and CLI
Connects scan + lock + pack + write into the full pipeline. CLI entry parses args, dispatches to bake(), prints summary or error. Five integration tests cover fresh bake, lock-aware ID preservation, deleted-tile tracking, oversize hard-fail, and bit-identical determinism across re-bakes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
48
bin/atlas-baker.js
Normal file
48
bin/atlas-baker.js
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env node
|
||||
// CLI entry. Parses args, dispatches to bake(), prints summary.
|
||||
|
||||
const { bake } = require('../src/bake');
|
||||
|
||||
function parseArgs(argv) {
|
||||
const opts = {};
|
||||
for (let i = 0; i < argv.length; i++) {
|
||||
const a = argv[i];
|
||||
const next = argv[i + 1];
|
||||
switch (a) {
|
||||
case '--in': opts.inDir = next; i++; break;
|
||||
case '--out': opts.outDir = next; i++; break;
|
||||
case '--atlas-id': opts.atlasId = next; i++; break;
|
||||
case '--tile-size':
|
||||
opts.tileSize = (next === 'auto') ? 'auto' : parseInt(next, 10);
|
||||
i++;
|
||||
break;
|
||||
case '--max-size': opts.maxSize = parseInt(next, 10); i++; break;
|
||||
case '--lock': opts.lockPath = next; i++; break;
|
||||
case '--blocks-sight-pattern':
|
||||
opts.blocksSightPattern = new RegExp(next); i++; break;
|
||||
case '--verbose': opts.verbose = true; break;
|
||||
default:
|
||||
console.error(`unknown arg: ${a}`);
|
||||
process.exit(2);
|
||||
}
|
||||
}
|
||||
return opts;
|
||||
}
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
const opts = parseArgs(process.argv.slice(2));
|
||||
const result = await bake(opts);
|
||||
console.log(
|
||||
`OK ${result.atlasId}: ${result.tileCount} tiles, `
|
||||
+ `${result.boundsW}x${result.boundsH} px atlas`
|
||||
);
|
||||
process.exit(0);
|
||||
} catch (err) {
|
||||
console.error('ERROR:', err.message);
|
||||
if (err.scanErrors) {
|
||||
for (const e of err.scanErrors) console.error(' ', e);
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user