Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[eas-cli] improve fingerprint UX #2675

Merged
merged 5 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ This is the log of notable changes to EAS CLI and related packages.

### 🎉 New features

- Add EAS_SKIP_AUTO_FINGERPRINT to skip fingerprint computation on build ([#2675](https://github.com/expo/eas-cli/pull/2675) by [@quinlanj](https://github.com/quinlanj))

### 🐛 Bug fixes

### 🧹 Chores
Expand Down
48 changes: 37 additions & 11 deletions packages/eas-cli/src/utils/fingerprintCli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Env, Workflow } from '@expo/eas-build-job';
import { silent as silentResolveFrom } from 'resolve-from';

import Log from '../log';
import { ora } from '../ora';

export async function createFingerprintAsync(
projectDir: string,
options: {
Expand All @@ -20,17 +23,40 @@ export async function createFingerprintAsync(
if (!fingerprintPath) {
return null;
}
const Fingerprint = require(fingerprintPath);
const fingerprintOptions: Record<string, any> = {};
if (options.platform) {
fingerprintOptions.platforms = [options.platform];
}
if (options.workflow === Workflow.MANAGED) {
fingerprintOptions.ignorePaths = ['android/**/*', 'ios/**/*'];

if (process.env.EAS_SKIP_AUTO_FINGERPRINT) {
Log.log('Skipping project fingerprint');
return null;
}
if (options.debug) {
fingerprintOptions.debug = true;

const timeoutId = setTimeout(() => {
Log.log('⌛️ Computing the project fingerprint is taking longer than expected...');
Log.log('⏩ To skip this step, set the environment variable: EAS_SKIP_AUTO_FINGERPRINT=1');
}, 5000);

const spinner = ora(`Computing project fingerprint`).start();
try {
const Fingerprint = require(fingerprintPath);
const fingerprintOptions: Record<string, any> = {};
if (options.platform) {
fingerprintOptions.platforms = [options.platform];
}
if (options.workflow === Workflow.MANAGED) {
fingerprintOptions.ignorePaths = ['android/**/*', 'ios/**/*'];
}
if (options.debug) {
fingerprintOptions.debug = true;
}
const fingerprint = await Fingerprint.createFingerprintAsync(projectDir, fingerprintOptions);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot this when I was reviewing the other PR re: doing a function call directly vs CLI call. One additional consideration/benefit of CLI is the process/subprocess model of using the CLI via spawn instead of a direct function call. By having this be in a subprocess rather than the CLI process, we could monitor that and even kill it with a Promise.race if it's taking too long (I think?).

spinner.succeed(`Computed project fingerprint`);
return fingerprint;
} catch (e) {
spinner.fail(`Failed to compute project fingerprint`);
Log.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();
}
// eslint-disable-next-line @typescript-eslint/return-await
return await Fingerprint.createFingerprintAsync(projectDir, fingerprintOptions);
}
Loading