From 87abfc2ec0a2165aa86d00bcde286660533e99e9 Mon Sep 17 00:00:00 2001 From: Anso Date: Sat, 2 May 2026 15:57:07 -0400 Subject: [PATCH] fix(ci): tolerate empty inline blogPosts array in scaffold script (#883) The release blog scaffold's index.ts regex required a literal newline before the closing bracket of the blogPosts array. A fresh website repo bootstraps the array as an empty inline literal (= []), which broke the script the first time it ran for v0.67.0. The closing capture now matches whitespace-then-bracket so both empty inline and multi-line shapes work, and the rebuild always emits a clean newline-comma-newline-bracket regardless of input shape. Verified via dry-run against the current website state. --- .github/scripts/scaffold-release-post.mjs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/scripts/scaffold-release-post.mjs b/.github/scripts/scaffold-release-post.mjs index 77c525c9..35ad36b7 100644 --- a/.github/scripts/scaffold-release-post.mjs +++ b/.github/scripts/scaffold-release-post.mjs @@ -284,16 +284,18 @@ function updateIndex(websiteRoot, exportName, fileBase) { lines.splice(lastImportIdx + 1, 0, importLine) const joined = lines.join('\n') - const arrayRegex = /(export const blogPosts: BlogPost\[\] = \[)([\s\S]*?)(\n\])/ + // The closing capture tolerates both multi-line (`,\n]`) and empty inline + // (`[]`) array shapes. Empty inline is the bootstrap state of a fresh + // sencho-website repo before any release post has been written. + const arrayRegex = /(export const blogPosts: BlogPost\[\] = \[)([\s\S]*?)(\s*\])/ const m = joined.match(arrayRegex) if (!m) throw new Error('Could not locate blogPosts array in index.ts') const before = joined.slice(0, m.index) const arrOpen = m[1] const arrBody = m[2] - const arrClose = m[3] const after = joined.slice(m.index + m[0].length) - const newBody = `${arrBody.replace(/\s*$/u, '')}\n ${exportName},` - return `${before}${arrOpen}${newBody}${arrClose}${after}` + const trimmedBody = arrBody.replace(/\s*$/u, '') + return `${before}${arrOpen}${trimmedBody}\n ${exportName},\n]${after}` } function updateMeta(websiteRoot, slug, title, description, date) {