@codemoreira/esad 1.4.6-30 → 1.4.6-32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemoreira/esad",
3
- "version": "1.4.6-30",
3
+ "version": "1.4.6-32",
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",
@@ -86,7 +86,8 @@ module.exports = async (subcommand) => {
86
86
  if (shouldStartBundler && choice !== 'c') {
87
87
  console.log(`\nšŸ› ļø Starting Rspack Bundler in a new window...`);
88
88
  if (process.platform === 'win32') {
89
- spawn('cmd', ['/c', 'start', '/D', cwd, 'npx', 'react-native', 'webpack-start'], {
89
+ const npxCmd = 'npx.cmd';
90
+ spawn('cmd', ['/c', 'start', '/D', cwd, npxCmd, 'react-native', 'webpack-start'], {
90
91
  detached: true,
91
92
  stdio: 'ignore',
92
93
  shell: true
@@ -122,10 +123,10 @@ module.exports = async (subcommand) => {
122
123
  // 6. Launch Native App
123
124
  if (choice === 'a') {
124
125
  console.log(`šŸ¤– Compiling and launching on Android...`);
125
- await runProcess('npx', ['react-native', 'run-android', '--no-packager'], cwd);
126
+ await runProcess('react-native', ['run-android', '--no-packager'], cwd);
126
127
  } else if (choice === 'i') {
127
128
  console.log(`šŸŽ Compiling and launching on iOS...`);
128
- await runProcess('npx', ['react-native', 'run-ios', '--no-packager'], cwd);
129
+ await runProcess('react-native', ['run-ios', '--no-packager'], cwd);
129
130
  } else if (choice === 'b') {
130
131
  if (portBusy) {
131
132
  console.log(`✨ Bundler is already active. You can launch manual native runs.`);
@@ -138,10 +139,9 @@ module.exports = async (subcommand) => {
138
139
  } else {
139
140
  // Other subcommands (android, ios directly)
140
141
  try {
141
- if (subcommand === 'android') {
142
- await runProcess('npx', ['react-native', 'run-android', '--no-packager'], cwd);
142
+ await runProcess('react-native', ['run-android', '--no-packager'], cwd);
143
143
  } else if (subcommand === 'ios') {
144
- await runProcess('npx', ['react-native', 'run-ios', '--no-packager'], cwd);
144
+ await runProcess('react-native', ['run-ios', '--no-packager'], cwd);
145
145
  }
146
146
  } catch (err) {
147
147
  console.error(`āŒ Error running host command: ${err.message}`);
@@ -1,4 +1,6 @@
1
1
  const { spawn } = require('cross-spawn');
2
+ const path = require('path');
3
+ const fs = require('fs-extra');
2
4
 
3
5
  /**
4
6
  * Helper to spawn commands synchronously
@@ -9,10 +11,40 @@ const { spawn } = require('cross-spawn');
9
11
  */
10
12
  const runProcess = (cmd, args, cwd = process.cwd()) => {
11
13
  return new Promise((resolve, reject) => {
12
- const child = spawn(cmd, args, { stdio: 'inherit', cwd, shell: true });
14
+ let finished = false;
15
+ const finalize = (fn, arg) => {
16
+ if (finished) return;
17
+ finished = true;
18
+ fn(arg);
19
+ };
20
+
21
+ // Try to find a local binary in node_modules/.bin first
22
+ const isWin = process.platform === 'win32';
23
+ const localBinPath = path.join(cwd, 'node_modules', '.bin', isWin ? `${cmd}.cmd` : cmd);
24
+
25
+ let command = cmd;
26
+ let finalArgs = args;
27
+
28
+ if (fs.existsSync(localBinPath)) {
29
+ command = localBinPath;
30
+ } else {
31
+ // Fallback to npx
32
+ command = isWin ? 'npx.cmd' : 'npx';
33
+ finalArgs = [cmd, ...args];
34
+ }
35
+
36
+ const child = spawn(command, finalArgs, { stdio: 'inherit', cwd, shell: true });
37
+
38
+ child.on('error', err => {
39
+ finalize(reject, new Error(`Failed to spawn command ${command}: ${err.message}`));
40
+ });
41
+
13
42
  child.on('close', code => {
14
- if (code !== 0) reject(new Error(`Command ${cmd} ${args.join(' ')} failed`));
15
- else resolve();
43
+ if (code !== 0) {
44
+ finalize(reject, new Error(`Command ${command} ${finalArgs.join(' ')} failed with exit code ${code}`));
45
+ } else {
46
+ finalize(resolve);
47
+ }
16
48
  });
17
49
  });
18
50
  };