@expo/fingerprint 0.20.13 → 0.21.1
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 -51
- package/build/Options.js.map +1 -1
- package/build/Presets.d.ts +26 -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 +208 -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/AutolinkingConfig.d.ts +19 -0
- package/build/sourcer/AutolinkingConfig.js +159 -0
- package/build/sourcer/AutolinkingConfig.js.map +1 -0
- package/build/sourcer/Bare.js +192 -94
- package/build/sourcer/Bare.js.map +1 -1
- package/build/sourcer/Expo.d.ts +3 -2
- package/build/sourcer/Expo.js +264 -121
- 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 +27 -2
- package/build/sourcer/SourceSkips.js +65 -48
- 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/sourcer/Utils.js
CHANGED
|
@@ -1,67 +1,141 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
0 && (module.exports = {
|
|
6
|
+
createAutolinkingHashSourceAsync: null,
|
|
7
|
+
getFileBasedHashSourceAsync: null,
|
|
8
|
+
maybeGetRealPathAsync: null,
|
|
9
|
+
readPackageIdentityAsync: null,
|
|
10
|
+
relativizeJsonPaths: null,
|
|
11
|
+
stringifyJsonSorted: null
|
|
12
|
+
});
|
|
13
|
+
function _export(target, all) {
|
|
14
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
_export(exports, {
|
|
20
|
+
get createAutolinkingHashSourceAsync () {
|
|
21
|
+
return createAutolinkingHashSourceAsync;
|
|
22
|
+
},
|
|
23
|
+
get getFileBasedHashSourceAsync () {
|
|
24
|
+
return getFileBasedHashSourceAsync;
|
|
25
|
+
},
|
|
26
|
+
get maybeGetRealPathAsync () {
|
|
27
|
+
return maybeGetRealPathAsync;
|
|
28
|
+
},
|
|
29
|
+
get readPackageIdentityAsync () {
|
|
30
|
+
return readPackageIdentityAsync;
|
|
31
|
+
},
|
|
32
|
+
get relativizeJsonPaths () {
|
|
33
|
+
return relativizeJsonPaths;
|
|
34
|
+
},
|
|
35
|
+
get stringifyJsonSorted () {
|
|
36
|
+
return stringifyJsonSorted;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
function _promises() {
|
|
40
|
+
const data = /*#__PURE__*/ _interop_require_default(require("fs/promises"));
|
|
41
|
+
_promises = function() {
|
|
42
|
+
return data;
|
|
43
|
+
};
|
|
44
|
+
return data;
|
|
45
|
+
}
|
|
46
|
+
function _path() {
|
|
47
|
+
const data = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
48
|
+
_path = function() {
|
|
49
|
+
return data;
|
|
50
|
+
};
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
const _Path = require("../utils/Path");
|
|
54
|
+
function _interop_require_default(obj) {
|
|
55
|
+
return obj && obj.__esModule ? obj : {
|
|
56
|
+
default: obj
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
async function createAutolinkingHashSourceAsync(projectRoot, dirRelativePath, reasons, nativeModuleSourceType) {
|
|
60
|
+
if (nativeModuleSourceType === 'package') {
|
|
61
|
+
const packageJsonPath = (0, _Path.getNodeModulesPackageJsonPath)(dirRelativePath);
|
|
62
|
+
if (packageJsonPath) {
|
|
63
|
+
const identity = await readPackageIdentityAsync(_path().default.join(projectRoot, packageJsonPath));
|
|
64
|
+
if (identity) {
|
|
65
|
+
return {
|
|
66
|
+
type: 'package',
|
|
67
|
+
...identity,
|
|
68
|
+
filePath: packageJsonPath,
|
|
69
|
+
reasons
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
type: 'dir',
|
|
76
|
+
filePath: dirRelativePath,
|
|
77
|
+
reasons
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
async function readPackageIdentityAsync(packageJsonPath) {
|
|
81
|
+
let packageJson;
|
|
82
|
+
try {
|
|
83
|
+
packageJson = JSON.parse(await _promises().default.readFile(packageJsonPath, 'utf8'));
|
|
84
|
+
} catch (error) {
|
|
85
|
+
if (error.code === 'ENOENT') {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
name: packageJson.name ?? '',
|
|
92
|
+
version: packageJson.version ?? ''
|
|
93
|
+
};
|
|
94
|
+
}
|
|
13
95
|
async function getFileBasedHashSourceAsync(projectRoot, filePath, reason) {
|
|
14
96
|
let result = null;
|
|
15
97
|
try {
|
|
16
|
-
const stat = await
|
|
98
|
+
const stat = await _promises().default.stat(_path().default.join(projectRoot, filePath));
|
|
17
99
|
result = {
|
|
18
100
|
type: stat.isDirectory() ? 'dir' : 'file',
|
|
19
|
-
filePath: (0,
|
|
20
|
-
reasons: [
|
|
101
|
+
filePath: (0, _Path.toPosixPath)(filePath),
|
|
102
|
+
reasons: [
|
|
103
|
+
reason
|
|
104
|
+
]
|
|
21
105
|
};
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
106
|
+
} catch {
|
|
24
107
|
result = null;
|
|
25
108
|
}
|
|
26
109
|
return result;
|
|
27
110
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Resolve path aliases before computing relative hash source paths.
|
|
30
|
-
* On Windows, temp paths can be passed as short paths like `RUNNER~1` while
|
|
31
|
-
* autolinking returns the long real path, which makes `path.relative()` unstable.
|
|
32
|
-
*/
|
|
33
111
|
async function maybeGetRealPathAsync(filePath) {
|
|
34
112
|
try {
|
|
35
|
-
return await
|
|
36
|
-
}
|
|
37
|
-
catch {
|
|
113
|
+
return await _promises().default.realpath(filePath);
|
|
114
|
+
} catch {
|
|
38
115
|
return filePath;
|
|
39
116
|
}
|
|
40
117
|
}
|
|
41
|
-
/**
|
|
42
|
-
* A version of `JSON.stringify` that keeps the keys sorted
|
|
43
|
-
*/
|
|
44
118
|
function stringifyJsonSorted(target, space) {
|
|
45
|
-
return JSON.stringify(target, (_, value)
|
|
119
|
+
return JSON.stringify(target, (_, value)=>sortJson(value), space);
|
|
46
120
|
}
|
|
47
|
-
/**
|
|
48
|
-
* Transform absolute paths in JSON to relative paths based on the project root.
|
|
49
|
-
*/
|
|
50
121
|
function relativizeJsonPaths(value, projectRoot) {
|
|
51
122
|
if (typeof value === 'string' && value.startsWith(projectRoot)) {
|
|
52
|
-
return (0,
|
|
123
|
+
return (0, _Path.toPosixPath)(_path().default.relative(projectRoot, value));
|
|
53
124
|
}
|
|
54
125
|
if (Array.isArray(value)) {
|
|
55
|
-
return value.map((item)
|
|
126
|
+
return value.map((item)=>relativizeJsonPaths(item, projectRoot));
|
|
56
127
|
}
|
|
57
128
|
if (value && typeof value === 'object') {
|
|
58
|
-
return Object.fromEntries(Object.entries(value).map(([key, val])
|
|
129
|
+
return Object.fromEntries(Object.entries(value).map(([key, val])=>[
|
|
130
|
+
key,
|
|
131
|
+
relativizeJsonPaths(val, projectRoot)
|
|
132
|
+
]));
|
|
59
133
|
}
|
|
60
134
|
return value;
|
|
61
135
|
}
|
|
62
136
|
function sortJson(json) {
|
|
63
137
|
if (Array.isArray(json)) {
|
|
64
|
-
return json.sort((a, b)
|
|
138
|
+
return json.sort((a, b)=>{
|
|
65
139
|
// Sort array items by their stringified value.
|
|
66
140
|
// We don't need the array to be sorted in meaningful way, just to be sorted in deterministic.
|
|
67
141
|
// E.g. `[{ b: '2' }, {}, { a: '3' }, null]` -> `[null, { a : '3' }, { b: '2' }, {}]`
|
|
@@ -70,8 +144,7 @@ function sortJson(json) {
|
|
|
70
144
|
const stringifiedB = stringifyJsonSorted(b);
|
|
71
145
|
if (stringifiedA < stringifiedB) {
|
|
72
146
|
return -1;
|
|
73
|
-
}
|
|
74
|
-
else if (stringifiedA > stringifiedB) {
|
|
147
|
+
} else if (stringifiedA > stringifiedB) {
|
|
75
148
|
return 1;
|
|
76
149
|
}
|
|
77
150
|
return 0;
|
|
@@ -79,9 +152,7 @@ function sortJson(json) {
|
|
|
79
152
|
}
|
|
80
153
|
if (json != null && typeof json === 'object') {
|
|
81
154
|
// Sort object items by keys
|
|
82
|
-
return Object.keys(json)
|
|
83
|
-
.sort()
|
|
84
|
-
.reduce((acc, key) => {
|
|
155
|
+
return Object.keys(json).sort().reduce((acc, key)=>{
|
|
85
156
|
acc[key] = json[key];
|
|
86
157
|
return acc;
|
|
87
158
|
}, {});
|
|
@@ -89,4 +160,5 @@ function sortJson(json) {
|
|
|
89
160
|
// Return primitives
|
|
90
161
|
return json;
|
|
91
162
|
}
|
|
92
|
-
|
|
163
|
+
|
|
164
|
+
//# sourceMappingURL=Utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["sourcer/Utils.ts"],"sourcesContent":[null],"names":["createAutolinkingHashSourceAsync","getFileBasedHashSourceAsync","maybeGetRealPathAsync","readPackageIdentityAsync","relativizeJsonPaths","stringifyJsonSorted","projectRoot","dirRelativePath","reasons","nativeModuleSourceType","packageJsonPath","getNodeModulesPackageJsonPath","identity","path","join","type","filePath","packageJson","JSON","parse","fs","readFile","error","code","name","version","reason","result","stat","isDirectory","toPosixPath","realpath","target","space","stringify","_","value","sortJson","startsWith","relative","Array","isArray","map","item","Object","fromEntries","entries","key","val","json","sort","a","b","stringifiedA","stringifiedB","keys","reduce","acc"],"mappings":";;;;;;;;;;;;;;;;;;;QAUsBA;eAAAA;;QAsCAC;eAAAA;;QAwBAC;eAAAA;;QAvCAC;eAAAA;;QAyDNC;eAAAA;;QAPAC;eAAAA;;;;gEAnFD;;;;;;;gEACE;;;;;;sBAG0C;;;;;;AAMpD,eAAeL,iCACpBM,WAAmB,EACnBC,eAAuB,EACvBC,OAAiB,EACjBC,sBAA2C;IAE3C,IAAIA,2BAA2B,WAAW;QACxC,MAAMC,kBAAkBC,IAAAA,mCAA6B,EAACJ;QACtD,IAAIG,iBAAiB;YACnB,MAAME,WAAW,MAAMT,yBAAyBU,eAAI,CAACC,IAAI,CAACR,aAAaI;YACvE,IAAIE,UAAU;gBACZ,OAAO;oBAAEG,MAAM;oBAAW,GAAGH,QAAQ;oBAAEI,UAAUN;oBAAiBF;gBAAQ;YAC5E;QACF;IACF;IACA,OAAO;QAAEO,MAAM;QAAOC,UAAUT;QAAiBC;IAAQ;AAC3D;AAOO,eAAeL,yBACpBO,eAAuB;IAEvB,IAAIO;IACJ,IAAI;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BD,OAAOE,OAAO,CAACV,OAAOM,GAAG,CAAC,CAAC,CAACK,KAAKC,IAAI,GAAK;gBAACD;gBAAK3C,oBAAoB4C,KAAK1C;aAAa;IAE1F;IAEA,OAAO8B;AACT;AAEA,SAASC,SAASY,IAAS;IACzB,IAAIT,MAAMC,OAAO,CAACQ,OAAO;QACvB,OAAOA,KAAKC,IAAI,CAAC,CAACC,GAAGC;YACnB,+CAA+C;YAC/C,8FAA8F;YAC9F,qFAAqF;YACrF,gFAAgF;YAChF,MAAMC,eAAehD,oBAAoB8C;YACzC,MAAMG,eAAejD,oBAAoB+C;YACzC,IAAIC,eAAeC,cAAc;gBAC/B,OAAO,CAAC;YACV,OAAO,IAAID,eAAeC,cAAc;gBACtC,OAAO;YACT;YACA,OAAO;QACT;IACF;IAEA,IAAIL,QAAQ,QAAQ,OAAOA,SAAS,UAAU;QAC5C,4BAA4B;QAC5B,OAAOL,OAAOW,IAAI,CAACN,MAChBC,IAAI,GACJM,MAAM,CAAC,CAACC,KAAUV;YACjBU,GAAG,CAACV,IAAI,GAAGE,IAAI,CAACF,IAAI;YACpB,OAAOU;QACT,GAAG,CAAC;IACR;IAEA,oBAAoB;IACpB,OAAOR;AACT"}
|
|
@@ -1,22 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "createLimiter", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return createLimiter;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const createLimiter = (limit = 1)=>{
|
|
5
12
|
let running = 0;
|
|
6
13
|
let head = null;
|
|
7
14
|
let tail = null;
|
|
8
|
-
const enqueue = ()
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const enqueue = ()=>new Promise((resolve)=>{
|
|
16
|
+
const item = {
|
|
17
|
+
resolve,
|
|
18
|
+
next: null
|
|
19
|
+
};
|
|
20
|
+
if (tail) {
|
|
21
|
+
tail.next = item;
|
|
22
|
+
tail = item;
|
|
23
|
+
} else {
|
|
24
|
+
head = item;
|
|
25
|
+
tail = item;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const dequeue = ()=>{
|
|
20
29
|
if (running < limit && head !== null) {
|
|
21
30
|
const { resolve, next } = head;
|
|
22
31
|
head.next = null;
|
|
@@ -28,21 +37,19 @@ const createLimiter = (limit = 1) => {
|
|
|
28
37
|
resolve();
|
|
29
38
|
}
|
|
30
39
|
};
|
|
31
|
-
return async (fn, ...args)
|
|
40
|
+
return async (fn, ...args)=>{
|
|
32
41
|
if (running < limit) {
|
|
33
42
|
running++;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
43
|
+
} else {
|
|
36
44
|
await enqueue();
|
|
37
45
|
}
|
|
38
46
|
try {
|
|
39
47
|
return await fn(...args);
|
|
40
|
-
}
|
|
41
|
-
finally {
|
|
48
|
+
} finally{
|
|
42
49
|
running--;
|
|
43
50
|
dequeue();
|
|
44
51
|
}
|
|
45
52
|
};
|
|
46
53
|
};
|
|
47
|
-
|
|
48
|
-
//# sourceMappingURL=Concurrency.js.map
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=Concurrency.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["utils/Concurrency.ts"],"sourcesContent":[null],"names":["createLimiter","limit","running","head","tail","enqueue","Promise","resolve","item","next","dequeue","fn","args"],"mappings":";;;;+BAYaA;;;eAAAA;;;AAAN,MAAMA,gBAAgB,CAACC,QAAQ,CAAC;IACrC,IAAIC,UAAU;IACd,IAAIC,OAAyB;IAC7B,IAAIC,OAAyB;IAE7B,MAAMC,UAAU,IACd,IAAIC,QAAc,CAACC;YACjB,MAAMC,OAAkB;gBAAED;gBAASE,MAAM;YAAK;YAC9C,IAAIL,MAAM;gBACRA,KAAKK,IAAI,GAAGD;gBACZJ,OAAOI;YACT,OAAO;gBACLL,OAAOK;gBACPJ,OAAOI;YACT;QACF;IAEF,MAAME,UAAU;QACd,IAAIR,UAAUD,SAASE,SAAS,MAAM;YACpC,MAAM,EAAEI,OAAO,EAAEE,IAAI,EAAE,GAAGN;YAC1BA,KAAKM,IAAI,GAAG;YACZN,OAAOM;YACP,IAAIN,SAAS,MAAM;gBACjBC,OAAO;YACT;YACAF;YACAK;QACF;IACF;IAEA,OAAO,OAAOI,IAAI,GAAGC;QACnB,IAAIV,UAAUD,OAAO;YACnBC;QACF,OAAO;YACL,MAAMG;QACR;QACA,IAAI;YACF,OAAO,MAAMM,MAAMC;QACrB,SAAU;YACRV;YACAQ;QACF;IACF;AACF"}
|
package/build/utils/Path.d.ts
CHANGED
|
@@ -39,3 +39,8 @@ export declare function toPosixPath(filePath: string): string;
|
|
|
39
39
|
* Check if the given `filePath` exists.
|
|
40
40
|
*/
|
|
41
41
|
export declare function pathExistsAsync(filePath: string): Promise<boolean>;
|
|
42
|
+
/**
|
|
43
|
+
* Given a posix path inside `node_modules`, return the owning package's `package.json` path.
|
|
44
|
+
* Returns null when the path is not inside `node_modules`. Handles scoped packages (`@scope/name`).
|
|
45
|
+
*/
|
|
46
|
+
export declare function getNodeModulesPackageJsonPath(relativePosixPath: string): string | null;
|
package/build/utils/Path.js
CHANGED
|
@@ -1,82 +1,139 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
0 && (module.exports = {
|
|
6
|
+
appendIgnorePath: null,
|
|
7
|
+
buildDirMatchObjects: null,
|
|
8
|
+
buildPathMatchObjects: null,
|
|
9
|
+
getNodeModulesPackageJsonPath: null,
|
|
10
|
+
isIgnoredPath: null,
|
|
11
|
+
isIgnoredPathWithMatchObjects: null,
|
|
12
|
+
normalizeFilePath: null,
|
|
13
|
+
pathExistsAsync: null,
|
|
14
|
+
toPosixPath: null
|
|
15
|
+
});
|
|
16
|
+
function _export(target, all) {
|
|
17
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
_export(exports, {
|
|
23
|
+
get appendIgnorePath () {
|
|
24
|
+
return appendIgnorePath;
|
|
25
|
+
},
|
|
26
|
+
get buildDirMatchObjects () {
|
|
27
|
+
return buildDirMatchObjects;
|
|
28
|
+
},
|
|
29
|
+
get buildPathMatchObjects () {
|
|
30
|
+
return buildPathMatchObjects;
|
|
31
|
+
},
|
|
32
|
+
get getNodeModulesPackageJsonPath () {
|
|
33
|
+
return getNodeModulesPackageJsonPath;
|
|
34
|
+
},
|
|
35
|
+
get isIgnoredPath () {
|
|
36
|
+
return isIgnoredPath;
|
|
37
|
+
},
|
|
38
|
+
get isIgnoredPathWithMatchObjects () {
|
|
39
|
+
return isIgnoredPathWithMatchObjects;
|
|
40
|
+
},
|
|
41
|
+
get normalizeFilePath () {
|
|
42
|
+
return normalizeFilePath;
|
|
43
|
+
},
|
|
44
|
+
get pathExistsAsync () {
|
|
45
|
+
return pathExistsAsync;
|
|
46
|
+
},
|
|
47
|
+
get toPosixPath () {
|
|
48
|
+
return toPosixPath;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
function _promises() {
|
|
52
|
+
const data = /*#__PURE__*/ _interop_require_default(require("fs/promises"));
|
|
53
|
+
_promises = function() {
|
|
54
|
+
return data;
|
|
55
|
+
};
|
|
56
|
+
return data;
|
|
57
|
+
}
|
|
58
|
+
function _minimatch() {
|
|
59
|
+
const data = require("minimatch");
|
|
60
|
+
_minimatch = function() {
|
|
61
|
+
return data;
|
|
62
|
+
};
|
|
63
|
+
return data;
|
|
64
|
+
}
|
|
65
|
+
function _nodeprocess() {
|
|
66
|
+
const data = /*#__PURE__*/ _interop_require_default(require("node:process"));
|
|
67
|
+
_nodeprocess = function() {
|
|
68
|
+
return data;
|
|
69
|
+
};
|
|
70
|
+
return data;
|
|
71
|
+
}
|
|
72
|
+
function _path() {
|
|
73
|
+
const data = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
74
|
+
_path = function() {
|
|
75
|
+
return data;
|
|
76
|
+
};
|
|
77
|
+
return data;
|
|
78
|
+
}
|
|
79
|
+
function _interop_require_default(obj) {
|
|
80
|
+
return obj && obj.__esModule ? obj : {
|
|
81
|
+
default: obj
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function isIgnoredPath(filePath, ignorePaths, minimatchOptions = {
|
|
85
|
+
dot: true
|
|
86
|
+
}) {
|
|
22
87
|
const matchObjects = buildPathMatchObjects(ignorePaths, minimatchOptions);
|
|
23
88
|
return isIgnoredPathWithMatchObjects(filePath, matchObjects);
|
|
24
89
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return paths.map((filePath) => new minimatch_1.Minimatch(filePath, minimatchOptions));
|
|
90
|
+
function buildPathMatchObjects(paths, minimatchOptions = {
|
|
91
|
+
dot: true
|
|
92
|
+
}) {
|
|
93
|
+
return paths.map((filePath)=>new (_minimatch()).Minimatch(filePath, minimatchOptions));
|
|
30
94
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
matchObjects.push(new minimatch_1.Minimatch(path, minimatchOptions));
|
|
95
|
+
function appendIgnorePath(matchObjects, path, minimatchOptions = {
|
|
96
|
+
dot: true
|
|
97
|
+
}) {
|
|
98
|
+
matchObjects.push(new (_minimatch()).Minimatch(path, minimatchOptions));
|
|
36
99
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
function buildDirMatchObjects(ignorePathMatchObjects, minimatchOptions = { dot: true }) {
|
|
100
|
+
function buildDirMatchObjects(ignorePathMatchObjects, minimatchOptions = {
|
|
101
|
+
dot: true
|
|
102
|
+
}) {
|
|
41
103
|
const dirIgnorePatterns = [];
|
|
42
|
-
const ignorePaths = ignorePathMatchObjects.filter((obj)
|
|
43
|
-
const negatedIgnorePaths = ignorePathMatchObjects
|
|
44
|
-
.filter((obj) => obj.negate)
|
|
45
|
-
.map((obj) => obj.pattern);
|
|
104
|
+
const ignorePaths = ignorePathMatchObjects.filter((obj)=>!obj.negate).map((obj)=>obj.pattern);
|
|
105
|
+
const negatedIgnorePaths = ignorePathMatchObjects.filter((obj)=>obj.negate).map((obj)=>obj.pattern);
|
|
46
106
|
// [0] Add positive patterns to dirIgnorePatterns
|
|
47
|
-
for (const pattern of ignorePaths)
|
|
107
|
+
for (const pattern of ignorePaths){
|
|
48
108
|
if (pattern.endsWith('/**/*')) {
|
|
49
109
|
// `/**/*` matches
|
|
50
110
|
dirIgnorePatterns.push(pattern.slice(0, -5));
|
|
51
|
-
}
|
|
52
|
-
else if (pattern.endsWith('/**')) {
|
|
111
|
+
} else if (pattern.endsWith('/**')) {
|
|
53
112
|
// `/**` by default matches directories
|
|
54
113
|
dirIgnorePatterns.push(pattern.slice(0, -3));
|
|
55
|
-
}
|
|
56
|
-
else if (pattern.endsWith('/')) {
|
|
114
|
+
} else if (pattern.endsWith('/')) {
|
|
57
115
|
// `/` suffix matches directories
|
|
58
116
|
dirIgnorePatterns.push(pattern.slice(0, -1));
|
|
59
117
|
}
|
|
60
118
|
}
|
|
61
119
|
// [1] If there is a negate pattern in the same directory, we should remove the existing directory.
|
|
62
|
-
for (const pattern of negatedIgnorePaths)
|
|
63
|
-
for
|
|
120
|
+
for (const pattern of negatedIgnorePaths){
|
|
121
|
+
for(let i = 0; i < dirIgnorePatterns.length; ++i){
|
|
64
122
|
const existingPattern = dirIgnorePatterns[i];
|
|
65
123
|
if (existingPattern != null && isSubDirectory(existingPattern, pattern)) {
|
|
66
124
|
dirIgnorePatterns.splice(i, 1);
|
|
67
125
|
}
|
|
68
126
|
}
|
|
69
127
|
}
|
|
70
|
-
return dirIgnorePatterns.map((pattern)
|
|
128
|
+
return dirIgnorePatterns.map((pattern)=>new (_minimatch()).Minimatch(pattern, minimatchOptions));
|
|
71
129
|
}
|
|
72
|
-
/**
|
|
73
|
-
* Indicate the given `filePath` should be excluded by the prebuilt `matchObjects`.
|
|
74
|
-
*/
|
|
75
130
|
function isIgnoredPathWithMatchObjects(filePath, matchObjects) {
|
|
76
131
|
let result = false;
|
|
77
|
-
for (const minimatchObj of matchObjects)
|
|
132
|
+
for (const minimatchObj of matchObjects){
|
|
78
133
|
const stripParentPrefix = minimatchObj.pattern.startsWith('**/');
|
|
79
|
-
const normalizedFilePath = normalizeFilePath(filePath, {
|
|
134
|
+
const normalizedFilePath = normalizeFilePath(filePath, {
|
|
135
|
+
stripParentPrefix
|
|
136
|
+
});
|
|
80
137
|
const currMatch = minimatchObj.match(normalizedFilePath);
|
|
81
138
|
if (minimatchObj.negate && result && !currMatch) {
|
|
82
139
|
// Special handler for negate (!pattern).
|
|
@@ -91,21 +148,11 @@ function isIgnoredPathWithMatchObjects(filePath, matchObjects) {
|
|
|
91
148
|
}
|
|
92
149
|
/**
|
|
93
150
|
* Returns true if `parent` is a parent directory of `child`.
|
|
94
|
-
*/
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return !relative.startsWith('..') && !path_1.default.isAbsolute(relative);
|
|
151
|
+
*/ function isSubDirectory(parent, child) {
|
|
152
|
+
const relative = _path().default.relative(parent, child);
|
|
153
|
+
return !relative.startsWith('..') && !_path().default.isAbsolute(relative);
|
|
98
154
|
}
|
|
99
155
|
const STRIP_PARENT_PREFIX_REGEX = /^(\.\.\/)+/g;
|
|
100
|
-
/**
|
|
101
|
-
* Normalize the given `filePath` to be used for matching against `ignorePaths`.
|
|
102
|
-
*
|
|
103
|
-
* @param filePath The file path to normalize.
|
|
104
|
-
* @param options.stripParentPrefix
|
|
105
|
-
* When people use fingerprint inside a monorepo, they may get source files from parent directories.
|
|
106
|
-
* However, minimatch '**' doesn't match the parent directories.
|
|
107
|
-
* We need to strip the `../` prefix to match the node_modules from parent directories.
|
|
108
|
-
*/
|
|
109
156
|
function normalizeFilePath(filePath, options) {
|
|
110
157
|
if (options.stripParentPrefix) {
|
|
111
158
|
return filePath.replace(STRIP_PARENT_PREFIX_REGEX, '');
|
|
@@ -113,22 +160,38 @@ function normalizeFilePath(filePath, options) {
|
|
|
113
160
|
return filePath;
|
|
114
161
|
}
|
|
115
162
|
const REGEXP_REPLACE_SLASHES = /\\/g;
|
|
116
|
-
/**
|
|
117
|
-
* Convert any platform-specific path to a POSIX path.
|
|
118
|
-
*/
|
|
119
163
|
function toPosixPath(filePath) {
|
|
120
|
-
return
|
|
164
|
+
return _nodeprocess().default.platform === 'win32' ? filePath.replace(REGEXP_REPLACE_SLASHES, '/') : filePath;
|
|
121
165
|
}
|
|
122
|
-
/**
|
|
123
|
-
* Check if the given `filePath` exists.
|
|
124
|
-
*/
|
|
125
166
|
async function pathExistsAsync(filePath) {
|
|
126
167
|
try {
|
|
127
|
-
const stat = await
|
|
168
|
+
const stat = await _promises().default.stat(filePath);
|
|
128
169
|
return stat.isFile() || stat.isDirectory();
|
|
129
|
-
}
|
|
130
|
-
catch {
|
|
170
|
+
} catch {
|
|
131
171
|
return false;
|
|
132
172
|
}
|
|
133
173
|
}
|
|
134
|
-
|
|
174
|
+
function getNodeModulesPackageJsonPath(relativePosixPath) {
|
|
175
|
+
const marker = 'node_modules/';
|
|
176
|
+
const markerIndex = relativePosixPath.lastIndexOf(marker);
|
|
177
|
+
if (markerIndex === -1) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
const prefix = relativePosixPath.slice(0, markerIndex + marker.length);
|
|
181
|
+
const segments = relativePosixPath.slice(markerIndex + marker.length).split('/');
|
|
182
|
+
if (!segments[0]) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
let packageDir;
|
|
186
|
+
if (segments[0].startsWith('@')) {
|
|
187
|
+
if (!segments[1]) {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
packageDir = `${prefix}${segments[0]}/${segments[1]}`;
|
|
191
|
+
} else {
|
|
192
|
+
packageDir = `${prefix}${segments[0]}`;
|
|
193
|
+
}
|
|
194
|
+
return `${packageDir}/package.json`;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
//# sourceMappingURL=Path.js.map
|
package/build/utils/Path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["utils/Path.ts"],"sourcesContent":[null],"names":["appendIgnorePath","buildDirMatchObjects","buildPathMatchObjects","getNodeModulesPackageJsonPath","isIgnoredPath","isIgnoredPathWithMatchObjects","normalizeFilePath","pathExistsAsync","toPosixPath","filePath","ignorePaths","minimatchOptions","dot","matchObjects","paths","map","Minimatch","path","push","ignorePathMatchObjects","dirIgnorePatterns","filter","obj","negate","pattern","negatedIgnorePaths","endsWith","slice","i","length","existingPattern","isSubDirectory","splice","result","minimatchObj","stripParentPrefix","startsWith","normalizedFilePath","currMatch","match","parent","child","relative","isAbsolute","STRIP_PARENT_PREFIX_REGEX","options","replace","REGEXP_REPLACE_SLASHES","process","platform","stat","fs","isFile","isDirectory","relativePosixPath","marker","markerIndex","lastIndexOf","prefix","segments","split","packageDir"],"mappings":";;;;;;;;;;;;;;;;;;;;;;QA8BgBA;eAAAA;;QAWAC;eAAAA;;QArBAC;eAAAA;;QA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