swiftpatch-cli 1.1.4 → 1.1.5

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
@@ -492,7 +492,7 @@ init_esm_shims();
492
492
  init_esm_shims();
493
493
  import { Command as Command47 } from "commander";
494
494
  import chalk45 from "chalk";
495
- import { readFileSync as readFileSync4 } from "fs";
495
+ import { readFileSync as readFileSync3 } from "fs";
496
496
  import { fileURLToPath as fileURLToPath3 } from "url";
497
497
  import { dirname as dirname3, join as join3 } from "path";
498
498
 
@@ -1308,7 +1308,6 @@ function sleep2(ms) {
1308
1308
  init_esm_shims();
1309
1309
  import crypto2 from "crypto";
1310
1310
  import fs3 from "fs-extra";
1311
- import { readFileSync as readFileSync2 } from "fs";
1312
1311
  async function hashBundle(bundlePath) {
1313
1312
  return new Promise((resolve, reject) => {
1314
1313
  const hash = crypto2.createHash("sha256");
@@ -1318,14 +1317,6 @@ async function hashBundle(bundlePath) {
1318
1317
  stream.on("error", reject);
1319
1318
  });
1320
1319
  }
1321
- function calculateZipHash(filePath) {
1322
- try {
1323
- const fileBuffer = readFileSync2(filePath);
1324
- return crypto2.createHash("sha256").update(fileBuffer).digest("hex");
1325
- } catch {
1326
- return null;
1327
- }
1328
- }
1329
1320
  async function hashFile(filePath) {
1330
1321
  return new Promise((resolve, reject) => {
1331
1322
  const hash = crypto2.createHash("sha256");
@@ -3820,83 +3811,65 @@ init_api();
3820
3811
  import { Command as Command39 } from "commander";
3821
3812
  import chalk37 from "chalk";
3822
3813
  import ora31 from "ora";
3823
- import path8 from "path";
3824
- import fs11 from "fs-extra";
3814
+ import path7 from "path";
3815
+ import fs10 from "fs-extra";
3825
3816
  import os3 from "os";
3826
3817
 
3827
- // src/lib/archive.ts
3828
- init_esm_shims();
3829
- import archiver from "archiver";
3830
- import fs8 from "fs";
3831
- import path5 from "path";
3832
- function createZip(inputPath, outputPath) {
3833
- return new Promise((resolve, reject) => {
3834
- const zipPath = path5.join(outputPath, "build.zip");
3835
- const output = fs8.createWriteStream(zipPath);
3836
- const archive = archiver("zip", { zlib: { level: 9 } });
3837
- output.on("close", () => resolve());
3838
- archive.on("error", (err) => reject(err));
3839
- archive.pipe(output);
3840
- archive.directory(inputPath, "build");
3841
- archive.finalize();
3842
- });
3843
- }
3844
-
3845
3818
  // src/lib/artifacts.ts
3846
3819
  init_esm_shims();
3847
- import fs9 from "fs-extra";
3848
- import path6 from "path";
3820
+ import fs8 from "fs-extra";
3821
+ import path5 from "path";
3849
3822
  async function keepArtifacts(contentRootPath, platform, variant) {
3850
- const artifactsDir = path6.join(process.cwd(), "swiftpatch-artifacts", platform, variant);
3851
- await fs9.ensureDir(artifactsDir);
3852
- const bundlesDir = path6.join(contentRootPath, "bundles");
3853
- const sourcemapsDir = path6.join(contentRootPath, "sourcemaps");
3854
- if (await fs9.pathExists(bundlesDir)) {
3855
- await copyDirRecursive(bundlesDir, path6.join(artifactsDir, "bundles"));
3823
+ const artifactsDir = path5.join(process.cwd(), "swiftpatch-artifacts", platform, variant);
3824
+ await fs8.ensureDir(artifactsDir);
3825
+ const bundlesDir = path5.join(contentRootPath, "bundles");
3826
+ const sourcemapsDir = path5.join(contentRootPath, "sourcemaps");
3827
+ if (await fs8.pathExists(bundlesDir)) {
3828
+ await copyDirRecursive(bundlesDir, path5.join(artifactsDir, "bundles"));
3856
3829
  }
3857
- if (await fs9.pathExists(sourcemapsDir)) {
3858
- await copyDirRecursive(sourcemapsDir, path6.join(artifactsDir, "sourcemaps"));
3830
+ if (await fs8.pathExists(sourcemapsDir)) {
3831
+ await copyDirRecursive(sourcemapsDir, path5.join(artifactsDir, "sourcemaps"));
3859
3832
  }
3860
3833
  }
3861
3834
  async function copyDirRecursive(srcDir, destDir) {
3862
- await fs9.ensureDir(destDir);
3863
- const entries = await fs9.readdir(srcDir);
3835
+ await fs8.ensureDir(destDir);
3836
+ const entries = await fs8.readdir(srcDir);
3864
3837
  for (const entry of entries) {
3865
- const srcPath = path6.join(srcDir, entry);
3866
- const destPath = path6.join(destDir, entry);
3867
- const stat = await fs9.stat(srcPath);
3838
+ const srcPath = path5.join(srcDir, entry);
3839
+ const destPath = path5.join(destDir, entry);
3840
+ const stat = await fs8.stat(srcPath);
3868
3841
  if (stat.isDirectory()) {
3869
3842
  await copyDirRecursive(srcPath, destPath);
3870
3843
  } else {
3871
- await fs9.copyFile(srcPath, destPath);
3844
+ await fs8.copyFile(srcPath, destPath);
3872
3845
  }
3873
3846
  }
3874
3847
  }
3875
3848
 
3876
3849
  // src/lib/react-native-utils.ts
3877
3850
  init_esm_shims();
3878
- import * as path7 from "path";
3879
- import * as fs10 from "fs";
3851
+ import * as path6 from "path";
3852
+ import * as fs9 from "fs";
3880
3853
  import * as childProcess from "child_process";
3881
3854
  import { coerce, compare } from "semver";
3882
3855
  function findUpwardReactNativePackageJson(startDir = process.cwd()) {
3883
3856
  let current = startDir;
3884
- while (current !== path7.parse(current).root) {
3885
- const candidate = path7.join(current, "node_modules", "react-native", "package.json");
3886
- if (fs10.existsSync(candidate)) return candidate;
3887
- current = path7.dirname(current);
3857
+ while (current !== path6.parse(current).root) {
3858
+ const candidate = path6.join(current, "node_modules", "react-native", "package.json");
3859
+ if (fs9.existsSync(candidate)) return candidate;
3860
+ current = path6.dirname(current);
3888
3861
  }
3889
3862
  return null;
3890
3863
  }
3891
3864
  function getReactNativeVersion() {
3892
3865
  const rnPackageJsonPath = findUpwardReactNativePackageJson();
3893
3866
  if (!rnPackageJsonPath) return null;
3894
- const rnPackageJson = JSON.parse(fs10.readFileSync(rnPackageJsonPath, "utf-8"));
3867
+ const rnPackageJson = JSON.parse(fs9.readFileSync(rnPackageJsonPath, "utf-8"));
3895
3868
  return rnPackageJson.version;
3896
3869
  }
3897
3870
  function directoryExistsSync(dirname4) {
3898
3871
  try {
3899
- return fs10.statSync(dirname4).isDirectory();
3872
+ return fs9.statSync(dirname4).isDirectory();
3900
3873
  } catch (err) {
3901
3874
  if (err.code !== "ENOENT") throw err;
3902
3875
  }
@@ -3904,14 +3877,14 @@ function directoryExistsSync(dirname4) {
3904
3877
  }
3905
3878
  function getReactNativePackagePath() {
3906
3879
  const rnPackageJsonPath = findUpwardReactNativePackageJson();
3907
- if (rnPackageJsonPath) return path7.dirname(rnPackageJsonPath);
3880
+ if (rnPackageJsonPath) return path6.dirname(rnPackageJsonPath);
3908
3881
  const result = childProcess.spawnSync("node", [
3909
3882
  "--print",
3910
3883
  "require.resolve('react-native/package.json')"
3911
3884
  ]);
3912
- const packagePath = path7.dirname(result.stdout.toString().trim());
3885
+ const packagePath = path6.dirname(result.stdout.toString().trim());
3913
3886
  if (result.status === 0 && directoryExistsSync(packagePath)) return packagePath;
3914
- return path7.join("node_modules", "react-native");
3887
+ return path6.join("node_modules", "react-native");
3915
3888
  }
3916
3889
  function resolvePackageDirFromCwd(packageName) {
3917
3890
  const result = childProcess.spawnSync("node", [
@@ -3921,7 +3894,7 @@ function resolvePackageDirFromCwd(packageName) {
3921
3894
  if (result.status !== 0) return null;
3922
3895
  const resolved = result.stdout.toString().trim();
3923
3896
  if (!resolved) return null;
3924
- const packageDir = path7.dirname(resolved);
3897
+ const packageDir = path6.dirname(resolved);
3925
3898
  return directoryExistsSync(packageDir) ? packageDir : null;
3926
3899
  }
3927
3900
  function isValidPlatform(platform) {
@@ -3929,18 +3902,18 @@ function isValidPlatform(platform) {
3929
3902
  }
3930
3903
  function fileExists(filePath) {
3931
3904
  try {
3932
- return fs10.statSync(filePath).isFile();
3905
+ return fs9.statSync(filePath).isFile();
3933
3906
  } catch {
3934
3907
  return false;
3935
3908
  }
3936
3909
  }
3937
3910
  function getCliPath() {
3938
- return path7.join(getReactNativePackagePath(), "cli.js");
3911
+ return path6.join(getReactNativePackagePath(), "cli.js");
3939
3912
  }
3940
3913
  async function runReactNativeBundleCommand(bundleName, entryFile, outputFolder, platform, sourcemap, devMode) {
3941
- fs10.mkdirSync(path7.join(outputFolder, "bundles"), { recursive: true });
3914
+ fs9.mkdirSync(path6.join(outputFolder, "bundles"), { recursive: true });
3942
3915
  if (sourcemap) {
3943
- fs10.mkdirSync(path7.join(outputFolder, "sourcemaps"), { recursive: true });
3916
+ fs9.mkdirSync(path6.join(outputFolder, "sourcemaps"), { recursive: true });
3944
3917
  }
3945
3918
  const reactNativeBundleArgs = [
3946
3919
  getCliPath(),
@@ -3948,14 +3921,14 @@ async function runReactNativeBundleCommand(bundleName, entryFile, outputFolder,
3948
3921
  "--dev",
3949
3922
  devMode,
3950
3923
  "--assets-dest",
3951
- path7.join(outputFolder, "bundles"),
3924
+ path6.join(outputFolder, "bundles"),
3952
3925
  "--bundle-output",
3953
- path7.join(outputFolder, "bundles", bundleName),
3926
+ path6.join(outputFolder, "bundles", bundleName),
3954
3927
  "--entry-file",
3955
3928
  entryFile,
3956
3929
  "--platform",
3957
3930
  platform,
3958
- ...sourcemap ? ["--sourcemap-output", path7.join(outputFolder, "sourcemaps", bundleName + ".map")] : []
3931
+ ...sourcemap ? ["--sourcemap-output", path6.join(outputFolder, "sourcemaps", bundleName + ".map")] : []
3959
3932
  ];
3960
3933
  logger.info('Running "react-native bundle" command');
3961
3934
  const reactNativeBundleProcess = childProcess.spawn("node", reactNativeBundleArgs);
@@ -3981,27 +3954,27 @@ async function runHermesEmitBinaryCommand(bundleName, outputFolder, hermesLogs =
3981
3954
  ...sourcemap ? ["--output-source-map"] : [],
3982
3955
  "--emit-binary",
3983
3956
  "--out",
3984
- path7.join(outputFolder, bundleName + ".hbc"),
3985
- path7.join(outputFolder, "bundles", bundleName)
3957
+ path6.join(outputFolder, bundleName + ".hbc"),
3958
+ path6.join(outputFolder, "bundles", bundleName)
3986
3959
  ];
3987
3960
  logger.info("Converting JS bundle to Hermes bytecode");
3988
3961
  const hermesCommand = await getHermesCommand();
3989
3962
  const resolvedHermesPath = hermescPath || hermesCommand;
3990
3963
  if (hermescPath) {
3991
- const binaryName = path7.basename(hermescPath).replace(/\.exe$/, "");
3964
+ const binaryName = path6.basename(hermescPath).replace(/\.exe$/, "");
3992
3965
  if (!["hermesc", "hermes"].includes(binaryName)) {
3993
3966
  throw new Error(
3994
- `Invalid hermesc path: binary must be named "hermesc" or "hermes", got "${path7.basename(hermescPath)}"`
3967
+ `Invalid hermesc path: binary must be named "hermesc" or "hermes", got "${path6.basename(hermescPath)}"`
3995
3968
  );
3996
3969
  }
3997
3970
  }
3998
3971
  logger.info(`Hermesc path: ${resolvedHermesPath}`);
3999
3972
  const hermesProcess = childProcess.spawn(resolvedHermesPath, hermesArgs);
4000
3973
  let logFile = null;
4001
- const logFilePath = path7.join(outputFolder, "hermes-output.log");
3974
+ const logFilePath = path6.join(outputFolder, "hermes-output.log");
4002
3975
  let isWarned = false;
4003
3976
  if (hermesLogs) {
4004
- logFile = fs10.createWriteStream(logFilePath, { flags: "a" });
3977
+ logFile = fs9.createWriteStream(logFilePath, { flags: "a" });
4005
3978
  }
4006
3979
  return new Promise((resolve, reject) => {
4007
3980
  hermesProcess.stdout.on("data", (data) => {
@@ -4024,14 +3997,14 @@ async function runHermesEmitBinaryCommand(bundleName, outputFolder, hermesLogs =
4024
3997
  reject(new Error(`"hermes" command failed (exitCode=${exitCode}, signal=${signal}).`));
4025
3998
  return;
4026
3999
  }
4027
- const source = path7.join(outputFolder, bundleName + ".hbc");
4028
- const destination = path7.join(outputFolder, "bundles", bundleName);
4029
- fs10.copyFile(source, destination, (err) => {
4000
+ const source = path6.join(outputFolder, bundleName + ".hbc");
4001
+ const destination = path6.join(outputFolder, "bundles", bundleName);
4002
+ fs9.copyFile(source, destination, (err) => {
4030
4003
  if (err) {
4031
4004
  reject(new Error(`Copying Hermes output failed: ${err.message}`));
4032
4005
  return;
4033
4006
  }
4034
- fs10.unlink(source, (unlinkErr) => {
4007
+ fs9.unlink(source, (unlinkErr) => {
4035
4008
  if (unlinkErr) {
4036
4009
  reject(unlinkErr);
4037
4010
  return;
@@ -4062,7 +4035,7 @@ function getHermesOSExe() {
4062
4035
  return process.platform === "win32" ? hermesExecutableName + ".exe" : hermesExecutableName;
4063
4036
  }
4064
4037
  async function getHermesCommand() {
4065
- const bundledHermesEngine = path7.join(
4038
+ const bundledHermesEngine = path6.join(
4066
4039
  getReactNativePackagePath(),
4067
4040
  "sdks",
4068
4041
  "hermesc",
@@ -4072,23 +4045,23 @@ async function getHermesCommand() {
4072
4045
  if (fileExists(bundledHermesEngine)) return bundledHermesEngine;
4073
4046
  const hermesEnginePackageDir = resolvePackageDirFromCwd("hermes-engine");
4074
4047
  if (hermesEnginePackageDir) {
4075
- const hermesEngine2 = path7.join(hermesEnginePackageDir, getHermesOSBin(), getHermesOSExe());
4048
+ const hermesEngine2 = path6.join(hermesEnginePackageDir, getHermesOSBin(), getHermesOSExe());
4076
4049
  if (fileExists(hermesEngine2)) return hermesEngine2;
4077
4050
  }
4078
- const hermesEngine = path7.join("node_modules", "hermes-engine", getHermesOSBin(), getHermesOSExe());
4051
+ const hermesEngine = path6.join("node_modules", "hermes-engine", getHermesOSBin(), getHermesOSExe());
4079
4052
  if (fileExists(hermesEngine)) return hermesEngine;
4080
4053
  const hermesCompilerPackageDir = resolvePackageDirFromCwd("hermes-compiler");
4081
4054
  if (hermesCompilerPackageDir) {
4082
- const hermesCompiler2 = path7.join(hermesCompilerPackageDir, "hermesc", getHermesOSBin(), getHermesOSExe());
4055
+ const hermesCompiler2 = path6.join(hermesCompilerPackageDir, "hermesc", getHermesOSBin(), getHermesOSExe());
4083
4056
  if (fileExists(hermesCompiler2)) return hermesCompiler2;
4084
4057
  }
4085
- const hermesCompiler = path7.join("node_modules", "hermes-compiler", "hermesc", getHermesOSBin(), getHermesOSExe());
4058
+ const hermesCompiler = path6.join("node_modules", "hermes-compiler", "hermesc", getHermesOSBin(), getHermesOSExe());
4086
4059
  if (fileExists(hermesCompiler)) return hermesCompiler;
4087
4060
  const hermesVmPackageDir = resolvePackageDirFromCwd("hermesvm");
4088
4061
  if (hermesVmPackageDir) {
4089
- return path7.join(hermesVmPackageDir, getHermesOSBin(), "hermes");
4062
+ return path6.join(hermesVmPackageDir, getHermesOSBin(), "hermes");
4090
4063
  }
4091
- return path7.join("node_modules", "hermesvm", getHermesOSBin(), "hermes");
4064
+ return path6.join("node_modules", "hermesvm", getHermesOSBin(), "hermes");
4092
4065
  }
4093
4066
 
4094
4067
  // src/commands/publish-bundle.ts
@@ -4137,7 +4110,7 @@ var publishBundleCommand = new Command39("publish-bundle").description("Bundle,
4137
4110
  const uploadPath = appSlug || resolvedAppId || "";
4138
4111
  const entryFile = options.entryFile || "index.js";
4139
4112
  const bundleName = platform === "ios" ? "main.jsbundle" : "index.android.bundle";
4140
- const contentRootPath = await fs11.mkdtemp(path8.join(os3.tmpdir(), "swiftpatch-publish-"));
4113
+ const contentRootPath = await fs10.mkdtemp(path7.join(os3.tmpdir(), "swiftpatch-publish-"));
4141
4114
  try {
4142
4115
  const spinner = ora31("Bundling JavaScript...").start();
4143
4116
  try {
@@ -4179,7 +4152,7 @@ var publishBundleCommand = new Command39("publish-bundle").description("Bundle,
4179
4152
  if (options.privateKey) {
4180
4153
  const signSpinner = ora31("Signing bundle...").start();
4181
4154
  try {
4182
- const bundlesDir2 = path8.join(contentRootPath, "bundles");
4155
+ const bundlesDir2 = path7.join(contentRootPath, "bundles");
4183
4156
  await signBundleDirectory(bundlesDir2, options.privateKey);
4184
4157
  signSpinner.succeed("Bundle signed with JWT RS256");
4185
4158
  } catch (error) {
@@ -4187,26 +4160,19 @@ var publishBundleCommand = new Command39("publish-bundle").description("Bundle,
4187
4160
  process.exit(1);
4188
4161
  }
4189
4162
  }
4190
- const zipSpinner = ora31("Creating ZIP archive...").start();
4191
- const bundlesDir = path8.join(contentRootPath, "bundles");
4192
- await createZip(bundlesDir, contentRootPath);
4193
- const zipPath = path8.join(contentRootPath, "build.zip");
4194
- if (!await fs11.pathExists(zipPath)) {
4195
- zipSpinner.fail("ZIP creation failed: build.zip not found");
4196
- process.exit(1);
4197
- }
4198
- const zipSize = (await fs11.stat(zipPath)).size;
4199
- zipSpinner.succeed(`ZIP archive created: ${chalk37.gray(formatBytes4(zipSize))}`);
4200
- const hashSpinner = ora31("Computing ZIP hash...").start();
4201
- const hash = calculateZipHash(zipPath);
4163
+ const bundlesDir = path7.join(contentRootPath, "bundles");
4164
+ const rawBundlePath = path7.join(bundlesDir, bundleName);
4165
+ const hashSpinner = ora31("Computing bundle hash...").start();
4166
+ const hash = await hashBundle(rawBundlePath);
4202
4167
  if (!hash) {
4203
- hashSpinner.fail("Failed to compute ZIP hash");
4168
+ hashSpinner.fail("Failed to compute bundle hash");
4204
4169
  process.exit(1);
4205
4170
  }
4206
- hashSpinner.succeed(`ZIP hash: ${chalk37.gray(hash.slice(0, 16))}...`);
4171
+ const bundleSize = (await fs10.stat(rawBundlePath)).size;
4172
+ hashSpinner.succeed(`Bundle hash: ${chalk37.gray(hash.slice(0, 16))}... (${formatBytes4(bundleSize)})`);
4207
4173
  let bundleSignature;
4208
4174
  if (options.privateKey) {
4209
- const bundlesDir2 = path8.join(contentRootPath, "bundles");
4175
+ const bundlesDir2 = path7.join(contentRootPath, "bundles");
4210
4176
  const sig = await readBundleSignature(bundlesDir2);
4211
4177
  if (sig) bundleSignature = sig;
4212
4178
  }
@@ -4224,7 +4190,7 @@ var publishBundleCommand = new Command39("publish-bundle").description("Bundle,
4224
4190
  );
4225
4191
  urlSpinner.succeed("Upload URL received");
4226
4192
  const uploadSpinner = ora31("Uploading bundle...").start();
4227
- await uploader.uploadZip(url, zipPath, (percent) => {
4193
+ await uploader.uploadBundle(url, rawBundlePath, (percent) => {
4228
4194
  uploadSpinner.text = `Uploading bundle... ${percent}%`;
4229
4195
  });
4230
4196
  uploadSpinner.succeed("Bundle uploaded");
@@ -4253,7 +4219,7 @@ var publishBundleCommand = new Command39("publish-bundle").description("Bundle,
4253
4219
  process.exit(1);
4254
4220
  }
4255
4221
  } finally {
4256
- await fs11.remove(contentRootPath).catch(() => {
4222
+ await fs10.remove(contentRootPath).catch(() => {
4257
4223
  logger.warning(`Failed to clean up temp directory: ${contentRootPath}`);
4258
4224
  });
4259
4225
  }
@@ -4380,12 +4346,12 @@ init_esm_shims();
4380
4346
  import { Command as Command42 } from "commander";
4381
4347
  import chalk40 from "chalk";
4382
4348
  import ora34 from "ora";
4383
- import path9 from "path";
4349
+ import path8 from "path";
4384
4350
  var generateKeyPairCommand = new Command42("generate-key-pair").description("Generate RSA 2048-bit key pair for bundle signing").option("-o, --output <dir>", "Output directory for key files", ".").action(async (options) => {
4385
4351
  console.log("");
4386
4352
  logger.info(chalk40.bold("SwiftPatch Generate Key Pair"));
4387
4353
  console.log("");
4388
- const outputDir = path9.resolve(options.output || ".");
4354
+ const outputDir = path8.resolve(options.output || ".");
4389
4355
  const spinner = ora34("Generating RSA 2048-bit key pair...").start();
4390
4356
  try {
4391
4357
  const { publicKeyPath, privateKeyPath } = await generateKeyPair(outputDir);
@@ -4418,8 +4384,8 @@ import { Command as Command43 } from "commander";
4418
4384
  import chalk41 from "chalk";
4419
4385
  import inquirer21 from "inquirer";
4420
4386
  import ora35 from "ora";
4421
- import fs12 from "fs-extra";
4422
- import path10 from "path";
4387
+ import fs11 from "fs-extra";
4388
+ import path9 from "path";
4423
4389
  import os4 from "os";
4424
4390
  var deployCommand = new Command43("deploy").description("Bundle, publish, and release in one step").option("-p, --platform <platform>", "Target platform (ios or android)").option("-a, --app <app-id>", "App ID or slug").option("-o, --org <org-id>", "Organization ID").option("--app-version <version>", "Target app version (semver)").option("-n, --release-note <note>", "Release notes").option("-m, --mandatory", "Mark as mandatory update").option("--paused", "Create release in paused state").option("--hermes", "Compile to Hermes bytecode").option("--ci-token <token>", "CI token for authentication").option("-e, --entry-file <path>", "Entry file (default: index.js)").option("--dev", "Dev bundle").option("--sourcemap", "Generate sourcemaps").option("-k, --private-key <path>", "Private key path for signing").option("-y, --yes", "Skip confirmations").action(async (options) => {
4425
4391
  const ciToken = options.ciToken || process.env.SWIFTPATCH_CI_TOKEN;
@@ -4429,8 +4395,8 @@ var deployCommand = new Command43("deploy").description("Bundle, publish, and re
4429
4395
  const orgId = ciToken ? void 0 : await resolveOrgId(options.org);
4430
4396
  let platform = options.platform;
4431
4397
  if (!platform) {
4432
- const hasIos = await fs12.pathExists("./ios");
4433
- const hasAndroid = await fs12.pathExists("./android");
4398
+ const hasIos = await fs11.pathExists("./ios");
4399
+ const hasAndroid = await fs11.pathExists("./android");
4434
4400
  if (hasIos && !hasAndroid) {
4435
4401
  platform = "ios";
4436
4402
  } else if (hasAndroid && !hasIos) {
@@ -4450,7 +4416,7 @@ var deployCommand = new Command43("deploy").description("Bundle, publish, and re
4450
4416
  let appVersion = options.appVersion;
4451
4417
  if (!appVersion) {
4452
4418
  try {
4453
- const pkg = await fs12.readJson("./package.json");
4419
+ const pkg = await fs11.readJson("./package.json");
4454
4420
  appVersion = pkg.version;
4455
4421
  } catch {
4456
4422
  }
@@ -4491,18 +4457,18 @@ var deployCommand = new Command43("deploy").description("Bundle, publish, and re
4491
4457
  console.log(chalk41.bold(" Deploy"));
4492
4458
  console.log(chalk41.gray(` Platform: ${platform} \xB7 Version: ${appVersion}`));
4493
4459
  console.log("");
4494
- const tmpRoot = await fs12.mkdtemp(path10.join(os4.tmpdir(), "swiftpatch-deploy-"));
4460
+ const tmpRoot = await fs11.mkdtemp(path9.join(os4.tmpdir(), "swiftpatch-deploy-"));
4495
4461
  try {
4496
4462
  const bundleSpinner = ora35("Bundling JavaScript...").start();
4497
4463
  try {
4498
4464
  const entryFile = options.entryFile || "index.js";
4499
- const outputDir = path10.join(tmpRoot, platform);
4500
- await fs12.ensureDir(outputDir);
4501
- const bundleName = platform === "ios" ? "main.jsbundle" : "index.android.bundle";
4465
+ const outputDir2 = path9.join(tmpRoot, platform);
4466
+ await fs11.ensureDir(outputDir2);
4467
+ const bundleName2 = platform === "ios" ? "main.jsbundle" : "index.android.bundle";
4502
4468
  await runReactNativeBundleCommand(
4503
- bundleName,
4469
+ bundleName2,
4504
4470
  entryFile,
4505
- outputDir,
4471
+ outputDir2,
4506
4472
  platform,
4507
4473
  options.sourcemap || false,
4508
4474
  options.dev || false
@@ -4515,20 +4481,17 @@ var deployCommand = new Command43("deploy").description("Bundle, publish, and re
4515
4481
  bundleSpinner.fail(`Bundle failed: ${error.message}`);
4516
4482
  process.exit(1);
4517
4483
  }
4518
- const archiveSpinner = ora35("Creating archive...").start();
4519
- let zipPath;
4484
+ const hashSpinner = ora35("Computing bundle hash...").start();
4485
+ const bundleName = platform === "ios" ? "main.jsbundle" : "index.android.bundle";
4486
+ const outputDir = path9.join(tmpRoot, platform);
4487
+ const rawBundlePath = path9.join(outputDir, bundleName);
4520
4488
  let bundleHash;
4521
4489
  try {
4522
- const outputDir = path10.join(tmpRoot, platform);
4523
- const zipOutputDir = path10.join(tmpRoot, "zip");
4524
- await fs12.ensureDir(zipOutputDir);
4525
- await createZip(outputDir, zipOutputDir);
4526
- zipPath = path10.join(zipOutputDir, "build.zip");
4527
- bundleHash = calculateZipHash(zipPath);
4490
+ bundleHash = await hashBundle(rawBundlePath);
4528
4491
  if (!bundleHash) throw new Error("Failed to compute bundle hash");
4529
- archiveSpinner.succeed(`Archive created (hash: ${bundleHash.slice(0, 12)}...)`);
4492
+ hashSpinner.succeed(`Bundle hashed (${bundleHash.slice(0, 12)}...)`);
4530
4493
  } catch (error) {
4531
- archiveSpinner.fail(`Archive failed: ${error.message}`);
4494
+ hashSpinner.fail(`Hash failed: ${error.message}`);
4532
4495
  process.exit(1);
4533
4496
  }
4534
4497
  const uploadSpinner = ora35("Uploading bundle...").start();
@@ -4537,7 +4500,7 @@ var deployCommand = new Command43("deploy").description("Bundle, publish, and re
4537
4500
  { hash: bundleHash, uploadPath, platform, releaseNote },
4538
4501
  ciToken
4539
4502
  );
4540
- await uploader.uploadZip(url, zipPath, (progress) => {
4503
+ await uploader.uploadBundle(url, rawBundlePath, (progress) => {
4541
4504
  uploadSpinner.text = `Uploading bundle... ${progress}%`;
4542
4505
  });
4543
4506
  uploadSpinner.succeed("Bundle uploaded");
@@ -4580,7 +4543,7 @@ var deployCommand = new Command43("deploy").description("Bundle, publish, and re
4580
4543
  }
4581
4544
  }
4582
4545
  } finally {
4583
- await fs12.remove(tmpRoot).catch((err) => {
4546
+ await fs11.remove(tmpRoot).catch((err) => {
4584
4547
  logger.warning(`Failed to clean up temp directory: ${tmpRoot}`);
4585
4548
  });
4586
4549
  }
@@ -4680,18 +4643,18 @@ import { Command as Command45 } from "commander";
4680
4643
  import chalk43 from "chalk";
4681
4644
  import inquirer23 from "inquirer";
4682
4645
  import ora37 from "ora";
4683
- import fs13 from "fs-extra";
4684
- import path11 from "path";
4646
+ import fs12 from "fs-extra";
4647
+ import path10 from "path";
4685
4648
  var initCommand = new Command45("init").description("Initialize SwiftPatch in your React Native project").option("-y, --yes", "Accept defaults").action(async (options) => {
4686
4649
  console.log("");
4687
4650
  console.log(chalk43.bold(" SwiftPatch Setup"));
4688
4651
  console.log("");
4689
- const hasPackageJson = await fs13.pathExists("./package.json");
4652
+ const hasPackageJson = await fs12.pathExists("./package.json");
4690
4653
  if (!hasPackageJson) {
4691
4654
  logger.error("No package.json found. Run this command in your React Native project root.");
4692
4655
  process.exit(1);
4693
4656
  }
4694
- const pkg = await fs13.readJson("./package.json");
4657
+ const pkg = await fs12.readJson("./package.json");
4695
4658
  const hasRN = pkg.dependencies?.["react-native"] || pkg.devDependencies?.["react-native"];
4696
4659
  if (!hasRN) {
4697
4660
  logger.warning("react-native not found in dependencies. Is this a React Native project?");
@@ -4720,8 +4683,8 @@ var initCommand = new Command45("init").description("Initialize SwiftPatch in yo
4720
4683
  }
4721
4684
  logger.success("Authenticated");
4722
4685
  const orgId = await resolveOrgId();
4723
- const hasIos = await fs13.pathExists("./ios");
4724
- const hasAndroid = await fs13.pathExists("./android");
4686
+ const hasIos = await fs12.pathExists("./ios");
4687
+ const hasAndroid = await fs12.pathExists("./android");
4725
4688
  const platforms = [];
4726
4689
  if (hasIos) platforms.push("ios");
4727
4690
  if (hasAndroid) platforms.push("android");
@@ -4772,14 +4735,14 @@ var initCommand = new Command45("init").description("Initialize SwiftPatch in yo
4772
4735
  platform: defaultPlatform || (selectedApp.platform === "BOTH" ? void 0 : selectedApp.platform.toLowerCase()),
4773
4736
  deploymentKey: selectedApp.deploymentKey
4774
4737
  };
4775
- const rcPath = path11.resolve(".swiftpatchrc");
4776
- await fs13.writeJson(rcPath, rcConfig, { spaces: 2 });
4738
+ const rcPath = path10.resolve(".swiftpatchrc");
4739
+ await fs12.writeJson(rcPath, rcConfig, { spaces: 2 });
4777
4740
  logger.success("Created .swiftpatchrc");
4778
4741
  config.set("defaultOrg", orgId);
4779
4742
  config.set("defaultApp", selectedApp.id);
4780
4743
  if (defaultPlatform) config.set("defaultPlatform", defaultPlatform);
4781
4744
  logger.success("Saved defaults to CLI config");
4782
- const gitignorePath = path11.resolve(".gitignore");
4745
+ const gitignorePath = path10.resolve(".gitignore");
4783
4746
  const swiftpatchIgnores = [
4784
4747
  "# SwiftPatch",
4785
4748
  ".swiftpatch-tmp/",
@@ -4787,11 +4750,11 @@ var initCommand = new Command45("init").description("Initialize SwiftPatch in yo
4787
4750
  "swiftpatch-private.pem"
4788
4751
  ];
4789
4752
  try {
4790
- let gitignore = await fs13.pathExists(gitignorePath) ? await fs13.readFile(gitignorePath, "utf-8") : "";
4753
+ let gitignore = await fs12.pathExists(gitignorePath) ? await fs12.readFile(gitignorePath, "utf-8") : "";
4791
4754
  const missing = swiftpatchIgnores.filter((line) => !gitignore.includes(line));
4792
4755
  if (missing.length > 0) {
4793
4756
  const addition = (gitignore.endsWith("\n") || gitignore === "" ? "" : "\n") + missing.join("\n") + "\n";
4794
- await fs13.appendFile(gitignorePath, addition);
4757
+ await fs12.appendFile(gitignorePath, addition);
4795
4758
  logger.success("Updated .gitignore with SwiftPatch entries");
4796
4759
  }
4797
4760
  } catch {
@@ -4816,7 +4779,7 @@ async function createApp(orgId, pkg, platforms) {
4816
4779
  type: "input",
4817
4780
  name: "name",
4818
4781
  message: "App name:",
4819
- default: pkg.name || path11.basename(process.cwd())
4782
+ default: pkg.name || path10.basename(process.cwd())
4820
4783
  }
4821
4784
  ]);
4822
4785
  let platform;
@@ -4852,7 +4815,7 @@ init_auth();
4852
4815
  init_config();
4853
4816
  import { Command as Command46 } from "commander";
4854
4817
  import chalk44 from "chalk";
4855
- import fs14 from "fs-extra";
4818
+ import fs13 from "fs-extra";
4856
4819
  var doctorCommand = new Command46("doctor").description("Diagnose your SwiftPatch setup").action(async () => {
4857
4820
  console.log("");
4858
4821
  console.log(chalk44.bold(" SwiftPatch Doctor"));
@@ -4866,9 +4829,9 @@ var doctorCommand = new Command46("doctor").description("Diagnose your SwiftPatc
4866
4829
  logger.error(`Node.js ${nodeVersion} \u2014 requires >= 18.0.0`);
4867
4830
  issues++;
4868
4831
  }
4869
- const hasPackageJson = await fs14.pathExists("./package.json");
4832
+ const hasPackageJson = await fs13.pathExists("./package.json");
4870
4833
  if (hasPackageJson) {
4871
- const pkg = await fs14.readJson("./package.json");
4834
+ const pkg = await fs13.readJson("./package.json");
4872
4835
  const rnVersion = pkg.dependencies?.["react-native"] || pkg.devDependencies?.["react-native"];
4873
4836
  if (rnVersion) {
4874
4837
  logger.success(`React Native ${rnVersion}`);
@@ -4887,8 +4850,8 @@ var doctorCommand = new Command46("doctor").description("Diagnose your SwiftPatc
4887
4850
  } else {
4888
4851
  logger.warning("No package.json found (not in a project directory?)");
4889
4852
  }
4890
- const hasIos = await fs14.pathExists("./ios");
4891
- const hasAndroid = await fs14.pathExists("./android");
4853
+ const hasIos = await fs13.pathExists("./ios");
4854
+ const hasAndroid = await fs13.pathExists("./android");
4892
4855
  if (hasIos || hasAndroid) {
4893
4856
  const platforms = [hasIos && "iOS", hasAndroid && "Android"].filter(Boolean).join(", ");
4894
4857
  logger.success(`Platforms: ${platforms}`);
@@ -4932,10 +4895,10 @@ var doctorCommand = new Command46("doctor").description("Diagnose your SwiftPatc
4932
4895
  } else {
4933
4896
  logger.info("No default app set");
4934
4897
  }
4935
- const hasRc = await fs14.pathExists("./.swiftpatchrc");
4898
+ const hasRc = await fs13.pathExists("./.swiftpatchrc");
4936
4899
  if (hasRc) {
4937
4900
  try {
4938
- const rc = await fs14.readJson("./.swiftpatchrc");
4901
+ const rc = await fs13.readJson("./.swiftpatchrc");
4939
4902
  logger.success(`.swiftpatchrc found (app: ${rc.app || rc.appId || "unknown"})`);
4940
4903
  } catch {
4941
4904
  logger.warning(".swiftpatchrc exists but is invalid JSON");
@@ -4946,7 +4909,7 @@ var doctorCommand = new Command46("doctor").description("Diagnose your SwiftPatc
4946
4909
  }
4947
4910
  if (hasPackageJson) {
4948
4911
  try {
4949
- const pkg = await fs14.readJson("./package.json");
4912
+ const pkg = await fs13.readJson("./package.json");
4950
4913
  const rnVersion = pkg.dependencies?.["react-native"];
4951
4914
  if (rnVersion) {
4952
4915
  const cleanVersion = rnVersion.replace(/[\^~>=<]/g, "");
@@ -4973,7 +4936,7 @@ var doctorCommand = new Command46("doctor").description("Diagnose your SwiftPatc
4973
4936
  var __dirname3 = dirname3(fileURLToPath3(import.meta.url));
4974
4937
  var version = "1.0.0";
4975
4938
  try {
4976
- const pkg = JSON.parse(readFileSync4(join3(__dirname3, "../package.json"), "utf-8"));
4939
+ const pkg = JSON.parse(readFileSync3(join3(__dirname3, "../package.json"), "utf-8"));
4977
4940
  version = pkg.version;
4978
4941
  } catch {
4979
4942
  }
@@ -5046,13 +5009,13 @@ init_esm_shims();
5046
5009
  function checkForUpdates() {
5047
5010
  try {
5048
5011
  import("update-notifier").then(({ default: updateNotifier }) => {
5049
- import("fs-extra").then(({ default: fs15 }) => {
5012
+ import("fs-extra").then(({ default: fs14 }) => {
5050
5013
  import("url").then(({ fileURLToPath: fileURLToPath4 }) => {
5051
5014
  import("path").then(({ dirname: dirname4, join: join4 }) => {
5052
5015
  try {
5053
5016
  const __dirname4 = dirname4(fileURLToPath4(import.meta.url));
5054
5017
  const pkg = JSON.parse(
5055
- fs15.readFileSync(join4(__dirname4, "../../package.json"), "utf-8")
5018
+ fs14.readFileSync(join4(__dirname4, "../../package.json"), "utf-8")
5056
5019
  );
5057
5020
  const notifier = updateNotifier({ pkg, updateCheckInterval: 1e3 * 60 * 60 * 24 });
5058
5021
  notifier.notify();