"use strict"; const Path = require("path"); const Fs = require("fs-extra"); const SemVer = require("semver"); const execMain = require("../shared/execMain"); const ChangeFileDir = Path.join(__dirname, "../../changes"); const Version = process.argv[2]; const releasePackagesJsonPath = process.argv[3]; const outputPath = process.argv[4]; execMain(main); /////////////////////////////////////////////////////////////////////////////////////////////////// async function main() { const out = new Output(); await GenerateChangeList(out); await CopyMarkdown(out, "packages-desc.md"); await GeneratePackageList(out); await Fs.ensureDir(Path.join(__dirname, `../../release-archives/`)); await Fs.writeFile(outputPath, out.buffer); } class Output { constructor() { this.buffer = ""; } log(...s) { this.buffer += s.join("") + "\n"; } } /////////////////////////////////////////////////////////////////////////////////////////////////// // Copy Markdown async function CopyMarkdown(out, name) { const content = await Fs.readFile( Path.resolve(__dirname, `release-note-fragments/${name}`), "utf8" ); out.log(content); } /////////////////////////////////////////////////////////////////////////////////////////////////// // CHANGE LIST async function GenerateChangeList(out) { const changeFiles = await Fs.readdir(ChangeFileDir); const fragments = new Map(); for (const file of changeFiles) { const filePath = Path.join(ChangeFileDir, file); const fileParts = Path.parse(filePath); if (fileParts.ext !== ".md") continue; if (!SemVer.valid(fileParts.name) || SemVer.lt(Version, fileParts.name)) continue; fragments.set(fileParts.name, await Fs.readFile(filePath, "utf8")); } const sortedFragments = Array.from(fragments).sort((a, b) => SemVer.compare(b[0], a[0])); const latestMajor = SemVer.major(sortedFragments[0][0]); const latestMinor = SemVer.minor(sortedFragments[0][0]); for (const [version, notes] of sortedFragments) { const currentMajor = SemVer.major(version); const currentMinor = SemVer.minor(version); if (latestMajor !== currentMajor || latestMinor !== currentMinor) continue; out.log(``); out.log(`## Changes of version ${version}`); out.log(notes.trimEnd() + "\n"); } } /////////////////////////////////////////////////////////////////////////////////////////////////// // PACKAGE LIST const Spacings = { // spacingDesc, ligation type: ["Default", true], term: ["Terminal", true], fixed: ["Fixed", false], "quasi-proportional": ["Default", false] }; const imagePrefix = `https://raw.githubusercontent.com/be5invis/Iosevka/v${Version}/images`; async function GeneratePackageList(out) { const pkgShapesData = await Fs.readJson(releasePackagesJsonPath); const DownloadLinkPrefix = `https://github.com/be5invis/Iosevka/releases/download/v${Version}`; out.log(`
📦 ${familyName} — ${desc} | `, `Super\u00A0TTC | `, `TTC | `, ``, ` | ||||
└ Sub-packages | `, `Spacing | `, `Ligatures | `, `Downloads | `, `||||
${leader} ${noBreak(subGr.family)} | `, `${spacingDesc} | `, `${flag(ligation)} | `, `${createLink("Super\u00A0TTC", "super-ttc-sgr")} | `, `${createLink("TTC", "ttc-sgr")} | `, `${createLink("TTF", "ttf")} | `, `${createLink("Unhinted", "ttf-unhinted")} | `, `${createLink("WebFont", "webfont")} | `, `
${img} | `, `|||||||