@mono-labs/cli 0.0.40 → 0.0.42

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,12 +1,30 @@
1
1
  import { execSync } from 'child_process';
2
+ import { getRootJson } from '../loadFromRoot';
2
3
 
4
+ const rootJson = getRootJson();
5
+ const workspacesList = (rootJson.workspaces || []).map((item) =>
6
+ item.replace(/[\.\/\*]/, '')
7
+ );
3
8
  //Run Action List before all script actions
4
9
 
5
- const result = execSync('yarn workspaces list --json', { encoding: 'utf8' })
6
- .trim()
7
- .split('\n')
8
- .map((line) => JSON.parse(line));
10
+ export function executeCommandsIfWorkspaceAction(commands = [], action) {
11
+ console.log('we here');
12
+ const result = execSync('yarn workspaces list --json', { encoding: 'utf8' })
13
+ .trim()
14
+ .split('\n')
15
+ .map((line) => JSON.parse(line))
16
+ .filter((obj) => obj !== '.');
9
17
 
10
- console.log(result.map((w) => w.location)); // list of workspace paths
18
+ console.log(result.map((w) => w.location)); // list of workspace paths
11
19
 
12
- function executeCommandsIfWorkspaceAction(commands = [], action) {}
20
+ console.log('workspacesList', workspacesList);
21
+ // Check if the action is a workspace action
22
+ if (action) {
23
+ // Execute each command in the context of the workspace
24
+ commands.forEach((cmd) => {
25
+ console.log(`Executing command in workspace: ${cmd}`);
26
+ // Here you would add the logic to execute the command
27
+ execSync(cmd, { stdio: 'inherit', shell: true });
28
+ });
29
+ }
30
+ }
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]);
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.42",
4
4
  "description": "A CLI tool for building and deploying projects",
5
5
  "type": "module",
6
6
  "main": "index.js",