ferst-core 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/cms-config.mjs +23 -3
  2. package/package.json +1 -1
@@ -44,6 +44,27 @@ export function repoSlug() {
44
44
  return '';
45
45
  }
46
46
 
47
+ /**
48
+ * The platform git-proxy origin (CMS `base_url` / `api_root`) for THIS site:
49
+ * FERST_GIT_BASE env → committed `ferst-site.json` `gitBase` → prod default.
50
+ * The seeder writes `ferst-site.json` with the origin of the worker that provisioned
51
+ * the site, so a dev-provisioned site points its CMS backend at the dev worker and a
52
+ * prod one at prod — the "site respects the portal it was generated from" binding,
53
+ * restored at build time.
54
+ */
55
+ export function resolveGitBase(cwd = process.cwd()) {
56
+ const fromEnv = env('FERST_GIT_BASE');
57
+ if (fromEnv) return fromEnv;
58
+ try {
59
+ const raw = readFileSync(resolve(cwd, 'ferst-site.json'), 'utf8');
60
+ const site = JSON.parse(raw);
61
+ if (site && typeof site.gitBase === 'string' && site.gitBase.trim()) return site.gitBase.trim();
62
+ } catch {
63
+ /* no ferst-site.json (e.g. the template repo itself) — fall through to the default */
64
+ }
65
+ return 'https://signin.ferst.co.uk';
66
+ }
67
+
47
68
  /** The deployment branch: CF Pages env → current git branch → main. */
48
69
  export function deploymentBranch() {
49
70
  const cf = env('CF_PAGES_BRANCH');
@@ -86,9 +107,8 @@ function main() {
86
107
  console.error('ferst-cms-config: could not determine the repo — set GITHUB_REPOSITORY=owner/name.');
87
108
  process.exit(1);
88
109
  }
89
- // The platform git-proxy origin. Identical for every managed client; overridable for
90
- // dev/self-hosted via FERST_GIT_BASE.
91
- const base = env('FERST_GIT_BASE') || 'https://signin.ferst.co.uk';
110
+ // The platform git-proxy origin for this site (env → ferst-site.json → prod default).
111
+ const base = resolveGitBase();
92
112
  const branch = deploymentBranch();
93
113
 
94
114
  let tpl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ferst-core",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "description": "Ferst Core — the shared, brand-agnostic client-site system: Astro components, layouts, content schemas, the layered config resolver, and a neutral styling architecture that every client overrides.",
6
6
  "license": "BUSL-1.1",