@hot-updater/apple-helper 1.2.0-rc.40 → 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";
@@ -3531,7 +3557,8 @@ const addSandboxPermissions = async (plist) => {
3531
3557
  ]);
3532
3558
  };
3533
3559
  /**
3534
- * The app's dedicated URL scheme, default channel, and the sandbox's key. The
3560
+ * The app's dedicated URL scheme and the sandbox's key: its channel stays the
3561
+ * project's, as any build's does. The
3535
3562
  * URL scheme, unless the scheme sets one, and App Store Connect's app come
3536
3563
  * from the scheme's `bundleIdentifier`, while Xcode's build settings decide
3537
3564
  * the app's ID, so an app of another ID stops here, before anything is signed
@@ -3547,7 +3574,6 @@ const patchAppInfoPlist = async (plist, scheme) => {
3547
3574
  if (appUrlTypes.some(isSandboxUrlType)) throw refusal(`The app has a URL type named ${_hot_updater_protocol_native_artifact.SANDBOX_URL_TYPE_NAME}, the name a sandbox build registers its URL scheme under.\nRename the app's URL type.`);
3548
3575
  if (patchedBefore) await refuseForeignSandboxUrlTypes(plist, urlTypes ?? [], scheme);
3549
3576
  if (registersUrlScheme(appUrlTypes, urlScheme)) throw refusal(`The sandbox scheme ${scheme.hotUpdaterSchemeName} registers URL scheme ${urlScheme}, which the app registers itself.\nSet sandbox.urlScheme to a scheme the app doesn't register.`);
3550
- await setString(plist, "HOT_UPDATER_CHANNEL", (0, _hot_updater_protocol_native_artifact.sandboxChannelOf)(scheme.hotUpdaterSchemeName));
3551
3577
  await plutil([
3552
3578
  "-replace",
3553
3579
  _hot_updater_protocol_native_artifact.SANDBOX_INFO_PLIST_KEY,
@@ -3621,8 +3647,7 @@ const extensionInfoPlists = (appPath) => ["PlugIns", "Extensions"].flatMap((dire
3621
3647
  });
3622
3648
  /**
3623
3649
  * Makes the archived app a sandbox app before `-exportArchive`, which signs
3624
- * what it finds, so no project file changes: its URL scheme, default channel
3625
- * and key, and from App Store Connect, the version a closed train needs and
3650
+ * what it finds, so no project file changes: its URL scheme and key, and from App Store Connect, the version a closed train needs and
3626
3651
  * the next build number, in its extensions too, which must match it.
3627
3652
  */
3628
3653
  const patchSandboxArchive = async ({ archivePath, appPath, schemeConfig, plan }) => {
@@ -3739,7 +3764,7 @@ const removeSavedAdHocProfiles = async ({ teamId, bundleIds, dirs = provisioning
3739
3764
  * once the caller has copied it out. A failed build removes it, and every
3740
3765
  * other directory the build used, itself.
3741
3766
  */
3742
- 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 }) => {
3743
3768
  await assertXcodebuildExist();
3744
3769
  if (schemeConfig.simulator && schemeConfig.destination.length) {
3745
3770
  _hot_updater_cli_tools.p.log.error("The scheme option 'simulator' is not compatible with the 'destination' option.");
@@ -3755,7 +3780,8 @@ const buildIos = async ({ schemeConfig, minBundleId = (0, _hot_updater_cli_tools
3755
3780
  sandbox,
3756
3781
  buildDirectory,
3757
3782
  logHeader,
3758
- expectedDevices
3783
+ expectedDevices,
3784
+ channel
3759
3785
  }),
3760
3786
  dispose: () => removeTmpDir(buildDirectory)
3761
3787
  };
@@ -3764,7 +3790,7 @@ const buildIos = async ({ schemeConfig, minBundleId = (0, _hot_updater_cli_tools
3764
3790
  throw error;
3765
3791
  }
3766
3792
  };
3767
- const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buildDirectory, logHeader, expectedDevices }) => {
3793
+ const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buildDirectory, logHeader, expectedDevices, channel }) => {
3768
3794
  const iosProjectRoot = path.default.join((0, _hot_updater_cli_tools.getCwd)(), "ios");
3769
3795
  if (schemeConfig.simulator) {
3770
3796
  const appDir = path.default.join(buildDirectory, "app");
@@ -3786,6 +3812,7 @@ const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buil
3786
3812
  sandbox: schemeConfig.sandbox
3787
3813
  });
3788
3814
  if (schemeConfig.sandbox) await patchSandboxSimulatorApp(appPath, schemeConfig);
3815
+ if (channel !== void 0) await stampAppChannel(appPath, channel, { signAdHoc: true });
3789
3816
  return {
3790
3817
  buildDirectory,
3791
3818
  buildArtifactPath: appPath,
@@ -3803,7 +3830,8 @@ const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buil
3803
3830
  sandbox,
3804
3831
  buildDirectory,
3805
3832
  logHeader,
3806
- expectedDevices
3833
+ expectedDevices,
3834
+ channel
3807
3835
  });
3808
3836
  const registeredDevices = await exportsForRegisteredDevices(schemeConfig);
3809
3837
  const ownKeychain = registeredDevices || await exportsForAppStoreConnect(schemeConfig);
@@ -3819,7 +3847,8 @@ const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buil
3819
3847
  buildDirectory,
3820
3848
  logHeader,
3821
3849
  authenticationArgs: signing.authenticationArgs,
3822
- expectedDevices
3850
+ expectedDevices,
3851
+ channel
3823
3852
  })
3824
3853
  });
3825
3854
  }
@@ -3828,7 +3857,8 @@ const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buil
3828
3857
  * Archives a device build and exports its `.ipa`, or returns the
3829
3858
  * `.xcarchive` of a scheme it cannot export.
3830
3859
  */
3831
- 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.`);
3832
3862
  const iosProjectRoot = path.default.join((0, _hot_updater_cli_tools.getCwd)(), "ios");
3833
3863
  const archiveDir = path.default.join(buildDirectory, "archive");
3834
3864
  const exportDir = path.default.join(buildDirectory, "export");
@@ -3859,6 +3889,10 @@ const archiveAndExport = async ({ schemeConfig, minBundleId, sandbox, buildDirec
3859
3889
  plan: sandbox
3860
3890
  });
3861
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
+ }
3862
3896
  const archivedAppPath = appFromArchive ? path.default.join(archiveDir, path.default.basename(appFromArchive)) : void 0;
3863
3897
  if (appFromArchive && archivedAppPath) await fs.default.promises.cp(appFromArchive, archivedAppPath, { recursive: true });
3864
3898
  if (!schemeConfig.exportOptionsPlist && !authenticationArgs) return {
@@ -4112,6 +4146,7 @@ exports.assertTestFlightExportOptions = assertTestFlightExportOptions;
4112
4146
  exports.buildIos = buildIos;
4113
4147
  exports.distributeTestFlightBuild = distributeTestFlightBuild;
4114
4148
  exports.enrichNativeBuildIosScheme = enrichNativeBuildIosScheme;
4149
+ exports.exportsForAppStoreConnect = exportsForAppStoreConnect;
4115
4150
  exports.exportsForRegisteredDevices = exportsForRegisteredDevices;
4116
4151
  exports.extractAppBundle = extractAppBundle;
4117
4152
  exports.extractBuiltInBundle = extractBuiltInBundle;
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. */
@@ -531,6 +536,14 @@ declare const assertSandboxExportOptions: (schemeName: string, exportOptionsPlis
531
536
  * signs it, as it does an App Store Connect export.
532
537
  */
533
538
  declare const exportsForRegisteredDevices: ({ exportOptionsPlist }: EnrichedNativeBuildIosScheme) => Promise<boolean>;
539
+ /**
540
+ * Whether a device build exports for App Store Connect: with its
541
+ * `exportOptionsPlist`'s method, or, without one, as a scheme signing with
542
+ * an App Store Connect API key does. Such an `.ipa` is signed with Apple's
543
+ * cloud-managed distribution certificate, never with a development
544
+ * certificate the archive was signed with.
545
+ */
546
+ declare const exportsForAppStoreConnect: (schemeConfig: EnrichedNativeBuildIosScheme) => Promise<boolean>;
534
547
  //#endregion
535
548
  //#region src/utils/extractBuiltInBundle.d.ts
536
549
  /**
@@ -559,4 +572,4 @@ declare const archiveAppBundle: ({ appPath, outputPath }: {
559
572
  outputPath: string;
560
573
  }) => Promise<void>;
561
574
  //#endregion
562
- export { ASC_INTEGRATIONS_URL, type AppleDeviceType, type AscApiKeyRole, type AscDevice, type AscDeviceOutcome, type AscTeam, type EnrichedNativeBuildIosScheme, type InternalBetaGroup, type IssueAscApiKey, type IssueAscApiKeyRequest, type IssuedAscApiKey, type SandboxArchivePlan, type SavedAdHocProfileRemoval, type Simulator, TestFlightBuildExistsError, type TestFlightBuildState, type TestFlightBuildStatus, type TestFlightGroupOutcome, type UploadToTestFlightResult, addAscDevices, applyTestFlightGroup, archiveAppBundle, assertBuildIsInternalOnly, assertIpaIsInternalOnly, assertSandboxExportOptions, assertTestFlightExportOptions, buildIos, distributeTestFlightBuild, enrichNativeBuildIosScheme, exportsForRegisteredDevices, extractAppBundle, extractBuiltInBundle, extractSimulatorApp, findAscDevice, findInternalBetaGroup, findTestFlightBuild, installOnSimulator, installPodsIfNeeded, isVersionTrainClosed, issueAscApiKey, listAscDevices, listSimulators, prepareSandboxArchive, provisioningProfileDirs, readIpaHasExportComplianceKey, readTestFlightBuildStatus, removeSavedAdHocProfiles, resolveTestFlightUploadKey, selectSimulator, updateAscDevice, uploadToTestFlight };
575
+ export { ASC_INTEGRATIONS_URL, type AppleDeviceType, type AscApiKeyRole, type AscDevice, type AscDeviceOutcome, type AscTeam, type EnrichedNativeBuildIosScheme, type InternalBetaGroup, type IssueAscApiKey, type IssueAscApiKeyRequest, type IssuedAscApiKey, type SandboxArchivePlan, type SavedAdHocProfileRemoval, type Simulator, TestFlightBuildExistsError, type TestFlightBuildState, type TestFlightBuildStatus, type TestFlightGroupOutcome, type UploadToTestFlightResult, addAscDevices, applyTestFlightGroup, archiveAppBundle, assertBuildIsInternalOnly, assertIpaIsInternalOnly, assertSandboxExportOptions, assertTestFlightExportOptions, buildIos, distributeTestFlightBuild, enrichNativeBuildIosScheme, exportsForAppStoreConnect, exportsForRegisteredDevices, extractAppBundle, extractBuiltInBundle, extractSimulatorApp, findAscDevice, findInternalBetaGroup, findTestFlightBuild, installOnSimulator, installPodsIfNeeded, isVersionTrainClosed, issueAscApiKey, listAscDevices, listSimulators, prepareSandboxArchive, provisioningProfileDirs, readIpaHasExportComplianceKey, readTestFlightBuildStatus, removeSavedAdHocProfiles, resolveTestFlightUploadKey, selectSimulator, updateAscDevice, uploadToTestFlight };
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. */
@@ -532,6 +537,14 @@ declare const assertSandboxExportOptions: (schemeName: string, exportOptionsPlis
532
537
  * signs it, as it does an App Store Connect export.
533
538
  */
534
539
  declare const exportsForRegisteredDevices: ({ exportOptionsPlist }: EnrichedNativeBuildIosScheme) => Promise<boolean>;
540
+ /**
541
+ * Whether a device build exports for App Store Connect: with its
542
+ * `exportOptionsPlist`'s method, or, without one, as a scheme signing with
543
+ * an App Store Connect API key does. Such an `.ipa` is signed with Apple's
544
+ * cloud-managed distribution certificate, never with a development
545
+ * certificate the archive was signed with.
546
+ */
547
+ declare const exportsForAppStoreConnect: (schemeConfig: EnrichedNativeBuildIosScheme) => Promise<boolean>;
535
548
  //#endregion
536
549
  //#region src/utils/extractBuiltInBundle.d.ts
537
550
  /**
@@ -560,4 +573,4 @@ declare const archiveAppBundle: ({ appPath, outputPath }: {
560
573
  outputPath: string;
561
574
  }) => Promise<void>;
562
575
  //#endregion
563
- export { ASC_INTEGRATIONS_URL, type AppleDeviceType, type AscApiKeyRole, type AscDevice, type AscDeviceOutcome, type AscTeam, type EnrichedNativeBuildIosScheme, type InternalBetaGroup, type IssueAscApiKey, type IssueAscApiKeyRequest, type IssuedAscApiKey, type SandboxArchivePlan, type SavedAdHocProfileRemoval, type Simulator, TestFlightBuildExistsError, type TestFlightBuildState, type TestFlightBuildStatus, type TestFlightGroupOutcome, type UploadToTestFlightResult, addAscDevices, applyTestFlightGroup, archiveAppBundle, assertBuildIsInternalOnly, assertIpaIsInternalOnly, assertSandboxExportOptions, assertTestFlightExportOptions, buildIos, distributeTestFlightBuild, enrichNativeBuildIosScheme, exportsForRegisteredDevices, extractAppBundle, extractBuiltInBundle, extractSimulatorApp, findAscDevice, findInternalBetaGroup, findTestFlightBuild, installOnSimulator, installPodsIfNeeded, isVersionTrainClosed, issueAscApiKey, listAscDevices, listSimulators, prepareSandboxArchive, provisioningProfileDirs, readIpaHasExportComplianceKey, readTestFlightBuildStatus, removeSavedAdHocProfiles, resolveTestFlightUploadKey, selectSimulator, updateAscDevice, uploadToTestFlight };
576
+ export { ASC_INTEGRATIONS_URL, type AppleDeviceType, type AscApiKeyRole, type AscDevice, type AscDeviceOutcome, type AscTeam, type EnrichedNativeBuildIosScheme, type InternalBetaGroup, type IssueAscApiKey, type IssueAscApiKeyRequest, type IssuedAscApiKey, type SandboxArchivePlan, type SavedAdHocProfileRemoval, type Simulator, TestFlightBuildExistsError, type TestFlightBuildState, type TestFlightBuildStatus, type TestFlightGroupOutcome, type UploadToTestFlightResult, addAscDevices, applyTestFlightGroup, archiveAppBundle, assertBuildIsInternalOnly, assertIpaIsInternalOnly, assertSandboxExportOptions, assertTestFlightExportOptions, buildIos, distributeTestFlightBuild, enrichNativeBuildIosScheme, exportsForAppStoreConnect, exportsForRegisteredDevices, extractAppBundle, extractBuiltInBundle, extractSimulatorApp, findAscDevice, findInternalBetaGroup, findTestFlightBuild, installOnSimulator, installPodsIfNeeded, isVersionTrainClosed, issueAscApiKey, listAscDevices, listSimulators, prepareSandboxArchive, provisioningProfileDirs, readIpaHasExportComplianceKey, readTestFlightBuildStatus, removeSavedAdHocProfiles, resolveTestFlightUploadKey, selectSimulator, updateAscDevice, uploadToTestFlight };
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import crypto from "node:crypto";
2
2
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
3
3
  import { BuildFailedError, BuildLogger, colors, createCredentialResolver, createMinBundleId, getCwd, getReactNativeMetadatas, isCI, p, parseSecretReference, registerSecretValue } from "@hot-updater/cli-tools";
4
- import { SANDBOX_INFO_PLIST_KEY, SANDBOX_URL_SCHEME_INFO_PLIST_KEY, SANDBOX_URL_TYPE_NAME, blobSource, isRecordedUrlSchemeSyntax, isSandboxUrlScheme, normalizeIosUdid, readIpaInstallInfo, readProvisioningProfile, recordedSandboxUrlScheme, sandboxChannelOf, sandboxUrlSchemeOf } from "@hot-updater/protocol/native-artifact";
4
+ import { SANDBOX_INFO_PLIST_KEY, SANDBOX_URL_SCHEME_INFO_PLIST_KEY, SANDBOX_URL_TYPE_NAME, blobSource, isRecordedUrlSchemeSyntax, isSandboxUrlScheme, normalizeIosUdid, readIpaInstallInfo, readProvisioningProfile, recordedSandboxUrlScheme, sandboxUrlSchemeOf } from "@hot-updater/protocol/native-artifact";
5
5
  import crypto$1 from "crypto";
6
6
  import fs from "fs";
7
7
  import path from "path";
@@ -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";
@@ -3503,7 +3529,8 @@ const addSandboxPermissions = async (plist) => {
3503
3529
  ]);
3504
3530
  };
3505
3531
  /**
3506
- * The app's dedicated URL scheme, default channel, and the sandbox's key. The
3532
+ * The app's dedicated URL scheme and the sandbox's key: its channel stays the
3533
+ * project's, as any build's does. The
3507
3534
  * URL scheme, unless the scheme sets one, and App Store Connect's app come
3508
3535
  * from the scheme's `bundleIdentifier`, while Xcode's build settings decide
3509
3536
  * the app's ID, so an app of another ID stops here, before anything is signed
@@ -3519,7 +3546,6 @@ const patchAppInfoPlist = async (plist, scheme) => {
3519
3546
  if (appUrlTypes.some(isSandboxUrlType)) throw refusal(`The app has a URL type named ${SANDBOX_URL_TYPE_NAME}, the name a sandbox build registers its URL scheme under.\nRename the app's URL type.`);
3520
3547
  if (patchedBefore) await refuseForeignSandboxUrlTypes(plist, urlTypes ?? [], scheme);
3521
3548
  if (registersUrlScheme(appUrlTypes, urlScheme)) throw refusal(`The sandbox scheme ${scheme.hotUpdaterSchemeName} registers URL scheme ${urlScheme}, which the app registers itself.\nSet sandbox.urlScheme to a scheme the app doesn't register.`);
3522
- await setString(plist, "HOT_UPDATER_CHANNEL", sandboxChannelOf(scheme.hotUpdaterSchemeName));
3523
3549
  await plutil([
3524
3550
  "-replace",
3525
3551
  SANDBOX_INFO_PLIST_KEY,
@@ -3593,8 +3619,7 @@ const extensionInfoPlists = (appPath) => ["PlugIns", "Extensions"].flatMap((dire
3593
3619
  });
3594
3620
  /**
3595
3621
  * Makes the archived app a sandbox app before `-exportArchive`, which signs
3596
- * what it finds, so no project file changes: its URL scheme, default channel
3597
- * and key, and from App Store Connect, the version a closed train needs and
3622
+ * what it finds, so no project file changes: its URL scheme and key, and from App Store Connect, the version a closed train needs and
3598
3623
  * the next build number, in its extensions too, which must match it.
3599
3624
  */
3600
3625
  const patchSandboxArchive = async ({ archivePath, appPath, schemeConfig, plan }) => {
@@ -3711,7 +3736,7 @@ const removeSavedAdHocProfiles = async ({ teamId, bundleIds, dirs = provisioning
3711
3736
  * once the caller has copied it out. A failed build removes it, and every
3712
3737
  * other directory the build used, itself.
3713
3738
  */
3714
- const buildIos = async ({ schemeConfig, minBundleId = createMinBundleId(), credentials, sandbox, logHeader = [], expectedDevices }) => {
3739
+ const buildIos = async ({ schemeConfig, minBundleId = createMinBundleId(), credentials, sandbox, logHeader = [], expectedDevices, channel }) => {
3715
3740
  await assertXcodebuildExist();
3716
3741
  if (schemeConfig.simulator && schemeConfig.destination.length) {
3717
3742
  p.log.error("The scheme option 'simulator' is not compatible with the 'destination' option.");
@@ -3727,7 +3752,8 @@ const buildIos = async ({ schemeConfig, minBundleId = createMinBundleId(), crede
3727
3752
  sandbox,
3728
3753
  buildDirectory,
3729
3754
  logHeader,
3730
- expectedDevices
3755
+ expectedDevices,
3756
+ channel
3731
3757
  }),
3732
3758
  dispose: () => removeTmpDir(buildDirectory)
3733
3759
  };
@@ -3736,7 +3762,7 @@ const buildIos = async ({ schemeConfig, minBundleId = createMinBundleId(), crede
3736
3762
  throw error;
3737
3763
  }
3738
3764
  };
3739
- const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buildDirectory, logHeader, expectedDevices }) => {
3765
+ const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buildDirectory, logHeader, expectedDevices, channel }) => {
3740
3766
  const iosProjectRoot = path.join(getCwd(), "ios");
3741
3767
  if (schemeConfig.simulator) {
3742
3768
  const appDir = path.join(buildDirectory, "app");
@@ -3758,6 +3784,7 @@ const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buil
3758
3784
  sandbox: schemeConfig.sandbox
3759
3785
  });
3760
3786
  if (schemeConfig.sandbox) await patchSandboxSimulatorApp(appPath, schemeConfig);
3787
+ if (channel !== void 0) await stampAppChannel(appPath, channel, { signAdHoc: true });
3761
3788
  return {
3762
3789
  buildDirectory,
3763
3790
  buildArtifactPath: appPath,
@@ -3775,7 +3802,8 @@ const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buil
3775
3802
  sandbox,
3776
3803
  buildDirectory,
3777
3804
  logHeader,
3778
- expectedDevices
3805
+ expectedDevices,
3806
+ channel
3779
3807
  });
3780
3808
  const registeredDevices = await exportsForRegisteredDevices(schemeConfig);
3781
3809
  const ownKeychain = registeredDevices || await exportsForAppStoreConnect(schemeConfig);
@@ -3791,7 +3819,8 @@ const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buil
3791
3819
  buildDirectory,
3792
3820
  logHeader,
3793
3821
  authenticationArgs: signing.authenticationArgs,
3794
- expectedDevices
3822
+ expectedDevices,
3823
+ channel
3795
3824
  })
3796
3825
  });
3797
3826
  }
@@ -3800,7 +3829,8 @@ const buildInto = async ({ schemeConfig, minBundleId, credentials, sandbox, buil
3800
3829
  * Archives a device build and exports its `.ipa`, or returns the
3801
3830
  * `.xcarchive` of a scheme it cannot export.
3802
3831
  */
3803
- 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.`);
3804
3834
  const iosProjectRoot = path.join(getCwd(), "ios");
3805
3835
  const archiveDir = path.join(buildDirectory, "archive");
3806
3836
  const exportDir = path.join(buildDirectory, "export");
@@ -3831,6 +3861,10 @@ const archiveAndExport = async ({ schemeConfig, minBundleId, sandbox, buildDirec
3831
3861
  plan: sandbox
3832
3862
  });
3833
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
+ }
3834
3868
  const archivedAppPath = appFromArchive ? path.join(archiveDir, path.basename(appFromArchive)) : void 0;
3835
3869
  if (appFromArchive && archivedAppPath) await fs.promises.cp(appFromArchive, archivedAppPath, { recursive: true });
3836
3870
  if (!schemeConfig.exportOptionsPlist && !authenticationArgs) return {
@@ -4072,4 +4106,4 @@ const enrichNativeBuildIosScheme = async ({ scheme, hotUpdaterSchemeName }) => {
4072
4106
  };
4073
4107
  };
4074
4108
  //#endregion
4075
- export { ASC_INTEGRATIONS_URL, TestFlightBuildExistsError, addAscDevices, applyTestFlightGroup, archiveAppBundle, assertBuildIsInternalOnly, assertIpaIsInternalOnly, assertSandboxExportOptions, assertTestFlightExportOptions, buildIos, distributeTestFlightBuild, enrichNativeBuildIosScheme, exportsForRegisteredDevices, extractAppBundle, extractBuiltInBundle, extractSimulatorApp, findAscDevice, findInternalBetaGroup, findTestFlightBuild, installOnSimulator, installPodsIfNeeded, isVersionTrainClosed, issueAscApiKey, listAscDevices, listSimulators, prepareSandboxArchive, provisioningProfileDirs, readIpaHasExportComplianceKey, readTestFlightBuildStatus, removeSavedAdHocProfiles, resolveTestFlightUploadKey, selectSimulator, updateAscDevice, uploadToTestFlight };
4109
+ export { ASC_INTEGRATIONS_URL, TestFlightBuildExistsError, addAscDevices, applyTestFlightGroup, archiveAppBundle, assertBuildIsInternalOnly, assertIpaIsInternalOnly, assertSandboxExportOptions, assertTestFlightExportOptions, buildIos, distributeTestFlightBuild, enrichNativeBuildIosScheme, exportsForAppStoreConnect, exportsForRegisteredDevices, extractAppBundle, extractBuiltInBundle, extractSimulatorApp, findAscDevice, findInternalBetaGroup, findTestFlightBuild, installOnSimulator, installPodsIfNeeded, isVersionTrainClosed, issueAscApiKey, listAscDevices, listSimulators, prepareSandboxArchive, provisioningProfileDirs, readIpaHasExportComplianceKey, readTestFlightBuildStatus, removeSavedAdHocProfiles, resolveTestFlightUploadKey, selectSimulator, updateAscDevice, uploadToTestFlight };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/apple-helper",
3
- "version": "1.2.0-rc.40",
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.40",
33
- "@hot-updater/plugin-core": "1.2.0-rc.40",
34
- "@hot-updater/protocol": "1.2.0-rc.40"
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"