@marvalt/digivalt-core 0.2.17 โ†’ 0.2.22

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 (43) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/components/index.d.ts +1 -0
  3. package/dist/components/integrations/digivalt-tracker.d.ts +1 -0
  4. package/dist/config/integrations.d.ts +16 -0
  5. package/dist/config.cjs +15 -0
  6. package/dist/config.cjs.map +1 -1
  7. package/dist/config.d.ts +17 -1
  8. package/dist/config.esm.js +15 -1
  9. package/dist/config.esm.js.map +1 -1
  10. package/dist/generators/index.d.ts +1 -0
  11. package/dist/generators/phplist.d.ts +3 -0
  12. package/dist/generators.cjs +312 -0
  13. package/dist/generators.cjs.map +1 -1
  14. package/dist/generators.d.ts +5 -1
  15. package/dist/generators.esm.js +312 -1
  16. package/dist/generators.esm.js.map +1 -1
  17. package/dist/hooks/useGravityForms.d.ts +12 -6
  18. package/dist/hooks/useGravityFormsNew.d.ts +9 -6
  19. package/dist/hooks/useSuiteCRM.d.ts +22 -15
  20. package/dist/index.cjs +313 -0
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.ts +7 -2
  23. package/dist/index.esm.js +313 -1
  24. package/dist/index.esm.js.map +1 -1
  25. package/dist/integrations-entry.d.ts +3 -0
  26. package/dist/integrations.cjs +316 -0
  27. package/dist/integrations.cjs.map +1 -0
  28. package/dist/integrations.d.ts +55 -0
  29. package/dist/integrations.esm.js +308 -0
  30. package/dist/integrations.esm.js.map +1 -0
  31. package/dist/seo.cjs +11 -0
  32. package/dist/seo.cjs.map +1 -1
  33. package/dist/seo.esm.js +11 -0
  34. package/dist/seo.esm.js.map +1 -1
  35. package/dist/services.cjs +11 -0
  36. package/dist/services.cjs.map +1 -1
  37. package/dist/services.esm.js +11 -0
  38. package/dist/services.esm.js.map +1 -1
  39. package/docs/ENVIRONMENT.md +12 -1
  40. package/docs/README.md +14 -0
  41. package/package.json +12 -3
  42. package/template/DIGIVALT_SETUP.md +36 -0
  43. package/template/scripts/deploy-secrets.js +44 -30
@@ -3,31 +3,45 @@ import path from 'path';
3
3
  import { execSync } from 'child_process';
4
4
 
5
5
  /**
6
- * ๐Ÿš€ DigiVAlt Cloudflare Secrets Deployer
7
- *
8
- * Automates the synchronization of local .env.local variables
9
- * securely straight into your Cloudflare Pages environment
10
- * using Wrangler bulk secret injection.
6
+ * DigiValt Cloudflare Pages secrets deployer
7
+ *
8
+ * Reads .env and .env.local, uploads allowed keys via wrangler pages secret bulk.
9
+ * Run: node scripts/deploy-secrets.js
10
+ * Dry run: node scripts/deploy-secrets.js --dry-run
11
11
  */
12
12
 
13
+ const dryRun = process.argv.includes('--dry-run');
14
+
13
15
  const secrets = {};
14
- /** Keys we never push from .env / .env.local (local dev or set manually on Cloudflare Pages). */
16
+
17
+ /** Local-only or non-Pages keys โ€” never bulk-uploaded. */
15
18
  const excludedKeys = new Set([
16
19
  'NODE_ENV',
20
+ 'NPM_TOKEN',
17
21
  'VITE_IS_LOVABLE',
18
22
  'VITE_LOCAL_DEVELOPMENT',
19
23
  'VITE_AUTH_MODE',
20
24
  'VITE_DEFAULT_MAX_ITEMS',
21
25
  ]);
22
26
 
23
- // VITE_SEO_* are often public (verification meta, titles); allow upload when teams store them as Pages secrets.
24
- // TURNSTILE_SECRET_KEY is server-only (Pages Functions), not a VITE_ prefix.
27
+ /**
28
+ * Allow DigiValt build/runtime variables (see digivalt-core bin/env-example-fragments.cjs).
29
+ * All VITE_* except excludedKeys; plus Node/generator alias names without VITE_ prefix.
30
+ */
25
31
  const allowedPatterns = [
26
32
  /^CLOUDFLARE_/,
27
33
  /^CF_ACCESS_/,
28
34
  /^TURNSTILE_/,
29
- /^VITE_SEO_/,
30
- /^VITE_(WORDPRESS|WP|GF|GRAVITY_FORMS|FRONTEND|FRONTENDS|MAUTIC|SUITECRM|SUPABASE|CLOUDFLARE|AUTH|TURNSTILE|CHATWOOT|THEME|GOOGLE_|FACEBOOK_|LINKEDIN_)/,
35
+ /^ALLOWED_ORIGINS$/,
36
+ /^SITE_URL$/,
37
+ /^WORDPRESS_/,
38
+ /^WP_/,
39
+ /^GF_/,
40
+ /^GRAVITY_FORMS_/,
41
+ /^MAUTIC_/,
42
+ /^SUITECRM_/,
43
+ /^GOOGLE_REVIEWS_/,
44
+ /^VITE_/,
31
45
  ];
32
46
 
33
47
  const isAllowedSecretKey = (key) => allowedPatterns.some((pattern) => pattern.test(key));
@@ -35,7 +49,7 @@ const isAllowedSecretKey = (key) => allowedPatterns.some((pattern) => pattern.te
35
49
  const parseEnvFile = (filePath) => {
36
50
  if (!fs.existsSync(filePath)) return;
37
51
 
38
- console.log(`๐Ÿ” Parsing ${path.basename(filePath)} secrets...`);
52
+ console.log(`๐Ÿ” Parsing ${path.basename(filePath)}...`);
39
53
  const rawEnv = fs.readFileSync(filePath, 'utf8');
40
54
 
41
55
  rawEnv.split('\n').forEach((line) => {
@@ -49,12 +63,12 @@ const parseEnvFile = (filePath) => {
49
63
  let value = match[2].trim();
50
64
 
51
65
  if (excludedKeys.has(key)) {
52
- console.log(`โš ๏ธ Skipping ${key} (DigiVAlt: excluded from Cloudflare bulk upload)`);
66
+ console.log(`โš ๏ธ Skipping ${key} (excluded from Cloudflare bulk upload)`);
53
67
  return;
54
68
  }
55
69
 
56
70
  if (!isAllowedSecretKey(key)) {
57
- console.log(`โš ๏ธ Skipping ${key} (not in DigiVAlt allowlist)`);
71
+ console.log(`โš ๏ธ Skipping ${key} (not in DigiValt allowlist)`);
58
72
  return;
59
73
  }
60
74
 
@@ -78,57 +92,57 @@ parseEnvFile(localEnvPath);
78
92
 
79
93
  const secretCount = Object.keys(secrets).length;
80
94
  if (secretCount === 0) {
81
- console.error('โŒ No allowed DigiVAlt environment variables were found in .env or .env.local.');
95
+ console.error('โŒ No allowed environment variables were found in .env or .env.local.');
82
96
  process.exit(1);
83
97
  }
84
98
 
99
+ console.log(`๐Ÿ“‹ ${secretCount} key(s) ready: ${Object.keys(secrets).sort().join(', ')}`);
100
+
101
+ if (dryRun) {
102
+ console.log('โœ… Dry run complete (nothing uploaded).');
103
+ process.exit(0);
104
+ }
105
+
85
106
  const tmpJsonPath = path.resolve(process.cwd(), '.tmp-cloudflare-secrets.json');
86
107
  fs.writeFileSync(tmpJsonPath, JSON.stringify(secrets, null, 2));
87
108
 
88
109
  try {
89
110
  console.log(`๐Ÿš€ Uploading ${secretCount} secrets to Cloudflare Pages...`);
90
-
91
- // Extract Cloudflare Account ID directly from the parsed environment variables!
111
+
92
112
  const accountId = secrets['CLOUDFLARE_ACCOUNT_ID'] || secrets['VITE_CLOUDFLARE_ACCOUNT_ID'] || '';
93
-
94
- // Try to read the Cloudflare project name from wrangler.toml
113
+
95
114
  const tomlPath = path.resolve(process.cwd(), 'wrangler.toml');
96
115
  let projectName = '';
97
-
116
+
98
117
  if (fs.existsSync(tomlPath)) {
99
118
  const tomlContent = fs.readFileSync(tomlPath, 'utf8');
100
-
101
- // Parse Project Name
102
119
  const nameMatch = tomlContent.match(/^name\s*=\s*["']([^"']+)["']/m);
103
120
  if (nameMatch) projectName = nameMatch[1];
104
-
105
- if (projectName) console.log(`๐Ÿ“ฆ Targeted Cloudflare Project: ${projectName}`);
106
- if (accountId) console.log(`๐Ÿข Targeted Cloudflare Account: ${accountId}`);
121
+
122
+ if (projectName) console.log(`๐Ÿ“ฆ Target Cloudflare project: ${projectName}`);
123
+ if (accountId) console.log(`๐Ÿข Target Cloudflare account: ${accountId}`);
107
124
  }
108
-
125
+
109
126
  if (!projectName) {
110
127
  throw new Error('Could not determine the Cloudflare Pages project name from wrangler.toml.');
111
128
  }
112
129
 
113
130
  let cmd = `npx wrangler pages secret bulk .tmp-cloudflare-secrets.json`;
114
131
  cmd += ` --project-name ${projectName}`;
115
-
116
- // Execute Wrangler natively with the Account ID passed through the strict environment scope
132
+
117
133
  const env = { ...process.env };
118
134
  if (accountId) {
119
135
  env.CLOUDFLARE_ACCOUNT_ID = accountId;
120
136
  }
121
-
137
+
122
138
  execSync(cmd, { stdio: 'inherit', env });
123
139
  console.log('โœ… All secrets deployed successfully to Cloudflare!');
124
-
125
140
  } catch (error) {
126
141
  console.error('โŒ Failed to push secrets to Cloudflare.');
127
142
  console.error('Ensure you are logged into Wrangler (`npx wrangler login`) and the project exists.');
128
143
  console.error(error instanceof Error ? error.message : error);
129
144
  process.exitCode = 1;
130
145
  } finally {
131
- // Always rigorously clean up the temporary plaintext JSON file for security
132
146
  if (fs.existsSync(tmpJsonPath)) {
133
147
  fs.unlinkSync(tmpJsonPath);
134
148
  console.log('๐Ÿงน Cleaned up temporary credentials payload.');