@mcesystems/apple-kit 1.0.50 → 1.0.51

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.js CHANGED
@@ -34060,8 +34060,9 @@ var ActivationFlow = class {
34060
34060
  }
34061
34061
  await this.installWifiProfile(udid);
34062
34062
  await this.installMdmProfile(udid);
34063
- await this.retryIosCommand("skip steps", () => this.iosCli.skipSteps(udid));
34064
34063
  await this.installTrustProfile(udid);
34064
+ await this.installResourcesIpa(udid);
34065
+ await this.retryIosCommand("skip steps", () => this.iosCli.skipSteps(udid));
34065
34066
  return "activated";
34066
34067
  }
34067
34068
  async installWifiProfile(udid) {
@@ -34139,6 +34140,21 @@ var ActivationFlow = class {
34139
34140
  () => this.iosCli.installProfile(udid, resourcesProfilePath)
34140
34141
  );
34141
34142
  }
34143
+ async installResourcesIpa(udid) {
34144
+ const ipaPath = await getResourcesIpaPath(this.resourcesDir);
34145
+ if (!ipaPath) {
34146
+ return;
34147
+ }
34148
+ logTask(`Installing IPA from resources: ${ipaPath}`);
34149
+ await this.retry(
34150
+ "install ipa",
34151
+ async () => {
34152
+ await installApp(ipaPath, udid);
34153
+ return true;
34154
+ },
34155
+ (result) => result
34156
+ );
34157
+ }
34142
34158
  async requireMdmClient() {
34143
34159
  const client = await this.mdmClientPromise;
34144
34160
  if (!client) {
@@ -34204,6 +34220,41 @@ function resolveResourcesDir(resourcesDir) {
34204
34220
  function resolveResourcesPlistDir(resourcesDir) {
34205
34221
  return (0, import_node_path8.join)(resolveResourcesDir(resourcesDir), "plist");
34206
34222
  }
34223
+ async function getResourcesIpaPath(resourcesDir) {
34224
+ const resolvedResourcesDir = resolveResourcesDir(resourcesDir);
34225
+ const candidateDirs = [resolvedResourcesDir, (0, import_node_path8.join)(resolvedResourcesDir, "apps")];
34226
+ for (const dir of candidateDirs) {
34227
+ const entries = await safeReadDir(dir);
34228
+ if (!entries) {
34229
+ continue;
34230
+ }
34231
+ for (const entry of entries) {
34232
+ if (!entry.isFile()) {
34233
+ continue;
34234
+ }
34235
+ const name = entry.name.toLowerCase();
34236
+ if (name.endsWith(".ipa")) {
34237
+ return (0, import_node_path8.join)(dir, entry.name);
34238
+ }
34239
+ }
34240
+ }
34241
+ return void 0;
34242
+ }
34243
+ function isErrorWithCode(error) {
34244
+ return typeof error === "object" && error !== null && "code" in error;
34245
+ }
34246
+ async function safeReadDir(dir) {
34247
+ try {
34248
+ return await (0, import_promises3.readdir)(dir, { withFileTypes: true });
34249
+ } catch (error) {
34250
+ if (isErrorWithCode(error) && typeof error.code === "string" && error.code === "ENOENT") {
34251
+ return void 0;
34252
+ }
34253
+ const errorMsg = error instanceof Error ? error.message : String(error);
34254
+ logError(`Failed to read resources directory ${dir}: ${errorMsg}`);
34255
+ return void 0;
34256
+ }
34257
+ }
34207
34258
  function getResourcesEnrollmentProfilePath(resourcesDir, udid) {
34208
34259
  const baseDir = resolveResourcesDir(resourcesDir);
34209
34260
  const mdmDir = (0, import_node_path8.join)(baseDir, "mdm");