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 72 73 74 75 | 'use strict' const fs = require('fs') const path = require('path') const { parseCsv } = require('./csv') const WORKFLOW_ROOT = '.workflow' /** * Normalize a release input ("R264" or "264") into { release, targetBuild }. */ function parseRelease(input) { const match = String(input || '').match(/(\d+)/) if (!match) { const err = new Error(`Could not read a build number from release "${input}"`) err.code = 'INVALID_RELEASE' throw err } const targetBuild = Number(match[1]) return { release: `R${targetBuild}`, targetBuild } } /** * Load the per-release working set produced by prepare-release. * Reads .workflow/<release>/<release>-icons.csv and resolves each icon's * working SVG path under .workflow/<release>/assets/<type>/<name>.svg. * * @returns {{ release, location, assetsDir, targetIconsCsv, icons: object[] }} */ function loadWorkset(releaseInput) { const { release } = parseRelease(releaseInput) const location = path.join(WORKFLOW_ROOT, release) const targetIconsCsv = path.join(location, `${release}-icons.csv`) const assetsDir = path.join(location, 'assets') if (!fs.existsSync(location)) { const err = new Error(`No working set at ${location}. Run prepare-release first.`) err.code = 'NO_WORKSET' throw err } if (!fs.existsSync(targetIconsCsv)) { const err = new Error(`Missing ${targetIconsCsv}. Run prepare-release first.`) err.code = 'NO_TARGET_CSV' throw err } const rows = parseCsv(fs.readFileSync(targetIconsCsv, 'utf8')) const header = rows[0].map(h => h.trim()) const idx = name => header.indexOf(name) const icons = rows.slice(1).map(row => { const get = name => (idx(name) === -1 ? '' : (row[idx(name)] || '').trim()) const iconType = get('icon_type') const iconName = get('icon_name') const synonyms = get('synonyms') .split('|') .map(s => s.trim()) .filter(Boolean) return { icon_name: iconName, icon_type: iconType, color: get('color'), synonyms, has_ltr_rtl: get('has_ltr_rtl') || 'no', converted: get('converted') === 'yes', source: get('source'), svgPath: path.join(assetsDir, iconType, `${iconName}.svg`) } }) return { release, location, assetsDir, targetIconsCsv, icons } } module.exports = { parseRelease, loadWorkset, WORKFLOW_ROOT } |