@gfean/react-native-bundle-drop 0.8.1 → 0.10.0

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
@@ -57,6 +57,15 @@ runtime identity. Native changes still require a new App Store or Play Store bui
57
57
  | Node.js | 20.19.4 or newer |
58
58
  | React | 17 or newer |
59
59
 
60
+ The Node requirement applies to installation of the package, including projects
61
+ that use only the mobile SDK. Development and
62
+ package builds use Node 22.13.0, as specified in `.nvmrc`.
63
+
64
+ Run `bundle-drop --help` to browse commands grouped into Setup, Analysis,
65
+ Releases, and Account. Existing command names and flags remain unchanged.
66
+ For iOS metadata, `--plist-file` and Sight accept XML Info.plist files; binary
67
+ and OpenStep property lists are not supported.
68
+
60
69
  ## Installation
61
70
 
62
71
  ### Expo
@@ -115,6 +124,15 @@ canonical packaging. Each revision uses its own JavaScript engine configuration:
115
124
  Hermes is compiled with project-local tooling when enabled. JavaScript attribution
116
125
  and raw asset sizes remain separate; they are not bytecode attribution.
117
126
 
127
+ Bare iOS upload and Sight honor explicit Bundle Drop and native Hermes settings first.
128
+ For the standard React Native **0.81.x** template, they also recognize the installed
129
+ React Native helpers' implicit Hermes default when those helpers match the verified
130
+ 0.81.5 files. This conservative fallback is skipped
131
+ for custom engine configuration, community JSC indicators, or unfamiliar templates
132
+ and versions. For a custom project, set `hermesBytecode: { ios: true }` (or `false`
133
+ for JavaScript) in `bundle.drop.config.js` to match the engine in your native app.
134
+ The fallback does not evaluate Ruby or change your Podfile.
135
+
118
136
  Measurement adds compilation and archive compression after the JavaScript build, once
119
137
  per side in a comparison. Expo's Hermes path also performs a separate bytecode
120
138
  export to preserve its upload-specific minification behavior. It requires a resolvable app/runtime identity. When that
@@ -660,6 +678,23 @@ npx bundle-drop upload ios --plist-file ios/Info.plist --channel develop
660
678
  Add `--sourcemap` to produce source maps for error tracking. In CI/CD, pass a
661
679
  Personal Access Token with `--token <PAT>` instead of using an interactive login.
662
680
 
681
+ To attach multiline Markdown release notes, save them in a file and pass its path
682
+ relative to the project directory:
683
+
684
+ ```bash
685
+ npx bundle-drop upload android --channel develop --release-notes-file ./release-notes.md
686
+ ```
687
+
688
+ `--release-notes "<text>"` remains available for inline notes. Use only one notes
689
+ option per upload. Notes longer than 2,000 characters are truncated with a
690
+ warning. After a successful upload, the CLI prints the bundle identity, ZIP size,
691
+ source-map and retained-artifact status, bundling/packaging and upload timings,
692
+ and a project dashboard link for the exact production or staging API. Custom
693
+ servers show the dashboard as unavailable; the CLI has no verified dashboard
694
+ origin for them.
695
+ The summary confirms the upload; channel publishing and rollout still control
696
+ delivery.
697
+
663
698
  ## Update Policies
664
699
 
665
700
  `policy` controls what happens after Bundle Drop hydrates its local state on startup:
package/lib/CLI/cli.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env node
2
- export declare const buildProgram: () => import("commander").Command;
2
+ import { Command } from 'commander';
3
+ export declare const buildProgram: () => Command;
3
4
  export declare const runCli: (argv?: string[]) => Promise<void>;
package/lib/CLI/cli.js CHANGED
@@ -98,11 +98,14 @@ const buildProgram = () => {
98
98
  const program = new commander_1.Command();
99
99
  program
100
100
  .name('bundle-drop')
101
- .version(package_json_1.default.version || '0.0.0', '-v, --cli-version', 'Show CLI version');
101
+ .version(package_json_1.default.version || '0.0.0', '-v, --cli-version', 'Show CLI version')
102
+ // Preserve the CLI's existing handling of extra arguments in shell wrappers.
103
+ .allowExcessArguments(true)
104
+ .configureHelp({ styleTitle: title => chalk_1.default.bold.cyan(title) })
105
+ .showHelpAfterError('Run "bundle-drop <command> --help" for usage.');
102
106
  program.addHelpText('beforeAll', logo);
103
107
  program.addHelpText('before', `
104
108
  ${chalk_1.default.magentaBright('Ship OTA Updates with Confidence\n')}
105
- ${chalk_1.default.bold.cyan('Available Commands:')}
106
109
  `);
107
110
  program.addHelpText('afterAll', `
108
111
  ${chalk_1.default.bold.cyan('Common Usage:')}
@@ -114,12 +117,14 @@ ${chalk_1.default.bold.cyan('Common Usage:')}
114
117
  ${chalk_1.default.gray('bundle-drop upload android --version 1.2.3 --channel develop')}
115
118
  ${chalk_1.default.gray('bundle-drop upload ios --plist-file ios/Info.plist --channel develop')}
116
119
  ${chalk_1.default.gray('bundle-drop upload android --buildgradle-path android/app/build.gradle --channel develop --release-notes "Fixes"')}
120
+ ${chalk_1.default.gray('bundle-drop upload android --channel develop --release-notes-file ./release-notes.md')}
117
121
 
118
122
  ${chalk_1.default.gray('Docs →')} ${chalk_1.default.underline.gray(DOCS_CLI_URL)}
119
123
  ${chalk_1.default.gray('Uploading →')} ${chalk_1.default.underline.gray(DOCS_UPLOADING_URL)}
120
124
  ${chalk_1.default.gray('CI/CD →')} ${chalk_1.default.underline.gray(DOCS_CI_CD_URL)}\n`);
121
125
  program
122
126
  .command('sight')
127
+ .helpGroup('Analysis:')
123
128
  .option('--compare <ref>', 'Compare the working tree with an explicit Git baseline')
124
129
  .option('--fetch', 'Refresh the explicitly named remote branch before comparing')
125
130
  .option('--include <path>', 'Copy an ignored local input identically into both builds (repeatable)', (value, previous) => [...previous, value], [])
@@ -142,11 +147,13 @@ ${chalk_1.default.bold('Examples:')}
142
147
  .action(sight_cli_1.runSightCommand);
143
148
  program
144
149
  .command('upload <platform>')
150
+ .helpGroup('Releases:')
145
151
  .option('--plist-file <path>', 'Path to Info.plist for iOS')
146
152
  .option('--version <version>', 'App version. iOS will fallback to --plist-file; Android can fallback to build.gradle when provided.')
147
153
  .option('--buildgradle-path <path>', 'Optional Android build.gradle path to read versionName')
148
154
  .option('--channel <name>', 'Target channel name to associate the bundle')
149
155
  .option('--release-notes <text>', 'Release notes (max 2000 chars)')
156
+ .option('--release-notes-file <path>', 'Read UTF-8 release notes from a file (max 2000 chars)')
150
157
  .option('--token <token>', 'Personal Access Token (alternative to `bundle-drop login`)')
151
158
  .option('--author <name>', 'Override the author name stored with the bundle')
152
159
  .option('--sourcemap', 'Generate source maps alongside the bundle for error tracking')
@@ -158,6 +165,7 @@ ${chalk_1.default.bold('Examples:')}
158
165
  ${chalk_1.default.gray('bundle-drop upload android --version 1.2.3 --channel develop')}
159
166
  ${chalk_1.default.gray('bundle-drop upload ios --plist-file ios/Info.plist --channel develop')}
160
167
  ${chalk_1.default.gray('bundle-drop upload android --buildgradle-path android/app/build.gradle --channel beta --release-notes "Bug fixes"')}
168
+ ${chalk_1.default.gray('bundle-drop upload android --channel develop --release-notes-file ./release-notes.md')}
161
169
  ${chalk_1.default.gray('bundle-drop upload android --version 1.2.3 --channel develop --token bdp_pat_xxx')}
162
170
  ${chalk_1.default.gray('bundle-drop upload android --version 1.2.3 --channel develop --sourcemap --artifact-dir ./build/bundledrop')}
163
171
 
@@ -167,6 +175,7 @@ ${chalk_1.default.gray('CI/CD docs →')} ${chalk_1.default.underline.gray(DOCS_
167
175
  .action(upload_cli_1.default);
168
176
  program
169
177
  .command('logout')
178
+ .helpGroup('Account:')
170
179
  .description('Log out of the CLI')
171
180
  .action(() => {
172
181
  const tokenPath = getTokenPath();
@@ -180,12 +189,14 @@ ${chalk_1.default.gray('CI/CD docs →')} ${chalk_1.default.underline.gray(DOCS_
180
189
  });
181
190
  program
182
191
  .command('login')
192
+ .helpGroup('Account:')
183
193
  .description('Log in to the CLI')
184
194
  .action(() => require('../CLI/scripts/login-cli').default());
185
195
  program
186
196
  .command('init')
197
+ .helpGroup('Setup:')
187
198
  .option('--token <token>', 'Personal Access Token (alternative to `bundle-drop login`)')
188
- .option('--project-type <type>', 'Force project type: expo or bare')
199
+ .addOption(new commander_1.Option('--project-type <type>', 'Force project type: expo or bare').choices(['expo', 'bare']))
189
200
  .option('--dry-run', 'Preview setup and AI context without changing files')
190
201
  .option('--migrate-code-push', 'Explicitly remove react-native-code-push after reviewing its native migration')
191
202
  .option('--migrate-expo-updates', 'Explicitly remove active expo-updates configuration and dependency')
@@ -193,9 +204,6 @@ ${chalk_1.default.gray('CI/CD docs →')} ${chalk_1.default.underline.gray(DOCS_
193
204
  .option('--yes', 'Approve ordinary setup changes noninteractively')
194
205
  .description('Configure Bundle Drop for Expo or bare React Native')
195
206
  .action(async (options) => {
196
- if (options.projectType && !['expo', 'bare'].includes(options.projectType)) {
197
- throw new Error('--project-type must be expo or bare.');
198
- }
199
207
  if (options.token) {
200
208
  const { detectProjectType } = require('../expo');
201
209
  const projectType = detectProjectType({
@@ -308,6 +316,7 @@ ${chalk_1.default.gray('CI/CD docs →')} ${chalk_1.default.underline.gray(DOCS_
308
316
  });
309
317
  program
310
318
  .command('sync')
319
+ .helpGroup('Setup:')
311
320
  .option('--token <token>', 'Personal Access Token (alternative to `bundle-drop login`)')
312
321
  .option('--dry-run', 'Validate and preview bootstrap synchronization without writing')
313
322
  .description('Refresh the package-managed runtime delivery bootstrap')
@@ -342,8 +351,9 @@ ${chalk_1.default.gray('CI/CD docs →')} ${chalk_1.default.underline.gray(DOCS_
342
351
  });
343
352
  program
344
353
  .command('doctor')
345
- .option('--platform <platform>', 'Limit checks to ios or android')
346
- .option('--project-type <type>', 'Force project type: expo or bare')
354
+ .helpGroup('Setup:')
355
+ .addOption(new commander_1.Option('--platform <platform>', 'Limit checks to ios or android').choices(['ios', 'android']))
356
+ .addOption(new commander_1.Option('--project-type <type>', 'Force project type: expo or bare').choices(['expo', 'bare']))
347
357
  .description('Validate Bundle Drop setup, runtime identity, and OTA startup ownership')
348
358
  .addHelpText('after', `
349
359
  ${chalk_1.default.bold('Examples:')}
@@ -352,23 +362,16 @@ ${chalk_1.default.bold('Examples:')}
352
362
  ${chalk_1.default.gray('bundle-drop doctor --project-type bare --platform android')}
353
363
  `)
354
364
  .action(async (options) => {
355
- if (options.platform && !['ios', 'android'].includes(options.platform)) {
356
- throw new Error('--platform must be ios or android.');
357
- }
358
- if (options.projectType && !['expo', 'bare'].includes(options.projectType)) {
359
- throw new Error('--project-type must be expo or bare.');
360
- }
361
365
  await require('./scripts/doctor').runDoctor(options);
362
366
  });
363
367
  program
364
- .command('eas-receipt <platform>')
368
+ .command('eas-receipt')
369
+ .helpGroup('Releases:')
370
+ .addArgument(new commander_1.Argument('<platform>', 'Platform of the finished EAS build').choices(['ios', 'android']))
365
371
  .requiredOption('--build-id <id>', 'Exact finished EAS application build ID')
366
372
  .option('--output <path>', 'Receipt path; defaults under .bundle-drop')
367
373
  .description('Create an authenticated Expo build receipt from official EAS metadata')
368
374
  .action(async (platform, options) => {
369
- if (platform !== 'ios' && platform !== 'android') {
370
- throw new Error('eas-receipt platform must be ios or android.');
371
- }
372
375
  const receiptPath = await require('./scripts/expo/write-eas-build-receipt')
373
376
  .writeEasBuildReceipt({
374
377
  projectRoot: process.cwd(),
@@ -380,6 +383,7 @@ ${chalk_1.default.bold('Examples:')}
380
383
  });
381
384
  program
382
385
  .command('whoami')
386
+ .helpGroup('Account:')
383
387
  .description('Show currently logged in user')
384
388
  .action(() => {
385
389
  const authState = readStoredAuthData();
@@ -1,37 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
@@ -95,7 +62,7 @@ async function runSightCommand(options) {
95
62
  throw new Error('--project-type must be expo or bare.');
96
63
  }
97
64
  if (options.compare !== undefined) {
98
- const { runSightComparison } = await Promise.resolve().then(() => __importStar(require('./sight-compare/run')));
65
+ const { runSightComparison } = await import('./sight-compare/run.js');
99
66
  await runSightComparison(options);
100
67
  return;
101
68
  }
@@ -9,7 +9,7 @@ const child_process_1 = require("child_process");
9
9
  const fs_1 = __importDefault(require("fs"));
10
10
  const path_1 = __importDefault(require("path"));
11
11
  const module_1 = require("module");
12
- const plist_1 = __importDefault(require("plist"));
12
+ const read_xml_plist_1 = require("../utils/read-xml-plist");
13
13
  const buildIdentity_1 = require("../../expo/buildIdentity");
14
14
  const exportValidation_1 = require("../../expo/exportValidation");
15
15
  const canonicalArtifact_1 = require("../../scripts/canonicalArtifact");
@@ -51,7 +51,7 @@ function iosVersion(options, value) {
51
51
  return values.length > 0 && values.every(concreteVersion) && new Set(values).size === 1 ? values[0] : undefined;
52
52
  }
53
53
  /** Only literal, unambiguous native versions are used; no native build configuration is executed. */
54
- function bareAppVersion(options) {
54
+ async function bareAppVersion(options) {
55
55
  if (options.platform === 'android') {
56
56
  const files = ['build.gradle', 'build.gradle.kts'].map(name => path_1.default.join(options.projectRoot, 'android', 'app', name)).filter(file => fs_1.default.existsSync(file));
57
57
  if (files.length !== 1)
@@ -70,12 +70,12 @@ function bareAppVersion(options) {
70
70
  if (item.isDirectory() && !['Pods', 'build'].includes(item.name))
71
71
  candidates.push(path_1.default.join(ios, item.name, 'Info.plist'));
72
72
  }
73
- const documents = candidates.filter(file => fs_1.default.existsSync(file)).map(file => plist_1.default.parse(fs_1.default.readFileSync(insideSnapshot(options, file), 'utf8')));
74
- const applications = documents.filter(document => document.CFBundlePackageType === 'APPL');
73
+ const documents = await Promise.all(candidates.filter(file => fs_1.default.existsSync(file)).map(file => (0, read_xml_plist_1.readXmlPlist)(insideSnapshot(options, file))));
74
+ const applications = documents.filter(document => Object.prototype.hasOwnProperty.call(document, 'CFBundlePackageType') && document.CFBundlePackageType === 'APPL');
75
75
  // Test bundles and extensions have their own versions, unrelated to the app's OTA identity.
76
76
  // Older app plists may omit the package type; use those only when no explicit app exists.
77
- const appDocuments = applications.length > 0 ? applications : documents.filter(document => document.CFBundlePackageType === undefined && document.NSExtension === undefined);
78
- const versions = appDocuments.map(document => iosVersion(options, document.CFBundleShortVersionString));
77
+ const appDocuments = applications.length > 0 ? applications : documents.filter(document => !Object.prototype.hasOwnProperty.call(document, 'CFBundlePackageType') && !Object.prototype.hasOwnProperty.call(document, 'NSExtension'));
78
+ const versions = appDocuments.map(document => iosVersion(options, Object.prototype.hasOwnProperty.call(document, 'CFBundleShortVersionString') ? document.CFBundleShortVersionString : undefined));
79
79
  if (!versions.length || !versions.every(concreteVersion) || new Set(versions).size !== 1)
80
80
  return undefined;
81
81
  return versions[0];
@@ -142,12 +142,12 @@ async function measureInstalledSightOta(options) {
142
142
  return unavailable(`Bundle Drop has no runtime version configured for ${options.platform}. Set runtimeVersion.${options.platform} in bundle.drop.config.js.`);
143
143
  }
144
144
  reason = `The native ${options.platform} app version could not be resolved unambiguously for Bundle Drop OTA packaging.`;
145
- const version = bareAppVersion(options);
145
+ const version = await bareAppVersion(options);
146
146
  if (!version)
147
147
  return unavailable(reason);
148
148
  appVersion = version;
149
149
  runtimeVersion = runtime;
150
- hermes = (0, bundle_1.shouldCompileHermesBytecode)(config, options.platform, options.projectRoot);
150
+ hermes = (0, bundle_1.shouldCompileHermesBytecode)(config, options.platform, options.projectRoot, options.snapshotRoot);
151
151
  }
152
152
  const bundlePath = path_1.default.join(options.workDirectory, 'main.jsbundle');
153
153
  let assetsDirectory = options.assetsDirectory;
@@ -6,6 +6,7 @@ type UploadOptions = {
6
6
  channel?: string;
7
7
  buildGradlePath?: string;
8
8
  releaseNotes?: string;
9
+ releaseNotesFile?: string;
9
10
  token?: string;
10
11
  author?: string;
11
12
  sourcemap?: boolean;
@@ -16,6 +17,7 @@ type UploadDependencies = {
16
17
  packageRoot: string;
17
18
  spawnProcess: typeof spawnSync;
18
19
  resolveModule: ModuleResolver;
20
+ nowMs?: () => number;
19
21
  };
20
22
  export declare function runUpload(platform: string, options: UploadOptions, dependencies?: UploadDependencies): Promise<void>;
21
23
  export default function upload(platform: string, options: UploadOptions): Promise<void>;
@@ -43,8 +43,10 @@ const child_process_1 = require("child_process");
43
43
  const form_data_1 = __importDefault(require("form-data"));
44
44
  const fs = __importStar(require("fs"));
45
45
  const path = __importStar(require("path"));
46
- const plist = __importStar(require("plist"));
46
+ const perf_hooks_1 = require("perf_hooks");
47
+ const logo_1 = require("../logo");
47
48
  const ui_1 = require("../utils/ui");
49
+ const read_xml_plist_1 = require("../utils/read-xml-plist");
48
50
  const resolve_ios_version_1 = require("../../scripts/resolve-ios-version");
49
51
  const expo_1 = require("../../expo");
50
52
  const resolveModule_1 = require("../../scripts/resolveModule");
@@ -62,7 +64,37 @@ const defaultUploadDependencies = () => ({
62
64
  packageRoot: path.resolve(__dirname, '..', '..', '..'),
63
65
  spawnProcess: child_process_1.spawnSync,
64
66
  resolveModule: resolveModule_1.resolveModuleFrom,
67
+ nowMs: () => perf_hooks_1.performance.now(),
65
68
  });
69
+ const MAX_RELEASE_NOTES_LENGTH = 2000;
70
+ const STAGING_SERVER_URL = 'https://api-staging.bundledrop.app';
71
+ const dashboardProjectUrl = (serverUrl, orgSlug, projectSlug) => {
72
+ const projectPath = `/organizations/${encodeURIComponent(orgSlug)}/projects/${encodeURIComponent(projectSlug)}`;
73
+ const normalizedServerUrl = (0, serverUrl_1.normalizeServerUrl)(serverUrl);
74
+ if (normalizedServerUrl === serverUrl_1.DEFAULT_SERVER_URL) {
75
+ return `https://developer.bundledrop.app${projectPath}`;
76
+ }
77
+ if (normalizedServerUrl === STAGING_SERVER_URL) {
78
+ return `https://develop.bundle-drop-web.pages.dev${projectPath}`;
79
+ }
80
+ return null;
81
+ };
82
+ const elapsedMs = (startMs, endMs) => Math.round(endMs - startMs);
83
+ const formatSeconds = (milliseconds) => `${(milliseconds / 1000).toFixed(1)}s`;
84
+ const errorMessage = (error) => error instanceof Error ? error.message : String(error);
85
+ const warnAfterUpload = (message) => {
86
+ try {
87
+ ui_1.log.warn(message);
88
+ }
89
+ catch {
90
+ try {
91
+ process.stderr.write(`Warning: ${message}\n`);
92
+ }
93
+ catch {
94
+ // Output is unavailable, but the server upload still succeeded.
95
+ }
96
+ }
97
+ };
66
98
  const assertPathInside = (targetPath, parentPath, label) => {
67
99
  const resolvedParent = path.resolve(parentPath);
68
100
  const resolvedTarget = path.resolve(targetPath);
@@ -133,12 +165,67 @@ const bareArtifactPaths = (packageRoot, platform) => {
133
165
  zipPath: path.join(outputDir, `bundle-${platform}.zip`),
134
166
  };
135
167
  };
168
+ const cleanupUploadArtifacts = (artifact, projectRoot, packageRoot, platform, isExpoProject) => {
169
+ const generatedRoot = isExpoProject
170
+ ? path.join(projectRoot, '.bundle-drop', 'artifacts')
171
+ : path.join(packageRoot, 'dist');
172
+ assertPathInside(artifact.outputDir, generatedRoot, 'Artifact output');
173
+ const cleanupFiles = [
174
+ artifact.zipPath,
175
+ artifact.metadataPath,
176
+ artifact.manifestPath,
177
+ artifact.bundlePath,
178
+ artifact.sourceMapPath,
179
+ ];
180
+ for (const file of cleanupFiles) {
181
+ if (!file)
182
+ continue;
183
+ assertPathInside(file, artifact.outputDir, 'Artifact file');
184
+ if (fs.existsSync(file))
185
+ fs.unlinkSync(file);
186
+ }
187
+ const assetsPath = path.join(artifact.outputDir, 'assets');
188
+ assertPathInside(assetsPath, artifact.outputDir, 'Artifact assets');
189
+ if (fs.existsSync(assetsPath))
190
+ fs.rmSync(assetsPath, { recursive: true, force: true });
191
+ const expoExportDirectory = artifact.expoExportDirectory ??
192
+ path.join(packageRoot, 'dist', `expo-export-${platform}`);
193
+ assertPathInside(expoExportDirectory, generatedRoot, 'Expo export');
194
+ if (fs.existsSync(expoExportDirectory)) {
195
+ fs.rmSync(expoExportDirectory, { recursive: true, force: true });
196
+ }
197
+ };
136
198
  async function runUpload(platform, options, dependencies = defaultUploadDependencies()) {
199
+ const nowMs = dependencies.nowMs ?? (() => perf_hooks_1.performance.now());
200
+ const commandStartMs = nowMs();
137
201
  console.log(); // blank line
138
202
  ui_1.log.info('🚀 React Native OTA Upload Initialized');
139
203
  const projectRoot = process.cwd();
140
204
  const artifactDir = options.artifactDir ? path.resolve(options.artifactDir) : undefined;
141
205
  prepareArtifactDirForRun(artifactDir);
206
+ if (options.releaseNotes !== undefined && options.releaseNotesFile !== undefined) {
207
+ ui_1.log.error('❌ Use either --release-notes or --release-notes-file, not both.');
208
+ process.exit(1);
209
+ }
210
+ let releaseNotes = options.releaseNotes;
211
+ if (options.releaseNotesFile !== undefined) {
212
+ const notesPath = path.resolve(projectRoot, options.releaseNotesFile);
213
+ try {
214
+ releaseNotes = fs.readFileSync(notesPath, 'utf8');
215
+ }
216
+ catch (error) {
217
+ ui_1.log.error(`❌ Cannot read release notes file ${notesPath}: ${errorMessage(error)}`);
218
+ process.exit(1);
219
+ }
220
+ if (!releaseNotes?.trim()) {
221
+ ui_1.log.error(`❌ Release notes file is empty: ${notesPath}`);
222
+ process.exit(1);
223
+ }
224
+ }
225
+ if (releaseNotes && releaseNotes.length > MAX_RELEASE_NOTES_LENGTH) {
226
+ ui_1.log.warn(`Release notes too long (${releaseNotes.length}); truncating to ${MAX_RELEASE_NOTES_LENGTH} chars.`);
227
+ releaseNotes = releaseNotes.slice(0, MAX_RELEASE_NOTES_LENGTH);
228
+ }
142
229
  const configPath = path.resolve(projectRoot, 'bundle.drop.config.js');
143
230
  //eslint-disable-next-line
144
231
  const authPath = path.join(require('os').homedir(), '.bundle-drop', 'auth.json');
@@ -175,6 +262,7 @@ async function runUpload(platform, options, dependencies = defaultUploadDependen
175
262
  ui_1.log.error(`❌ Missing "serverUrl", "org.slug" or "project.slug" in config\nSee ${DOCS_INSTALLATION_URL}`);
176
263
  process.exit(1);
177
264
  }
265
+ const dashboardUrl = dashboardProjectUrl(serverUrl, orgSlug, projectSlug);
178
266
  // Resolve auth token: --token flag takes priority over auth.json
179
267
  let token = options.token;
180
268
  if (!token) {
@@ -218,12 +306,6 @@ async function runUpload(platform, options, dependencies = defaultUploadDependen
218
306
  let version = options.version;
219
307
  let expoBuildIdentity;
220
308
  const buildGradlePath = options.buildGradlePath || options.buildgradlePath;
221
- let releaseNotes = options.releaseNotes;
222
- const MAX_NOTES = 2000;
223
- if (releaseNotes && releaseNotes.length > MAX_NOTES) {
224
- ui_1.log.warn(`Release notes too long (${releaseNotes.length}); truncating to ${MAX_NOTES} chars.`);
225
- releaseNotes = releaseNotes.slice(0, MAX_NOTES);
226
- }
227
309
  const parseAndroidVersionFromGradle = (filePath) => {
228
310
  if (!fs.existsSync(filePath)) {
229
311
  ui_1.log.error(`❌ build.gradle not found at ${filePath}`);
@@ -265,13 +347,17 @@ async function runUpload(platform, options, dependencies = defaultUploadDependen
265
347
  process.exit(1);
266
348
  }
267
349
  try {
268
- const plistContent = fs.readFileSync(options.plistFile, 'utf-8');
269
- const parsed = plist.parse(plistContent);
270
- const rawVersion = parsed.CFBundleShortVersionString;
271
- if (!rawVersion) {
350
+ const parsed = await (0, read_xml_plist_1.readXmlPlist)(options.plistFile);
351
+ const rawVersion = Object.prototype.hasOwnProperty.call(parsed, 'CFBundleShortVersionString')
352
+ ? parsed.CFBundleShortVersionString
353
+ : undefined;
354
+ if (rawVersion === undefined) {
272
355
  ui_1.log.error('❌ Could not find CFBundleShortVersionString in plist');
273
356
  process.exit(1);
274
357
  }
358
+ if (typeof rawVersion !== 'string' || !rawVersion.trim()) {
359
+ throw new Error('CFBundleShortVersionString must be a non-empty string.');
360
+ }
275
361
  const resolved = (0, resolve_ios_version_1.resolveIosPlistVersion)(rawVersion, projectRoot);
276
362
  if (!resolved) {
277
363
  process.exit(1);
@@ -308,7 +394,9 @@ async function runUpload(platform, options, dependencies = defaultUploadDependen
308
394
  }
309
395
  ui_1.log.label('App Version', version);
310
396
  console.log();
397
+ console.log((0, logo_1.buildBundleDropLogo)());
311
398
  ui_1.log.arrow(`Bundling ${platform} app...`);
399
+ const bundlingStartMs = nowMs();
312
400
  const packageRoot = dependencies.packageRoot;
313
401
  const packageVersion = readPackageVersion(packageRoot);
314
402
  const compiledBundleScript = path.join(packageRoot, 'lib', 'scripts', 'bundle.js');
@@ -372,6 +460,8 @@ async function runUpload(platform, options, dependencies = defaultUploadDependen
372
460
  ui_1.log.error(`❌ Bundle ZIP not found at: ${artifact.zipPath}`);
373
461
  process.exit(1);
374
462
  }
463
+ const zipSizeBytes = fs.statSync(artifact.zipPath).size;
464
+ const bundlingAndPackagingMs = elapsedMs(bundlingStartMs, nowMs());
375
465
  // Build form data
376
466
  const form = new form_data_1.default();
377
467
  form.append('orgSlug', orgSlug);
@@ -391,7 +481,9 @@ async function runUpload(platform, options, dependencies = defaultUploadDependen
391
481
  }
392
482
  form.append('file', fs.createReadStream(artifact.zipPath));
393
483
  const uploadLoader = (0, ui_1.startLoadingStatus)('Uploading bundle to server');
394
- let uploadSucceeded = false;
484
+ const uploadStartMs = nowMs();
485
+ let uploadMs = 0;
486
+ let responseData = {};
395
487
  try {
396
488
  const res = await axios_1.default.post(`${serverUrl}/bundle/upload`, form, {
397
489
  headers: {
@@ -401,120 +493,129 @@ async function runUpload(platform, options, dependencies = defaultUploadDependen
401
493
  maxContentLength: Infinity,
402
494
  maxBodyLength: Infinity,
403
495
  });
404
- const hasSourceMap = options.sourcemap && artifact.sourceMapPath &&
405
- fs.existsSync(artifact.sourceMapPath);
406
- const result = {
407
- platform,
408
- appVersion: version,
409
- channel,
410
- orgSlug,
411
- projectSlug,
412
- runtimeVersion: res.data?.runtimeVersion ?? runtimeVersion ?? null,
413
- packageVersion: res.data?.packageVersion ?? packageVersion ?? null,
414
- bundleId: res.data?.bundleId ?? null,
415
- bundleVersion: res.data?.bundleVersion ?? null,
416
- bundleVersionLabel: res.data?.bundleVersionLabel ?? null,
417
- hash: res.data?.hash ?? null,
418
- releaseNotes: releaseNotes ?? null,
419
- author: options.author ?? null,
420
- };
421
- if (artifactDir) {
422
- try {
423
- fs.mkdirSync(artifactDir, { recursive: true });
424
- if (fs.existsSync(artifact.bundlePath)) {
425
- fs.copyFileSync(artifact.bundlePath, path.join(artifactDir, 'main.jsbundle'));
426
- result.bundlePath = path.join(artifactDir, 'main.jsbundle');
427
- }
428
- if (hasSourceMap && artifact.sourceMapPath) {
429
- fs.copyFileSync(artifact.sourceMapPath, path.join(artifactDir, 'main.jsbundle.map'));
430
- result.sourceMapPath = path.join(artifactDir, 'main.jsbundle.map');
431
- }
432
- }
433
- catch (copyErr) {
434
- ui_1.log.warn(`Upload succeeded but artifact copy failed: ${copyErr.message}`);
435
- }
436
- }
437
- uploadLoader.stop();
438
- ui_1.log.success(`✅ Upload complete`);
439
- if (result.bundleVersion != null)
440
- ui_1.log.label('Bundle Version', `${result.bundleVersion}`);
441
- if (result.bundleVersionLabel)
442
- ui_1.log.label('Bundle Label', `${result.bundleVersionLabel}`);
443
- if (result.hash)
444
- ui_1.log.label('Hash', `${result.hash}`);
445
- const resultDir = artifactDir ?? artifact.outputDir;
446
- if (!fs.existsSync(resultDir))
447
- fs.mkdirSync(resultDir, { recursive: true });
448
- const resultPath = path.join(resultDir, 'bundle-drop-result.json');
449
- fs.writeFileSync(resultPath, JSON.stringify(result, null, 2));
450
- ui_1.log.label('Result file', resultPath);
451
- if (artifactDir) {
452
- ui_1.log.label('Artifact dir', artifactDir);
453
- }
454
- uploadSucceeded = true;
496
+ uploadMs = elapsedMs(uploadStartMs, nowMs());
497
+ responseData = res.data ?? {};
455
498
  }
456
499
  catch (err) {
457
- uploadLoader.stop();
458
500
  const uploadError = stringifyUploadError(err);
459
- writeArtifactResult(artifactDir, {
460
- success: false,
461
- status: 'failed',
462
- error: uploadError,
463
- platform,
464
- appVersion: version,
465
- channel,
466
- orgSlug,
467
- projectSlug,
468
- runtimeVersion,
469
- packageVersion: packageVersion ?? null,
470
- releaseNotes: releaseNotes ?? null,
471
- author: options.author ?? null,
472
- });
501
+ try {
502
+ writeArtifactResult(artifactDir, {
503
+ success: false,
504
+ status: 'failed',
505
+ error: uploadError,
506
+ platform,
507
+ appVersion: version,
508
+ channel,
509
+ orgSlug,
510
+ projectSlug,
511
+ runtimeVersion,
512
+ packageVersion: packageVersion ?? null,
513
+ releaseNotes: releaseNotes ?? null,
514
+ author: options.author ?? null,
515
+ });
516
+ }
517
+ catch (writeError) {
518
+ ui_1.log.warn(`Could not write failed upload result: ${errorMessage(writeError)}`);
519
+ }
473
520
  ui_1.log.error(`Upload failed: ${uploadError}`);
474
521
  process.exitCode = 1;
522
+ try {
523
+ cleanupUploadArtifacts(artifact, projectRoot, packageRoot, platform, isExpoProject);
524
+ }
525
+ catch (cleanupError) {
526
+ ui_1.log.warn(`Cleanup failed: ${errorMessage(cleanupError)}`);
527
+ }
475
528
  return;
476
529
  }
477
530
  finally {
478
531
  try {
479
- const generatedRoot = isExpoProject
480
- ? path.join(projectRoot, '.bundle-drop', 'artifacts')
481
- : path.join(packageRoot, 'dist');
482
- assertPathInside(artifact.outputDir, generatedRoot, 'Artifact output');
483
- const cleanupFiles = [
484
- artifact.zipPath,
485
- artifact.metadataPath,
486
- artifact.manifestPath,
487
- artifact.bundlePath,
488
- artifact.sourceMapPath,
489
- ];
490
- const assetsPath = path.join(artifact.outputDir, 'assets');
491
- const expoExportDirectory = artifact.expoExportDirectory ??
492
- path.join(packageRoot, 'dist', `expo-export-${platform}`);
493
- for (const file of cleanupFiles) {
494
- if (file) {
495
- assertPathInside(file, artifact.outputDir, 'Artifact file');
496
- if (fs.existsSync(file))
497
- fs.unlinkSync(file);
498
- }
499
- }
500
- assertPathInside(assetsPath, artifact.outputDir, 'Artifact assets');
501
- if (fs.existsSync(assetsPath)) {
502
- fs.rmSync(assetsPath, { recursive: true, force: true });
503
- }
504
- assertPathInside(expoExportDirectory, generatedRoot, 'Expo export');
505
- if (fs.existsSync(expoExportDirectory)) {
506
- fs.rmSync(expoExportDirectory, { recursive: true, force: true });
532
+ uploadLoader.stop();
533
+ }
534
+ catch (loaderError) {
535
+ warnAfterUpload(`Could not stop upload status: ${errorMessage(loaderError)}`);
536
+ }
537
+ }
538
+ const hasSourceMap = Boolean(options.sourcemap && artifact.sourceMapPath &&
539
+ fs.existsSync(artifact.sourceMapPath));
540
+ const result = {
541
+ platform,
542
+ appVersion: version,
543
+ channel,
544
+ orgSlug,
545
+ projectSlug,
546
+ runtimeVersion: responseData.runtimeVersion ?? runtimeVersion ?? null,
547
+ packageVersion: responseData.packageVersion ?? packageVersion ?? null,
548
+ bundleId: responseData.bundleId ?? null,
549
+ bundleVersion: responseData.bundleVersion ?? null,
550
+ bundleVersionLabel: responseData.bundleVersionLabel ?? null,
551
+ hash: responseData.hash ?? null,
552
+ releaseNotes: releaseNotes ?? null,
553
+ author: options.author ?? null,
554
+ zipSizeBytes,
555
+ bundlingAndPackagingMs,
556
+ uploadMs,
557
+ dashboardUrl,
558
+ };
559
+ if (artifactDir) {
560
+ try {
561
+ fs.mkdirSync(artifactDir, { recursive: true });
562
+ if (fs.existsSync(artifact.bundlePath)) {
563
+ fs.copyFileSync(artifact.bundlePath, path.join(artifactDir, 'main.jsbundle'));
564
+ result.bundlePath = path.join(artifactDir, 'main.jsbundle');
507
565
  }
508
- if (uploadSucceeded) {
509
- console.log();
510
- ui_1.log.success('🎉 Done! Bundle uploaded and cleaned.');
511
- console.log();
566
+ if (hasSourceMap && artifact.sourceMapPath) {
567
+ fs.copyFileSync(artifact.sourceMapPath, path.join(artifactDir, 'main.jsbundle.map'));
568
+ result.sourceMapPath = path.join(artifactDir, 'main.jsbundle.map');
512
569
  }
513
570
  }
514
- catch (cleanupErr) {
515
- ui_1.log.warn(`Cleanup failed: ${cleanupErr.message}`);
571
+ catch (copyError) {
572
+ warnAfterUpload(`Upload succeeded but artifact copy failed: ${errorMessage(copyError)}`);
516
573
  }
517
574
  }
575
+ try {
576
+ cleanupUploadArtifacts(artifact, projectRoot, packageRoot, platform, isExpoProject);
577
+ }
578
+ catch (cleanupError) {
579
+ warnAfterUpload(`Cleanup failed: ${errorMessage(cleanupError)}`);
580
+ }
581
+ const totalMs = elapsedMs(commandStartMs, nowMs());
582
+ result.totalMs = totalMs;
583
+ const resultDir = artifactDir ?? artifact.outputDir;
584
+ const resultPath = path.join(resultDir, 'bundle-drop-result.json');
585
+ let resultWritten = false;
586
+ try {
587
+ if (!fs.existsSync(resultDir))
588
+ fs.mkdirSync(resultDir, { recursive: true });
589
+ fs.writeFileSync(resultPath, JSON.stringify(result, null, 2));
590
+ resultWritten = true;
591
+ }
592
+ catch (writeError) {
593
+ warnAfterUpload(`Upload succeeded but local result writing failed: ${errorMessage(writeError)}`);
594
+ }
595
+ try {
596
+ const summary = [
597
+ ` Organization / project: ${orgSlug} / ${projectSlug}`,
598
+ ` Channel / platform: ${channel} / ${platform}`,
599
+ ` App / runtime: ${version} / ${result.runtimeVersion}`,
600
+ ...(result.bundleVersion != null ? [` Bundle version: ${result.bundleVersion}`] : []),
601
+ ...(result.bundleVersionLabel ? [` Bundle label: ${result.bundleVersionLabel}`] : []),
602
+ ...(result.hash ? [` Hash: ${result.hash}`] : []),
603
+ ` Uploaded ZIP: ${zipSizeBytes} bytes`,
604
+ ` Source map: ${!options.sourcemap ? 'not requested' : !hasSourceMap ? 'not generated' :
605
+ result.sourceMapPath ? `generated; retained at ${result.sourceMapPath}` : 'generated; not retained'}`,
606
+ ...(result.bundlePath ? [` Retained bundle: ${result.bundlePath}`] : []),
607
+ ` Timings: bundle/package ${formatSeconds(bundlingAndPackagingMs)} · upload ${formatSeconds(uploadMs)} · total ${formatSeconds(totalMs)}`,
608
+ ...(resultWritten ? [` Result file: ${resultPath}`] : []),
609
+ ` Dashboard: ${dashboardUrl ?? 'unavailable for this server'}`,
610
+ ];
611
+ console.log();
612
+ ui_1.log.success('Upload complete.');
613
+ console.log(summary.join('\n'));
614
+ console.log();
615
+ }
616
+ catch (summaryError) {
617
+ warnAfterUpload(`Upload succeeded but summary rendering failed: ${errorMessage(summaryError)}`);
618
+ }
518
619
  }
519
620
  function upload(platform, options) {
520
621
  return runUpload(platform, options);
@@ -0,0 +1,2 @@
1
+ /** Read native XML metadata without enabling Plist's binary/OpenStep autodetection. */
2
+ export declare function readXmlPlist(file: string): Promise<Record<string, unknown>>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.readXmlPlist = readXmlPlist;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ /** Read native XML metadata without enabling Plist's binary/OpenStep autodetection. */
9
+ async function readXmlPlist(file) {
10
+ const xml = node_fs_1.default.readFileSync(file, 'utf8').replace(/^\uFEFF/, '');
11
+ if (!xml.trimStart().startsWith('<')) {
12
+ throw new Error('Info.plist must be an XML property list.');
13
+ }
14
+ const { parse } = await import('plist');
15
+ const document = parse(xml);
16
+ if (document === null ||
17
+ typeof document !== 'object' ||
18
+ Object.getPrototypeOf(document) !== Object.prototype) {
19
+ throw new Error('Info.plist must contain a dictionary.');
20
+ }
21
+ return document;
22
+ }
@@ -1,37 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.getAvailableChannels = getAvailableChannels;
37
4
  exports.checkForUpdate = checkForUpdate;
@@ -114,7 +81,9 @@ async function readResolveContext(channelName) {
114
81
  (0, installId_1.getOrCreateInstallId)(),
115
82
  (0, rollbackState_1.getFailedBundleHashes)(),
116
83
  ]);
117
- const supportsXdelta = await Promise.resolve().then(() => __importStar(require('../native/fs'))).then(module => module.default.supportsXdelta())
84
+ const supportsXdelta = await Promise.resolve()
85
+ .then(() => require('../native/fs'))
86
+ .then(module => module.default.supportsXdelta())
118
87
  .catch(() => false);
119
88
  return {
120
89
  channelName,
@@ -14,7 +14,7 @@ type BundleScriptOptions = {
14
14
  };
15
15
  export declare const buildHermesFlags: (hermescPath: string, generateSourceMap: boolean, spawnProcess: SpawnProcess) => string[];
16
16
  export declare const detectHermesFromNativeProject: (projectRoot: string, platform: string) => boolean | undefined;
17
- export declare const shouldCompileHermesBytecode: (cfg: Record<string, unknown>, platform: string, projectRoot: string) => boolean;
17
+ export declare const shouldCompileHermesBytecode: (cfg: Record<string, unknown>, platform: string, projectRoot: string, snapshotRoot?: string) => boolean;
18
18
  export declare function runBundleScript(options?: BundleScriptOptions): {
19
19
  outputDir: string;
20
20
  bundlePath: string;
@@ -44,6 +44,7 @@ const canonicalArtifact_1 = require("./canonicalArtifact");
44
44
  const projectRoot_1 = require("./projectRoot");
45
45
  Object.defineProperty(exports, "findProjectRoot", { enumerable: true, get: function () { return projectRoot_1.findProjectRoot; } });
46
46
  const resolveModule_1 = require("./resolveModule");
47
+ const iosHermesDefault_1 = require("./iosHermesDefault");
47
48
  const SENTRY_HERMES_OTA_DOCS_URL = 'https://bundledrop.app/docs/observability#sentry-and-hermes-ota-builds';
48
49
  const SENTRY_DEBUG_ID_MARKERS = ['//# debugId=', 'sentry-dbid-'];
49
50
  const runProcess = (spawnProcess, executable, args, options) => {
@@ -182,7 +183,7 @@ const detectHermesFromNativeProject = (projectRoot, platform) => {
182
183
  ]);
183
184
  };
184
185
  exports.detectHermesFromNativeProject = detectHermesFromNativeProject;
185
- const shouldCompileHermesBytecode = (cfg, platform, projectRoot) => {
186
+ const shouldCompileHermesBytecode = (cfg, platform, projectRoot, snapshotRoot) => {
186
187
  const explicit = readPlatformSetting(cfg.hermesBytecode, platform) ??
187
188
  readPlatformSetting(cfg.hermes, platform);
188
189
  if (typeof explicit === 'boolean')
@@ -190,6 +191,8 @@ const shouldCompileHermesBytecode = (cfg, platform, projectRoot) => {
190
191
  const detected = (0, exports.detectHermesFromNativeProject)(projectRoot, platform);
191
192
  if (detected !== undefined)
192
193
  return detected;
194
+ if (platform === 'ios' && (0, iosHermesDefault_1.detectImplicitIosHermes)(projectRoot, snapshotRoot))
195
+ return true;
193
196
  if (explicit === 'auto') {
194
197
  console.warn(`⚠️ Could not detect Hermes for ${platform}; set hermesBytecode.${platform} in bundle.drop.config.js to opt in explicitly.`);
195
198
  }
@@ -0,0 +1,2 @@
1
+ /** Only infer the installed 0.81.x template's default after explicit detection. */
2
+ export declare function detectImplicitIosHermes(projectRoot: string, snapshotRoot?: string): true | undefined;
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.detectImplicitIosHermes = detectImplicitIosHermes;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const crypto_1 = require("crypto");
10
+ // This recognizes a known template, not arbitrary Ruby configuration. Unknown
11
+ // layouts must keep using the existing detector or an explicit SDK setting.
12
+ const engineMention = /hermes|jsc|javascriptcore|js[_-]?engine/i;
13
+ function withoutUnusedTemplateFramework(text) {
14
+ // The stock Xcode template lists JavaScriptCore in its navigator but does not
15
+ // link it. Ignore that exact unused reference, not linked JSC or engine flags.
16
+ const reference = text.match(/^\s*([A-F0-9]{24}) \/\* JavaScriptCore\.framework \*\/ = \{isa = PBXFileReference; lastKnownFileType = wrapper\.framework; name = JavaScriptCore\.framework; path = System\/Library\/Frameworks\/JavaScriptCore\.framework; sourceTree = SDKROOT; \};$/m);
17
+ if (!reference || text.split(reference[1]).length !== 3)
18
+ return text;
19
+ return text.replace(reference[0], '').replace(new RegExp(`^\\s*${reference[1]} /\\* JavaScriptCore\\.framework \\*/,\\s*$`, 'm'), '');
20
+ }
21
+ // RN 0.81.5's shipped helpers. Deliberately decline other implementations rather
22
+ // than interpret Ruby or assume that a package version proves engine semantics.
23
+ const helperHashes = {
24
+ 'scripts/react_native_pods.rb': 'bd090959a5ff31edcd1c391a44a4e5f342969a33e11f9d4ecd457bda2a2eef73',
25
+ 'scripts/cocoapods/jsengine.rb': '4bc4b49e4ab5adf1fc2000e276822cb31af7819a5d9ce1a635563cb7cc527106',
26
+ };
27
+ const compactRuby = (text) => text
28
+ .replace(/^\s*#.*$/gm, '')
29
+ .replace(/\s+/g, ' ')
30
+ .replace(/"/g, "'")
31
+ .trim();
32
+ const standardLoader = compactRuby(`require Pod::Executable.execute_command('node', ['-p',
33
+ 'require.resolve(
34
+ "react-native/scripts/react_native_pods.rb",
35
+ {paths: [process.argv[1]]},
36
+ )', __dir__]).strip`);
37
+ const standardArguments = compactRuby(`
38
+ :path => config[:reactNativePath],
39
+ :app_path => "#{Pod::Config.instance.installation_root}/.."
40
+ `);
41
+ /** Only infer the installed 0.81.x template's default after explicit detection. */
42
+ function detectImplicitIosHermes(projectRoot, snapshotRoot) {
43
+ if (process.env.USE_HERMES !== undefined || process.env.USE_THIRD_PARTY_JSC !== undefined)
44
+ return undefined;
45
+ try {
46
+ const boundary = snapshotRoot ? fs_1.default.realpathSync(snapshotRoot) : undefined;
47
+ function checked(file) {
48
+ const resolved = fs_1.default.realpathSync(file);
49
+ if (boundary) {
50
+ const relative = path_1.default.relative(boundary, resolved);
51
+ if (relative === '..' || relative.startsWith(`..${path_1.default.sep}`) || path_1.default.isAbsolute(relative)) {
52
+ throw new Error('Hermes configuration resolved outside the comparison snapshot.');
53
+ }
54
+ }
55
+ return resolved;
56
+ }
57
+ function read(file) {
58
+ return fs_1.default.readFileSync(checked(file), 'utf8');
59
+ }
60
+ const app = JSON.parse(read(path_1.default.join(projectRoot, 'package.json')));
61
+ const dependencies = { ...app.dependencies, ...app.devDependencies, ...app.optionalDependencies, ...app.peerDependencies };
62
+ if (!dependencies['react-native'] || Object.keys(dependencies).some(name => /jsc|javascriptcore/i.test(name)))
63
+ return undefined;
64
+ if (['js', 'cjs', 'mjs', 'ts'].some(extension => fs_1.default.existsSync(path_1.default.join(projectRoot, `react-native.config.${extension}`))))
65
+ return undefined;
66
+ const ios = path_1.default.join(projectRoot, 'ios');
67
+ if (fs_1.default.existsSync(path_1.default.join(ios, 'node_modules/react-native')))
68
+ return undefined;
69
+ const podfile = read(path_1.default.join(ios, 'Podfile'));
70
+ const nativeFiles = ['.xcode.env', '.xcode.env.local', 'Podfile.properties.json']
71
+ .map(name => path_1.default.join(ios, name));
72
+ for (const name of fs_1.default.readdirSync(checked(ios))) {
73
+ if (name.endsWith('.xcodeproj'))
74
+ nativeFiles.push(path_1.default.join(ios, name, 'project.pbxproj'));
75
+ if (name.endsWith('.xcconfig'))
76
+ nativeFiles.push(path_1.default.join(ios, name));
77
+ }
78
+ const nativeContents = nativeFiles.filter(file => fs_1.default.existsSync(file)).map(file => {
79
+ const contents = read(file);
80
+ return file.endsWith('project.pbxproj') ? withoutUnusedTemplateFramework(contents) : contents;
81
+ });
82
+ if ([podfile, ...nativeContents].some(text => engineMention.test(text)))
83
+ return undefined;
84
+ // The stock template already references CocoaPods' generated debug/release
85
+ // configs before pods are installed. Other referenced configs are custom.
86
+ for (const text of nativeContents) {
87
+ for (const line of text.split('\n').filter(line => line.includes('baseConfigurationReference'))) {
88
+ if (!/\/\* Pods-[\w-]+\.(?:debug|release)\.xcconfig \*\//.test(line))
89
+ return undefined;
90
+ }
91
+ }
92
+ const ruby = compactRuby(podfile);
93
+ const calls = [...ruby.matchAll(/\buse_react_native!\s*\(([^()]*)\)/g)];
94
+ if (!ruby.includes(standardLoader) || calls.length !== 1 ||
95
+ [...ruby.matchAll(/\buse_react_native!/g)].length !== 1 ||
96
+ compactRuby(calls[0][1]) !== standardArguments ||
97
+ !/\bconfig = use_native_modules! use_react_native!/.test(ruby) ||
98
+ [...ruby.matchAll(/\bconfig\s*=/g)].length !== 1 ||
99
+ /\bconfig\s*(?:\[[^\]]*\]\s*=|\.)/.test(ruby) ||
100
+ /\b(?:def|eval|load|require_relative)\b/.test(ruby) ||
101
+ [...ruby.matchAll(/\brequire\b(?!\.)/g)].length !== 1)
102
+ return undefined;
103
+ // Search only the consumer's node_modules ancestry: never NODE_PATH or the
104
+ // CLI's own React Native dependency. Hoisted and symlinked installs work too.
105
+ let directory = path_1.default.resolve(projectRoot);
106
+ let manifest;
107
+ while (true) {
108
+ const candidate = path_1.default.join(directory, 'node_modules/react-native/package.json');
109
+ if (fs_1.default.existsSync(candidate)) {
110
+ manifest = checked(candidate);
111
+ break;
112
+ }
113
+ const parent = path_1.default.dirname(directory);
114
+ if (parent === directory || (boundary && fs_1.default.realpathSync(directory) === boundary))
115
+ break;
116
+ directory = parent;
117
+ }
118
+ if (!manifest)
119
+ return undefined;
120
+ const rn = JSON.parse(read(manifest));
121
+ if (rn.name !== 'react-native' || typeof rn.version !== 'string' || !/^0\.81\.\d+$/.test(rn.version))
122
+ return undefined;
123
+ const root = path_1.default.dirname(manifest);
124
+ for (const [file, expectedHash] of Object.entries(helperHashes)) {
125
+ const source = read(path_1.default.join(root, file)).replace(/\r\n/g, '\n');
126
+ if ((0, crypto_1.createHash)('sha256').update(source).digest('hex') !== expectedHash)
127
+ return undefined;
128
+ }
129
+ return true;
130
+ }
131
+ catch {
132
+ // Missing, unreadable, or unfamiliar inputs provide no evidence of a default.
133
+ return undefined;
134
+ }
135
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gfean/react-native-bundle-drop",
3
- "version": "0.8.1",
3
+ "version": "0.10.0",
4
4
  "nativeVersion": "0.6.0",
5
5
  "description": "Over-the-air updates for Expo and bare React Native apps, with channels, staged rollouts, patch delivery, and rollback.",
6
6
  "main": "lib/index.js",
@@ -38,6 +38,8 @@
38
38
  "clean": "rimraf lib dist",
39
39
  "build": "npm run clean && tsc -p tsconfig.build.json && node scripts/make-cli-executable.js",
40
40
  "test": "jest --runInBand",
41
+ "typecheck": "tsc --noEmit -p tsconfig.json",
42
+ "test:cli:compat": "node scripts/check-cli-compatibility.cjs",
41
43
  "test:coverage": "jest --runInBand --coverage",
42
44
  "coverage:check": "node scripts/check-coverage-thresholds.cjs",
43
45
  "coverage:gate": "yarn test:coverage && yarn coverage:check",
@@ -50,7 +52,7 @@
50
52
  "codeql:local:fast": "node scripts/run-codeql-local.cjs fast",
51
53
  "codeql:local:full": "node scripts/run-codeql-local.cjs full",
52
54
  "codeql:local:compare": "node scripts/run-codeql-local.cjs compare",
53
- "verify:quick": "yarn build && yarn coverage:gate && yarn test:expo:plugin && yarn package:check",
55
+ "verify:quick": "yarn typecheck && yarn build && yarn coverage:gate && yarn test:expo:plugin && yarn package:check",
54
56
  "verify:native": "yarn test:android && yarn test:ios",
55
57
  "verify:release": "yarn verify:quick && yarn verify:native && yarn audit:production",
56
58
  "prepack": "npm run build",
@@ -59,7 +61,7 @@
59
61
  "devDependencies": {
60
62
  "@types/adm-zip": "^0.5.8",
61
63
  "@types/jest": "^29.5.14",
62
- "@types/node": "^24.13.4",
64
+ "@types/node": "^24.19.1",
63
65
  "@types/react": "^18.2.66",
64
66
  "@types/react-native": "^0.73.0",
65
67
  "expo-autolinking-sdk55": "npm:expo-modules-autolinking@55.0.8",
@@ -71,7 +73,7 @@
71
73
  "react-test-renderer": "^18.3.1",
72
74
  "rimraf": "^6.1.3",
73
75
  "rn-cli-platform-android-078": "npm:@react-native-community/cli-platform-android@15.0.1",
74
- "ts-jest": "^29.4.12",
76
+ "ts-jest": "^29.4.14",
75
77
  "ts-node": "^10.9.2",
76
78
  "typescript": "^5.9.3"
77
79
  },
@@ -172,12 +174,12 @@
172
174
  "adm-zip": "0.6.1",
173
175
  "axios": "1.20.0",
174
176
  "chalk": "4.1.2",
175
- "commander": "7.2.0",
177
+ "commander": "14.0.3",
176
178
  "diff": "9.0.0",
177
179
  "figures": "3.2.0",
178
180
  "form-data": "4.0.6",
179
- "fs-extra": "11.4.0",
180
- "plist": "3.1.1",
181
+ "fs-extra": "11.4.1",
182
+ "plist": "5.0.0",
181
183
  "prompts": "2.4.2"
182
184
  },
183
185
  "publishConfig": {