@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.
- package/CHANGELOG.md +24 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/integrations/digivalt-tracker.d.ts +1 -0
- package/dist/config/integrations.d.ts +16 -0
- package/dist/config.cjs +15 -0
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.ts +17 -1
- package/dist/config.esm.js +15 -1
- package/dist/config.esm.js.map +1 -1
- package/dist/generators/index.d.ts +1 -0
- package/dist/generators/phplist.d.ts +3 -0
- package/dist/generators.cjs +312 -0
- package/dist/generators.cjs.map +1 -1
- package/dist/generators.d.ts +5 -1
- package/dist/generators.esm.js +312 -1
- package/dist/generators.esm.js.map +1 -1
- package/dist/hooks/useGravityForms.d.ts +12 -6
- package/dist/hooks/useGravityFormsNew.d.ts +9 -6
- package/dist/hooks/useSuiteCRM.d.ts +22 -15
- package/dist/index.cjs +313 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.esm.js +313 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/integrations-entry.d.ts +3 -0
- package/dist/integrations.cjs +316 -0
- package/dist/integrations.cjs.map +1 -0
- package/dist/integrations.d.ts +55 -0
- package/dist/integrations.esm.js +308 -0
- package/dist/integrations.esm.js.map +1 -0
- package/dist/seo.cjs +11 -0
- package/dist/seo.cjs.map +1 -1
- package/dist/seo.esm.js +11 -0
- package/dist/seo.esm.js.map +1 -1
- package/dist/services.cjs +11 -0
- package/dist/services.cjs.map +1 -1
- package/dist/services.esm.js +11 -0
- package/dist/services.esm.js.map +1 -1
- package/docs/ENVIRONMENT.md +12 -1
- package/docs/README.md +14 -0
- package/package.json +12 -3
- package/template/DIGIVALT_SETUP.md +36 -0
- 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
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
24
|
-
|
|
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
|
-
/^
|
|
30
|
-
/^
|
|
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)}
|
|
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} (
|
|
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
|
|
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
|
|
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(`๐ฆ
|
|
106
|
-
if (accountId) console.log(`๐ข
|
|
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.');
|