@agimon-ai/po-ios 0.0.1-alpha.32 → 0.0.1-alpha.34

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.
@@ -522,10 +522,15 @@ function simctlEnvironment(environment) {
522
522
  ...environment.DEVELOPER_DIR ? { DEVELOPER_DIR: environment.DEVELOPER_DIR } : {}
523
523
  };
524
524
  }
525
- /** `RunCommand` over the injected `po/shell`, with a timeout and an output cap. */
525
+ /** Commands that start Xcode tools; each one asks for an administrator while Xcode's first-launch setup is missing. */
526
+ const usesXcode = (argv) => argv.some((arg) => arg === "xcrun" || arg === "xcodebuild");
527
+ /**
528
+ * `RunCommand` over the injected `po/shell`, with a timeout and an output cap. Xcode tools run only once
529
+ * `xcodebuild -checkFirstLaunchStatus` passes, so Po never triggers the system "install Apple software" prompt.
530
+ */
526
531
  function createShellRunner(shell, environment) {
527
532
  const env = simctlEnvironment(environment);
528
- return async (argv, options = {}) => {
533
+ const exec = async (argv, options = {}) => {
529
534
  const output = {
530
535
  stdout: "",
531
536
  stderr: ""
@@ -548,6 +553,18 @@ function createShellRunner(shell, environment) {
548
553
  stderr: output.stderr
549
554
  };
550
555
  };
556
+ let xcodeReady;
557
+ const requireXcodeSetup = () => (xcodeReady ??= exec(["xcodebuild", "-checkFirstLaunchStatus"]).then((status) => {
558
+ if (status.exitCode === 0) return;
559
+ throw new IosError("IOS_NO_XCODE", "Xcode has not finished its first-launch setup. Ask an administrator to run `sudo xcodebuild -runFirstLaunch`.");
560
+ })).catch((error) => {
561
+ xcodeReady = void 0;
562
+ throw error;
563
+ });
564
+ return async (argv, options) => {
565
+ if (usesXcode(argv)) await requireXcodeSetup();
566
+ return exec(argv, options);
567
+ };
551
568
  }
552
569
  function firstLine(text) {
553
570
  return text.split("\n").map((line) => line.trim()).find((line) => line !== "") ?? "";
@@ -837,6 +854,8 @@ function createDevicePool(options) {
837
854
  let ready = Promise.resolve();
838
855
  let lastReap = 0;
839
856
  let stopped = false;
857
+ /** The last failure message per janitor step, so a lasting failure is noticed once. */
858
+ const failures = /* @__PURE__ */ new Map();
840
859
  const wake = () => {
841
860
  for (const waker of wakers) waker();
842
861
  };
@@ -1129,8 +1148,11 @@ function createDevicePool(options) {
1129
1148
  if (stopped) return;
1130
1149
  try {
1131
1150
  await step();
1151
+ failures.delete(name);
1132
1152
  } catch (error) {
1133
- notice(`${name} failed: ${errorMessage(error)}`);
1153
+ const message = `${name} failed: ${errorMessage(error)}`;
1154
+ if (failures.get(name) !== message) notice(message);
1155
+ failures.set(name, message);
1134
1156
  }
1135
1157
  }
1136
1158
  wake();