1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3    return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5Object.defineProperty(exports, "__esModule", { value: true });
6exports.normalizeOptionsAsync = exports.DEFAULT_IGNORE_PATHS = exports.FINGERPRINT_IGNORE_FILENAME = void 0;
7const promises_1 = __importDefault(require("fs/promises"));
8const os_1 = __importDefault(require("os"));
9const path_1 = __importDefault(require("path"));
10exports.FINGERPRINT_IGNORE_FILENAME = '.fingerprintignore';
11exports.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    // Ignore default javascript files when calling `getConfig()`
23    '**/node_modules/@babel/**/*',
24    '**/node_modules/@expo/**/*',
25    '**/node_modules/@jridgewell/**/*',
26    '**/node_modules/expo/config.js',
27    '**/node_modules/expo/config-plugins.js',
28    `**/node_modules/{${[
29        'debug',
30        'escape-string-regexp',
31        'getenv',
32        'graceful-fs',
33        'has-flag',
34        'imurmurhash',
35        'js-tokens',
36        'json5',
37        'lines-and-columns',
38        'require-from-string',
39        'resolve-from',
40        'signal-exit',
41        'sucrase',
42        'supports-color',
43        'ts-interface-checker',
44        'write-file-atomic',
45    ].join(',')}}/**/*`,
46];
47async function normalizeOptionsAsync(projectRoot, options) {
48    return {
49        ...options,
50        platforms: options?.platforms ?? ['android', 'ios'],
51        concurrentIoLimit: options?.concurrentIoLimit ?? os_1.default.cpus().length,
52        hashAlgorithm: options?.hashAlgorithm ?? 'sha1',
53        ignorePaths: await collectIgnorePathsAsync(projectRoot, options),
54    };
55}
56exports.normalizeOptionsAsync = normalizeOptionsAsync;
57async function collectIgnorePathsAsync(projectRoot, options) {
58    const ignorePaths = [
59        ...exports.DEFAULT_IGNORE_PATHS,
60        ...(options?.ignorePaths ?? []),
61        ...(options?.dirExcludes?.map((dirExclude) => `${dirExclude}/**/*`) ?? []),
62    ];
63    const fingerprintIgnorePath = path_1.default.join(projectRoot, exports.FINGERPRINT_IGNORE_FILENAME);
64    try {
65        const fingerprintIgnore = await promises_1.default.readFile(fingerprintIgnorePath, 'utf8');
66        const fingerprintIgnoreLines = fingerprintIgnore.split('\n');
67        for (const line of fingerprintIgnoreLines) {
68            const trimmedLine = line.trim();
69            if (trimmedLine) {
70                ignorePaths.push(trimmedLine);
71            }
72        }
73    }
74    catch { }
75    return ignorePaths;
76}
77//# sourceMappingURL=Options.js.map