@marvalt/digivalt-core 0.2.22 → 0.2.24

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.
@@ -36,7 +36,7 @@ Or install once with `npm install --legacy-peer-deps`. Runtime behavior with Rea
36
36
 
37
37
  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`.
38
38
 
39
- - **Allowlist (summary):** all **`VITE_*`** keys except **`VITE_IS_LOVABLE`**, **`VITE_LOCAL_DEVELOPMENT`**, **`VITE_AUTH_MODE`**, **`VITE_DEFAULT_MAX_ITEMS`**; plus **`CLOUDFLARE_*`**, **`CF_ACCESS_*`**, **`TURNSTILE_*`**, **`ALLOWED_ORIGINS`**, **`SITE_URL`**, and Node alias prefixes **`WORDPRESS_`**, **`WP_`**, **`GF_`**, **`GRAVITY_FORMS_`**, **`MAUTIC_`**, **`SUITECRM_`**, **`GOOGLE_REVIEWS_`**. **`NPM_TOKEN`** is never uploaded. Run **`node scripts/deploy-secrets.js --dry-run`** to list keys before upload.
39
+ - **Allowlist (summary):** all **`VITE_*`** keys except **`VITE_IS_LOVABLE`**, **`VITE_LOCAL_DEVELOPMENT`**, **`VITE_AUTH_MODE`**, **`VITE_DEFAULT_MAX_ITEMS`**; plus **`CLOUDFLARE_*`**, **`CF_ACCESS_*`**, **`TURNSTILE_*`**, **`PHPLIST_*`**, **`ALLOWED_ORIGINS`**, **`SITE_URL`**, and Node alias prefixes **`WORDPRESS_`**, **`WP_`**, **`GF_`**, **`GRAVITY_FORMS_`**, **`MAUTIC_`**, **`SUITECRM_`**, **`GOOGLE_REVIEWS_`**. **`NPM_TOKEN`** is never uploaded. Run **`node scripts/deploy-secrets.js --dry-run`** to list keys before upload.
40
40
  - **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.
41
41
  - **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.
42
42
  - **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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marvalt/digivalt-core",
3
- "version": "0.2.22",
3
+ "version": "0.2.24",
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",
@@ -107,7 +107,7 @@
107
107
  "@digivalt/tracker": "^0.1.0",
108
108
  "@marvalt/dstyler": "^0.1.51",
109
109
  "@marvalt/madapter": "^2.3.7",
110
- "@marvalt/plister": "^0.1.0",
110
+ "@marvalt/plister": "^0.2.0",
111
111
  "@marvalt/sadapter": "^0.1.5",
112
112
  "@marvalt/shcoder": "^0.1.35",
113
113
  "@marvalt/tadapter": "^1.0.12",
@@ -0,0 +1,88 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { execSync } from 'child_process';
4
+
5
+ /**
6
+ * Build and deploy to Cloudflare Pages via Wrangler.
7
+ *
8
+ * node scripts/deploy-pages.js # build + deploy production branch
9
+ * node scripts/deploy-pages.js --branch staging
10
+ * node scripts/deploy-pages.js --skip-build # deploy existing dist/
11
+ * node scripts/deploy-pages.js --dry-run
12
+ *
13
+ * Requires: npx wrangler login, CLOUDFLARE_ACCOUNT_ID in .env / .env.local,
14
+ * and wrangler.toml `name` matching your Pages project.
15
+ */
16
+
17
+ const dryRun = process.argv.includes('--dry-run');
18
+ const skipBuild = process.argv.includes('--skip-build');
19
+ const branchArg = process.argv.find((arg) => arg.startsWith('--branch='));
20
+ const branch = branchArg ? branchArg.slice('--branch='.length) : process.env.DEPLOY_BRANCH || '';
21
+
22
+ const parseAccountId = () => {
23
+ for (const fileName of ['.env', '.env.local']) {
24
+ const filePath = path.resolve(process.cwd(), fileName);
25
+ if (!fs.existsSync(filePath)) continue;
26
+ const match = fs.readFileSync(filePath, 'utf8').match(/^CLOUDFLARE_ACCOUNT_ID=(.*)$/m);
27
+ if (match) {
28
+ let value = match[1].trim();
29
+ if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
30
+ value = value.slice(1, -1);
31
+ }
32
+ if (value) return value;
33
+ }
34
+ }
35
+ return process.env.CLOUDFLARE_ACCOUNT_ID || '';
36
+ };
37
+
38
+ const readProjectName = () => {
39
+ const tomlPath = path.resolve(process.cwd(), 'wrangler.toml');
40
+ if (!fs.existsSync(tomlPath)) {
41
+ throw new Error('wrangler.toml not found in project root.');
42
+ }
43
+ const nameMatch = fs.readFileSync(tomlPath, 'utf8').match(/^name\s*=\s*["']([^"']+)["']/m);
44
+ if (!nameMatch) {
45
+ throw new Error('Could not read project name from wrangler.toml.');
46
+ }
47
+ return nameMatch[1];
48
+ };
49
+
50
+ const projectName = readProjectName();
51
+ const accountId = parseAccountId();
52
+ const distPath = path.resolve(process.cwd(), 'dist');
53
+
54
+ console.log(`📦 Cloudflare Pages project: ${projectName}`);
55
+ if (branch) console.log(`🌿 Deploy branch: ${branch}`);
56
+ if (accountId) console.log(`🏢 Cloudflare account: ${accountId}`);
57
+
58
+ if (!skipBuild) {
59
+ console.log('🔨 Running npm run build...');
60
+ if (dryRun) {
61
+ console.log(' (dry run — build skipped)');
62
+ } else {
63
+ execSync('npm run build', { stdio: 'inherit' });
64
+ }
65
+ } else {
66
+ console.log('⏭️ Skipping build (--skip-build)');
67
+ }
68
+
69
+ if (!dryRun && !fs.existsSync(distPath)) {
70
+ throw new Error('dist/ not found. Run npm run build first or remove --skip-build.');
71
+ }
72
+
73
+ let cmd = 'npx wrangler pages deploy dist';
74
+ cmd += ` --project-name ${projectName}`;
75
+ if (branch) cmd += ` --branch ${branch}`;
76
+ cmd += ' --commit-dirty=true';
77
+
78
+ console.log(dryRun ? `✅ Dry run — would run: ${cmd}` : `🚀 ${cmd}`);
79
+
80
+ if (dryRun) {
81
+ process.exit(0);
82
+ }
83
+
84
+ const env = { ...process.env };
85
+ if (accountId) env.CLOUDFLARE_ACCOUNT_ID = accountId;
86
+
87
+ execSync(cmd, { stdio: 'inherit', env });
88
+ console.log('✅ Pages deployment complete.');
@@ -41,6 +41,7 @@ const allowedPatterns = [
41
41
  /^MAUTIC_/,
42
42
  /^SUITECRM_/,
43
43
  /^GOOGLE_REVIEWS_/,
44
+ /^PHPLIST_/,
44
45
  /^VITE_/,
45
46
  ];
46
47