@mono-labs/cli 0.0.37 → 0.0.39

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,49 +1,51 @@
1
- import fs from 'fs'
2
- import path from 'path'
1
+ import fs from 'fs';
2
+ import path from 'path';
3
3
 
4
4
  export function getRootDirectory() {
5
- return path.join(process.cwd(), 'myfile.json')
5
+ return path.join(process.cwd(), 'myfile.json');
6
6
  }
7
7
 
8
8
  export function getRootJson() {
9
- const jsonPath = path.join(process.cwd(), 'package.json') // cwd + file
10
- const raw = fs.readFileSync(jsonPath, 'utf-8')
11
- const data = JSON.parse(raw)
9
+ const jsonPath = path.join(process.cwd(), 'package.json'); // cwd + file
10
+ const raw = fs.readFileSync(jsonPath, 'utf-8');
11
+ const data = JSON.parse(raw);
12
12
 
13
- return data
13
+ return data;
14
14
  }
15
15
 
16
16
  export function getHasteFiles() {
17
- const dir = path.join(process.cwd(), '.mono')
17
+ const dir = path.join(process.cwd(), '.mono');
18
18
 
19
- if (!fs.existsSync(dir)) {
20
- return []
21
- }
19
+ if (!fs.existsSync(dir)) {
20
+ return [];
21
+ }
22
22
 
23
- const files = fs.readdirSync(dir) // names only
24
- return files.map((f) => path.join(dir, f))
23
+ const files = fs.readdirSync(dir); // names only
24
+ return files.map((f) => path.join(dir, f));
25
25
  }
26
26
 
27
- const workspaceMap = {
28
- "web": "next-app",
29
- "app": "expo-app"
30
- }
31
27
  export function getHasteConfig() {
32
- const objHaste = getHasteFiles()
33
- const hasteFileConfig = {}
34
- for (const file of objHaste) {
35
- const fileName = path.basename(file).replace('.json', '')
36
- if(fileName === 'config') {
37
- continue
38
- } else {
39
- const raw = fs.readFileSync(file, 'utf-8')
40
- console.log('file content', file, raw)
41
- const data = JSON.parse(raw)
42
- hasteFileConfig[fileName] = data
43
- }
44
- }
45
-
46
- return {files:hasteFileConfig, config: {
47
- workspace: workspaceMap
48
- }}
28
+ const objHaste = getHasteFiles();
29
+ const hasteFileConfig = {};
30
+ let configObject = {};
31
+ for (const file of objHaste) {
32
+ const fileName = path.basename(file).replace('.json', '');
33
+ if (fileName === 'config') {
34
+ const raw = fs.readFileSync(file, 'utf-8');
35
+ const data = JSON.parse(raw);
36
+ if (data) configObject = data;
37
+ } else {
38
+ const raw = fs.readFileSync(file, 'utf-8');
39
+ const data = JSON.parse(raw);
40
+ hasteFileConfig[fileName] = data;
41
+ }
42
+ }
43
+
44
+ return {
45
+ files: hasteFileConfig,
46
+ // config: {
47
+ // workspace: workspaceMap,
48
+ // },
49
+ config: configObject,
50
+ };
49
51
  }
package/lib/index.js CHANGED
@@ -1,60 +1,56 @@
1
- import 'dotenv/config'
1
+ import 'dotenv/config';
2
2
  import spawn from 'cross-spawn';
3
3
 
4
- import { program } from './app.js'
5
- import './commands/build/index.js'
6
- import './commands/deploy/index.js'
7
- import './commands/destroy.js'
8
- import './commands/dev/index.js'
9
- import './commands/generate/index.js'
10
- import './commands/init/index.js'
11
- import './commands/prune/index.js'
12
- import './commands/reset.js'
13
- import './commands/seed/index.js'
14
- import './commands/submit/index.js'
15
- import './commands/update/index.js'
16
- import './commands/build-process/index.js'
17
- import { getHasteConfig} from './commands/loadFromRoot.js'
18
- const workspaceMap = {
19
- "web": "next-app",
20
- "app": "expo-app"
21
- }
4
+ import { program } from './app.js';
5
+ import './commands/build/index.js';
6
+ import './commands/deploy/index.js';
7
+ import './commands/destroy.js';
8
+ import './commands/dev/index.js';
9
+ import './commands/generate/index.js';
10
+ import './commands/init/index.js';
11
+ import './commands/prune/index.js';
12
+ import './commands/seed/index.js';
13
+ import './commands/submit/index.js';
14
+ import './commands/update/index.js';
15
+ import './commands/build-process/index.js';
16
+ import { getHasteConfig } from './commands/loadFromRoot.js';
22
17
 
18
+ const { config } = getHasteConfig();
23
19
 
24
- const {config} = getHasteConfig()
25
-
26
-
27
- const workspacemap = config.workspace || {}
20
+ const workspacemap = config.workspace || {};
28
21
 
29
22
  program.on('command:*', (operands) => {
30
- const [cmd] = operands; // e.g. "destroy3"
31
- const raw = program.rawArgs.slice(2); // after `node script.js`
32
- const i = raw.indexOf(cmd);
33
- const tokens = i >= 0 ? raw.slice(i) : operands;
34
-
35
- const workspace = workspacemap[tokens[0]] || tokens[0];
36
- let rest = tokens.slice(1);
37
- console.log('Workspace:', workspace);
38
- console.log('Rest:', rest);
39
-
40
- // If the “rest” is empty or starts with flags, insert a default script
41
- if (rest.length === 0 || rest[0].startsWith('--')) {
42
- console.log('Rest is empty or starts with flags, inserting DEFAULT_SCRIPT');
43
- // Prefer an explicit script name; if you want to always use `run`, do:
44
- // rest = ['run', DEFAULT_SCRIPT, ...rest];
45
- rest = [ ...rest]; // yarn workspace <ws> dev --flags
46
- console.log('Rest after inserting DEFAULT_SCRIPT:', rest);
47
- }
48
-
49
- const args = ['workspace', workspace, ...rest];
50
- console.log('Final args for yarn:', args);
51
-
52
- console.error(`Unknown command. Falling back to: yarn ${args.join(' ')}`);
53
-
54
- const child = spawn('yarn', args, { stdio: 'inherit', shell: process.platform === 'win32' });
55
- child.on('exit', (code) => {
56
- console.log('Child process exited with code:', code);
57
- process.exitCode = code ?? 1;
58
- });
23
+ const [cmd] = operands; // e.g. "destroy3"
24
+ const raw = program.rawArgs.slice(2); // after `node script.js`
25
+ const i = raw.indexOf(cmd);
26
+ const tokens = i >= 0 ? raw.slice(i) : operands;
27
+
28
+ const workspace = workspacemap[tokens[0]] || tokens[0];
29
+ let rest = tokens.slice(1);
30
+ console.log('Workspace:', workspace);
31
+ console.log('Rest:', rest);
32
+
33
+ // 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
+
42
+ const args = ['workspace', workspace, ...rest];
43
+ console.log('Final args for yarn:', args);
44
+
45
+ console.error(`Unknown command. Falling back to: yarn ${args.join(' ')}`);
46
+
47
+ const child = spawn('yarn', args, {
48
+ stdio: 'inherit',
49
+ shell: process.platform === 'win32',
50
+ });
51
+ child.on('exit', (code) => {
52
+ console.log('Child process exited with code:', code);
53
+ process.exitCode = code ?? 1;
54
+ });
59
55
  });
60
- program.parse()
56
+ program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mono-labs/cli",
3
- "version": "0.0.37",
3
+ "version": "0.0.39",
4
4
  "description": "A CLI tool for building and deploying projects",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -35,6 +35,7 @@
35
35
  "cross-spawn": "^7.0.6",
36
36
  "dotenv": "^17.2.0",
37
37
  "inquirer": "^12.8.2",
38
+ "prettier": "^3.6.2",
38
39
  "tree-kill": "^1.2.2"
39
40
  },
40
41
  "devDependencies": {
@@ -1,31 +0,0 @@
1
- import { spawn } from 'child_process'
2
-
3
- import { program } from '../app.js'
4
-
5
- function createChild(command) {
6
- const child = spawn(command, {
7
- stdio: ['inherit', 'pipe', 'pipe'], // Read from terminal, but capture output
8
- shell: true,
9
- env: {
10
- ...process.env,
11
- },
12
- })
13
-
14
- child.stdout.on('data', (data) => {
15
- process.stdout.write(data) // pipe to main stdout
16
- })
17
-
18
- child.stderr.on('data', (data) => {
19
- process.stderr.write(data) // pipe errors
20
- })
21
- child.on('message', (data) => {
22
- console.log(`Message from child process: ${data}`)
23
- })
24
- }
25
- program
26
- .command('reset')
27
- .description('Execute eas build command')
28
- .option('-s, --soft', 'Pull from live')
29
- .action(async (options) => {
30
- createChild(`git reset ${options.soft ? '--soft' : '--mixed '} HEAD~1`)
31
- })