eas-cli
Version:
EAS command line tool
111 lines (110 loc) • 5.17 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.createFingerprintsByKeyAsync = exports.createFingerprintAsync = exports.diffFingerprint = void 0;
const tslib_1 = require("tslib");
const eas_build_job_1 = require("@expo/eas-build-job");
const resolve_from_1 = require("resolve-from");
const mapMapAsync_1 = tslib_1.__importDefault(require("./expodash/mapMapAsync"));
const log_1 = tslib_1.__importDefault(require("../log"));
const ora_1 = require("../ora");
function diffFingerprint(projectDir, fingerprint1, fingerprint2) {
// @expo/fingerprint is exported in the expo package for SDK 52+
const fingerprintPath = (0, resolve_from_1.silent)(projectDir, 'expo/fingerprint');
if (!fingerprintPath) {
return null;
}
const Fingerprint = require(fingerprintPath);
return Fingerprint.diffFingerprints(fingerprint1, fingerprint2);
}
exports.diffFingerprint = diffFingerprint;
async function createFingerprintAsync(projectDir, options) {
// @expo/fingerprint is exported in the expo package for SDK 52+
const fingerprintPath = (0, resolve_from_1.silent)(projectDir, 'expo/fingerprint');
if (!fingerprintPath) {
return null;
}
if (process.env.EAS_SKIP_AUTO_FINGERPRINT) {
log_1.default.log('Skipping project fingerprint');
return null;
}
const timeoutId = setTimeout(() => {
log_1.default.log('⌛️ Computing the project fingerprint is taking longer than expected...');
log_1.default.log('⏩ To skip this step, set the environment variable: EAS_SKIP_AUTO_FINGERPRINT=1');
}, 5000);
const spinner = (0, ora_1.ora)(`Computing project fingerprint`).start();
try {
const fingerprint = await createFingerprintWithoutLoggingAsync(projectDir, fingerprintPath, options);
spinner.succeed(`Computed project fingerprint`);
return fingerprint;
}
catch (e) {
spinner.fail(`Failed to compute project fingerprint`);
log_1.default.log('⏩ To skip this step, set the environment variable: EAS_SKIP_AUTO_FINGERPRINT=1');
throw e;
}
finally {
// Clear the timeout if the operation finishes before the time limit
clearTimeout(timeoutId);
spinner.stop();
}
}
exports.createFingerprintAsync = createFingerprintAsync;
async function createFingerprintWithoutLoggingAsync(projectDir, fingerprintPath, options) {
const Fingerprint = require(fingerprintPath);
const fingerprintOptions = {};
if (options.platforms) {
fingerprintOptions.platforms = [...options.platforms];
}
if (options.workflow === eas_build_job_1.Workflow.MANAGED) {
fingerprintOptions.ignorePaths = ['android/**/*', 'ios/**/*'];
}
if (options.debug) {
fingerprintOptions.debug = true;
}
// eslint-disable-next-line @typescript-eslint/return-await
return await Fingerprint.createFingerprintAsync(projectDir, fingerprintOptions);
}
/**
* Computes project fingerprints based on provided options and returns a map of fingerprint data keyed by a string.
*
* @param projectDir - The root directory of the project.
* @param fingerprintOptionsByKey - A map where each key is associated with options for generating the fingerprint.
* - **Key**: A unique identifier (`string`) for the fingerprint options.
* - **Value**: An object containing options for generating a fingerprint.
*
* @returns A promise that resolves to a map where each key corresponds to the input keys, and each value is an object containing fingerprint data.
*
* @throws Will throw an error if fingerprint computation fails.
*/
async function createFingerprintsByKeyAsync(projectDir, fingerprintOptionsByKey) {
// @expo/fingerprint is exported in the expo package for SDK 52+
const fingerprintPath = (0, resolve_from_1.silent)(projectDir, 'expo/fingerprint');
if (!fingerprintPath) {
return new Map();
}
if (process.env.EAS_SKIP_AUTO_FINGERPRINT) {
log_1.default.log('Skipping project fingerprints');
return new Map();
}
const timeoutId = setTimeout(() => {
log_1.default.log('⌛️ Computing the project fingerprints is taking longer than expected...');
log_1.default.log('⏩ To skip this step, set the environment variable: EAS_SKIP_AUTO_FINGERPRINT=1');
}, 5000);
const spinner = (0, ora_1.ora)(`Computing project fingerprints`).start();
try {
const fingerprintsByKey = await (0, mapMapAsync_1.default)(fingerprintOptionsByKey, async (options) => await createFingerprintWithoutLoggingAsync(projectDir, fingerprintPath, options));
spinner.succeed(`Computed project fingerprints`);
return fingerprintsByKey;
}
catch (e) {
spinner.fail(`Failed to compute project fingerprints`);
log_1.default.log('⏩ To skip this step, set the environment variable: EAS_SKIP_AUTO_FINGERPRINT=1');
throw e;
}
finally {
// Clear the timeout if the operation finishes before the time limit
clearTimeout(timeoutId);
spinner.stop();
}
}
exports.createFingerprintsByKeyAsync = createFingerprintsByKeyAsync;
;