Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | #!/usr/bin/env node
'use strict'
/**
* validate-icons
*
* Validates the per-release working set produced by prepare-release:
* SVG existence, dimensions, icon name, synonyms, color, repo collisions,
* and duplicates. Reads only from .workflow/<release>/.
*
* Usage:
* node .claude/skills/icons-release/scripts/validate-icons.js --release R264
*
* Output (a single JSON object on stdout):
* { success, step, data: { total, passed, failed, failures: [...] } }
*
* `success` reflects that validation ran; inspect data.failed to gate the
* pipeline. Failures never throw — they are reported per icon.
*/
const { succeed, run } = require('./lib/output')
const { parseArgs } = require('./lib/args')
const { loadWorkset } = require('./lib/workset')
const { readSvg } = require('./lib/svg')
const { validateIcon, findDuplicates } = require('./lib/validate')
const STEP = 'validate-icons'
function main() {
const args = parseArgs(process.argv.slice(2))
if (!args.release) {
throw Object.assign(new Error('--release is required (e.g. --release R264)'), {
code: 'MISSING_ARG'
})
}
const repoRoot = args['repo-root'] || '.'
const { release, icons } = loadWorkset(args.release)
const dupes = findDuplicates(icons)
const failures = []
let passed = 0
for (const icon of icons) {
const svgContent = readSvg(icon.svgPath)
const { errors } = validateIcon(icon, { svgContent, repoRoot })
const key = `${icon.icon_name}--${icon.icon_type}`
if (dupes.has(key)) {
errors.push(`Duplicate entry for ${icon.icon_name} (${icon.icon_type}).`)
}
if (errors.length > 0) {
failures.push({ icon: icon.icon_name, icon_type: icon.icon_type, reasons: errors })
} else {
passed++
}
}
succeed(STEP, {
release,
total: icons.length,
passed,
failed: failures.length,
failures
})
}
run(STEP, main)
|