LifeMate — Personal, Family & Learning Companion
fix(pages): build QA for github.io repository path, isolate unimplemented API
davoodmehraban89 committed
Oct 15, 2026 at 09:31 UTC
3fc7d5b955bb33d7aab8be0f741f55277fcba013
1 file changed
+31
-12
scripts/build-github-pages-qa.sh
+31
-12
@@ -1,34 +1,53 @@
1
#!/usr/bin/env bash
2
-# LifeGuide QA: STATIC PWA ONLY, built for GitHub Pages with a custom-domain root.
3
-# Do not use this as proof of user login / API readiness.
2
+# LifeGuide QA STATIC-ONLY Pages artifact. No login/API or family sync is hosted here.
3
+# Default GitHub project Pages URL: /LifeMate/. Switch to / ONLY after GitHub
4
+# accepts the isolated qa.lifeguide.ir custom hostname.
5
set -Eeuo pipefail
6
cd "$(dirname "$0")/.."
7
7
-# Reuse the already-tested, pinned Flutter 3.47.6 build and local asset bundling.
8
+export LIFEGUIDE_PAGES_BASE_HREF="${LIFEGUIDE_PAGES_BASE_HREF:-/LifeMate/}"
9
+case "$LIFEGUIDE_PAGES_BASE_HREF" in
10
+ /LifeMate/|/) ;;
11
+ *) echo "Unsupported LifeGuide Pages QA base href" >&2; exit 2 ;;
12
+esac
13
+export LIFEGUIDE_FLUTTER_BASE_HREF="$LIFEGUIDE_PAGES_BASE_HREF"
14
+
15
+# Reuse pinned Flutter 3.47.6 self-hosting/asset checks, not a second build pipeline.
16
bash scripts/build-cloudflare-pages-qa.sh
17
out="apps/lifemate/build/web"
18
11
-# _headers is a Cloudflare Pages directive; it does not protect GitHub Pages.
19
+# Cloudflare-specific response header directives cannot secure GitHub Pages.
20
rm -f "$out/_headers"
21
touch "$out/.nojekyll"
22
23
node --input-type=module <<'NODE'
16
-import { readFileSync, writeFileSync } from 'node:fs';
24
+import { readFileSync, writeFileSync, existsSync } from 'node:fs';
25
const path = 'apps/lifemate/build/web/';
18
-const config = JSON.parse(readFileSync(path + 'config.json','utf8'));
26
+const base = process.env.LIFEGUIDE_PAGES_BASE_HREF;
27
+const expectedApiBase = base === '/' ? '/api' : base + 'api';
28
+const config = JSON.parse(readFileSync(path + 'config.json', 'utf8'));
29
if (config.apiBaseUrl !== '/api' ||
30
!Array.isArray(config.apiFallbackUrls) ||
31
config.apiFallbackUrls.length !== 0) {
22
- throw new Error('QA app must not silently fall back to Railway or an unverified backend');
32
+ throw new Error('QA config must start fail-closed with no external API fallback');
33
+}
34
+// Keep the unimplemented endpoint inside this app's path on github.io; do not
35
+// accidentally target another project hosted under the same origin.
36
+config.apiBaseUrl = expectedApiBase;
37
+writeFileSync(path + 'config.json', JSON.stringify(config) + '\n');
38
+const index = readFileSync(path + 'index.html', 'utf8');
39
+if (!index.includes(`<base href="${base}">`) || !index.includes('LifeGuide')) {
40
+ throw new Error('Pages index base href does not match the selected hosting path');
41
}
24
-const index = readFileSync(path + 'index.html','utf8');
25
-if (!index.includes('<base href="/">') || !index.includes('LifeGuide')) {
26
- throw new Error('GitHub Pages custom-domain root assets not configured');
42
+for (const file of ['main.dart.js', 'flutter_bootstrap.js', 'lifeguide-sw.js',
43
+ 'manifest.json', 'favicon.png', 'canvaskit']) {
44
+ if (!existsSync(path + file)) throw new Error('Missing QA web asset: ' + file);
45
}
46
const version = process.env.GITHUB_SHA?.slice(0,12) || 'local';
29
-writeFileSync(path + 'site-check.txt', 'LifeGuide GitHub Pages QA STATIC_ONLY ' + version + '\n');
47
+writeFileSync(path + 'site-check.txt',
48
+ 'LifeGuide GitHub Pages QA STATIC_ONLY ' + version + ' BASE=' + base + '\n');
49
NODE
50
51
test -s "$out/main.dart.js"
52
test -s "$out/site-check.txt"
34
-echo "GitHub Pages QA static artifact prepared. API registration remains unavailable."
53
+echo "LifeGuide Pages QA static artifact built for $LIFEGUIDE_PAGES_BASE_HREF (API unavailable)."