eas-cli 24.12.0 → 24.12.1
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/README.md +142 -142
- package/build/commands/simulator/index.js +54 -7
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
|
@@ -262,7 +262,7 @@ class Simulator extends EasCommand_1.default {
|
|
|
262
262
|
...agentIdentity,
|
|
263
263
|
maxRunTimeMinutes: flags['max-duration-minutes'],
|
|
264
264
|
maxIdleTimeMinutes: flags['max-idle-time-minutes'],
|
|
265
|
-
}));
|
|
265
|
+
}), createdSession => stopDeviceRunSessionCreatedAfterCancelAsync(graphqlClient, createdSession.id));
|
|
266
266
|
deviceRunSessionId = session.id;
|
|
267
267
|
(0, nullthrows_1.default)(session.turtleJobRun?.id, 'Expected simulator session to start');
|
|
268
268
|
deviceRunSessionUrl = (0, url_1.getDeviceRunSessionUrl)(session.app.ownerAccount.name, session.app.slug, deviceRunSessionId);
|
|
@@ -548,6 +548,16 @@ async function stopDeviceRunSessionAfterInterruptAsync({ graphqlClient, deviceRu
|
|
|
548
548
|
}
|
|
549
549
|
process.exit(130);
|
|
550
550
|
}
|
|
551
|
+
async function stopDeviceRunSessionCreatedAfterCancelAsync(graphqlClient, deviceRunSessionId) {
|
|
552
|
+
const spinner = (0, ora_1.ora)(`Stopping simulator session ${deviceRunSessionId}, which the request created after Ctrl+C`).start();
|
|
553
|
+
const stopped = await ensureDeviceRunSessionStoppedSafelyAsync(graphqlClient, deviceRunSessionId);
|
|
554
|
+
if (stopped) {
|
|
555
|
+
spinner.succeed(`Simulator session ${deviceRunSessionId} stopped`);
|
|
556
|
+
}
|
|
557
|
+
else {
|
|
558
|
+
spinner.fail(`Could not confirm the simulator session was stopped. Run \`eas simulator:stop --id ${deviceRunSessionId}\` to terminate it and avoid unexpected charges.`);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
551
561
|
async function resetSimulatorEnvVerboseAsync(projectDir, deviceRunSessionId) {
|
|
552
562
|
try {
|
|
553
563
|
await (0, env_1.resetSimulatorEnvAsync)(projectDir, deviceRunSessionId);
|
|
@@ -573,26 +583,43 @@ async function ensureDeviceRunSessionStoppedSafelyAsync(graphqlClient, deviceRun
|
|
|
573
583
|
* without a limit a hung network would make Ctrl+C look ignored.
|
|
574
584
|
*/
|
|
575
585
|
const CANCEL_FLUSH_TIMEOUT_MS = 1_000;
|
|
586
|
+
/**
|
|
587
|
+
* How long Ctrl+C then waits for the create request. The server can still create the session after
|
|
588
|
+
* the client stops waiting, and nothing else stops that session before its maximum duration.
|
|
589
|
+
*/
|
|
590
|
+
const CANCEL_CREATE_WAIT_MS = 5_000;
|
|
591
|
+
const SESSION_MAY_BE_RUNNING_WARNING = 'A simulator session may still be running. Run `eas simulator:list` to check for a running session, and `eas simulator:stop --id <id>` to stop it.';
|
|
576
592
|
class SimulatorRequestCancelledError extends Error {
|
|
577
593
|
}
|
|
578
594
|
/**
|
|
579
595
|
* Runs the create request and logs the client-side funnel events around it: "request sent" before
|
|
580
596
|
* it leaves, "request cancelled" on Ctrl+C before an answer, and "request failed" when no answer
|
|
581
|
-
* arrives.
|
|
582
|
-
* Ctrl+C
|
|
583
|
-
*
|
|
597
|
+
* arrives. "Request cancelled" means the client stopped waiting; the server can still create the
|
|
598
|
+
* session. So Ctrl+C stops the spinner, flushes analytics, and waits a bounded time for the
|
|
599
|
+
* request: a session that comes back goes to `stopCreatedAsync`, and otherwise the user is told how
|
|
600
|
+
* to check for one. Then it exits with 130, like the session's own Ctrl+C handler: going through
|
|
601
|
+
* the command's error handling would print the exit as an error and report it to Sentry. A second
|
|
602
|
+
* Ctrl+C exits at once.
|
|
584
603
|
*/
|
|
585
|
-
async function withSimulatorRequestAnalyticsAsync(analytics, properties, spinner, createAsync) {
|
|
604
|
+
async function withSimulatorRequestAnalyticsAsync(analytics, properties, spinner, createAsync, stopCreatedAsync) {
|
|
605
|
+
let cancelRequested = false;
|
|
586
606
|
let onSigint;
|
|
587
607
|
const cancelled = new Promise((_, reject) => {
|
|
588
608
|
onSigint = () => {
|
|
609
|
+
if (cancelRequested) {
|
|
610
|
+
log_1.default.warn(SESSION_MAY_BE_RUNNING_WARNING);
|
|
611
|
+
process.exit(130);
|
|
612
|
+
}
|
|
613
|
+
cancelRequested = true;
|
|
589
614
|
reject(new SimulatorRequestCancelledError());
|
|
590
615
|
};
|
|
591
616
|
});
|
|
592
|
-
process.
|
|
617
|
+
process.on('SIGINT', onSigint);
|
|
593
618
|
analytics.logEvent(AnalyticsManager_1.SimulatorEvent.REQUEST_SENT, properties);
|
|
619
|
+
let createPromise;
|
|
594
620
|
try {
|
|
595
|
-
|
|
621
|
+
createPromise = createAsync();
|
|
622
|
+
return await Promise.race([createPromise, cancelled]);
|
|
596
623
|
}
|
|
597
624
|
catch (error) {
|
|
598
625
|
if (error instanceof SimulatorRequestCancelledError) {
|
|
@@ -604,6 +631,7 @@ async function withSimulatorRequestAnalyticsAsync(analytics, properties, spinner
|
|
|
604
631
|
(0, promise_1.sleepAsync)(CANCEL_FLUSH_TIMEOUT_MS, flushTimeout.signal),
|
|
605
632
|
]);
|
|
606
633
|
flushTimeout.abort();
|
|
634
|
+
await stopSessionCreatedAfterCancelAsync(createPromise, stopCreatedAsync);
|
|
607
635
|
process.exit(130);
|
|
608
636
|
}
|
|
609
637
|
const reason = (0, requestAnalytics_1.simulatorRequestFailureReason)(error);
|
|
@@ -616,6 +644,25 @@ async function withSimulatorRequestAnalyticsAsync(analytics, properties, spinner
|
|
|
616
644
|
process.removeListener('SIGINT', onSigint);
|
|
617
645
|
}
|
|
618
646
|
}
|
|
647
|
+
async function stopSessionCreatedAfterCancelAsync(createPromise, stopCreatedAsync) {
|
|
648
|
+
if (!createPromise) {
|
|
649
|
+
// Ctrl+C came before the request was sent, so no session can have been created.
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
log_1.default.log(`Waiting up to ${CANCEL_CREATE_WAIT_MS / 1_000} seconds for the request to finish, so a session it created can be stopped. Press Ctrl+C again to exit now.`);
|
|
653
|
+
const waitTimeout = new AbortController();
|
|
654
|
+
const created = await Promise.race([
|
|
655
|
+
createPromise.then(value => ({ value }), () => undefined),
|
|
656
|
+
(0, promise_1.sleepAsync)(CANCEL_CREATE_WAIT_MS, waitTimeout.signal).then(() => undefined),
|
|
657
|
+
]);
|
|
658
|
+
waitTimeout.abort();
|
|
659
|
+
if (created) {
|
|
660
|
+
await stopCreatedAsync(created.value);
|
|
661
|
+
}
|
|
662
|
+
else {
|
|
663
|
+
log_1.default.warn(SESSION_MAY_BE_RUNNING_WARNING);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
619
666
|
async function agentIdentityInputAsync() {
|
|
620
667
|
if (await (0, AnalyticsManager_1.isAnalyticsOptedOutAsync)()) {
|
|
621
668
|
return {};
|
package/oclif.manifest.json
CHANGED
|
@@ -16657,5 +16657,5 @@
|
|
|
16657
16657
|
]
|
|
16658
16658
|
}
|
|
16659
16659
|
},
|
|
16660
|
-
"version": "24.12.
|
|
16660
|
+
"version": "24.12.1"
|
|
16661
16661
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eas-cli",
|
|
3
|
-
"version": "24.12.
|
|
3
|
+
"version": "24.12.1",
|
|
4
4
|
"description": "EAS command line tool",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -269,5 +269,5 @@
|
|
|
269
269
|
"engines": {
|
|
270
270
|
"node": "^20.18.3 || >=22.0.0"
|
|
271
271
|
},
|
|
272
|
-
"gitHead": "
|
|
272
|
+
"gitHead": "01e3be71aab19f224d2695d886df52390fdc5674"
|
|
273
273
|
}
|