@mono-labs/cli 0.0.85 → 0.0.87
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { runForeground } from './runners/runForeground.js';
|
|
2
2
|
import { runBackground } from './runners/runBackground.js';
|
|
3
3
|
import { killAllBackground } from './runners/processManager.js';
|
|
4
|
+
import { getHasteConfig } from '../loadFromRoot.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Orchestrate execution of a single haste command definition.
|
|
@@ -10,12 +11,25 @@ import { killAllBackground } from './runners/processManager.js';
|
|
|
10
11
|
* Environment selection based on --stage flag and injection of AWS_PROFILE.
|
|
11
12
|
*/
|
|
12
13
|
export async function runHasteCommand(configObject, options = {}) {
|
|
14
|
+
const { config } = getHasteConfig();
|
|
13
15
|
console.log('runHasteCommand options:', options);
|
|
14
16
|
const devConfig = configObject.environments?.dev ?? {};
|
|
15
17
|
const stageConfig = configObject.environments?.stage ?? {};
|
|
16
18
|
const awsProfile = process.env.CDK_DEPLOY_PROFILE || 'default';
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
+
const envObjBase = options.stage ? { ...stageConfig } : { ...devConfig };
|
|
20
|
+
envObjBase.AWS_PROFILE = awsProfile;
|
|
21
|
+
|
|
22
|
+
const envKeys = Object.keys(process.env).filter((k) => k.startsWith('MONO_'));
|
|
23
|
+
const envMapList = config.envMap ?? ['FAILURE'];
|
|
24
|
+
let envMapVals = {};
|
|
25
|
+
|
|
26
|
+
envKeys.map((k) => {
|
|
27
|
+
envMapList.map((item) => {
|
|
28
|
+
envMapVals[k.replace('MONO', item)] = process.env[k];
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const envObj = { ...envObjBase, ...envMapVals };
|
|
19
33
|
|
|
20
34
|
const preactions = configObject.preactions ?? [];
|
|
21
35
|
const actions = configObject.actions ?? [];
|
|
@@ -5,7 +5,11 @@ import { getRootJson, getHasteConfig } from '../loadFromRoot.js';
|
|
|
5
5
|
|
|
6
6
|
const WorkSpaceDirectory = '${dir}';
|
|
7
7
|
|
|
8
|
-
export function executeCommandsIfWorkspaceAction(
|
|
8
|
+
export function executeCommandsIfWorkspaceAction(
|
|
9
|
+
action,
|
|
10
|
+
commands = [],
|
|
11
|
+
fullEnv
|
|
12
|
+
) {
|
|
9
13
|
console.log('commands', commands);
|
|
10
14
|
const { config } = getHasteConfig();
|
|
11
15
|
const workspacemap = config.workspace?.packageMaps || {};
|
|
@@ -45,8 +49,13 @@ export function executeCommandsIfWorkspaceAction(action, commands = []) {
|
|
|
45
49
|
commands.forEach((cmd) => {
|
|
46
50
|
const finalCommand = cmd.replace(WorkSpaceDirectory, workingDirectory);
|
|
47
51
|
console.log(`Executing command in workspace: ${finalCommand}`);
|
|
52
|
+
console.log('fullEnv:', fullEnv);
|
|
48
53
|
// Here you would add the logic to execute the command
|
|
49
|
-
execSync(finalCommand, {
|
|
54
|
+
execSync(finalCommand, {
|
|
55
|
+
stdio: 'inherit',
|
|
56
|
+
shell: true,
|
|
57
|
+
env: { ...fullEnv },
|
|
58
|
+
});
|
|
50
59
|
});
|
|
51
60
|
}
|
|
52
61
|
}
|
package/lib/index.js
CHANGED
|
@@ -20,6 +20,7 @@ const { config } = getHasteConfig();
|
|
|
20
20
|
|
|
21
21
|
const workspacemap = config.workspace?.packageMaps || {};
|
|
22
22
|
const preactions = config.workspace?.preactions || [];
|
|
23
|
+
const envMapList = config.envMap ?? ['FAILURE'];
|
|
23
24
|
|
|
24
25
|
program.on('command:*', (operands) => {
|
|
25
26
|
console.log('operands command:', operands.join(' '));
|
|
@@ -33,13 +34,23 @@ program.on('command:*', (operands) => {
|
|
|
33
34
|
console.log('Workspace:', workspace);
|
|
34
35
|
console.log('Rest:', rest);
|
|
35
36
|
|
|
37
|
+
const envKeys = Object.keys(process.env).filter((k) => k.startsWith('MONO_'));
|
|
38
|
+
|
|
39
|
+
let envObj = {};
|
|
40
|
+
|
|
41
|
+
envKeys.map((k) => {
|
|
42
|
+
envMapList.map((item) => {
|
|
43
|
+
envObj[k.replace('MONO', item)] = process.env[k];
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
36
47
|
// If the “rest” is empty or starts with flags, insert a default script
|
|
37
48
|
|
|
38
49
|
const args = ['workspace', workspace, ...rest];
|
|
39
50
|
console.log('Final args for yarn:', args);
|
|
40
51
|
|
|
41
52
|
console.error(`Unknown command. Falling back to: yarn ${args.join(' ')}`);
|
|
42
|
-
executeCommandsIfWorkspaceAction(args, preactions);
|
|
53
|
+
executeCommandsIfWorkspaceAction(args, preactions, envObj);
|
|
43
54
|
console.log('yarn', args, {
|
|
44
55
|
stdio: 'inherit',
|
|
45
56
|
shell: process.platform === 'win32',
|