jetbridge 0.1.0-rc.1 → 0.1.0-rc.3

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 CHANGED
@@ -136,6 +136,7 @@ jetbridge install --device --json | jq -c 'select(.event == "step" and .phase ==
136
136
  {"event":"signing","decision":"cached","profiles":["Acme wave app","Acme wave uploadwidget"]}
137
137
  {"event":"step","step":"build","phase":"start"}
138
138
  {"event":"step","step":"build","phase":"end","ok":true,"durationMs":72000,"buildNumber":"1786437647","configuration":"Debug"}
139
+ {"event":"step","step":"settings","phase":"end","ok":true,"durationMs":5000,"product":"Acme.app"}
139
140
  {"event":"step","step":"install","phase":"end","ok":true,"durationMs":18000,"device":{"id":"10BFE051","name":"Dev's 17 Pro"},"bundleId":"io.acme.app.dev.wave"}
140
141
  {"event":"done","ok":true,"durationMs":113000,"devices":1,"bundleId":"io.acme.app.dev.wave"}
141
142
  ```
package/dist/cli.js CHANGED
@@ -1635,29 +1635,34 @@ function assertDeletable(identifier, protectedIds, config) {
1635
1635
  );
1636
1636
  }
1637
1637
  }
1638
- async function fetchBundleIds(client) {
1639
- const result = await client.request("GET", "/v1/bundleIds?limit=200");
1640
- if (result.status !== 200) {
1641
- fail(
1642
- `could not list bundle ids (HTTP ${result.status}).
1638
+ async function fetchAllPages(client, what, firstPath) {
1639
+ const rows = [];
1640
+ let path = firstPath;
1641
+ for (let page = 0; path && page < 50; page += 1) {
1642
+ const result = await client.request("GET", path);
1643
+ if (result.status !== 200) {
1644
+ fail(
1645
+ `could not list ${what} (HTTP ${result.status}).
1643
1646
  Check that the App Store Connect key still has access to this team.`
1644
- );
1647
+ );
1648
+ }
1649
+ rows.push(...asArray(result.body.data));
1650
+ const next = result.body.links?.next;
1651
+ path = next ? next.replace(/^https:\/\/api\.appstoreconnect\.apple\.com/, "") : void 0;
1645
1652
  }
1646
- return asArray(result.body.data).map((row) => ({
1653
+ return rows;
1654
+ }
1655
+ async function fetchBundleIds(client) {
1656
+ const rows = await fetchAllPages(client, "bundle ids", "/v1/bundleIds?limit=200");
1657
+ return rows.map((row) => ({
1647
1658
  id: row.id,
1648
1659
  identifier: String(row.attributes.identifier ?? ""),
1649
1660
  name: String(row.attributes.name ?? "")
1650
1661
  }));
1651
1662
  }
1652
1663
  async function fetchProfiles(client) {
1653
- const result = await client.request("GET", "/v1/profiles?limit=200");
1654
- if (result.status !== 200) {
1655
- fail(
1656
- `could not list provisioning profiles (HTTP ${result.status}).
1657
- Check that the App Store Connect key still has access to this team.`
1658
- );
1659
- }
1660
- return asArray(result.body.data).map((row) => ({
1664
+ const rows = await fetchAllPages(client, "provisioning profiles", "/v1/profiles?limit=200");
1665
+ return rows.map((row) => ({
1661
1666
  id: row.id,
1662
1667
  name: String(row.attributes.name ?? ""),
1663
1668
  createdDate: String(row.attributes.createdDate ?? "")
@@ -2545,6 +2550,7 @@ function fillTemplate(template, values) {
2545
2550
 
2546
2551
  // src/build.ts
2547
2552
  import { join as join9 } from "path";
2553
+ import { z as z2 } from "zod";
2548
2554
 
2549
2555
  // src/signing.ts
2550
2556
  import { createHash } from "crypto";
@@ -2676,15 +2682,72 @@ function buildArgs(boundary, project, request) {
2676
2682
  ...request.verbose ? [] : ["-quiet"]
2677
2683
  ];
2678
2684
  }
2679
- function productPath(request, config, platform) {
2685
+ function productPath(request, productName, platform) {
2680
2686
  return join9(
2681
2687
  request.derivedDataPath,
2682
2688
  "Build",
2683
2689
  "Products",
2684
2690
  `${request.configuration}-${platform}`,
2685
- `${config.project.scheme}.app`
2691
+ productName
2686
2692
  );
2687
2693
  }
2694
+ function settingsArgs(project, request) {
2695
+ return [
2696
+ "-showBuildSettings",
2697
+ "-json",
2698
+ ...project.xcodebuildTarget(),
2699
+ "-scheme",
2700
+ project.config.project.scheme,
2701
+ "-configuration",
2702
+ request.configuration,
2703
+ "-destination",
2704
+ request.destination,
2705
+ "-derivedDataPath",
2706
+ request.derivedDataPath,
2707
+ ...variantSettings(request.suffix, request.displayName)
2708
+ ];
2709
+ }
2710
+ var SettingsOutput = z2.array(
2711
+ z2.object({
2712
+ buildSettings: z2.object({
2713
+ PRODUCT_TYPE: z2.string().optional(),
2714
+ FULL_PRODUCT_NAME: z2.string().optional()
2715
+ })
2716
+ })
2717
+ );
2718
+ function appProductName(stdout) {
2719
+ let json;
2720
+ try {
2721
+ json = JSON.parse(stdout);
2722
+ } catch {
2723
+ return null;
2724
+ }
2725
+ const parsed = SettingsOutput.safeParse(json);
2726
+ if (!parsed.success) return null;
2727
+ const apps = parsed.data.filter(
2728
+ (entry) => entry.buildSettings.PRODUCT_TYPE === "com.apple.product-type.application"
2729
+ );
2730
+ return apps.length === 1 ? apps[0].buildSettings.FULL_PRODUCT_NAME ?? null : null;
2731
+ }
2732
+ async function builtApp(boundary, project, request, platform) {
2733
+ const name = await boundary.report.run("settings", "read build settings", async (step) => {
2734
+ const result = await boundary.exec.run("xcodebuild", settingsArgs(project, request), {
2735
+ cwd: project.root,
2736
+ allowFail: true
2737
+ });
2738
+ const found = result.ok ? appProductName(result.stdout) : null;
2739
+ const name2 = found ?? `${project.config.project.scheme}.app`;
2740
+ if (!found) {
2741
+ boundary.report.note(`the build settings name no single app \u2014 assuming ${name2}`);
2742
+ }
2743
+ step.detail(name2);
2744
+ step.data({ product: name2 });
2745
+ return name2;
2746
+ });
2747
+ const path = productPath(request, name, platform);
2748
+ if (!boundary.fs.exists(path)) fail(`the build reported success but produced no app at ${path}`);
2749
+ return path;
2750
+ }
2688
2751
  async function requireToolchain(boundary, project, binaries) {
2689
2752
  for (const binary of binaries) {
2690
2753
  const found = await boundary.exec.run("command", ["-v", binary], { allowFail: true });
@@ -3269,29 +3332,23 @@ async function wiredInstall(boundary, project, options) {
3269
3332
  return { byTarget: Object.fromEntries(provisioned.map((p) => [p.target, p.profileName])) };
3270
3333
  });
3271
3334
  await runHook(boundary, project, "preBuild");
3272
- const appPath = await withEntitlementSwap(
3335
+ const request = {
3336
+ configuration,
3337
+ suffix: options.suffix,
3338
+ displayName: options.displayName,
3339
+ profiles,
3340
+ derivedDataPath: derivedData,
3341
+ destination: "generic/platform=iOS",
3342
+ buildNumber: buildNumber(boundary),
3343
+ verbose: options.verbose
3344
+ };
3345
+ await withEntitlementSwap(
3273
3346
  boundary,
3274
3347
  project,
3275
3348
  { suffix: options.suffix, backupPath: join12(scratch, "project.pbxproj.orig"), configuration },
3276
- async () => {
3277
- const request = {
3278
- configuration,
3279
- suffix: options.suffix,
3280
- displayName: options.displayName,
3281
- profiles,
3282
- derivedDataPath: derivedData,
3283
- destination: "generic/platform=iOS",
3284
- buildNumber: buildNumber(boundary),
3285
- verbose: options.verbose
3286
- };
3287
- await build(boundary, project, request);
3288
- const built = productPath(request, config, "iphoneos");
3289
- if (!boundary.fs.exists(built)) {
3290
- fail(`the build reported success but produced no app at ${built}`);
3291
- }
3292
- return built;
3293
- }
3349
+ () => build(boundary, project, request)
3294
3350
  );
3351
+ const appPath = await builtApp(boundary, project, request, "iphoneos");
3295
3352
  await runHook(boundary, project, "postBuild");
3296
3353
  const failures = [];
3297
3354
  for (const target of targets) {
@@ -4019,10 +4076,7 @@ async function simInstall(boundary, project, options) {
4019
4076
  verbose: options.verbose
4020
4077
  };
4021
4078
  await build(boundary, project, request);
4022
- const appPath = productPath(request, config, "iphonesimulator");
4023
- if (!boundary.fs.exists(appPath)) {
4024
- fail(`the build reported success but produced no app at ${appPath}`);
4025
- }
4079
+ const appPath = await builtApp(boundary, project, request, "iphonesimulator");
4026
4080
  await runHook(boundary, project, "postBuild");
4027
4081
  await report.run("install", simulator.name, async (step) => {
4028
4082
  step.data({ device: { id: simulator.udid, name: simulator.name }, bundleId, appPath });