@touchtechclub/simbox 0.2.6 → 0.2.8

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.
Files changed (2) hide show
  1. package/dist/cli.js +13 -4
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/cli.ts
4
- import { Command } from "commander";
4
+ import { Command, Option } from "commander";
5
5
  import pc4 from "picocolors";
6
6
  import { createRequire } from "node:module";
7
7
 
@@ -163,7 +163,7 @@ var repoStatus = () => api("/v1/repo/status");
163
163
  var repairRepo = () => api("/v1/repo/repair", {
164
164
  method: "POST"
165
165
  });
166
- var ensureRun = (fresh) => api("/v1/runs/ensure", { method: "POST", body: { new: fresh } });
166
+ var ensureRun = (fresh, platform2) => api("/v1/runs/ensure", { method: "POST", body: { new: fresh, platform: platform2 } });
167
167
  async function currentRun() {
168
168
  try {
169
169
  const res = await api("/v1/runs/current");
@@ -370,6 +370,9 @@ async function waitForAndroid(runId, options = {}) {
370
370
  if (!run || run.id !== runId || run.state !== "live") {
371
371
  throw new CliError("The run ended or was replaced while preparing Android. Run `simbox sim` again.");
372
372
  }
373
+ if (run.platform === "ios") {
374
+ throw new CliError("Android needs a Linux/KVM run. Run `simbox repair`, then `simbox sim --new --platform android`.");
375
+ }
373
376
  if (run.androidReady)
374
377
  return;
375
378
  await (options.pause?.() ?? sleep(3000));
@@ -566,7 +569,7 @@ var SIM_POLL_MS = 3000;
566
569
  async function cmdSim(opts) {
567
570
  const json = opts.json === true;
568
571
  const out = json ? process.stderr : process.stdout;
569
- const first = await ensureRun(opts.new === true);
572
+ const first = await ensureRun(opts.new === true, opts.platform);
570
573
  let info;
571
574
  if (first.state === "live") {
572
575
  info = {
@@ -614,6 +617,8 @@ async function cmdSim(opts) {
614
617
  };
615
618
  }
616
619
  info = await waitForRemote(info);
620
+ if (opts.platform === "android")
621
+ await waitForAndroid(info.runId);
617
622
  if (json) {
618
623
  const payload = {
619
624
  tunnel_url: info.tunnelUrl,
@@ -639,6 +644,7 @@ async function cmdPs() {
639
644
  const stateColor = run.state === "live" ? pc3.green : run.state === "failed" ? pc3.red : pc3.yellow;
640
645
  console.log(`${pc3.bold("run")} ${run.id}`);
641
646
  console.log(` state: ${stateColor(run.state)}`);
647
+ console.log(` platform: ${run.platform}`);
642
648
  console.log(` gh_run_id: ${run.ghRunId ?? pc3.dim("pending")}`);
643
649
  console.log(` active_devices: ${run.activeDevices}`);
644
650
  console.log(` android_ready: ${run.androidReady ? "yes" : "no"}`);
@@ -682,7 +688,10 @@ program.command("init").description("Open onboarding and wait until a repo is co
682
688
  requireToken();
683
689
  return run(cmdInit());
684
690
  });
685
- program.command("sim").description("Ensure a run and its tunnel are ready for device commands").option("--new", "force a fresh run even if one is live").option("--json", "print {tunnel_url, daemon_token, run_id, expires_at} as JSON only").action((opts) => {
691
+ program.command("sim").description("Ensure a run and its tunnel are ready for device commands").option("--new", "force a fresh run even if one is live").addOption(new Option("--platform <platform>", "ios: macOS runner; android: Linux/KVM runner").choices([
692
+ "ios",
693
+ "android"
694
+ ])).option("--json", "print {tunnel_url, daemon_token, run_id, expires_at} as JSON only").action((opts) => {
686
695
  requireToken();
687
696
  return run(cmdSim(opts));
688
697
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@touchtechclub/simbox",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "On-demand iOS simulators & Android emulators on your own GitHub Actions minutes.",
5
5
  "repository": {
6
6
  "type": "git",