@mono-labs/cli 0.0.86 → 0.0.88

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.
@@ -7,6 +7,33 @@ import { getHasteConfig } from '../loadFromRoot.js';
7
7
  * Register commander commands for each haste file definition.
8
8
  * Handles argument, options, validation, and action wiring.
9
9
  */
10
+ export function createCliCommands() {
11
+ const config = new Command('config').description('Manage configuration');
12
+
13
+ config
14
+ .command('set <key> <value>')
15
+ .description('Set a configuration value')
16
+ .action((key, value) => {
17
+ console.log(`Setting ${key} to ${value}`);
18
+ });
19
+
20
+ config
21
+ .command('get <key>')
22
+ .description('Get a configuration value')
23
+ .action((key) => {
24
+ console.log(`Value of ${key} is ...`);
25
+ });
26
+
27
+ config
28
+ .command('list')
29
+ .description('List all configuration values')
30
+ .action(() => {
31
+ console.log('Listing config...');
32
+ });
33
+
34
+ return config;
35
+ }
36
+
10
37
  export function buildCommands(files) {
11
38
  const { config } = getHasteConfig();
12
39
  Object.entries(files).forEach(([commandName, configObject]) => {
@@ -1,7 +1,8 @@
1
1
  // Orchestrator for modular build-process command system.
2
2
  import { boot } from './boot.js';
3
- import { buildCommands } from './cliFactory.js';
3
+ import { buildCommands, createCliCommands } from './cliFactory.js';
4
4
  import { ensureSignalHandlers } from './runners/processManager.js';
5
+ import { program } from '../../app.js';
5
6
 
6
7
  const { files, config, rootDir } = boot();
7
8
  console.log('[build-process] root:', rootDir);
@@ -9,5 +10,6 @@ console.log('[build-process] commands discovered:', Object.keys(files));
9
10
 
10
11
  ensureSignalHandlers();
11
12
  buildCommands(files);
13
+ program.addCommand(createCliCommands());
12
14
 
13
15
  // (No direct export; importing this file registers commands on the shared commander program.)
@@ -5,7 +5,11 @@ import { getRootJson, getHasteConfig } from '../loadFromRoot.js';
5
5
 
6
6
  const WorkSpaceDirectory = '${dir}';
7
7
 
8
- export function executeCommandsIfWorkspaceAction(action, commands = []) {
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, { stdio: 'inherit', shell: true });
54
+ execSync(finalCommand, {
55
+ stdio: 'inherit',
56
+ shell: true,
57
+ env: { ...fullEnv },
58
+ });
50
59
  });
51
60
  }
52
61
  }
@@ -24,12 +24,16 @@ export function getHasteFiles() {
24
24
  return files.map((f) => path.join(dir, f));
25
25
  }
26
26
 
27
+ const disallowedFiles = ['tools'];
28
+
27
29
  export function getHasteConfig() {
28
30
  const objHaste = getHasteFiles();
29
31
  const hasteFileConfig = {};
30
32
  let configObject = {};
31
33
  for (const file of objHaste) {
32
34
  const fileName = path.basename(file).replace('.json', '');
35
+ if (disallowedFiles.includes(fileName))
36
+ throw new Error(`Disallowed file name in .mono directory: ${fileName}`);
33
37
  if (fileName === 'config') {
34
38
  const raw = fs.readFileSync(file, 'utf-8');
35
39
  const data = JSON.parse(raw);
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,24 @@ 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
+ console.log('envKeys:', envKeys);
42
+ envKeys.map((k) => {
43
+ envMapList.map((item) => {
44
+ envObj[k.replace('MONO', item)] = process.env[k];
45
+ });
46
+ });
47
+
36
48
  // If the “rest” is empty or starts with flags, insert a default script
37
49
 
38
50
  const args = ['workspace', workspace, ...rest];
39
51
  console.log('Final args for yarn:', args);
40
52
 
41
53
  console.error(`Unknown command. Falling back to: yarn ${args.join(' ')}`);
42
- executeCommandsIfWorkspaceAction(args, preactions);
54
+ executeCommandsIfWorkspaceAction(args, preactions, envObj);
43
55
  console.log('yarn', args, {
44
56
  stdio: 'inherit',
45
57
  shell: process.platform === 'win32',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mono-labs/cli",
3
- "version": "0.0.86",
3
+ "version": "0.0.88",
4
4
  "description": "A CLI tool for building and deploying projects",
5
5
  "type": "module",
6
6
  "main": "index.js",