@mono-labs/cli 0.0.155 → 0.0.157
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.
|
@@ -13,74 +13,81 @@ import path from 'node:path';
|
|
|
13
13
|
* Environment selection based on --stage flag and injection of AWS_PROFILE.
|
|
14
14
|
*/
|
|
15
15
|
export async function runHasteCommand(configObject, options = {}) {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
try {
|
|
17
|
+
const { config } = getHasteConfig();
|
|
18
|
+
const devConfig = configObject.environments?.dev ?? {};
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
// Usage:
|
|
21
|
+
const envPath = path.resolve(process.cwd(), '.env');
|
|
22
|
+
const keymap = parseEnvFile(envPath);
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
const prodConfig = configObject.environments?.prod ?? {};
|
|
25
|
+
const awsProfile = process.env.CDK_DEPLOY_PROFILE || 'default';
|
|
26
|
+
const envObjBase = options.prod ? { ...prodConfig } : { ...devConfig };
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
Object.keys(envObjBase).forEach((k) => {
|
|
29
|
+
if (
|
|
30
|
+
typeof envObjBase[k] === 'string' &&
|
|
31
|
+
envObjBase[k].startsWith('$') &&
|
|
32
|
+
!envObjBase[k].startsWith('${')
|
|
33
|
+
) {
|
|
34
|
+
const refKey = envObjBase[k].substring(1);
|
|
35
|
+
envObjBase[k] = keymap[refKey] || '';
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
envObjBase.AWS_PROFILE = awsProfile;
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
const envKeys = Object.keys(process.env).filter((k) =>
|
|
41
|
+
k.startsWith('MONO_')
|
|
42
|
+
);
|
|
43
|
+
const envMapList = config.envMap ?? ['FAILURE'];
|
|
44
|
+
const combinedEnv = { ...process.env, ...envObjBase };
|
|
45
|
+
let envMapVals = {};
|
|
43
46
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
envKeys.map((k) => {
|
|
48
|
+
envMapList.map((item) => {
|
|
49
|
+
envMapVals[k.replace('MONO', item)] = combinedEnv[k];
|
|
50
|
+
});
|
|
47
51
|
});
|
|
48
|
-
});
|
|
49
52
|
|
|
50
|
-
|
|
53
|
+
const envObj = { ...envObjBase, ...envMapVals };
|
|
51
54
|
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
const preactions = configObject.preactions ?? [];
|
|
56
|
+
const actions = configObject.actions ?? [];
|
|
54
57
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
console.log(
|
|
59
|
+
`→ Executing haste command: ${configObject.name || 'Unnamed Command'}`
|
|
60
|
+
);
|
|
61
|
+
console.log(`→ Using AWS profile: ${awsProfile}`);
|
|
62
|
+
console.log(`→ Using environment: ${options.stage ? 'stage' : 'dev'}`);
|
|
63
|
+
console.log('→ Environment variables:', envObj);
|
|
61
64
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
// Run preactions sequentially
|
|
66
|
+
for (const cmd of preactions) {
|
|
67
|
+
console.log(`→ pre-action: ${cmd}`);
|
|
68
|
+
await runForeground(cmd, envObj, options);
|
|
69
|
+
}
|
|
67
70
|
|
|
68
|
-
|
|
71
|
+
if (actions.length === 0) return;
|
|
69
72
|
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
const bg = actions.slice(0, -1);
|
|
74
|
+
const fg = actions[actions.length - 1];
|
|
72
75
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
for (const cmd of bg) {
|
|
77
|
+
console.log(`→ background action: ${cmd}`);
|
|
78
|
+
runBackground(cmd, envObj, options);
|
|
79
|
+
}
|
|
77
80
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
console.log(`→ foreground action (attached): ${fg}`);
|
|
82
|
+
console.log('options:', options);
|
|
83
|
+
try {
|
|
84
|
+
await runBackground(fg, envObj, options, true);
|
|
85
|
+
} finally {
|
|
86
|
+
killAllBackground();
|
|
87
|
+
}
|
|
88
|
+
} catch (err) {
|
|
89
|
+
console.error('Error executing mono command:', err);
|
|
90
|
+
throw err;
|
|
84
91
|
}
|
|
85
92
|
}
|
|
86
93
|
|
|
@@ -5,7 +5,7 @@ export function verifyOptionValue(optionKey, value, optionsData) {
|
|
|
5
5
|
let actualOptions = optionInfo.options;
|
|
6
6
|
if (actualOptions) {
|
|
7
7
|
actualOptions =
|
|
8
|
-
|
|
8
|
+
optionInfo?.allowAll ? [...actualOptions, 'all'] : [...actualOptions];
|
|
9
9
|
}
|
|
10
10
|
if (!actualOptions.includes(value)) {
|
|
11
11
|
throw new Error(
|