@expo/fingerprint 0.20.12 → 0.21.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/build/Config.js +69 -44
- package/build/Config.js.map +1 -1
- package/build/Dedup.js +82 -36
- package/build/Dedup.js.map +1 -1
- package/build/ExpoConfig.d.ts +11 -2
- package/build/ExpoConfig.js +118 -34
- package/build/ExpoConfig.js.map +1 -1
- package/build/ExpoConfigLoader.d.ts +41 -0
- package/build/ExpoConfigLoader.js +185 -145
- package/build/ExpoConfigLoader.js.map +1 -1
- package/build/ExpoResolver.js +77 -43
- package/build/ExpoResolver.js.map +1 -1
- package/build/Fingerprint.js +67 -76
- package/build/Fingerprint.js.map +1 -1
- package/build/Fingerprint.types.d.ts +98 -5
- package/build/Fingerprint.types.js +6 -3
- package/build/Fingerprint.types.js.map +1 -1
- package/build/Options.d.ts +1 -2
- package/build/Options.js +101 -49
- package/build/Options.js.map +1 -1
- package/build/Presets.d.ts +24 -0
- package/build/Presets.js +50 -0
- package/build/Presets.js.map +1 -0
- package/build/ProjectWorkflow.js +129 -67
- package/build/ProjectWorkflow.js.map +1 -1
- package/build/Sort.js +30 -16
- package/build/Sort.js.map +1 -1
- package/build/hash/FileHookTransform.js +26 -20
- package/build/hash/FileHookTransform.js.map +1 -1
- package/build/hash/Hash.d.ts +8 -1
- package/build/hash/Hash.js +204 -116
- package/build/hash/Hash.js.map +1 -1
- package/build/hash/ReactImportsPatcher.js +39 -27
- package/build/hash/ReactImportsPatcher.js.map +1 -1
- package/build/index.js +40 -22
- package/build/index.js.map +1 -1
- package/build/sourcer/Bare.js +184 -93
- package/build/sourcer/Bare.js.map +1 -1
- package/build/sourcer/Expo.d.ts +3 -2
- package/build/sourcer/Expo.js +250 -119
- package/build/sourcer/Expo.js.map +1 -1
- package/build/sourcer/Packages.d.ts +4 -3
- package/build/sourcer/Packages.js +83 -23
- package/build/sourcer/Packages.js.map +1 -1
- package/build/sourcer/PatchPackage.js +32 -14
- package/build/sourcer/PatchPackage.js.map +1 -1
- package/build/sourcer/SourceSkips.d.ts +18 -2
- package/build/sourcer/SourceSkips.js +53 -45
- package/build/sourcer/SourceSkips.js.map +1 -1
- package/build/sourcer/Sourcer.js +57 -38
- package/build/sourcer/Sourcer.js.map +1 -1
- package/build/sourcer/Utils.d.ts +14 -0
- package/build/sourcer/Utils.js +113 -41
- package/build/sourcer/Utils.js.map +1 -1
- package/build/types/module.d.ts +7 -0
- package/build/utils/Concurrency.js +29 -22
- package/build/utils/Concurrency.js.map +1 -1
- package/build/utils/Path.d.ts +5 -0
- package/build/utils/Path.js +138 -75
- package/build/utils/Path.js.map +1 -1
- package/build/utils/Predicates.js +11 -3
- package/build/utils/Predicates.js.map +1 -1
- package/build/utils/Profile.js +29 -20
- package/build/utils/Profile.js.map +1 -1
- package/build/utils/SpawnIPC.js +41 -16
- package/build/utils/SpawnIPC.js.map +1 -1
- package/cli/build/cli.js +94 -60
- package/cli/build/cli.js.map +1 -0
- package/cli/build/commands/diffFingerprints.js +76 -53
- package/cli/build/commands/diffFingerprints.js.map +1 -0
- package/cli/build/commands/generateFingerprint.js +129 -72
- package/cli/build/commands/generateFingerprint.js.map +1 -0
- package/cli/build/runLegacyCLIAsync.js +31 -22
- package/cli/build/runLegacyCLIAsync.js.map +1 -0
- package/cli/build/utils/args.js +110 -67
- package/cli/build/utils/args.js.map +1 -0
- package/cli/build/utils/errors.js +49 -20
- package/cli/build/utils/errors.js.map +1 -0
- package/cli/build/utils/log.js +62 -20
- package/cli/build/utils/log.js.map +1 -0
- package/cli/build/utils/readFingerprintFileAsync.js +25 -9
- package/cli/build/utils/readFingerprintFileAsync.js.map +1 -0
- package/cli/build/utils/withConsoleDisabledAsync.js +16 -8
- package/cli/build/utils/withConsoleDisabledAsync.js.map +1 -0
- package/package.json +37 -31
package/build/Config.js
CHANGED
|
@@ -1,27 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
0 && (module.exports = {
|
|
6
|
+
loadConfigAsync: null,
|
|
7
|
+
normalizeSourceSkips: null
|
|
8
|
+
});
|
|
9
|
+
function _export(target, all) {
|
|
10
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
_export(exports, {
|
|
16
|
+
get loadConfigAsync () {
|
|
17
|
+
return loadConfigAsync;
|
|
18
|
+
},
|
|
19
|
+
get normalizeSourceSkips () {
|
|
20
|
+
return normalizeSourceSkips;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
function _promises() {
|
|
24
|
+
const data = /*#__PURE__*/ _interop_require_default(require("fs/promises"));
|
|
25
|
+
_promises = function() {
|
|
26
|
+
return data;
|
|
27
|
+
};
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
function _path() {
|
|
31
|
+
const data = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
32
|
+
_path = function() {
|
|
33
|
+
return data;
|
|
34
|
+
};
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
const _SourceSkips = require("./sourcer/SourceSkips");
|
|
38
|
+
function _interop_require_default(obj) {
|
|
39
|
+
return obj && obj.__esModule ? obj : {
|
|
40
|
+
default: obj
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const CONFIG_FILES = [
|
|
44
|
+
'fingerprint.config.js',
|
|
45
|
+
'fingerprint.config.cjs'
|
|
46
|
+
];
|
|
12
47
|
const debug = require('debug')('expo:fingerprint:Config');
|
|
13
|
-
/**
|
|
14
|
-
* Load the fingerprint.config.js from project root.
|
|
15
|
-
* @param projectRoot The project root directory.
|
|
16
|
-
* @param silent Whether to mute console logs when loading the config. This is useful for expo-updates integration and makes sure the JSON output is valid.
|
|
17
|
-
* @returns The loaded config or null if no config file was found.
|
|
18
|
-
*/
|
|
19
48
|
async function loadConfigAsync(projectRoot, silent = false) {
|
|
20
49
|
let configFile;
|
|
21
50
|
try {
|
|
22
51
|
configFile = await resolveConfigFileAsync(projectRoot);
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
52
|
+
} catch {
|
|
25
53
|
return null;
|
|
26
54
|
}
|
|
27
55
|
debug('Resolved config file:', configFile);
|
|
@@ -29,13 +57,13 @@ async function loadConfigAsync(projectRoot, silent = false) {
|
|
|
29
57
|
let rawConfig;
|
|
30
58
|
try {
|
|
31
59
|
rawConfig = require(configFile);
|
|
32
|
-
}
|
|
33
|
-
catch (e) {
|
|
60
|
+
} catch (e) {
|
|
34
61
|
debug('Error loading config file:', e);
|
|
35
62
|
rawConfig = {};
|
|
36
63
|
}
|
|
37
64
|
unregisterMuteLogs?.();
|
|
38
65
|
const supportedConfigKeys = [
|
|
66
|
+
'preset',
|
|
39
67
|
'concurrentIoLimit',
|
|
40
68
|
'hashAlgorithm',
|
|
41
69
|
'ignorePaths',
|
|
@@ -43,39 +71,37 @@ async function loadConfigAsync(projectRoot, silent = false) {
|
|
|
43
71
|
'sourceSkips',
|
|
44
72
|
'enableReactImportsPatcher',
|
|
45
73
|
'useRNCoreAutolinkingFromExpo',
|
|
74
|
+
'nativeModuleSourceType',
|
|
75
|
+
'configPluginSourceType',
|
|
46
76
|
'debug',
|
|
47
|
-
'fileHookTransform'
|
|
77
|
+
'fileHookTransform'
|
|
48
78
|
];
|
|
49
79
|
const config = {};
|
|
50
|
-
for (const key of supportedConfigKeys)
|
|
80
|
+
for (const key of supportedConfigKeys){
|
|
51
81
|
if (key in rawConfig) {
|
|
52
82
|
if (key === 'sourceSkips') {
|
|
53
83
|
config[key] = normalizeSourceSkips(rawConfig[key]);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
84
|
+
} else {
|
|
56
85
|
config[key] = rawConfig[key];
|
|
57
86
|
}
|
|
58
87
|
}
|
|
59
88
|
}
|
|
60
89
|
return config;
|
|
61
90
|
}
|
|
62
|
-
/**
|
|
63
|
-
* Normalize the sourceSkips from enum number or string array to a valid enum number.
|
|
64
|
-
*/
|
|
65
91
|
function normalizeSourceSkips(sourceSkips) {
|
|
66
92
|
if (sourceSkips == null) {
|
|
67
|
-
return
|
|
93
|
+
return _SourceSkips.SourceSkips.None;
|
|
68
94
|
}
|
|
69
95
|
if (typeof sourceSkips === 'number') {
|
|
70
96
|
return sourceSkips;
|
|
71
97
|
}
|
|
72
98
|
if (Array.isArray(sourceSkips)) {
|
|
73
|
-
let result =
|
|
74
|
-
for (const value of sourceSkips)
|
|
99
|
+
let result = _SourceSkips.SourceSkips.None;
|
|
100
|
+
for (const value of sourceSkips){
|
|
75
101
|
if (typeof value !== 'string') {
|
|
76
102
|
continue;
|
|
77
103
|
}
|
|
78
|
-
const skipValue =
|
|
104
|
+
const skipValue = _SourceSkips.SourceSkips[value];
|
|
79
105
|
if (skipValue != null) {
|
|
80
106
|
result |= skipValue;
|
|
81
107
|
}
|
|
@@ -86,11 +112,10 @@ function normalizeSourceSkips(sourceSkips) {
|
|
|
86
112
|
}
|
|
87
113
|
/**
|
|
88
114
|
* Resolve the config file path from the project root.
|
|
89
|
-
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
const stat = await promises_1.default.stat(configPath);
|
|
115
|
+
*/ async function resolveConfigFileAsync(projectRoot) {
|
|
116
|
+
return await Promise.any(CONFIG_FILES.map(async (file)=>{
|
|
117
|
+
const configPath = _path().default.resolve(projectRoot, file);
|
|
118
|
+
const stat = await _promises().default.stat(configPath);
|
|
94
119
|
if (!stat.isFile()) {
|
|
95
120
|
throw new Error(`Config file is not a file: ${configPath}`);
|
|
96
121
|
}
|
|
@@ -100,21 +125,21 @@ async function resolveConfigFileAsync(projectRoot) {
|
|
|
100
125
|
/**
|
|
101
126
|
* Monkey-patch the console to mute logs.
|
|
102
127
|
* @returns A function to unregister the monkey-patch.
|
|
103
|
-
*/
|
|
104
|
-
function muteLogs() {
|
|
128
|
+
*/ function muteLogs() {
|
|
105
129
|
const originalConsole = {
|
|
106
130
|
log: console.log,
|
|
107
131
|
warn: console.warn,
|
|
108
|
-
error: console.error
|
|
132
|
+
error: console.error
|
|
109
133
|
};
|
|
110
|
-
const unregister = ()
|
|
134
|
+
const unregister = ()=>{
|
|
111
135
|
console.log = originalConsole.log;
|
|
112
136
|
console.warn = originalConsole.warn;
|
|
113
137
|
console.error = originalConsole.error;
|
|
114
138
|
};
|
|
115
|
-
console.log = ()
|
|
116
|
-
console.warn = ()
|
|
117
|
-
console.error = ()
|
|
139
|
+
console.log = ()=>{};
|
|
140
|
+
console.warn = ()=>{};
|
|
141
|
+
console.error = ()=>{};
|
|
118
142
|
return unregister;
|
|
119
143
|
}
|
|
120
|
-
|
|
144
|
+
|
|
145
|
+
//# sourceMappingURL=Config.js.map
|
package/build/Config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["Config.ts"],"sourcesContent":[null],"names":["loadConfigAsync","normalizeSourceSkips","CONFIG_FILES","debug","require","projectRoot","silent","configFile","resolveConfigFileAsync","unregisterMuteLogs","muteLogs","rawConfig","e","supportedConfigKeys","config","key","sourceSkips","SourceSkips","None","Array","isArray","result","value","skipValue","Error","Promise","any","map","file","configPath","path","resolve","stat","fs","isFile","originalConsole","log","console","warn","error","unregister"],"mappings":";;;;;;;;;;;;;;;QAoBsBA;eAAAA;;QAoDNC;eAAAA;;;;gEAxED;;;;;;;gEACE;;;;;;6BAGW;;;;;;AAE5B,MAAMC,eAAe;IAAC;IAAyB;CAAyB;AAExE,MAAMC,QAAQC,QAAQ,SAAS;AAYxB,eAAeJ,gBACpBK,WAAmB,EACnBC,SAAkB,KAAK;IAEvB,IAAIC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,CAAC1B,aAAauB;QAC7C,MAAMI,OAAO,MAAMC,mBAAE,CAACD,IAAI,CAACH;QAC3B,IAAI,CAACG,KAAKE,MAAM,IAAI;YAClB,MAAM,IAAIV,MAAM,CAAC,2BAA2B,EAAEK,YAAY;QAC5D;QACA,OAAOA;IACT;AAEJ;AAEA;;;CAGC,GACD,SAASnB;IACP,MAAMyB,kBAAkB;QACtBC,KAAKC,QAAQD,GAAG;QAChBE,MAAMD,QAAQC,IAAI;QAClBC,OAAOF,QAAQE,KAAK;IACtB;IACA,MAAMC,aAAa;QACjBH,QAAQD,GAAG,GAAGD,gBAAgBC,GAAG;QACjCC,QAAQC,IAAI,GAAGH,gBAAgBG,IAAI;QACnCD,QAAQE,KAAK,GAAGJ,gBAAgBI,KAAK;IACvC;IACAF,QAAQD,GAAG,GAAG,KAAO;IACrBC,QAAQC,IAAI,GAAG,KAAO;IACtBD,QAAQE,KAAK,GAAG,KAAO;IACvB,OAAOC;AACT"}
|
package/build/Dedup.js
CHANGED
|
@@ -1,19 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
0 && (module.exports = {
|
|
6
|
+
dedupSources: null,
|
|
7
|
+
mergeSourceWithReasons: null
|
|
8
|
+
});
|
|
9
|
+
function _export(target, all) {
|
|
10
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
_export(exports, {
|
|
16
|
+
get dedupSources () {
|
|
17
|
+
return dedupSources;
|
|
18
|
+
},
|
|
19
|
+
get mergeSourceWithReasons () {
|
|
20
|
+
return mergeSourceWithReasons;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
function _assert() {
|
|
24
|
+
const data = /*#__PURE__*/ _interop_require_default(require("assert"));
|
|
25
|
+
_assert = function() {
|
|
26
|
+
return data;
|
|
27
|
+
};
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
function _path() {
|
|
31
|
+
const data = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
32
|
+
_path = function() {
|
|
33
|
+
return data;
|
|
34
|
+
};
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
function _interop_require_default(obj) {
|
|
38
|
+
return obj && obj.__esModule ? obj : {
|
|
39
|
+
default: obj
|
|
40
|
+
};
|
|
41
|
+
}
|
|
10
42
|
const debug = require('debug')('expo:fingerprint:Dedup');
|
|
11
|
-
/**
|
|
12
|
-
* Strip duplicated sources, mainly for duplicated file or dir
|
|
13
|
-
*/
|
|
14
43
|
function dedupSources(sources, projectRoot) {
|
|
15
44
|
const newSources = [];
|
|
16
|
-
for (const source of sources)
|
|
45
|
+
for (const source of sources){
|
|
17
46
|
const [duplicatedItemIndex, shouldSwapSource] = findDuplicatedSourceIndex(newSources, source, projectRoot);
|
|
18
47
|
const duplicatedItem = newSources[duplicatedItemIndex];
|
|
19
48
|
if (duplicatedItem != null) {
|
|
@@ -21,62 +50,79 @@ function dedupSources(sources, projectRoot) {
|
|
|
21
50
|
if (shouldSwapSource) {
|
|
22
51
|
newSources[duplicatedItemIndex] = {
|
|
23
52
|
...source,
|
|
24
|
-
reasons: [
|
|
53
|
+
reasons: [
|
|
54
|
+
...source.reasons,
|
|
55
|
+
...duplicatedItem.reasons
|
|
56
|
+
]
|
|
25
57
|
};
|
|
58
|
+
} else {
|
|
59
|
+
duplicatedItem.reasons = [
|
|
60
|
+
...duplicatedItem.reasons,
|
|
61
|
+
...source.reasons
|
|
62
|
+
];
|
|
26
63
|
}
|
|
27
|
-
|
|
28
|
-
duplicatedItem.reasons = [...duplicatedItem.reasons, ...source.reasons];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
64
|
+
} else {
|
|
32
65
|
newSources.push(source);
|
|
33
66
|
}
|
|
34
67
|
}
|
|
35
68
|
return newSources;
|
|
36
69
|
}
|
|
37
|
-
/**
|
|
38
|
-
* When two sources are duplicated, merge `src`'s reasons into `dst`
|
|
39
|
-
*/
|
|
40
70
|
function mergeSourceWithReasons(dst, src) {
|
|
41
71
|
return dst;
|
|
42
72
|
}
|
|
43
73
|
/**
|
|
44
74
|
* Find the duplicated `source` in `newSources`
|
|
45
75
|
* @return tuple of [duplicatedItemIndexInNewSources, shouldSwapSource]
|
|
46
|
-
*/
|
|
47
|
-
function findDuplicatedSourceIndex(newSources, source, projectRoot) {
|
|
76
|
+
*/ function findDuplicatedSourceIndex(newSources, source, projectRoot) {
|
|
48
77
|
let shouldSwapSource = false;
|
|
49
78
|
if (source.type === 'contents') {
|
|
50
79
|
return [
|
|
51
|
-
newSources.findIndex((item)
|
|
52
|
-
shouldSwapSource
|
|
80
|
+
newSources.findIndex((item)=>item.type === source.type && item.id === source.id) ?? null,
|
|
81
|
+
shouldSwapSource
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
if (source.type === 'package') {
|
|
85
|
+
const key = source.overrideHashKey ?? `${source.name}@${source.version}`;
|
|
86
|
+
return [
|
|
87
|
+
newSources.findIndex((item)=>item.type === 'package' && (item.overrideHashKey ?? `${item.name}@${item.version}`) === key) ?? null,
|
|
88
|
+
shouldSwapSource
|
|
53
89
|
];
|
|
54
90
|
}
|
|
55
|
-
for (const [index, existingSource] of newSources.entries())
|
|
56
|
-
if (existingSource.type === 'contents') {
|
|
91
|
+
for (const [index, existingSource] of newSources.entries()){
|
|
92
|
+
if (existingSource.type === 'contents' || existingSource.type === 'package') {
|
|
57
93
|
continue;
|
|
58
94
|
}
|
|
59
95
|
if (isDescendant(source, existingSource, projectRoot)) {
|
|
60
|
-
return [
|
|
96
|
+
return [
|
|
97
|
+
index,
|
|
98
|
+
shouldSwapSource
|
|
99
|
+
];
|
|
61
100
|
}
|
|
62
|
-
// If the new source is ancestor of existing source,
|
|
101
|
+
// If the new source is ancestor of existing source, swap the existing source with the new source
|
|
63
102
|
if (isDescendant(existingSource, source, projectRoot)) {
|
|
64
103
|
shouldSwapSource = true;
|
|
65
|
-
return [
|
|
104
|
+
return [
|
|
105
|
+
index,
|
|
106
|
+
shouldSwapSource
|
|
107
|
+
];
|
|
66
108
|
}
|
|
67
109
|
}
|
|
68
|
-
return [
|
|
110
|
+
return [
|
|
111
|
+
-1,
|
|
112
|
+
shouldSwapSource
|
|
113
|
+
];
|
|
69
114
|
}
|
|
70
115
|
function isDescendant(from, to, projectRoot) {
|
|
71
116
|
if (from === to) {
|
|
72
117
|
return true;
|
|
73
118
|
}
|
|
74
|
-
const fromPath =
|
|
75
|
-
const toPath =
|
|
76
|
-
const result =
|
|
119
|
+
const fromPath = _path().default.join(projectRoot, from.filePath);
|
|
120
|
+
const toPath = _path().default.join(projectRoot, to.filePath);
|
|
121
|
+
const result = _path().default.relative(fromPath, toPath).match(/^[./\\/]*$/) != null;
|
|
77
122
|
if (result) {
|
|
78
|
-
(0,
|
|
123
|
+
(0, _assert().default)(!(to.type === 'file' && from.type === 'dir'), `Unexpected case which a dir is a descendant of a file - from[${fromPath}] to[${toPath}]`);
|
|
79
124
|
}
|
|
80
125
|
return result;
|
|
81
126
|
}
|
|
82
|
-
|
|
127
|
+
|
|
128
|
+
//# sourceMappingURL=Dedup.js.map
|
package/build/Dedup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["Dedup.ts"],"sourcesContent":[null],"names":["dedupSources","mergeSourceWithReasons","debug","require","sources","projectRoot","newSources","source","duplicatedItemIndex","shouldSwapSource","findDuplicatedSourceIndex","duplicatedItem","JSON","stringify","reasons","push","dst","src","type","findIndex","item","id","key","overrideHashKey","name","version","index","existingSource","entries","isDescendant","from","to","fromPath","path","join","filePath","toPath","result","relative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Config } from '@expo/config';
|
|
2
|
+
import { type LoadedModuleSource } from './ExpoConfigLoader';
|
|
2
3
|
import type { NormalizedOptions } from './Fingerprint.types';
|
|
3
4
|
/**
|
|
4
5
|
* An out-of-process `expo/config` loader that can be used to get the Expo config and loaded modules.
|
|
5
6
|
*/
|
|
6
7
|
export declare function getExpoConfigAsync(projectRoot: string, options: NormalizedOptions): Promise<{
|
|
7
8
|
config: ProjectConfig | null;
|
|
8
|
-
loadedModules:
|
|
9
|
+
loadedModules: LoadedModuleSource[] | null;
|
|
9
10
|
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Keep only the config-plugin modules attributable to applying plugins.
|
|
13
|
+
*
|
|
14
|
+
* Anything that also loads when plugins are skipped is the config-loading framework and is dropped.
|
|
15
|
+
* In-repo files are always kept regardless of the diff, so a local plugin imported at the top of
|
|
16
|
+
* `app.config` (which loads during config evaluation, not plugin application) is never lost.
|
|
17
|
+
*/
|
|
18
|
+
export declare function diffLoadedModules(withPlugins: LoadedModuleSource[], withoutPlugins: LoadedModuleSource[]): LoadedModuleSource[];
|
package/build/ExpoConfig.js
CHANGED
|
@@ -1,54 +1,138 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
0 && (module.exports = {
|
|
6
|
+
diffLoadedModules: null,
|
|
7
|
+
getExpoConfigAsync: null
|
|
8
|
+
});
|
|
9
|
+
function _export(target, all) {
|
|
10
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
_export(exports, {
|
|
16
|
+
get diffLoadedModules () {
|
|
17
|
+
return diffLoadedModules;
|
|
18
|
+
},
|
|
19
|
+
get getExpoConfigAsync () {
|
|
20
|
+
return getExpoConfigAsync;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
function _env() {
|
|
24
|
+
const data = require("@expo/env");
|
|
25
|
+
_env = function() {
|
|
26
|
+
return data;
|
|
27
|
+
};
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
function _promises() {
|
|
31
|
+
const data = /*#__PURE__*/ _interop_require_default(require("fs/promises"));
|
|
32
|
+
_promises = function() {
|
|
33
|
+
return data;
|
|
34
|
+
};
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
function _os() {
|
|
38
|
+
const data = /*#__PURE__*/ _interop_require_default(require("os"));
|
|
39
|
+
_os = function() {
|
|
40
|
+
return data;
|
|
41
|
+
};
|
|
42
|
+
return data;
|
|
43
|
+
}
|
|
44
|
+
function _path() {
|
|
45
|
+
const data = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
46
|
+
_path = function() {
|
|
47
|
+
return data;
|
|
48
|
+
};
|
|
49
|
+
return data;
|
|
50
|
+
}
|
|
51
|
+
function _resolvefrom() {
|
|
52
|
+
const data = /*#__PURE__*/ _interop_require_default(require("resolve-from"));
|
|
53
|
+
_resolvefrom = function() {
|
|
54
|
+
return data;
|
|
55
|
+
};
|
|
56
|
+
return data;
|
|
57
|
+
}
|
|
58
|
+
const _ExpoConfigLoader = require("./ExpoConfigLoader");
|
|
59
|
+
const _SpawnIPC = require("./utils/SpawnIPC");
|
|
60
|
+
function _interop_require_default(obj) {
|
|
61
|
+
return obj && obj.__esModule ? obj : {
|
|
62
|
+
default: obj
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const FINGERPRINT_ENV_MODE = 'development';
|
|
16
66
|
async function getExpoConfigAsync(projectRoot, options) {
|
|
17
67
|
const result = {
|
|
18
68
|
config: null,
|
|
19
|
-
loadedModules: null
|
|
69
|
+
loadedModules: null
|
|
20
70
|
};
|
|
21
|
-
if (!
|
|
71
|
+
if (!_resolvefrom().default.silent(_path().default.resolve(projectRoot), 'expo/config')) {
|
|
22
72
|
return result;
|
|
23
73
|
}
|
|
24
|
-
const tmpDir = await
|
|
74
|
+
const tmpDir = await _promises().default.mkdtemp(_path().default.join(_os().default.tmpdir(), 'expo-fingerprint-'));
|
|
25
75
|
const ignoredFile = await createTempIgnoredFileAsync(tmpDir, options);
|
|
26
76
|
try {
|
|
27
|
-
const {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
77
|
+
const [{ config, loadedModules: modulesWithPlugins }, { loadedModules: modulesWithoutPlugins }] = await Promise.all([
|
|
78
|
+
spawnConfigLoaderAsync(projectRoot, ignoredFile, /* skipPlugins */ false),
|
|
79
|
+
spawnConfigLoaderAsync(projectRoot, ignoredFile, /* skipPlugins */ true)
|
|
80
|
+
]);
|
|
81
|
+
result.config = config;
|
|
82
|
+
result.loadedModules = diffLoadedModules(modulesWithPlugins ?? [], modulesWithoutPlugins ?? []);
|
|
83
|
+
} catch (e) {
|
|
33
84
|
if (e instanceof Error) {
|
|
34
85
|
console.warn(`Cannot get Expo config from an Expo project - ${e.message}: `, e.stack);
|
|
35
86
|
}
|
|
36
|
-
}
|
|
37
|
-
finally {
|
|
87
|
+
} finally{
|
|
38
88
|
try {
|
|
39
|
-
await
|
|
40
|
-
|
|
41
|
-
|
|
89
|
+
await _promises().default.rm(tmpDir, {
|
|
90
|
+
recursive: true
|
|
91
|
+
});
|
|
92
|
+
} catch {}
|
|
42
93
|
}
|
|
43
94
|
return result;
|
|
44
95
|
}
|
|
96
|
+
async function spawnConfigLoaderAsync(projectRoot, ignoredFile, skipPlugins) {
|
|
97
|
+
const args = [
|
|
98
|
+
(0, _ExpoConfigLoader.getExpoConfigLoaderPath)(),
|
|
99
|
+
_path().default.resolve(projectRoot),
|
|
100
|
+
ignoredFile,
|
|
101
|
+
'--mode',
|
|
102
|
+
FINGERPRINT_ENV_MODE
|
|
103
|
+
];
|
|
104
|
+
if (skipPlugins) {
|
|
105
|
+
args.push('--skipPlugins');
|
|
106
|
+
}
|
|
107
|
+
const childEnv = (0, _env().setNodeEnv)(FINGERPRINT_ENV_MODE, {
|
|
108
|
+
systemEnv: (0, _env().getOriginalEnv)()
|
|
109
|
+
});
|
|
110
|
+
childEnv.__EXPO_CONFIG_MODE = FINGERPRINT_ENV_MODE;
|
|
111
|
+
const { message } = await (0, _SpawnIPC.spawnWithIpcAsync)('node', args, {
|
|
112
|
+
cwd: projectRoot,
|
|
113
|
+
env: childEnv
|
|
114
|
+
});
|
|
115
|
+
return JSON.parse(message);
|
|
116
|
+
}
|
|
117
|
+
function diffLoadedModules(withPlugins, withoutPlugins) {
|
|
118
|
+
const skippedKeys = new Set(withoutPlugins.map(getLoadedModuleKey));
|
|
119
|
+
return withPlugins.filter((source)=>isInRepoLoadedModule(source) || !skippedKeys.has(getLoadedModuleKey(source)));
|
|
120
|
+
}
|
|
121
|
+
/** Stable identity of a loaded module: its file path, or its id for a virtual module. */ function getLoadedModuleKey(source) {
|
|
122
|
+
return source.type === 'file' ? source.path : source.id;
|
|
123
|
+
}
|
|
124
|
+
/** Whether a loaded module is a project-local file (e.g. a local config plugin) rather than a dependency. */ function isInRepoLoadedModule(source) {
|
|
125
|
+
const key = getLoadedModuleKey(source);
|
|
126
|
+
// `..` means the path escaped the project root (e.g. a hoisted or linked dependency).
|
|
127
|
+
return !key.startsWith('..') && !key.includes('node_modules');
|
|
128
|
+
}
|
|
45
129
|
/**
|
|
46
130
|
* Create a temporary file with ignored paths from options that will be read by the ExpoConfigLoader.
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
await promises_1.default.writeFile(ignoredFile, ignorePaths.join('\n'));
|
|
131
|
+
*/ async function createTempIgnoredFileAsync(tmpDir, options) {
|
|
132
|
+
const ignoredFile = _path().default.join(tmpDir, '.fingerprintignore');
|
|
133
|
+
const ignorePaths = options.ignorePathMatchObjects.map((match)=>match.pattern);
|
|
134
|
+
await _promises().default.writeFile(ignoredFile, ignorePaths.join('\n'));
|
|
52
135
|
return ignoredFile;
|
|
53
136
|
}
|
|
54
|
-
|
|
137
|
+
|
|
138
|
+
//# sourceMappingURL=ExpoConfig.js.map
|
package/build/ExpoConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["ExpoConfig.ts"],"sourcesContent":[null],"names":["diffLoadedModules","getExpoConfigAsync","FINGERPRINT_ENV_MODE","projectRoot","options","result","config","loadedModules","resolveFrom","silent","path","resolve","tmpDir","fs","mkdtemp","join","os","tmpdir","ignoredFile","createTempIgnoredFileAsync","modulesWithPlugins","modulesWithoutPlugins","Promise","all","spawnConfigLoaderAsync","e","Error","console","warn","message","stack","rm","recursive","skipPlugins","args","getExpoConfigLoaderPath","push","childEnv","setNodeEnv","systemEnv","getOriginalEnv","__EXPO_CONFIG_MODE","spawnWithIpcAsync","cwd","env","JSON","parse","withPlugins","withoutPlugins","skippedKeys","Set","map","getLoadedModuleKey","filter","source","isInRepoLoadedModule","has","type","id","key","startsWith","includes","ignorePaths","ignorePathMatchObjects","match","pattern","writeFile"],"mappings":";;;;;;;;;;;;;;;QAwFgBA;eAAAA;;QAxEMC;eAAAA;;;;yBAfqB;;;;;;;gEAC5B;;;;;;;gEACA;;;;;;;gEACE;;;;;;;gEACO;;;;;;kCAEyC;0BAE/B;;;;;;AAElC,MAAMC,uBAAuB;AAKtB,eAAeD,mBACpBE,WAAmB,EACnBC,OAA0B;IAK1B,MAAMC,SAGF;QACFC,QAAQ;QACRC,eAAe;IACjB;IAEA,IAAI,CAACC,sBAAW,CAACC,MAAM,CAACC,eAAI,CAACC,OAAO,CAACR,cAAc,gBAAgB;QACjE,OAAOE;IACT;IAEA,MAAMO,SAAS,MAAMC,mBAAE,CAACC,OAAO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