@gfean/react-native-bundle-drop 0.4.2 → 0.4.4

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 (111) hide show
  1. package/BundleDropExpo.podspec +21 -0
  2. package/README.md +339 -74
  3. package/android/src/main/java/com/bundledrop/BundleDropNativePaths.kt +33 -3
  4. package/app.plugin.js +3 -0
  5. package/expo/android/build.gradle +159 -0
  6. package/expo/android/src/main/AndroidManifest.xml +1 -0
  7. package/expo/android/src/main/java/com/bundledrop/expo/BundleDropExpoConfiguration.kt +35 -0
  8. package/expo/android/src/main/java/com/bundledrop/expo/BundleDropExpoIdentityModule.kt +30 -0
  9. package/expo/android/src/main/java/com/bundledrop/expo/BundleDropExpoPackage.kt +29 -0
  10. package/expo/android/src/main/java/com/bundledrop/expo/BundleDropExpoReactNativeHostHandler.kt +16 -0
  11. package/expo/bundle-drop-expo-gradle-plugin/build.gradle +31 -0
  12. package/expo/bundle-drop-expo-gradle-plugin/src/main/groovy/com/bundledrop/gradle/BundleDropExpoPlugin.groovy +83 -0
  13. package/expo/bundle-drop-expo-gradle-plugin/src/main/groovy/com/bundledrop/gradle/GenerateBundleDropBuildIdentityTask.groovy +57 -0
  14. package/expo/ios/Sources/BundleDropExpoIdentity.m +31 -0
  15. package/expo/ios/Sources/BundleDropExpoReactDelegateHandler.swift +24 -0
  16. package/expo-module.config.json +19 -0
  17. package/ios/BundleDropLocator.swift +7 -1
  18. package/lib/CLI/cli.d.ts +1 -2
  19. package/lib/CLI/cli.js +126 -31
  20. package/lib/CLI/logo.d.ts +9 -0
  21. package/lib/CLI/logo.js +26 -0
  22. package/lib/CLI/scripts/aipowered/apply-setup-plan.d.ts +12 -0
  23. package/lib/CLI/scripts/aipowered/apply-setup-plan.js +55 -0
  24. package/lib/CLI/scripts/aipowered/backend-client.d.ts +6 -1
  25. package/lib/CLI/scripts/aipowered/backend-client.js +25 -2
  26. package/lib/CLI/scripts/aipowered/init-project-config.d.ts +17 -0
  27. package/lib/CLI/scripts/aipowered/init-project-config.js +400 -0
  28. package/lib/CLI/scripts/aipowered/scanner.d.ts +10 -1
  29. package/lib/CLI/scripts/aipowered/scanner.js +274 -5
  30. package/lib/CLI/scripts/aipowered/types.d.ts +39 -0
  31. package/lib/CLI/scripts/aipowered/validate-plan.d.ts +12 -0
  32. package/lib/CLI/scripts/aipowered/validate-plan.js +76 -1
  33. package/lib/CLI/scripts/doctor.d.ts +17 -0
  34. package/lib/CLI/scripts/doctor.js +412 -0
  35. package/lib/CLI/scripts/expo/build-receipt.d.ts +26 -0
  36. package/lib/CLI/scripts/expo/build-receipt.js +223 -0
  37. package/lib/CLI/scripts/expo/configure-expo.d.ts +28 -0
  38. package/lib/CLI/scripts/expo/configure-expo.js +268 -0
  39. package/lib/CLI/scripts/expo/eas-build-proof.d.ts +22 -0
  40. package/lib/CLI/scripts/expo/eas-build-proof.js +116 -0
  41. package/lib/CLI/scripts/expo/package-manager.d.ts +11 -0
  42. package/lib/CLI/scripts/expo/package-manager.js +84 -0
  43. package/lib/CLI/scripts/expo/write-build-receipt.d.ts +25 -0
  44. package/lib/CLI/scripts/expo/write-build-receipt.js +325 -0
  45. package/lib/CLI/scripts/expo/write-eas-build-receipt.d.ts +8 -0
  46. package/lib/CLI/scripts/expo/write-eas-build-receipt.js +71 -0
  47. package/lib/CLI/scripts/init-config.d.ts +18 -1
  48. package/lib/CLI/scripts/init-config.js +29 -9
  49. package/lib/CLI/scripts/init-metro-config.d.ts +7 -0
  50. package/lib/CLI/scripts/init-metro-config.js +28 -8
  51. package/lib/CLI/scripts/login-cli.js +17 -3
  52. package/lib/CLI/scripts/post-init.d.ts +6 -1
  53. package/lib/CLI/scripts/post-init.js +6 -33
  54. package/lib/CLI/scripts/upload-cli.d.ts +1 -0
  55. package/lib/CLI/scripts/upload-cli.js +106 -36
  56. package/lib/context.d.ts +0 -2
  57. package/lib/context.js +19 -3
  58. package/lib/expo/buildIdentity.d.ts +15 -0
  59. package/lib/expo/buildIdentity.js +201 -0
  60. package/lib/expo/buildReceipt.d.ts +42 -0
  61. package/lib/expo/buildReceipt.js +272 -0
  62. package/lib/expo/config.d.ts +7 -0
  63. package/lib/expo/config.js +43 -0
  64. package/lib/expo/configCache.d.ts +1 -0
  65. package/lib/expo/configCache.js +20 -0
  66. package/lib/expo/errors.d.ts +6 -0
  67. package/lib/expo/errors.js +11 -0
  68. package/lib/expo/expoUpdatesOwnership.d.ts +13 -0
  69. package/lib/expo/expoUpdatesOwnership.js +22 -0
  70. package/lib/expo/exportExpoProject.d.ts +21 -0
  71. package/lib/expo/exportExpoProject.js +125 -0
  72. package/lib/expo/exportValidation.d.ts +11 -0
  73. package/lib/expo/exportValidation.js +115 -0
  74. package/lib/expo/index.d.ts +18 -0
  75. package/lib/expo/index.js +25 -0
  76. package/lib/expo/localModules.d.ts +4 -0
  77. package/lib/expo/localModules.js +51 -0
  78. package/lib/expo/nativeIdentity.d.ts +1 -0
  79. package/lib/expo/nativeIdentity.js +17 -0
  80. package/lib/expo/projectType.d.ts +7 -0
  81. package/lib/expo/projectType.js +200 -0
  82. package/lib/expo/runtimeVersion.d.ts +13 -0
  83. package/lib/expo/runtimeVersion.js +45 -0
  84. package/lib/expo/types.d.ts +15 -0
  85. package/lib/expo/types.js +2 -0
  86. package/lib/fs/userProperties.d.ts +0 -2
  87. package/lib/fs/userProperties.js +0 -3
  88. package/lib/index.d.ts +1 -1
  89. package/lib/index.js +1 -2
  90. package/lib/loadConfig.d.ts +17 -5
  91. package/lib/loadConfig.js +2 -19
  92. package/lib/metro.d.ts +17 -0
  93. package/lib/metro.js +57 -0
  94. package/lib/native/bundleDropNative.d.ts +2 -0
  95. package/lib/native/bundleDropNative.js +9 -1
  96. package/lib/runtime/service.js +12 -1
  97. package/lib/scripts/bundle.d.ts +2 -2
  98. package/lib/scripts/bundle.js +30 -99
  99. package/lib/scripts/canonicalArtifact.d.ts +30 -0
  100. package/lib/scripts/canonicalArtifact.js +212 -0
  101. package/lib/scripts/download-bundle.js +1 -1
  102. package/lib/scripts/exportProject.d.ts +41 -0
  103. package/lib/scripts/exportProject.js +82 -0
  104. package/package.json +74 -55
  105. package/plugin/constants.js +9 -0
  106. package/plugin/expoUpdates.js +131 -0
  107. package/plugin/index.js +11 -0
  108. package/plugin/markers.js +31 -0
  109. package/plugin/withBundleDrop.js +36 -0
  110. package/plugin/xcodeBuildPhase.js +77 -0
  111. package/react-native.config.js +20 -0
@@ -0,0 +1,41 @@
1
+ import type { ExpoBuildIdentity, MobilePlatform, ProjectType } from '../expo';
2
+ export type ExportProjectArtifactOptions = {
3
+ projectRoot: string;
4
+ platform: MobilePlatform;
5
+ appVersion: string;
6
+ generateSourceMap: boolean;
7
+ projectType?: ProjectType;
8
+ buildReceipt?: string;
9
+ buildIdentity?: ExpoBuildIdentity;
10
+ };
11
+ export declare function exportProjectArtifact(options: ExportProjectArtifactOptions): Promise<{
12
+ outputDir: string;
13
+ bundlePath: string;
14
+ sourceMapPath?: string;
15
+ metadataPath: string;
16
+ zipPath: string;
17
+ runtimeVersion: string;
18
+ hash: string;
19
+ bundleHash: string;
20
+ jsBundleHash: string;
21
+ manifestPath: string;
22
+ projectRoot: string;
23
+ projectType: "bare";
24
+ buildIdentity: any;
25
+ } | {
26
+ outputDir: string;
27
+ bundlePath: string;
28
+ sourceMapPath?: string;
29
+ metadataPath: string;
30
+ zipPath: string;
31
+ runtimeVersion: string;
32
+ hash: string;
33
+ bundleHash: string;
34
+ jsBundleHash: string;
35
+ manifestPath: string;
36
+ projectType: "expo";
37
+ projectRoot: string;
38
+ buildIdentity: ExpoBuildIdentity;
39
+ expoExportDirectory: string;
40
+ sourceMapDebugId: string;
41
+ }>;
@@ -0,0 +1,82 @@
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.exportProjectArtifact = exportProjectArtifact;
7
+ const fs_extra_1 = __importDefault(require("fs-extra"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const expo_1 = require("../expo");
10
+ const build_receipt_1 = require("../CLI/scripts/expo/build-receipt");
11
+ const canonicalArtifact_1 = require("./canonicalArtifact");
12
+ const bundle_1 = require("./bundle");
13
+ const getExpoArtifactRoot = (projectRoot) => path_1.default.join(projectRoot, '.bundle-drop', 'artifacts');
14
+ const assertExpoUpdatesDoesNotOwnExport = (projectRoot) => {
15
+ const { exp } = (0, expo_1.evaluateExpoConfig)(projectRoot);
16
+ (0, expo_1.assertExpoUpdatesDoesNotOwnStartup)(projectRoot, exp);
17
+ };
18
+ async function exportProjectArtifact(options) {
19
+ const projectRoot = path_1.default.resolve(options.projectRoot);
20
+ const projectType = (0, expo_1.detectProjectType)({
21
+ projectRoot,
22
+ explicitType: options.projectType,
23
+ });
24
+ if (projectType === 'bare') {
25
+ return {
26
+ projectType,
27
+ buildIdentity: undefined,
28
+ ...(0, bundle_1.runBundleScript)({
29
+ platform: options.platform,
30
+ cwd: projectRoot,
31
+ sourcemap: options.generateSourceMap,
32
+ }),
33
+ };
34
+ }
35
+ assertExpoUpdatesDoesNotOwnExport(projectRoot);
36
+ const buildIdentity = options.buildIdentity || await (0, build_receipt_1.resolveExpoUploadIdentity)({
37
+ projectRoot,
38
+ platform: options.platform,
39
+ receiptFile: options.buildReceipt,
40
+ });
41
+ if (buildIdentity.platform !== options.platform) {
42
+ throw new Error(`Expo build receipt identity is for ${buildIdentity.platform}, not ${options.platform}.`);
43
+ }
44
+ if (options.appVersion !== buildIdentity.appVersion) {
45
+ throw new Error(`Expo app version mismatch: upload requested ${options.appVersion}, but the proven build identity is ` +
46
+ `${buildIdentity.appVersion}. Bundle Drop will not publish to an unproven binary identity.`);
47
+ }
48
+ const distDir = getExpoArtifactRoot(projectRoot);
49
+ const outputDir = path_1.default.join(distDir, `expo-artifacts-${options.platform}`);
50
+ const expoOutput = path_1.default.join(distDir, `expo-export-${options.platform}`);
51
+ fs_extra_1.default.removeSync(outputDir);
52
+ fs_extra_1.default.removeSync(expoOutput);
53
+ fs_extra_1.default.ensureDirSync(outputDir);
54
+ const exported = await (0, expo_1.exportExpoProject)({
55
+ projectRoot,
56
+ platform: options.platform,
57
+ outputDirectory: expoOutput,
58
+ resetCache: true,
59
+ buildIdentity,
60
+ });
61
+ const bundlePath = path_1.default.join(outputDir, 'main.jsbundle');
62
+ const sourceMapPath = path_1.default.join(outputDir, 'main.jsbundle.map');
63
+ fs_extra_1.default.copyFileSync(exported.bundlePath, bundlePath);
64
+ fs_extra_1.default.copyFileSync(exported.sourceMapPath, sourceMapPath);
65
+ const artifact = (0, canonicalArtifact_1.buildCanonicalArtifact)({
66
+ platform: options.platform,
67
+ appVersion: buildIdentity.appVersion,
68
+ runtimeVersion: buildIdentity.runtimeVersion,
69
+ bundlePath,
70
+ assetsDir: exported.assetsDirectory,
71
+ outputDir,
72
+ sourceMapPath,
73
+ });
74
+ return {
75
+ projectType,
76
+ projectRoot,
77
+ buildIdentity,
78
+ expoExportDirectory: expoOutput,
79
+ sourceMapDebugId: exported.sourceMapDebugId,
80
+ ...artifact,
81
+ };
82
+ }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@gfean/react-native-bundle-drop",
3
- "version": "0.4.2",
4
- "nativeVersion": "0.4.2",
5
- "description": "Over-the-air (OTA) updates for React Native — ship fixes instantly, no App Store or Play Store delays",
3
+ "version": "0.4.4",
4
+ "nativeVersion": "0.4.4",
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",
7
7
  "types": "lib/index.d.ts",
8
8
  "author": {
@@ -23,10 +23,11 @@
23
23
  "types": "./lib/index.d.ts",
24
24
  "default": "./lib/index.js"
25
25
  },
26
- "./bootstrap": {
27
- "types": "./lib/bootstrap.d.ts",
28
- "default": "./lib/bootstrap.js"
26
+ "./metro": {
27
+ "types": "./lib/metro.d.ts",
28
+ "default": "./lib/metro.js"
29
29
  },
30
+ "./app.plugin.js": "./app.plugin.js",
30
31
  "./package.json": "./package.json"
31
32
  },
32
33
  "sideEffects": [
@@ -35,46 +36,22 @@
35
36
  ],
36
37
  "scripts": {
37
38
  "clean": "rimraf lib dist",
38
- "build": "yarn clean && tsc -p tsconfig.build.json && node scripts/make-cli-executable.js",
39
- "prepare": "husky",
39
+ "build": "npm run clean && tsc -p tsconfig.build.json && node scripts/make-cli-executable.js",
40
40
  "test": "jest --runInBand",
41
41
  "test:coverage": "jest --runInBand --coverage",
42
42
  "coverage:check": "node scripts/check-coverage-thresholds.cjs",
43
- "test:android:unit": "node scripts/run-android-tests.cjs",
44
- "test:android": "yarn test:android:unit",
43
+ "coverage:gate": "yarn test:coverage && yarn coverage:check",
44
+ "test:android": "node scripts/run-android-tests.cjs",
45
45
  "test:android:device": "node scripts/run-android-instrumented-tests.cjs",
46
46
  "test:ios": "node scripts/run-ios-tests.cjs",
47
- "test:native": "yarn verify:native",
48
- "test:harness": "jest --runInBand src/tests/harness",
49
- "harness:app:install": "node scripts/harness/install-app-deps.cjs",
50
- "harness:app:install:rn85:new": "node scripts/harness/install-app-deps.cjs rn-0.85-new-arch",
51
- "harness:app:install:rn71:old": "node scripts/harness/install-app-deps.cjs rn-0.71-old-arch",
52
- "harness:app:install:rn74:old": "node scripts/harness/install-app-deps.cjs rn-0.74-old-arch",
53
- "harness:app:install:rn78:old": "node scripts/harness/install-app-deps.cjs rn-0.78-old-arch",
54
- "harness:ios": "node scripts/harness/run-app-harness.cjs ios",
55
- "harness:android": "node scripts/harness/run-app-harness.cjs android",
56
- "harness:ios:rn85:new": "node scripts/harness/run-app-harness.cjs ios rn-0.85-new-arch",
57
- "harness:android:rn85:new": "node scripts/harness/run-app-harness.cjs android rn-0.85-new-arch",
58
- "harness:ios:rn71:old": "node scripts/harness/run-app-harness.cjs ios rn-0.71-old-arch",
59
- "harness:android:rn71:old": "node scripts/harness/run-app-harness.cjs android rn-0.71-old-arch",
60
- "harness:ios:rn74:old": "node scripts/harness/run-app-harness.cjs ios rn-0.74-old-arch",
61
- "harness:android:rn74:old": "node scripts/harness/run-app-harness.cjs android rn-0.74-old-arch",
62
- "harness:ios:rn78:old": "node scripts/harness/run-app-harness.cjs ios rn-0.78-old-arch",
63
- "harness:android:rn78:old": "node scripts/harness/run-app-harness.cjs android rn-0.78-old-arch",
64
- "harness:backend:live": "node scripts/harness/live-backend-smoke.cjs",
65
- "harness:pack": "node scripts/harness/pack-dry-run.cjs",
66
- "coverage:gate": "yarn test:coverage && yarn coverage:check",
67
- "verify:quick": "yarn coverage:gate && yarn harness:pack",
47
+ "test:expo:plugin": "node --test plugin/__tests__/*.test.js",
48
+ "package:check": "node scripts/check-package-contents.cjs",
49
+ "audit:production": "yarn npm audit --environment production --recursive --severity high",
50
+ "verify:quick": "yarn build && yarn coverage:gate && yarn test:expo:plugin && yarn package:check",
68
51
  "verify:native": "yarn test:android && yarn test:ios",
69
- "verify:release": "yarn verify:quick && yarn verify:native",
70
- "prepublishOnly": "yarn clean && yarn build && yarn harness:pack",
71
- "build-and-publish": "yarn clean && yarn build && npm publish --access=restricted",
72
- "publish:local": "yalc publish --private"
73
- },
74
- "create-react-native-library": {
75
- "type": "legacy-module",
76
- "languages": "kotlin-swift",
77
- "version": "0.49.6"
52
+ "verify:release": "yarn verify:quick && yarn verify:native && yarn audit:production",
53
+ "prepack": "npm run build",
54
+ "prepublishOnly": "npm run verify:release"
78
55
  },
79
56
  "devDependencies": {
80
57
  "@types/adm-zip": "^0.5.8",
@@ -82,12 +59,15 @@
82
59
  "@types/node": "^24.10.1",
83
60
  "@types/react": "^18.2.66",
84
61
  "@types/react-native": "^0.73.0",
85
- "husky": "^9.1.7",
62
+ "expo-autolinking-sdk55": "npm:expo-modules-autolinking@55.0.8",
63
+ "expo-autolinking-sdk56": "npm:expo-modules-autolinking@56.0.9",
64
+ "expo-autolinking-sdk57": "npm:expo-modules-autolinking@57.0.2",
86
65
  "jest": "^29.7.0",
87
66
  "react": "^18.3.1",
88
67
  "react-native": ">=0.71.0",
89
68
  "react-test-renderer": "^18.3.1",
90
69
  "rimraf": "^6.0.1",
70
+ "rn-cli-platform-android-078": "npm:@react-native-community/cli-platform-android@15.0.1",
91
71
  "ts-jest": "^29.4.4",
92
72
  "ts-node": "^10.9.2",
93
73
  "typescript": "^5.8.3"
@@ -117,49 +97,88 @@
117
97
  "!third_party/xdelta/README.md",
118
98
  "!third_party/xdelta/xdelta3/README.md",
119
99
  "BundleDrop.podspec",
100
+ "BundleDropExpo.podspec",
120
101
  "react-native.config.js",
102
+ "app.plugin.js",
103
+ "plugin/*.js",
104
+ "expo-module.config.json",
105
+ "expo/android/build.gradle",
106
+ "expo/android/src/main/**",
107
+ "expo/bundle-drop-expo-gradle-plugin/build.gradle",
108
+ "expo/bundle-drop-expo-gradle-plugin/src/main/**",
109
+ "expo/ios/Sources/**",
121
110
  "README.md"
122
111
  ],
123
112
  "keywords": [
124
113
  "react-native",
114
+ "expo",
115
+ "expo-sdk",
116
+ "expo-router",
125
117
  "react-native-ota",
118
+ "ota",
126
119
  "ota-updates",
127
120
  "over-the-air",
121
+ "over-the-air-updates",
122
+ "codepush",
123
+ "codepush-alternative",
124
+ "react-native-code-push",
125
+ "app-center-codepush",
126
+ "eas-update-alternative",
127
+ "expo-updates-alternative",
128
+ "expo-eas-update-alternative",
128
129
  "react-native-update",
129
130
  "react-native-updates",
130
- "bundle-updates",
131
131
  "hot-update",
132
- "codepush-alternative",
133
- "expo-eas-update-alternative",
134
- "react-native-deployment",
135
- "mobile-updates",
136
- "app-updates",
137
132
  "live-updates",
138
- "feature-rollout",
133
+ "instant-updates",
134
+ "hotfix",
135
+ "bundle-updates",
136
+ "js-bundle",
137
+ "delta-updates",
138
+ "patch-updates",
139
139
  "staged-rollout",
140
+ "feature-rollout",
140
141
  "rollback",
141
- "react-native-ci",
142
+ "react-native-deployment",
142
143
  "react-native-release",
143
- "react-native-production"
144
+ "react-native-ci",
145
+ "react-native-production",
146
+ "mobile-updates",
147
+ "app-updates",
148
+ "react-native-ios",
149
+ "react-native-android"
144
150
  ],
145
151
  "peerDependencies": {
152
+ "expo": ">=54.0.0 <58.0.0",
146
153
  "react": ">=17.0.0",
147
154
  "react-native": ">=0.71.0"
148
155
  },
156
+ "peerDependenciesMeta": {
157
+ "expo": {
158
+ "optional": true
159
+ }
160
+ },
161
+ "engines": {
162
+ "node": ">=20.19.4"
163
+ },
164
+ "resolutions": {
165
+ "diff@^4.0.1": "4.0.4",
166
+ "@xmldom/xmldom@^0.8.8": "0.8.13"
167
+ },
149
168
  "dependencies": {
150
- "adm-zip": "^0.5.16",
151
- "axios": "^1.8.4",
169
+ "adm-zip": "^0.6.0",
170
+ "axios": "^1.19.0",
152
171
  "chalk": "4",
153
- "commander": "^13.1.0",
172
+ "commander": "^7.2.0",
154
173
  "diff": "^9.0.0",
155
174
  "figures": "3",
156
- "form-data": "^4.0.2",
175
+ "form-data": "^4.0.6",
157
176
  "fs-extra": "^11.2.0",
158
177
  "plist": "^3.1.0",
159
178
  "prompts": "^2.4.2"
160
179
  },
161
180
  "publishConfig": {
162
- "access": "restricted"
181
+ "access": "public"
163
182
  },
164
183
  "packageManager": "yarn@3.8.3+sha512.154080e749d50325f4df31bc341cd5ea2dc2c3ca9b2cfb8591c831ddefc8025084d9500223f61f4f73086f6d9faa746cbbf39bb988b41dfc042907687e8e7d7a"
165
184
  }
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ const ANDROID_ENABLED_META_DATA = 'com.bundledrop.EXPO_ENABLED';
4
+ const IOS_ENABLED_INFO_PLIST_KEY = 'BundleDropExpoEnabled';
5
+
6
+ module.exports = {
7
+ ANDROID_ENABLED_META_DATA,
8
+ IOS_ENABLED_INFO_PLIST_KEY,
9
+ };
@@ -0,0 +1,131 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const EXPO_UPDATES_PACKAGE = 'expo-updates';
7
+ const EXPO_UPDATES_DISABLED_WARNING =
8
+ 'Bundle Drop: expo-updates is installed but explicitly disabled. ' +
9
+ 'Launch support still requires generated-native and cold-start proof that expo-updates yields startup.';
10
+
11
+ function getProjectRoot(config) {
12
+ return config?._internal?.projectRoot || process.cwd();
13
+ }
14
+
15
+ function getPluginName(plugin) {
16
+ if (typeof plugin === 'string') {
17
+ return plugin;
18
+ }
19
+
20
+ if (Array.isArray(plugin) && typeof plugin[0] === 'string') {
21
+ return plugin[0];
22
+ }
23
+
24
+ return null;
25
+ }
26
+
27
+ function configReferencesExpoUpdates(config) {
28
+ return (config.plugins || []).some(
29
+ (plugin) => getPluginName(plugin) === EXPO_UPDATES_PACKAGE,
30
+ );
31
+ }
32
+
33
+ function packageJsonReferencesExpoUpdates(projectRoot) {
34
+ try {
35
+ const packageJson = JSON.parse(
36
+ fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf8'),
37
+ );
38
+
39
+ return [
40
+ packageJson.dependencies,
41
+ packageJson.devDependencies,
42
+ packageJson.optionalDependencies,
43
+ packageJson.peerDependencies,
44
+ ].some((dependencies) => Boolean(dependencies?.[EXPO_UPDATES_PACKAGE]));
45
+ } catch {
46
+ return false;
47
+ }
48
+ }
49
+
50
+ function canResolveExpoUpdates(projectRoot) {
51
+ try {
52
+ const packagePath = require.resolve(`${EXPO_UPDATES_PACKAGE}/package.json`, {
53
+ paths: [projectRoot],
54
+ });
55
+ return fs.existsSync(packagePath);
56
+ } catch {
57
+ try {
58
+ const modulePath = require.resolve(EXPO_UPDATES_PACKAGE, { paths: [projectRoot] });
59
+ return fs.existsSync(modulePath);
60
+ } catch {
61
+ return false;
62
+ }
63
+ }
64
+ }
65
+
66
+ function getExpoUpdatesState(config, options = {}) {
67
+ return getExpoUpdatesOwnership(config, options).state;
68
+ }
69
+
70
+ function getExpoUpdatesOwnership(config, options = {}) {
71
+ const projectRoot = options.projectRoot || getProjectRoot(config);
72
+ const packageIsInstalled = options.packageIsInstalled ?? canResolveExpoUpdates(projectRoot);
73
+ const packageIsDeclared = packageJsonReferencesExpoUpdates(projectRoot);
74
+ const pluginIsDeclared = configReferencesExpoUpdates(config);
75
+ const updatesConfig = config.updates || {};
76
+ const hasUpdatesUrl = typeof updatesConfig.url === 'string';
77
+ const explicitlyEnabled = updatesConfig.enabled === true;
78
+ const explicitlyDisabled = updatesConfig.enabled === false;
79
+ const isPresent =
80
+ packageIsInstalled || packageIsDeclared || pluginIsDeclared || hasUpdatesUrl || explicitlyEnabled;
81
+
82
+ if (!isPresent) {
83
+ return {
84
+ state: 'absent',
85
+ packageIsInstalled,
86
+ packageIsDeclared,
87
+ pluginIsDeclared,
88
+ hasUpdatesUrl,
89
+ explicitlyEnabled,
90
+ explicitlyDisabled,
91
+ };
92
+ }
93
+
94
+ return {
95
+ state: explicitlyDisabled ? 'disabled' : 'active',
96
+ packageIsInstalled,
97
+ packageIsDeclared,
98
+ pluginIsDeclared,
99
+ hasUpdatesUrl,
100
+ explicitlyEnabled,
101
+ explicitlyDisabled,
102
+ };
103
+ }
104
+
105
+ function assertExpoUpdatesDoesNotOwnStartup(config, options = {}) {
106
+ const state = getExpoUpdatesState(config, options);
107
+
108
+ if (state === 'active') {
109
+ throw new Error(
110
+ 'Bundle Drop cannot be enabled while expo-updates is active. ' +
111
+ 'Disable or migrate expo-updates, create a new native build, and run setup again. ' +
112
+ 'Bundle Drop will never disable expo-updates silently.',
113
+ );
114
+ }
115
+
116
+ if (state === 'disabled' && options.warn !== false) {
117
+ console.warn(EXPO_UPDATES_DISABLED_WARNING);
118
+ }
119
+
120
+ return config;
121
+ }
122
+
123
+ module.exports = {
124
+ EXPO_UPDATES_DISABLED_WARNING,
125
+ assertExpoUpdatesDoesNotOwnStartup,
126
+ configReferencesExpoUpdates,
127
+ getExpoUpdatesOwnership,
128
+ getExpoUpdatesState,
129
+ getPluginName,
130
+ packageJsonReferencesExpoUpdates,
131
+ };
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ const { createRunOncePlugin } = require('expo/config-plugins');
4
+ const packageJson = require('../package.json');
5
+ const withBundleDrop = require('./withBundleDrop');
6
+
7
+ module.exports = createRunOncePlugin(
8
+ withBundleDrop,
9
+ packageJson.name,
10
+ packageJson.version,
11
+ );
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ const {
4
+ ANDROID_ENABLED_META_DATA,
5
+ IOS_ENABLED_INFO_PLIST_KEY,
6
+ } = require('./constants');
7
+
8
+ function addIosEnabledMarker(infoPlist) {
9
+ return {
10
+ ...infoPlist,
11
+ [IOS_ENABLED_INFO_PLIST_KEY]: true,
12
+ };
13
+ }
14
+
15
+ function addAndroidEnabledMarker(androidConfig, androidManifest) {
16
+ const mainApplication =
17
+ androidConfig.Manifest.getMainApplicationOrThrow(androidManifest);
18
+
19
+ androidConfig.Manifest.addMetaDataItemToMainApplication(
20
+ mainApplication,
21
+ ANDROID_ENABLED_META_DATA,
22
+ 'true',
23
+ );
24
+
25
+ return androidManifest;
26
+ }
27
+
28
+ module.exports = {
29
+ addAndroidEnabledMarker,
30
+ addIosEnabledMarker,
31
+ };
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ const {
4
+ AndroidConfig,
5
+ withAndroidManifest,
6
+ withInfoPlist,
7
+ withXcodeProject,
8
+ } = require('expo/config-plugins');
9
+
10
+ const { assertExpoUpdatesDoesNotOwnStartup } = require('./expoUpdates');
11
+ const { addAndroidEnabledMarker, addIosEnabledMarker } = require('./markers');
12
+ const { ensureBundleDropBuildPhase } = require('./xcodeBuildPhase');
13
+
14
+ function withBundleDrop(config) {
15
+ assertExpoUpdatesDoesNotOwnStartup(config);
16
+
17
+ config = withInfoPlist(config, (modConfig) => {
18
+ modConfig.modResults = addIosEnabledMarker(modConfig.modResults);
19
+ return modConfig;
20
+ });
21
+
22
+ config = withXcodeProject(config, (modConfig) => {
23
+ modConfig.modResults = ensureBundleDropBuildPhase(modConfig.modResults);
24
+ return modConfig;
25
+ });
26
+
27
+ return withAndroidManifest(config, (modConfig) => {
28
+ modConfig.modResults = addAndroidEnabledMarker(
29
+ AndroidConfig,
30
+ modConfig.modResults,
31
+ );
32
+ return modConfig;
33
+ });
34
+ }
35
+
36
+ module.exports = withBundleDrop;
@@ -0,0 +1,77 @@
1
+ 'use strict';
2
+
3
+ const PHASE_NAME = 'Bundle Drop: Write iOS build identity';
4
+
5
+ const SHELL_SCRIPT = [
6
+ 'set -e',
7
+ 'if [ "${ENABLE_TESTABILITY:-NO}" = "YES" ]; then exit 0; fi',
8
+ 'BUNDLE_DROP_PROJECT_ROOT="$PROJECT_DIR/.."',
9
+ 'BUNDLE_DROP_WRITER="$BUNDLE_DROP_PROJECT_ROOT/node_modules/@gfean/react-native-bundle-drop/lib/CLI/scripts/expo/write-build-receipt.js"',
10
+ '"${NODE_BINARY:-node}" "$BUNDLE_DROP_WRITER" --project-root "$BUNDLE_DROP_PROJECT_ROOT" --platform ios --artifact "$TARGET_BUILD_DIR/$WRAPPER_NAME"',
11
+ ].join('\n');
12
+
13
+ function unquote(value) {
14
+ if (typeof value !== 'string') return value;
15
+ return value.replace(/^"|"$/g, '');
16
+ }
17
+
18
+ function findPhaseUuid(project) {
19
+ const phases = project.hash?.project?.objects?.PBXShellScriptBuildPhase || {};
20
+ for (const [uuid, phase] of Object.entries(phases)) {
21
+ if (uuid.endsWith('_comment') || !phase || typeof phase !== 'object') continue;
22
+ if (unquote(phase.name) === PHASE_NAME) return uuid;
23
+ }
24
+ return null;
25
+ }
26
+
27
+ function updatePhase(project, phaseUuid) {
28
+ const phase = project.hash.project.objects.PBXShellScriptBuildPhase[phaseUuid];
29
+ phase.name = `"${PHASE_NAME}"`;
30
+ phase.shellPath = '/bin/sh';
31
+ phase.shellScript = `"${SHELL_SCRIPT.replace(/"/g, '\\"')}"`;
32
+ }
33
+
34
+ function movePhaseToEnd(target, phaseUuid) {
35
+ const phases = target?.buildPhases;
36
+ if (!Array.isArray(phases)) return;
37
+ const index = phases.findIndex(reference => reference?.value === phaseUuid);
38
+ if (index < 0 || index === phases.length - 1) return;
39
+ const [reference] = phases.splice(index, 1);
40
+ phases.push(reference);
41
+ }
42
+
43
+ function ensureBundleDropBuildPhase(project) {
44
+ const targetResult = project.getFirstTarget();
45
+ const targetUuid = targetResult?.uuid;
46
+ const target = targetResult?.firstTarget;
47
+ if (!targetUuid || !target) {
48
+ throw new Error('Bundle Drop could not find the iOS application target.');
49
+ }
50
+
51
+ let phaseUuid = findPhaseUuid(project);
52
+ if (!phaseUuid) {
53
+ project.addBuildPhase(
54
+ [],
55
+ 'PBXShellScriptBuildPhase',
56
+ PHASE_NAME,
57
+ targetUuid,
58
+ {
59
+ shellPath: '/bin/sh',
60
+ shellScript: SHELL_SCRIPT,
61
+ },
62
+ );
63
+ phaseUuid = findPhaseUuid(project);
64
+ if (!phaseUuid) {
65
+ throw new Error('Bundle Drop could not add its iOS post-bundle identity phase.');
66
+ }
67
+ }
68
+ updatePhase(project, phaseUuid);
69
+ movePhaseToEnd(target, phaseUuid);
70
+ return project;
71
+ }
72
+
73
+ module.exports = {
74
+ PHASE_NAME,
75
+ SHELL_SCRIPT,
76
+ ensureBundleDropBuildPhase,
77
+ };
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+
5
+ module.exports = {
6
+ dependency: {
7
+ platforms: {
8
+ ios: {
9
+ podspecPath: path.join(__dirname, 'BundleDrop.podspec'),
10
+ },
11
+ android: {
12
+ // Keep this relative. Both the Community CLI and Expo autolinking
13
+ // resolve sourceDir from the installed package root.
14
+ sourceDir: 'android',
15
+ packageImportPath: 'import com.bundledrop.BundleDropPackage;',
16
+ packageInstance: 'new BundleDropPackage()',
17
+ },
18
+ },
19
+ },
20
+ };