@gfean/react-native-bundle-drop 0.9.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 +77 -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 +12 -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 +3 -0
- package/lib/CLI/scripts/upload-cli.js +239 -107
- 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 +26 -12
- 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,84 @@
|
|
|
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.resolveExpoVersion = resolveExpoVersion;
|
|
7
|
+
exports.resolveExpoAutolinkingPackageRoot = resolveExpoAutolinkingPackageRoot;
|
|
8
|
+
exports.resolveExpoAutolinkingCliPath = resolveExpoAutolinkingCliPath;
|
|
9
|
+
exports.resolveExpoAutolinkingVersion = resolveExpoAutolinkingVersion;
|
|
10
|
+
exports.resolveExpoConfigPluginsPackagePath = resolveExpoConfigPluginsPackagePath;
|
|
11
|
+
exports.satisfyExpoVersion = satisfyExpoVersion;
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const resolve_from_1 = __importDefault(require("resolve-from"));
|
|
14
|
+
const semver_1 = __importDefault(require("semver"));
|
|
15
|
+
let cachedExpoAutolinkingPackageRoot = null;
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the version of `expo` package in the project.
|
|
18
|
+
*/
|
|
19
|
+
function resolveExpoVersion(projectRoot) {
|
|
20
|
+
const expoPackageJsonPath = resolve_from_1.default.silent(projectRoot, 'expo/package.json');
|
|
21
|
+
if (expoPackageJsonPath) {
|
|
22
|
+
const expoPackageJson = require(expoPackageJsonPath);
|
|
23
|
+
return expoPackageJson.version;
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resolve the package root of `expo-modules-autolinking` package in the project.
|
|
29
|
+
*/
|
|
30
|
+
function resolveExpoAutolinkingPackageRoot(projectRoot) {
|
|
31
|
+
if (cachedExpoAutolinkingPackageRoot) {
|
|
32
|
+
const [cachedProjectRoot, cachedPackageRoot] = cachedExpoAutolinkingPackageRoot;
|
|
33
|
+
if (cachedProjectRoot === projectRoot) {
|
|
34
|
+
return cachedPackageRoot;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const expoPackageRoot = resolve_from_1.default.silent(projectRoot, 'expo/package.json');
|
|
38
|
+
const autolinkingPackageJsonPath = resolve_from_1.default.silent(expoPackageRoot ?? projectRoot, 'expo-modules-autolinking/package.json');
|
|
39
|
+
if (autolinkingPackageJsonPath) {
|
|
40
|
+
const autolinkingPackageRoot = path_1.default.dirname(autolinkingPackageJsonPath);
|
|
41
|
+
cachedExpoAutolinkingPackageRoot = [projectRoot, autolinkingPackageRoot];
|
|
42
|
+
return autolinkingPackageRoot;
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Resolve the path to the `expo-modules-autolinking` CLI in the project.
|
|
48
|
+
* @throws If the package is not found in the project.
|
|
49
|
+
*/
|
|
50
|
+
function resolveExpoAutolinkingCliPath(projectRoot) {
|
|
51
|
+
const autolinkingPackageRoot = resolveExpoAutolinkingPackageRoot(projectRoot);
|
|
52
|
+
if (autolinkingPackageRoot == null) {
|
|
53
|
+
throw new Error('Cannot resolve expo-modules-autolinking package in the project.');
|
|
54
|
+
}
|
|
55
|
+
return path_1.default.join(autolinkingPackageRoot, 'bin', 'expo-modules-autolinking.js');
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Resolve the version of `expo-modules-autolinking` package in the project.
|
|
59
|
+
*/
|
|
60
|
+
function resolveExpoAutolinkingVersion(projectRoot) {
|
|
61
|
+
const autolinkingPackageRoot = resolveExpoAutolinkingPackageRoot(projectRoot);
|
|
62
|
+
if (autolinkingPackageRoot) {
|
|
63
|
+
const autolinkingPackageJson = require(path_1.default.join(autolinkingPackageRoot, 'package.json'));
|
|
64
|
+
return autolinkingPackageJson.version;
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Resolve the package root of `expo/config-plugins` package in the project.
|
|
70
|
+
*/
|
|
71
|
+
function resolveExpoConfigPluginsPackagePath(projectRoot) {
|
|
72
|
+
return resolve_from_1.default.silent(projectRoot, 'expo/config-plugins') ?? null;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Resolve the `expo` package version and check if it satisfies the provided semver range.
|
|
76
|
+
* @returns `null` if the `expo` package is not found in the project.
|
|
77
|
+
*/
|
|
78
|
+
function satisfyExpoVersion(projectRoot, range) {
|
|
79
|
+
const expoVersion = resolveExpoVersion(projectRoot);
|
|
80
|
+
if (expoVersion) {
|
|
81
|
+
return semver_1.default.satisfies(expoVersion, range);
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFingerprintAsync = createFingerprintAsync;
|
|
4
|
+
exports.createProjectHashAsync = createProjectHashAsync;
|
|
5
|
+
exports.diffFingerprintChangesAsync = diffFingerprintChangesAsync;
|
|
6
|
+
exports.diffFingerprints = diffFingerprints;
|
|
7
|
+
const Dedup_1 = require("./Dedup");
|
|
8
|
+
const Options_1 = require("./Options");
|
|
9
|
+
const Sort_1 = require("./Sort");
|
|
10
|
+
const Hash_1 = require("./hash/Hash");
|
|
11
|
+
const Sourcer_1 = require("./sourcer/Sourcer");
|
|
12
|
+
/**
|
|
13
|
+
* Create a fingerprint for a project.
|
|
14
|
+
* @example
|
|
15
|
+
* ```js
|
|
16
|
+
* const fingerprint = await createFingerprintAsync('/app');
|
|
17
|
+
* console.log(fingerprint);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
async function createFingerprintAsync(projectRoot, options) {
|
|
21
|
+
const opts = await (0, Options_1.normalizeOptionsAsync)(projectRoot, options);
|
|
22
|
+
const sources = await (0, Sourcer_1.getHashSourcesAsync)(projectRoot, opts);
|
|
23
|
+
const normalizedSources = (0, Sort_1.sortSources)((0, Dedup_1.dedupSources)(sources, projectRoot));
|
|
24
|
+
const fingerprint = await (0, Hash_1.createFingerprintFromSourcesAsync)(normalizedSources, projectRoot, opts);
|
|
25
|
+
return fingerprint;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Create a native hash value for a project.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const hash = await createProjectHashAsync('/app');
|
|
33
|
+
* console.log(hash);
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
async function createProjectHashAsync(projectRoot, options) {
|
|
37
|
+
const fingerprint = await createFingerprintAsync(projectRoot, options);
|
|
38
|
+
return fingerprint.hash;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Diff the fingerprint with the fingerprint of the provided project.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* // Create a fingerprint for the project
|
|
46
|
+
* const fingerprint = await createFingerprintAsync('/app');
|
|
47
|
+
*
|
|
48
|
+
* // Make some changes to the project
|
|
49
|
+
*
|
|
50
|
+
* // Calculate the diff
|
|
51
|
+
* const diff = await diffFingerprintChangesAsync(fingerprint, '/app');
|
|
52
|
+
* console.log(diff);
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
async function diffFingerprintChangesAsync(fingerprint, projectRoot, options) {
|
|
56
|
+
const newFingerprint = await createFingerprintAsync(projectRoot, options);
|
|
57
|
+
if (fingerprint.hash === newFingerprint.hash) {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
return diffFingerprints(fingerprint, newFingerprint);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Diff two fingerprints. The implementation assumes that the sources are sorted.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* // Create a fingerprint for the project
|
|
68
|
+
* const fingerprint = await createFingerprintAsync('/app');
|
|
69
|
+
*
|
|
70
|
+
* // Make some changes to the project
|
|
71
|
+
*
|
|
72
|
+
* // Create a fingerprint again
|
|
73
|
+
* const fingerprint2 = await createFingerprintAsync('/app');
|
|
74
|
+
* const diff = await diffFingerprints(fingerprint, fingerprint2);
|
|
75
|
+
* console.log(diff);
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
function diffFingerprints(fingerprint1, fingerprint2) {
|
|
79
|
+
let index1 = 0;
|
|
80
|
+
let index2 = 0;
|
|
81
|
+
let source1 = fingerprint1.sources[index1];
|
|
82
|
+
let source2 = fingerprint2.sources[index2];
|
|
83
|
+
const diff = [];
|
|
84
|
+
while (source1 != null && source2 != null) {
|
|
85
|
+
const compareResult = (0, Sort_1.compareSource)(source1, source2);
|
|
86
|
+
if (compareResult === 0) {
|
|
87
|
+
if (source1.hash !== source2.hash) {
|
|
88
|
+
diff.push({ op: 'changed', beforeSource: source1, afterSource: source2 });
|
|
89
|
+
}
|
|
90
|
+
source1 = fingerprint1.sources[++index1];
|
|
91
|
+
source2 = fingerprint2.sources[++index2];
|
|
92
|
+
}
|
|
93
|
+
else if (compareResult < 0) {
|
|
94
|
+
diff.push({ op: 'removed', removedSource: source1 });
|
|
95
|
+
source1 = fingerprint1.sources[++index1];
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
diff.push({ op: 'added', addedSource: source2 });
|
|
99
|
+
source2 = fingerprint2.sources[++index2];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
while (source1 != null) {
|
|
103
|
+
diff.push({ op: 'removed', removedSource: source1 });
|
|
104
|
+
source1 = fingerprint1.sources[++index1];
|
|
105
|
+
}
|
|
106
|
+
while (source2 != null) {
|
|
107
|
+
diff.push({ op: 'added', addedSource: source2 });
|
|
108
|
+
source2 = fingerprint2.sources[++index2];
|
|
109
|
+
}
|
|
110
|
+
return diff;
|
|
111
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
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.DEFAULT_SOURCE_SKIPS = exports.DEFAULT_IGNORE_PATHS = exports.FINGERPRINT_IGNORE_FILENAME = void 0;
|
|
7
|
+
exports.normalizeOptionsAsync = normalizeOptionsAsync;
|
|
8
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
|
+
const os_1 = __importDefault(require("os"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const ExpoResolver_1 = require("./ExpoResolver");
|
|
12
|
+
const Presets_1 = require("./Presets");
|
|
13
|
+
const ProjectWorkflow_1 = require("./ProjectWorkflow");
|
|
14
|
+
const Path_1 = require("./utils/Path");
|
|
15
|
+
exports.FINGERPRINT_IGNORE_FILENAME = '.fingerprintignore';
|
|
16
|
+
exports.DEFAULT_IGNORE_PATHS = [
|
|
17
|
+
exports.FINGERPRINT_IGNORE_FILENAME,
|
|
18
|
+
// Android
|
|
19
|
+
'**/android/build/**/*',
|
|
20
|
+
'**/android/.cxx/**/*',
|
|
21
|
+
'**/android/.gradle/**/*',
|
|
22
|
+
'**/android/app/build/**/*',
|
|
23
|
+
'**/android/app/.cxx/**/*',
|
|
24
|
+
'**/android/app/.gradle/**/*',
|
|
25
|
+
'**/android-annotation/build/**/*',
|
|
26
|
+
'**/android-annotation/.cxx/**/*',
|
|
27
|
+
'**/android-annotation/.gradle/**/*',
|
|
28
|
+
'**/android-annotation-processor/build/**/*',
|
|
29
|
+
'**/android-annotation-processor/.cxx/**/*',
|
|
30
|
+
'**/android-annotation-processor/.gradle/**/*',
|
|
31
|
+
// Often has different line endings, thus we have to ignore it
|
|
32
|
+
'**/android/gradlew.bat',
|
|
33
|
+
// Android gradle plugins
|
|
34
|
+
'**/*-gradle-plugin/build/**/*',
|
|
35
|
+
'**/*-gradle-plugin/.cxx/**/*',
|
|
36
|
+
'**/*-gradle-plugin/.gradle/**/*',
|
|
37
|
+
// iOS
|
|
38
|
+
'**/ios/Pods/**/*',
|
|
39
|
+
'**/ios/build/**/*',
|
|
40
|
+
'**/ios/.xcode.env.local',
|
|
41
|
+
'**/ios/**/project.xcworkspace',
|
|
42
|
+
'**/ios/*.xcworkspace/xcuserdata/**/*',
|
|
43
|
+
'**/.swiftpm/**/*',
|
|
44
|
+
// System files that differ from machine to machine
|
|
45
|
+
'**/.DS_Store',
|
|
46
|
+
// Ignore all expo configs because we will read expo config in a HashSourceContents already
|
|
47
|
+
'app.config.ts',
|
|
48
|
+
'app.config.js',
|
|
49
|
+
'app.config.json',
|
|
50
|
+
'app.json',
|
|
51
|
+
// Ignore CocoaPods generated files
|
|
52
|
+
// https://github.com/expo/expo/blob/d0e39858ead9a194d90990f89903e773b9d33582/packages/expo-sqlite/ios/ExpoSQLite.podspec#L25-L36
|
|
53
|
+
// https://github.com/expo/expo/blob/d0e39858ead9a194d90990f89903e773b9d33582/packages/expo-updates/ios/EXUpdates.podspec#L51-L58
|
|
54
|
+
'**/node_modules/expo-sqlite/ios/sqlite3.[ch]',
|
|
55
|
+
'**/node_modules/expo-updates/ios/EXUpdates/BSPatch/bspatch.c',
|
|
56
|
+
// expo-modules-jsi has build artifacts
|
|
57
|
+
'**/node_modules/expo-modules-jsi/apple/{Products,.build,.DerivedData,.generated}/**/*',
|
|
58
|
+
// Ignore node binaries that might be platform dependent
|
|
59
|
+
'**/node_modules/**/*.node',
|
|
60
|
+
'**/node_modules/@img/sharp-*/**/*',
|
|
61
|
+
'**/node_modules/sharp/{build,vendor}/**/*',
|
|
62
|
+
// Precompiled autolinking patches for external packages
|
|
63
|
+
'**/node_modules/**/*.podspec.json',
|
|
64
|
+
// Ignore known 3rd party binaries artifacts
|
|
65
|
+
// It happens mostly on iOS because the autolinking root is the whole package root as its podspec
|
|
66
|
+
'**/node_modules/@shopify/react-native-skia/libs/**/*',
|
|
67
|
+
];
|
|
68
|
+
exports.DEFAULT_SOURCE_SKIPS = (0, Presets_1.resolvePreset)(Presets_1.DEFAULT_PRESET).sourceSkips;
|
|
69
|
+
async function normalizeOptionsAsync(projectRoot, options) {
|
|
70
|
+
// Bundle Drop's versioned options are the sole calculation authority.
|
|
71
|
+
const config = null;
|
|
72
|
+
const preset = (0, Presets_1.resolvePreset)(options?.preset ?? config?.preset ?? Presets_1.DEFAULT_PRESET);
|
|
73
|
+
const ignorePathMatchObjects = await collectIgnorePathsAsync(projectRoot, config?.ignorePaths, options);
|
|
74
|
+
const useCNGForPlatforms = await resolveUseCNGAsync(projectRoot, options, ignorePathMatchObjects);
|
|
75
|
+
if (useCNGForPlatforms.android) {
|
|
76
|
+
(0, Path_1.appendIgnorePath)(ignorePathMatchObjects, 'android/**/*');
|
|
77
|
+
}
|
|
78
|
+
if (useCNGForPlatforms.ios) {
|
|
79
|
+
(0, Path_1.appendIgnorePath)(ignorePathMatchObjects, 'ios/**/*');
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
// Defaults, derived from the resolved preset
|
|
83
|
+
platforms: ['android', 'ios'],
|
|
84
|
+
concurrentIoLimit: os_1.default.cpus().length,
|
|
85
|
+
hashAlgorithm: 'sha1',
|
|
86
|
+
sourceSkips: preset.sourceSkips,
|
|
87
|
+
nativeModuleSourceType: preset.nativeModuleSourceType,
|
|
88
|
+
configPluginSourceType: preset.configPluginSourceType,
|
|
89
|
+
// Options from config
|
|
90
|
+
...config,
|
|
91
|
+
// Explicit options (any explicitly provided value replaces the preset default)
|
|
92
|
+
...Object.fromEntries(Object.entries(options ?? {}).filter(([_, v]) => v != null)),
|
|
93
|
+
// These options are computed by both default and explicit options, so we put them last.
|
|
94
|
+
enableReactImportsPatcher: options?.enableReactImportsPatcher ??
|
|
95
|
+
config?.enableReactImportsPatcher ??
|
|
96
|
+
(0, ExpoResolver_1.satisfyExpoVersion)(projectRoot, '<52.0.0') ??
|
|
97
|
+
false,
|
|
98
|
+
ignorePathMatchObjects,
|
|
99
|
+
ignoreDirMatchObjects: (0, Path_1.buildDirMatchObjects)(ignorePathMatchObjects),
|
|
100
|
+
useCNGForPlatforms,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
async function collectIgnorePathsAsync(projectRoot, pathsFromConfig, options) {
|
|
104
|
+
const ignorePaths = [
|
|
105
|
+
...exports.DEFAULT_IGNORE_PATHS,
|
|
106
|
+
...(pathsFromConfig ?? []),
|
|
107
|
+
...(options?.ignorePaths ?? []),
|
|
108
|
+
...(options?.dirExcludes?.map((dirExclude) => `${dirExclude}/**/*`) ?? []),
|
|
109
|
+
];
|
|
110
|
+
const fingerprintIgnorePath = path_1.default.join(projectRoot, exports.FINGERPRINT_IGNORE_FILENAME);
|
|
111
|
+
try {
|
|
112
|
+
const fingerprintIgnore = await promises_1.default.readFile(fingerprintIgnorePath, 'utf8');
|
|
113
|
+
const fingerprintIgnoreLines = fingerprintIgnore.split('\n');
|
|
114
|
+
for (const line of fingerprintIgnoreLines) {
|
|
115
|
+
const trimmedLine = line.trim();
|
|
116
|
+
if (trimmedLine) {
|
|
117
|
+
ignorePaths.push(trimmedLine);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch { }
|
|
122
|
+
return (0, Path_1.buildPathMatchObjects)(ignorePaths);
|
|
123
|
+
}
|
|
124
|
+
async function resolveUseCNGAsync(projectRoot, options, ignorePathMatchObjects) {
|
|
125
|
+
const results = {
|
|
126
|
+
android: false,
|
|
127
|
+
ios: false,
|
|
128
|
+
};
|
|
129
|
+
const platforms = options?.platforms ?? ['android', 'ios'];
|
|
130
|
+
for (const platform of platforms) {
|
|
131
|
+
const explicitMode = options?.bundleDropNativeProjectMode?.[platform];
|
|
132
|
+
if (explicitMode) {
|
|
133
|
+
results[platform] = explicitMode === 'cng';
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
const projectWorkflow = await (0, ProjectWorkflow_1.resolveProjectWorkflowAsync)(projectRoot, platform, ignorePathMatchObjects);
|
|
137
|
+
results[platform] = projectWorkflow === 'managed';
|
|
138
|
+
}
|
|
139
|
+
return results;
|
|
140
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_PRESET = void 0;
|
|
4
|
+
exports.resolvePreset = resolvePreset;
|
|
5
|
+
const SourceSkips_1 = require("./sourcer/SourceSkips");
|
|
6
|
+
/**
|
|
7
|
+
* The preset used when a project doesn't configure one.
|
|
8
|
+
*/
|
|
9
|
+
exports.DEFAULT_PRESET = 'balanced';
|
|
10
|
+
/**
|
|
11
|
+
* Resolve a preset name to the settings it stands for.
|
|
12
|
+
*
|
|
13
|
+
* - `strict`: highest fidelity - the historical default. Only skips prebuild-mutated package.json
|
|
14
|
+
* scripts so a fingerprint stays consistent before and after prebuild. Autolinking config is
|
|
15
|
+
* still sorted before hashing, so the fingerprint changes once on upgrade.
|
|
16
|
+
* - `balanced`: the default. Also ignores app version and string runtime version churn, the EAS
|
|
17
|
+
* Build files (`eas.json` and `.easignore`), and path fields in the resolved autolinking config,
|
|
18
|
+
* and hashes autolinked packages and node_modules config-plugin modules by their `package.json`
|
|
19
|
+
* version. Best first-time experience.
|
|
20
|
+
* - `relaxed`: for building multiple variants from one native project. Additionally ignores app
|
|
21
|
+
* names, bundle identifiers, schemes, and assets, while still hashing the config-plugins list so
|
|
22
|
+
* adding a plugin still changes the fingerprint.
|
|
23
|
+
*/
|
|
24
|
+
function resolvePreset(preset) {
|
|
25
|
+
switch (preset) {
|
|
26
|
+
case 'strict':
|
|
27
|
+
return {
|
|
28
|
+
sourceSkips: SourceSkips_1.SourceSkips.PackageJsonAndroidAndIosScriptsIfNotContainRun,
|
|
29
|
+
nativeModuleSourceType: 'files',
|
|
30
|
+
configPluginSourceType: 'files',
|
|
31
|
+
};
|
|
32
|
+
case 'balanced':
|
|
33
|
+
return {
|
|
34
|
+
sourceSkips: SourceSkips_1.SourceSkips.PackageJsonAndroidAndIosScriptsIfNotContainRun |
|
|
35
|
+
SourceSkips_1.SourceSkips.ExpoConfigVersions |
|
|
36
|
+
SourceSkips_1.SourceSkips.ExpoConfigRuntimeVersionIfString |
|
|
37
|
+
SourceSkips_1.SourceSkips.EasJson |
|
|
38
|
+
SourceSkips_1.SourceSkips.Easignore |
|
|
39
|
+
SourceSkips_1.SourceSkips.AutolinkingConfigPaths,
|
|
40
|
+
nativeModuleSourceType: 'package',
|
|
41
|
+
configPluginSourceType: 'package',
|
|
42
|
+
};
|
|
43
|
+
case 'relaxed':
|
|
44
|
+
return {
|
|
45
|
+
sourceSkips: SourceSkips_1.SourceSkips.PackageJsonAndroidAndIosScriptsIfNotContainRun |
|
|
46
|
+
SourceSkips_1.SourceSkips.ExpoConfigVersions |
|
|
47
|
+
SourceSkips_1.SourceSkips.ExpoConfigRuntimeVersionIfString |
|
|
48
|
+
SourceSkips_1.SourceSkips.EasJson |
|
|
49
|
+
SourceSkips_1.SourceSkips.Easignore |
|
|
50
|
+
SourceSkips_1.SourceSkips.AutolinkingConfigPaths |
|
|
51
|
+
SourceSkips_1.SourceSkips.ExpoConfigNames |
|
|
52
|
+
SourceSkips_1.SourceSkips.ExpoConfigAndroidPackage |
|
|
53
|
+
SourceSkips_1.SourceSkips.ExpoConfigIosBundleIdentifier |
|
|
54
|
+
SourceSkips_1.SourceSkips.ExpoConfigSchemes |
|
|
55
|
+
SourceSkips_1.SourceSkips.ExpoConfigAssets,
|
|
56
|
+
nativeModuleSourceType: 'package',
|
|
57
|
+
configPluginSourceType: 'package',
|
|
58
|
+
};
|
|
59
|
+
default:
|
|
60
|
+
throw new Error(`Invalid fingerprint preset: ${preset}. Supported presets are 'strict', 'balanced', and 'relaxed'.`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
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.resolveProjectWorkflowAsync = resolveProjectWorkflowAsync;
|
|
7
|
+
exports.resolveProjectWorkflowPerPlatformAsync = resolveProjectWorkflowPerPlatformAsync;
|
|
8
|
+
const Spawn_1 = __importDefault(require("./utils/Spawn"));
|
|
9
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
10
|
+
const glob_1 = require("glob");
|
|
11
|
+
const ignore_1 = __importDefault(require("ignore"));
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const ExpoResolver_1 = require("./ExpoResolver");
|
|
14
|
+
const Path_1 = require("./utils/Path");
|
|
15
|
+
/**
|
|
16
|
+
* Replicated project workflow detection logic from expo-updates:
|
|
17
|
+
* - https://github.com/expo/expo/blob/9b829e0749b8ff04f55a02b03cd1fefa74c5cd8d/packages/expo-updates/utils/src/workflow.ts
|
|
18
|
+
* - https://github.com/expo/expo/blob/9b829e0749b8ff04f55a02b03cd1fefa74c5cd8d/packages/expo-updates/utils/src/vcs.ts
|
|
19
|
+
*/
|
|
20
|
+
async function resolveProjectWorkflowAsync(projectRoot, platform, fingerprintIgnorePaths) {
|
|
21
|
+
const configPluginsPackageRoot = (0, ExpoResolver_1.resolveExpoConfigPluginsPackagePath)(projectRoot);
|
|
22
|
+
if (configPluginsPackageRoot == null) {
|
|
23
|
+
return 'unknown';
|
|
24
|
+
}
|
|
25
|
+
const { AndroidConfig, IOSConfig } = require(configPluginsPackageRoot);
|
|
26
|
+
let platformWorkflowMarkers;
|
|
27
|
+
try {
|
|
28
|
+
platformWorkflowMarkers =
|
|
29
|
+
platform === 'android'
|
|
30
|
+
? [
|
|
31
|
+
path_1.default.join(projectRoot, 'android/app/build.gradle'),
|
|
32
|
+
await AndroidConfig.Paths.getAndroidManifestAsync(projectRoot),
|
|
33
|
+
]
|
|
34
|
+
: [IOSConfig.Paths.getPBXProjectPath(projectRoot)];
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return 'managed';
|
|
38
|
+
}
|
|
39
|
+
const vcsClient = await getVCSClientAsync(projectRoot);
|
|
40
|
+
const vcsRoot = path_1.default.normalize(await vcsClient.getRootPathAsync());
|
|
41
|
+
for (const marker of platformWorkflowMarkers) {
|
|
42
|
+
const relativeMarker = (0, Path_1.toPosixPath)(path_1.default.relative(vcsRoot, marker));
|
|
43
|
+
if ((await (0, Path_1.pathExistsAsync)(marker)) &&
|
|
44
|
+
!(0, Path_1.isIgnoredPathWithMatchObjects)(relativeMarker, fingerprintIgnorePaths) &&
|
|
45
|
+
!(await vcsClient.isFileIgnoredAsync(relativeMarker))) {
|
|
46
|
+
return 'generic';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return 'managed';
|
|
50
|
+
}
|
|
51
|
+
async function resolveProjectWorkflowPerPlatformAsync(projectRoot, fingerprintIgnorePaths) {
|
|
52
|
+
const [android, ios] = await Promise.all([
|
|
53
|
+
resolveProjectWorkflowAsync(projectRoot, 'android', fingerprintIgnorePaths),
|
|
54
|
+
resolveProjectWorkflowAsync(projectRoot, 'ios', fingerprintIgnorePaths),
|
|
55
|
+
]);
|
|
56
|
+
return { android, ios };
|
|
57
|
+
}
|
|
58
|
+
async function getVCSClientAsync(projectRoot) {
|
|
59
|
+
if (await isGitInstalledAndConfiguredAsync(projectRoot)) {
|
|
60
|
+
return new GitClient(projectRoot);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return new NoVCSClient(projectRoot);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
class GitClient {
|
|
67
|
+
constructor(projectRoot) {
|
|
68
|
+
this.projectRoot = projectRoot;
|
|
69
|
+
}
|
|
70
|
+
async getRootPathAsync() {
|
|
71
|
+
return (await (0, Spawn_1.default)('git', ['rev-parse', '--show-toplevel'], { cwd: this.projectRoot })).stdout.trim();
|
|
72
|
+
}
|
|
73
|
+
async isFileIgnoredAsync(filePath) {
|
|
74
|
+
try {
|
|
75
|
+
await (0, Spawn_1.default)('git', ['check-ignore', '-q', filePath], {
|
|
76
|
+
cwd: path_1.default.normalize(await this.getRootPathAsync()),
|
|
77
|
+
});
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
class NoVCSClient {
|
|
86
|
+
constructor(projectRoot) {
|
|
87
|
+
this.projectRoot = projectRoot;
|
|
88
|
+
}
|
|
89
|
+
async getRootPathAsync() {
|
|
90
|
+
return this.projectRoot;
|
|
91
|
+
}
|
|
92
|
+
async isFileIgnoredAsync(filePath) {
|
|
93
|
+
const ignore = new Ignore(this.projectRoot);
|
|
94
|
+
await ignore.initIgnoreAsync();
|
|
95
|
+
return ignore.ignores(filePath);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async function isGitInstalledAndConfiguredAsync(projectRoot) {
|
|
99
|
+
try {
|
|
100
|
+
await (0, Spawn_1.default)('git', ['--help']);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
if (error.code === 'ENOENT') {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
await (0, Spawn_1.default)('git', ['rev-parse', '--show-toplevel'], { cwd: projectRoot });
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
const GITIGNORE_FILENAME = '.gitignore';
|
|
117
|
+
const DEFAULT_IGNORE = `
|
|
118
|
+
.git
|
|
119
|
+
node_modules
|
|
120
|
+
`;
|
|
121
|
+
/**
|
|
122
|
+
* Ignore wraps the 'ignore' package to support multiple .gitignore files
|
|
123
|
+
* in subdirectories.
|
|
124
|
+
*
|
|
125
|
+
* Inconsistencies with git behavior:
|
|
126
|
+
* - if parent .gitignore has ignore rule and child has exception to that rule,
|
|
127
|
+
* file will still be ignored,
|
|
128
|
+
* - node_modules is always ignored
|
|
129
|
+
*
|
|
130
|
+
* Differs from the eas-cli Ignore class by not using `.easignore`. Otherwise this is copied. May try
|
|
131
|
+
* to merge the implementations soon.
|
|
132
|
+
*/
|
|
133
|
+
class Ignore {
|
|
134
|
+
constructor(rootDir) {
|
|
135
|
+
this.rootDir = rootDir;
|
|
136
|
+
this.ignoreMapping = [];
|
|
137
|
+
}
|
|
138
|
+
async initIgnoreAsync() {
|
|
139
|
+
const ignoreFilePaths = (await (0, glob_1.glob)(`**/${GITIGNORE_FILENAME}`, {
|
|
140
|
+
cwd: this.rootDir,
|
|
141
|
+
ignore: ['node_modules'],
|
|
142
|
+
follow: false,
|
|
143
|
+
}))
|
|
144
|
+
// ensure that parent dir is before child directories
|
|
145
|
+
.sort((a, b) => a.length - b.length && a.localeCompare(b));
|
|
146
|
+
const ignoreMapping = await Promise.all(ignoreFilePaths.map(async (filePath) => {
|
|
147
|
+
return [
|
|
148
|
+
filePath.slice(0, filePath.length - GITIGNORE_FILENAME.length),
|
|
149
|
+
(0, ignore_1.default)().add(await promises_1.default.readFile(path_1.default.join(this.rootDir, filePath), 'utf-8')),
|
|
150
|
+
];
|
|
151
|
+
}));
|
|
152
|
+
this.ignoreMapping = [['', (0, ignore_1.default)().add(DEFAULT_IGNORE)], ...ignoreMapping];
|
|
153
|
+
}
|
|
154
|
+
ignores(relativePath) {
|
|
155
|
+
for (const [prefix, ignore] of this.ignoreMapping) {
|
|
156
|
+
if (relativePath.startsWith(prefix) && ignore.ignores(relativePath.slice(prefix.length))) {
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
//#endregion - a copy of vcs client and ignore handler from expo-updates
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sortSources = sortSources;
|
|
4
|
+
exports.compareSource = compareSource;
|
|
5
|
+
const compareText = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
6
|
+
function sortSources(sources) {
|
|
7
|
+
return sources.sort(compareSource);
|
|
8
|
+
}
|
|
9
|
+
const typeOrder = {
|
|
10
|
+
file: 0,
|
|
11
|
+
dir: 1,
|
|
12
|
+
contents: 2,
|
|
13
|
+
package: 3,
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Comparator between two sources.
|
|
17
|
+
* This is useful for sorting sources in a consistent order.
|
|
18
|
+
* @returns:
|
|
19
|
+
* == 0 if a and b are equal,
|
|
20
|
+
* < 0 if a is less than b,
|
|
21
|
+
* > 0 if a is greater than b.
|
|
22
|
+
*/
|
|
23
|
+
function compareSource(a, b) {
|
|
24
|
+
const typeResult = typeOrder[a.type] - typeOrder[b.type];
|
|
25
|
+
if (typeResult === 0) {
|
|
26
|
+
if (a.type === 'file' && b.type === 'file') {
|
|
27
|
+
const aValue = a.overrideHashKey ?? a.filePath;
|
|
28
|
+
const bValue = b.overrideHashKey ?? b.filePath;
|
|
29
|
+
return compareText(aValue, bValue);
|
|
30
|
+
}
|
|
31
|
+
else if (a.type === 'dir' && b.type === 'dir') {
|
|
32
|
+
const aValue = a.overrideHashKey ?? a.filePath;
|
|
33
|
+
const bValue = b.overrideHashKey ?? b.filePath;
|
|
34
|
+
return compareText(aValue, bValue);
|
|
35
|
+
}
|
|
36
|
+
else if (a.type === 'contents' && b.type === 'contents') {
|
|
37
|
+
return compareText(a.id, b.id);
|
|
38
|
+
}
|
|
39
|
+
else if (a.type === 'package' && b.type === 'package') {
|
|
40
|
+
const aValue = a.overrideHashKey ?? `${a.name}@${a.version}`;
|
|
41
|
+
const bValue = b.overrideHashKey ?? `${b.name}@${b.version}`;
|
|
42
|
+
return compareText(aValue, bValue);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return typeResult;
|
|
46
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileHookTransform = void 0;
|
|
4
|
+
const stream_1 = require("stream");
|
|
5
|
+
/**
|
|
6
|
+
* A transform stream that allows to hook into file contents and transform them.
|
|
7
|
+
*/
|
|
8
|
+
class FileHookTransform extends stream_1.Transform {
|
|
9
|
+
constructor(source, transformFn, debug) {
|
|
10
|
+
super();
|
|
11
|
+
this.source = source;
|
|
12
|
+
this.transformFn = transformFn;
|
|
13
|
+
this.debug = debug;
|
|
14
|
+
this._isTransformed = undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Indicates whether the file content has been transformed.
|
|
18
|
+
* @returns boolean value if `debug` is true, otherwise the value would be undefined.
|
|
19
|
+
*/
|
|
20
|
+
get isTransformed() {
|
|
21
|
+
return this._isTransformed;
|
|
22
|
+
}
|
|
23
|
+
//#region - Transform implementations
|
|
24
|
+
_transform(chunk, encoding, callback) {
|
|
25
|
+
const result = this.transformFn(this.source, chunk, false /* isEndOfFile */, encoding);
|
|
26
|
+
if (this.debug) {
|
|
27
|
+
this._isTransformed || (this._isTransformed = chunk !== result);
|
|
28
|
+
}
|
|
29
|
+
if (result) {
|
|
30
|
+
this.push(result);
|
|
31
|
+
}
|
|
32
|
+
callback();
|
|
33
|
+
}
|
|
34
|
+
_flush(callback) {
|
|
35
|
+
const result = this.transformFn(this.source, null, true /* isEndOfFile */, 'utf8');
|
|
36
|
+
if (result) {
|
|
37
|
+
this.push(result);
|
|
38
|
+
}
|
|
39
|
+
callback();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.FileHookTransform = FileHookTransform;
|