@mono-labs/cli 0.0.228 → 0.0.229
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/commands/build-process/boot.js +3 -3
- package/lib/commands/build-process/cliFactory.js +5 -5
- package/lib/commands/build-process/{runHasteCommand.js → runMonoCommand.js} +5 -5
- package/lib/commands/build-process/test.js +2 -2
- package/lib/commands/loadFromRoot.js +7 -7
- package/lib/generateNewEnvList.js +2 -2
- package/lib/index.js +2 -2
- package/package.json +1 -1
- package/types.d.ts +9 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// Boot logic: load root +
|
|
1
|
+
// Boot logic: load root + mono configuration
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
getMonoConfig,
|
|
4
4
|
getRootDirectory,
|
|
5
5
|
getRootJson,
|
|
6
6
|
} from '../loadFromRoot.js';
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
export function boot() {
|
|
9
9
|
const rootDir = getRootDirectory();
|
|
10
10
|
const rootJson = getRootJson();
|
|
11
|
-
const { files, config } =
|
|
11
|
+
const { files, config } = getMonoConfig();
|
|
12
12
|
return { rootDir, rootJson, files, config };
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { program } from '../../app.js';
|
|
2
2
|
import { Command } from 'commander';
|
|
3
|
-
import
|
|
3
|
+
import runMonoCommand from './runMonoCommand.js';
|
|
4
4
|
import { verifyOptionValue } from './validators.js';
|
|
5
5
|
import { mergeData, setData } from './dataLayer.js';
|
|
6
|
-
import {
|
|
6
|
+
import { getMonoConfig } from '../loadFromRoot.js';
|
|
7
7
|
import { pruneRepo } from '../prune/prune.js';
|
|
8
8
|
import { testFlag } from './testflag.js';
|
|
9
9
|
/**
|
|
10
|
-
* Register commander commands for each
|
|
10
|
+
* Register commander commands for each mono file definition.
|
|
11
11
|
* Handles argument, options, validation, and action wiring.
|
|
12
12
|
*/
|
|
13
13
|
export function createConfigCommands() {
|
|
@@ -44,7 +44,7 @@ export function createCliCommands() {
|
|
|
44
44
|
|
|
45
45
|
export function buildCommands(files) {
|
|
46
46
|
try {
|
|
47
|
-
const { config } =
|
|
47
|
+
const { config } = getMonoConfig();
|
|
48
48
|
Object.entries(files).forEach(([commandName, configObject]) => {
|
|
49
49
|
const optionsData = configObject.options || {};
|
|
50
50
|
|
|
@@ -147,7 +147,7 @@ export function buildCommands(files) {
|
|
|
147
147
|
const argVal = arg || configObject.argument?.default;
|
|
148
148
|
|
|
149
149
|
mergeData({ ...optionVals, arg: argVal });
|
|
150
|
-
await
|
|
150
|
+
await runMonoCommand(configObject, optionVals);
|
|
151
151
|
} catch (err) {
|
|
152
152
|
console.error('Error executing mono command:', err.message);
|
|
153
153
|
}
|
|
@@ -1,7 +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 {
|
|
4
|
+
import { getMonoConfig } from '../loadFromRoot.js';
|
|
5
5
|
import { parseEnvFile } from './readEnv.js';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import { testFlag } from './testflag.js';
|
|
@@ -19,14 +19,14 @@ export function getAllowAllKeys(cfg) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* Orchestrate execution of a single
|
|
22
|
+
* Orchestrate execution of a single mono command definition.
|
|
23
23
|
* Phases:
|
|
24
24
|
* 1. Preactions (sequential, blocking) via runForeground
|
|
25
25
|
* 2. Actions (background except last; last attached) via runBackground
|
|
26
26
|
* Environment selection based on --stage flag and injection of AWS_PROFILE.
|
|
27
27
|
*/
|
|
28
|
-
export async function
|
|
29
|
-
const { config } =
|
|
28
|
+
export async function runMonoCommand(configObject, options = {}) {
|
|
29
|
+
const { config } = getMonoConfig();
|
|
30
30
|
const devConfig = configObject.environments?.dev ?? {};
|
|
31
31
|
|
|
32
32
|
// Usage:
|
|
@@ -102,4 +102,4 @@ export async function runHasteCommand(configObject, options = {}) {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
export default
|
|
105
|
+
export default runMonoCommand;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execSync } from 'child_process';
|
|
2
|
-
import { getRootJson,
|
|
2
|
+
import { getRootJson, getMonoConfig } from '../loadFromRoot.js';
|
|
3
3
|
|
|
4
4
|
//Run Action List before all script actions
|
|
5
5
|
|
|
@@ -10,7 +10,7 @@ export function executeCommandsIfWorkspaceAction(
|
|
|
10
10
|
commands = [],
|
|
11
11
|
fullEnv
|
|
12
12
|
) {
|
|
13
|
-
const { config } =
|
|
13
|
+
const { config } = getMonoConfig();
|
|
14
14
|
const workspacemap = config.workspace?.packageMaps || {};
|
|
15
15
|
|
|
16
16
|
const result = execSync('yarn workspaces list --json', { encoding: 'utf8' })
|
|
@@ -13,7 +13,7 @@ export function getRootJson() {
|
|
|
13
13
|
return data;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export function
|
|
16
|
+
export function getMonoFiles() {
|
|
17
17
|
const dir = path.join(process.cwd(), '.mono');
|
|
18
18
|
|
|
19
19
|
if (!fs.existsSync(dir)) {
|
|
@@ -26,11 +26,11 @@ export function getHasteFiles() {
|
|
|
26
26
|
|
|
27
27
|
const disallowedFiles = ['tools'];
|
|
28
28
|
|
|
29
|
-
export function
|
|
30
|
-
const
|
|
31
|
-
const
|
|
29
|
+
export function getMonoConfig() {
|
|
30
|
+
const objMono = getMonoFiles();
|
|
31
|
+
const monoFileConfig = {};
|
|
32
32
|
let configObject = {};
|
|
33
|
-
for (const file of
|
|
33
|
+
for (const file of objMono) {
|
|
34
34
|
const fileName = path.basename(file).replace('.json', '');
|
|
35
35
|
if (disallowedFiles.includes(fileName))
|
|
36
36
|
throw new Error(`Disallowed file name in .mono directory: ${fileName}`);
|
|
@@ -41,12 +41,12 @@ export function getHasteConfig() {
|
|
|
41
41
|
} else {
|
|
42
42
|
const raw = fs.readFileSync(file, 'utf-8');
|
|
43
43
|
const data = JSON.parse(raw);
|
|
44
|
-
|
|
44
|
+
monoFileConfig[fileName] = data;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
return {
|
|
49
|
-
files:
|
|
49
|
+
files: monoFileConfig,
|
|
50
50
|
// config: {
|
|
51
51
|
// workspace: workspaceMap,
|
|
52
52
|
// },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getMonoConfig } from './commands/loadFromRoot.js';
|
|
2
2
|
export function generateNewEnvList(processEnv) {
|
|
3
|
-
const { config } =
|
|
3
|
+
const { config } = getMonoConfig();
|
|
4
4
|
|
|
5
5
|
const envMapList = config.envMap ?? ['FAILURE'];
|
|
6
6
|
const envKeys = Object.keys(processEnv).filter((k) => k.startsWith('MONO_'));
|
package/lib/index.js
CHANGED
|
@@ -9,14 +9,14 @@ import './commands/seed/index.js';
|
|
|
9
9
|
import './commands/submit/index.js';
|
|
10
10
|
import './commands/update/index.js';
|
|
11
11
|
import './commands/build-process/index.js';
|
|
12
|
-
import {
|
|
12
|
+
import { getMonoConfig } from './commands/loadFromRoot.js';
|
|
13
13
|
import { executeCommandsIfWorkspaceAction } from './commands/build-process/test.js';
|
|
14
14
|
import os from 'node:os';
|
|
15
15
|
import path from 'node:path';
|
|
16
16
|
const homeBin = path.join(os.homedir(), 'bin');
|
|
17
17
|
const PATH = [homeBin, process.env.PATH].filter(Boolean).join(path.delimiter);
|
|
18
18
|
|
|
19
|
-
const { config } =
|
|
19
|
+
const { config } = getMonoConfig();
|
|
20
20
|
|
|
21
21
|
const workspacemap = config.workspace?.packageMaps || {};
|
|
22
22
|
const preactions = config.workspace?.preactions || [];
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Type definitions for mono-labs CLI
|
|
2
2
|
|
|
3
3
|
declare module '@mono-labs/cli' {
|
|
4
|
-
export interface
|
|
4
|
+
export interface MonoConfig {
|
|
5
5
|
envMap?: Record<string, string>;
|
|
6
6
|
workspace?: {
|
|
7
7
|
packageMaps?: Record<string, string>;
|
|
@@ -9,7 +9,7 @@ declare module '@mono-labs/cli' {
|
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export interface
|
|
12
|
+
export interface MonoFiles {
|
|
13
13
|
[commandName: string]: CommandConfig;
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -42,8 +42,8 @@ declare module '@mono-labs/cli' {
|
|
|
42
42
|
export interface BootResult {
|
|
43
43
|
rootDir: string;
|
|
44
44
|
rootJson: any;
|
|
45
|
-
files:
|
|
46
|
-
config:
|
|
45
|
+
files: MonoFiles;
|
|
46
|
+
config: MonoConfig;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export function filterUnwantedEnvVarsEAS(env: string): NodeJS.ProcessEnv;
|
|
@@ -60,17 +60,17 @@ declare module '@mono-labs/cli' {
|
|
|
60
60
|
|
|
61
61
|
export function boot(): BootResult;
|
|
62
62
|
|
|
63
|
-
export function
|
|
64
|
-
files:
|
|
65
|
-
config:
|
|
63
|
+
export function getMonoConfig(): {
|
|
64
|
+
files: MonoFiles;
|
|
65
|
+
config: MonoConfig;
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
export function getRootDirectory(): string;
|
|
69
69
|
export function getRootJson(): any;
|
|
70
70
|
|
|
71
|
-
export function buildCommands(files:
|
|
71
|
+
export function buildCommands(files: MonoFiles): void;
|
|
72
72
|
|
|
73
|
-
export function
|
|
73
|
+
export function runMonoCommand(
|
|
74
74
|
configObject: CommandConfig,
|
|
75
75
|
options: Record<string, any>
|
|
76
76
|
): Promise<void>;
|