@touchtechclub/simbox 0.4.8 → 0.4.9
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 +44 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -81,6 +81,35 @@ function parseRunnerInput(input, platform) {
|
|
|
81
81
|
function formatRunner(runner) {
|
|
82
82
|
return runner ? runner.labels.join(" + ") : "unknown (legacy workflow)";
|
|
83
83
|
}
|
|
84
|
+
// ../../packages/shared/src/device-profile.ts
|
|
85
|
+
var XCODE_VERSION = /^\d{1,3}(\.\d{1,3}){0,2}$/;
|
|
86
|
+
function validateDeviceProfile(value, platform) {
|
|
87
|
+
if (value === undefined || value === null)
|
|
88
|
+
return null;
|
|
89
|
+
if (typeof value !== "object" || Array.isArray(value))
|
|
90
|
+
throw new Error("Device must be {foldable?: boolean, xcode?: string}.");
|
|
91
|
+
const keys = Object.keys(value);
|
|
92
|
+
if (keys.some((key) => key !== "foldable" && key !== "xcode"))
|
|
93
|
+
throw new Error("Device only accepts foldable and xcode.");
|
|
94
|
+
const { foldable, xcode } = value;
|
|
95
|
+
if (foldable !== undefined && typeof foldable !== "boolean")
|
|
96
|
+
throw new Error("foldable must be true or false.");
|
|
97
|
+
if (xcode !== undefined) {
|
|
98
|
+
if (typeof xcode !== "string" || !XCODE_VERSION.test(xcode))
|
|
99
|
+
throw new Error('Xcode must be a version such as "27.1".');
|
|
100
|
+
if (platform !== "ios")
|
|
101
|
+
throw new Error("Xcode selection only applies to iOS runs.");
|
|
102
|
+
}
|
|
103
|
+
const profile = {
|
|
104
|
+
...foldable === true ? { foldable: true } : {},
|
|
105
|
+
...xcode !== undefined ? { xcode } : {}
|
|
106
|
+
};
|
|
107
|
+
return Object.keys(profile).length > 0 ? profile : null;
|
|
108
|
+
}
|
|
109
|
+
function formatDeviceProfile(profile, platform) {
|
|
110
|
+
const device = profile?.foldable ? platform === "ios" ? "iPhone Duo" : "Android foldable" : "default";
|
|
111
|
+
return profile?.xcode ? `${device}, Xcode ${profile.xcode}` : device;
|
|
112
|
+
}
|
|
84
113
|
// ../../packages/shared/src/preview.ts
|
|
85
114
|
var PREVIEW_SESSION_MS = 5 * 60000;
|
|
86
115
|
// src/config.ts
|
|
@@ -234,9 +263,9 @@ var repoStatus = () => api("/v1/repo/status");
|
|
|
234
263
|
var repairRepo = () => api("/v1/repo/repair", {
|
|
235
264
|
method: "POST"
|
|
236
265
|
});
|
|
237
|
-
var ensureRun = (fresh, platform2, runner) => api("/v1/runs/ensure", {
|
|
266
|
+
var ensureRun = (fresh, platform2, runner, device) => api("/v1/runs/ensure", {
|
|
238
267
|
method: "POST",
|
|
239
|
-
body: { new: fresh, platform: platform2, runner }
|
|
268
|
+
body: { new: fresh, platform: platform2, runner, device }
|
|
240
269
|
});
|
|
241
270
|
var runnerSettings = () => api("/v1/runners");
|
|
242
271
|
var runnerDiagnostics = () => api("/v1/runners/doctor");
|
|
@@ -616,7 +645,7 @@ async function cmdExec(args) {
|
|
|
616
645
|
}
|
|
617
646
|
const bin = findAgentDevice();
|
|
618
647
|
if (!bin)
|
|
619
|
-
throw new CliError("Install agent-device first: npm i -g agent-device@0.21.
|
|
648
|
+
throw new CliError("Install agent-device first: npm i -g agent-device@0.21.28");
|
|
620
649
|
const android = args.some((arg, i) => arg === "--platform=android" || arg === "--platform" && args[i + 1] === "android");
|
|
621
650
|
let info = android ? null : readCachedRun();
|
|
622
651
|
if (info && !await probeRemote(info))
|
|
@@ -744,7 +773,16 @@ async function cmdSim(opts) {
|
|
|
744
773
|
if (opts.runner !== undefined && !opts.platform)
|
|
745
774
|
throw new CliError("Use --platform ios or android with --runner.");
|
|
746
775
|
const runner = opts.runner === undefined ? undefined : parseRunnerInput(opts.runner, opts.platform);
|
|
747
|
-
const
|
|
776
|
+
const wantsDevice = opts.foldable === true || opts.xcode !== undefined;
|
|
777
|
+
if (wantsDevice && !opts.platform)
|
|
778
|
+
throw new CliError("Use --platform ios or android with --foldable or --xcode.");
|
|
779
|
+
let device;
|
|
780
|
+
try {
|
|
781
|
+
device = wantsDevice ? validateDeviceProfile({ foldable: opts.foldable, xcode: opts.xcode }, opts.platform) ?? undefined : undefined;
|
|
782
|
+
} catch (err) {
|
|
783
|
+
throw new CliError(err.message);
|
|
784
|
+
}
|
|
785
|
+
const first = await ensureRun(opts.new === true, opts.platform, runner, device);
|
|
748
786
|
let info;
|
|
749
787
|
if (first.state === "live") {
|
|
750
788
|
info = {
|
|
@@ -823,6 +861,7 @@ async function cmdPs() {
|
|
|
823
861
|
console.log(` state: ${stateColor(run.state)}`);
|
|
824
862
|
console.log(` platform: ${run.platform}`);
|
|
825
863
|
console.log(` runner: ${formatRunner(run.runner)}`);
|
|
864
|
+
console.log(` device: ${formatDeviceProfile(run.device ?? null, run.platform)}`);
|
|
826
865
|
console.log(` gh_run_id: ${run.ghRunId ?? pc3.dim("pending")}`);
|
|
827
866
|
console.log(` active_devices: ${run.activeDevices}`);
|
|
828
867
|
console.log(` android_ready: ${run.androidReady ? "yes" : "no"}`);
|
|
@@ -1011,7 +1050,7 @@ program.command("init").description("Open onboarding and wait until a repo is co
|
|
|
1011
1050
|
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([
|
|
1012
1051
|
"ios",
|
|
1013
1052
|
"android"
|
|
1014
|
-
])).option("--runner <label-or-json>", "override runner label or JSON label array; requires --platform").option("--json", "print {tunnel_url, daemon_token, run_id, expires_at} as JSON only").action((opts) => {
|
|
1053
|
+
])).option("--runner <label-or-json>", "override runner label or JSON label array; requires --platform").option("--foldable", "boot a foldable: iPhone Duo (needs Xcode 27.1+, e.g. --runner xcode-27) or a 7.6in Android foldable; requires --platform").option("--xcode <version>", "iOS: select this Xcode (e.g. 27.1) before the device daemon starts").option("--json", "print {tunnel_url, daemon_token, run_id, expires_at} as JSON only").action((opts) => {
|
|
1015
1054
|
requireToken();
|
|
1016
1055
|
return run(cmdSim(opts));
|
|
1017
1056
|
});
|