@gfean/react-native-bundle-drop 0.3.5 โ†’ 0.3.7

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.
Files changed (63) hide show
  1. package/android/build.gradle +2 -0
  2. package/android/src/main/java/com/bundledrop/BundleDropModule.kt +12 -48
  3. package/android/src/main/java/com/bundledrop/BundleDropNativePaths.kt +64 -0
  4. package/android/src/main/java/com/bundledrop/BundleDropOtaPrefs.kt +41 -0
  5. package/ios/BundleDropBridge.m +4 -0
  6. package/ios/BundleDropLocator.h +11 -0
  7. package/ios/BundleDropLocator.swift +11 -1
  8. package/ios/BundleDropModule.swift +10 -0
  9. package/lib/CLI/cli.js +56 -6
  10. package/lib/CLI/scripts/aipowered/apply-plan.d.ts +10 -0
  11. package/lib/CLI/scripts/aipowered/apply-plan.js +50 -0
  12. package/lib/CLI/scripts/aipowered/backend-client.d.ts +6 -0
  13. package/lib/CLI/scripts/aipowered/backend-client.js +34 -0
  14. package/lib/CLI/scripts/aipowered/diff-preview.d.ts +7 -0
  15. package/lib/CLI/scripts/aipowered/diff-preview.js +33 -0
  16. package/lib/CLI/scripts/aipowered/init-native-config.d.ts +2 -0
  17. package/lib/CLI/scripts/aipowered/init-native-config.js +131 -0
  18. package/lib/CLI/scripts/aipowered/scanner.d.ts +5 -0
  19. package/lib/CLI/scripts/aipowered/scanner.js +349 -0
  20. package/lib/CLI/scripts/aipowered/types.d.ts +53 -0
  21. package/lib/CLI/scripts/aipowered/types.js +2 -0
  22. package/lib/CLI/scripts/aipowered/validate-plan.d.ts +8 -0
  23. package/lib/CLI/scripts/aipowered/validate-plan.js +164 -0
  24. package/lib/CLI/scripts/init-config.js +10 -5
  25. package/lib/CLI/scripts/init-native-config.js +1 -1
  26. package/lib/CLI/scripts/post-init.js +7 -18
  27. package/lib/CLI/scripts/upload-cli.d.ts +2 -0
  28. package/lib/CLI/scripts/upload-cli.js +53 -25
  29. package/lib/CLI/utils/ui.d.ts +3 -0
  30. package/lib/CLI/utils/ui.js +26 -0
  31. package/lib/api/clientApi.d.ts +2 -1
  32. package/lib/api/clientApi.js +9 -0
  33. package/lib/api/types.d.ts +17 -0
  34. package/lib/context.d.ts +4 -4
  35. package/lib/context.js +2 -2
  36. package/lib/fs/bundlePointer.d.ts +2 -0
  37. package/lib/fs/bundlePointer.js +14 -4
  38. package/lib/index.d.ts +6 -3
  39. package/lib/index.js +5 -1
  40. package/lib/injectImageResolver.js +6 -15
  41. package/lib/loadConfig.d.ts +4 -4
  42. package/lib/manager/downloadAndInstall.d.ts +3 -0
  43. package/lib/manager/downloadAndInstall.js +23 -3
  44. package/lib/manager/reporting.d.ts +2 -0
  45. package/lib/manager/reporting.js +25 -0
  46. package/lib/manager/rollbackState.d.ts +25 -8
  47. package/lib/manager/rollbackState.js +87 -22
  48. package/lib/manager/updateCheck.js +15 -1
  49. package/lib/manager/updateState.d.ts +5 -1
  50. package/lib/manager/updateState.js +20 -11
  51. package/lib/native/bundleDropNative.d.ts +1 -0
  52. package/lib/native/bundleDropNative.js +14 -0
  53. package/lib/runtime/service.d.ts +28 -0
  54. package/lib/runtime/service.js +175 -16
  55. package/lib/scripts/bundle.d.ts +4 -1
  56. package/lib/scripts/bundle.js +41 -28
  57. package/lib/scripts/projectRoot.d.ts +1 -0
  58. package/lib/scripts/projectRoot.js +54 -0
  59. package/lib/scripts/upload-bundle.d.ts +2 -1
  60. package/lib/scripts/upload-bundle.js +46 -37
  61. package/lib/useBundleDrop.d.ts +2 -0
  62. package/lib/useBundleDrop.js +1 -0
  63. package/package.json +3 -2
@@ -37,8 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
38
  };
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.cleanupArtifacts = void 0;
41
- exports.findProjectRoot = findProjectRoot;
40
+ exports.cleanupArtifacts = exports.findProjectRoot = void 0;
42
41
  exports.parseAndroidVersionFromGradle = parseAndroidVersionFromGradle;
43
42
  exports.runUploadBundle = runUploadBundle;
44
43
  const axios_1 = __importDefault(require("axios"));
@@ -48,24 +47,10 @@ const fs = __importStar(require("fs"));
48
47
  const os_1 = __importDefault(require("os"));
49
48
  const path = __importStar(require("path"));
50
49
  const plist = __importStar(require("plist"));
50
+ const projectRoot_1 = require("./projectRoot");
51
+ Object.defineProperty(exports, "findProjectRoot", { enumerable: true, get: function () { return projectRoot_1.findProjectRoot; } });
51
52
  const resolve_ios_version_1 = require("./resolve-ios-version");
52
53
  const getPackageRoot = () => process.env.BUNDLE_DROP_PACKAGE_ROOT_OVERRIDE || path.resolve(__dirname, '..', '..');
53
- function findProjectRoot(startDir) {
54
- let dir = path.resolve(startDir);
55
- const MAX_UP = 12;
56
- for (let i = 0; i < MAX_UP; i++) {
57
- const iosDir = path.join(dir, 'ios');
58
- const androidDir = path.join(dir, 'android');
59
- if (fs.existsSync(iosDir) && fs.existsSync(androidDir)) {
60
- return dir;
61
- }
62
- const parent = path.dirname(dir);
63
- if (parent === dir)
64
- break;
65
- dir = parent;
66
- }
67
- return startDir;
68
- }
69
54
  function parseAndroidVersionFromGradle(filePath) {
70
55
  if (!fs.existsSync(filePath)) {
71
56
  console.error(`โŒ build.gradle not found at ${filePath}`);
@@ -82,25 +67,20 @@ function parseAndroidVersionFromGradle(filePath) {
82
67
  const cleanupArtifacts = (platform, zipPath) => {
83
68
  const outputDir = path.join(getPackageRoot(), 'dist');
84
69
  try {
85
- if (fs.existsSync(zipPath)) {
86
- fs.unlinkSync(zipPath);
87
- console.log(`๐Ÿงน Deleted: ${zipPath}`);
88
- }
89
70
  const suffix = platform === 'ios' ? 'ios' : 'android';
90
- const metadataPath = path.join(outputDir, `metadata-${suffix}.json`);
91
- const assetsPath = path.join(outputDir, 'assets');
92
- if (fs.existsSync(metadataPath)) {
93
- fs.unlinkSync(metadataPath);
94
- console.log(`๐Ÿงน Deleted: ${metadataPath}`);
71
+ const filesToDelete = [
72
+ zipPath,
73
+ path.join(outputDir, `metadata-${suffix}.json`),
74
+ path.join(outputDir, 'main.jsbundle'),
75
+ path.join(outputDir, 'main.jsbundle.map'),
76
+ ];
77
+ for (const file of filesToDelete) {
78
+ if (fs.existsSync(file))
79
+ fs.unlinkSync(file);
95
80
  }
81
+ const assetsPath = path.join(outputDir, 'assets');
96
82
  if (fs.existsSync(assetsPath)) {
97
83
  fs.rmSync(assetsPath, { recursive: true, force: true });
98
- console.log(`๐Ÿงน Deleted: ${assetsPath}`);
99
- }
100
- const bundlePath = path.join(outputDir, 'main.jsbundle');
101
- if (fs.existsSync(bundlePath)) {
102
- fs.unlinkSync(bundlePath);
103
- console.log(`๐Ÿงน Deleted: ${bundlePath}`);
104
84
  }
105
85
  }
106
86
  catch (err) {
@@ -112,7 +92,7 @@ async function runUploadBundle(options) {
112
92
  const packageRoot = getPackageRoot();
113
93
  const outputDir = path.join(packageRoot, 'dist');
114
94
  const argv = options?.argv || process.argv;
115
- const projectRoot = findProjectRoot(options?.cwd || process.cwd());
95
+ const projectRoot = (0, projectRoot_1.findProjectRoot)(options?.cwd || process.cwd());
116
96
  const configPath = path.resolve(projectRoot, 'bundle.drop.config.js');
117
97
  if (!fs.existsSync(configPath)) {
118
98
  console.error('โŒ bundle.drop.config.js not found in project root');
@@ -167,6 +147,9 @@ async function runUploadBundle(options) {
167
147
  const runtimeVersionOverride = runtimeVersionArg?.split('=')[1];
168
148
  const releaseNotesArg = args.find(arg => arg.startsWith('--release-notes='));
169
149
  let releaseNotes = releaseNotesArg ? releaseNotesArg.split('=')[1] : undefined;
150
+ const generateSourceMap = args.includes('--sourcemap');
151
+ const artifactDirArg = args.find(arg => arg.startsWith('--artifact-dir='));
152
+ const artifactDir = artifactDirArg ? path.resolve(artifactDirArg.split('=')[1]) : undefined;
170
153
  const MAX_NOTES = 2000;
171
154
  if (releaseNotes && releaseNotes.length > MAX_NOTES) {
172
155
  console.warn(`โš ๏ธ Release notes too long (${releaseNotes.length}); truncating to ${MAX_NOTES} chars.`);
@@ -233,8 +216,9 @@ async function runUploadBundle(options) {
233
216
  ? `node "${compiledBundleScript}"`
234
217
  : `ts-node "${tsBundleScript}"`;
235
218
  try {
219
+ const sourcemapArg = generateSourceMap ? ' --sourcemap' : '';
236
220
  console.log(`๐Ÿ“ฆ Running bundler for ${platform}...`);
237
- (0, child_process_1.execSync)(`${bundleCommand} ${platform}`, {
221
+ (0, child_process_1.execSync)(`${bundleCommand} ${platform}${sourcemapArg}`, {
238
222
  stdio: 'inherit',
239
223
  });
240
224
  const suffix = platform === 'ios' ? 'ios' : 'android';
@@ -285,7 +269,7 @@ async function runUploadBundle(options) {
285
269
  form.append('releaseNotes', releaseNotes);
286
270
  }
287
271
  form.append('file', fs.createReadStream(zipPath));
288
- console.log(`โฌ†๏ธ Uploading ${platform} bundle (v${version}) to project "${projectSlug}" at ${serverUrl}...`);
272
+ console.log(`โ†’ Uploading bundle to server...`);
289
273
  try {
290
274
  const res = await axios_1.default.post(`${serverUrl}/bundle/upload`, form, {
291
275
  headers: {
@@ -295,7 +279,32 @@ async function runUploadBundle(options) {
295
279
  maxContentLength: Infinity,
296
280
  maxBodyLength: Infinity,
297
281
  });
298
- console.log('โœ… Upload complete:', res.data);
282
+ if (artifactDir) {
283
+ try {
284
+ fs.mkdirSync(artifactDir, { recursive: true });
285
+ const bundleFile = path.join(outputDir, 'main.jsbundle');
286
+ const sourceMapFile = path.join(outputDir, 'main.jsbundle.map');
287
+ const result = { ...res.data };
288
+ if (fs.existsSync(bundleFile)) {
289
+ fs.copyFileSync(bundleFile, path.join(artifactDir, 'main.jsbundle'));
290
+ result.bundlePath = path.join(artifactDir, 'main.jsbundle');
291
+ }
292
+ if (generateSourceMap && fs.existsSync(sourceMapFile)) {
293
+ fs.copyFileSync(sourceMapFile, path.join(artifactDir, 'main.jsbundle.map'));
294
+ result.sourceMapPath = path.join(artifactDir, 'main.jsbundle.map');
295
+ }
296
+ fs.writeFileSync(path.join(artifactDir, 'bundle-drop-result.json'), JSON.stringify(result, null, 2));
297
+ console.log('๐Ÿ“ Artifacts saved to:', artifactDir);
298
+ }
299
+ catch (copyErr) {
300
+ console.warn('โš ๏ธ Upload succeeded but artifact copy failed:', copyErr.message);
301
+ }
302
+ }
303
+ console.log('โœ… Upload complete');
304
+ if (res.data?.bundleVersion != null)
305
+ console.log(`Bundle Version: ${res.data.bundleVersion}`);
306
+ if (res.data?.hash)
307
+ console.log(`Hash: ${res.data.hash}`);
299
308
  return res.data;
300
309
  }
301
310
  catch (err) {
@@ -36,6 +36,8 @@ export type UseBundleDropReturn = {
36
36
  result: ApplyUpdateResult;
37
37
  status?: string;
38
38
  }>;
39
+ /** Mark the current OTA candidate healthy for this device. */
40
+ reportHealthy: () => Promise<void>;
39
41
  /** Fetch available channel names from the server (API key auth). */
40
42
  fetchAvailableChannels: () => Promise<string[]>;
41
43
  /** Last fetched list of channel names. */
@@ -24,6 +24,7 @@ function useBundleDrop() {
24
24
  checkLatest: service_1.checkLatest,
25
25
  downloadUpdate: service_1.downloadAndStage,
26
26
  applyUpdate: service_1.applyDownloadedUpdate,
27
+ reportHealthy: service_1.reportHealthy,
27
28
  fetchAvailableChannels: service_1.fetchAvailableChannels,
28
29
  availableChannels: state.availableChannels,
29
30
  setChannel: service_1.setChannel,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gfean/react-native-bundle-drop",
3
- "version": "0.3.5",
4
- "nativeVersion": "0.3.5",
3
+ "version": "0.3.7",
4
+ "nativeVersion": "0.3.7",
5
5
  "description": "Over-the-air (OTA) updates for React Native โ€” ship fixes instantly, no App Store or Play Store delays",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -112,6 +112,7 @@
112
112
  "axios": "^1.8.4",
113
113
  "chalk": "4",
114
114
  "commander": "^13.1.0",
115
+ "diff": "^9.0.0",
115
116
  "figures": "3",
116
117
  "form-data": "^4.0.2",
117
118
  "fs-extra": "^11.2.0",