Skip to content

Commit 1da9573

Browse files
authored
[eas-cli] add support for build profiles in fingerprint generation (#2951)
* [eas-cli] add build profile support for fingerprint Temporary Commit at 3/16/2025, 6:31:01 PM Temporary Commit at 3/16/2025, 6:37:24 PM Temporary Commit at 3/16/2025, 7:59:29 PM Temporary Commit at 3/16/2025, 8:01:21 PM Temporary Commit at 3/18/2025, 2:38:20 PM Temporary Commit at 3/18/2025, 3:21:52 PM * Temporary Commit at 3/20/2025, 3:35:30 PM * Temporary Commit at 3/20/2025, 3:55:17 PM * Temporary Commit at 3/21/2025, 7:42:01 AM * Temporary Commit at 3/21/2025, 7:42:34 AM * Temporary Commit at 3/21/2025, 7:46:59 AM * Temporary Commit at 3/21/2025, 12:16:23 PM
1 parent 4e8fc05 commit 1da9573

File tree

5 files changed

+43
-12
lines changed

5 files changed

+43
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ This is the log of notable changes to EAS CLI and related packages.
88

99
### 🎉 New features
1010

11+
- Add environment flag to `eas fingerprint:generate`. ([#2951](https://github.com/expo/eas-cli/pull/2951) by [@quinlanj](https://github.com/quinlanj))
12+
1113
### 🐛 Bug fixes
1214

1315
### 🧹 Chores

packages/eas-cli/src/commands/fingerprint/compare.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ function isJSON(str: string): boolean {
757757
}
758758
}
759759

760-
export async function selectBuildToCompareAsync(
760+
async function selectBuildToCompareAsync(
761761
graphqlClient: ExpoGraphqlClient,
762762
projectId: string,
763763
projectDisplayName: string,

packages/eas-cli/src/commands/fingerprint/generate.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Flags } from '@oclif/core';
22

33
import { getExpoWebsiteBaseUrl } from '../../api';
44
import EasCommand from '../../commandUtils/EasCommand';
5-
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
5+
import { EASEnvironmentFlag, EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
66
import {
77
getFingerprintInfoFromLocalProjectForPlatformsAsync,
88
stringToAppPlatform,
@@ -19,15 +19,17 @@ export default class FingerprintGenerate extends EasCommand {
1919
static override hidden = true;
2020

2121
static override examples = [
22-
'$ eas fingerprint:generate',
23-
'$ eas fingerprint:generate --json --non-interactive -p android',
22+
'$ eas fingerprint:generate \t # Generate fingerprint in interactive mode',
23+
'$ eas fingerprint:generate --profile preview \t # Generate a fingerprint using the "preview" build profile',
24+
'$ eas fingerprint:generate --json --non-interactive --platform android \t # Output fingerprint json to stdout',
2425
];
2526

2627
static override flags = {
2728
platform: Flags.enum({
2829
char: 'p',
2930
options: ['android', 'ios'],
3031
}),
32+
...EASEnvironmentFlag,
3133
...EasNonInteractiveAndJsonFlags,
3234
};
3335

@@ -36,20 +38,27 @@ export default class FingerprintGenerate extends EasCommand {
3638
...this.ContextOptions.ProjectConfig,
3739
...this.ContextOptions.LoggedIn,
3840
...this.ContextOptions.Vcs,
41+
...this.ContextOptions.ServerSideEnvironmentVariables,
3942
};
4043

4144
async runAsync(): Promise<void> {
4245
const { flags } = await this.parse(FingerprintGenerate);
43-
const { json, 'non-interactive': nonInteractive, platform: platformStringFlag } = flags;
46+
const {
47+
json,
48+
'non-interactive': nonInteractive,
49+
platform: platformStringFlag,
50+
environment,
51+
} = flags;
4452

4553
const {
4654
projectId,
4755
privateProjectConfig: { projectDir },
4856
loggedIn: { graphqlClient },
4957
vcsClient,
58+
getServerSideEnvironmentVariablesAsync,
5059
} = await this.getContextAsync(FingerprintGenerate, {
5160
nonInteractive,
52-
withServerSideEnvironment: null,
61+
withServerSideEnvironment: environment ?? null,
5362
});
5463
if (json) {
5564
enableJsonOutput();
@@ -64,12 +73,17 @@ export default class FingerprintGenerate extends EasCommand {
6473
}
6574
platform = await selectRequestedPlatformAsync();
6675
}
76+
77+
const env = environment
78+
? { ...(await getServerSideEnvironmentVariablesAsync()), EXPO_NO_DOTENV: '1' }
79+
: undefined;
6780
const fingerprint = await getFingerprintInfoFromLocalProjectForPlatformsAsync(
6881
graphqlClient,
6982
projectDir,
7083
projectId,
7184
vcsClient,
72-
[platform]
85+
[platform],
86+
{ env }
7387
);
7488

7589
if (json) {
@@ -89,7 +103,7 @@ export default class FingerprintGenerate extends EasCommand {
89103
}
90104
}
91105

92-
export async function selectRequestedPlatformAsync(): Promise<AppPlatform> {
106+
async function selectRequestedPlatformAsync(): Promise<AppPlatform> {
93107
const { requestedPlatform } = await promptAsync({
94108
type: 'select',
95109
message: 'Select platform',

packages/eas-cli/src/fingerprint/cli.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,21 @@ async function createFingerprintWithoutLoggingAsync(
103103
if (options.debug) {
104104
fingerprintOptions.debug = true;
105105
}
106-
// eslint-disable-next-line @typescript-eslint/return-await
107-
return await Fingerprint.createFingerprintAsync(projectDir, fingerprintOptions);
106+
107+
return await withTemporaryEnvAsync(options.env ?? {}, () =>
108+
Fingerprint.createFingerprintAsync(projectDir, fingerprintOptions)
109+
);
110+
}
111+
112+
async function withTemporaryEnvAsync(envVars: Env, fn: () => Promise<any>): Promise<any> {
113+
const originalEnv = { ...process.env };
114+
Object.assign(process.env, envVars);
115+
116+
try {
117+
return await fn();
118+
} finally {
119+
process.env = originalEnv;
120+
}
108121
}
109122

110123
/**

packages/eas-cli/src/fingerprint/utils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export async function getFingerprintInfoFromLocalProjectForPlatformsAsync(
1515
projectDir: string,
1616
projectId: string,
1717
vcsClient: Client,
18-
platforms: AppPlatform[]
18+
platforms: AppPlatform[],
19+
{ env }: { env?: Record<string, string> } = {}
1920
): Promise<Fingerprint> {
2021
const workflows = await resolveWorkflowPerPlatformAsync(projectDir, vcsClient);
2122
const optionsFromWorkflow = getFingerprintOptionsFromWorkflow(platforms, workflows);
@@ -24,7 +25,7 @@ export async function getFingerprintInfoFromLocalProjectForPlatformsAsync(
2425
...optionsFromWorkflow,
2526
platforms: platforms.map(appPlatformToString),
2627
debug: true,
27-
env: undefined,
28+
env,
2829
});
2930
if (!projectFingerprint) {
3031
throw new Error('Project fingerprints can only be computed for projects with SDK 52 or higher');
@@ -45,6 +46,7 @@ export async function getFingerprintInfoFromLocalProjectForPlatformsAsync(
4546

4647
return projectFingerprint;
4748
}
49+
4850
function getFingerprintOptionsFromWorkflow(
4951
platforms: AppPlatform[],
5052
workflowsByPlatform: Record<Platform, Workflow>

0 commit comments

Comments
 (0)