Compare commits

...
Author SHA1 Message Date
Brent Vatne 9d77b2ac50 [eas-cli] shorten the local egress banner
Interactive mode no longer mentions eas simulator:egress at all, since the
client starts and stops with the session in the same terminal. Both modes
open with one summary line that names the allowed destinations, the
loopback-forward mechanism sentence moves out of the banner (it stays in the
--egress-allow help), only entries the device host will not forward still
get a warning, and the connected message is just that.
2026-09-10 17:28:41 -07:00
Brent Vatne bcf7f3d892 [eas-cli] say when reconnecting the inline egress client actually applies
Ctrl+C stops the session along with the client, so 'if this process exits,
reconnect' read as a contradiction. Only SIGINT is handled: a terminal that
closes any other way leaves the session running. Say that, fold the Ctrl+C
note into the same block, and point at eas simulator:stop as the other way
out.
2026-09-10 17:20:41 -07:00
Brent Vatne 0dc37b07d2 [eas-cli] fill in PR number in changelog 2026-09-10 16:53:04 -07:00
Brent Vatne 05a485e80e [eas-cli] describe the inline egress client instead of asking to start one
Interactive simulator:start with --egress local printed the non-interactive
instructions (run eas simulator:egress, keep it running) and then started the
egress client itself. Tell formatRemoteSessionInstructions when the client runs
inline so it says so and mentions eas simulator:egress only as the way to
reconnect from another shell.
2026-09-10 16:52:59 -07:00
5 changed files with 82 additions and 57 deletions

No files matched your search

+2
View File
@@ -10,6 +10,8 @@ This is the log of notable changes to EAS CLI and related packages.
### 🐛 Bug fixes
- [eas-cli] Stop telling interactive `eas simulator:start --egress local` users to run `eas simulator:egress` when the egress client already runs in the same terminal. ([#4382](https://github.com/expo/eas-cli/pull/4382) by [@brentvatne](https://github.com/brentvatne))
### 🧹 Chores
## [24.1.0](https://github.com/expo/eas-cli/releases/tag/v24.1.0) - 2026-09-10
@@ -59,9 +59,7 @@ export default class SimulatorEgress extends EasCommand {
...egress,
signal: abortController.signal,
onConnected: () => {
Log.succeed(
"Egress tunnel connected. Proxied HTTP(S) requests can use this machine's network."
);
Log.succeed('Egress tunnel connected.');
},
onDisconnected: () => {
Log.warn(
@@ -419,7 +419,10 @@ export default class Simulator extends EasCommand {
Log.newLine();
Log.log(
formatRemoteSessionInstructions(remoteConfig, flags['out-config-type'], { egressAllow })
formatRemoteSessionInstructions(remoteConfig, flags['out-config-type'], {
egressAllow,
egressClientRunsInline: !nonInteractive,
})
);
Log.newLine();
@@ -444,11 +447,6 @@ export default class Simulator extends EasCommand {
let egressError: Error | undefined;
const egressAbortController = new AbortController();
if (localEgress) {
Log.log(
"🔀 Running the egress client in this terminal. When connected, proxied HTTP(S) requests can use this machine's network."
);
Log.log('Press Ctrl+C to stop both the egress client and the simulator session.');
Log.newLine();
sessionInterrupt.signal.addEventListener(
'abort',
() => {
@@ -460,9 +458,7 @@ export default class Simulator extends EasCommand {
...localEgress,
signal: egressAbortController.signal,
onConnected: () => {
Log.succeed(
"Egress tunnel connected. Proxied HTTP(S) requests can use this machine's network."
);
Log.succeed('Egress tunnel connected.');
},
onDisconnected: () => {
Log.warn(
@@ -61,14 +61,37 @@ describe('local egress configuration', () => {
EAS_SIMULATOR_EGRESS_ALLOW: '',
});
const instructions = formatRemoteSessionInstructions(agentDeviceConfigWithEgress, 'dotenv');
expect(instructions).toContain('eas simulator:egress');
expect(instructions).toContain(
"🔀 Local egress: the simulator's HTTP(S) traffic exits from this machine.\n"
);
expect(instructions).toContain('Run the egress client to connect the tunnel');
expect(instructions).not.toContain('may reach');
expect(instructions).toContain('eas simulator:egress');
expect(instructions).toContain('Keep it running for the life of the session.');
expect(instructions).not.toContain('It can also reach');
expect(formatRemoteSessionInstructions(agentDeviceConfigWithEgress, 'env')).toContain(
"export EAS_SIMULATOR_EGRESS_ALLOW=''"
);
});
it('says nothing about starting the client when it runs inline', () => {
for (const configType of ['dotenv', 'env'] as const) {
const instructions = formatRemoteSessionInstructions(
agentDeviceConfigWithEgress,
configType,
{
egressClientRunsInline: true,
}
);
expect(instructions).toContain(
"🔀 Local egress: the simulator's HTTP(S) traffic exits from this machine."
);
expect(instructions).not.toContain('eas simulator:egress');
expect(instructions).not.toContain('Run the egress client');
expect(instructions).not.toContain('Keep it running');
expect(instructions).not.toContain('export EAS_SIMULATOR_EGRESS');
}
});
it('carries the allowed local destinations into the config, env file and instructions', () => {
const egressAllow = ['localhost:3000', '192.168.1.20:8080'];
expect(getLocalEgressConfig(agentDeviceConfigWithEgress, egressAllow)?.allow).toEqual(
@@ -84,19 +107,19 @@ describe('local egress configuration', () => {
egressAllow,
});
expect(instructions).toContain(
"The simulator may reach localhost:3000, 192.168.1.20:8080 on this machine's network."
);
expect(instructions).toContain(
'127.0.0.1:3000 in the simulator reaches the same port on this machine (like adb reverse)'
"🔀 Local egress: the simulator's HTTP(S) traffic exits from this machine. It can also reach localhost:3000, 192.168.1.20:8080."
);
expect(instructions).not.toContain('reachable by name only');
});
it('omits the loopback forwarding notice when no allowed destination is loopback', () => {
it('warns only about loopback entries the device host will not forward', () => {
expect(
formatRemoteSessionInstructions(agentDeviceConfigWithEgress, 'dotenv', {
egressAllow: ['192.168.1.20:8080'],
egressAllow: ['localhost:80', 'localhost:3000'],
})
).not.toContain('adb reverse');
).toContain(
'localhost:80 is reachable by name only: privileged ports and the egress proxy port are not forwarded to 127.0.0.1 in the simulator.'
);
});
});
@@ -122,13 +145,13 @@ describe(getLoopbackForwardPlan, () => {
});
describe(formatLoopbackForwardNotice, () => {
it('describes forwarded ports and name-only entries', () => {
it('describes name-only entries and stays silent about forwarded ports', () => {
expect(formatLoopbackForwardNotice({ ports: [3000, 8082], skipped: ['localhost:80'] })).toEqual(
[
'127.0.0.1:3000, 127.0.0.1:8082 in the simulator reach the same ports on this machine (like adb reverse), so dev server URLs that use 127.0.0.1 work.',
'localhost:80 is reachable by name only: privileged ports and the egress proxy port are not forwarded to 127.0.0.1 in the simulator.',
]
);
expect(formatLoopbackForwardNotice({ ports: [3000], skipped: [] })).toEqual([]);
expect(formatLoopbackForwardNotice({ ports: [], skipped: [] })).toEqual([]);
});
});
+40 -34
View File
@@ -81,6 +81,12 @@ export type LocalEgressConfig = {
export type LocalEgressOptions = {
egressAllow?: readonly string[];
/**
* Whether the calling command runs the egress client itself in the current
* terminal, as interactive `simulator:start` does. When false the reader must
* start `eas simulator:egress` in another process.
*/
egressClientRunsInline?: boolean;
};
/**
@@ -143,23 +149,18 @@ export function getLoopbackForwardPlan(
return { ports: [...ports].sort((a, b) => a - b), skipped };
}
export function formatLoopbackForwardNotice({ ports, skipped }: LoopbackForwardPlan): string[] {
const lines: string[] = [];
if (ports.length > 0) {
const addresses = ports.map(port => `127.0.0.1:${port}`).join(', ');
lines.push(
`${addresses} in the simulator ${ports.length === 1 ? 'reaches' : 'reach'} the same ` +
`${ports.length === 1 ? 'port' : 'ports'} on this machine (like adb reverse), so dev server ` +
'URLs that use 127.0.0.1 work.'
);
/**
* Only the exception is worth a line: forwarded ports just work, but an entry
* the device host will not forward changes what the reader would expect.
*/
export function formatLoopbackForwardNotice({ skipped }: LoopbackForwardPlan): string[] {
if (skipped.length === 0) {
return [];
}
if (skipped.length > 0) {
lines.push(
`${skipped.join(', ')} ${skipped.length === 1 ? 'is' : 'are'} reachable by name only: ` +
'privileged ports and the egress proxy port are not forwarded to 127.0.0.1 in the simulator.'
);
}
return lines;
return [
`${skipped.join(', ')} ${skipped.length === 1 ? 'is' : 'are'} reachable by name only: ` +
'privileged ports and the egress proxy port are not forwarded to 127.0.0.1 in the simulator.',
];
}
export function getLocalEgressEnvironmentVariables(
@@ -258,34 +259,39 @@ export function sanitizeRemoteConfigForJson(
export function formatRemoteSessionInstructions(
remoteConfig: DeviceRunSessionRemoteConfig,
configType: RemoteSessionInstructionsConfigType,
{ egressAllow }: LocalEgressOptions = {}
{ egressAllow, egressClientRunsInline = false }: LocalEgressOptions = {}
): string {
const instructions = formatControllerInstructions(remoteConfig, configType);
const egress = getLocalEgressConfig(remoteConfig, egressAllow);
if (!egress) {
return instructions;
}
const egressCommand =
configType === 'env' ? 'eas simulator:egress --config-type env' : 'eas simulator:egress';
const summary =
"🔀 Local egress: the simulator's HTTP(S) traffic exits from this machine." +
(egress.allow.length > 0 ? ` It can also reach ${egress.allow.join(', ')}.` : '');
return [
instructions,
'',
'🔀 This session can route proxied HTTP(S) requests through this machine.',
...(configType === 'env'
? Object.entries(getLocalEgressEnvironmentVariables(egress)).map(
([key, value]) => `export ${key}='${value}'`
)
: []),
'Run the egress client to connect the tunnel:',
'',
configType === 'env' ? 'eas simulator:egress --config-type env' : 'eas simulator:egress',
'',
'Keep it running for the life of the session.',
...(egress.allow.length > 0
? [
summary,
...formatLoopbackForwardNotice(getLoopbackForwardPlan(egress.allow, egress.port)),
// In interactive mode the client starts in this terminal once the session is
// ready and stops with it, so there is nothing for the reader to run.
...(egressClientRunsInline
? []
: [
...(configType === 'env'
? Object.entries(getLocalEgressEnvironmentVariables(egress)).map(
([key, value]) => `export ${key}='${value}'`
)
: []),
'Run the egress client to connect the tunnel:',
'',
`The simulator may reach ${egress.allow.join(', ')} on this machine's network.`,
...formatLoopbackForwardNotice(getLoopbackForwardPlan(egress.allow, egress.port)),
]
: []),
egressCommand,
'',
'Keep it running for the life of the session.',
]),
].join('\n');
}