@expo/fingerprint 0.1.0 → 0.2.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/CHANGELOG.md +10 -0
- package/build/Fingerprint.js +1 -1
- package/build/Fingerprint.js.map +1 -1
- package/build/Fingerprint.types.d.ts +12 -1
- package/build/Fingerprint.types.js.map +1 -1
- package/build/Options.d.ts +3 -1
- package/build/Options.js +39 -9
- package/build/Options.js.map +1 -1
- package/build/hash/Hash.d.ts +6 -1
- package/build/hash/Hash.js +28 -13
- package/build/hash/Hash.js.map +1 -1
- package/build/sourcer/Expo.js +14 -11
- package/build/sourcer/Expo.js.map +1 -1
- package/build/sourcer/Utils.d.ts +4 -0
- package/build/sourcer/Utils.js +38 -1
- package/build/sourcer/Utils.js.map +1 -1
- package/e2e/__tests__/__snapshots__/managed-test.ts.snap +3 -2
- package/e2e/__tests__/managed-test.ts +6 -3
- package/package.json +2 -2
- package/src/Fingerprint.ts +2 -2
- package/src/Fingerprint.types.ts +13 -1
- package/src/Options.ts +45 -7
- package/src/__tests__/Fingerprint-test.ts +43 -17
- package/src/hash/Hash.ts +38 -14
- package/src/hash/__tests__/Hash-test.ts +98 -16
- package/src/sourcer/Expo.ts +17 -18
- package/src/sourcer/Utils.ts +39 -0
- package/src/sourcer/__tests__/Bare-test.ts +11 -5
- package/src/sourcer/__tests__/Expo-test.ts +75 -20
- package/src/sourcer/__tests__/PatchPackage-test.ts +3 -3
- package/src/sourcer/__tests__/Sourcer-test.ts +2 -2
- package/src/sourcer/__tests__/Utils-test.ts +41 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 0.2.0 — 2023-09-08
|
|
14
|
+
|
|
15
|
+
### 🛠 Breaking changes
|
|
16
|
+
|
|
17
|
+
- Normalize Expo config and remove `runtimeVersion` from fingerprint. Note that the fingerprint result will be changed from this version. ([#24290](https://github.com/expo/expo/pull/24290) by [@Kudo](https://github.com/kudo))
|
|
18
|
+
|
|
19
|
+
### 🎉 New features
|
|
20
|
+
|
|
21
|
+
- Added `options.ignorePaths` and **.fingerprintignore** to support. ([#24265](https://github.com/expo/expo/pull/24265) by [@Kudo](https://github.com/kudo))
|
|
22
|
+
|
|
13
23
|
## 0.1.0 — 2023-08-29
|
|
14
24
|
|
|
15
25
|
### 🛠 Breaking changes
|
package/build/Fingerprint.js
CHANGED
|
@@ -10,7 +10,7 @@ const Sourcer_1 = require("./sourcer/Sourcer");
|
|
|
10
10
|
* Create a fingerprint from project
|
|
11
11
|
*/
|
|
12
12
|
async function createFingerprintAsync(projectRoot, options) {
|
|
13
|
-
const opts = (0, Options_1.
|
|
13
|
+
const opts = await (0, Options_1.normalizeOptionsAsync)(projectRoot, options);
|
|
14
14
|
const sources = await (0, Sourcer_1.getHashSourcesAsync)(projectRoot, opts);
|
|
15
15
|
const normalizedSources = (0, Sort_1.sortSources)((0, Dedup_1.dedupSources)(sources, projectRoot));
|
|
16
16
|
const fingerprint = await (0, Hash_1.createFingerprintFromSourcesAsync)(normalizedSources, projectRoot, opts);
|
package/build/Fingerprint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Fingerprint.js","sourceRoot":"","sources":["../src/Fingerprint.ts"],"names":[],"mappings":";;;AAAA,mCAAuC;AAEvC,
|
|
1
|
+
{"version":3,"file":"Fingerprint.js","sourceRoot":"","sources":["../src/Fingerprint.ts"],"names":[],"mappings":";;;AAAA,mCAAuC;AAEvC,uCAAkD;AAClD,iCAAqC;AACrC,sCAAgE;AAChE,+CAAwD;AAExD;;GAEG;AACI,KAAK,UAAU,sBAAsB,CAC1C,WAAmB,EACnB,OAAiB;IAEjB,MAAM,IAAI,GAAG,MAAM,IAAA,+BAAqB,EAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC/D,MAAM,OAAO,GAAG,MAAM,IAAA,6BAAmB,EAAC,WA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|
* Excludes directories from hashing. This supported pattern is as `glob()`.
|
|
35
35
|
* Default is `['android/build', 'android/app/build', 'android/app/.cxx', 'ios/Pods']`.
|
|
36
|
+
* @deprecated Use `ignorePaths` instead.
|
|
36
37
|
*/
|
|
37
38
|
dirExcludes?: string[];
|
|
39
|
+
/**
|
|
40
|
+
* Ignore files and directories from hashing. This supported pattern is as `glob()`.
|
|
41
|
+
*
|
|
42
|
+
* Please note that the pattern matching is slightly different from gitignore. For example, we don't support partial matching where `build` does not match `android/build`. You should use `'**' + '/build'` instead.
|
|
43
|
+
* @see [minimatch implementations](https://github.com/isaacs/minimatch#comparisons-to-other-fnmatchglob-implementations) for more reference.
|
|
44
|
+
*
|
|
45
|
+
* Besides this `ignorePaths`, fingerprint comes with implicit default ignorePaths defined in `Options.DEFAULT_IGNORE_PATHS`.
|
|
46
|
+
* If you want to override the default ignorePaths, use `!` prefix.
|
|
47
|
+
*/
|
|
48
|
+
ignorePaths?: string[];
|
|
38
49
|
/**
|
|
39
50
|
* Additional sources for hashing.
|
|
40
51
|
*/
|
|
@@ -44,7 +55,7 @@ export interface NormalizedOptions extends Options {
|
|
|
44
55
|
platforms: NonNullable<Options['platforms']>;
|
|
45
56
|
concurrentIoLimit: NonNullable<Options['concurrentIoLimit']>;
|
|
46
57
|
hashAlgorithm: NonNullable<Options['hashAlgorithm']>;
|
|
47
|
-
|
|
58
|
+
ignorePaths: NonNullable<Options['ignorePaths']>;
|
|
48
59
|
}
|
|
49
60
|
export interface HashSourceFile {
|
|
50
61
|
type: 'file';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Fingerprint.types.js","sourceRoot":"","sources":["../src/Fingerprint.types.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"Fingerprint.types.js","sourceRoot":"","sources":["../src/Fingerprint.types.ts"],"names":[],"mappings":";;AA6GA,YAAY"}
|
package/build/Options.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import type { NormalizedOptions, Options } from './Fingerprint.types';
|
|
2
|
-
export declare
|
|
2
|
+
export declare const FINGERPRINT_IGNORE_FILENAME = ".fingerprintignore";
|
|
3
|
+
export declare const DEFAULT_IGNORE_PATHS: string[];
|
|
4
|
+
export declare function normalizeOptionsAsync(projectRoot: string, options?: Options): Promise<NormalizedOptions>;
|
package/build/Options.js
CHANGED
|
@@ -3,21 +3,51 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.normalizeOptionsAsync = exports.DEFAULT_IGNORE_PATHS = exports.FINGERPRINT_IGNORE_FILENAME = void 0;
|
|
7
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
7
8
|
const os_1 = __importDefault(require("os"));
|
|
8
|
-
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
exports.FINGERPRINT_IGNORE_FILENAME = '.fingerprintignore';
|
|
11
|
+
exports.DEFAULT_IGNORE_PATHS = [
|
|
12
|
+
exports.FINGERPRINT_IGNORE_FILENAME,
|
|
13
|
+
'**/android/build/**/*',
|
|
14
|
+
'**/android/app/build/**/*',
|
|
15
|
+
'**/android/app/.cxx/**/*',
|
|
16
|
+
'**/ios/Pods/**/*',
|
|
17
|
+
// Ignore all expo configs because we will read expo config in a HashSourceContents already
|
|
18
|
+
'app.config.ts',
|
|
19
|
+
'app.config.js',
|
|
20
|
+
'app.config.json',
|
|
21
|
+
'app.json',
|
|
22
|
+
];
|
|
23
|
+
async function normalizeOptionsAsync(projectRoot, options) {
|
|
9
24
|
return {
|
|
10
25
|
...options,
|
|
11
26
|
platforms: options?.platforms ?? ['android', 'ios'],
|
|
12
27
|
concurrentIoLimit: options?.concurrentIoLimit ?? os_1.default.cpus().length,
|
|
13
28
|
hashAlgorithm: options?.hashAlgorithm ?? 'sha1',
|
|
14
|
-
|
|
15
|
-
'**/android/build',
|
|
16
|
-
'**/android/app/build',
|
|
17
|
-
'**/android/app/.cxx',
|
|
18
|
-
'ios/Pods',
|
|
19
|
-
],
|
|
29
|
+
ignorePaths: await collectIgnorePathsAsync(projectRoot, options),
|
|
20
30
|
};
|
|
21
31
|
}
|
|
22
|
-
exports.
|
|
32
|
+
exports.normalizeOptionsAsync = normalizeOptionsAsync;
|
|
33
|
+
async function collectIgnorePathsAsync(projectRoot, options) {
|
|
34
|
+
const ignorePaths = [
|
|
35
|
+
...exports.DEFAULT_IGNORE_PATHS,
|
|
36
|
+
...(options?.ignorePaths ?? []),
|
|
37
|
+
...(options?.dirExcludes?.map((dirExclude) => `${dirExclude}/**/*`) ?? []),
|
|
38
|
+
];
|
|
39
|
+
const fingerprintIgnorePath = path_1.default.join(projectRoot, exports.FINGERPRINT_IGNORE_FILENAME);
|
|
40
|
+
try {
|
|
41
|
+
const fingerprintIgnore = await promises_1.default.readFile(fingerprintIgnorePath, 'utf8');
|
|
42
|
+
const fingerprintIgnoreLines = fingerprintIgnore.split('\n');
|
|
43
|
+
for (const line of fingerprintIgnoreLines) {
|
|
44
|
+
const trimmedLine = line.trim();
|
|
45
|
+
if (trimmedLine) {
|
|
46
|
+
ignorePaths.push(trimmedLine);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch { }
|
|
51
|
+
return ignorePaths;
|
|
52
|
+
}
|
|
23
53
|
//# sourceMappingURL=Options.js.map
|
package/build/Options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Options.js","sourceRoot":"","sources":["../src/Options.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;
|
|
1
|
+
{"version":3,"file":"Options.js","sourceRoot":"","sources":["../src/Options.ts"],"names":[],"mappings":";;;;;;AAAA,2DAA6B;AAC7B,4CAAoB;AACpB,gDAAwB;AAIX,QAAA,2BAA2B,GAAG,oBAAoB,CAAC;AAEn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;gBACf,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;aAC/B;SACF;KACF;IAAC,MAAM,GAAE;IAEV,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
package/build/hash/Hash.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import minimatch from 'minimatch';
|
|
1
2
|
import pLimit from 'p-limit';
|
|
2
3
|
import type { Fingerprint, FingerprintSource, HashResult, HashSource, HashSourceContents, NormalizedOptions } from '../Fingerprint.types';
|
|
3
4
|
/**
|
|
@@ -12,7 +13,11 @@ export declare function createFingerprintSourceAsync(source: HashSource, limiter
|
|
|
12
13
|
/**
|
|
13
14
|
* Create a `HashResult` from a file
|
|
14
15
|
*/
|
|
15
|
-
export declare function createFileHashResultsAsync(filePath: string, limiter: pLimit.Limit, projectRoot: string, options: NormalizedOptions): Promise<HashResult>;
|
|
16
|
+
export declare function createFileHashResultsAsync(filePath: string, limiter: pLimit.Limit, projectRoot: string, options: NormalizedOptions): Promise<HashResult | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Indicate the given `filePath` should be excluded by `ignorePaths`
|
|
19
|
+
*/
|
|
20
|
+
export declare function isIgnoredPath(filePath: string, ignorePaths: string[], minimatchOptions?: minimatch.IOptions): boolean;
|
|
16
21
|
/**
|
|
17
22
|
* Create `HashResult` for a dir.
|
|
18
23
|
* If the dir is excluded, returns null rather than a HashResult
|
package/build/hash/Hash.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createSourceId = exports.createContentsHashResultsAsync = exports.createDirHashResultsAsync = exports.createFileHashResultsAsync = exports.createFingerprintSourceAsync = exports.createFingerprintFromSourcesAsync = void 0;
|
|
6
|
+
exports.createSourceId = exports.createContentsHashResultsAsync = exports.createDirHashResultsAsync = exports.isIgnoredPath = exports.createFileHashResultsAsync = exports.createFingerprintSourceAsync = exports.createFingerprintFromSourcesAsync = void 0;
|
|
7
7
|
const crypto_1 = require("crypto");
|
|
8
8
|
const fs_1 = require("fs");
|
|
9
9
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
@@ -60,6 +60,10 @@ async function createFileHashResultsAsync(filePath, limiter, projectRoot, option
|
|
|
60
60
|
// Backup code for faster hashing
|
|
61
61
|
/*
|
|
62
62
|
return limiter(async () => {
|
|
63
|
+
if (isIgnoredPath(filePath, options.ignorePaths)) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
63
67
|
const hasher = createHash(options.hashAlgorithm);
|
|
64
68
|
|
|
65
69
|
const stat = await fs.stat(filePath);
|
|
@@ -76,6 +80,9 @@ async function createFileHashResultsAsync(filePath, limiter, projectRoot, option
|
|
|
76
80
|
*/
|
|
77
81
|
return limiter(() => {
|
|
78
82
|
return new Promise((resolve, reject) => {
|
|
83
|
+
if (isIgnoredPath(filePath, options.ignorePaths)) {
|
|
84
|
+
return resolve(null);
|
|
85
|
+
}
|
|
79
86
|
let resolved = false;
|
|
80
87
|
const hasher = (0, crypto_1.createHash)(options.hashAlgorithm);
|
|
81
88
|
const stream = (0, fs_1.createReadStream)(path_1.default.join(projectRoot, filePath));
|
|
@@ -97,22 +104,29 @@ async function createFileHashResultsAsync(filePath, limiter, projectRoot, option
|
|
|
97
104
|
}
|
|
98
105
|
exports.createFileHashResultsAsync = createFileHashResultsAsync;
|
|
99
106
|
/**
|
|
100
|
-
* Indicate the given `
|
|
107
|
+
* Indicate the given `filePath` should be excluded by `ignorePaths`
|
|
101
108
|
*/
|
|
102
|
-
function
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
109
|
+
function isIgnoredPath(filePath, ignorePaths, minimatchOptions = { dot: true }) {
|
|
110
|
+
const minimatchObjs = ignorePaths.map((ignorePath) => new minimatch_1.default.Minimatch(ignorePath, minimatchOptions));
|
|
111
|
+
let result = false;
|
|
112
|
+
for (const minimatchObj of minimatchObjs) {
|
|
113
|
+
const currMatch = minimatchObj.match(filePath);
|
|
114
|
+
if (minimatchObj.negate && result && !currMatch) {
|
|
115
|
+
// Special handler for negate (!pattern).
|
|
116
|
+
// As long as previous match result is true and not matched from the current negate pattern, we should early return.
|
|
117
|
+
return false;
|
|
106
118
|
}
|
|
119
|
+
result || (result = currMatch);
|
|
107
120
|
}
|
|
108
|
-
return
|
|
121
|
+
return result;
|
|
109
122
|
}
|
|
123
|
+
exports.isIgnoredPath = isIgnoredPath;
|
|
110
124
|
/**
|
|
111
125
|
* Create `HashResult` for a dir.
|
|
112
126
|
* If the dir is excluded, returns null rather than a HashResult
|
|
113
127
|
*/
|
|
114
128
|
async function createDirHashResultsAsync(dirPath, limiter, projectRoot, options, depth = 0) {
|
|
115
|
-
if (
|
|
129
|
+
if (isIgnoredPath(dirPath, options.ignorePaths)) {
|
|
116
130
|
return null;
|
|
117
131
|
}
|
|
118
132
|
const dirents = (await promises_1.default.readdir(path_1.default.join(projectRoot, dirPath), { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -128,12 +142,13 @@ async function createDirHashResultsAsync(dirPath, limiter, projectRoot, options,
|
|
|
128
142
|
}
|
|
129
143
|
}
|
|
130
144
|
const hasher = (0, crypto_1.createHash)(options.hashAlgorithm);
|
|
131
|
-
const results = await Promise.all(promises);
|
|
145
|
+
const results = (await Promise.all(promises)).filter((result) => result != null);
|
|
146
|
+
if (results.length === 0) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
132
149
|
for (const result of results) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
hasher.update(result.hex);
|
|
136
|
-
}
|
|
150
|
+
hasher.update(result.id);
|
|
151
|
+
hasher.update(result.hex);
|
|
137
152
|
}
|
|
138
153
|
const hex = hasher.digest('hex');
|
|
139
154
|
return { id: dirPath, hex };
|
package/build/hash/Hash.js.map
CHANGED
|
@@ -1 +1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,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpF,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC;AAChC,CAAC;AAND,wEAMC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,MAAkB;IAC/C,QAAQ,MAAM,CAAC,IAAI,EAAE;QACnB,KAAK,UAAU;YACb,OAAO,MAAM,CAAC,EAAE,CAAC;QACnB,KAAK,MAAM;YACT,OAAO,MAAM,CAAC,QAAQ,CAAC;QACzB,KAAK,KAAK;YACR,OAAO,MAAM,CAAC,QAAQ,CAAC;QACzB;YACE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;KAC9C;AACH,CAAC;AAXD,wCAWC"}
|
package/build/sourcer/Expo.js
CHANGED
|
@@ -13,26 +13,22 @@ const resolve_from_1 = __importDefault(require("resolve-from"));
|
|
|
13
13
|
const Utils_1 = require("./Utils");
|
|
14
14
|
const debug = require('debug')('expo:fingerprint:sourcer:Expo');
|
|
15
15
|
async function getExpoConfigSourcesAsync(projectRoot, options) {
|
|
16
|
+
const results = [];
|
|
16
17
|
let config;
|
|
17
18
|
try {
|
|
18
19
|
const { getConfig } = require((0, resolve_from_1.default)(path_1.default.resolve(projectRoot), 'expo/config'));
|
|
19
20
|
config = await getConfig(projectRoot, { skipSDKVersionRequirement: true });
|
|
21
|
+
results.push({
|
|
22
|
+
type: 'contents',
|
|
23
|
+
id: 'expoConfig',
|
|
24
|
+
contents: normalizeExpoConfig(config.exp),
|
|
25
|
+
reasons: ['expoConfig'],
|
|
26
|
+
});
|
|
20
27
|
}
|
|
21
28
|
catch (e) {
|
|
22
29
|
debug('Cannot get Expo config: ' + e);
|
|
23
30
|
return [];
|
|
24
31
|
}
|
|
25
|
-
const results = [];
|
|
26
|
-
// app config files
|
|
27
|
-
const configFiles = ['app.config.ts', 'app.config.js', 'app.config.json', 'app.json'];
|
|
28
|
-
const configFileSources = (await Promise.all(configFiles.map(async (file) => {
|
|
29
|
-
const result = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, file, 'expoConfig');
|
|
30
|
-
if (result != null) {
|
|
31
|
-
debug(`Adding config file - ${chalk_1.default.dim(file)}`);
|
|
32
|
-
}
|
|
33
|
-
return result;
|
|
34
|
-
}))).filter(Boolean);
|
|
35
|
-
results.push(...configFileSources);
|
|
36
32
|
// external files in config
|
|
37
33
|
const isAndroid = options.platforms.includes('android');
|
|
38
34
|
const isIos = options.platforms.includes('ios');
|
|
@@ -78,6 +74,13 @@ function findUpPluginRoot(entryFile) {
|
|
|
78
74
|
(0, assert_1.default)(packageJson, `No package.json found for module "${entryRoot}"`);
|
|
79
75
|
return path_1.default.dirname(packageJson);
|
|
80
76
|
}
|
|
77
|
+
function normalizeExpoConfig(config) {
|
|
78
|
+
// Deep clone by JSON.parse/stringify that assumes the config is serializable.
|
|
79
|
+
const normalizedConfig = JSON.parse(JSON.stringify(config));
|
|
80
|
+
delete normalizedConfig.runtimeVersion;
|
|
81
|
+
delete normalizedConfig._internal;
|
|
82
|
+
return (0, Utils_1.stringifyJsonSorted)(normalizedConfig);
|
|
83
|
+
}
|
|
81
84
|
function getConfigPluginSourcesAsync(projectRoot, plugins) {
|
|
82
85
|
if (plugins == null) {
|
|
83
86
|
return [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Expo.js","sourceRoot":"","sources":["../../src/sourcer/Expo.ts"],"names":[],"mappings":";;;;;;AAAA,oEAA2C;AAC3C,oDAA4B;AAC5B,kDAA0B;AAE1B,sDAA6B;AAC7B,gDAAwB;AACxB,gEAAuC;AAEvC,
|
|
1
|
+
{"version":3,"file":"Expo.js","sourceRoot":"","sources":["../../src/sourcer/Expo.ts"],"names":[],"mappings":";;;;;;AAAA,oEAA2C;AAC3C,oDAA4B;AAC5B,kDAA0B;AAE1B,sDAA6B;AAC7B,gDAAwB;AACxB,gEAAuC;AAEvC,mCAA2E;AAG3E,MAAM,KAAK,GAA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,IAAI,MAAM,CAAC,IAAI,EAAE;gBAC7B,MAAM,QAAQ,GAAG,cAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;gBAC5D,GAAG,CAAC,UAAU,GAAG,QAAQ,CAAC,CAAC,gCAAgC;gBAC3D,KAAK,CAAC,6CAA6C,eAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;gBAC1E,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;aAClD;SACF;QACD,OAAO,CAAC,IAAI,CAAC;YACX,IAAI,EAAE,UAAU;YAChB,EAAE,EAAE,2BAA2B;YAC/B,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;YAChC,OAAO;SACR,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;KAChB;IAAC,MAAM;QACN,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AAnCD,8EAmCC;AAED;;GAEG;AACH,SAAgB,gCAAgC,CAAC,MAA2B;IAC1E,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE;QACnC,oCAAoC;QACpC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAsB,EAAE,CAAsB,EAAE,EAAE,CACtE,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC/C,CAAC;KACH;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AARD,4EAQC"}
|
package/build/sourcer/Utils.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import type { HashSource } from '../Fingerprint.types';
|
|
2
2
|
export declare function getFileBasedHashSourceAsync(projectRoot: string, filePath: string, reason: string): Promise<HashSource | null>;
|
|
3
|
+
/**
|
|
4
|
+
* A version of `JSON.stringify` that keeps the keys sorted
|
|
5
|
+
*/
|
|
6
|
+
export declare function stringifyJsonSorted(target: any, space?: string | number | undefined): string;
|
package/build/sourcer/Utils.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getFileBasedHashSourceAsync = void 0;
|
|
6
|
+
exports.stringifyJsonSorted = exports.getFileBasedHashSourceAsync = void 0;
|
|
7
7
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
async function getFileBasedHashSourceAsync(projectRoot, filePath, reason) {
|
|
@@ -22,4 +22,41 @@ async function getFileBasedHashSourceAsync(projectRoot, filePath, reason) {
|
|
|
22
22
|
return result;
|
|
23
23
|
}
|
|
24
24
|
exports.getFileBasedHashSourceAsync = getFileBasedHashSourceAsync;
|
|
25
|
+
/**
|
|
26
|
+
* A version of `JSON.stringify` that keeps the keys sorted
|
|
27
|
+
*/
|
|
28
|
+
function stringifyJsonSorted(target, space) {
|
|
29
|
+
return JSON.stringify(target, (_, value) => sortJson(value), space);
|
|
30
|
+
}
|
|
31
|
+
exports.stringifyJsonSorted = stringifyJsonSorted;
|
|
32
|
+
function sortJson(json) {
|
|
33
|
+
if (Array.isArray(json)) {
|
|
34
|
+
return json.sort((a, b) => {
|
|
35
|
+
// Sort array items by their stringified value.
|
|
36
|
+
// We don't need the array to be sorted in meaningful way, just to be sorted in deterministic.
|
|
37
|
+
// E.g. `[{ b: '2' }, {}, { a: '3' }, null]` -> `[null, { a : '3' }, { b: '2' }, {}]`
|
|
38
|
+
// This result is not a perfect solution, but it's good enough for our use case.
|
|
39
|
+
const stringifiedA = stringifyJsonSorted(a);
|
|
40
|
+
const stringifiedB = stringifyJsonSorted(b);
|
|
41
|
+
if (stringifiedA < stringifiedB) {
|
|
42
|
+
return -1;
|
|
43
|
+
}
|
|
44
|
+
else if (stringifiedA > stringifiedB) {
|
|
45
|
+
return 1;
|
|
46
|
+
}
|
|
47
|
+
return 0;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (json != null && typeof json === 'object') {
|
|
51
|
+
// Sort object items by keys
|
|
52
|
+
return Object.keys(json)
|
|
53
|
+
.sort()
|
|
54
|
+
.reduce((acc, key) => {
|
|
55
|
+
acc[key] = json[key];
|
|
56
|
+
return acc;
|
|
57
|
+
}, {});
|
|
58
|
+
}
|
|
59
|
+
// Return primitives
|
|
60
|
+
return json;
|
|
61
|
+
}
|
|
25
62
|
//# sourceMappingURL=Utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../src/sourcer/Utils.ts"],"names":[],"mappings":";;;;;;AAAA,2DAA6B;AAC7B,gDAAwB;AAIjB,KAAK,UAAU,2BAA2B,CAC/C,WAAmB,EACnB,QAAgB,EAChB,MAAc;IAEd,IAAI,MAAM,GAAsB,IAAI,CAAC;IACrC,IAAI;QACF,MAAM,IAAI,GAAG,MAAM,kBAAE,CAAC,IAAI,CAAC,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;QAC7D,MAAM,GAAG;YACP,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM;YACzC,QAAQ;YACR,OAAO,EAAE,CAAC,MAAM,CAAC;SAClB,CAAC;KACH;IAAC,MAAM;QACN,MAAM,GAAG,IAAI,CAAC;KACf;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAjBD,kEAiBC"}
|
|
1
|
+
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../src/sourcer/Utils.ts"],"names":[],"mappings":";;;;;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,OAAO,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;KACJ;IAED,IAAI,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5C,4BAA4B;QAC5B,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;aACrB,IAAI,EAAE;aACN,MAAM,CAAC,CAAC,GAAQ,EAAE,GAAW,EAAE,EAAE;YAChC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;YACrB,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CAAC;KACV;IAED,oBAAoB;IACpB,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -131,11 +131,12 @@ exports[`getHashSourcesAsync - managed project should match snapshot 1`] = `
|
|
|
131
131
|
"type": "contents",
|
|
132
132
|
},
|
|
133
133
|
{
|
|
134
|
-
"
|
|
134
|
+
"contents": "{"android":{"adaptiveIcon":{"backgroundColor":"#FFFFFF","foregroundImage":"./assets/adaptive-icon.png"}},"assetBundlePatterns":["**/*"],"icon":"./assets/icon.png","ios":{"supportsTablet":true},"name":"fingerprint-e2e-managed","orientation":"portrait","platforms":["android","ios"],"sdkVersion":"47.0.0","slug":"fingerprint-e2e-managed","splash":{"backgroundColor":"#ffffff","image":"./assets/splash.png","resizeMode":"contain"},"updates":{"fallbackToCacheTimeout":0},"userInterfaceStyle":"light","version":"1.0.0","web":{"favicon":"./assets/favicon.png"}}",
|
|
135
|
+
"id": "expoConfig",
|
|
135
136
|
"reasons": [
|
|
136
137
|
"expoConfig",
|
|
137
138
|
],
|
|
138
|
-
"type": "
|
|
139
|
+
"type": "contents",
|
|
139
140
|
},
|
|
140
141
|
{
|
|
141
142
|
"filePath": "./assets/icon.png",
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
createProjectHashAsync,
|
|
9
9
|
diffFingerprintChangesAsync,
|
|
10
10
|
} from '../../src/Fingerprint';
|
|
11
|
-
import {
|
|
11
|
+
import { normalizeOptionsAsync } from '../../src/Options';
|
|
12
12
|
import { getHashSourcesAsync } from '../../src/sourcer/Sourcer';
|
|
13
13
|
|
|
14
14
|
describe('managed project test', () => {
|
|
@@ -65,7 +65,7 @@ describe('managed project test', () => {
|
|
|
65
65
|
|
|
66
66
|
const configPath = path.join(projectRoot, 'app.json');
|
|
67
67
|
const config = JSON.parse(await fs.readFile(configPath, 'utf8'));
|
|
68
|
-
config.jsEngine = 'hermes';
|
|
68
|
+
config.expo.jsEngine = 'hermes';
|
|
69
69
|
await fs.writeFile(configPath, JSON.stringify(config, null, 2));
|
|
70
70
|
|
|
71
71
|
const hash2 = await createProjectHashAsync(projectRoot);
|
|
@@ -147,7 +147,10 @@ describe(`getHashSourcesAsync - managed project`, () => {
|
|
|
147
147
|
});
|
|
148
148
|
|
|
149
149
|
it('should match snapshot', async () => {
|
|
150
|
-
const sources = await getHashSourcesAsync(
|
|
150
|
+
const sources = await getHashSourcesAsync(
|
|
151
|
+
projectRoot,
|
|
152
|
+
await normalizeOptionsAsync(projectRoot)
|
|
153
|
+
);
|
|
151
154
|
expect(sources).toMatchSnapshot();
|
|
152
155
|
});
|
|
153
156
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/fingerprint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "A library to generate a fingerprint from a React Native project",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"glob": "^7.1.7",
|
|
49
49
|
"temp-dir": "^2.0.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "431682b5adf82c17d11da7dc9b4648801299f520"
|
|
52
52
|
}
|
package/src/Fingerprint.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { dedupSources } from './Dedup';
|
|
2
2
|
import type { Fingerprint, FingerprintSource, Options } from './Fingerprint.types';
|
|
3
|
-
import {
|
|
3
|
+
import { normalizeOptionsAsync } from './Options';
|
|
4
4
|
import { sortSources } from './Sort';
|
|
5
5
|
import { createFingerprintFromSourcesAsync } from './hash/Hash';
|
|
6
6
|
import { getHashSourcesAsync } from './sourcer/Sourcer';
|
|
@@ -12,7 +12,7 @@ export async function createFingerprintAsync(
|
|
|
12
12
|
projectRoot: string,
|
|
13
13
|
options?: Options
|
|
14
14
|
): Promise<Fingerprint> {
|
|
15
|
-
const opts =
|
|
15
|
+
const opts = await normalizeOptionsAsync(projectRoot, options);
|
|
16
16
|
const sources = await getHashSourcesAsync(projectRoot, opts);
|
|
17
17
|
const normalizedSources = sortSources(dedupSources(sources, projectRoot));
|
|
18
18
|
const fingerprint = await createFingerprintFromSourcesAsync(normalizedSources, projectRoot, opts);
|
package/src/Fingerprint.types.ts
CHANGED
|
@@ -39,9 +39,21 @@ export interface Options {
|
|
|
39
39
|
/**
|
|
40
40
|
* Excludes directories from hashing. This supported pattern is as `glob()`.
|
|
41
41
|
* Default is `['android/build', 'android/app/build', 'android/app/.cxx', 'ios/Pods']`.
|
|
42
|
+
* @deprecated Use `ignorePaths` instead.
|
|
42
43
|
*/
|
|
43
44
|
dirExcludes?: string[];
|
|
44
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Ignore files and directories from hashing. This supported pattern is as `glob()`.
|
|
48
|
+
*
|
|
49
|
+
* Please note that the pattern matching is slightly different from gitignore. For example, we don't support partial matching where `build` does not match `android/build`. You should use `'**' + '/build'` instead.
|
|
50
|
+
* @see [minimatch implementations](https://github.com/isaacs/minimatch#comparisons-to-other-fnmatchglob-implementations) for more reference.
|
|
51
|
+
*
|
|
52
|
+
* Besides this `ignorePaths`, fingerprint comes with implicit default ignorePaths defined in `Options.DEFAULT_IGNORE_PATHS`.
|
|
53
|
+
* If you want to override the default ignorePaths, use `!` prefix.
|
|
54
|
+
*/
|
|
55
|
+
ignorePaths?: string[];
|
|
56
|
+
|
|
45
57
|
/**
|
|
46
58
|
* Additional sources for hashing.
|
|
47
59
|
*/
|
|
@@ -54,7 +66,7 @@ export interface NormalizedOptions extends Options {
|
|
|
54
66
|
platforms: NonNullable<Options['platforms']>;
|
|
55
67
|
concurrentIoLimit: NonNullable<Options['concurrentIoLimit']>;
|
|
56
68
|
hashAlgorithm: NonNullable<Options['hashAlgorithm']>;
|
|
57
|
-
|
|
69
|
+
ignorePaths: NonNullable<Options['ignorePaths']>;
|
|
58
70
|
}
|
|
59
71
|
|
|
60
72
|
export interface HashSourceFile {
|
package/src/Options.ts
CHANGED
|
@@ -1,18 +1,56 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
1
2
|
import os from 'os';
|
|
3
|
+
import path from 'path';
|
|
2
4
|
|
|
3
5
|
import type { NormalizedOptions, Options } from './Fingerprint.types';
|
|
4
6
|
|
|
5
|
-
export
|
|
7
|
+
export const FINGERPRINT_IGNORE_FILENAME = '.fingerprintignore';
|
|
8
|
+
|
|
9
|
+
export const DEFAULT_IGNORE_PATHS = [
|
|
10
|
+
FINGERPRINT_IGNORE_FILENAME,
|
|
11
|
+
'**/android/build/**/*',
|
|
12
|
+
'**/android/app/build/**/*',
|
|
13
|
+
'**/android/app/.cxx/**/*',
|
|
14
|
+
'**/ios/Pods/**/*',
|
|
15
|
+
|
|
16
|
+
// Ignore all expo configs because we will read expo config in a HashSourceContents already
|
|
17
|
+
'app.config.ts',
|
|
18
|
+
'app.config.js',
|
|
19
|
+
'app.config.json',
|
|
20
|
+
'app.json',
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
export async function normalizeOptionsAsync(
|
|
24
|
+
projectRoot: string,
|
|
25
|
+
options?: Options
|
|
26
|
+
): Promise<NormalizedOptions> {
|
|
6
27
|
return {
|
|
7
28
|
...options,
|
|
8
29
|
platforms: options?.platforms ?? ['android', 'ios'],
|
|
9
30
|
concurrentIoLimit: options?.concurrentIoLimit ?? os.cpus().length,
|
|
10
31
|
hashAlgorithm: options?.hashAlgorithm ?? 'sha1',
|
|
11
|
-
|
|
12
|
-
'**/android/build',
|
|
13
|
-
'**/android/app/build',
|
|
14
|
-
'**/android/app/.cxx',
|
|
15
|
-
'ios/Pods',
|
|
16
|
-
],
|
|
32
|
+
ignorePaths: await collectIgnorePathsAsync(projectRoot, options),
|
|
17
33
|
};
|
|
18
34
|
}
|
|
35
|
+
|
|
36
|
+
async function collectIgnorePathsAsync(projectRoot: string, options?: Options): Promise<string[]> {
|
|
37
|
+
const ignorePaths = [
|
|
38
|
+
...DEFAULT_IGNORE_PATHS,
|
|
39
|
+
...(options?.ignorePaths ?? []),
|
|
40
|
+
...(options?.dirExcludes?.map((dirExclude) => `${dirExclude}/**/*`) ?? []),
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
const fingerprintIgnorePath = path.join(projectRoot, FINGERPRINT_IGNORE_FILENAME);
|
|
44
|
+
try {
|
|
45
|
+
const fingerprintIgnore = await fs.readFile(fingerprintIgnorePath, 'utf8');
|
|
46
|
+
const fingerprintIgnoreLines = fingerprintIgnore.split('\n');
|
|
47
|
+
for (const line of fingerprintIgnoreLines) {
|
|
48
|
+
const trimmedLine = line.trim();
|
|
49
|
+
if (trimmedLine) {
|
|
50
|
+
ignorePaths.push(trimmedLine);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
} catch {}
|
|
54
|
+
|
|
55
|
+
return ignorePaths;
|
|
56
|
+
}
|