@mono-labs/cli 0.0.38 → 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.
- package/lib/commands/loadFromRoot.js +0 -6
- package/lib/index.js +49 -48
- package/package.json +1 -1
- package/lib/commands/reset.js +0 -31
|
@@ -24,10 +24,6 @@ export function getHasteFiles() {
|
|
|
24
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
28
|
const objHaste = getHasteFiles();
|
|
33
29
|
const hasteFileConfig = {};
|
|
@@ -36,12 +32,10 @@ export function getHasteConfig() {
|
|
|
36
32
|
const fileName = path.basename(file).replace('.json', '');
|
|
37
33
|
if (fileName === 'config') {
|
|
38
34
|
const raw = fs.readFileSync(file, 'utf-8');
|
|
39
|
-
console.log('file content', file, raw);
|
|
40
35
|
const data = JSON.parse(raw);
|
|
41
36
|
if (data) configObject = data;
|
|
42
37
|
} else {
|
|
43
38
|
const raw = fs.readFileSync(file, 'utf-8');
|
|
44
|
-
console.log('file content', file, raw);
|
|
45
39
|
const data = JSON.parse(raw);
|
|
46
40
|
hasteFileConfig[fileName] = data;
|
|
47
41
|
}
|
package/lib/index.js
CHANGED
|
@@ -1,55 +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/
|
|
13
|
-
import './commands/
|
|
14
|
-
import './commands/
|
|
15
|
-
import './commands/
|
|
16
|
-
import './commands/
|
|
17
|
-
import { getHasteConfig} from './commands/loadFromRoot.js'
|
|
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';
|
|
18
17
|
|
|
19
|
-
const {config} = getHasteConfig()
|
|
18
|
+
const { config } = getHasteConfig();
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
const workspacemap = config.workspace || {}
|
|
20
|
+
const workspacemap = config.workspace || {};
|
|
23
21
|
|
|
24
22
|
program.on('command:*', (operands) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
+
});
|
|
54
55
|
});
|
|
55
|
-
program.parse()
|
|
56
|
+
program.parse();
|
package/package.json
CHANGED
package/lib/commands/reset.js
DELETED
|
@@ -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
|
-
})
|