From 61b3cbc6d8c83095f652e5f375646bfc58c00267 Mon Sep 17 00:00:00 2001 From: litruv Date: Sun, 23 Aug 2026 08:26:33 +1000 Subject: [PATCH] Point desktop build at cinny-local update manifest script for mobile CI. --- .github/workflows/update-manifest.yml | 4 +- cinny | 2 +- scripts/generate-update-manifest.mjs | 118 +++----------------------- 3 files changed, 14 insertions(+), 110 deletions(-) diff --git a/.github/workflows/update-manifest.yml b/.github/workflows/update-manifest.yml index 6dc050a..f9561bc 100644 --- a/.github/workflows/update-manifest.yml +++ b/.github/workflows/update-manifest.yml @@ -4,7 +4,7 @@ on: push: paths: - 'cinny/public/update/*.md' - - 'scripts/generate-update-manifest.mjs' + - 'cinny/scripts/generate-update-manifest.mjs' permissions: contents: write @@ -20,7 +20,7 @@ jobs: node-version: '20' - name: Generate manifest.json - run: node scripts/generate-update-manifest.mjs + run: node cinny/scripts/generate-update-manifest.mjs - name: Commit manifest if changed run: | diff --git a/cinny b/cinny index 25be638..b6f3f5c 160000 --- a/cinny +++ b/cinny @@ -1 +1 @@ -Subproject commit 25be638c5ece3fb9d5a598531d7311da0820c0b2 +Subproject commit b6f3f5c0aa6ab30742111770d814f90494f87f14 diff --git a/scripts/generate-update-manifest.mjs b/scripts/generate-update-manifest.mjs index 3f5073a..3ab4097 100644 --- a/scripts/generate-update-manifest.mjs +++ b/scripts/generate-update-manifest.mjs @@ -1,114 +1,18 @@ #!/usr/bin/env node /** - * Regenerates cinny/public/update/manifest.json from markdown files. - * - * - currentupdate.md is always the "current" entry - * - Other *.md files matching X.Y.Z.md become "older" (sorted newest first) - * - title, date, version come from YAML frontmatter when present + * Desktop repo wrapper — manifest generator lives in cinny/scripts/. */ - -import fs from 'fs'; +import { spawnSync } from 'child_process'; import path from 'path'; import { fileURLToPath } from 'url'; -const __dirname = path.dirname(fileURLToPath(import.meta.url)); -const ROOT = path.resolve(__dirname, '..'); -const UPDATE_DIR = path.join(ROOT, 'cinny', 'public', 'update'); -const MANIFEST_PATH = path.join(UPDATE_DIR, 'manifest.json'); -const CURRENT_FILE = 'currentupdate.md'; -const VERSION_FILE_RE = /^(\d+\.\d+\.\d+)\.md$/; +const script = path.join( + path.dirname(fileURLToPath(import.meta.url)), + '..', + 'cinny', + 'scripts', + 'generate-update-manifest.mjs' +); -const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/; - -function parseFrontmatter(source) { - const match = FRONTMATTER_RE.exec(source.trimStart()); - if (!match) return {}; - - const frontmatter = {}; - match[1].split('\n').forEach((line) => { - const colon = line.indexOf(':'); - if (colon <= 0) return; - const key = line.slice(0, colon).trim(); - const raw = line.slice(colon + 1).trim(); - frontmatter[key] = raw.replace(/^['"]|['"]$/g, ''); - }); - return frontmatter; -} - -function compareVersions(a, b) { - const pa = a.split('.').map((part) => Number.parseInt(part, 10)); - const pb = b.split('.').map((part) => Number.parseInt(part, 10)); - const len = Math.max(pa.length, pb.length); - - for (let i = 0; i < len; i += 1) { - const na = pa[i] ?? 0; - const nb = pb[i] ?? 0; - if (na !== nb) return nb - na; - } - return 0; -} - -function readMarkdownMeta(fileName) { - const filePath = path.join(UPDATE_DIR, fileName); - const source = fs.readFileSync(filePath, 'utf8'); - const frontmatter = parseFrontmatter(source); - const versionFromName = VERSION_FILE_RE.exec(fileName)?.[1]; - - return { - file: fileName, - version: frontmatter.version ?? versionFromName, - title: frontmatter.title, - date: frontmatter.date, - }; -} - -function buildManifest() { - if (!fs.existsSync(UPDATE_DIR)) { - throw new Error(`Update directory not found: ${UPDATE_DIR}`); - } - - const currentPath = path.join(UPDATE_DIR, CURRENT_FILE); - if (!fs.existsSync(currentPath)) { - throw new Error(`Missing ${CURRENT_FILE} in ${UPDATE_DIR}`); - } - - const older = fs - .readdirSync(UPDATE_DIR, { withFileTypes: true }) - .filter((entry) => entry.isFile() && VERSION_FILE_RE.test(entry.name)) - .map((entry) => readMarkdownMeta(entry.name)) - .filter((entry) => entry.version) - .sort((a, b) => compareVersions(a.version, b.version)); - - return { - current: CURRENT_FILE, - older: older.map(({ file, version, title, date }) => { - const item = { file }; - if (version) item.version = version; - if (title) item.title = title; - if (date) item.date = date; - return item; - }), - }; -} - -function main() { - const manifest = buildManifest(); - const json = `${JSON.stringify(manifest, null, 2)}\n`; - - let previous = null; - if (fs.existsSync(MANIFEST_PATH)) { - previous = fs.readFileSync(MANIFEST_PATH, 'utf8'); - } - - if (previous === json) { - console.log('[update-manifest] manifest.json is already up to date'); - return; - } - - fs.writeFileSync(MANIFEST_PATH, json, 'utf8'); - console.log( - `[update-manifest] wrote manifest.json (${manifest.older.length} older version(s))` - ); -} - -main(); +const result = spawnSync(process.execPath, [script], { stdio: 'inherit' }); +process.exit(result.status ?? 1);