feat(bake-sprite): end-to-end sprite-mode orchestrator + CLI dispatch

This commit is contained in:
Axel Meyer
2026-06-16 21:23:42 +02:00
parent d5fb03b8d0
commit 766c03c955
6 changed files with 209 additions and 4 deletions

View File

@@ -0,0 +1,33 @@
const { test } = require('node:test');
const assert = require('node:assert');
const fs = require('node:fs');
const path = require('node:path');
const os = require('node:os');
const { bake } = require('../src/bake');
const FRESH = path.resolve(__dirname, 'fixtures/sprite-fresh');
test('bake sprite: fresh bake of 4 fixture sprites', async (t) => {
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'bake-sprite-fresh-'));
t.after(() => fs.rmSync(tmp, { recursive: true, force: true }));
const result = await bake({
mode: 'sprite',
inDir: FRESH,
outDir: tmp,
atlasId: 'test',
padPx: 0,
});
assert.strictEqual(result.atlasId, 'test');
assert.strictEqual(result.spriteCount, 4);
// Outputs exist
assert.ok(fs.existsSync(path.join(tmp, 'test/sprites.diffuse.atlas.png')));
assert.ok(fs.existsSync(path.join(tmp, 'test/sprites.uv.json')));
assert.ok(fs.existsSync(path.join(tmp, 'test/sprites.atlas.lock.json')));
// UV-JSON has expected aliases
const uv = JSON.parse(fs.readFileSync(path.join(tmp, 'test/sprites.uv.json'), 'utf8'));
const aliases = Object.keys(uv.sprites).sort();
assert.deepStrictEqual(aliases, ['barrel_large', 'bed1', 'bench1', 'sack']);
});