rn-iso 0.4.4 → 0.4.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/package.json +1 -1
- package/skill/SKILL.md +2 -2
- package/src/commands/start.js +12 -4
- package/src/metro.js +7 -6
- package/src/runner.js +4 -4
package/package.json
CHANGED
package/skill/SKILL.md
CHANGED
|
@@ -30,7 +30,7 @@ From the project root (or any subdirectory):
|
|
|
30
30
|
## CRITICAL rules
|
|
31
31
|
|
|
32
32
|
- **Pass `--auto` for non-interactive use** of `ios` or `android`. Without it, the command will prompt with an arrow-key picker if multiple unclaimed sims/AVDs exist. `--auto` is also implied automatically when stdin isn't a TTY (e.g., when an agent pipes the command), so under most agent harnesses you don't have to remember the flag — but passing it explicitly is harmless and clearer.
|
|
33
|
-
- **Forward extra flags to the build CLI with `--`.** `npx rn-iso ios -- --variant=release` (or `android -- --mode=diaRelease`) appends those flags to the underlying `react-native run-*` / `expo run:*` invocation. Useful for release-mode builds, custom terminals, etc. Last-wins semantics, so extras can override defaults rn-iso set earlier in the command.
|
|
33
|
+
- **Forward extra flags to the build CLI with `--`.** `npx rn-iso ios -- --variant=release` (or `android -- --mode=diaRelease`) appends those flags to the underlying `react-native run-*` / `expo run:*` invocation. Useful for release-mode builds, custom terminals, etc. Last-wins semantics, so extras can override defaults rn-iso set earlier in the command. `start` accepts the same `--` extras and forwards them to `expo start` / `react-native start` — e.g. `npx rn-iso start -- --reset-cache`. If Metro is already running, extras are not applied (run `rn-iso stop` first and re-run).
|
|
34
34
|
- **`--auto` will NOT take over a claimed sim/AVD.** If every device is claimed by other rn-iso projects, `--auto` errors. To take one over, run the command interactively (no `--auto`, with a real TTY) and confirm at the prompt — only do this if the user explicitly asks.
|
|
35
35
|
- **Always use `npx rn-iso device` to discover your target.** Never assume `booted` is your sim — another project's simulator might be booted too.
|
|
36
36
|
- **Always pass the UDID/serial explicitly** to `xcrun simctl` and `adb -s`. Examples:
|
|
@@ -81,7 +81,7 @@ Reserve binds the sim to the current project the same way `ios` does, but skips
|
|
|
81
81
|
## Other useful commands
|
|
82
82
|
|
|
83
83
|
- `npx rn-iso status` — show all projects, their assignments, and Metro state.
|
|
84
|
-
- `npx rn-iso start` — start Metro detached on the project's assigned port WITHOUT building/installing. Useful to keep Metro alive across builds.
|
|
84
|
+
- `npx rn-iso start [-- <extras...>]` — start Metro detached on the project's assigned port WITHOUT building/installing. Useful to keep Metro alive across builds. Extras after `--` are forwarded to `expo start` / `react-native start` (e.g. `--reset-cache`).
|
|
85
85
|
- `npx rn-iso stop [<port>|<shortcut>|<path>]` — kill Metro. No arg = current project. Passing a port (e.g. `8083`) kills whatever is on it; a project shortcut (label or unique basename) or absolute path targets that project. Finds the process by port, so it works whether Metro was started by `npx rn-iso start` or by the build CLI.
|
|
86
86
|
- `npx rn-iso release [<port>|<shortcut>|<path>] [--platform <p>] [--shutdown]` — free a project's sim assignment. Defaults to the current project. Target can also be a Metro port (`8083`) or a shortcut (label / unique basename). `--shutdown` also stops the sim/emulator.
|
|
87
87
|
- `npx rn-iso shutdown [<shortcut>|<path>] [-y] [--keep-sims]` — kill Metro, shut down sims/emulators, and clear device assignments. With no arg, scopes to **every** registered project (end-of-day reset); pass a project shortcut (label or unique basename) or absolute path to scope to one. Note this does NOT default to the current project (deliberate — `shutdown` is the explicit "tear it all down" command). Prompts unless `-y` / non-TTY; `--keep-sims` only kills Metro and clears assignments without touching the sims. Project entries themselves stay registered, so `metroPort` allocations and labels survive.
|
package/src/commands/start.js
CHANGED
|
@@ -8,8 +8,9 @@ import { ensureMetro } from '../metro.js';
|
|
|
8
8
|
export default function startCommand(program) {
|
|
9
9
|
program
|
|
10
10
|
.command('start')
|
|
11
|
-
.description('Ensure Metro is running for the current project (no platform action)')
|
|
12
|
-
.
|
|
11
|
+
.description('Ensure Metro is running for the current project (no platform action). Pass extra flags to `expo start` / `react-native start` after `--`, e.g. `rn-iso start -- --reset-cache`.')
|
|
12
|
+
.argument('[extras...]', 'Flags forwarded as-is to expo/react-native start (after `--`)')
|
|
13
|
+
.action(async (extras) => {
|
|
13
14
|
const root = findProjectRoot(process.cwd());
|
|
14
15
|
if (!root) {
|
|
15
16
|
console.error(chalk.red('Not in a React Native project (no package.json found).'));
|
|
@@ -32,9 +33,16 @@ export default function startCommand(program) {
|
|
|
32
33
|
proj = getProject(root);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
const metro = await ensureMetro({ projectPath: root, isExpo, port: proj.metroPort });
|
|
36
|
+
const metro = await ensureMetro({ projectPath: root, isExpo, port: proj.metroPort, extras });
|
|
36
37
|
if (metro.alreadyRunning) {
|
|
37
|
-
|
|
38
|
+
if (extras?.length) {
|
|
39
|
+
console.log(chalk.yellow(
|
|
40
|
+
`Metro already running on port ${proj.metroPort}; extras (${extras.join(' ')}) were not applied. ` +
|
|
41
|
+
`Run \`rn-iso stop\` first and re-run to apply them.`
|
|
42
|
+
));
|
|
43
|
+
} else {
|
|
44
|
+
console.log(chalk.dim(`Metro already running on port ${proj.metroPort}`));
|
|
45
|
+
}
|
|
38
46
|
} else {
|
|
39
47
|
setMetro(root, proj.metroPort, metro.pid);
|
|
40
48
|
console.log(chalk.green(`Metro started (pid ${metro.pid}, port ${proj.metroPort})`));
|
package/src/metro.js
CHANGED
|
@@ -15,22 +15,23 @@ export function logFileFor(projectPath) {
|
|
|
15
15
|
return join(dir, `${projectHash(projectPath)}.log`);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export function buildMetroSpawnArgs({ isExpo, port }) {
|
|
18
|
+
export function buildMetroSpawnArgs({ isExpo, port, extras = [] }) {
|
|
19
|
+
const base = isExpo
|
|
20
|
+
? ['expo', 'start', '--port', String(port)]
|
|
21
|
+
: ['react-native', 'start', '--port', String(port)];
|
|
19
22
|
return {
|
|
20
23
|
cmd: 'npx',
|
|
21
|
-
args:
|
|
22
|
-
? ['expo', 'start', '--port', String(port)]
|
|
23
|
-
: ['react-native', 'start', '--port', String(port)],
|
|
24
|
+
args: [...base, ...extras],
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
export async function ensureMetro({ projectPath, isExpo, port, detach = true }) {
|
|
28
|
+
export async function ensureMetro({ projectPath, isExpo, port, extras = [], detach = true }) {
|
|
28
29
|
if (await isMetroRunning(port)) return { alreadyRunning: true, pid: null };
|
|
29
30
|
|
|
30
31
|
const log = logFileFor(projectPath);
|
|
31
32
|
const fd = openSync(log, 'a');
|
|
32
33
|
|
|
33
|
-
const { cmd, args } = buildMetroSpawnArgs({ isExpo, port });
|
|
34
|
+
const { cmd, args } = buildMetroSpawnArgs({ isExpo, port, extras });
|
|
34
35
|
const exec = getExecutor();
|
|
35
36
|
const child = exec.spawn(cmd, args, {
|
|
36
37
|
cwd: projectPath,
|
package/src/runner.js
CHANGED
|
@@ -66,7 +66,7 @@ export function buildScriptCommand(packageManager, scriptName, extraArgs = []) {
|
|
|
66
66
|
|
|
67
67
|
// Decide which CLI a script invokes. Affects flag names:
|
|
68
68
|
// iOS: Expo `--device <UDID>` | RN `--udid <UDID>`
|
|
69
|
-
// Android: Expo `--device <AVD-name>` | RN `--
|
|
69
|
+
// Android: Expo `--device <AVD-name>` | RN `--device <serial>`
|
|
70
70
|
// Expo's run:android resolves --device by name (not by serial), so we pass
|
|
71
71
|
// the AVD name there even though we boot/track by serial.
|
|
72
72
|
export function detectScriptCli(scriptBody) {
|
|
@@ -113,8 +113,8 @@ export function buildAndroidCommand({ projectRoot, packageManager, scriptName, i
|
|
|
113
113
|
const script = getProjectScript(projectRoot, scriptName);
|
|
114
114
|
if (script) {
|
|
115
115
|
const cli = detectScriptCli(script);
|
|
116
|
-
// Expo: --device <AVD name | serial>; RN: --
|
|
117
|
-
const deviceFlag = cli === 'expo' ? `--device "${expoDeviceArg}"` : `--
|
|
116
|
+
// Expo: --device <AVD name | serial>; RN: --device <serial>.
|
|
117
|
+
const deviceFlag = cli === 'expo' ? `--device "${expoDeviceArg}"` : `--device ${serial}`;
|
|
118
118
|
return buildScriptCommand(packageManager, scriptName, [
|
|
119
119
|
deviceFlag,
|
|
120
120
|
`--port ${port}`,
|
|
@@ -126,7 +126,7 @@ export function buildAndroidCommand({ projectRoot, packageManager, scriptName, i
|
|
|
126
126
|
if (isExpo) {
|
|
127
127
|
return `npx expo run:android --device "${expoDeviceArg}" --port ${port}${tailStr}`;
|
|
128
128
|
}
|
|
129
|
-
return `RCT_METRO_PORT=${port} npx react-native run-android --
|
|
129
|
+
return `RCT_METRO_PORT=${port} npx react-native run-android --device ${serial}${tailStr}`;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
// POSIX-safe single-quote shell escape. Leaves "safe" tokens (alnum and a
|