@marvalt/digivalt-core 0.1.5 → 0.1.7
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/package.json
CHANGED
|
@@ -10,39 +10,42 @@ import { execSync } from 'child_process';
|
|
|
10
10
|
* using Wrangler bulk secret injection.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
const envPath = path.resolve(process.cwd(), '.env.local');
|
|
14
|
-
|
|
15
|
-
if (!fs.existsSync(envPath)) {
|
|
16
|
-
console.error("❌ No .env.local file found in the root directory!");
|
|
17
|
-
console.log("👉 Please create a .env.local file with your production secrets.");
|
|
18
|
-
process.exit(1);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
console.log("🔍 Parsing .env.local secrets...");
|
|
22
|
-
const rawEnv = fs.readFileSync(envPath, 'utf8');
|
|
23
13
|
const secrets = {};
|
|
24
14
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// Ignore comments and empty lines
|
|
28
|
-
if (!trimmed || trimmed.startsWith('#')) return;
|
|
15
|
+
const parseEnvFile = (filePath) => {
|
|
16
|
+
if (!fs.existsSync(filePath)) return;
|
|
29
17
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
//
|
|
36
|
-
if (
|
|
37
|
-
if (value.startsWith("'") && value.endsWith("'")) value = value.slice(1, -1);
|
|
18
|
+
console.log(`🔍 Parsing ${path.basename(filePath)} secrets...`);
|
|
19
|
+
const rawEnv = fs.readFileSync(filePath, 'utf8');
|
|
20
|
+
|
|
21
|
+
rawEnv.split('\n').forEach(line => {
|
|
22
|
+
const trimmed = line.trim();
|
|
23
|
+
// Ignore comments and empty lines
|
|
24
|
+
if (!trimmed || trimmed.startsWith('#')) return;
|
|
38
25
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
const match = trimmed.match(/^([^=]+)=(.*)$/);
|
|
27
|
+
if (match) {
|
|
28
|
+
const key = match[1].trim();
|
|
29
|
+
let value = match[2].trim();
|
|
30
|
+
|
|
31
|
+
// Strip surrounding quotes if present
|
|
32
|
+
if (value.startsWith('"') && value.endsWith('"')) value = value.slice(1, -1);
|
|
33
|
+
if (value.startsWith("'") && value.endsWith("'")) value = value.slice(1, -1);
|
|
34
|
+
|
|
35
|
+
secrets[key] = value;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const defaultEnvPath = path.resolve(process.cwd(), '.env');
|
|
41
|
+
const localEnvPath = path.resolve(process.cwd(), '.env.local');
|
|
42
|
+
|
|
43
|
+
parseEnvFile(defaultEnvPath);
|
|
44
|
+
parseEnvFile(localEnvPath);
|
|
42
45
|
|
|
43
46
|
const secretCount = Object.keys(secrets).length;
|
|
44
47
|
if (secretCount === 0) {
|
|
45
|
-
console.log("⚠️ No valid SECRETS found in .env.local. Exiting.");
|
|
48
|
+
console.log("⚠️ No valid SECRETS found in .env or .env.local. Exiting.");
|
|
46
49
|
process.exit(0);
|
|
47
50
|
}
|
|
48
51
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { generators } from '@marvalt/digivalt-core';
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
|
|
4
|
+
// Load environment variables manually for Node script context
|
|
5
|
+
dotenv.config();
|
|
6
|
+
dotenv.config({ path: '.env.local' });
|
|
7
|
+
|
|
8
|
+
async function runGenerators() {
|
|
9
|
+
console.log('🚀 Starting DigiVAlt static data generation for Landing Project...');
|
|
10
|
+
|
|
11
|
+
if (process.env.VITE_IS_LOVABLE === 'true') {
|
|
12
|
+
console.log('⚡ Lovable Environment Detected (VITE_IS_LOVABLE). Skipping static data generation to use GitHub synced files.');
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
console.log('Fetching Gravity Forms Context...');
|
|
18
|
+
const gfSuccess = await generators.generateGravityFormsData();
|
|
19
|
+
|
|
20
|
+
console.log('Fetching Mautic Context...');
|
|
21
|
+
const mauticSuccess = await generators.generateMauticData();
|
|
22
|
+
|
|
23
|
+
if (!gfSuccess || !mauticSuccess) {
|
|
24
|
+
console.warn('⚠️ Some data generation tasks returned false, but continuing build gracefully.');
|
|
25
|
+
} else {
|
|
26
|
+
console.log('✅ Customized static generation complete!');
|
|
27
|
+
}
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error('❌ Data fetching encountered an error, but continuing build gracefully:', error);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
runGenerators();
|