| 1 | #!/usr/bin/env node |
| 2 | |
| 3 | // Regenerate the Seedmark v1 parity fixture from a local upstream checkout. |
| 4 | // Usage: node scripts/qa/generate-seedmark-fixture.mjs ../seedmark [output] |
| 5 | import {execFileSync} from 'node:child_process' ; |
| 6 | import {createHash} from 'node:crypto' ; |
| 7 | import {writeFile} from 'node:fs/promises' ; |
| 8 | import {pathToFileURL} from 'node:url' ; |
| 9 | import path from 'node:path' ; |
| 10 | |
| 11 | const upstream = path.resolve(process.argv[2] || '../seedmark' ); |
| 12 | const output = path.resolve(process.argv[3] || 'internal/seedmark/testdata/v1.json' ); |
| 13 | const expectedCommit = 'c808a940bc193f97512c02d58da33ecc28ba1f53' ; |
| 14 | const commit = execFileSync('git' , ['-C' , upstream, 'rev-parse' , 'HEAD' ], {encoding: 'utf8' }).trim(); |
| 15 | if (commit !== expectedCommit) { |
| 16 | throw new Error(`Seedmark checkout is ${commit}; expected ${expectedCommit}` ); |
| 17 | } |
| 18 | |
| 19 | const {avatar, recipe} = await import(pathToFileURL(path.join(upstream, 'src/index.js' )).href); |
| 20 | const seeds = [ |
| 21 | '' , |
| 22 | 'seedmark' , |
| 23 | 'a' .repeat(64), |
| 24 | 'A' .repeat(64), |
| 25 | '0' .repeat(64), |
| 26 | 'seed/\u0000part' , |
| 27 | 'é' , |
| 28 | 'e\u0301' , |
| 29 | '猫🌱' , |
| 30 | '👩💻' , |
| 31 | ...Array.from({length: 1000}, (_, index) => `sample/${index}` ), |
| 32 | ]; |
| 33 | const fixtures = seeds.map(seed => { |
| 34 | const svg = avatar(seed); |
| 35 | return { |
| 36 | seed, |
| 37 | family: recipe(seed).family, |
| 38 | sha256: createHash('sha256' ).update(svg).digest('hex' ), |
| 39 | }; |
| 40 | }); |
| 41 | await writeFile(output, `${JSON.stringify(fixtures, null, 2)}\n` ); |
| 42 | process.stderr.write(`wrote ${fixtures.length} cases from Seedmark ${commit} to ${output}\n` ); |