Fix: robust version hash injection in build process

Replaced the fragile regex-based version injection in `scripts/build-dist.mjs` with a robust placeholder method.

- Added `<!-- VERSION_INFO -->` placeholder to `index.html`.
- Updated `scripts/build-dist.mjs` to target the placeholder, while retaining regex fallback for safety.
- Ensures version info is reliably injected during local builds regardless of code formatting.

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-02-10 21:05:37 +00:00
1 parent 93d9bb7585
commit 53c0e9e8f4
4 files changed
+33 -20

No files matched your search

+13 -5
View File
@@ -171,14 +171,22 @@ function injectVersionInfo() {
v: ${hash.slice(0, 8)} • ${date}
</div>`;
// Fallback search if whitespace differs
const taglineRegex = /(seed\. zap\. subscribe\.\s*<\/h2>)/;
if (taglineRegex.test(content)) {
content = content.replace(taglineRegex, '$1' + versionHtml);
// Robust replacement using explicit comment placeholder
const placeholder = '<!-- VERSION_INFO -->';
if (content.includes(placeholder)) {
content = content.replace(placeholder, versionHtml);
fs.writeFileSync(indexHtmlPath, content);
console.log(`Injected version: ${hash.slice(0, 8)} • ${date}`);
} else {
console.warn('Could not find tagline to inject version info.');
// Fallback search if placeholder is missing (legacy behavior)
const taglineRegex = /(seed\. zap\. subscribe\.\s*<\/h2>)/;
if (taglineRegex.test(content)) {
content = content.replace(taglineRegex, '$1' + versionHtml);
fs.writeFileSync(indexHtmlPath, content);
console.log(`Injected version (via fallback regex): ${hash.slice(0, 8)} • ${date}`);
} else {
console.warn('Could not find placeholder or tagline to inject version info.');
}
}
}
} catch (error) {