import fs from "fs"; import path from "path"; import url from "url"; import { Output } from "./shared/index.mjs"; const __dirname = url.fileURLToPath(new URL(".", import.meta.url)); /////////////////////////////////////////////////////////////////////////////////////////////////// // Copy Markdown async function CopyMarkdown(out, name) { const content = await fs.promises.readFile( path.resolve(__dirname, `release-note-fragments/${name}`), "utf8" ); out.log(content); } /////////////////////////////////////////////////////////////////////////////////////////////////// // PACKAGE LIST const Spacings = { // spacingDesc, ligation type: ["Default", true], term: ["Terminal", true], fixed: ["Fixed", false], "quasi-proportional": ["Default", false] }; const ImagePrefixNoVersion = `https://raw.githubusercontent.com/be5invis/Iosevka`; const DownloadLinkPrefixNoVersion = `https://github.com/be5invis/Iosevka/releases/download`; async function GeneratePackageList(argv, out) { const imagePrefix = `${ImagePrefixNoVersion}/v${argv.version}/images`; const pkgShapesData = JSON.parse(await fs.promises.readFile(argv.releasePackagesJsonPath)); const DownloadLinkPrefix = `${DownloadLinkPrefixNoVersion}/v${argv.version}`; out.log(``); for (let [groupID, gr] of Object.entries(pkgShapesData)) { const prime = gr.subGroups[groupID]; const familyName = buildName("\u00a0", ...prime.family.split(" ")); const sTtcName = buildName("-", "SuperTTC", groupID, argv.version); const ttcName = buildName("-", "PkgTTC", groupID, argv.version); const proportionPrefix = gr.quasiProportional ? "Quasi-proportional" : "Monospace"; const desc = `${proportionPrefix}, ${prime.desc}`; const img = ImgX(`${imagePrefix}/package-sample-${groupID}`); let ttcCells = [``]; const hasSpacings = Object.entries(gr.subGroups).length > 1; if (hasSpacings) { const sTtcLink = `${DownloadLinkPrefix}/${sTtcName}.zip`; const ttcLink = `${DownloadLinkPrefix}/${ttcName}.zip`; ttcCells = [ ``, ``, `` ]; } out.log( ``, ``, ...ttcCells, `` ); out.log( ``, ``, ``, ``, ``, `` ); let lastSubGroupID = null; for (const [subGroupID, subGr] of Object.entries(gr.subGroups)) { lastSubGroupID = subGroupID; } for (const [subGroupID, subGr] of Object.entries(gr.subGroups)) { const [spacingDesc, ligation] = Spacings[subGr.spacing]; const createLink = (label, prefix) => { const fileName = buildName("-", prefix, subGroupID, argv.version); const downloadLink = `${DownloadLinkPrefix}/${fileName}.zip`; return `${label}`; }; const leader = "    " + (subGroupID === lastSubGroupID ? "└" : "├"); const superTtcPrefix = hasSpacings ? "SuperTTC-SGr" : "SuperTTC"; const ttcPrefix = hasSpacings ? "PkgTTC-SGr" : "PkgTTC"; out.log( ``, ``, ``, ``, ``, ``, ``, ``, `` ); } out.log(``, ``, ``); } out.log(`
 Super\u00A0TTCTTC 
📦 ${familyName} — ${desc}
  └ Sub-packagesSpacingLigaturesDownloads
${leader} ${noBreak(subGr.family)}${spacingDesc}${flag(ligation)}${createLink("Super\u00A0TTC", superTtcPrefix)}${createLink("TTC", ttcPrefix)}${createLink("TTF", "PkgTTF")} ` + `(${createLink("Unhinted", "PkgTTF-Unhinted")})${createLink("WebFont", "PkgWebFont")} ` + `(${createLink("Unhinted", "PkgWebFont-Unhinted")})
${img}
\n`); } function noBreak(s) { return s.replace(/ /g, "\u00a0"); } function buildName(j, ...parts) { return parts.filter(x => !!x).join(j); } function flag(f) { return f ? "Yes" : "No"; } function ImgX(path, w) { const widthProp = w ? ` width=${w}` : ``; return ( `` + `` ); } export default (async function main(argv) { const out = new Output(); out.log(`# Package list of Release ${argv.version}`); await CopyMarkdown(out, "packages-desc.md"); await GeneratePackageList(argv, out); await fs.promises.writeFile(argv.outputPath, out.buffer); });