@marvalt/digivalt-core 0.2.13 → 0.2.16

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.
@@ -0,0 +1,51 @@
1
+ # DigiVAlt environment variables
2
+
3
+ This document is the handover reference for **DevOps** (Cloudflare, secrets) and **app developers** using `@marvalt/digivalt-core`. The **canonical list of variable lines** that `npx digivalt-init` installs lives in the package at [`bin/env-example-fragments.cjs`](../bin/env-example-fragments.cjs). The same content is committed as [`.env.example`](../.env.example) and [`.env.local.example`](../.env.local.example) for browsing in Git or the IDE; **when you change the fragments file, update those two files in the same change**.
4
+
5
+ ## Two-file model (developers)
6
+
7
+ - **`.env.example`** — team-safe, public-style placeholders. Copy to **`.env`** if your tools only read `.env`.
8
+ - **`.env.local.example`** — same idea for secrets. Copy to **`.env.local`** and fill real values. **Never commit** `.env` or `.env.local` with production secrets.
9
+ - Vite exposes only variables whose names are prefixed with **`VITE_`** to the browser (except where Node-only scripts read `process.env` at build or in Pages Functions; see below).
10
+
11
+ ## `npx digivalt-init` and the managed block
12
+
13
+ Run **`npx digivalt-init`** in the app root after first adding DigiVAlt or after upgrading `@marvalt/digivalt-core` when you want the latest scaffolded env template.
14
+
15
+ The command **creates or updates** `.env.example` and `.env.local.example`. The DigiValt content is wrapped in markers (see [`bin/init.cjs`](../bin/init.cjs): `ENV_MANAGED_START` / `ENV_MANAGED_END`). **Lines you add outside that block are preserved**; the block itself is replaced when you rerun init so teams stay aligned with the package. If an old file has no markers, init **appends** the block and warns you to merge manually once.
16
+
17
+ **Node / static generation aliases:** Generators and some scripts also accept un-prefixed names (e.g. `WORDPRESS_API_URL`, `WP_API_USERNAME`) as alternatives to `VITE_*` when running under Node. Prefer the `VITE_` names in app repos for consistency.
18
+
19
+ **`VITE_IS_LOVABLE` (generators only):** Used in hosted Lovable/CI “fixture” flows to skip live API fetches. **Do not set this in local full-data development.** See [SEO-PERFORMANCE.md](./SEO-PERFORMANCE.md) and your app’s `DIGIVALT_SETUP.md`. It is **not** part of the managed example block; it is listed in `deploy-secrets` excluded keys (below).
20
+
21
+ ## Handover to DevOps (Cloudflare and secrets)
22
+
23
+ ### `node scripts/deploy-secrets.js`
24
+
25
+ After `digivalt-init`, the app has [`scripts/deploy-secrets.js`](../template/scripts/deploy-secrets.js) (from the template). It reads **`.env`** and **`.env.local`**, then uploads only keys that pass an **allowlist** to Cloudflare Pages via Wrangler `pages secret bulk`.
26
+
27
+ - **Allowlist (summary):** patterns include `CLOUDFLARE_*`, `CF_ACCESS_*`, `TURNSTILE_*`, `VITE_SEO_*`, and `VITE_`-prefixed keys for WordPress, Gravity Forms, Mautic, SuiteCRM, Supabase, Cloudflare worker URL, auth, Turnstile, Chatwoot, theme, and similar integrations (see the `allowedPatterns` array in the script).
28
+ - **Excluded from bulk upload (set in the Pages UI or locally instead):** `NODE_ENV`, `VITE_IS_LOVABLE`, `VITE_LOCAL_DEVELOPMENT`, `VITE_AUTH_MODE`, `VITE_DEFAULT_MAX_ITEMS` — so environment-specific or non-secret toggles are not mass-synced.
29
+ - **Empty values** are skipped. **`CLOUDFLARE_ACCOUNT_ID`** in env is used when invoking Wrangler; the **project name** comes from **`wrangler.toml`** in the app root.
30
+ - **Turnstile:** `VITE_TURNSTILE_SITE_KEY` is for the browser; **`TURNSTILE_SECRET_KEY`** is server-only for Pages Functions (not a `VITE_` var). Both can appear in the allowlist path when set in your env files.
31
+
32
+ ### Wrangler and Pages
33
+
34
+ Align **`name`** in `wrangler.toml` with your **Cloudflare Pages** project. Local Functions development may use **`.dev.vars.example`** (from the template) copied to `.dev.vars`.
35
+
36
+ ## Variable groups (what they’re for)
37
+
38
+ | Area | Notes |
39
+ |------|--------|
40
+ | **WordPress / static gen** | `VITE_WORDPRESS_API_URL`, `VITE_AUTH_MODE`, `VITE_CLOUDFLARE_WORKER_URL`, `VITE_LOCAL_DEVELOPMENT`, `VITE_ENABLED_POST_TYPES`, `VITE_DEFAULT_MAX_ITEMS`, `VITE_USE_DSTYLER`, `VITE_FRONTEND_ID` / `VITE_FRONTEND_NAME` — used by hooks, generators, and `getIntegrationConfig` / `getAppEnvironmentConfig`. **`google_reviews`** in `VITE_ENABLED_POST_TYPES` is a pseudo-type (not a WordPress CPT): it opt-in enables build-time fetch of `public/google-reviews-data.json` via the `vibune-google-reviews` plugin. |
41
+ | **Theme** | `VITE_THEME` — optional; see `loadTheme` in `config/themes`. |
42
+ | **Integrations (URLs often public; secrets in `.env.local`)** | Mautic, SuiteCRM, Supabase, Chatwoot, Gravity Forms — see `getIntegrationConfig` in `src/config/integrations.ts`. `VITE_SUITECRM_TOKEN_URL` is optional for non-default OAuth token endpoints (`environment.ts`). |
43
+ | **SEO** | `VITE_SEO_*` — see [SEO-PERFORMANCE.md](./SEO-PERFORMANCE.md) and `getSEOConfig`. |
44
+ | **Performance** | `VITE_PERF_*` — optional toggles; see [SEO-PERFORMANCE.md](./SEO-PERFORMANCE.md) and `getPerformanceConfig`. |
45
+ | **Secrets (typical in `.env.local`)** | WordPress app password, Cloudflare Access, Mautic API keys, GF keys, SuiteCRM creds, `VITE_FRONTEND_SECRET` / `VITE_WP_REFRESH_SECRET` (webhook), `VITE_TURNSTILE_SITE_KEY` + `TURNSTILE_SECRET_KEY`. |
46
+
47
+ ## Further reading
48
+
49
+ - [SEO-PERFORMANCE.md](./SEO-PERFORMANCE.md) — `VITE_SEO_*`, `VITE_PERF_*`, sitemap, Lovable / `VITE_IS_LOVABLE` behavior
50
+ - [Template `DIGIVALT_SETUP.md`](../template/DIGIVALT_SETUP.md) — onboarding in a Vite app
51
+ - [README.md](../README.md) — init workflow and `deploy-secrets` overview
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marvalt/digivalt-core",
3
- "version": "0.2.13",
3
+ "version": "0.2.16",
4
4
  "description": "Core glue logic and shared context for DigiVAlt frontend applications",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "main": "dist/index.cjs",
@@ -66,7 +66,8 @@
66
66
  "smoke:imports": "node ./scripts/smoke-imports.mjs",
67
67
  "smoke:init": "node ./scripts/smoke-init.cjs",
68
68
  "smoke:sitemap": "node ./scripts/test-sitemap-paths.cjs",
69
- "smoke": "npm run smoke:imports && npm run smoke:init && npm run smoke:sitemap",
69
+ "smoke:google-reviews-gate": "node ./scripts/test-google-reviews-gate.cjs",
70
+ "smoke": "npm run smoke:imports && npm run smoke:init && npm run smoke:sitemap && npm run smoke:google-reviews-gate",
70
71
  "prepublishOnly": "npm run clean && npm run build && npm run smoke"
71
72
  },
72
73
  "devDependencies": {