diff options
Diffstat (limited to 'build.js')
| -rw-r--r-- | build.js | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -252,7 +252,11 @@ export async function buildSwNwc({ minify = true } = {}) { return result.outputs[0].text(); } -// Optional-feature selection: HAL_FEATURES is a comma list of enabled +// Build switches are COINOS_* environment variables. The old HAL_* names still +// work: the cs deploy hook and pinned F-Droid recipes pass them. +const env = (name) => process.env['COINOS_' + name] ?? process.env['HAL_' + name]; + +// Optional-feature selection: COINOS_FEATURES is a comma list of enabled // features (gifts,ark,zaps,nwc,…). Unset means all; "none"/"" means a minimal // on-chain-only wallet. A build plugin swaps src/features/index.js for a // generated module that only imports the enabled features, so a disabled @@ -273,7 +277,7 @@ const ALL_FEATURES = { gifts: 'giftsFeature', ark: 'arkFeature', nostrlogin: 'no // later chunk makes the header change after the rest of the page has painted. const DEFERRED_FEATURES = ['gifts', 'nwc', 'pos']; -export function enabledFeatures(spec = process.env.HAL_FEATURES) { +export function enabledFeatures(spec = env('FEATURES')) { if (spec == null) return Object.keys(ALL_FEATURES); return spec.split(',').map((x) => x.trim().toLowerCase()).filter((x) => x in ALL_FEATURES); } @@ -305,9 +309,9 @@ const featurePlugin = (enabled) => ({ }, }); -// HAL_TARGET=staging flips src/build-flags.js in the bundle: mutinynet-first +// COINOS_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'; +export const isStaging = (target = env('TARGET')) => target === 'staging'; const flagsPlugin = (staging) => ({ name: 'coinos-build-flags', @@ -375,10 +379,10 @@ function bootShell(logo, staging) { } const BOOT_SHELL_SCRIPT = `<script>try{var m=location.pathname.match(/^\\/([A-Za-z0-9._-]{1,64})\\/?$/);if(m&&!/^(note|nevent|naddr)1/i.test(m[1])){document.getElementById('boot-shell').style.display='';document.getElementById('boot-shell-name').textContent=decodeURIComponent(m[1]);}}catch(e){}</script>`; -// HAL_NO_SW=1: the page registers no service worker. The Android bundled +// COINOS_NO_SW=1: the page registers no service worker. The Android bundled // build serves this page from its own assets, where a worker would only // fetch the live site over the top of them. -const NO_SW = !!process.env.HAL_NO_SW; +const NO_SW = !!env('NO_SW'); async function pageHtml({ css, staging, pwa, scriptHtml }) { return `<!doctype html> @@ -401,7 +405,7 @@ ${pwa && !NO_SW ? SW_REGISTER + '\n' : ''}</body> } // Self-contained single file (dev server, test tools, save-and-open-offline). -export async function buildHtml({ minify = true, pwa = minify, features = process.env.HAL_FEATURES, staging = isStaging(), inlineFonts = false } = {}) { +export async function buildHtml({ minify = true, pwa = minify, features = env('FEATURES'), staging = isStaging(), inlineFonts = false } = {}) { const outputs = await bundleApp({ minify, features, staging }); let js = await outputs[0].text(); // Guard against a literal </script> inside the bundle closing our tag early. @@ -422,7 +426,7 @@ export async function buildHtml({ minify = true, pwa = minify, features = proces // features ride in their own files, fetched right after boot. The page stays // tiny on every load while the heavy bundles are cached by name — a repeat // visit re-downloads kilobytes, not the app. -export async function buildSplit({ minify = true, features = process.env.HAL_FEATURES, staging = isStaging() } = {}) { +export async function buildSplit({ minify = true, features = env('FEATURES'), staging = isStaging() } = {}) { const outputs = await bundleApp({ minify, features, staging, splitting: true }); const entry = outputs.find((o) => o.kind === 'entry-point') || outputs[0]; const js = (await entry.text()).replaceAll('{{COMMIT}}', gitCommit()); |
