@gfean/react-native-bundle-drop 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +151 -56
- package/lib/CLI/logo.js +1 -1
- package/lib/CLI/scripts/aipowered/apply-setup-plan.d.ts +12 -0
- package/lib/CLI/scripts/aipowered/{apply-plan.js → apply-setup-plan.js} +24 -19
- package/lib/CLI/scripts/aipowered/backend-client.d.ts +4 -4
- package/lib/CLI/scripts/aipowered/backend-client.js +7 -7
- package/lib/CLI/scripts/aipowered/init-project-config.d.ts +17 -0
- package/lib/CLI/scripts/aipowered/init-project-config.js +418 -0
- package/lib/CLI/scripts/aipowered/scanner.d.ts +10 -3
- package/lib/CLI/scripts/aipowered/scanner.js +225 -201
- package/lib/CLI/scripts/aipowered/types.d.ts +37 -33
- package/lib/CLI/scripts/aipowered/validate-plan.d.ts +9 -2
- package/lib/CLI/scripts/aipowered/validate-plan.js +70 -119
- package/lib/CLI/scripts/bare-metro-config.d.ts +7 -0
- package/lib/CLI/scripts/{init-metro-config.js → bare-metro-config.js} +16 -30
- package/lib/CLI/scripts/doctor.d.ts +17 -0
- package/lib/CLI/scripts/doctor.js +410 -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/login-cli.js +21 -3
- package/lib/CLI/scripts/native-setup-contract.d.ts +7 -0
- package/lib/CLI/scripts/native-setup-contract.js +101 -0
- 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 +15 -0
- package/lib/CLI/scripts/aipowered/apply-plan.d.ts +0 -10
- package/lib/CLI/scripts/aipowered/init-native-config.d.ts +0 -2
- package/lib/CLI/scripts/aipowered/init-native-config.js +0 -131
- package/lib/CLI/scripts/init-metro-config.d.ts +0 -2
|
@@ -0,0 +1,272 @@
|
|
|
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.resolveExpoIntegrationGeneration = resolveExpoIntegrationGeneration;
|
|
7
|
+
exports.parseExpoBuildIdentityReceipt = parseExpoBuildIdentityReceipt;
|
|
8
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const PACKED_INTEGRATION_FILES = [
|
|
12
|
+
'app.plugin.js',
|
|
13
|
+
'expo-module.config.json',
|
|
14
|
+
'react-native.config.js',
|
|
15
|
+
'BundleDrop.podspec',
|
|
16
|
+
'BundleDropExpo.podspec',
|
|
17
|
+
'android/build.gradle',
|
|
18
|
+
'android/gradle.properties',
|
|
19
|
+
'expo/android/build.gradle',
|
|
20
|
+
'expo/bundle-drop-expo-gradle-plugin/build.gradle',
|
|
21
|
+
'lib/CLI/scripts/expo/build-receipt.js',
|
|
22
|
+
'lib/CLI/scripts/expo/eas-build-proof.js',
|
|
23
|
+
'lib/CLI/scripts/expo/write-build-receipt.js',
|
|
24
|
+
'lib/CLI/scripts/expo/write-eas-build-receipt.js',
|
|
25
|
+
'lib/expo/buildIdentity.js',
|
|
26
|
+
'lib/expo/buildReceipt.js',
|
|
27
|
+
'lib/expo/config.js',
|
|
28
|
+
'lib/expo/configCache.js',
|
|
29
|
+
'lib/expo/errors.js',
|
|
30
|
+
'lib/expo/index.js',
|
|
31
|
+
'lib/expo/localModules.js',
|
|
32
|
+
'lib/expo/runtimeVersion.js',
|
|
33
|
+
'third_party/xdelta/bundle_drop_xdelta.c',
|
|
34
|
+
'third_party/xdelta/bundle_drop_xdelta.h',
|
|
35
|
+
'third_party/xdelta/xdelta3/config.h',
|
|
36
|
+
'third_party/xdelta/xdelta3/xdelta3-cfgs.h',
|
|
37
|
+
'third_party/xdelta/xdelta3/xdelta3-decode.h',
|
|
38
|
+
'third_party/xdelta/xdelta3/xdelta3-hash.h',
|
|
39
|
+
'third_party/xdelta/xdelta3/xdelta3-internal.h',
|
|
40
|
+
'third_party/xdelta/xdelta3/xdelta3-list.h',
|
|
41
|
+
'third_party/xdelta/xdelta3/xdelta3.c',
|
|
42
|
+
'third_party/xdelta/xdelta3/xdelta3.h',
|
|
43
|
+
];
|
|
44
|
+
const PACKED_INTEGRATION_DIRECTORIES = [
|
|
45
|
+
{
|
|
46
|
+
relativePath: 'plugin',
|
|
47
|
+
recursive: false,
|
|
48
|
+
includeFile: relativePath => !relativePath.includes('/') && relativePath.endsWith('.js'),
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
relativePath: 'expo/android/src/main',
|
|
52
|
+
recursive: true,
|
|
53
|
+
includeFile: () => true,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
relativePath: 'expo/bundle-drop-expo-gradle-plugin/src/main',
|
|
57
|
+
recursive: true,
|
|
58
|
+
includeFile: () => true,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
relativePath: 'expo/ios/Sources',
|
|
62
|
+
recursive: true,
|
|
63
|
+
includeFile: () => true,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
relativePath: 'android/src/main',
|
|
67
|
+
recursive: true,
|
|
68
|
+
includeFile: () => true,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
relativePath: 'ios',
|
|
72
|
+
recursive: false,
|
|
73
|
+
includeFile: relativePath => !relativePath.includes('/') && /\.(?:h|m|mm|swift)$/.test(relativePath),
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
const PACKAGE_DISCRIMINATOR_PATH = 'package.json#native-version';
|
|
77
|
+
const EXPECTED_PACKAGE_NAME = '@gfean/react-native-bundle-drop';
|
|
78
|
+
const isRecord = (value) => Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
79
|
+
const sha256 = (content) => crypto_1.default.createHash('sha256').update(content).digest('hex');
|
|
80
|
+
const EAS_BUILD_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
81
|
+
const defaultPackageRoot = () => path_1.default.resolve(__dirname, '..', '..');
|
|
82
|
+
const toPortablePath = (value) => value.split(path_1.default.sep).join('/');
|
|
83
|
+
const comparePortablePaths = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
84
|
+
const readRequiredPackedFile = (packageRoot, relativePath) => {
|
|
85
|
+
const absolutePath = path_1.default.join(packageRoot, relativePath);
|
|
86
|
+
if (!fs_1.default.existsSync(absolutePath)) {
|
|
87
|
+
throw new Error(`Packed Bundle Drop Expo integration is missing ${relativePath}.`);
|
|
88
|
+
}
|
|
89
|
+
const fileStat = fs_1.default.lstatSync(absolutePath);
|
|
90
|
+
if (!fileStat.isFile() || fileStat.isSymbolicLink()) {
|
|
91
|
+
throw new Error(`Packed Bundle Drop Expo integration has an unsupported entry at ${relativePath}.`);
|
|
92
|
+
}
|
|
93
|
+
return { relativePath, content: fs_1.default.readFileSync(absolutePath) };
|
|
94
|
+
};
|
|
95
|
+
const collectPackedDirectoryFiles = (packageRoot, boundary) => {
|
|
96
|
+
const directoryPath = path_1.default.join(packageRoot, boundary.relativePath);
|
|
97
|
+
if (!fs_1.default.existsSync(directoryPath)) {
|
|
98
|
+
throw new Error(`Packed Bundle Drop Expo integration is missing ${boundary.relativePath}.`);
|
|
99
|
+
}
|
|
100
|
+
const directoryStat = fs_1.default.lstatSync(directoryPath);
|
|
101
|
+
if (!directoryStat.isDirectory() || directoryStat.isSymbolicLink()) {
|
|
102
|
+
throw new Error(`Packed Bundle Drop Expo integration has an unsupported entry at ${boundary.relativePath}.`);
|
|
103
|
+
}
|
|
104
|
+
const files = [];
|
|
105
|
+
const visit = (absoluteDirectory, relativeDirectory) => {
|
|
106
|
+
const entries = fs_1.default.readdirSync(absoluteDirectory, { withFileTypes: true })
|
|
107
|
+
.sort((left, right) => comparePortablePaths(left.name, right.name));
|
|
108
|
+
for (const entry of entries) {
|
|
109
|
+
const relativeToBoundary = toPortablePath(path_1.default.join(relativeDirectory, entry.name));
|
|
110
|
+
const relativeToPackage = toPortablePath(path_1.default.join(boundary.relativePath, relativeToBoundary));
|
|
111
|
+
const absoluteEntry = path_1.default.join(absoluteDirectory, entry.name);
|
|
112
|
+
if (entry.isSymbolicLink()) {
|
|
113
|
+
throw new Error(`Packed Bundle Drop Expo integration has an unsupported entry at ${relativeToPackage}.`);
|
|
114
|
+
}
|
|
115
|
+
if (entry.isDirectory()) {
|
|
116
|
+
if (boundary.recursive)
|
|
117
|
+
visit(absoluteEntry, relativeToBoundary);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (!entry.isFile()) {
|
|
121
|
+
throw new Error(`Packed Bundle Drop Expo integration has an unsupported entry at ${relativeToPackage}.`);
|
|
122
|
+
}
|
|
123
|
+
if (boundary.includeFile(relativeToBoundary)) {
|
|
124
|
+
files.push({ relativePath: relativeToPackage, content: fs_1.default.readFileSync(absoluteEntry) });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
visit(directoryPath, '');
|
|
129
|
+
if (files.length === 0) {
|
|
130
|
+
throw new Error(`Packed Bundle Drop Expo integration has no packed files under ${boundary.relativePath}.`);
|
|
131
|
+
}
|
|
132
|
+
return files;
|
|
133
|
+
};
|
|
134
|
+
const readPackageNativeVersionDiscriminator = (packageRoot) => {
|
|
135
|
+
const packageJson = readRequiredPackedFile(packageRoot, 'package.json');
|
|
136
|
+
let value;
|
|
137
|
+
try {
|
|
138
|
+
value = JSON.parse(packageJson.content.toString('utf8'));
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
throw new Error('Packed Bundle Drop package.json is malformed.');
|
|
142
|
+
}
|
|
143
|
+
if (!isRecord(value) || value.name !== EXPECTED_PACKAGE_NAME) {
|
|
144
|
+
throw new Error(`Packed Bundle Drop package.json must identify ${EXPECTED_PACKAGE_NAME}.`);
|
|
145
|
+
}
|
|
146
|
+
if (typeof value.version !== 'string' || !value.version.trim()) {
|
|
147
|
+
throw new Error('Packed Bundle Drop package.json has no package version.');
|
|
148
|
+
}
|
|
149
|
+
const nativeVersion = value.nativeVersion === undefined ? value.version : value.nativeVersion;
|
|
150
|
+
if (typeof nativeVersion !== 'string' || !nativeVersion.trim()) {
|
|
151
|
+
throw new Error('Packed Bundle Drop package.json has no native version discriminator.');
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
relativePath: PACKAGE_DISCRIMINATOR_PATH,
|
|
155
|
+
content: Buffer.from(JSON.stringify({ name: value.name, nativeVersion }), 'utf8'),
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
const collectPackedIntegrationInputs = (packageRoot) => {
|
|
159
|
+
const inputs = PACKED_INTEGRATION_FILES.map(relativePath => readRequiredPackedFile(packageRoot, relativePath));
|
|
160
|
+
for (const boundary of PACKED_INTEGRATION_DIRECTORIES) {
|
|
161
|
+
inputs.push(...collectPackedDirectoryFiles(packageRoot, boundary));
|
|
162
|
+
}
|
|
163
|
+
inputs.push(readPackageNativeVersionDiscriminator(packageRoot));
|
|
164
|
+
return inputs.sort((left, right) => comparePortablePaths(left.relativePath, right.relativePath));
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Hashes the packed source, build, configuration, and proof inputs that can
|
|
168
|
+
* alter the Expo native integration or its signed build evidence.
|
|
169
|
+
* A receipt from a different adapter generation must not authorize an upload.
|
|
170
|
+
*/
|
|
171
|
+
function resolveExpoIntegrationGeneration(packageRoot = defaultPackageRoot()) {
|
|
172
|
+
const digest = crypto_1.default.createHash('sha256');
|
|
173
|
+
digest.update('bundle-drop-expo-integration-generation-v2');
|
|
174
|
+
digest.update('\0');
|
|
175
|
+
for (const input of collectPackedIntegrationInputs(packageRoot)) {
|
|
176
|
+
digest.update(input.relativePath);
|
|
177
|
+
digest.update('\0');
|
|
178
|
+
digest.update(String(input.content.length));
|
|
179
|
+
digest.update('\0');
|
|
180
|
+
digest.update(input.content);
|
|
181
|
+
digest.update('\0');
|
|
182
|
+
}
|
|
183
|
+
return `sha256:${digest.digest('hex')}`;
|
|
184
|
+
}
|
|
185
|
+
const assertIdentity = (platform, value) => {
|
|
186
|
+
if (!isRecord(value) || value.platform !== platform || typeof value.identityHash !== 'string') {
|
|
187
|
+
throw new Error(`Bundle Drop build identity receipt has an invalid ${platform} identity.`);
|
|
188
|
+
}
|
|
189
|
+
const { identityHash, ...identityWithoutHash } = value;
|
|
190
|
+
if (sha256(JSON.stringify(identityWithoutHash)) !== identityHash) {
|
|
191
|
+
throw new Error(`Bundle Drop build identity receipt has an invalid ${platform} identity hash.`);
|
|
192
|
+
}
|
|
193
|
+
return value;
|
|
194
|
+
};
|
|
195
|
+
const assertProof = (params) => {
|
|
196
|
+
if (!isRecord(params.value)) {
|
|
197
|
+
throw new Error(`Bundle Drop build identity receipt has no ${params.platform} build proof.`);
|
|
198
|
+
}
|
|
199
|
+
const { createdAt, evidence, integrationGeneration, easBuildId, artifactPath, artifactSha256, embeddedCandidateSha256, } = params.value;
|
|
200
|
+
if (typeof createdAt !== 'string' || Number.isNaN(Date.parse(createdAt))) {
|
|
201
|
+
throw new Error(`Bundle Drop build identity receipt has an invalid ${params.platform} proof date.`);
|
|
202
|
+
}
|
|
203
|
+
const localEvidence = params.platform === 'ios'
|
|
204
|
+
? 'ios-signed-app'
|
|
205
|
+
: 'android-signed-artifact';
|
|
206
|
+
if (evidence !== localEvidence && evidence !== 'eas-official-metadata') {
|
|
207
|
+
throw new Error(`Bundle Drop build identity receipt has invalid ${params.platform} evidence.`);
|
|
208
|
+
}
|
|
209
|
+
if (integrationGeneration !== params.expectedIntegrationGeneration) {
|
|
210
|
+
throw new Error(`Bundle Drop ${params.platform} build proof belongs to a different Expo integration generation. ` +
|
|
211
|
+
'Create a new native build before uploading.');
|
|
212
|
+
}
|
|
213
|
+
if (evidence === 'eas-official-metadata') {
|
|
214
|
+
if (typeof easBuildId !== 'string' || !EAS_BUILD_ID.test(easBuildId)) {
|
|
215
|
+
throw new Error(`Bundle Drop ${params.platform} EAS build proof must include its exact easBuildId.`);
|
|
216
|
+
}
|
|
217
|
+
if (artifactPath !== undefined || artifactSha256 !== undefined || embeddedCandidateSha256 !== undefined) {
|
|
218
|
+
throw new Error(`Bundle Drop ${params.platform} EAS build proof cannot include local artifact fields.`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
if (easBuildId !== undefined) {
|
|
223
|
+
throw new Error(`Bundle Drop local ${params.platform} build proof cannot include an easBuildId.`);
|
|
224
|
+
}
|
|
225
|
+
if (typeof artifactPath !== 'string' || !path_1.default.isAbsolute(artifactPath)) {
|
|
226
|
+
throw new Error(`Bundle Drop local ${params.platform} build proof requires an absolute artifactPath.`);
|
|
227
|
+
}
|
|
228
|
+
if (params.platform === 'android') {
|
|
229
|
+
if (typeof artifactSha256 !== 'string' || !/^[a-f0-9]{64}$/.test(artifactSha256)) {
|
|
230
|
+
throw new Error('Bundle Drop Android build proof has an invalid artifact SHA-256.');
|
|
231
|
+
}
|
|
232
|
+
if (typeof embeddedCandidateSha256 !== 'string' || !/^[a-f0-9]{64}$/.test(embeddedCandidateSha256)) {
|
|
233
|
+
throw new Error('Bundle Drop Android build proof has an invalid embedded candidate SHA-256.');
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
if (typeof embeddedCandidateSha256 !== 'string' || !/^[a-f0-9]{64}$/.test(embeddedCandidateSha256)) {
|
|
238
|
+
throw new Error('Bundle Drop iOS build proof has an invalid embedded candidate SHA-256.');
|
|
239
|
+
}
|
|
240
|
+
if (artifactSha256 !== undefined) {
|
|
241
|
+
throw new Error('Bundle Drop iOS build proof cannot include an Android artifact hash.');
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return params.value;
|
|
246
|
+
};
|
|
247
|
+
function parseExpoBuildIdentityReceipt(value, expectedIntegrationGeneration = resolveExpoIntegrationGeneration()) {
|
|
248
|
+
if (!isRecord(value) || value.schemaVersion !== 3 || !isRecord(value.identities) || !isRecord(value.proofs)) {
|
|
249
|
+
throw new Error('Bundle Drop build identity receipt is incomplete or unsupported.');
|
|
250
|
+
}
|
|
251
|
+
const identities = {};
|
|
252
|
+
const proofs = {};
|
|
253
|
+
for (const platform of ['ios', 'android']) {
|
|
254
|
+
const identityValue = value.identities[platform];
|
|
255
|
+
const proofValue = value.proofs[platform];
|
|
256
|
+
if (identityValue === undefined && proofValue === undefined)
|
|
257
|
+
continue;
|
|
258
|
+
if (identityValue === undefined || proofValue === undefined) {
|
|
259
|
+
throw new Error(`Bundle Drop build identity receipt has incomplete ${platform} build proof.`);
|
|
260
|
+
}
|
|
261
|
+
identities[platform] = assertIdentity(platform, identityValue);
|
|
262
|
+
proofs[platform] = assertProof({
|
|
263
|
+
platform,
|
|
264
|
+
value: proofValue,
|
|
265
|
+
expectedIntegrationGeneration,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
if (!identities.ios && !identities.android) {
|
|
269
|
+
throw new Error('Bundle Drop build identity receipt is incomplete or unsupported.');
|
|
270
|
+
}
|
|
271
|
+
return { schemaVersion: 3, identities, proofs };
|
|
272
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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.evaluateExpoConfig = evaluateExpoConfig;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const errors_1 = require("./errors");
|
|
9
|
+
const localModules_1 = require("./localModules");
|
|
10
|
+
const configCache_1 = require("./configCache");
|
|
11
|
+
function evaluateExpoConfig(projectRoot) {
|
|
12
|
+
const absoluteProjectRoot = path_1.default.resolve(projectRoot);
|
|
13
|
+
(0, configCache_1.clearDynamicExpoConfigCache)(absoluteProjectRoot);
|
|
14
|
+
let configModule;
|
|
15
|
+
try {
|
|
16
|
+
configModule = (0, localModules_1.loadExpoDependency)(absoluteProjectRoot, '@expo/config');
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
throw new errors_1.ExpoIntegrationError(`Expo is installed in ${absoluteProjectRoot}, but its project-local @expo/config API is unavailable.`, { cause: error });
|
|
20
|
+
}
|
|
21
|
+
if (typeof configModule.getConfig !== 'function') {
|
|
22
|
+
throw new errors_1.ExpoIntegrationError('The project-local @expo/config package does not export getConfig().');
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const evaluated = configModule.getConfig(absoluteProjectRoot, {
|
|
26
|
+
skipSDKVersionRequirement: true,
|
|
27
|
+
isPublicConfig: false,
|
|
28
|
+
});
|
|
29
|
+
if (!evaluated || typeof evaluated.exp !== 'object' || evaluated.exp === null) {
|
|
30
|
+
throw new errors_1.ExpoIntegrationError('The evaluated Expo config did not contain an Expo config object.');
|
|
31
|
+
}
|
|
32
|
+
if (!evaluated.pkg || typeof evaluated.pkg !== 'object') {
|
|
33
|
+
throw new errors_1.ExpoIntegrationError('The evaluated Expo config did not contain the project package.json.');
|
|
34
|
+
}
|
|
35
|
+
return evaluated;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error instanceof errors_1.ExpoIntegrationError) {
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
throw new errors_1.ExpoIntegrationError(`Expo config evaluation failed for ${absoluteProjectRoot}. Fix the config before Bundle Drop setup continues.`, { cause: error });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function clearDynamicExpoConfigCache(projectRoot: string): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
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.clearDynamicExpoConfigCache = clearDynamicExpoConfigCache;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const module_1 = require("module");
|
|
10
|
+
const dynamicExpoConfigExtensions = ['js', 'cjs', 'mjs', 'ts', 'cts', 'mts'];
|
|
11
|
+
function clearDynamicExpoConfigCache(projectRoot) {
|
|
12
|
+
const projectRequire = (0, module_1.createRequire)(path_1.default.join(projectRoot, 'package.json'));
|
|
13
|
+
for (const extension of dynamicExpoConfigExtensions) {
|
|
14
|
+
const configPath = path_1.default.join(projectRoot, `app.config.${extension}`);
|
|
15
|
+
delete projectRequire.cache[configPath];
|
|
16
|
+
if (fs_1.default.existsSync(configPath)) {
|
|
17
|
+
delete projectRequire.cache[fs_1.default.realpathSync(configPath)];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExpoIntegrationError = void 0;
|
|
4
|
+
class ExpoIntegrationError extends Error {
|
|
5
|
+
constructor(message, options) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'ExpoIntegrationError';
|
|
8
|
+
this.cause = options?.cause;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.ExpoIntegrationError = ExpoIntegrationError;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type ExpoUpdatesState = 'absent' | 'disabled' | 'active';
|
|
2
|
+
export type ExpoUpdatesOwnership = {
|
|
3
|
+
state: ExpoUpdatesState;
|
|
4
|
+
packageIsInstalled: boolean;
|
|
5
|
+
packageIsDeclared: boolean;
|
|
6
|
+
pluginIsDeclared: boolean;
|
|
7
|
+
hasUpdatesUrl: boolean;
|
|
8
|
+
explicitlyEnabled: boolean;
|
|
9
|
+
explicitlyDisabled: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function inspectExpoUpdatesOwnership(projectRoot: string, evaluatedExpoConfig: Record<string, any>): ExpoUpdatesOwnership;
|
|
12
|
+
export declare function assertExpoUpdatesDoesNotOwnStartup(projectRoot: string, evaluatedExpoConfig: Record<string, any>): ExpoUpdatesOwnership;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.inspectExpoUpdatesOwnership = inspectExpoUpdatesOwnership;
|
|
4
|
+
exports.assertExpoUpdatesDoesNotOwnStartup = assertExpoUpdatesDoesNotOwnStartup;
|
|
5
|
+
// The config plugin and the TypeScript CLI deliberately share this pure module.
|
|
6
|
+
// Keeping ownership classification here prevents setup, doctor, export, and the
|
|
7
|
+
// generated native integration from disagreeing about who controls startup.
|
|
8
|
+
const expoUpdatesOwnership = require('../../plugin/expoUpdates');
|
|
9
|
+
function inspectExpoUpdatesOwnership(projectRoot, evaluatedExpoConfig) {
|
|
10
|
+
return expoUpdatesOwnership.getExpoUpdatesOwnership(evaluatedExpoConfig, { projectRoot });
|
|
11
|
+
}
|
|
12
|
+
function assertExpoUpdatesDoesNotOwnStartup(projectRoot, evaluatedExpoConfig) {
|
|
13
|
+
const ownership = inspectExpoUpdatesOwnership(projectRoot, evaluatedExpoConfig);
|
|
14
|
+
if (ownership.state === 'active') {
|
|
15
|
+
throw new Error('Active expo-updates blocks Bundle Drop because it can own native startup. ' +
|
|
16
|
+
'Run `bundle-drop init --migrate-expo-updates` and create a new native binary.');
|
|
17
|
+
}
|
|
18
|
+
if (ownership.state === 'disabled') {
|
|
19
|
+
console.warn(expoUpdatesOwnership.EXPO_UPDATES_DISABLED_WARNING);
|
|
20
|
+
}
|
|
21
|
+
return ownership;
|
|
22
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ExpoBuildIdentity, MobilePlatform } from './types';
|
|
2
|
+
export type ExpoExportOptions = {
|
|
3
|
+
projectRoot: string;
|
|
4
|
+
platform: MobilePlatform;
|
|
5
|
+
outputDirectory: string;
|
|
6
|
+
resetCache?: boolean;
|
|
7
|
+
buildIdentity?: ExpoBuildIdentity;
|
|
8
|
+
};
|
|
9
|
+
export type ExpoExportResult = {
|
|
10
|
+
projectRoot: string;
|
|
11
|
+
platform: MobilePlatform;
|
|
12
|
+
outputDirectory: string;
|
|
13
|
+
entryFile: string;
|
|
14
|
+
bundlePath: string;
|
|
15
|
+
sourceMapPath: string;
|
|
16
|
+
assetsDirectory: string;
|
|
17
|
+
sourceMapDebugId?: string;
|
|
18
|
+
files: string[];
|
|
19
|
+
buildIdentity: ExpoBuildIdentity;
|
|
20
|
+
};
|
|
21
|
+
export declare function exportExpoProject({ projectRoot, platform, outputDirectory, resetCache, buildIdentity: suppliedBuildIdentity, }: ExpoExportOptions): Promise<ExpoExportResult>;
|
|
@@ -0,0 +1,125 @@
|
|
|
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.exportExpoProject = exportExpoProject;
|
|
7
|
+
const child_process_1 = __importDefault(require("child_process"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const util_1 = require("util");
|
|
11
|
+
const config_1 = require("./config");
|
|
12
|
+
const buildIdentity_1 = require("./buildIdentity");
|
|
13
|
+
const errors_1 = require("./errors");
|
|
14
|
+
const localModules_1 = require("./localModules");
|
|
15
|
+
const exportValidation_1 = require("./exportValidation");
|
|
16
|
+
const execFile = (0, util_1.promisify)(child_process_1.default.execFile);
|
|
17
|
+
function ensureEmptyOutputDirectory(outputDirectory) {
|
|
18
|
+
if (fs_1.default.existsSync(outputDirectory)) {
|
|
19
|
+
const stats = fs_1.default.lstatSync(outputDirectory);
|
|
20
|
+
if (!stats.isDirectory() || stats.isSymbolicLink()) {
|
|
21
|
+
throw new errors_1.ExpoIntegrationError('Expo export output must be a real directory.');
|
|
22
|
+
}
|
|
23
|
+
if (fs_1.default.readdirSync(outputDirectory).length > 0) {
|
|
24
|
+
throw new errors_1.ExpoIntegrationError('Expo export output directory must be empty.');
|
|
25
|
+
}
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
fs_1.default.mkdirSync(outputDirectory, { recursive: true, mode: 0o755 });
|
|
29
|
+
}
|
|
30
|
+
function resolveExpoEntryFile(projectRoot, platform) {
|
|
31
|
+
const configPaths = (0, localModules_1.loadExpoDependency)(projectRoot, '@expo/config/paths');
|
|
32
|
+
if (typeof configPaths.resolveEntryPoint !== 'function') {
|
|
33
|
+
throw new errors_1.ExpoIntegrationError('The project-local @expo/config/paths package does not export resolveEntryPoint().');
|
|
34
|
+
}
|
|
35
|
+
const entryFile = configPaths.resolveEntryPoint(projectRoot, { platform });
|
|
36
|
+
if (!entryFile) {
|
|
37
|
+
throw new errors_1.ExpoIntegrationError(`Expo could not resolve the ${platform} entrypoint. Check package.json main and Router configuration.`);
|
|
38
|
+
}
|
|
39
|
+
return path_1.default.isAbsolute(entryFile) ? entryFile : path_1.default.resolve(projectRoot, entryFile);
|
|
40
|
+
}
|
|
41
|
+
function buildExpoExportArguments(options) {
|
|
42
|
+
const argumentsList = [
|
|
43
|
+
options.cliPath,
|
|
44
|
+
'export:embed',
|
|
45
|
+
'--platform',
|
|
46
|
+
options.platform,
|
|
47
|
+
'--entry-file',
|
|
48
|
+
options.entryFile,
|
|
49
|
+
'--bundle-output',
|
|
50
|
+
options.bundlePath,
|
|
51
|
+
'--assets-dest',
|
|
52
|
+
options.assetsDirectory,
|
|
53
|
+
'--sourcemap-output',
|
|
54
|
+
options.sourceMapPath,
|
|
55
|
+
'--dev',
|
|
56
|
+
'false',
|
|
57
|
+
'--minify',
|
|
58
|
+
'true',
|
|
59
|
+
];
|
|
60
|
+
if (options.useHermesBytecode) {
|
|
61
|
+
argumentsList.push('--bytecode');
|
|
62
|
+
}
|
|
63
|
+
if (options.resetCache) {
|
|
64
|
+
argumentsList.push('--reset-cache');
|
|
65
|
+
}
|
|
66
|
+
return argumentsList;
|
|
67
|
+
}
|
|
68
|
+
async function exportExpoProject({ projectRoot, platform, outputDirectory, resetCache = false, buildIdentity: suppliedBuildIdentity, }) {
|
|
69
|
+
const absoluteProjectRoot = path_1.default.resolve(projectRoot);
|
|
70
|
+
const absoluteOutputDirectory = path_1.default.resolve(outputDirectory);
|
|
71
|
+
(0, config_1.evaluateExpoConfig)(absoluteProjectRoot);
|
|
72
|
+
ensureEmptyOutputDirectory(absoluteOutputDirectory);
|
|
73
|
+
if (suppliedBuildIdentity && suppliedBuildIdentity.platform !== platform) {
|
|
74
|
+
throw new errors_1.ExpoIntegrationError(`The supplied Expo build identity is for ${suppliedBuildIdentity.platform}, not ${platform}.`);
|
|
75
|
+
}
|
|
76
|
+
const buildIdentity = suppliedBuildIdentity ??
|
|
77
|
+
(await (0, buildIdentity_1.resolveExpoBuildIdentity)(absoluteProjectRoot, platform));
|
|
78
|
+
const entryFile = resolveExpoEntryFile(absoluteProjectRoot, platform);
|
|
79
|
+
const bundlePath = path_1.default.join(absoluteOutputDirectory, 'main.jsbundle');
|
|
80
|
+
const sourceMapPath = path_1.default.join(absoluteOutputDirectory, 'main.jsbundle.map');
|
|
81
|
+
const assetsDirectory = path_1.default.join(absoluteOutputDirectory, 'assets');
|
|
82
|
+
fs_1.default.mkdirSync(assetsDirectory, { recursive: true, mode: 0o755 });
|
|
83
|
+
const cliPath = (0, localModules_1.resolveExpoDependency)(absoluteProjectRoot, '@expo/cli');
|
|
84
|
+
const argumentsList = buildExpoExportArguments({
|
|
85
|
+
cliPath,
|
|
86
|
+
platform,
|
|
87
|
+
entryFile,
|
|
88
|
+
bundlePath,
|
|
89
|
+
sourceMapPath,
|
|
90
|
+
assetsDirectory,
|
|
91
|
+
useHermesBytecode: buildIdentity.javaScriptEngine === 'hermes',
|
|
92
|
+
resetCache,
|
|
93
|
+
});
|
|
94
|
+
try {
|
|
95
|
+
await execFile(process.execPath, argumentsList, {
|
|
96
|
+
cwd: absoluteProjectRoot,
|
|
97
|
+
env: {
|
|
98
|
+
...process.env,
|
|
99
|
+
NODE_ENV: 'production',
|
|
100
|
+
BUNDLE_DROP_OTA_BUILD: '1',
|
|
101
|
+
},
|
|
102
|
+
maxBuffer: 16 * 1024 * 1024,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
throw new errors_1.ExpoIntegrationError(`Expo export:embed failed for ${platform}. No Bundle Drop artifact was created.`, { cause: error });
|
|
107
|
+
}
|
|
108
|
+
const validatedOutput = (0, exportValidation_1.validateExpoExportOutput)({
|
|
109
|
+
outputDirectory: absoluteOutputDirectory,
|
|
110
|
+
bundlePath,
|
|
111
|
+
sourceMapPath,
|
|
112
|
+
assetsDirectory,
|
|
113
|
+
});
|
|
114
|
+
return {
|
|
115
|
+
projectRoot: absoluteProjectRoot,
|
|
116
|
+
platform,
|
|
117
|
+
outputDirectory: absoluteOutputDirectory,
|
|
118
|
+
entryFile,
|
|
119
|
+
bundlePath,
|
|
120
|
+
sourceMapPath,
|
|
121
|
+
assetsDirectory,
|
|
122
|
+
...validatedOutput,
|
|
123
|
+
buildIdentity,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ValidatedExpoExport = {
|
|
2
|
+
files: string[];
|
|
3
|
+
sourceMapDebugId?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function assertSafeExpoExportRelativePaths(relativePaths: string[]): void;
|
|
6
|
+
export declare function validateExpoExportOutput(options: {
|
|
7
|
+
outputDirectory: string;
|
|
8
|
+
bundlePath: string;
|
|
9
|
+
sourceMapPath: string;
|
|
10
|
+
assetsDirectory: string;
|
|
11
|
+
}): ValidatedExpoExport;
|