GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — opencode-mobile/scripts/release-notes.mjs at main · opencode-mobile/opencode-mobile Expand file tree/ Copy pathrelease-notes.mjsMore file actions 148 lines (140 loc) · 6.36 KB / Copy pathrelease-notes.mjsFile metadata and controls148 lines (140 loc) · 6.36 KB 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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 #!/usr/bin/env node // Release notes for the in-app "What's new" sheet. Source: release-notes/release-notes.json. // // A release is a successful release-workflow run, not a version bump. The release workflow // tags the commit it shipped as <platform>-v<version>; those tags are the record this script // reads to find what changed and when each version shipped. // // node scripts/release-notes.mjs validate // Check the file's shape. Runs on every pull request that touches it. // node scripts/release-notes.mjs check --platform android|ios --version 1.5.0 // Fail unless that version has notes for that platform and every older release has a // date. The release workflows run this before building. // node scripts/release-notes.mjs draft --platform android|ios // List the pull requests merged since the last release tag, to write the next notes from. // node scripts/release-notes.mjs sync-dates // Fill missing `released` dates from the release tags. import { execFileSync } from "node:child_process"; import { readFileSync, writeFileSync } from "node:fs"; import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; const ROOT = join(dirname(fileURLToPath(import.meta.url)), ".."); const FILE = join(ROOT, "release-notes", "release-notes.json"); const PLATFORMS = ["android", "ios"]; const KINDS = ["new", "improved", "fixed"]; const VERSION = /^\d+\.\d+\.\d+$/; const DATE = /^\d{4}-\d{2}-\d{2}$/; const fail = (msg) => { console.error(`release-notes: ${msg}`); process.exit(1); }; const arg = (name) => { const i = process.argv.indexOf(`--${name}`); return i > 0 ? process.argv[i + 1] : undefined; }; const git = (...args) => execFileSync("git", args, { cwd: ROOT, encoding: "utf8" }).trim(); const cmp = (a, b) => { const x = a.split(".").map(Number); const y = b.split(".").map(Number); for (let i = 0; i < 3; i++) if (x[i] !== y[i]) return x[i] - y[i]; return 0; }; // Prerelease builds (1.5.0-rc1) use the notes of their release version. const baseVersion = (v) => v.replace(/-.*$/, ""); function load() { let data; try { data = JSON.parse(readFileSync(FILE, "utf8")); } catch (e) { fail(`cannot read ${FILE}: ${e.message}`); } return data; } function validate(data) { const errors = []; if (!Array.isArray(data?.releases)) return ["`releases` must be an array"]; const last = {}; data.releases.forEach((r, i) => { const at = `releases[${i}]`; const present = PLATFORMS.filter((p) => r[p]); if (!present.length) errors.push(`${at} needs an android or ios version`); for (const p of present) { const { version, released } = r[p]; if (!VERSION.test(version ?? "")) errors.push(`${at}.${p}.version must be MAJOR.MINOR.PATCH`); if (released !== null && !DATE.test(released ?? "")) errors.push(`${at}.${p}.released must be YYYY-MM-DD or null`); if (last[p] && VERSION.test(version) && cmp(version, last[p]) >= 0) errors.push(`${at}.${p}.version ${version} must be lower than the release above it (${last[p]}); list newest first`); if (VERSION.test(version ?? "")) last[p] = version; } if (!Array.isArray(r.items) || !r.items.length) errors.push(`${at}.items must not be empty`); (r.items ?? []).forEach((it, j) => { const iat = `${at}.items[${j}]`; if (!KINDS.includes(it.kind)) errors.push(`${iat}.kind must be one of ${KINDS.join(", ")}`); for (const k of ["icon", "title", "body"]) if (typeof it[k] !== "string" || !it[k].trim()) errors.push(`${iat}.${k} is required`); if (it.platforms !== undefined) { if (!Array.isArray(it.platforms) || !it.platforms.length || it.platforms.some((p) => !present.includes(p))) errors.push(`${iat}.platforms must list platforms this release has (${present.join(", ")})`); } }); for (const p of present) if (!(r.items ?? []).some((it) => !it.platforms || it.platforms.includes(p))) errors.push(`${at} has no items for ${p}`); }); return errors; } function tagDate(platform, version) { try { return git("log", "-1", "--format=%cs", `refs/tags/${platform}-v${version}`) || null; } catch { return null; } } const cmd = process.argv[2]; const data = load(); const errors = validate(data); if (errors.length) fail(`${FILE} is invalid:\n ${errors.join("\n ")}`); if (cmd === "validate") { console.log(`release-notes: ${data.releases.length} releases OK`); } else if (cmd === "check") { const platform = arg("platform"); const raw = arg("version"); if (!PLATFORMS.includes(platform) || !raw) fail("usage: check --platform android|ios --version X.Y.Z"); const version = baseVersion(raw); const entry = data.releases.find((r) => r[platform]?.version === version); if (!entry) fail( `no release notes for ${platform} ${version}. Add an entry to release-notes/release-notes.json ` + `(run \`node scripts/release-notes.mjs draft --platform ${platform}\` for what changed) before releasing.`, ); const undated = data.releases.filter((r) => r[platform] && r !== entry && cmp(r[platform].version, version) < 0 && !r[platform].released); if (undated.length) fail( `older ${platform} releases have no date: ${undated.map((r) => r[platform].version).join(", ")}. ` + "Run `node scripts/release-notes.mjs sync-dates` and commit the result.", ); console.log(`release-notes: ${platform} ${version} has notes`); } else if (cmd === "draft") { const platform = arg("platform"); if (!PLATFORMS.includes(platform)) fail("usage: draft --platform android|ios"); const tags = git("tag", "--list", `${platform}-v*`, "--sort=-v:refname").split("\n").filter(Boolean); if (!tags.length) fail(`no ${platform}-v* tags; fetch tags first (git fetch --tags)`); console.log(`Merged since ${tags[0]}:\n`); console.log(git("log", "--reverse", "--format=- %s", `${tags[0]}..HEAD`)); } else if (cmd === "sync-dates") { let filled = 0; for (const r of data.releases) for (const p of PLATFORMS) if (r[p] && !r[p].released) { const d = tagDate(p, r[p].version); if (d) { r[p].released = d; filled++; console.log(`${p} ${r[p].version}: ${d}`); } } writeFileSync(FILE, `${JSON.stringify(data, null, 2)}\n`); console.log(`release-notes: filled ${filled} date(s)`); } else { fail("usage: release-notes.mjs validate | check --platform P --version V | draft --platform P | sync-dates"); } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |