@codemoreira/esad 1.4.6-4 → 1.4.6-6
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/bin/esad.js +43 -17
- package/package.json +3 -2
- package/src/cli/commands/build.js +2 -1
- package/src/cli/commands/dev.js +2 -1
- package/src/cli/commands/host.js +14 -10
- package/src/cli/utils/process.js +2 -1
- package/src/cli/utils/scaffold.js +1 -1
package/bin/esad.js
CHANGED
|
@@ -16,7 +16,7 @@ program
|
|
|
16
16
|
.version(pkg.version)
|
|
17
17
|
.description('esad - Easy Super App Development Toolkit');
|
|
18
18
|
|
|
19
|
-
// ---
|
|
19
|
+
// --- COMMAND: esad init ---
|
|
20
20
|
program
|
|
21
21
|
.command('init <project-name>')
|
|
22
22
|
.description('Scaffold a new ESAD workspace containing the Host App')
|
|
@@ -34,15 +34,52 @@ program
|
|
|
34
34
|
process.exit(0);
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
// --- COMMAND: esad
|
|
37
|
+
// --- COMMAND: esad dev ---
|
|
38
|
+
program
|
|
39
|
+
.command('dev [platform]')
|
|
40
|
+
.description('Start the development environment for the Host App (platform: android, ios)')
|
|
41
|
+
.action(async (platform) => {
|
|
42
|
+
await hostCommand(platform);
|
|
43
|
+
process.exit(0);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// --- COMMAND: esad android ---
|
|
38
47
|
program
|
|
39
|
-
.command('
|
|
40
|
-
.description('
|
|
41
|
-
.action(async (
|
|
42
|
-
await hostCommand(
|
|
48
|
+
.command('android')
|
|
49
|
+
.description('Run Host on Android (alias for esad dev android)')
|
|
50
|
+
.action(async () => {
|
|
51
|
+
await hostCommand('android');
|
|
43
52
|
process.exit(0);
|
|
44
53
|
});
|
|
45
54
|
|
|
55
|
+
// --- COMMAND: esad ios ---
|
|
56
|
+
program
|
|
57
|
+
.command('ios')
|
|
58
|
+
.description('Run Host on iOS (alias for esad dev ios)')
|
|
59
|
+
.action(async () => {
|
|
60
|
+
await hostCommand('ios');
|
|
61
|
+
process.exit(0);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// --- COMMAND: esad start ---
|
|
65
|
+
program
|
|
66
|
+
.command('start')
|
|
67
|
+
.description('Alias for esad dev')
|
|
68
|
+
.action(async () => {
|
|
69
|
+
await hostCommand('dev');
|
|
70
|
+
process.exit(0);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// --- COMMAND: esad push ---
|
|
74
|
+
program
|
|
75
|
+
.command('push')
|
|
76
|
+
.option('-i, --id <moduleId>', 'The Module ID to sync to Dev-Cloud')
|
|
77
|
+
.option('-p, --platform <platform>', 'Platform (android, ios)', 'android')
|
|
78
|
+
.description('Build and Push the module bundle to the Dev-Cloud for global previewing')
|
|
79
|
+
.action(async (options) => {
|
|
80
|
+
await devCommand(options);
|
|
81
|
+
});
|
|
82
|
+
|
|
46
83
|
// --- COMMAND: esad create-module ---
|
|
47
84
|
program
|
|
48
85
|
.command('create-module <module-name>')
|
|
@@ -75,15 +112,4 @@ program
|
|
|
75
112
|
process.exit(0);
|
|
76
113
|
});
|
|
77
114
|
|
|
78
|
-
// --- COMMAND: esad dev ---
|
|
79
|
-
program
|
|
80
|
-
.command('dev')
|
|
81
|
-
.option('-i, --id <moduleId>', 'The Module ID to sync to Dev-Cloud')
|
|
82
|
-
.option('-p, --platform <platform>', 'Platform (android, ios)', 'android')
|
|
83
|
-
.description('Build and Push the module bundle to the Dev-Cloud for global previewing')
|
|
84
|
-
.action(async (options) => {
|
|
85
|
-
await devCommand(options);
|
|
86
|
-
// Note: dev command has its own shutdown logic with SIGINT/SIGTERM
|
|
87
|
-
});
|
|
88
|
-
|
|
89
115
|
program.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codemoreira/esad",
|
|
3
|
-
"version": "1.4.6-
|
|
3
|
+
"version": "1.4.6-6",
|
|
4
4
|
"description": "Easy Super App Development - Zero-Config CLI and DevTools for React Native Module Federation",
|
|
5
5
|
"main": "src/plugin/index.js",
|
|
6
6
|
"types": "./src/plugin/index.d.ts",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"./client": {
|
|
17
17
|
"types": "./src/client/index.d.ts",
|
|
18
18
|
"default": "./src/client/index.js"
|
|
19
|
-
}
|
|
19
|
+
},
|
|
20
|
+
"./config-plugin": "./src/plugin/config-plugin.js"
|
|
20
21
|
},
|
|
21
22
|
"bin": {
|
|
22
23
|
"esad": "./bin/esad.js"
|
|
@@ -52,7 +52,8 @@ module.exports = async (options) => {
|
|
|
52
52
|
'--platform', platform,
|
|
53
53
|
'--dev', 'false',
|
|
54
54
|
'--bundle-output', bundleOutput,
|
|
55
|
-
'--assets-dest', path.dirname(bundleOutput)
|
|
55
|
+
'--assets-dest', path.dirname(bundleOutput),
|
|
56
|
+
'--reset-cache'
|
|
56
57
|
], cwd);
|
|
57
58
|
|
|
58
59
|
console.log(chalk.green(`\n✅ Build complete! Assets generated in build/ directory.`));
|
package/src/cli/commands/dev.js
CHANGED
|
@@ -84,7 +84,8 @@ module.exports = async (options) => {
|
|
|
84
84
|
'--platform', platform,
|
|
85
85
|
'--dev', 'false',
|
|
86
86
|
'--bundle-output', bundleOutput,
|
|
87
|
-
'--assets-dest', path.dirname(bundleOutput)
|
|
87
|
+
'--assets-dest', path.dirname(bundleOutput),
|
|
88
|
+
'--reset-cache'
|
|
88
89
|
], cwd);
|
|
89
90
|
} catch (err) {
|
|
90
91
|
console.error(chalk.red(`❌ Build failed.`));
|
package/src/cli/commands/host.js
CHANGED
|
@@ -7,12 +7,7 @@ const readline = require('readline');
|
|
|
7
7
|
const { getWorkspaceConfig } = require('../utils/config');
|
|
8
8
|
const { prepareNative } = require('../utils/scaffold');
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
input: process.stdin,
|
|
12
|
-
output: process.stdout
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const askQuestion = (query) => new Promise((resolve) => rl.question(query, resolve));
|
|
10
|
+
const askQuestion = (query, rl) => new Promise((resolve) => rl.question(query, resolve));
|
|
16
11
|
|
|
17
12
|
/**
|
|
18
13
|
* Check if a port is in use
|
|
@@ -28,6 +23,12 @@ const isPortInUse = (port) => new Promise((resolve) => {
|
|
|
28
23
|
});
|
|
29
24
|
|
|
30
25
|
module.exports = async (subcommand) => {
|
|
26
|
+
const rl = readline.createInterface({
|
|
27
|
+
input: process.stdin,
|
|
28
|
+
output: process.stdout
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
if (!subcommand) subcommand = 'dev';
|
|
31
32
|
let cwd = process.cwd();
|
|
32
33
|
let pkgPath = path.join(cwd, 'package.json');
|
|
33
34
|
|
|
@@ -64,7 +65,7 @@ module.exports = async (subcommand) => {
|
|
|
64
65
|
console.log(`[b] Bundler Only`);
|
|
65
66
|
console.log(`[c] Cancel`);
|
|
66
67
|
|
|
67
|
-
const choice = (await askQuestion(`\nSelect platform:
|
|
68
|
+
const choice = (await askQuestion(`\nSelect platform: `, rl)).toLowerCase();
|
|
68
69
|
|
|
69
70
|
if (choice === 'c') {
|
|
70
71
|
console.log(`\n❌ Cancelled.`);
|
|
@@ -86,13 +87,13 @@ module.exports = async (subcommand) => {
|
|
|
86
87
|
if (shouldStartBundler && choice !== 'c') {
|
|
87
88
|
console.log(`\n🛠️ Starting Rspack Bundler in a new window...`);
|
|
88
89
|
if (process.platform === 'win32') {
|
|
89
|
-
spawn('cmd', ['/c', 'start', '/D', cwd, 'npx', 'react-native', '
|
|
90
|
+
spawn('cmd', ['/c', 'start', '/D', cwd, 'npx', 'react-native', 'start', '--reset-cache'], {
|
|
90
91
|
detached: true,
|
|
91
92
|
stdio: 'ignore',
|
|
92
93
|
shell: true
|
|
93
94
|
}).unref();
|
|
94
95
|
} else {
|
|
95
|
-
spawn('npx', ['react-native', '
|
|
96
|
+
spawn('npx', ['react-native', 'start', '--reset-cache'], {
|
|
96
97
|
cwd,
|
|
97
98
|
detached: true,
|
|
98
99
|
stdio: 'inherit',
|
|
@@ -139,13 +140,16 @@ module.exports = async (subcommand) => {
|
|
|
139
140
|
// Other subcommands (android, ios directly)
|
|
140
141
|
try {
|
|
141
142
|
if (subcommand === 'android') {
|
|
143
|
+
console.log(`🤖 Compiling and launching on Android...`);
|
|
142
144
|
await runProcess('npx', ['expo', 'run:android', '--no-bundler'], cwd);
|
|
143
145
|
} else if (subcommand === 'ios') {
|
|
146
|
+
console.log(`🍎 Compiling and launching on iOS...`);
|
|
144
147
|
await runProcess('npx', ['expo', 'run:ios', '--no-bundler'], cwd);
|
|
145
148
|
}
|
|
146
149
|
} catch (err) {
|
|
147
150
|
console.error(`❌ Error running host command: ${err.message}`);
|
|
151
|
+
} finally {
|
|
152
|
+
rl.close();
|
|
148
153
|
}
|
|
149
|
-
rl.close();
|
|
150
154
|
}
|
|
151
155
|
};
|
package/src/cli/utils/process.js
CHANGED
|
@@ -8,8 +8,9 @@ const { spawn } = require('cross-spawn');
|
|
|
8
8
|
* @returns {Promise<void>}
|
|
9
9
|
*/
|
|
10
10
|
const runProcess = (cmd, args, cwd = process.cwd()) => {
|
|
11
|
+
const executable = (process.platform === 'win32' && cmd === 'npx') ? 'npx.cmd' : cmd;
|
|
11
12
|
return new Promise((resolve, reject) => {
|
|
12
|
-
const child = spawn(
|
|
13
|
+
const child = spawn(executable, args, { stdio: 'inherit', cwd, shell: true });
|
|
13
14
|
child.on('close', code => {
|
|
14
15
|
if (code !== 0) reject(new Error(`Command ${cmd} ${args.join(' ')} failed`));
|
|
15
16
|
else resolve();
|
|
@@ -76,7 +76,7 @@ async function prepareNative(cwd, platform = 'android') {
|
|
|
76
76
|
const appJson = await fs.readJson(appJsonPath);
|
|
77
77
|
if (appJson.expo) {
|
|
78
78
|
const plugins = appJson.expo.plugins || [];
|
|
79
|
-
const pluginName = '@codemoreira/esad/
|
|
79
|
+
const pluginName = '@codemoreira/esad/config-plugin';
|
|
80
80
|
|
|
81
81
|
if (!plugins.includes(pluginName) && !plugins.some(p => Array.isArray(p) && p[0] === pluginName)) {
|
|
82
82
|
appJson.expo.plugins = [...plugins, pluginName];
|