@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,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SourceSkips = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Bitmask of values that can be used to skip certain parts of the sources when generating a fingerprint.
|
|
6
|
+
*/
|
|
7
|
+
var SourceSkips;
|
|
8
|
+
(function (SourceSkips) {
|
|
9
|
+
/** Skip nothing. */
|
|
10
|
+
SourceSkips[SourceSkips["None"] = 0] = "None";
|
|
11
|
+
//#region - ExpoConfig source (e.g., app.json, app.config.js, etc.)
|
|
12
|
+
/**
|
|
13
|
+
* Versions in app.json, including `version`, `android.versionCode`, `ios.buildNumber`, and the
|
|
14
|
+
* platform-specific overrides `ios.version` and `android.version` (which take precedence over
|
|
15
|
+
* the top-level `version`).
|
|
16
|
+
*/
|
|
17
|
+
SourceSkips[SourceSkips["ExpoConfigVersions"] = 1] = "ExpoConfigVersions";
|
|
18
|
+
/** `runtimeVersion` in app.json if it is a string. */
|
|
19
|
+
SourceSkips[SourceSkips["ExpoConfigRuntimeVersionIfString"] = 2] = "ExpoConfigRuntimeVersionIfString";
|
|
20
|
+
/** App names in app.json, including `name`, `description`, `web.name`, `web.shortName`, and `web.description`. */
|
|
21
|
+
SourceSkips[SourceSkips["ExpoConfigNames"] = 4] = "ExpoConfigNames";
|
|
22
|
+
/** Android package name in app.json. */
|
|
23
|
+
SourceSkips[SourceSkips["ExpoConfigAndroidPackage"] = 8] = "ExpoConfigAndroidPackage";
|
|
24
|
+
/** iOS bundle identifier in app.json. */
|
|
25
|
+
SourceSkips[SourceSkips["ExpoConfigIosBundleIdentifier"] = 16] = "ExpoConfigIosBundleIdentifier";
|
|
26
|
+
/** Schemes in app.json. */
|
|
27
|
+
SourceSkips[SourceSkips["ExpoConfigSchemes"] = 32] = "ExpoConfigSchemes";
|
|
28
|
+
/** EAS project information in app.json. */
|
|
29
|
+
SourceSkips[SourceSkips["ExpoConfigEASProject"] = 64] = "ExpoConfigEASProject";
|
|
30
|
+
/** Assets in app.json, including icons and splash assets. */
|
|
31
|
+
SourceSkips[SourceSkips["ExpoConfigAssets"] = 128] = "ExpoConfigAssets";
|
|
32
|
+
/**
|
|
33
|
+
* Skip the whole ExpoConfig.
|
|
34
|
+
* Prefer the other ExpoConfig source skips when possible and use this flag with caution.
|
|
35
|
+
* This will potentially ignore some native changes that should be part of most fingerprints.
|
|
36
|
+
* E.g., adding a new config plugin, changing the app icon, or changing the app name.
|
|
37
|
+
*/
|
|
38
|
+
SourceSkips[SourceSkips["ExpoConfigAll"] = 256] = "ExpoConfigAll";
|
|
39
|
+
//#endregion - ExpoConfig source (e.g., app.json, app.config.js, etc.)
|
|
40
|
+
/**
|
|
41
|
+
* package.json scripts if android and ios items do not contain "run".
|
|
42
|
+
* Because prebuild will change the scripts in package.json,
|
|
43
|
+
* this is useful to generate a consistent fingerprint before and after prebuild.
|
|
44
|
+
*/
|
|
45
|
+
SourceSkips[SourceSkips["PackageJsonAndroidAndIosScriptsIfNotContainRun"] = 512] = "PackageJsonAndroidAndIosScriptsIfNotContainRun";
|
|
46
|
+
/**
|
|
47
|
+
* Skip the whole `scripts` section in the project's package.json.
|
|
48
|
+
*/
|
|
49
|
+
SourceSkips[SourceSkips["PackageJsonScriptsAll"] = 1024] = "PackageJsonScriptsAll";
|
|
50
|
+
/**
|
|
51
|
+
* Skip .gitignore files.
|
|
52
|
+
*/
|
|
53
|
+
SourceSkips[SourceSkips["GitIgnore"] = 2048] = "GitIgnore";
|
|
54
|
+
/** The [extra](https://docs.expo.dev/versions/latest/config/app/#extra) section in app.json */
|
|
55
|
+
SourceSkips[SourceSkips["ExpoConfigExtraSection"] = 4096] = "ExpoConfigExtraSection";
|
|
56
|
+
//#region - EAS Build source
|
|
57
|
+
/**
|
|
58
|
+
* Skip eas.json.
|
|
59
|
+
* Most of its content, such as build profiles and submit settings, does not affect the native
|
|
60
|
+
* project. Note that some fields do, e.g. `ios.buildConfiguration` or `android.gradleCommand`.
|
|
61
|
+
*/
|
|
62
|
+
SourceSkips[SourceSkips["EasJson"] = 8192] = "EasJson";
|
|
63
|
+
/**
|
|
64
|
+
* Skip .easignore.
|
|
65
|
+
* The file only controls which files are uploaded to EAS Build.
|
|
66
|
+
* Note that excluding a file that does affect the native build will not change the fingerprint.
|
|
67
|
+
*/
|
|
68
|
+
SourceSkips[SourceSkips["Easignore"] = 16384] = "Easignore";
|
|
69
|
+
//#endregion - EAS Build source
|
|
70
|
+
/**
|
|
71
|
+
* Path fields in the resolved autolinking config from `expo-modules-autolinking` and
|
|
72
|
+
* `react-native-config`.
|
|
73
|
+
* The config itself is still hashed. Filesystem paths, and values that sit under the project
|
|
74
|
+
* root, are omitted, including `scriptPhases[].path` and `sourceDir` / `podspecPath` overrides
|
|
75
|
+
* from the project's **react-native.config.js**. Those overrides will not change the fingerprint.
|
|
76
|
+
* Linked module names and `scriptPhases` names remain.
|
|
77
|
+
*/
|
|
78
|
+
SourceSkips[SourceSkips["AutolinkingConfigPaths"] = 32768] = "AutolinkingConfigPaths";
|
|
79
|
+
})(SourceSkips || (exports.SourceSkips = SourceSkips = {}));
|
|
@@ -0,0 +1,58 @@
|
|
|
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.getHashSourcesAsync = getHashSourcesAsync;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const semver_1 = __importDefault(require("semver"));
|
|
9
|
+
const ExpoConfig_1 = require("../ExpoConfig");
|
|
10
|
+
const ExpoResolver_1 = require("../ExpoResolver");
|
|
11
|
+
const Profile_1 = require("../utils/Profile");
|
|
12
|
+
const Bare_1 = require("./Bare");
|
|
13
|
+
const Expo_1 = require("./Expo");
|
|
14
|
+
const Packages_1 = require("./Packages");
|
|
15
|
+
const PatchPackage_1 = require("./PatchPackage");
|
|
16
|
+
const debug = require('debug')('expo:fingerprint:sourcer:Sourcer');
|
|
17
|
+
async function getHashSourcesAsync(projectRoot, options) {
|
|
18
|
+
const { config: expoConfig, loadedModules } = await (0, ExpoConfig_1.getExpoConfigAsync)(projectRoot, options);
|
|
19
|
+
const expoAutolinkingVersion = (0, ExpoResolver_1.resolveExpoAutolinkingVersion)(projectRoot) ?? '0.0.0';
|
|
20
|
+
const useRNCoreAutolinkingFromExpo =
|
|
21
|
+
// expo-modules-autolinking supports the `react-native-config` core autolinking from 1.11.2.
|
|
22
|
+
// To makes the `useRNCoreAutolinkingFromExpo` default to `true` for Expo SDK 52 and higher.
|
|
23
|
+
// We check the expo-modules-autolinking version from 1.12.0.
|
|
24
|
+
typeof options.useRNCoreAutolinkingFromExpo === 'boolean'
|
|
25
|
+
? options.useRNCoreAutolinkingFromExpo
|
|
26
|
+
: semver_1.default.gte(expoAutolinkingVersion, '1.12.0');
|
|
27
|
+
const results = await Promise.all([
|
|
28
|
+
// expo
|
|
29
|
+
expoAutolinkingVersion === '0.0.0' ? [] : (0, Profile_1.profile)(options, Expo_1.getExpoAutolinkingAndroidSourcesAsync)(projectRoot, options, expoAutolinkingVersion),
|
|
30
|
+
expoAutolinkingVersion === '0.0.0' ? [] : (0, Profile_1.profile)(options, Expo_1.getExpoAutolinkingIosSourcesAsync)(projectRoot, options, expoAutolinkingVersion),
|
|
31
|
+
(0, Profile_1.profile)(options, Expo_1.getExpoConfigSourcesAsync)(projectRoot, expoConfig, loadedModules, options),
|
|
32
|
+
(0, Profile_1.profile)(options, Expo_1.getEasBuildSourcesAsync)(projectRoot, options),
|
|
33
|
+
(0, Profile_1.profile)(options, Expo_1.getExpoCNGPatchSourcesAsync)(projectRoot, options),
|
|
34
|
+
// bare managed files
|
|
35
|
+
(0, Profile_1.profile)(options, Bare_1.getGitIgnoreSourcesAsync)(projectRoot, options),
|
|
36
|
+
(0, Profile_1.profile)(options, Bare_1.getPackageJsonScriptSourcesAsync)(projectRoot, options),
|
|
37
|
+
// bare native files
|
|
38
|
+
(0, Profile_1.profile)(options, Bare_1.getBareAndroidSourcesAsync)(projectRoot, options),
|
|
39
|
+
(0, Profile_1.profile)(options, Bare_1.getBareIosSourcesAsync)(projectRoot, options),
|
|
40
|
+
// react-native core autolinking
|
|
41
|
+
(0, Profile_1.profile)(options, Bare_1.getCoreAutolinkingSourcesFromExpoAndroid)(projectRoot, options, useRNCoreAutolinkingFromExpo),
|
|
42
|
+
(0, Profile_1.profile)(options, Bare_1.getCoreAutolinkingSourcesFromExpoIos)(projectRoot, options, useRNCoreAutolinkingFromExpo),
|
|
43
|
+
(0, Profile_1.profile)(options, Bare_1.getCoreAutolinkingSourcesFromRncCliAsync)(projectRoot, options, useRNCoreAutolinkingFromExpo),
|
|
44
|
+
// patch-package
|
|
45
|
+
(0, Profile_1.profile)(options, PatchPackage_1.getPatchPackageSourcesAsync)(projectRoot, options),
|
|
46
|
+
// some known dependencies, e.g. react-native
|
|
47
|
+
(0, Profile_1.profile)(options, Packages_1.getDefaultPackageSourcesAsync)(projectRoot, options),
|
|
48
|
+
]);
|
|
49
|
+
// extra sources
|
|
50
|
+
if (options.extraSources) {
|
|
51
|
+
for (const source of options.extraSources) {
|
|
52
|
+
debug(`Adding extra source - ${chalk_1.default.dim(JSON.stringify(source))}`);
|
|
53
|
+
}
|
|
54
|
+
results.push(options.extraSources);
|
|
55
|
+
}
|
|
56
|
+
// flatten results
|
|
57
|
+
return [].concat(...results);
|
|
58
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
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.createAutolinkingHashSourceAsync = createAutolinkingHashSourceAsync;
|
|
7
|
+
exports.readPackageIdentityAsync = readPackageIdentityAsync;
|
|
8
|
+
exports.getFileBasedHashSourceAsync = getFileBasedHashSourceAsync;
|
|
9
|
+
exports.maybeGetRealPathAsync = maybeGetRealPathAsync;
|
|
10
|
+
exports.stringifyJsonSorted = stringifyJsonSorted;
|
|
11
|
+
exports.relativizeJsonPaths = relativizeJsonPaths;
|
|
12
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
const Path_1 = require("../utils/Path");
|
|
15
|
+
/**
|
|
16
|
+
* Build a hash source for an autolinked native module - its `package.json` name+version for the
|
|
17
|
+
* `package` source type, otherwise its whole native directory.
|
|
18
|
+
*/
|
|
19
|
+
async function createAutolinkingHashSourceAsync(projectRoot, dirRelativePath, reasons, nativeModuleSourceType) {
|
|
20
|
+
if (nativeModuleSourceType === 'package') {
|
|
21
|
+
const packageJsonPath = (0, Path_1.getNodeModulesPackageJsonPath)(dirRelativePath);
|
|
22
|
+
if (packageJsonPath) {
|
|
23
|
+
const identity = await readPackageIdentityAsync(path_1.default.join(projectRoot, packageJsonPath));
|
|
24
|
+
if (identity) {
|
|
25
|
+
return { type: 'package', ...identity, filePath: packageJsonPath, reasons };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return { type: 'dir', filePath: dirRelativePath, reasons };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Read a package's identity — its `package.json` `name` and `version` — for a `package` source.
|
|
33
|
+
* Returns null when the `package.json` is missing so the caller can fall back to hashing files;
|
|
34
|
+
* any other read/parse error throws, matching `getPackageSourceAsync`.
|
|
35
|
+
*/
|
|
36
|
+
async function readPackageIdentityAsync(packageJsonPath) {
|
|
37
|
+
let packageJson;
|
|
38
|
+
try {
|
|
39
|
+
packageJson = JSON.parse(await promises_1.default.readFile(packageJsonPath, 'utf8'));
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (error.code === 'ENOENT') {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
return { name: packageJson.name ?? '', version: packageJson.version ?? '' };
|
|
48
|
+
}
|
|
49
|
+
async function getFileBasedHashSourceAsync(projectRoot, filePath, reason) {
|
|
50
|
+
let result = null;
|
|
51
|
+
try {
|
|
52
|
+
const stat = await promises_1.default.stat(path_1.default.join(projectRoot, filePath));
|
|
53
|
+
result = {
|
|
54
|
+
type: stat.isDirectory() ? 'dir' : 'file',
|
|
55
|
+
filePath: (0, Path_1.toPosixPath)(filePath),
|
|
56
|
+
reasons: [reason],
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
if (error.code !== 'ENOENT')
|
|
61
|
+
throw error;
|
|
62
|
+
result = null;
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Resolve path aliases before computing relative hash source paths.
|
|
68
|
+
* On Windows, temp paths can be passed as short paths like `RUNNER~1` while
|
|
69
|
+
* autolinking returns the long real path, which makes `path.relative()` unstable.
|
|
70
|
+
*/
|
|
71
|
+
async function maybeGetRealPathAsync(filePath) {
|
|
72
|
+
try {
|
|
73
|
+
return await promises_1.default.realpath(filePath);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return filePath;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A version of `JSON.stringify` that keeps the keys sorted
|
|
81
|
+
*/
|
|
82
|
+
function stringifyJsonSorted(target, space) {
|
|
83
|
+
return JSON.stringify(target, (_, value) => sortJson(value), space);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Transform absolute paths in JSON to relative paths based on the project root.
|
|
87
|
+
*/
|
|
88
|
+
function relativizeJsonPaths(value, projectRoot) {
|
|
89
|
+
if (typeof value === 'string' && value.startsWith(projectRoot)) {
|
|
90
|
+
return (0, Path_1.toPosixPath)(path_1.default.relative(projectRoot, value));
|
|
91
|
+
}
|
|
92
|
+
if (Array.isArray(value)) {
|
|
93
|
+
return value.map((item) => relativizeJsonPaths(item, projectRoot));
|
|
94
|
+
}
|
|
95
|
+
if (value && typeof value === 'object') {
|
|
96
|
+
return Object.fromEntries(Object.entries(value).map(([key, val]) => [key, relativizeJsonPaths(val, projectRoot)]));
|
|
97
|
+
}
|
|
98
|
+
return value;
|
|
99
|
+
}
|
|
100
|
+
function sortJson(json) {
|
|
101
|
+
if (Array.isArray(json)) {
|
|
102
|
+
return json.sort((a, b) => {
|
|
103
|
+
// Sort array items by their stringified value.
|
|
104
|
+
// We don't need the array to be sorted in meaningful way, just to be sorted in deterministic.
|
|
105
|
+
// E.g. `[{ b: '2' }, {}, { a: '3' }, null]` -> `[null, { a : '3' }, { b: '2' }, {}]`
|
|
106
|
+
// This result is not a perfect solution, but it's good enough for our use case.
|
|
107
|
+
const stringifiedA = stringifyJsonSorted(a);
|
|
108
|
+
const stringifiedB = stringifyJsonSorted(b);
|
|
109
|
+
if (stringifiedA < stringifiedB) {
|
|
110
|
+
return -1;
|
|
111
|
+
}
|
|
112
|
+
else if (stringifiedA > stringifiedB) {
|
|
113
|
+
return 1;
|
|
114
|
+
}
|
|
115
|
+
return 0;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (json != null && typeof json === 'object') {
|
|
119
|
+
// Sort object items by keys
|
|
120
|
+
return Object.keys(json)
|
|
121
|
+
.sort()
|
|
122
|
+
.reduce((acc, key) => {
|
|
123
|
+
acc[key] = json[key];
|
|
124
|
+
return acc;
|
|
125
|
+
}, {});
|
|
126
|
+
}
|
|
127
|
+
// Return primitives
|
|
128
|
+
return json;
|
|
129
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createLimiter = void 0;
|
|
4
|
+
const createLimiter = (limit = 1) => {
|
|
5
|
+
let running = 0;
|
|
6
|
+
let head = null;
|
|
7
|
+
let tail = null;
|
|
8
|
+
const enqueue = () => new Promise((resolve) => {
|
|
9
|
+
const item = { resolve, next: null };
|
|
10
|
+
if (tail) {
|
|
11
|
+
tail.next = item;
|
|
12
|
+
tail = item;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
head = item;
|
|
16
|
+
tail = item;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const dequeue = () => {
|
|
20
|
+
if (running < limit && head !== null) {
|
|
21
|
+
const { resolve, next } = head;
|
|
22
|
+
head.next = null;
|
|
23
|
+
head = next;
|
|
24
|
+
if (head === null) {
|
|
25
|
+
tail = null;
|
|
26
|
+
}
|
|
27
|
+
running++;
|
|
28
|
+
resolve();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return async (fn, ...args) => {
|
|
32
|
+
if (running < limit) {
|
|
33
|
+
running++;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
await enqueue();
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
return await fn(...args);
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
running--;
|
|
43
|
+
dequeue();
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
exports.createLimiter = createLimiter;
|
|
@@ -0,0 +1,28 @@
|
|
|
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.setNodeEnv = exports.getOriginalEnv = void 0;
|
|
7
|
+
exports.loadProjectEnv = loadProjectEnv;
|
|
8
|
+
const node_module_1 = require("node:module");
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const getOriginalEnv = () => ({ ...process.env });
|
|
11
|
+
exports.getOriginalEnv = getOriginalEnv;
|
|
12
|
+
const setNodeEnv = (mode, options) => ({
|
|
13
|
+
...options.systemEnv, NODE_ENV: mode,
|
|
14
|
+
});
|
|
15
|
+
exports.setNodeEnv = setNodeEnv;
|
|
16
|
+
function loadProjectEnv(projectRoot, options) {
|
|
17
|
+
process.env.NODE_ENV = options.mode;
|
|
18
|
+
const projectRequire = (0, node_module_1.createRequire)(node_path_1.default.join(projectRoot, 'package.json'));
|
|
19
|
+
const expoRequire = (0, node_module_1.createRequire)(projectRequire.resolve('expo/package.json'));
|
|
20
|
+
const env = expoRequire('@expo/env');
|
|
21
|
+
// The app owns its supported Expo environment loader, including dotenv rules.
|
|
22
|
+
if (typeof env.loadProjectEnv === 'function')
|
|
23
|
+
env.loadProjectEnv(projectRoot, options);
|
|
24
|
+
else if (typeof env.load === 'function')
|
|
25
|
+
env.load(projectRoot);
|
|
26
|
+
else
|
|
27
|
+
throw new Error('The project-local Expo environment loader is unavailable.');
|
|
28
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
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.isIgnoredPath = isIgnoredPath;
|
|
7
|
+
exports.buildPathMatchObjects = buildPathMatchObjects;
|
|
8
|
+
exports.appendIgnorePath = appendIgnorePath;
|
|
9
|
+
exports.buildDirMatchObjects = buildDirMatchObjects;
|
|
10
|
+
exports.isIgnoredPathWithMatchObjects = isIgnoredPathWithMatchObjects;
|
|
11
|
+
exports.normalizeFilePath = normalizeFilePath;
|
|
12
|
+
exports.toPosixPath = toPosixPath;
|
|
13
|
+
exports.pathExistsAsync = pathExistsAsync;
|
|
14
|
+
exports.getNodeModulesPackageJsonPath = getNodeModulesPackageJsonPath;
|
|
15
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
16
|
+
const minimatch_1 = require("minimatch");
|
|
17
|
+
const node_process_1 = __importDefault(require("node:process"));
|
|
18
|
+
const path_1 = __importDefault(require("path"));
|
|
19
|
+
/**
|
|
20
|
+
* Indicate the given `filePath` should be excluded by the `ignorePaths`.
|
|
21
|
+
*/
|
|
22
|
+
function isIgnoredPath(filePath, ignorePaths, minimatchOptions = { dot: true }) {
|
|
23
|
+
const matchObjects = buildPathMatchObjects(ignorePaths, minimatchOptions);
|
|
24
|
+
return isIgnoredPathWithMatchObjects(filePath, matchObjects);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Prebuild match objects for `isIgnoredPathWithMatchObjects` calls.
|
|
28
|
+
*/
|
|
29
|
+
function buildPathMatchObjects(paths, minimatchOptions = { dot: true }) {
|
|
30
|
+
return paths.map((filePath) => new minimatch_1.Minimatch(filePath, minimatchOptions));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Append a new ignore path to the given `matchObjects`.
|
|
34
|
+
*/
|
|
35
|
+
function appendIgnorePath(matchObjects, path, minimatchOptions = { dot: true }) {
|
|
36
|
+
matchObjects.push(new minimatch_1.Minimatch(path, minimatchOptions));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Build an ignore match objects for directories based on the given `ignorePathMatchObjects`.
|
|
40
|
+
*/
|
|
41
|
+
function buildDirMatchObjects(ignorePathMatchObjects, minimatchOptions = { dot: true }) {
|
|
42
|
+
const dirIgnorePatterns = [];
|
|
43
|
+
const ignorePaths = ignorePathMatchObjects.filter((obj) => !obj.negate).map((obj) => obj.pattern);
|
|
44
|
+
const negatedIgnorePaths = ignorePathMatchObjects
|
|
45
|
+
.filter((obj) => obj.negate)
|
|
46
|
+
.map((obj) => obj.pattern);
|
|
47
|
+
// [0] Add positive patterns to dirIgnorePatterns
|
|
48
|
+
for (const pattern of ignorePaths) {
|
|
49
|
+
if (pattern.endsWith('/**/*')) {
|
|
50
|
+
// `/**/*` matches
|
|
51
|
+
dirIgnorePatterns.push(pattern.slice(0, -5));
|
|
52
|
+
}
|
|
53
|
+
else if (pattern.endsWith('/**')) {
|
|
54
|
+
// `/**` by default matches directories
|
|
55
|
+
dirIgnorePatterns.push(pattern.slice(0, -3));
|
|
56
|
+
}
|
|
57
|
+
else if (pattern.endsWith('/')) {
|
|
58
|
+
// `/` suffix matches directories
|
|
59
|
+
dirIgnorePatterns.push(pattern.slice(0, -1));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// [1] If there is a negate pattern in the same directory, we should remove the existing directory.
|
|
63
|
+
for (const pattern of negatedIgnorePaths) {
|
|
64
|
+
for (let i = 0; i < dirIgnorePatterns.length; ++i) {
|
|
65
|
+
const existingPattern = dirIgnorePatterns[i];
|
|
66
|
+
if (existingPattern != null && isSubDirectory(existingPattern, pattern)) {
|
|
67
|
+
dirIgnorePatterns.splice(i, 1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return dirIgnorePatterns.map((pattern) => new minimatch_1.Minimatch(pattern, minimatchOptions));
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Indicate the given `filePath` should be excluded by the prebuilt `matchObjects`.
|
|
75
|
+
*/
|
|
76
|
+
function isIgnoredPathWithMatchObjects(filePath, matchObjects) {
|
|
77
|
+
let result = false;
|
|
78
|
+
for (const minimatchObj of matchObjects) {
|
|
79
|
+
const stripParentPrefix = minimatchObj.pattern.startsWith('**/');
|
|
80
|
+
const normalizedFilePath = normalizeFilePath(filePath, { stripParentPrefix });
|
|
81
|
+
const currMatch = minimatchObj.match(normalizedFilePath);
|
|
82
|
+
if (minimatchObj.negate && result && !currMatch) {
|
|
83
|
+
// Special handler for negate (!pattern).
|
|
84
|
+
// As long as previous match result is true and not matched from the current negate pattern, we should early return.
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
if (!minimatchObj.negate) {
|
|
88
|
+
result || (result = currMatch);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Returns true if `parent` is a parent directory of `child`.
|
|
95
|
+
*/
|
|
96
|
+
function isSubDirectory(parent, child) {
|
|
97
|
+
const relative = path_1.default.relative(parent, child);
|
|
98
|
+
return !relative.startsWith('..') && !path_1.default.isAbsolute(relative);
|
|
99
|
+
}
|
|
100
|
+
const STRIP_PARENT_PREFIX_REGEX = /^(\.\.\/)+/g;
|
|
101
|
+
/**
|
|
102
|
+
* Normalize the given `filePath` to be used for matching against `ignorePaths`.
|
|
103
|
+
*
|
|
104
|
+
* @param filePath The file path to normalize.
|
|
105
|
+
* @param options.stripParentPrefix
|
|
106
|
+
* When people use fingerprint inside a monorepo, they may get source files from parent directories.
|
|
107
|
+
* However, minimatch '**' doesn't match the parent directories.
|
|
108
|
+
* We need to strip the `../` prefix to match the node_modules from parent directories.
|
|
109
|
+
*/
|
|
110
|
+
function normalizeFilePath(filePath, options) {
|
|
111
|
+
if (options.stripParentPrefix) {
|
|
112
|
+
return filePath.replace(STRIP_PARENT_PREFIX_REGEX, '');
|
|
113
|
+
}
|
|
114
|
+
return filePath;
|
|
115
|
+
}
|
|
116
|
+
const REGEXP_REPLACE_SLASHES = /\\/g;
|
|
117
|
+
/**
|
|
118
|
+
* Convert any platform-specific path to a POSIX path.
|
|
119
|
+
*/
|
|
120
|
+
function toPosixPath(filePath) {
|
|
121
|
+
return node_process_1.default.platform === 'win32' ? filePath.replace(REGEXP_REPLACE_SLASHES, '/') : filePath;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Check if the given `filePath` exists.
|
|
125
|
+
*/
|
|
126
|
+
async function pathExistsAsync(filePath) {
|
|
127
|
+
try {
|
|
128
|
+
const stat = await promises_1.default.stat(filePath);
|
|
129
|
+
return stat.isFile() || stat.isDirectory();
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Given a posix path inside `node_modules`, return the owning package's `package.json` path.
|
|
137
|
+
* Returns null when the path is not inside `node_modules`. Handles scoped packages (`@scope/name`).
|
|
138
|
+
*/
|
|
139
|
+
function getNodeModulesPackageJsonPath(relativePosixPath) {
|
|
140
|
+
const marker = 'node_modules/';
|
|
141
|
+
const markerIndex = relativePosixPath.lastIndexOf(marker);
|
|
142
|
+
if (markerIndex === -1) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
const prefix = relativePosixPath.slice(0, markerIndex + marker.length);
|
|
146
|
+
const segments = relativePosixPath.slice(markerIndex + marker.length).split('/');
|
|
147
|
+
if (!segments[0]) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
let packageDir;
|
|
151
|
+
if (segments[0].startsWith('@')) {
|
|
152
|
+
if (!segments[1]) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
packageDir = `${prefix}${segments[0]}/${segments[1]}`;
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
packageDir = `${prefix}${segments[0]}`;
|
|
159
|
+
}
|
|
160
|
+
return `${packageDir}/package.json`;
|
|
161
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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.profile = profile;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
/**
|
|
9
|
+
* Wrap a method and profile the time it takes to execute the method using `EXPO_PROFILE`.
|
|
10
|
+
* Works best with named functions (i.e. not arrow functions).
|
|
11
|
+
*
|
|
12
|
+
* @param fn function to profile.
|
|
13
|
+
* @param functionName optional name of the function to display in the profile output.
|
|
14
|
+
*/
|
|
15
|
+
function profile(options, fn, functionName = fn.name) {
|
|
16
|
+
if (!process.env['DEBUG'] || options.silent) {
|
|
17
|
+
return fn;
|
|
18
|
+
}
|
|
19
|
+
const name = chalk_1.default.dim(`⏱ [profile] ${functionName ?? 'unknown'}`);
|
|
20
|
+
return ((...args) => {
|
|
21
|
+
// Start the timer.
|
|
22
|
+
console.time(name);
|
|
23
|
+
// Invoke the method.
|
|
24
|
+
const results = fn(...args);
|
|
25
|
+
// If non-promise then return as-is.
|
|
26
|
+
if (!(results instanceof Promise)) {
|
|
27
|
+
console.timeEnd(name);
|
|
28
|
+
return results;
|
|
29
|
+
}
|
|
30
|
+
// Otherwise await to profile after the promise resolves.
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
results.then((results) => {
|
|
33
|
+
resolve(results);
|
|
34
|
+
console.timeEnd(name);
|
|
35
|
+
}, (reason) => {
|
|
36
|
+
reject(reason);
|
|
37
|
+
console.timeEnd(name);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 = spawnAsync;
|
|
7
|
+
const node_child_process_1 = require("node:child_process");
|
|
8
|
+
const node_module_1 = require("node:module");
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
/** Bounded, project-local commands. No shell or implicit package installation. */
|
|
11
|
+
function spawnAsync(command, args = [], options = {}) {
|
|
12
|
+
if (command === 'node')
|
|
13
|
+
command = process.execPath;
|
|
14
|
+
if (command === 'npx') {
|
|
15
|
+
if (args.join(' ') !== 'react-native config' || typeof options.cwd !== 'string') {
|
|
16
|
+
throw new Error('Fingerprint collection cannot install or invoke arbitrary npx commands.');
|
|
17
|
+
}
|
|
18
|
+
const projectRequire = (0, node_module_1.createRequire)(node_path_1.default.join(options.cwd, 'package.json'));
|
|
19
|
+
args = [projectRequire.resolve('react-native/cli.js'), 'config'];
|
|
20
|
+
command = process.execPath;
|
|
21
|
+
}
|
|
22
|
+
const child = (0, node_child_process_1.spawn)(command, args, { ...options, shell: false, timeout: 60000 });
|
|
23
|
+
const promise = new Promise((resolve, reject) => {
|
|
24
|
+
let stdout = '';
|
|
25
|
+
let stderr = '';
|
|
26
|
+
child.stdout?.on('data', chunk => { stdout += chunk; });
|
|
27
|
+
child.stderr?.on('data', chunk => { stderr += chunk; });
|
|
28
|
+
child.on('error', reject);
|
|
29
|
+
child.on('close', status => {
|
|
30
|
+
if (status === 0)
|
|
31
|
+
resolve({ stdout, stderr, status });
|
|
32
|
+
else
|
|
33
|
+
reject(new Error(`Fingerprint subprocess failed (${command}, status ${status}): ${stderr.trim()}`));
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
promise.child = child;
|
|
37
|
+
return promise;
|
|
38
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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.spawnWithIpcAsync = spawnWithIpcAsync;
|
|
7
|
+
const Spawn_1 = __importDefault(require("./Spawn"));
|
|
8
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
9
|
+
async function spawnWithIpcAsync(command, args, options
|
|
10
|
+
// @ts-expect-error: spawnAsync returns a customized Promise
|
|
11
|
+
) {
|
|
12
|
+
(0, node_assert_1.default)(options?.stdio == null, 'Cannot override stdio when using IPC');
|
|
13
|
+
const promise = (0, Spawn_1.default)(command, args, {
|
|
14
|
+
...options,
|
|
15
|
+
stdio: ['pipe', 'pipe', 'pipe', 'ipc'],
|
|
16
|
+
});
|
|
17
|
+
const messageChunks = [];
|
|
18
|
+
const appendMessage = (message) => {
|
|
19
|
+
messageChunks.push(message);
|
|
20
|
+
};
|
|
21
|
+
promise.child.on('message', appendMessage);
|
|
22
|
+
const result = await promise;
|
|
23
|
+
promise.child.off('message', appendMessage);
|
|
24
|
+
return {
|
|
25
|
+
...result,
|
|
26
|
+
message: messageChunks.join(''),
|
|
27
|
+
};
|
|
28
|
+
}
|