@hot-updater/apple-helper 1.2.0-rc.41 → 1.2.0-rc.42

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/index.cjs CHANGED
@@ -2574,6 +2574,32 @@ const assertXcodebuildExist = async () => {
2574
2574
  }
2575
2575
  };
2576
2576
  //#endregion
2577
+ //#region src/utils/channelInfoPlist.ts
2578
+ /**
2579
+ * Makes a built app embed `channel`: its Info.plist's `HOT_UPDATER_CHANNEL`,
2580
+ * which the SDK reads, whatever the project's Info.plist or an Expo config
2581
+ * plugin set. The app's signature covers the Info.plist, so an archived app
2582
+ * is stamped before its export signs it, and a simulator app is signed again
2583
+ * ad hoc after, as Xcode does for the simulator.
2584
+ */
2585
+ const stampAppChannel = async (appPath, channel, { signAdHoc = false } = {}) => {
2586
+ await (0, execa.execa)("plutil", [
2587
+ "-replace",
2588
+ "HOT_UPDATER_CHANNEL",
2589
+ "-string",
2590
+ channel,
2591
+ path.default.join(appPath, "Info.plist")
2592
+ ]);
2593
+ if (signAdHoc) await (0, execa.execa)("codesign", [
2594
+ "--force",
2595
+ "--sign",
2596
+ "-",
2597
+ "--timestamp=none",
2598
+ "--preserve-metadata=entitlements",
2599
+ appPath
2600
+ ]);
2601
+ };
2602
+ //#endregion
2577
2603
  //#region src/utils/ciSigningKeychain.ts
2578
2604
  const API_URL = "https://api.appstoreconnect.apple.com";
2579
2605
  const CERTIFICATES_URL = "https://developer.apple.com/account/resources/certificates/list";
@@ -3738,7 +3764,7 @@ const removeSavedAdHocProfiles = async ({ teamId, bundleIds, dirs = provisioning
3738
3764
  * once the caller has copied it out. A failed build removes it, and every
3739
3765
  * other directory the build used, itself.
3740
3766
  */
3741
- const buildIos = async ({ schemeConfig, minBundleId = (0, _hot_updater_cli_tools.createMinBundleId)(), credentials, sandbox, logHeader = [], expectedDevices }) => {
3767
+ const buildIos = async ({ schemeConfig, minBundleId = (0, _hot_updater_cli_tools.createMinBundleId)(), credentials, sandbox, logHeader = [], expectedDevices, channel }) => {
3742
3768
  await assertXcodebuildExist();
3743
3769
  if (schemeConfig.simulator && schemeConfig.destination.length) {
3744
3770
  _hot_updater_cli_tools.p.log.error("The scheme option 'simulator' is not compatible with the 'destination' option.");
@@ -3754,7 +3780,8 @@ const buildIos = async ({ schemeConfig, minBundleId = (0, _hot_updater_cli_tools
3754
3780
  sandbox,
3755
3781
  buildDirectory,
3756
3782
  logHeader,
3757
- expectedDevices
3783
+ expectedDevices,
3784
+ channel
3758
3785
  }),
3759
3786
  dispose: () => removeTmpDir(buildDirectory)
3760
3787
  };
@@ -3763,7 +3790,7 @@ const buildIos = async ({ schemeConfig, minBundleId = (0, _hot_updater_cli_tools
3763
3790
  throw error;
3764
3791
  }
3765
3792
  };
3766
- const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buildDirectory, logHeader, expectedDevices }) => {
3793
+ const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buildDirectory, logHeader, expectedDevices, channel }) => {
3767
3794
  const iosProjectRoot = path.default.join((0, _hot_updater_cli_tools.getCwd)(), "ios");
3768
3795
  if (schemeConfig.simulator) {
3769
3796
  const appDir = path.default.join(buildDirectory, "app");
@@ -3785,6 +3812,7 @@ const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buil
3785
3812
  sandbox: schemeConfig.sandbox
3786
3813
  });
3787
3814
  if (schemeConfig.sandbox) await patchSandboxSimulatorApp(appPath, schemeConfig);
3815
+ if (channel !== void 0) await stampAppChannel(appPath, channel, { signAdHoc: true });
3788
3816
  return {
3789
3817
  buildDirectory,
3790
3818
  buildArtifactPath: appPath,
@@ -3802,7 +3830,8 @@ const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buil
3802
3830
  sandbox,
3803
3831
  buildDirectory,
3804
3832
  logHeader,
3805
- expectedDevices
3833
+ expectedDevices,
3834
+ channel
3806
3835
  });
3807
3836
  const registeredDevices = await exportsForRegisteredDevices(schemeConfig);
3808
3837
  const ownKeychain = registeredDevices || await exportsForAppStoreConnect(schemeConfig);
@@ -3818,7 +3847,8 @@ const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buil
3818
3847
  buildDirectory,
3819
3848
  logHeader,
3820
3849
  authenticationArgs: signing.authenticationArgs,
3821
- expectedDevices
3850
+ expectedDevices,
3851
+ channel
3822
3852
  })
3823
3853
  });
3824
3854
  }
@@ -3827,7 +3857,8 @@ const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buil
3827
3857
  * Archives a device build and exports its `.ipa`, or returns the
3828
3858
  * `.xcarchive` of a scheme it cannot export.
3829
3859
  */
3830
- const archiveAndExport = async ({ schemeConfig, minBundleId, sandbox, buildDirectory, logHeader, authenticationArgs, expectedDevices }) => {
3860
+ const archiveAndExport = async ({ schemeConfig, minBundleId, sandbox, buildDirectory, logHeader, authenticationArgs, expectedDevices, channel }) => {
3861
+ if (channel !== void 0 && !schemeConfig.exportOptionsPlist && !authenticationArgs) throw new Error(`The scheme ${schemeConfig.hotUpdaterSchemeName} archives without exporting, so its app can't embed a --channel and stay signed.\nSet exportOptionsPlist or signing.ascApiKey on the scheme.`);
3831
3862
  const iosProjectRoot = path.default.join((0, _hot_updater_cli_tools.getCwd)(), "ios");
3832
3863
  const archiveDir = path.default.join(buildDirectory, "archive");
3833
3864
  const exportDir = path.default.join(buildDirectory, "export");
@@ -3858,6 +3889,10 @@ const archiveAndExport = async ({ schemeConfig, minBundleId, sandbox, buildDirec
3858
3889
  plan: sandbox
3859
3890
  });
3860
3891
  }
3892
+ if (channel !== void 0) {
3893
+ if (!appFromArchive) throw new Error(`The archive ${archivePath} has no app to stamp.`);
3894
+ await stampAppChannel(appFromArchive, channel);
3895
+ }
3861
3896
  const archivedAppPath = appFromArchive ? path.default.join(archiveDir, path.default.basename(appFromArchive)) : void 0;
3862
3897
  if (appFromArchive && archivedAppPath) await fs.default.promises.cp(appFromArchive, archivedAppPath, { recursive: true });
3863
3898
  if (!schemeConfig.exportOptionsPlist && !authenticationArgs) return {
package/dist/index.d.cts CHANGED
@@ -394,8 +394,13 @@ declare const readTestFlightBuildStatus: ({ bundleId, shortVersion, bundleVersio
394
394
  * once the caller has copied it out. A failed build removes it, and every
395
395
  * other directory the build used, itself.
396
396
  */
397
- declare const buildIos: ({ schemeConfig, minBundleId, credentials, sandbox, logHeader, expectedDevices }: {
397
+ declare const buildIos: ({ schemeConfig, minBundleId, credentials, sandbox, logHeader, expectedDevices, channel }: {
398
398
  schemeConfig: EnrichedNativeBuildIosScheme;
399
+ /**
400
+ * The channel the build embeds, whatever the project's Info.plist or an
401
+ * Expo config plugin set; without it, theirs.
402
+ */
403
+ channel?: string;
399
404
  /** The MIN_BUNDLE_ID the build compiles in. */
400
405
  minBundleId?: string;
401
406
  /** Resolves the scheme's `signing` key, when a device build signs with one. */
package/dist/index.d.mts CHANGED
@@ -395,8 +395,13 @@ declare const readTestFlightBuildStatus: ({ bundleId, shortVersion, bundleVersio
395
395
  * once the caller has copied it out. A failed build removes it, and every
396
396
  * other directory the build used, itself.
397
397
  */
398
- declare const buildIos: ({ schemeConfig, minBundleId, credentials, sandbox, logHeader, expectedDevices }: {
398
+ declare const buildIos: ({ schemeConfig, minBundleId, credentials, sandbox, logHeader, expectedDevices, channel }: {
399
399
  schemeConfig: EnrichedNativeBuildIosScheme;
400
+ /**
401
+ * The channel the build embeds, whatever the project's Info.plist or an
402
+ * Expo config plugin set; without it, theirs.
403
+ */
404
+ channel?: string;
400
405
  /** The MIN_BUNDLE_ID the build compiles in. */
401
406
  minBundleId?: string;
402
407
  /** Resolves the scheme's `signing` key, when a device build signs with one. */
package/dist/index.mjs CHANGED
@@ -2546,6 +2546,32 @@ const assertXcodebuildExist = async () => {
2546
2546
  }
2547
2547
  };
2548
2548
  //#endregion
2549
+ //#region src/utils/channelInfoPlist.ts
2550
+ /**
2551
+ * Makes a built app embed `channel`: its Info.plist's `HOT_UPDATER_CHANNEL`,
2552
+ * which the SDK reads, whatever the project's Info.plist or an Expo config
2553
+ * plugin set. The app's signature covers the Info.plist, so an archived app
2554
+ * is stamped before its export signs it, and a simulator app is signed again
2555
+ * ad hoc after, as Xcode does for the simulator.
2556
+ */
2557
+ const stampAppChannel = async (appPath, channel, { signAdHoc = false } = {}) => {
2558
+ await execa("plutil", [
2559
+ "-replace",
2560
+ "HOT_UPDATER_CHANNEL",
2561
+ "-string",
2562
+ channel,
2563
+ path.join(appPath, "Info.plist")
2564
+ ]);
2565
+ if (signAdHoc) await execa("codesign", [
2566
+ "--force",
2567
+ "--sign",
2568
+ "-",
2569
+ "--timestamp=none",
2570
+ "--preserve-metadata=entitlements",
2571
+ appPath
2572
+ ]);
2573
+ };
2574
+ //#endregion
2549
2575
  //#region src/utils/ciSigningKeychain.ts
2550
2576
  const API_URL = "https://api.appstoreconnect.apple.com";
2551
2577
  const CERTIFICATES_URL = "https://developer.apple.com/account/resources/certificates/list";
@@ -3710,7 +3736,7 @@ const removeSavedAdHocProfiles = async ({ teamId, bundleIds, dirs = provisioning
3710
3736
  * once the caller has copied it out. A failed build removes it, and every
3711
3737
  * other directory the build used, itself.
3712
3738
  */
3713
- const buildIos = async ({ schemeConfig, minBundleId = createMinBundleId(), credentials, sandbox, logHeader = [], expectedDevices }) => {
3739
+ const buildIos = async ({ schemeConfig, minBundleId = createMinBundleId(), credentials, sandbox, logHeader = [], expectedDevices, channel }) => {
3714
3740
  await assertXcodebuildExist();
3715
3741
  if (schemeConfig.simulator && schemeConfig.destination.length) {
3716
3742
  p.log.error("The scheme option 'simulator' is not compatible with the 'destination' option.");
@@ -3726,7 +3752,8 @@ const buildIos = async ({ schemeConfig, minBundleId = createMinBundleId(), crede
3726
3752
  sandbox,
3727
3753
  buildDirectory,
3728
3754
  logHeader,
3729
- expectedDevices
3755
+ expectedDevices,
3756
+ channel
3730
3757
  }),
3731
3758
  dispose: () => removeTmpDir(buildDirectory)
3732
3759
  };
@@ -3735,7 +3762,7 @@ const buildIos = async ({ schemeConfig, minBundleId = createMinBundleId(), crede
3735
3762
  throw error;
3736
3763
  }
3737
3764
  };
3738
- const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buildDirectory, logHeader, expectedDevices }) => {
3765
+ const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buildDirectory, logHeader, expectedDevices, channel }) => {
3739
3766
  const iosProjectRoot = path.join(getCwd(), "ios");
3740
3767
  if (schemeConfig.simulator) {
3741
3768
  const appDir = path.join(buildDirectory, "app");
@@ -3757,6 +3784,7 @@ const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buil
3757
3784
  sandbox: schemeConfig.sandbox
3758
3785
  });
3759
3786
  if (schemeConfig.sandbox) await patchSandboxSimulatorApp(appPath, schemeConfig);
3787
+ if (channel !== void 0) await stampAppChannel(appPath, channel, { signAdHoc: true });
3760
3788
  return {
3761
3789
  buildDirectory,
3762
3790
  buildArtifactPath: appPath,
@@ -3774,7 +3802,8 @@ const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buil
3774
3802
  sandbox,
3775
3803
  buildDirectory,
3776
3804
  logHeader,
3777
- expectedDevices
3805
+ expectedDevices,
3806
+ channel
3778
3807
  });
3779
3808
  const registeredDevices = await exportsForRegisteredDevices(schemeConfig);
3780
3809
  const ownKeychain = registeredDevices || await exportsForAppStoreConnect(schemeConfig);
@@ -3790,7 +3819,8 @@ const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buil
3790
3819
  buildDirectory,
3791
3820
  logHeader,
3792
3821
  authenticationArgs: signing.authenticationArgs,
3793
- expectedDevices
3822
+ expectedDevices,
3823
+ channel
3794
3824
  })
3795
3825
  });
3796
3826
  }
@@ -3799,7 +3829,8 @@ const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buil
3799
3829
  * Archives a device build and exports its `.ipa`, or returns the
3800
3830
  * `.xcarchive` of a scheme it cannot export.
3801
3831
  */
3802
- const archiveAndExport = async ({ schemeConfig, minBundleId, sandbox, buildDirectory, logHeader, authenticationArgs, expectedDevices }) => {
3832
+ const archiveAndExport = async ({ schemeConfig, minBundleId, sandbox, buildDirectory, logHeader, authenticationArgs, expectedDevices, channel }) => {
3833
+ if (channel !== void 0 && !schemeConfig.exportOptionsPlist && !authenticationArgs) throw new Error(`The scheme ${schemeConfig.hotUpdaterSchemeName} archives without exporting, so its app can't embed a --channel and stay signed.\nSet exportOptionsPlist or signing.ascApiKey on the scheme.`);
3803
3834
  const iosProjectRoot = path.join(getCwd(), "ios");
3804
3835
  const archiveDir = path.join(buildDirectory, "archive");
3805
3836
  const exportDir = path.join(buildDirectory, "export");
@@ -3830,6 +3861,10 @@ const archiveAndExport = async ({ schemeConfig, minBundleId, sandbox, buildDirec
3830
3861
  plan: sandbox
3831
3862
  });
3832
3863
  }
3864
+ if (channel !== void 0) {
3865
+ if (!appFromArchive) throw new Error(`The archive ${archivePath} has no app to stamp.`);
3866
+ await stampAppChannel(appFromArchive, channel);
3867
+ }
3833
3868
  const archivedAppPath = appFromArchive ? path.join(archiveDir, path.basename(appFromArchive)) : void 0;
3834
3869
  if (appFromArchive && archivedAppPath) await fs.promises.cp(appFromArchive, archivedAppPath, { recursive: true });
3835
3870
  if (!schemeConfig.exportOptionsPlist && !authenticationArgs) return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/apple-helper",
3
- "version": "1.2.0-rc.41",
3
+ "version": "1.2.0-rc.42",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -29,9 +29,9 @@
29
29
  "dependencies": {
30
30
  "execa": "9.5.2",
31
31
  "fast-xml-parser": "5.8.0",
32
- "@hot-updater/cli-tools": "1.2.0-rc.41",
33
- "@hot-updater/plugin-core": "1.2.0-rc.41",
34
- "@hot-updater/protocol": "1.2.0-rc.41"
32
+ "@hot-updater/cli-tools": "1.2.0-rc.42",
33
+ "@hot-updater/plugin-core": "1.2.0-rc.42",
34
+ "@hot-updater/protocol": "1.2.0-rc.42"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^20"