@mono-labs/cli 0.0.40 → 0.0.41

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.
@@ -2,11 +2,21 @@ import { execSync } from 'child_process';
2
2
 
3
3
  //Run Action List before all script actions
4
4
 
5
- const result = execSync('yarn workspaces list --json', { encoding: 'utf8' })
6
- .trim()
7
- .split('\n')
8
- .map((line) => JSON.parse(line));
5
+ export function executeCommandsIfWorkspaceAction(commands = [], action) {
6
+ console.log('we here');
7
+ const result = execSync('yarn workspaces list --json', { encoding: 'utf8' })
8
+ .trim()
9
+ .split('\n')
10
+ .map((line) => JSON.parse(line));
9
11
 
10
- console.log(result.map((w) => w.location)); // list of workspace paths
11
-
12
- function executeCommandsIfWorkspaceAction(commands = [], action) {}
12
+ console.log(result.map((w) => w.location)); // list of workspace paths
13
+ // Check if the action is a workspace action
14
+ if (action && action.type === 'workspace') {
15
+ // Execute each command in the context of the workspace
16
+ commands.forEach((cmd) => {
17
+ console.log(`Executing command in workspace: ${cmd}`);
18
+ // Here you would add the logic to execute the command
19
+ execSync(cmd, { stdio: 'inherit', shell: true });
20
+ });
21
+ }
22
+ }
package/lib/index.js CHANGED
@@ -14,10 +14,11 @@ import './commands/submit/index.js';
14
14
  import './commands/update/index.js';
15
15
  import './commands/build-process/index.js';
16
16
  import { getHasteConfig } from './commands/loadFromRoot.js';
17
+ import { executeCommandsIfWorkspaceAction } from './commands/build-process/test.js';
17
18
 
18
19
  const { config } = getHasteConfig();
19
20
 
20
- const workspacemap = config.workspace || {};
21
+ const workspacemap = config.workspace?.packageMaps || {};
21
22
 
22
23
  program.on('command:*', (operands) => {
23
24
  const [cmd] = operands; // e.g. "destroy3"
@@ -31,26 +32,23 @@ program.on('command:*', (operands) => {
31
32
  console.log('Rest:', rest);
32
33
 
33
34
  // If the “rest” is empty or starts with flags, insert a default script
34
- if (rest.length === 0 || rest[0].startsWith('--')) {
35
- console.log('Rest is empty or starts with flags, inserting DEFAULT_SCRIPT');
36
- // Prefer an explicit script name; if you want to always use `run`, do:
37
- // rest = ['run', DEFAULT_SCRIPT, ...rest];
38
- rest = [...rest]; // yarn workspace <ws> dev --flags
39
- console.log('Rest after inserting DEFAULT_SCRIPT:', rest);
40
- }
41
35
 
42
36
  const args = ['workspace', workspace, ...rest];
43
37
  console.log('Final args for yarn:', args);
44
38
 
45
39
  console.error(`Unknown command. Falling back to: yarn ${args.join(' ')}`);
46
-
47
- const child = spawn('yarn', args, {
40
+ executeCommandsIfWorkspaceAction(['yarn', ...args], { type: 'workspace' });
41
+ console.log('yarn', args, {
48
42
  stdio: 'inherit',
49
43
  shell: process.platform === 'win32',
50
44
  });
51
- child.on('exit', (code) => {
52
- console.log('Child process exited with code:', code);
53
- process.exitCode = code ?? 1;
54
- });
45
+ // const child = spawn('yarn', args, {
46
+ // stdio: 'inherit',
47
+ // shell: process.platform === 'win32',
48
+ // });
49
+ // child.on('exit', (code) => {
50
+ // console.log('Child process exited with code:', code);
51
+ // process.exitCode = code ?? 1;
52
+ // });
55
53
  });
56
54
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mono-labs/cli",
3
- "version": "0.0.40",
3
+ "version": "0.0.41",
4
4
  "description": "A CLI tool for building and deploying projects",
5
5
  "type": "module",
6
6
  "main": "index.js",