@touchtechclub/simbox 0.2.4 → 0.2.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/dist/cli.js +24 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -178,6 +178,7 @@ async function currentRun() {
|
|
|
178
178
|
var stopRun = (runId) => api(`/v1/runs/${encodeURIComponent(runId)}/stop`, {
|
|
179
179
|
method: "POST"
|
|
180
180
|
});
|
|
181
|
+
var runHistory = async () => (await api("/v1/runs")).runs;
|
|
181
182
|
function friendlyError(err) {
|
|
182
183
|
if (err instanceof CliError)
|
|
183
184
|
return err;
|
|
@@ -362,6 +363,19 @@ class Spinner {
|
|
|
362
363
|
import { spawn } from "node:child_process";
|
|
363
364
|
import { join as join2 } from "node:path";
|
|
364
365
|
var STARTUP_TIMEOUT_MS = 300000;
|
|
366
|
+
async function waitForAndroid(runId, options = {}) {
|
|
367
|
+
const deadline = Date.now() + (options.timeoutMs ?? 12 * 60000);
|
|
368
|
+
do {
|
|
369
|
+
const run = await (options.read ?? currentRun)();
|
|
370
|
+
if (!run || run.id !== runId || run.state !== "live") {
|
|
371
|
+
throw new CliError("The run ended or was replaced while preparing Android. Run `simbox sim` again.");
|
|
372
|
+
}
|
|
373
|
+
if (run.androidReady)
|
|
374
|
+
return;
|
|
375
|
+
await (options.pause?.() ?? sleep(3000));
|
|
376
|
+
} while (Date.now() < deadline);
|
|
377
|
+
throw new CliError("Android AVD preparation did not complete. Inspect the Actions job's Android emulator prep logs. No device command was sent.");
|
|
378
|
+
}
|
|
365
379
|
async function waitForRemote(initial, options = {}) {
|
|
366
380
|
const probe = options.probe ?? probeRemote;
|
|
367
381
|
const refresh = options.refresh ?? refreshRemote;
|
|
@@ -441,6 +455,9 @@ async function cmdExec(args) {
|
|
|
441
455
|
const initial = await refreshRemote();
|
|
442
456
|
if (!initial)
|
|
443
457
|
throw new CliError("No live run. Start one with `simbox sim`.");
|
|
458
|
+
if (args.some((arg, i) => arg === "--platform=android" || arg === "--platform" && args[i + 1] === "android")) {
|
|
459
|
+
await waitForAndroid(initial.runId);
|
|
460
|
+
}
|
|
444
461
|
const info = await waitForRemote(initial);
|
|
445
462
|
const env = {
|
|
446
463
|
...process.env,
|
|
@@ -566,8 +583,14 @@ async function cmdSim(opts) {
|
|
|
566
583
|
while (Date.now() < deadline) {
|
|
567
584
|
await sleep(SIM_POLL_MS);
|
|
568
585
|
const run = await currentRun();
|
|
569
|
-
if (!run)
|
|
586
|
+
if (!run) {
|
|
587
|
+
const ended = (await runHistory()).find((candidate) => candidate.id === first.runId);
|
|
588
|
+
if (ended && (ended.state === "ended" || ended.state === "failed")) {
|
|
589
|
+
spinner.fail(`Run ${ended.state}`);
|
|
590
|
+
throw new CliError(`The run ${ended.state} during startup (${ended.endReason ?? "check the Actions logs"}). Try \`simbox sim --new\`.`);
|
|
591
|
+
}
|
|
570
592
|
continue;
|
|
593
|
+
}
|
|
571
594
|
if (run.state === "live" && run.tunnelUrl && run.daemonToken) {
|
|
572
595
|
live = { run, tunnelUrl: run.tunnelUrl, daemonToken: run.daemonToken };
|
|
573
596
|
break;
|