@mono-labs/cli 0.0.30 → 0.0.31
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.
- package/lib/index.js +33 -7
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -16,15 +16,41 @@ import './commands/build-process/index.js'
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
program.on('command:*', (operands) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
console.log('Received unknown command event');
|
|
20
|
+
console.log('Operands:', operands);
|
|
21
|
+
const [cmd] = operands; // e.g. "destroy3"
|
|
22
|
+
console.log('Command:', cmd);
|
|
23
|
+
const raw = program.rawArgs.slice(2); // after `node script.js`
|
|
24
|
+
console.log('Raw args:', raw);
|
|
22
25
|
const i = raw.indexOf(cmd);
|
|
23
|
-
|
|
26
|
+
console.log('Index of command in raw args:', i);
|
|
27
|
+
const tokens = i >= 0 ? raw.slice(i) : operands;
|
|
28
|
+
console.log('Tokens:', tokens);
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
// tokens = ["destroy3", "--test", "--lot", "test"]
|
|
31
|
+
const workspace = tokens[0];
|
|
32
|
+
let rest = tokens.slice(1);
|
|
33
|
+
console.log('Workspace:', workspace);
|
|
34
|
+
console.log('Rest:', rest);
|
|
27
35
|
|
|
28
|
-
|
|
36
|
+
// If the “rest” is empty or starts with flags, insert a default script
|
|
37
|
+
if (rest.length === 0 || rest[0].startsWith('--')) {
|
|
38
|
+
console.log('Rest is empty or starts with flags, inserting DEFAULT_SCRIPT');
|
|
39
|
+
// Prefer an explicit script name; if you want to always use `run`, do:
|
|
40
|
+
// rest = ['run', DEFAULT_SCRIPT, ...rest];
|
|
41
|
+
rest = [DEFAULT_SCRIPT, ...rest]; // yarn workspace <ws> dev --flags
|
|
42
|
+
console.log('Rest after inserting DEFAULT_SCRIPT:', rest);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const args = ['workspace', workspace, ...rest];
|
|
46
|
+
console.log('Final args for yarn:', args);
|
|
47
|
+
|
|
48
|
+
console.error(`Unknown command. Falling back to: yarn ${args.join(' ')}`);
|
|
49
|
+
|
|
50
|
+
const child = spawn('yarn', args, { stdio: 'inherit', shell: process.platform === 'win32' });
|
|
51
|
+
child.on('exit', (code) => {
|
|
52
|
+
console.log('Child process exited with code:', code);
|
|
53
|
+
process.exitCode = code ?? 1;
|
|
54
|
+
});
|
|
29
55
|
});
|
|
30
56
|
program.parse()
|