@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
- const { config } = getHasteConfig();
17
- const devConfig = configObject.environments?.dev ?? {};
16
+ try {
17
+ const { config } = getHasteConfig();
18
+ const devConfig = configObject.environments?.dev ?? {};
18
19
 
19
- // Usage:
20
- const envPath = path.resolve(process.cwd(), '.env');
21
- const keymap = parseEnvFile(envPath);
20
+ // Usage:
21
+ const envPath = path.resolve(process.cwd(), '.env');
22
+ const keymap = parseEnvFile(envPath);
22
23
 
23
- const prodConfig = configObject.environments?.prod ?? {};
24
- const awsProfile = process.env.CDK_DEPLOY_PROFILE || 'default';
25
- const envObjBase = options.prod ? { ...prodConfig } : { ...devConfig };
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
- Object.keys(envObjBase).forEach((k) => {
28
- if (
29
- typeof envObjBase[k] === 'string' &&
30
- envObjBase[k].startsWith('$') &&
31
- !envObjBase[k].startsWith('${')
32
- ) {
33
- const refKey = envObjBase[k].substring(1);
34
- envObjBase[k] = keymap[refKey] || '';
35
- }
36
- });
37
- envObjBase.AWS_PROFILE = awsProfile;
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
- const envKeys = Object.keys(process.env).filter((k) => k.startsWith('MONO_'));
40
- const envMapList = config.envMap ?? ['FAILURE'];
41
- const combinedEnv = { ...process.env, ...envObjBase };
42
- let envMapVals = {};
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
- envKeys.map((k) => {
45
- envMapList.map((item) => {
46
- envMapVals[k.replace('MONO', item)] = combinedEnv[k];
47
+ envKeys.map((k) => {
48
+ envMapList.map((item) => {
49
+ envMapVals[k.replace('MONO', item)] = combinedEnv[k];
50
+ });
47
51
  });
48
- });
49
52
 
50
- const envObj = { ...envObjBase, ...envMapVals };
53
+ const envObj = { ...envObjBase, ...envMapVals };
51
54
 
52
- const preactions = configObject.preactions ?? [];
53
- const actions = configObject.actions ?? [];
55
+ const preactions = configObject.preactions ?? [];
56
+ const actions = configObject.actions ?? [];
54
57
 
55
- console.log(
56
- `→ Executing haste command: ${configObject.name || 'Unnamed Command'}`
57
- );
58
- console.log(`→ Using AWS profile: ${awsProfile}`);
59
- console.log(`→ Using environment: ${options.stage ? 'stage' : 'dev'}`);
60
- console.log('→ Environment variables:', envObj);
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
- // Run preactions sequentially
63
- for (const cmd of preactions) {
64
- console.log(`→ pre-action: ${cmd}`);
65
- await runForeground(cmd, envObj, options);
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
- if (actions.length === 0) return;
71
+ if (actions.length === 0) return;
69
72
 
70
- const bg = actions.slice(0, -1);
71
- const fg = actions[actions.length - 1];
73
+ const bg = actions.slice(0, -1);
74
+ const fg = actions[actions.length - 1];
72
75
 
73
- for (const cmd of bg) {
74
- console.log(`→ background action: ${cmd}`);
75
- runBackground(cmd, envObj, options);
76
- }
76
+ for (const cmd of bg) {
77
+ console.log(`→ background action: ${cmd}`);
78
+ runBackground(cmd, envObj, options);
79
+ }
77
80
 
78
- console.log(`→ foreground action (attached): ${fg}`);
79
- console.log('options:', options);
80
- try {
81
- await runBackground(fg, envObj, options, true);
82
- } finally {
83
- killAllBackground();
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
- argInfo?.allowAll ? [...actualOptions, 'all'] : [...actualOptions];
8
+ optionInfo?.allowAll ? [...actualOptions, 'all'] : [...actualOptions];
9
9
  }
10
10
  if (!actualOptions.includes(value)) {
11
11
  throw new Error(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mono-labs/cli",
3
- "version": "0.0.155",
3
+ "version": "0.0.157",
4
4
  "description": "A CLI tool for building and deploying projects",
5
5
  "type": "module",
6
6
  "main": "index.js",