Move single-use rule sets to their call sites

rules/ exists so several deploys can declare the same rules; a set with
one caller is just indirection. Only gen10Modelslike has two (smogon xy/
and ps ani/), so it stays. The live sets move into assets.build.ts and
smogon.build.ts, and the three deprecated sets move into the commented-out
block that was their only reference, which empties minisprites.ts and
social.ts.

Declarations are copied verbatim, so no rule key moves: a full dry run
reports 7748 up to date, 0 would run, and all three deploy trees come out
byte-identical.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MQicnpaee6kQXGG7uVExLS
This commit is contained in:
Christopher Monsanto
2026-08-21 01:09:57 -04:00
parent 45adc3579f
commit ed199c3768
5 changed files with 78 additions and 112 deletions

View File

@@ -1,8 +1,7 @@
import {gen6Padded, itemPadded} from './rules/minisprites.ts';
import {Manifest, itemspritecopy, spritecopy} from './rules/publish.ts';
import {rule} from './tools/build/artifact.ts';
import {spriteglob} from './tools/build/helpers.ts';
import {forEachRule, rule} from './tools/build/artifact.ts';
import {compresspng, pad, spriteglob} from './tools/build/helpers.ts';
import {deploy} from './tools/deploy/api.ts';
// The tar root maps onto the served tree: sprites/x is served at
@@ -54,11 +53,18 @@ deploy(async ctx => {
ctx.write('__meta/spritesheet-css-url.txt', `${SERVED}/${ASSETS}/spritesheet-${ch}.css\n`);
});
// Forumsprites: padded minisprites under stamped names, with the
// Forumsprites: uniform-size minisprites under stamped names, with the
// unhashed -> url mapping in a manifest.
let forumItems = itemPadded();
let forumG6 = gen6Padded();
let forumItems = forEachRule('src/minisprites/items/*.png', {
display: 'pad item minisprite %f',
cmds: [pad({w: 24, h: 24}), compresspng({config: 'MINISPRITE'})],
}, '%b');
let forumG6 = forEachRule('src/minisprites/pokemon/gen6/*.png', {
display: 'pad g6 minisprite %f',
cmds: [pad({w: 40, h: 30}), compresspng({config: 'MINISPRITE'})],
}, '%b');
deploy(async ctx => {
let manifest = new Manifest(ctx, SERVED);

View File

@@ -1,33 +0,0 @@
import {type Artifact, forEachRule} from '../tools/build/artifact.ts';
import {compresspng, pad, trimimg} from '../tools/build/helpers.ts';
// Uniform size minisprites
export function gen6Padded(): Artifact[] {
return forEachRule('src/minisprites/pokemon/gen6/*.png', {
display: 'pad g6 minisprite %f',
cmds: [pad({w: 40, h: 30}), compresspng({config: 'MINISPRITE'})],
}, '%b');
}
export function itemPadded(): Artifact[] {
return forEachRule('src/minisprites/items/*.png', {
display: 'pad item minisprite %f',
cmds: [pad({w: 24, h: 24}), compresspng({config: 'MINISPRITE'})],
}, '%b');
}
export function gen6Trimmed(): Artifact[] {
return forEachRule('src/minisprites/pokemon/gen6/*.png', {
display: 'trim g6 minisprite %f',
cmds: [trimimg(), compresspng({config: 'MINISPRITE'})],
}, '%b');
}
export function itemTrimmed(): Artifact[] {
return forEachRule('src/minisprites/items/*.png', {
display: 'trim item minisprite %f',
cmds: [trimimg(), compresspng({config: 'MINISPRITE'})],
}, '%b');
}

View File

@@ -1,21 +1,7 @@
import {type Artifact, forEachRule} from '../tools/build/artifact.ts';
// Gen 9
export function gen9Modelslike(): Artifact[] {
return forEachRule('src/gen9species/*.png', {
display: '96x96 %f',
// TODO, add customizable compression for gif
// ... or investigate using webp instead of both png/gif here
cmds: [
'magick convert %f -trim +repage -resize 90x90 %o',
'gifsicle -O3 -b %o',
],
}, '%B.gif');
}
// Gen 10
// Shared by the smogon xy/ set and the PS ani/ set.
export function gen10Modelslike(): Artifact[] {
return forEachRule('src/champions/*.png', {
@@ -28,14 +14,3 @@ export function gen10Modelslike(): Artifact[] {
],
}, '%B.gif');
}
// Gen 5 CAPs...
export function gen5Gifs(): Artifact[] {
return forEachRule('src/sprites/gen5/*.png', [
// TODO, add customizable compression for gif
// ... or investigate using webp instead of both png/gif here
'magick convert %f %o',
'gifsicle -O3 -b %o',
], '%B.gif');
}

View File

@@ -1,38 +0,0 @@
import {type Artifact, forEachRule} from '../tools/build/artifact.ts';
import {PNG_DETERMINISTIC, base, compresspng, spriteglob} from '../tools/build/helpers.ts';
// Smogdex social images: models, backfilled with gen9 species not yet in
// models (first source wins).
function socialInputs(): string[] {
let social = spriteglob(['src/models/*'], {b: false, s: false});
let socialSeen = new Set(social.map(base));
for (let file of spriteglob(['src/gen9species/*'], {b: false, s: false})) {
if (!socialSeen.has(base(file))) {
social.push(file);
socialSeen.add(base(file));
}
}
return social;
}
export function fbSprites(): Artifact[] {
return forEachRule(socialInputs(), {
display: 'fbsprite %f',
cmds: [
`magick convert "%f[0]" ${PNG_DETERMINISTIC} -trim -resize 150x150 -background white -gravity center -extent 198x198 -bordercolor black -border 1 %o`,
compresspng({config: 'MODELS'}),
],
}, '%B.png');
}
export function twitterSprites(): Artifact[] {
return forEachRule(socialInputs(), {
display: 'twittersprite %f',
cmds: [
`magick convert "%f[0]" ${PNG_DETERMINISTIC} -trim -resize 115x115 -background white -gravity center -extent 120x120 %o`,
compresspng({config: 'MODELS'}),
],
}, '%B.png');
}

View File

@@ -1,14 +1,32 @@
import {gen6Trimmed} from './rules/minisprites.ts';
import {gen10Modelslike, gen5Gifs, gen9Modelslike} from './rules/modelslike.ts';
import {gen10Modelslike} from './rules/modelslike.ts';
import {Manifest, type Sprite, spritecopy} from './rules/publish.ts';
import {forEachRule} from './tools/build/artifact.ts';
import {compresspng, trimimg} from './tools/build/helpers.ts';
import {deploy} from './tools/deploy/api.ts';
// xy/ animations: first source wins per sprite name.
let xyModels = gen9Modelslike();
let xyModels = forEachRule('src/gen9species/*.png', {
display: '96x96 %f',
// TODO, add customizable compression for gif
// ... or investigate using webp instead of both png/gif here
cmds: [
'magick convert %f -trim +repage -resize 90x90 %o',
'gifsicle -O3 -b %o',
],
}, '%B.gif');
let xyChampions = gen10Modelslike();
let xyGen5 = gen5Gifs();
// Non-model gen 5 CAPs.
let xyGen5 = forEachRule('src/sprites/gen5/*.png', [
// TODO, add customizable compression for gif
// ... or investigate using webp instead of both png/gif here
'magick convert %f %o',
'gifsicle -O3 -b %o',
], '%B.gif');
deploy(async ctx => {
let seenModels = new Set<string>();
@@ -44,7 +62,10 @@ deploy(async ctx => {
// xyicons/: trimmed gen6 minisprites.
let xyIcons = gen6Trimmed();
let xyIcons = forEachRule('src/minisprites/pokemon/gen6/*.png', {
display: 'trim g6 minisprite %f',
cmds: [trimimg(), compresspng({config: 'MINISPRITE'})],
}, '%b');
deploy(async ctx => {
let manifest = new Manifest(ctx);
@@ -54,10 +75,45 @@ deploy(async ctx => {
manifest.write('xyicons/manifest.json');
});
// Deprecated, unstamped sets:
// let xyItems = itemTrimmed(); (rules/minisprites.ts)
// let fb = fbSprites(); (rules/social.ts)
// let twitter = twitterSprites(); (rules/social.ts)
// Deprecated, unstamped sets. Reviving one also means importing what it
// uses (PNG_DETERMINISTIC, base, spriteglob, itemspritecopy) and giving the
// copies a Manifest, as the stamped deploys above do.
//
// let xyItems = forEachRule('src/minisprites/items/*.png', {
// display: 'trim item minisprite %f',
// cmds: [trimimg(), compresspng({config: 'MINISPRITE'})],
// }, '%b');
//
// Smogdex social images: models, backfilled with gen9 species not yet in
// models (first source wins).
//
// function socialInputs(): string[] {
// let social = spriteglob(['src/models/*'], {b: false, s: false});
// let socialSeen = new Set(social.map(base));
// for (let file of spriteglob(['src/gen9species/*'], {b: false, s: false})) {
// if (!socialSeen.has(base(file))) {
// social.push(file);
// socialSeen.add(base(file));
// }
// }
// return social;
// }
//
// let fb = forEachRule(socialInputs(), {
// display: 'fbsprite %f',
// cmds: [
// `magick convert "%f[0]" ${PNG_DETERMINISTIC} -trim -resize 150x150 -background white -gravity center -extent 198x198 -bordercolor black -border 1 %o`,
// compresspng({config: 'MODELS'}),
// ],
// }, '%B.png');
//
// let twitter = forEachRule(socialInputs(), {
// display: 'twittersprite %f',
// cmds: [
// `magick convert "%f[0]" ${PNG_DETERMINISTIC} -trim -resize 115x115 -background white -gravity center -extent 120x120 %o`,
// compresspng({config: 'MODELS'}),
// ],
// }, '%B.png');
//
// deploy(ctx => {
// for (let f of xyItems) {