@gfean/react-native-bundle-drop 0.4.3 → 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.
- package/BundleDropExpo.podspec +21 -0
- package/README.md +250 -124
- package/android/src/main/java/com/bundledrop/BundleDropNativePaths.kt +33 -3
- package/app.plugin.js +3 -0
- package/expo/android/build.gradle +159 -0
- package/expo/android/src/main/AndroidManifest.xml +1 -0
- package/expo/android/src/main/java/com/bundledrop/expo/BundleDropExpoConfiguration.kt +35 -0
- package/expo/android/src/main/java/com/bundledrop/expo/BundleDropExpoIdentityModule.kt +30 -0
- package/expo/android/src/main/java/com/bundledrop/expo/BundleDropExpoPackage.kt +29 -0
- package/expo/android/src/main/java/com/bundledrop/expo/BundleDropExpoReactNativeHostHandler.kt +16 -0
- package/expo/bundle-drop-expo-gradle-plugin/build.gradle +31 -0
- package/expo/bundle-drop-expo-gradle-plugin/src/main/groovy/com/bundledrop/gradle/BundleDropExpoPlugin.groovy +83 -0
- package/expo/bundle-drop-expo-gradle-plugin/src/main/groovy/com/bundledrop/gradle/GenerateBundleDropBuildIdentityTask.groovy +57 -0
- package/expo/ios/Sources/BundleDropExpoIdentity.m +31 -0
- package/expo/ios/Sources/BundleDropExpoReactDelegateHandler.swift +24 -0
- package/expo-module.config.json +19 -0
- package/ios/BundleDropLocator.swift +7 -1
- package/lib/CLI/cli.d.ts +1 -2
- package/lib/CLI/cli.js +116 -14
- package/lib/CLI/scripts/aipowered/apply-setup-plan.d.ts +12 -0
- package/lib/CLI/scripts/aipowered/apply-setup-plan.js +55 -0
- package/lib/CLI/scripts/aipowered/backend-client.d.ts +6 -1
- package/lib/CLI/scripts/aipowered/backend-client.js +25 -2
- package/lib/CLI/scripts/aipowered/init-project-config.d.ts +17 -0
- package/lib/CLI/scripts/aipowered/init-project-config.js +400 -0
- package/lib/CLI/scripts/aipowered/scanner.d.ts +10 -1
- package/lib/CLI/scripts/aipowered/scanner.js +252 -5
- package/lib/CLI/scripts/aipowered/types.d.ts +39 -0
- package/lib/CLI/scripts/aipowered/validate-plan.d.ts +12 -0
- package/lib/CLI/scripts/aipowered/validate-plan.js +76 -1
- package/lib/CLI/scripts/doctor.d.ts +17 -0
- package/lib/CLI/scripts/doctor.js +412 -0
- package/lib/CLI/scripts/expo/build-receipt.d.ts +26 -0
- package/lib/CLI/scripts/expo/build-receipt.js +223 -0
- package/lib/CLI/scripts/expo/configure-expo.d.ts +28 -0
- package/lib/CLI/scripts/expo/configure-expo.js +268 -0
- package/lib/CLI/scripts/expo/eas-build-proof.d.ts +22 -0
- package/lib/CLI/scripts/expo/eas-build-proof.js +116 -0
- package/lib/CLI/scripts/expo/package-manager.d.ts +11 -0
- package/lib/CLI/scripts/expo/package-manager.js +84 -0
- package/lib/CLI/scripts/expo/write-build-receipt.d.ts +25 -0
- package/lib/CLI/scripts/expo/write-build-receipt.js +325 -0
- package/lib/CLI/scripts/expo/write-eas-build-receipt.d.ts +8 -0
- package/lib/CLI/scripts/expo/write-eas-build-receipt.js +71 -0
- package/lib/CLI/scripts/init-config.d.ts +18 -1
- package/lib/CLI/scripts/init-config.js +29 -8
- package/lib/CLI/scripts/init-metro-config.d.ts +7 -0
- package/lib/CLI/scripts/init-metro-config.js +28 -8
- package/lib/CLI/scripts/login-cli.js +17 -3
- package/lib/CLI/scripts/post-init.d.ts +6 -1
- package/lib/CLI/scripts/post-init.js +6 -33
- package/lib/CLI/scripts/upload-cli.d.ts +1 -0
- package/lib/CLI/scripts/upload-cli.js +106 -36
- package/lib/context.d.ts +0 -2
- package/lib/context.js +18 -2
- package/lib/expo/buildIdentity.d.ts +15 -0
- package/lib/expo/buildIdentity.js +201 -0
- package/lib/expo/buildReceipt.d.ts +42 -0
- package/lib/expo/buildReceipt.js +272 -0
- package/lib/expo/config.d.ts +7 -0
- package/lib/expo/config.js +43 -0
- package/lib/expo/configCache.d.ts +1 -0
- package/lib/expo/configCache.js +20 -0
- package/lib/expo/errors.d.ts +6 -0
- package/lib/expo/errors.js +11 -0
- package/lib/expo/expoUpdatesOwnership.d.ts +13 -0
- package/lib/expo/expoUpdatesOwnership.js +22 -0
- package/lib/expo/exportExpoProject.d.ts +21 -0
- package/lib/expo/exportExpoProject.js +125 -0
- package/lib/expo/exportValidation.d.ts +11 -0
- package/lib/expo/exportValidation.js +115 -0
- package/lib/expo/index.d.ts +18 -0
- package/lib/expo/index.js +25 -0
- package/lib/expo/localModules.d.ts +4 -0
- package/lib/expo/localModules.js +51 -0
- package/lib/expo/nativeIdentity.d.ts +1 -0
- package/lib/expo/nativeIdentity.js +17 -0
- package/lib/expo/projectType.d.ts +7 -0
- package/lib/expo/projectType.js +200 -0
- package/lib/expo/runtimeVersion.d.ts +13 -0
- package/lib/expo/runtimeVersion.js +45 -0
- package/lib/expo/types.d.ts +15 -0
- package/lib/expo/types.js +2 -0
- package/lib/fs/userProperties.d.ts +0 -2
- package/lib/fs/userProperties.js +0 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -2
- package/lib/loadConfig.d.ts +15 -7
- package/lib/loadConfig.js +2 -19
- package/lib/metro.d.ts +17 -0
- package/lib/metro.js +57 -0
- package/lib/native/bundleDropNative.d.ts +2 -0
- package/lib/native/bundleDropNative.js +9 -1
- package/lib/runtime/service.js +12 -1
- package/lib/scripts/bundle.d.ts +2 -2
- package/lib/scripts/bundle.js +10 -97
- package/lib/scripts/canonicalArtifact.d.ts +30 -0
- package/lib/scripts/canonicalArtifact.js +212 -0
- package/lib/scripts/exportProject.d.ts +41 -0
- package/lib/scripts/exportProject.js +82 -0
- package/package.json +51 -46
- package/plugin/constants.js +9 -0
- package/plugin/expoUpdates.js +131 -0
- package/plugin/index.js +11 -0
- package/plugin/markers.js +31 -0
- package/plugin/withBundleDrop.js +36 -0
- package/plugin/xcodeBuildPhase.js +77 -0
- package/react-native.config.js +20 -0
|
@@ -45,6 +45,7 @@ const path = __importStar(require("path"));
|
|
|
45
45
|
const plist = __importStar(require("plist"));
|
|
46
46
|
const ui_1 = require("../utils/ui");
|
|
47
47
|
const resolve_ios_version_1 = require("../../scripts/resolve-ios-version");
|
|
48
|
+
const expo_1 = require("../../expo");
|
|
48
49
|
const DOCS_INSTALLATION_URL = 'https://bundledrop.app/docs/installation';
|
|
49
50
|
const DOCS_UPLOADING_URL = 'https://bundledrop.app/docs/uploading';
|
|
50
51
|
const DOCS_CI_CD_URL = 'https://bundledrop.app/docs/ci-cd';
|
|
@@ -102,6 +103,17 @@ const stringifyUploadError = (err) => {
|
|
|
102
103
|
const raw = err?.response?.data || err.message;
|
|
103
104
|
return typeof raw === 'object' ? JSON.stringify(raw, null, 2) : String(raw);
|
|
104
105
|
};
|
|
106
|
+
const bareArtifactPaths = (packageRoot, platform) => {
|
|
107
|
+
const outputDir = path.join(packageRoot, 'dist');
|
|
108
|
+
return {
|
|
109
|
+
outputDir,
|
|
110
|
+
bundlePath: path.join(outputDir, 'main.jsbundle'),
|
|
111
|
+
sourceMapPath: path.join(outputDir, 'main.jsbundle.map'),
|
|
112
|
+
metadataPath: path.join(outputDir, `metadata-${platform}.json`),
|
|
113
|
+
manifestPath: path.join(outputDir, 'bundle-manifest.json'),
|
|
114
|
+
zipPath: path.join(outputDir, `bundle-${platform}.zip`),
|
|
115
|
+
};
|
|
116
|
+
};
|
|
105
117
|
async function upload(platform, options) {
|
|
106
118
|
console.log(); // blank line
|
|
107
119
|
ui_1.log.info('🚀 React Native OTA Upload Initialized');
|
|
@@ -121,6 +133,25 @@ async function upload(platform, options) {
|
|
|
121
133
|
const serverUrl = config.serverUrl;
|
|
122
134
|
const orgSlug = config.org?.slug;
|
|
123
135
|
const projectSlug = config.project?.slug;
|
|
136
|
+
let detectedProjectType;
|
|
137
|
+
try {
|
|
138
|
+
detectedProjectType = (0, expo_1.detectProjectType)({ projectRoot });
|
|
139
|
+
const usesExpoRuntimePolicy = config.runtimeVersion?.source === 'expo';
|
|
140
|
+
if (detectedProjectType === 'bare' && usesExpoRuntimePolicy) {
|
|
141
|
+
throw new Error('Bare React Native was detected, but bundle.drop.config.js contains a stale Expo runtime marker.');
|
|
142
|
+
}
|
|
143
|
+
if (detectedProjectType === 'expo') {
|
|
144
|
+
(0, expo_1.resolveBundleDropRuntimeVersionAuthority)(projectRoot, 'ios');
|
|
145
|
+
(0, expo_1.resolveBundleDropRuntimeVersionAuthority)(projectRoot, 'android');
|
|
146
|
+
const { exp } = (0, expo_1.evaluateExpoConfig)(projectRoot);
|
|
147
|
+
(0, expo_1.assertExpoUpdatesDoesNotOwnStartup)(projectRoot, exp);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
ui_1.log.error(`❌ Project type validation failed: ${error.message}`);
|
|
152
|
+
process.exit(1);
|
|
153
|
+
}
|
|
154
|
+
const isExpoProject = detectedProjectType === 'expo';
|
|
124
155
|
if (!serverUrl || !projectSlug || !orgSlug) {
|
|
125
156
|
ui_1.log.error(`❌ Missing "serverUrl", "org.slug" or "project.slug" in config\nSee ${DOCS_INSTALLATION_URL}`);
|
|
126
157
|
process.exit(1);
|
|
@@ -147,6 +178,7 @@ async function upload(platform, options) {
|
|
|
147
178
|
ui_1.log.label('Project', projectSlug);
|
|
148
179
|
ui_1.log.label('Channel', channel);
|
|
149
180
|
let version = options.version;
|
|
181
|
+
let expoBuildIdentity;
|
|
150
182
|
const buildGradlePath = options.buildGradlePath || options.buildgradlePath;
|
|
151
183
|
let releaseNotes = options.releaseNotes;
|
|
152
184
|
const MAX_NOTES = 2000;
|
|
@@ -167,7 +199,28 @@ async function upload(platform, options) {
|
|
|
167
199
|
}
|
|
168
200
|
return match[1];
|
|
169
201
|
};
|
|
170
|
-
if (
|
|
202
|
+
if (isExpoProject) {
|
|
203
|
+
if (platform !== 'ios' && platform !== 'android') {
|
|
204
|
+
ui_1.log.error('❌ Expo uploads require platform ios or android');
|
|
205
|
+
process.exit(1);
|
|
206
|
+
}
|
|
207
|
+
try {
|
|
208
|
+
expoBuildIdentity = await require('./expo/build-receipt').resolveExpoUploadIdentity({
|
|
209
|
+
projectRoot,
|
|
210
|
+
platform,
|
|
211
|
+
receiptFile: options.buildReceipt,
|
|
212
|
+
});
|
|
213
|
+
if (version && version !== expoBuildIdentity.appVersion) {
|
|
214
|
+
throw new Error(`--version ${version} does not match the proven Expo build version ${expoBuildIdentity.appVersion}.`);
|
|
215
|
+
}
|
|
216
|
+
version = expoBuildIdentity.appVersion;
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
ui_1.log.error(`❌ ${error.message}\nSee ${DOCS_RUNTIME_VERSION_URL}`);
|
|
220
|
+
process.exit(1);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
else if (platform === 'ios') {
|
|
171
224
|
if (!version) {
|
|
172
225
|
if (!options.plistFile) {
|
|
173
226
|
ui_1.log.error(`❌ Provide --version or --plist-file for iOS\nSee ${DOCS_UPLOADING_URL}`);
|
|
@@ -222,37 +275,50 @@ async function upload(platform, options) {
|
|
|
222
275
|
const packageVersion = readPackageVersion(packageRoot);
|
|
223
276
|
const compiledBundleScript = path.join(packageRoot, 'lib', 'scripts', 'bundle.js');
|
|
224
277
|
const tsBundleScript = path.join(packageRoot, 'src', 'scripts', 'bundle.ts');
|
|
225
|
-
|
|
226
|
-
? `node "${compiledBundleScript}"`
|
|
227
|
-
: `ts-node "${tsBundleScript}"`;
|
|
228
|
-
const sourcemapArg = options.sourcemap ? ' --sourcemap' : '';
|
|
278
|
+
let artifact = bareArtifactPaths(packageRoot, platform);
|
|
229
279
|
try {
|
|
230
|
-
(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
280
|
+
if (isExpoProject) {
|
|
281
|
+
artifact = await require('../../scripts/exportProject').exportProjectArtifact({
|
|
282
|
+
projectRoot,
|
|
283
|
+
platform,
|
|
284
|
+
appVersion: version,
|
|
285
|
+
generateSourceMap: Boolean(options.sourcemap),
|
|
286
|
+
projectType: detectedProjectType,
|
|
287
|
+
buildReceipt: options.buildReceipt,
|
|
288
|
+
buildIdentity: expoBuildIdentity,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
const bundleCommand = fs.existsSync(compiledBundleScript)
|
|
293
|
+
? `node "${compiledBundleScript}"`
|
|
294
|
+
: `ts-node "${tsBundleScript}"`;
|
|
295
|
+
const sourcemapArg = options.sourcemap ? ' --sourcemap' : '';
|
|
296
|
+
(0, child_process_1.execSync)(`${bundleCommand} ${platform}${sourcemapArg}`, {
|
|
297
|
+
stdio: 'inherit',
|
|
298
|
+
env: {
|
|
299
|
+
...process.env,
|
|
300
|
+
BUNDLE_DROP_APP_VERSION: version,
|
|
301
|
+
},
|
|
302
|
+
});
|
|
303
|
+
}
|
|
237
304
|
}
|
|
238
|
-
catch {
|
|
239
|
-
ui_1.log.error(
|
|
305
|
+
catch (error) {
|
|
306
|
+
ui_1.log.error(isExpoProject
|
|
307
|
+
? `❌ Expo export failed: ${error.message}`
|
|
308
|
+
: '❌ Bundling failed');
|
|
240
309
|
process.exit(1);
|
|
241
310
|
}
|
|
242
|
-
const outputDir = path.join(packageRoot, 'dist');
|
|
243
|
-
const manifestPath = path.join(outputDir, 'bundle-manifest.json');
|
|
244
311
|
let runtimeVersion;
|
|
245
312
|
try {
|
|
246
|
-
runtimeVersion = readManifestRuntimeVersion(manifestPath);
|
|
313
|
+
runtimeVersion = readManifestRuntimeVersion(artifact.manifestPath);
|
|
247
314
|
ui_1.log.label('Runtime Version', runtimeVersion);
|
|
248
315
|
}
|
|
249
316
|
catch (error) {
|
|
250
317
|
ui_1.log.error(`❌ ${error.message}\nSee ${DOCS_RUNTIME_VERSION_URL}`);
|
|
251
318
|
process.exit(1);
|
|
252
319
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
ui_1.log.error(`❌ Bundle ZIP not found at: ${zipPath}`);
|
|
320
|
+
if (!fs.existsSync(artifact.zipPath)) {
|
|
321
|
+
ui_1.log.error(`❌ Bundle ZIP not found at: ${artifact.zipPath}`);
|
|
256
322
|
process.exit(1);
|
|
257
323
|
}
|
|
258
324
|
// Build form data
|
|
@@ -272,7 +338,7 @@ async function upload(platform, options) {
|
|
|
272
338
|
if (options.author) {
|
|
273
339
|
form.append('author', options.author);
|
|
274
340
|
}
|
|
275
|
-
form.append('file', fs.createReadStream(zipPath));
|
|
341
|
+
form.append('file', fs.createReadStream(artifact.zipPath));
|
|
276
342
|
const uploadLoader = (0, ui_1.startLoadingStatus)('Uploading bundle to server');
|
|
277
343
|
let uploadSucceeded = false;
|
|
278
344
|
try {
|
|
@@ -284,8 +350,8 @@ async function upload(platform, options) {
|
|
|
284
350
|
maxContentLength: Infinity,
|
|
285
351
|
maxBodyLength: Infinity,
|
|
286
352
|
});
|
|
287
|
-
const
|
|
288
|
-
|
|
353
|
+
const hasSourceMap = options.sourcemap && artifact.sourceMapPath &&
|
|
354
|
+
fs.existsSync(artifact.sourceMapPath);
|
|
289
355
|
const result = {
|
|
290
356
|
platform,
|
|
291
357
|
appVersion: version,
|
|
@@ -304,13 +370,12 @@ async function upload(platform, options) {
|
|
|
304
370
|
if (artifactDir) {
|
|
305
371
|
try {
|
|
306
372
|
fs.mkdirSync(artifactDir, { recursive: true });
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
fs.copyFileSync(bundleFile, path.join(artifactDir, 'main.jsbundle'));
|
|
373
|
+
if (fs.existsSync(artifact.bundlePath)) {
|
|
374
|
+
fs.copyFileSync(artifact.bundlePath, path.join(artifactDir, 'main.jsbundle'));
|
|
310
375
|
result.bundlePath = path.join(artifactDir, 'main.jsbundle');
|
|
311
376
|
}
|
|
312
|
-
if (hasSourceMap) {
|
|
313
|
-
fs.copyFileSync(
|
|
377
|
+
if (hasSourceMap && artifact.sourceMapPath) {
|
|
378
|
+
fs.copyFileSync(artifact.sourceMapPath, path.join(artifactDir, 'main.jsbundle.map'));
|
|
314
379
|
result.sourceMapPath = path.join(artifactDir, 'main.jsbundle.map');
|
|
315
380
|
}
|
|
316
381
|
}
|
|
@@ -326,7 +391,7 @@ async function upload(platform, options) {
|
|
|
326
391
|
ui_1.log.label('Bundle Label', `${result.bundleVersionLabel}`);
|
|
327
392
|
if (result.hash)
|
|
328
393
|
ui_1.log.label('Hash', `${result.hash}`);
|
|
329
|
-
const resultDir = artifactDir ??
|
|
394
|
+
const resultDir = artifactDir ?? artifact.outputDir;
|
|
330
395
|
if (!fs.existsSync(resultDir))
|
|
331
396
|
fs.mkdirSync(resultDir, { recursive: true });
|
|
332
397
|
const resultPath = path.join(resultDir, 'bundle-drop-result.json');
|
|
@@ -361,20 +426,25 @@ async function upload(platform, options) {
|
|
|
361
426
|
finally {
|
|
362
427
|
try {
|
|
363
428
|
const cleanupFiles = [
|
|
364
|
-
zipPath,
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
429
|
+
artifact.zipPath,
|
|
430
|
+
artifact.metadataPath,
|
|
431
|
+
artifact.manifestPath,
|
|
432
|
+
artifact.bundlePath,
|
|
433
|
+
artifact.sourceMapPath,
|
|
369
434
|
];
|
|
370
|
-
const assetsPath = path.join(outputDir, 'assets');
|
|
435
|
+
const assetsPath = path.join(artifact.outputDir, 'assets');
|
|
436
|
+
const expoExportDirectory = artifact.expoExportDirectory ??
|
|
437
|
+
path.join(packageRoot, 'dist', `expo-export-${platform}`);
|
|
371
438
|
for (const file of cleanupFiles) {
|
|
372
|
-
if (fs.existsSync(file))
|
|
439
|
+
if (file && fs.existsSync(file))
|
|
373
440
|
fs.unlinkSync(file);
|
|
374
441
|
}
|
|
375
442
|
if (fs.existsSync(assetsPath)) {
|
|
376
443
|
fs.rmSync(assetsPath, { recursive: true, force: true });
|
|
377
444
|
}
|
|
445
|
+
if (fs.existsSync(expoExportDirectory)) {
|
|
446
|
+
fs.rmSync(expoExportDirectory, { recursive: true, force: true });
|
|
447
|
+
}
|
|
378
448
|
if (uploadSucceeded) {
|
|
379
449
|
console.log();
|
|
380
450
|
ui_1.log.success('🎉 Done! Bundle uploaded and cleaned.');
|
package/lib/context.d.ts
CHANGED
|
@@ -25,8 +25,6 @@ export type BundleDropConfig = {
|
|
|
25
25
|
name: string;
|
|
26
26
|
slug: string;
|
|
27
27
|
};
|
|
28
|
-
/** Whether local debug backend routing is enabled. */
|
|
29
|
-
debugLocal: boolean;
|
|
30
28
|
/** Effective rollback/crash recovery policy with defaults applied. */
|
|
31
29
|
rollback: {
|
|
32
30
|
/** Crash count required before rollback. */
|
package/lib/context.js
CHANGED
|
@@ -7,10 +7,27 @@ exports.bundleDropConfig = exports.BUNDLE_DROP_ROOT = exports.defaultChannel = e
|
|
|
7
7
|
const react_native_1 = require("react-native");
|
|
8
8
|
const fs_1 = __importDefault(require("./native/fs"));
|
|
9
9
|
const loadConfig_1 = require("./loadConfig");
|
|
10
|
+
const nativeIdentity_1 = require("./expo/nativeIdentity");
|
|
11
|
+
const bundleDropNative_1 = require("./native/bundleDropNative");
|
|
10
12
|
exports.config = (0, loadConfig_1.loadConfig)();
|
|
11
13
|
exports.platform = react_native_1.Platform.OS === 'ios' ? 'ios' : 'android';
|
|
12
14
|
exports.isIOS = exports.platform === 'ios';
|
|
13
|
-
|
|
15
|
+
const configuredRuntimeVersion = exports.config.runtimeVersion;
|
|
16
|
+
const platformRuntimeVersion = configuredRuntimeVersion && !('source' in configuredRuntimeVersion)
|
|
17
|
+
? configuredRuntimeVersion[exports.platform]
|
|
18
|
+
: undefined;
|
|
19
|
+
const isExpoDevelopmentWithoutNativeAdapter = exports.config.projectType === 'expo' &&
|
|
20
|
+
typeof __DEV__ !== 'undefined' &&
|
|
21
|
+
__DEV__ &&
|
|
22
|
+
!(0, bundleDropNative_1.isBundleDropNativeAvailable)();
|
|
23
|
+
exports.runtimeVersion = typeof platformRuntimeVersion === 'string'
|
|
24
|
+
? platformRuntimeVersion
|
|
25
|
+
: platformRuntimeVersion?.source === 'appVersion' ||
|
|
26
|
+
platformRuntimeVersion?.source === 'nativeVersion'
|
|
27
|
+
? isExpoDevelopmentWithoutNativeAdapter
|
|
28
|
+
? undefined
|
|
29
|
+
: (0, nativeIdentity_1.resolveExpoNativeRuntimeVersion)(platformRuntimeVersion.source)
|
|
30
|
+
: undefined;
|
|
14
31
|
exports.defaultChannel = exports.config.defaultChannel || 'develop';
|
|
15
32
|
exports.BUNDLE_DROP_ROOT = exports.isIOS
|
|
16
33
|
? `${fs_1.default.LibraryDirectoryPath}/bundle-drop`
|
|
@@ -25,7 +42,6 @@ exports.bundleDropConfig = {
|
|
|
25
42
|
defaultChannel: exports.defaultChannel,
|
|
26
43
|
org: { slug: exports.config.org.slug },
|
|
27
44
|
project: { name: exports.config.project.name, slug: exports.config.project.slug },
|
|
28
|
-
debugLocal: exports.config.debugLocal ?? false,
|
|
29
45
|
rollback: {
|
|
30
46
|
maxCrashCount: exports.config.rollback?.maxCrashCount ?? 3,
|
|
31
47
|
healthCheckMode: exports.config.rollback?.healthCheckMode === 'manual' ? 'manual' : 'auto',
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ExpoBuildIdentity, MobilePlatform } from './types';
|
|
2
|
+
export declare function resolveExpoProjectFingerprint(projectRoot: string, platform: MobilePlatform): Promise<string>;
|
|
3
|
+
export declare function resolveExpoBuildIdentity(projectRoot: string, platform: MobilePlatform, options?: {
|
|
4
|
+
officialAppVersion?: string;
|
|
5
|
+
officialNativeBuildVersion?: string;
|
|
6
|
+
}): Promise<ExpoBuildIdentity>;
|
|
7
|
+
export type ExpoMetroRuntimeVersion = string | {
|
|
8
|
+
source: 'appVersion' | 'nativeVersion';
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* App-derived policies read the signed binary at runtime. This remains exact
|
|
12
|
+
* for remote EAS versions and for committed native projects whose generated
|
|
13
|
+
* version fields have not yet been reconciled with app config.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveExpoMetroRuntimeVersion(projectRoot: string, platform: MobilePlatform): Promise<ExpoMetroRuntimeVersion>;
|
|
@@ -0,0 +1,201 @@
|
|
|
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.resolveExpoProjectFingerprint = resolveExpoProjectFingerprint;
|
|
7
|
+
exports.resolveExpoBuildIdentity = resolveExpoBuildIdentity;
|
|
8
|
+
exports.resolveExpoMetroRuntimeVersion = resolveExpoMetroRuntimeVersion;
|
|
9
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const config_1 = require("./config");
|
|
13
|
+
const errors_1 = require("./errors");
|
|
14
|
+
const localModules_1 = require("./localModules");
|
|
15
|
+
const runtimeVersion_1 = require("./runtimeVersion");
|
|
16
|
+
const MIN_SUPPORTED_EXPO_SDK = 54;
|
|
17
|
+
const MAX_SUPPORTED_EXPO_SDK = 57;
|
|
18
|
+
function requirePackageVersion(projectRoot, moduleId) {
|
|
19
|
+
const manifest = (0, localModules_1.loadProjectModule)(projectRoot, moduleId);
|
|
20
|
+
if (typeof manifest.version !== 'string' || manifest.version.trim() === '') {
|
|
21
|
+
throw new errors_1.ExpoIntegrationError(`${moduleId} does not contain a valid version.`);
|
|
22
|
+
}
|
|
23
|
+
return manifest.version;
|
|
24
|
+
}
|
|
25
|
+
function getExpoSdkMajor(expoVersion) {
|
|
26
|
+
const match = /^(\d+)\./.exec(expoVersion);
|
|
27
|
+
if (!match) {
|
|
28
|
+
throw new errors_1.ExpoIntegrationError(`Could not determine the Expo SDK from expo@${expoVersion}.`);
|
|
29
|
+
}
|
|
30
|
+
return Number(match[1]);
|
|
31
|
+
}
|
|
32
|
+
function assertSupportedExpoSdk(expoVersion) {
|
|
33
|
+
const sdkMajor = getExpoSdkMajor(expoVersion);
|
|
34
|
+
if (sdkMajor < MIN_SUPPORTED_EXPO_SDK || sdkMajor > MAX_SUPPORTED_EXPO_SDK) {
|
|
35
|
+
throw new errors_1.ExpoIntegrationError(`Expo SDK ${sdkMajor} is outside Bundle Drop's supported SDK ` +
|
|
36
|
+
`${MIN_SUPPORTED_EXPO_SDK}-${MAX_SUPPORTED_EXPO_SDK} range.`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function getSelectedRuntimeVersion(config, platform) {
|
|
40
|
+
return config[platform]?.runtimeVersion ?? config.runtimeVersion;
|
|
41
|
+
}
|
|
42
|
+
function getRuntimeVersionPolicy(selectedRuntimeVersion) {
|
|
43
|
+
if (typeof selectedRuntimeVersion === 'string' && selectedRuntimeVersion.trim() !== '') {
|
|
44
|
+
return 'literal';
|
|
45
|
+
}
|
|
46
|
+
if (selectedRuntimeVersion &&
|
|
47
|
+
typeof selectedRuntimeVersion === 'object' &&
|
|
48
|
+
'policy' in selectedRuntimeVersion) {
|
|
49
|
+
const policy = selectedRuntimeVersion.policy;
|
|
50
|
+
if (policy === 'appVersion' ||
|
|
51
|
+
policy === 'nativeVersion' ||
|
|
52
|
+
policy === 'sdkVersion' ||
|
|
53
|
+
policy === 'fingerprint') {
|
|
54
|
+
return policy;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
throw new errors_1.ExpoIntegrationError('Expo runtimeVersion must be a non-empty literal or a supported Expo runtime-version policy.');
|
|
58
|
+
}
|
|
59
|
+
function getJavaScriptEngine(config, platform) {
|
|
60
|
+
const engine = config[platform]?.jsEngine ?? config.jsEngine ?? 'hermes';
|
|
61
|
+
if (engine !== 'hermes' && engine !== 'jsc') {
|
|
62
|
+
throw new errors_1.ExpoIntegrationError(`Unsupported Expo JavaScript engine: ${String(engine)}.`);
|
|
63
|
+
}
|
|
64
|
+
return engine;
|
|
65
|
+
}
|
|
66
|
+
function assertLocalNativeVersionPolicy(projectRoot, runtimeVersionPolicy, hasOfficialNativeBuildVersion) {
|
|
67
|
+
if (runtimeVersionPolicy !== 'nativeVersion' || hasOfficialNativeBuildVersion) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const easConfigPath = path_1.default.join(projectRoot, 'eas.json');
|
|
71
|
+
if (!fs_1.default.existsSync(easConfigPath)) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
let easConfig;
|
|
75
|
+
try {
|
|
76
|
+
easConfig = JSON.parse(fs_1.default.readFileSync(easConfigPath, 'utf8'));
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
throw new errors_1.ExpoIntegrationError('eas.json could not be parsed while checking native versioning.', {
|
|
80
|
+
cause: error,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (easConfig.cli?.appVersionSource === 'remote') {
|
|
84
|
+
throw new errors_1.ExpoIntegrationError('The nativeVersion runtime policy uses remote EAS app versions. ' +
|
|
85
|
+
'An exact build receipt or an officially resolved EAS value is required; Bundle Drop will not guess it.');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function applyOfficialBuildVersions(config, platform, versions) {
|
|
89
|
+
const { appVersion, appBuildVersion } = versions;
|
|
90
|
+
if (appVersion !== undefined && !appVersion.trim()) {
|
|
91
|
+
throw new errors_1.ExpoIntegrationError('The official app version is empty.');
|
|
92
|
+
}
|
|
93
|
+
if (appBuildVersion !== undefined && !appBuildVersion.trim()) {
|
|
94
|
+
throw new errors_1.ExpoIntegrationError('The official EAS app build version is empty.');
|
|
95
|
+
}
|
|
96
|
+
const platformConfig = { ...(config[platform] || {}) };
|
|
97
|
+
if (appVersion !== undefined)
|
|
98
|
+
platformConfig.version = appVersion;
|
|
99
|
+
if (platform === 'ios' && appBuildVersion !== undefined) {
|
|
100
|
+
platformConfig.buildNumber = appBuildVersion;
|
|
101
|
+
}
|
|
102
|
+
else if (platform === 'android' && appBuildVersion !== undefined) {
|
|
103
|
+
if (!/^\d+$/.test(appBuildVersion)) {
|
|
104
|
+
throw new errors_1.ExpoIntegrationError('The official Android EAS app build version is not a version code.');
|
|
105
|
+
}
|
|
106
|
+
platformConfig.versionCode = Number(appBuildVersion);
|
|
107
|
+
}
|
|
108
|
+
return { ...config, [platform]: platformConfig };
|
|
109
|
+
}
|
|
110
|
+
async function resolveExpoProjectFingerprint(projectRoot, platform) {
|
|
111
|
+
const fingerprintModule = (0, localModules_1.loadExpoDependency)(projectRoot, '@expo/fingerprint');
|
|
112
|
+
if (typeof fingerprintModule.createFingerprintAsync !== 'function') {
|
|
113
|
+
throw new errors_1.ExpoIntegrationError('The project-local @expo/fingerprint package does not export createFingerprintAsync().');
|
|
114
|
+
}
|
|
115
|
+
const fingerprint = await fingerprintModule.createFingerprintAsync(projectRoot, {
|
|
116
|
+
platforms: [platform],
|
|
117
|
+
});
|
|
118
|
+
if (typeof fingerprint.hash !== 'string' || fingerprint.hash.trim() === '') {
|
|
119
|
+
throw new errors_1.ExpoIntegrationError('Expo fingerprint resolution did not return a concrete hash.');
|
|
120
|
+
}
|
|
121
|
+
return fingerprint.hash;
|
|
122
|
+
}
|
|
123
|
+
function hashIdentity(identity) {
|
|
124
|
+
return crypto_1.default.createHash('sha256').update(JSON.stringify(identity)).digest('hex');
|
|
125
|
+
}
|
|
126
|
+
async function resolveExpoBuildIdentity(projectRoot, platform, options = {}) {
|
|
127
|
+
if (platform !== 'ios' && platform !== 'android') {
|
|
128
|
+
throw new errors_1.ExpoIntegrationError(`Unsupported mobile platform: ${String(platform)}.`);
|
|
129
|
+
}
|
|
130
|
+
const absoluteProjectRoot = path_1.default.resolve(projectRoot);
|
|
131
|
+
const evaluated = (0, config_1.evaluateExpoConfig)(absoluteProjectRoot).exp;
|
|
132
|
+
const expoSdkVersion = requirePackageVersion(absoluteProjectRoot, 'expo/package.json');
|
|
133
|
+
const reactNativeVersion = requirePackageVersion(absoluteProjectRoot, 'react-native/package.json');
|
|
134
|
+
assertSupportedExpoSdk(expoSdkVersion);
|
|
135
|
+
const selectedRuntimeVersion = getSelectedRuntimeVersion(evaluated, platform);
|
|
136
|
+
const runtimeAuthority = (0, runtimeVersion_1.resolveBundleDropRuntimeVersionAuthority)(absoluteProjectRoot, platform);
|
|
137
|
+
const runtimeVersionPolicy = runtimeAuthority.source === 'bundle-drop'
|
|
138
|
+
? 'literal'
|
|
139
|
+
: getRuntimeVersionPolicy(selectedRuntimeVersion);
|
|
140
|
+
const officialNativeBuildVersion = options.officialNativeBuildVersion;
|
|
141
|
+
assertLocalNativeVersionPolicy(absoluteProjectRoot, runtimeVersionPolicy, officialNativeBuildVersion !== undefined);
|
|
142
|
+
const exp = options.officialAppVersion !== undefined || officialNativeBuildVersion !== undefined
|
|
143
|
+
? applyOfficialBuildVersions(evaluated, platform, {
|
|
144
|
+
appVersion: options.officialAppVersion,
|
|
145
|
+
appBuildVersion: officialNativeBuildVersion,
|
|
146
|
+
})
|
|
147
|
+
: evaluated;
|
|
148
|
+
const updatesUtilities = (0, localModules_1.loadExpoDependency)(absoluteProjectRoot, '@expo/config-plugins/build/utils/Updates');
|
|
149
|
+
if (typeof updatesUtilities.getAppVersion !== 'function' ||
|
|
150
|
+
typeof updatesUtilities.getNativeVersion !== 'function') {
|
|
151
|
+
throw new errors_1.ExpoIntegrationError('The project-local Expo runtime-version utilities are incomplete or incompatible.');
|
|
152
|
+
}
|
|
153
|
+
let runtimeVersion = runtimeAuthority.source === 'bundle-drop'
|
|
154
|
+
? runtimeAuthority.runtimeVersion
|
|
155
|
+
: null;
|
|
156
|
+
if (runtimeAuthority.source === 'expo') {
|
|
157
|
+
if (typeof updatesUtilities.getRuntimeVersionAsync !== 'function') {
|
|
158
|
+
throw new errors_1.ExpoIntegrationError('The project-local Expo runtime-version utilities are incomplete or incompatible.');
|
|
159
|
+
}
|
|
160
|
+
runtimeVersion = await updatesUtilities.getRuntimeVersionAsync(absoluteProjectRoot, exp, platform);
|
|
161
|
+
const fingerprintSentinel = updatesUtilities.FINGERPRINT_RUNTIME_VERSION_SENTINEL ?? 'file:fingerprint';
|
|
162
|
+
if (runtimeVersionPolicy === 'fingerprint' || runtimeVersion === fingerprintSentinel) {
|
|
163
|
+
runtimeVersion = await resolveExpoProjectFingerprint(absoluteProjectRoot, platform);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (typeof runtimeVersion !== 'string' || runtimeVersion.trim() === '') {
|
|
167
|
+
throw new errors_1.ExpoIntegrationError('Expo did not resolve a concrete runtime version for this build.');
|
|
168
|
+
}
|
|
169
|
+
const identityWithoutHash = {
|
|
170
|
+
platform,
|
|
171
|
+
runtimeVersion,
|
|
172
|
+
runtimeVersionPolicy,
|
|
173
|
+
expoSdkVersion,
|
|
174
|
+
reactNativeVersion,
|
|
175
|
+
javaScriptEngine: getJavaScriptEngine(exp, platform),
|
|
176
|
+
appVersion: updatesUtilities.getAppVersion(exp, platform),
|
|
177
|
+
nativeVersion: updatesUtilities.getNativeVersion(exp, platform),
|
|
178
|
+
};
|
|
179
|
+
return {
|
|
180
|
+
...identityWithoutHash,
|
|
181
|
+
identityHash: hashIdentity(identityWithoutHash),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* App-derived policies read the signed binary at runtime. This remains exact
|
|
186
|
+
* for remote EAS versions and for committed native projects whose generated
|
|
187
|
+
* version fields have not yet been reconciled with app config.
|
|
188
|
+
*/
|
|
189
|
+
async function resolveExpoMetroRuntimeVersion(projectRoot, platform) {
|
|
190
|
+
const absoluteProjectRoot = path_1.default.resolve(projectRoot);
|
|
191
|
+
const runtimeAuthority = (0, runtimeVersion_1.resolveBundleDropRuntimeVersionAuthority)(absoluteProjectRoot, platform);
|
|
192
|
+
if (runtimeAuthority.source === 'bundle-drop') {
|
|
193
|
+
return runtimeAuthority.runtimeVersion;
|
|
194
|
+
}
|
|
195
|
+
const exp = (0, config_1.evaluateExpoConfig)(absoluteProjectRoot).exp;
|
|
196
|
+
const policy = getRuntimeVersionPolicy(getSelectedRuntimeVersion(exp, platform));
|
|
197
|
+
if (policy === 'appVersion' || policy === 'nativeVersion') {
|
|
198
|
+
return { source: policy };
|
|
199
|
+
}
|
|
200
|
+
return (await resolveExpoBuildIdentity(absoluteProjectRoot, platform)).runtimeVersion;
|
|
201
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ExpoBuildIdentity } from './types';
|
|
2
|
+
export type ExpoBuildProofEvidence = 'ios-signed-app' | 'android-signed-artifact' | 'eas-official-metadata';
|
|
3
|
+
type ExpoBuildProofBase = {
|
|
4
|
+
createdAt: string;
|
|
5
|
+
evidence: ExpoBuildProofEvidence;
|
|
6
|
+
integrationGeneration: string;
|
|
7
|
+
};
|
|
8
|
+
export type ExpoIosLocalBuildProof = ExpoBuildProofBase & {
|
|
9
|
+
evidence: 'ios-signed-app';
|
|
10
|
+
artifactPath: string;
|
|
11
|
+
embeddedCandidateSha256: string;
|
|
12
|
+
};
|
|
13
|
+
export type ExpoAndroidLocalBuildProof = ExpoBuildProofBase & {
|
|
14
|
+
evidence: 'android-signed-artifact';
|
|
15
|
+
artifactPath: string;
|
|
16
|
+
artifactSha256: string;
|
|
17
|
+
embeddedCandidateSha256: string;
|
|
18
|
+
};
|
|
19
|
+
export type ExpoEasBuildProof = ExpoBuildProofBase & {
|
|
20
|
+
evidence: 'eas-official-metadata';
|
|
21
|
+
easBuildId: string;
|
|
22
|
+
};
|
|
23
|
+
export type ExpoBuildPlatformProof = ExpoIosLocalBuildProof | ExpoAndroidLocalBuildProof | ExpoEasBuildProof;
|
|
24
|
+
export type ExpoBuildIdentityReceipt = {
|
|
25
|
+
schemaVersion: 3;
|
|
26
|
+
identities: {
|
|
27
|
+
ios?: ExpoBuildIdentity;
|
|
28
|
+
android?: ExpoBuildIdentity;
|
|
29
|
+
};
|
|
30
|
+
proofs: {
|
|
31
|
+
ios?: ExpoBuildPlatformProof;
|
|
32
|
+
android?: ExpoBuildPlatformProof;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Hashes the packed source, build, configuration, and proof inputs that can
|
|
37
|
+
* alter the Expo native integration or its signed build evidence.
|
|
38
|
+
* A receipt from a different adapter generation must not authorize an upload.
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveExpoIntegrationGeneration(packageRoot?: string): string;
|
|
41
|
+
export declare function parseExpoBuildIdentityReceipt(value: unknown, expectedIntegrationGeneration?: string): ExpoBuildIdentityReceipt;
|
|
42
|
+
export {};
|