From 65064e2bb0eefb90c3585bf49fe7a5c038da6454 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 16 Aug 2026 17:00:28 -0700 Subject: Staging wears its name on the logo and deals in play money: HAL_TARGET=staging stamps the brand, renames the PWA, and starts fresh wallets on Mutinynet — one master, no diverging branch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01JtaatFfAbx91Nh3xqKVqKz --- build.js | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'build.js') diff --git a/build.js b/build.js index ea8540b..8abf5fb 100644 --- a/build.js +++ b/build.js @@ -225,12 +225,26 @@ const featurePlugin = (enabled) => ({ }, }); -export async function buildHtml({ minify = true, pwa = minify, features = process.env.HAL_FEATURES } = {}) { +// HAL_TARGET=staging flips src/build-flags.js in the bundle: mutinynet-first +// defaults and a visible staging stamp, without a diverging branch. +export const isStaging = (target = process.env.HAL_TARGET) => target === 'staging'; + +const flagsPlugin = (staging) => ({ + name: 'coinos-build-flags', + setup(b) { + b.onLoad({ filter: /src[\/\\]build-flags\.js$/ }, () => ({ + contents: `export const STAGING = ${!!staging};\n`, + loader: 'js', + })); + }, +}); + +export async function buildHtml({ minify = true, pwa = minify, features = process.env.HAL_FEATURES, staging = isStaging() } = {}) { const result = await Bun.build({ entrypoints: ['./src/app.js'], target: 'browser', minify, - plugins: [featurePlugin(enabledFeatures(features))], + plugins: [featurePlugin(enabledFeatures(features)), flagsPlugin(staging)], }); if (!result.success) { for (const log of result.logs) console.error(log); @@ -247,7 +261,7 @@ export async function buildHtml({ minify = true, pwa = minify, features = proces -Coinos +${staging ? 'Coinos Staging' : 'Coinos'} ${pwa ? PWA_HEAD : ''} @@ -278,8 +292,12 @@ if (import.meta.main) { const locales = await readdir('src/locales'); for (const f of locales) await Bun.write('dist/locales/' + f, Bun.file('src/locales/' + f)); - // PWA sidecars. - await Bun.write('dist/manifest.webmanifest', JSON.stringify(MANIFEST, null, 2)); + // PWA sidecars. The staging install gets its own name so the two icons are + // tellable apart on a phone's home screen (identity is per-origin anyway). + const manifest = isStaging() + ? { ...MANIFEST, name: 'Coinos Staging', short_name: 'Staging' } + : MANIFEST; + await Bun.write('dist/manifest.webmanifest', JSON.stringify(manifest, null, 2)); // Full builds get the auto-answering NWC worker; feature-stripped builds // keep the notify-only handler (the responder would just dead-weight them). const feats = enabledFeatures(); -- cgit v1.2.3