@gfean/react-native-bundle-drop 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BundleDrop.podspec +17 -20
- package/README.md +60 -1
- package/android/build.gradle +4 -0
- package/android/src/main/java/com/bundledrop/BundleDropFileOps.kt +20 -0
- package/android/src/main/java/com/bundledrop/BundleDropModule.kt +4 -1
- package/android/src/main/java/com/bundledrop/BundleDropNativePaths.kt +5 -1
- package/docs/native-fingerprint.md +211 -0
- package/expo/android/build.gradle +61 -56
- package/ios/BundleDropLocator.swift +12 -0
- package/ios/BundleDropModule.swift +31 -13
- package/ios/BundleDropReactContent.swift +54 -0
- package/ios/BundleDropStartupRecovery.swift +48 -2
- package/ios/BundleDropStartupRecoveryAdapter.swift +87 -30
- package/lib/CLI/cli.js +9 -0
- package/lib/CLI/scripts/doctor.js +18 -7
- package/lib/CLI/scripts/expo/configure-expo.js +8 -3
- package/lib/CLI/scripts/fingerprint-cli.d.ts +12 -0
- package/lib/CLI/scripts/fingerprint-cli.js +36 -0
- package/lib/CLI/scripts/native/write-runtime-identity.js +3 -1
- package/lib/CLI/scripts/sight-ota.js +12 -3
- package/lib/CLI/scripts/upload-cli.d.ts +1 -0
- package/lib/CLI/scripts/upload-cli.js +35 -0
- package/lib/context.js +9 -1
- package/lib/errors.d.ts +2 -1
- package/lib/errors.js +2 -1
- package/lib/expo/buildIdentity.d.ts +1 -1
- package/lib/expo/buildIdentity.js +3 -0
- package/lib/expo/runtimeVersion.d.ts +10 -0
- package/lib/expo/runtimeVersion.js +11 -9
- package/lib/fingerprint/client.d.ts +5 -0
- package/lib/fingerprint/client.js +21 -0
- package/lib/fingerprint/collect.d.ts +3 -0
- package/lib/fingerprint/collect.js +116 -0
- package/lib/fingerprint/config.d.ts +14 -0
- package/lib/fingerprint/config.js +60 -0
- package/lib/fingerprint/normalizeBuildNumber.d.ts +4 -0
- package/lib/fingerprint/normalizeBuildNumber.js +55 -0
- package/lib/fingerprint/normalizeIosBuildNumber.d.ts +4 -0
- package/lib/fingerprint/normalizeIosBuildNumber.js +62 -0
- package/lib/fingerprint/types.d.ts +29 -0
- package/lib/fingerprint/types.js +2 -0
- package/lib/fingerprint/worker.d.ts +1 -0
- package/lib/fingerprint/worker.js +24 -0
- package/lib/fs/installedReportHistory.d.ts +2 -0
- package/lib/fs/installedReportHistory.js +55 -0
- package/lib/loadConfig.d.ts +6 -2
- package/lib/manager/downloadAndInstall.d.ts +1 -0
- package/lib/manager/downloadAndInstall.js +4 -0
- package/lib/manager/pendingRollback.d.ts +11 -0
- package/lib/manager/pendingRollback.js +54 -0
- package/lib/manager/reporting.d.ts +1 -0
- package/lib/manager/reporting.js +23 -6
- package/lib/manager/updateState.d.ts +3 -0
- package/lib/manager/updateState.js +1 -0
- package/lib/metro.js +3 -0
- package/lib/native/bundleDropNative.d.ts +2 -0
- package/lib/native/bundleDropNative.js +15 -5
- package/lib/patch-engine/installFromPatchSet.js +1 -1
- package/lib/patch-engine/patchTransport.d.ts +2 -1
- package/lib/patch-engine/patchTransport.js +4 -2
- package/lib/runtime/service.d.ts +2 -1
- package/lib/runtime/service.js +77 -22
- package/lib/scripts/bundle.js +10 -0
- package/lib/scripts/canonicalArtifact.d.ts +3 -0
- package/lib/scripts/canonicalArtifact.js +3 -1
- package/lib/scripts/exportProject.js +11 -0
- package/lib/scripts/nativeBuildNumber.d.ts +9 -0
- package/lib/scripts/nativeBuildNumber.js +110 -0
- package/lib/scripts/runtimeCompatibilityMetadata.d.ts +10 -0
- package/lib/scripts/runtimeCompatibilityMetadata.js +13 -0
- package/package.json +25 -11
- package/third_party/expo-fingerprint/LICENSE +22 -0
- package/third_party/expo-fingerprint/NOTICE +5 -0
- package/third_party/expo-fingerprint/PROVENANCE.md +41 -0
- package/third_party/expo-fingerprint/build/Config.js +122 -0
- package/third_party/expo-fingerprint/build/Dedup.js +89 -0
- package/third_party/expo-fingerprint/build/ExpoConfig.js +93 -0
- package/third_party/expo-fingerprint/build/ExpoConfigLoader.js +201 -0
- package/third_party/expo-fingerprint/build/ExpoResolver.js +84 -0
- package/third_party/expo-fingerprint/build/Fingerprint.js +111 -0
- package/third_party/expo-fingerprint/build/Fingerprint.types.js +3 -0
- package/third_party/expo-fingerprint/build/Options.js +140 -0
- package/third_party/expo-fingerprint/build/Presets.js +62 -0
- package/third_party/expo-fingerprint/build/ProjectWorkflow.js +163 -0
- package/third_party/expo-fingerprint/build/Sort.js +46 -0
- package/third_party/expo-fingerprint/build/hash/FileHookTransform.js +42 -0
- package/third_party/expo-fingerprint/build/hash/Hash.js +264 -0
- package/third_party/expo-fingerprint/build/hash/ReactImportsPatcher.js +344 -0
- package/third_party/expo-fingerprint/build/index.js +23 -0
- package/third_party/expo-fingerprint/build/sourcer/AutolinkingConfig.js +130 -0
- package/third_party/expo-fingerprint/build/sourcer/Bare.js +231 -0
- package/third_party/expo-fingerprint/build/sourcer/Expo.js +376 -0
- package/third_party/expo-fingerprint/build/sourcer/Packages.js +54 -0
- package/third_party/expo-fingerprint/build/sourcer/PatchPackage.js +22 -0
- package/third_party/expo-fingerprint/build/sourcer/SourceSkips.js +79 -0
- package/third_party/expo-fingerprint/build/sourcer/Sourcer.js +58 -0
- package/third_party/expo-fingerprint/build/sourcer/Utils.js +129 -0
- package/third_party/expo-fingerprint/build/types/module.d.js +2 -0
- package/third_party/expo-fingerprint/build/utils/Concurrency.js +47 -0
- package/third_party/expo-fingerprint/build/utils/Env.js +28 -0
- package/third_party/expo-fingerprint/build/utils/Path.js +161 -0
- package/third_party/expo-fingerprint/build/utils/Predicates.js +6 -0
- package/third_party/expo-fingerprint/build/utils/Profile.js +41 -0
- package/third_party/expo-fingerprint/build/utils/Spawn.js +38 -0
- package/third_party/expo-fingerprint/build/utils/SpawnIPC.js +28 -0
- package/third_party/expo-fingerprint/scheme-1-contract.json +132 -0
- package/third_party/expo-fingerprint/upstream-files.json +37 -0
|
@@ -0,0 +1,231 @@
|
|
|
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.getBareAndroidSourcesAsync = getBareAndroidSourcesAsync;
|
|
7
|
+
exports.getBareIosSourcesAsync = getBareIosSourcesAsync;
|
|
8
|
+
exports.getPackageJsonScriptSourcesAsync = getPackageJsonScriptSourcesAsync;
|
|
9
|
+
exports.getGitIgnoreSourcesAsync = getGitIgnoreSourcesAsync;
|
|
10
|
+
exports.getCoreAutolinkingSourcesFromRncCliAsync = getCoreAutolinkingSourcesFromRncCliAsync;
|
|
11
|
+
exports.getCoreAutolinkingSourcesFromExpoAndroid = getCoreAutolinkingSourcesFromExpoAndroid;
|
|
12
|
+
exports.getCoreAutolinkingSourcesFromExpoIos = getCoreAutolinkingSourcesFromExpoIos;
|
|
13
|
+
const Env_1 = require("../utils/Env");
|
|
14
|
+
const Spawn_1 = __importDefault(require("../utils/Spawn"));
|
|
15
|
+
const assert_1 = __importDefault(require("assert"));
|
|
16
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
+
const node_process_1 = __importDefault(require("node:process"));
|
|
18
|
+
const path_1 = __importDefault(require("path"));
|
|
19
|
+
const resolve_from_1 = __importDefault(require("resolve-from"));
|
|
20
|
+
const ExpoResolver_1 = require("../ExpoResolver");
|
|
21
|
+
const Path_1 = require("../utils/Path");
|
|
22
|
+
const Profile_1 = require("../utils/Profile");
|
|
23
|
+
const AutolinkingConfig_1 = require("./AutolinkingConfig");
|
|
24
|
+
const SourceSkips_1 = require("./SourceSkips");
|
|
25
|
+
const Utils_1 = require("./Utils");
|
|
26
|
+
const debug = require('debug')('expo:fingerprint:sourcer:Bare');
|
|
27
|
+
async function getBareAndroidSourcesAsync(projectRoot, options) {
|
|
28
|
+
if (options.platforms.includes('android')) {
|
|
29
|
+
const result = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, 'android', 'bareNativeDir');
|
|
30
|
+
if (result != null) {
|
|
31
|
+
debug(`Adding bare native dir - ${chalk_1.default.dim('android')}`);
|
|
32
|
+
return [result];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
async function getBareIosSourcesAsync(projectRoot, options) {
|
|
38
|
+
if (options.platforms.includes('ios')) {
|
|
39
|
+
const result = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, 'ios', 'bareNativeDir');
|
|
40
|
+
if (result != null) {
|
|
41
|
+
debug(`Adding bare native dir - ${chalk_1.default.dim('ios')}`);
|
|
42
|
+
return [result];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
async function getPackageJsonScriptSourcesAsync(projectRoot, options) {
|
|
48
|
+
if (options.sourceSkips & SourceSkips_1.SourceSkips.PackageJsonScriptsAll) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
let packageJson;
|
|
52
|
+
try {
|
|
53
|
+
packageJson = require((0, resolve_from_1.default)(path_1.default.resolve(projectRoot), './package.json'));
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
debug(`Unable to read package.json from ${path_1.default.resolve(projectRoot)}/package.json: ` + e);
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
const results = [];
|
|
60
|
+
if (packageJson.scripts) {
|
|
61
|
+
debug(`Adding package.json contents - ${chalk_1.default.dim('scripts')}`);
|
|
62
|
+
const id = 'packageJson:scripts';
|
|
63
|
+
results.push({
|
|
64
|
+
type: 'contents',
|
|
65
|
+
id,
|
|
66
|
+
contents: normalizePackageJsonScriptSources(packageJson.scripts, options),
|
|
67
|
+
reasons: [id],
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return results;
|
|
71
|
+
}
|
|
72
|
+
async function getGitIgnoreSourcesAsync(projectRoot, options) {
|
|
73
|
+
if (options.sourceSkips & SourceSkips_1.SourceSkips.GitIgnore) {
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
const result = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, '.gitignore', 'bareGitIgnore');
|
|
77
|
+
if (result != null) {
|
|
78
|
+
debug(`Adding file - ${chalk_1.default.dim('.gitignore')}`);
|
|
79
|
+
return [result];
|
|
80
|
+
}
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
async function getCoreAutolinkingSourcesFromRncCliAsync(projectRoot, options, useRNCoreAutolinkingFromExpo) {
|
|
84
|
+
if (useRNCoreAutolinkingFromExpo === true) {
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
const { stdout } = await (0, Spawn_1.default)('npx', ['react-native', 'config'], {
|
|
89
|
+
cwd: projectRoot,
|
|
90
|
+
env: (0, Env_1.getOriginalEnv)(),
|
|
91
|
+
});
|
|
92
|
+
const config = JSON.parse(stdout);
|
|
93
|
+
const results = await parseCoreAutolinkingSourcesAsync({
|
|
94
|
+
config,
|
|
95
|
+
contentsId: 'rncoreAutolinkingConfig',
|
|
96
|
+
reasons: ['rncoreAutolinking'],
|
|
97
|
+
options,
|
|
98
|
+
});
|
|
99
|
+
return results;
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
debug(chalk_1.default.red(`Error adding react-native core autolinking sources.\n${e}`));
|
|
103
|
+
throw e;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async function getCoreAutolinkingSourcesFromExpoAndroid(projectRoot, options, useRNCoreAutolinkingFromExpo) {
|
|
107
|
+
if (useRNCoreAutolinkingFromExpo === false || !options.platforms.includes('android')) {
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
const args = [
|
|
111
|
+
(0, ExpoResolver_1.resolveExpoAutolinkingCliPath)(projectRoot),
|
|
112
|
+
'react-native-config',
|
|
113
|
+
'--json',
|
|
114
|
+
'--platform',
|
|
115
|
+
'android',
|
|
116
|
+
];
|
|
117
|
+
try {
|
|
118
|
+
const { stdout } = await (0, Spawn_1.default)('node', args, {
|
|
119
|
+
cwd: projectRoot,
|
|
120
|
+
env: (0, Env_1.getOriginalEnv)(),
|
|
121
|
+
});
|
|
122
|
+
const config = JSON.parse(stdout);
|
|
123
|
+
const results = await parseCoreAutolinkingSourcesAsync({
|
|
124
|
+
config,
|
|
125
|
+
contentsId: 'rncoreAutolinkingConfig:android',
|
|
126
|
+
reasons: ['rncoreAutolinkingAndroid'],
|
|
127
|
+
options,
|
|
128
|
+
platform: 'android',
|
|
129
|
+
});
|
|
130
|
+
return results;
|
|
131
|
+
}
|
|
132
|
+
catch (e) {
|
|
133
|
+
debug(chalk_1.default.red(`Error adding react-native core autolinking sources for android.\n${e}`));
|
|
134
|
+
throw e;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
async function getCoreAutolinkingSourcesFromExpoIos(projectRoot, options, useRNCoreAutolinkingFromExpo) {
|
|
138
|
+
if (useRNCoreAutolinkingFromExpo === false || !options.platforms.includes('ios')) {
|
|
139
|
+
return [];
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
const { stdout } = await (0, Spawn_1.default)('node', [
|
|
143
|
+
(0, ExpoResolver_1.resolveExpoAutolinkingCliPath)(projectRoot),
|
|
144
|
+
'react-native-config',
|
|
145
|
+
'--json',
|
|
146
|
+
'--platform',
|
|
147
|
+
'ios',
|
|
148
|
+
], { cwd: projectRoot, env: (0, Env_1.getOriginalEnv)() });
|
|
149
|
+
const config = JSON.parse(stdout);
|
|
150
|
+
const results = await parseCoreAutolinkingSourcesAsync({
|
|
151
|
+
config,
|
|
152
|
+
contentsId: 'rncoreAutolinkingConfig:ios',
|
|
153
|
+
reasons: ['rncoreAutolinkingIos'],
|
|
154
|
+
options,
|
|
155
|
+
platform: 'ios',
|
|
156
|
+
});
|
|
157
|
+
return results;
|
|
158
|
+
}
|
|
159
|
+
catch (e) {
|
|
160
|
+
debug(chalk_1.default.red(`Error adding react-native core autolinking sources for ios.\n${e}`));
|
|
161
|
+
throw e;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async function parseCoreAutolinkingSourcesAsync({ config, reasons, contentsId, platform, options, }) {
|
|
165
|
+
const logTag = platform
|
|
166
|
+
? `react-native core autolinking dir for ${platform}`
|
|
167
|
+
: 'react-native core autolinking dir';
|
|
168
|
+
const results = [];
|
|
169
|
+
const root = await (0, Utils_1.maybeGetRealPathAsync)(config.root);
|
|
170
|
+
const autolinkingConfig = {};
|
|
171
|
+
for (const [depName, depData] of Object.entries(config.dependencies)) {
|
|
172
|
+
try {
|
|
173
|
+
stripRncoreAutolinkingAbsolutePaths(depData, root);
|
|
174
|
+
const filePath = (0, Path_1.toPosixPath)(depData.root);
|
|
175
|
+
debug(`Adding ${logTag} - ${chalk_1.default.dim(filePath)}`);
|
|
176
|
+
results.push(await (0, Utils_1.createAutolinkingHashSourceAsync)(root, filePath, reasons, options.nativeModuleSourceType));
|
|
177
|
+
autolinkingConfig[depName] = depData;
|
|
178
|
+
}
|
|
179
|
+
catch (e) {
|
|
180
|
+
debug(chalk_1.default.red(`Error adding ${logTag} - ${depName}.\n${e}`));
|
|
181
|
+
throw e;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
results.push({
|
|
185
|
+
type: 'contents',
|
|
186
|
+
id: contentsId,
|
|
187
|
+
contents: JSON.stringify((0, Profile_1.profile)(options, AutolinkingConfig_1.normalizeAutolinkingConfig)(autolinkingConfig, {
|
|
188
|
+
stripPaths: !!(options.sourceSkips & SourceSkips_1.SourceSkips.AutolinkingConfigPaths),
|
|
189
|
+
roots: [root],
|
|
190
|
+
})),
|
|
191
|
+
reasons,
|
|
192
|
+
});
|
|
193
|
+
return results;
|
|
194
|
+
}
|
|
195
|
+
function stripRncoreAutolinkingAbsolutePaths(dependency, root) {
|
|
196
|
+
(0, assert_1.default)(dependency.root);
|
|
197
|
+
const dependencyRoot = dependency.root;
|
|
198
|
+
const cmakeDepRoot = node_process_1.default.platform === 'win32' ? dependencyRoot.replace(/\\/g, '/') : dependencyRoot;
|
|
199
|
+
dependency.root = (0, Path_1.toPosixPath)(path_1.default.relative(root, dependencyRoot));
|
|
200
|
+
for (const platformData of Object.values(dependency.platforms)) {
|
|
201
|
+
for (const [key, value] of Object.entries(platformData ?? {})) {
|
|
202
|
+
let newValue;
|
|
203
|
+
if (node_process_1.default.platform === 'win32' &&
|
|
204
|
+
['cmakeListsPath', 'cxxModuleCMakeListsPath'].includes(key)) {
|
|
205
|
+
// CMake paths on Windows are serving in slashes,
|
|
206
|
+
// we have to check startsWith with the same slashes.
|
|
207
|
+
newValue = value?.startsWith?.(cmakeDepRoot)
|
|
208
|
+
? (0, Path_1.toPosixPath)(path_1.default.relative(root, value))
|
|
209
|
+
: value;
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
newValue = value?.startsWith?.(dependencyRoot)
|
|
213
|
+
? (0, Path_1.toPosixPath)(path_1.default.relative(root, value))
|
|
214
|
+
: value;
|
|
215
|
+
}
|
|
216
|
+
platformData[key] = newValue;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
function normalizePackageJsonScriptSources(scripts, options) {
|
|
221
|
+
if (options.sourceSkips & SourceSkips_1.SourceSkips.PackageJsonAndroidAndIosScriptsIfNotContainRun) {
|
|
222
|
+
// Replicate the behavior of `expo prebuild`
|
|
223
|
+
if (!scripts.android?.includes('run') || scripts.android === 'expo run:android') {
|
|
224
|
+
delete scripts.android;
|
|
225
|
+
}
|
|
226
|
+
if (!scripts.ios?.includes('run') || scripts.ios === 'expo run:ios') {
|
|
227
|
+
delete scripts.ios;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return JSON.stringify(scripts);
|
|
231
|
+
}
|
|
@@ -0,0 +1,376 @@
|
|
|
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.getExpoConfigSourcesAsync = getExpoConfigSourcesAsync;
|
|
7
|
+
exports.createHashSourceExternalFileAsync = createHashSourceExternalFileAsync;
|
|
8
|
+
exports.getEasBuildSourcesAsync = getEasBuildSourcesAsync;
|
|
9
|
+
exports.getExpoAutolinkingAndroidSourcesAsync = getExpoAutolinkingAndroidSourcesAsync;
|
|
10
|
+
exports.getExpoCNGPatchSourcesAsync = getExpoCNGPatchSourcesAsync;
|
|
11
|
+
exports.getExpoAutolinkingIosSourcesAsync = getExpoAutolinkingIosSourcesAsync;
|
|
12
|
+
exports.sortExpoAutolinkingAndroidConfig = sortExpoAutolinkingAndroidConfig;
|
|
13
|
+
exports.getConfigPluginProps = getConfigPluginProps;
|
|
14
|
+
const Env_1 = require("../utils/Env");
|
|
15
|
+
const Spawn_1 = __importDefault(require("../utils/Spawn"));
|
|
16
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const semver_1 = __importDefault(require("semver"));
|
|
19
|
+
const ExpoResolver_1 = require("../ExpoResolver");
|
|
20
|
+
const Path_1 = require("../utils/Path");
|
|
21
|
+
const Profile_1 = require("../utils/Profile");
|
|
22
|
+
const AutolinkingConfig_1 = require("./AutolinkingConfig");
|
|
23
|
+
const SourceSkips_1 = require("./SourceSkips");
|
|
24
|
+
const Utils_1 = require("./Utils");
|
|
25
|
+
const debug = require('debug')('expo:fingerprint:sourcer:Expo');
|
|
26
|
+
async function getExpoConfigSourcesAsync(projectRoot, config, loadedModules, options) {
|
|
27
|
+
if (options.sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigAll) {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
if (config == null) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
const results = [];
|
|
34
|
+
let expoConfig = normalizeExpoConfig(config.exp, projectRoot, options);
|
|
35
|
+
// external files in config
|
|
36
|
+
const isAndroid = options.platforms.includes('android');
|
|
37
|
+
const isIos = options.platforms.includes('ios');
|
|
38
|
+
const splashScreenPluginProps = getConfigPluginProps(expoConfig, 'expo-splash-screen');
|
|
39
|
+
const fontPluginProps = getConfigPluginProps(expoConfig, 'expo-font');
|
|
40
|
+
const externalFiles = [
|
|
41
|
+
// expo-font files
|
|
42
|
+
...(fontPluginProps?.fonts ?? []),
|
|
43
|
+
...(isIos ? (fontPluginProps?.ios?.fonts ?? []) : []),
|
|
44
|
+
...(isAndroid
|
|
45
|
+
? (fontPluginProps?.android?.fonts ?? []).flatMap((f) => typeof f === 'string'
|
|
46
|
+
? [f]
|
|
47
|
+
: // When a variable font file backs several definitions,
|
|
48
|
+
// a family may name the file path once instead of each definition repeating it
|
|
49
|
+
(f.fontDefinitions ?? []).map((d) => d.path ?? f.path))
|
|
50
|
+
: []),
|
|
51
|
+
// icons
|
|
52
|
+
expoConfig.icon,
|
|
53
|
+
isAndroid ? expoConfig.android?.icon : undefined,
|
|
54
|
+
...(isIos ? collectIosIcons(expoConfig.ios?.icon) : []),
|
|
55
|
+
isAndroid ? expoConfig.android?.adaptiveIcon?.foregroundImage : undefined,
|
|
56
|
+
isAndroid ? expoConfig.android?.adaptiveIcon?.backgroundImage : undefined,
|
|
57
|
+
// expo-splash-screen images
|
|
58
|
+
splashScreenPluginProps?.image,
|
|
59
|
+
splashScreenPluginProps?.dark?.image,
|
|
60
|
+
isAndroid ? splashScreenPluginProps?.android?.image : undefined,
|
|
61
|
+
isAndroid ? splashScreenPluginProps?.android?.mdpi : undefined,
|
|
62
|
+
isAndroid ? splashScreenPluginProps?.android?.hdpi : undefined,
|
|
63
|
+
isAndroid ? splashScreenPluginProps?.android?.xhdpi : undefined,
|
|
64
|
+
isAndroid ? splashScreenPluginProps?.android?.xxhdpi : undefined,
|
|
65
|
+
isAndroid ? splashScreenPluginProps?.android?.xxxhdpi : undefined,
|
|
66
|
+
isAndroid ? splashScreenPluginProps?.android?.dark?.image : undefined,
|
|
67
|
+
isAndroid ? splashScreenPluginProps?.android?.dark?.mdpi : undefined,
|
|
68
|
+
isAndroid ? splashScreenPluginProps?.android?.dark?.hdpi : undefined,
|
|
69
|
+
isAndroid ? splashScreenPluginProps?.android?.dark?.xhdpi : undefined,
|
|
70
|
+
isAndroid ? splashScreenPluginProps?.android?.dark?.xxhdpi : undefined,
|
|
71
|
+
isAndroid ? splashScreenPluginProps?.android?.dark?.xxxhdpi : undefined,
|
|
72
|
+
isIos ? splashScreenPluginProps?.ios?.image : undefined,
|
|
73
|
+
isIos ? splashScreenPluginProps?.ios?.tabletImage : undefined,
|
|
74
|
+
isIos ? splashScreenPluginProps?.ios?.dark?.image : undefined,
|
|
75
|
+
isIos ? splashScreenPluginProps?.ios?.dark?.tabletImage : undefined,
|
|
76
|
+
// google service files
|
|
77
|
+
isAndroid ? expoConfig.android?.googleServicesFile : undefined,
|
|
78
|
+
isIos ? expoConfig.ios?.googleServicesFile : undefined,
|
|
79
|
+
]
|
|
80
|
+
.filter((file) => Boolean(file))
|
|
81
|
+
.map((filePath) => ensureRelativePath(projectRoot, filePath));
|
|
82
|
+
const externalFileSources = (await Promise.all(externalFiles.map((file) => createHashSourceExternalFileAsync({ projectRoot, file, reason: 'expoConfigExternalFile' })))).filter(Boolean);
|
|
83
|
+
results.push(...externalFileSources);
|
|
84
|
+
expoConfig = postUpdateExpoConfig(expoConfig, projectRoot);
|
|
85
|
+
results.push({
|
|
86
|
+
type: 'contents',
|
|
87
|
+
id: 'expoConfig',
|
|
88
|
+
contents: (0, Utils_1.stringifyJsonSorted)(expoConfig),
|
|
89
|
+
reasons: ['expoConfig'],
|
|
90
|
+
});
|
|
91
|
+
// config plugins
|
|
92
|
+
// With `configPluginSourceType: 'package'`, node_modules plugin files collapse to their package
|
|
93
|
+
// name+version; in-repo files and virtual modules are hashed directly.
|
|
94
|
+
const configPluginModules = await Promise.all((loadedModules ?? []).map(async (loadedModule) => {
|
|
95
|
+
if (loadedModule.type === 'contents') {
|
|
96
|
+
return {
|
|
97
|
+
type: 'contents',
|
|
98
|
+
id: loadedModule.id,
|
|
99
|
+
contents: loadedModule.contents,
|
|
100
|
+
reasons: ['expoConfigPlugins'],
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
if (options.configPluginSourceType === 'package') {
|
|
104
|
+
const packageJsonPath = (0, Path_1.getNodeModulesPackageJsonPath)(loadedModule.path);
|
|
105
|
+
if (packageJsonPath) {
|
|
106
|
+
const identity = await (0, Utils_1.readPackageIdentityAsync)(path_1.default.join(projectRoot, packageJsonPath));
|
|
107
|
+
if (identity) {
|
|
108
|
+
return {
|
|
109
|
+
type: 'package',
|
|
110
|
+
...identity,
|
|
111
|
+
filePath: packageJsonPath,
|
|
112
|
+
reasons: ['expoConfigPlugins'],
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return { type: 'file', filePath: loadedModule.path, reasons: ['expoConfigPlugins'] };
|
|
118
|
+
}));
|
|
119
|
+
results.push(...configPluginModules);
|
|
120
|
+
return results;
|
|
121
|
+
}
|
|
122
|
+
function normalizeExpoConfig(config, projectRoot, options) {
|
|
123
|
+
// Deep clone by JSON.parse/stringify that assumes the config is serializable.
|
|
124
|
+
const normalizedConfig = JSON.parse(JSON.stringify(config));
|
|
125
|
+
const { sourceSkips } = options;
|
|
126
|
+
delete normalizedConfig._internal;
|
|
127
|
+
if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigVersions) {
|
|
128
|
+
delete normalizedConfig.version;
|
|
129
|
+
delete normalizedConfig.android?.versionCode;
|
|
130
|
+
delete normalizedConfig.android?.version;
|
|
131
|
+
delete normalizedConfig.ios?.buildNumber;
|
|
132
|
+
delete normalizedConfig.ios?.version;
|
|
133
|
+
}
|
|
134
|
+
if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigRuntimeVersionIfString) {
|
|
135
|
+
if (typeof normalizedConfig.runtimeVersion === 'string') {
|
|
136
|
+
delete normalizedConfig.runtimeVersion;
|
|
137
|
+
}
|
|
138
|
+
if (typeof normalizedConfig.android?.runtimeVersion === 'string') {
|
|
139
|
+
delete normalizedConfig.android.runtimeVersion;
|
|
140
|
+
}
|
|
141
|
+
if (typeof normalizedConfig.ios?.runtimeVersion === 'string') {
|
|
142
|
+
delete normalizedConfig.ios.runtimeVersion;
|
|
143
|
+
}
|
|
144
|
+
if (typeof normalizedConfig.web?.runtimeVersion === 'string') {
|
|
145
|
+
delete normalizedConfig.web.runtimeVersion;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigNames) {
|
|
149
|
+
normalizedConfig.name = '';
|
|
150
|
+
delete normalizedConfig.description;
|
|
151
|
+
delete normalizedConfig.web?.name;
|
|
152
|
+
delete normalizedConfig.web?.shortName;
|
|
153
|
+
delete normalizedConfig.web?.description;
|
|
154
|
+
}
|
|
155
|
+
if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigAndroidPackage) {
|
|
156
|
+
delete normalizedConfig.android?.package;
|
|
157
|
+
}
|
|
158
|
+
if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigIosBundleIdentifier) {
|
|
159
|
+
delete normalizedConfig.ios?.bundleIdentifier;
|
|
160
|
+
}
|
|
161
|
+
if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigSchemes) {
|
|
162
|
+
delete normalizedConfig.scheme;
|
|
163
|
+
normalizedConfig.slug = '';
|
|
164
|
+
}
|
|
165
|
+
if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigEASProject) {
|
|
166
|
+
delete normalizedConfig.owner;
|
|
167
|
+
delete normalizedConfig?.extra?.eas;
|
|
168
|
+
delete normalizedConfig?.updates?.url;
|
|
169
|
+
}
|
|
170
|
+
if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigAssets) {
|
|
171
|
+
delete normalizedConfig.icon;
|
|
172
|
+
delete normalizedConfig.android?.adaptiveIcon;
|
|
173
|
+
delete normalizedConfig.android?.icon;
|
|
174
|
+
delete normalizedConfig.ios?.icon;
|
|
175
|
+
delete normalizedConfig.web?.favicon;
|
|
176
|
+
delete normalizedConfig.web?.splash;
|
|
177
|
+
}
|
|
178
|
+
if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigExtraSection) {
|
|
179
|
+
delete normalizedConfig.extra;
|
|
180
|
+
}
|
|
181
|
+
return (0, Utils_1.relativizeJsonPaths)(normalizedConfig, projectRoot);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Gives the last chance to modify the ExpoConfig.
|
|
185
|
+
* For example, we can remove some fields that are already included in the fingerprint.
|
|
186
|
+
*/
|
|
187
|
+
function postUpdateExpoConfig(config, projectRoot) {
|
|
188
|
+
// The config is already a clone, so we can modify it in place for performance.
|
|
189
|
+
// googleServicesFile may contain absolute paths on EAS with file-based secrets.
|
|
190
|
+
// Given we include googleServicesFile as external files already, we can remove it from the config.
|
|
191
|
+
delete config.android?.googleServicesFile;
|
|
192
|
+
delete config.ios?.googleServicesFile;
|
|
193
|
+
return config;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Collect iOS icon to flattened file paths.
|
|
197
|
+
*/
|
|
198
|
+
function collectIosIcons(icon) {
|
|
199
|
+
if (icon == null) {
|
|
200
|
+
return [];
|
|
201
|
+
}
|
|
202
|
+
if (typeof icon === 'string') {
|
|
203
|
+
return [icon];
|
|
204
|
+
}
|
|
205
|
+
return [icon.light, icon.dark, icon.tinted].filter((file) => Boolean(file));
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* The filePath in config could be relative (`./assets/icon.png`, `assets/icon.png`) or even absolute.
|
|
209
|
+
* We need to normalize the path and return as relative path without `./` prefix.
|
|
210
|
+
*/
|
|
211
|
+
function ensureRelativePath(projectRoot, filePath) {
|
|
212
|
+
const absolutePath = path_1.default.resolve(projectRoot, filePath);
|
|
213
|
+
return path_1.default.relative(projectRoot, absolutePath);
|
|
214
|
+
}
|
|
215
|
+
async function createHashSourceExternalFileAsync({ projectRoot, file, reason, }) {
|
|
216
|
+
const hashSource = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, file, reason);
|
|
217
|
+
if (!hashSource)
|
|
218
|
+
throw new Error(`Required Expo fingerprint input is missing: ${file}`);
|
|
219
|
+
if (hashSource) {
|
|
220
|
+
debug(`Adding config external file - ${chalk_1.default.dim(file)}`);
|
|
221
|
+
if (hashSource.type === 'file' || hashSource.type === 'dir') {
|
|
222
|
+
// We include the expo config contents in the fingerprint,
|
|
223
|
+
// the `filePath` hashing for the external files is not necessary.
|
|
224
|
+
// Especially people using EAS environment variables for the google service files,
|
|
225
|
+
// the `filePath` will be different between local and remote builds.
|
|
226
|
+
// We use a fixed override hash key and basically ignore the `filePath` hashing.
|
|
227
|
+
hashSource.overrideHashKey = 'expoConfigExternalFile:contentsOnly';
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return hashSource;
|
|
231
|
+
}
|
|
232
|
+
async function getEasBuildSourcesAsync(projectRoot, options) {
|
|
233
|
+
const files = [
|
|
234
|
+
...(options.sourceSkips & SourceSkips_1.SourceSkips.EasJson ? [] : ['eas.json']),
|
|
235
|
+
...(options.sourceSkips & SourceSkips_1.SourceSkips.Easignore ? [] : ['.easignore']),
|
|
236
|
+
];
|
|
237
|
+
const results = (await Promise.all(files.map(async (file) => {
|
|
238
|
+
const result = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, file, 'easBuild');
|
|
239
|
+
if (result != null) {
|
|
240
|
+
debug(`Adding eas file - ${chalk_1.default.dim(file)}`);
|
|
241
|
+
}
|
|
242
|
+
return result;
|
|
243
|
+
}))).filter(Boolean);
|
|
244
|
+
return results;
|
|
245
|
+
}
|
|
246
|
+
async function getExpoAutolinkingAndroidSourcesAsync(projectRoot, options, expoAutolinkingVersion) {
|
|
247
|
+
if (!options.platforms.includes('android')) {
|
|
248
|
+
return [];
|
|
249
|
+
}
|
|
250
|
+
try {
|
|
251
|
+
const reasons = ['expoAutolinkingAndroid'];
|
|
252
|
+
const results = [];
|
|
253
|
+
const realProjectRoot = await (0, Utils_1.maybeGetRealPathAsync)(projectRoot);
|
|
254
|
+
const { stdout } = await (0, Spawn_1.default)('node', [(0, ExpoResolver_1.resolveExpoAutolinkingCliPath)(projectRoot), 'resolve', '-p', 'android', '--json'], { cwd: projectRoot, env: (0, Env_1.getOriginalEnv)() });
|
|
255
|
+
const config = sortExpoAutolinkingAndroidConfig(JSON.parse(stdout));
|
|
256
|
+
for (const module of config.modules) {
|
|
257
|
+
for (const project of module.projects) {
|
|
258
|
+
const filePath = (0, Path_1.toPosixPath)(path_1.default.relative(realProjectRoot, project.sourceDir));
|
|
259
|
+
project.sourceDir = filePath; // use relative path for the dir
|
|
260
|
+
debug(`Adding expo-modules-autolinking android dir - ${chalk_1.default.dim(filePath)}`);
|
|
261
|
+
results.push(await (0, Utils_1.createAutolinkingHashSourceAsync)(realProjectRoot, filePath, reasons, options.nativeModuleSourceType));
|
|
262
|
+
// `aarProjects` is present in project starting from SDK 53+.
|
|
263
|
+
if (project.aarProjects) {
|
|
264
|
+
for (const aarProject of project.aarProjects) {
|
|
265
|
+
// use relative path for aarProject fields
|
|
266
|
+
aarProject.aarFilePath = (0, Path_1.toPosixPath)(path_1.default.relative(realProjectRoot, aarProject.aarFilePath));
|
|
267
|
+
aarProject.projectDir = (0, Path_1.toPosixPath)(path_1.default.relative(realProjectRoot, aarProject.projectDir));
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
if (typeof project.shouldUsePublicationScriptPath === 'string') {
|
|
271
|
+
project.shouldUsePublicationScriptPath = (0, Path_1.toPosixPath)(path_1.default.relative(realProjectRoot, project.shouldUsePublicationScriptPath));
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
if (module.plugins) {
|
|
275
|
+
for (const plugin of module.plugins) {
|
|
276
|
+
const filePath = (0, Path_1.toPosixPath)(path_1.default.relative(realProjectRoot, plugin.sourceDir));
|
|
277
|
+
plugin.sourceDir = filePath; // use relative path for the dir
|
|
278
|
+
debug(`Adding expo-modules-autolinking android dir - ${chalk_1.default.dim(filePath)}`);
|
|
279
|
+
results.push(await (0, Utils_1.createAutolinkingHashSourceAsync)(realProjectRoot, filePath, reasons, options.nativeModuleSourceType));
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
// Backward compatibility for SDK versions earlier than 53
|
|
283
|
+
if (module.aarProjects) {
|
|
284
|
+
for (const aarProject of module.aarProjects) {
|
|
285
|
+
// use relative path for aarProject fields
|
|
286
|
+
aarProject.aarFilePath = (0, Path_1.toPosixPath)(path_1.default.relative(realProjectRoot, aarProject.aarFilePath));
|
|
287
|
+
aarProject.projectDir = (0, Path_1.toPosixPath)(path_1.default.relative(realProjectRoot, aarProject.projectDir));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
results.push({
|
|
292
|
+
type: 'contents',
|
|
293
|
+
id: 'expoAutolinkingConfig:android',
|
|
294
|
+
contents: JSON.stringify((0, Profile_1.profile)(options, AutolinkingConfig_1.normalizeAutolinkingConfig)(config, {
|
|
295
|
+
stripPaths: !!(options.sourceSkips & SourceSkips_1.SourceSkips.AutolinkingConfigPaths),
|
|
296
|
+
roots: [realProjectRoot],
|
|
297
|
+
})),
|
|
298
|
+
reasons,
|
|
299
|
+
});
|
|
300
|
+
return results;
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
throw error;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Gets the patch sources for the `patch-project`.
|
|
308
|
+
*/
|
|
309
|
+
async function getExpoCNGPatchSourcesAsync(projectRoot, options) {
|
|
310
|
+
const result = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, 'cng-patches', 'expoCNGPatches');
|
|
311
|
+
if (result != null) {
|
|
312
|
+
debug(`Adding dir - ${chalk_1.default.dim('cng-patches')}`);
|
|
313
|
+
return [result];
|
|
314
|
+
}
|
|
315
|
+
return [];
|
|
316
|
+
}
|
|
317
|
+
async function getExpoAutolinkingIosSourcesAsync(projectRoot, options, expoAutolinkingVersion) {
|
|
318
|
+
if (!options.platforms.includes('ios')) {
|
|
319
|
+
return [];
|
|
320
|
+
}
|
|
321
|
+
// expo-modules-autolinking 1.10.0 added support for apple platform
|
|
322
|
+
const platform = semver_1.default.lt(expoAutolinkingVersion, '1.10.0') ? 'ios' : 'apple';
|
|
323
|
+
try {
|
|
324
|
+
const reasons = ['expoAutolinkingIos'];
|
|
325
|
+
const results = [];
|
|
326
|
+
const realProjectRoot = await (0, Utils_1.maybeGetRealPathAsync)(projectRoot);
|
|
327
|
+
const { stdout } = await (0, Spawn_1.default)('node', [(0, ExpoResolver_1.resolveExpoAutolinkingCliPath)(projectRoot), 'resolve', '-p', platform, '--json'], { cwd: projectRoot, env: (0, Env_1.getOriginalEnv)() });
|
|
328
|
+
const config = JSON.parse(stdout);
|
|
329
|
+
for (const module of config.modules) {
|
|
330
|
+
for (const pod of module.pods) {
|
|
331
|
+
const filePath = (0, Path_1.toPosixPath)(path_1.default.relative(realProjectRoot, pod.podspecDir));
|
|
332
|
+
pod.podspecDir = filePath; // use relative path for the dir
|
|
333
|
+
debug(`Adding expo-modules-autolinking ios dir - ${chalk_1.default.dim(filePath)}`);
|
|
334
|
+
results.push(await (0, Utils_1.createAutolinkingHashSourceAsync)(realProjectRoot, filePath, reasons, options.nativeModuleSourceType));
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
results.push({
|
|
338
|
+
type: 'contents',
|
|
339
|
+
id: 'expoAutolinkingConfig:ios',
|
|
340
|
+
contents: JSON.stringify((0, Profile_1.profile)(options, AutolinkingConfig_1.normalizeAutolinkingConfig)(config, {
|
|
341
|
+
stripPaths: !!(options.sourceSkips & SourceSkips_1.SourceSkips.AutolinkingConfigPaths),
|
|
342
|
+
roots: [realProjectRoot],
|
|
343
|
+
})),
|
|
344
|
+
reasons,
|
|
345
|
+
});
|
|
346
|
+
return results;
|
|
347
|
+
}
|
|
348
|
+
catch (error) {
|
|
349
|
+
throw error;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Sort the expo-modules-autolinking android config to make it stable from hashing.
|
|
354
|
+
*/
|
|
355
|
+
function sortExpoAutolinkingAndroidConfig(config) {
|
|
356
|
+
for (const module of config.modules) {
|
|
357
|
+
// Sort the projects by project.name
|
|
358
|
+
module.projects.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
359
|
+
}
|
|
360
|
+
return config;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Get the props for a config-plugin
|
|
364
|
+
*/
|
|
365
|
+
function getConfigPluginProps(config, pluginName) {
|
|
366
|
+
const plugin = (config.plugins ?? []).find((plugin) => {
|
|
367
|
+
if (Array.isArray(plugin)) {
|
|
368
|
+
return plugin[0] === pluginName;
|
|
369
|
+
}
|
|
370
|
+
return plugin === pluginName;
|
|
371
|
+
});
|
|
372
|
+
if (Array.isArray(plugin)) {
|
|
373
|
+
return (plugin[1] ?? null);
|
|
374
|
+
}
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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.getDefaultPackageSourcesAsync = getDefaultPackageSourcesAsync;
|
|
7
|
+
exports.getPackageSourceAsync = getPackageSourceAsync;
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const resolve_from_1 = __importDefault(require("resolve-from"));
|
|
12
|
+
const Path_1 = require("../utils/Path");
|
|
13
|
+
const Utils_1 = require("./Utils");
|
|
14
|
+
const debug = require('debug')('expo:fingerprint:sourcer:Packages');
|
|
15
|
+
const DEFAULT_PACKAGES = [
|
|
16
|
+
{
|
|
17
|
+
packageName: 'react-native',
|
|
18
|
+
sourceType: 'package',
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
async function getDefaultPackageSourcesAsync(projectRoot, options) {
|
|
22
|
+
const results = await Promise.all(DEFAULT_PACKAGES.map((params) => getPackageSourceAsync(projectRoot, params)));
|
|
23
|
+
return results.filter(Boolean);
|
|
24
|
+
}
|
|
25
|
+
async function getPackageSourceAsync(projectRoot, params) {
|
|
26
|
+
const reason = `package:${params.packageName}`;
|
|
27
|
+
const packageJsonPath = resolve_from_1.default.silent(projectRoot, `${params.packageName}/package.json`);
|
|
28
|
+
if (packageJsonPath == null) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
debug(`Adding package - ${chalk_1.default.dim(params.packageName)}`);
|
|
32
|
+
if (params.sourceType === 'package') {
|
|
33
|
+
let packageJson;
|
|
34
|
+
try {
|
|
35
|
+
packageJson = JSON.parse(await promises_1.default.readFile(packageJsonPath, 'utf8'));
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
// A resolved package.json that can't be read shouldn't crash fingerprinting; skip the source.
|
|
39
|
+
if (error.code === 'ENOENT') {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
type: 'package',
|
|
46
|
+
name: packageJson.name ?? '',
|
|
47
|
+
version: packageJson.version ?? '',
|
|
48
|
+
filePath: (0, Path_1.toPosixPath)(path_1.default.relative(projectRoot, packageJsonPath)),
|
|
49
|
+
reasons: [reason],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const packageRoot = path_1.default.relative(projectRoot, path_1.default.dirname(packageJsonPath));
|
|
53
|
+
return await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, packageRoot, reason);
|
|
54
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getPatchPackageSourcesAsync = getPatchPackageSourcesAsync;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const Path_1 = require("../utils/Path");
|
|
9
|
+
const Utils_1 = require("./Utils");
|
|
10
|
+
const debug = require('debug')('expo:fingerprint:sourcer:PatchPackage');
|
|
11
|
+
async function getPatchPackageSourcesAsync(projectRoot, options) {
|
|
12
|
+
if ((0, Path_1.isIgnoredPathWithMatchObjects)('patches', options.ignoreDirMatchObjects)) {
|
|
13
|
+
debug(`Skipping dir - ${chalk_1.default.dim('patches')} (ignored by ignoreDirMatchObjects)`);
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
const result = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, 'patches', 'patchPackage');
|
|
17
|
+
if (result != null) {
|
|
18
|
+
debug(`Adding dir - ${chalk_1.default.dim('patches')}`);
|
|
19
|
+
return [result];
|
|
20
|
+
}
|
|
21
|
+
return [];
|
|
22
|
+
}
|