1+ import { Env , Platform } from '@expo/eas-build-job' ;
2+ import { EasJsonAccessor } from '@expo/eas-json' ;
13import { Flags } from '@oclif/core' ;
24
35import { getExpoWebsiteBaseUrl } from '../../api' ;
6+ import { evaluateConfigWithEnvVarsAsync } from '../../build/evaluateConfigWithEnvVarsAsync' ;
47import EasCommand from '../../commandUtils/EasCommand' ;
58import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags' ;
69import {
@@ -12,22 +15,28 @@ import { AppQuery } from '../../graphql/queries/AppQuery';
1215import Log , { link } from '../../log' ;
1316import { promptAsync } from '../../prompts' ;
1417import { enableJsonOutput , printJsonOnlyOutput } from '../../utils/json' ;
18+ import { getProfilesAsync } from '../../utils/profiles' ;
1519
1620export default class FingerprintGenerate extends EasCommand {
1721 static override description = 'generate fingerprints from the current project' ;
1822 static override strict = false ;
1923 static override hidden = true ;
2024
2125 static override examples = [
22- '$ eas fingerprint:generate' ,
23- '$ eas fingerprint:generate --json --non-interactive -p android' ,
26+ '$ eas fingerprint:generate \t # Generate fingerprint in interactive mode' ,
27+ '$ eas fingerprint:generate --profile preview \t # Generate a fingerprint using the "preview" build profile' ,
28+ '$ eas fingerprint:generate --json --non-interactive --platform android \t # Output fingerprint json to stdout' ,
2429 ] ;
2530
2631 static override flags = {
2732 platform : Flags . enum ( {
2833 char : 'p' ,
2934 options : [ 'android' , 'ios' ] ,
3035 } ) ,
36+ profile : Flags . string ( {
37+ char : 'e' ,
38+ description : 'Name of the build profile from eas.json.' ,
39+ } ) ,
3140 ...EasNonInteractiveAndJsonFlags ,
3241 } ;
3342
@@ -36,17 +45,24 @@ export default class FingerprintGenerate extends EasCommand {
3645 ...this . ContextOptions . ProjectConfig ,
3746 ...this . ContextOptions . LoggedIn ,
3847 ...this . ContextOptions . Vcs ,
48+ ...this . ContextOptions . DynamicProjectConfig ,
3949 } ;
4050
4151 async runAsync ( ) : Promise < void > {
4252 const { flags } = await this . parse ( FingerprintGenerate ) ;
43- const { json, 'non-interactive' : nonInteractive , platform : platformStringFlag } = flags ;
53+ const {
54+ json,
55+ 'non-interactive' : nonInteractive ,
56+ platform : platformStringFlag ,
57+ profile : buildProfileName ,
58+ } = flags ;
4459
4560 const {
4661 projectId,
4762 privateProjectConfig : { projectDir } ,
4863 loggedIn : { graphqlClient } ,
4964 vcsClient,
65+ getDynamicPrivateProjectConfigAsync,
5066 } = await this . getContextAsync ( FingerprintGenerate , {
5167 nonInteractive,
5268 withServerSideEnvironment : null ,
@@ -64,12 +80,39 @@ export default class FingerprintGenerate extends EasCommand {
6480 }
6581 platform = await selectRequestedPlatformAsync ( ) ;
6682 }
83+
84+ let env : Env | undefined ;
85+ if ( buildProfileName ) {
86+ const easJsonAccessor = EasJsonAccessor . fromProjectPath ( projectDir ) ;
87+ const buildProfile = (
88+ await getProfilesAsync ( {
89+ type : 'build' ,
90+ easJsonAccessor,
91+ platforms : [ appPlatformtoPlatform ( platform ) ] ,
92+ profileName : buildProfileName ?? undefined ,
93+ projectDir,
94+ } )
95+ ) [ 0 ] ;
96+ if ( ! buildProfile ) {
97+ throw new Error ( `Build profile ${ buildProfile } not found for platform: ${ platform } ` ) ;
98+ }
99+ const configResult = await evaluateConfigWithEnvVarsAsync ( {
100+ buildProfile : buildProfile . profile ,
101+ buildProfileName : buildProfile . profileName ,
102+ graphqlClient,
103+ getProjectConfig : getDynamicPrivateProjectConfigAsync ,
104+ opts : { env : buildProfile . profile . env } ,
105+ } ) ;
106+ env = configResult . env ;
107+ }
108+
67109 const fingerprint = await getFingerprintInfoFromLocalProjectForPlatformsAsync (
68110 graphqlClient ,
69111 projectDir ,
70112 projectId ,
71113 vcsClient ,
72- [ platform ]
114+ [ platform ] ,
115+ { env }
73116 ) ;
74117
75118 if ( json ) {
@@ -89,7 +132,7 @@ export default class FingerprintGenerate extends EasCommand {
89132 }
90133}
91134
92- export async function selectRequestedPlatformAsync ( ) : Promise < AppPlatform > {
135+ async function selectRequestedPlatformAsync ( ) : Promise < AppPlatform > {
93136 const { requestedPlatform } = await promptAsync ( {
94137 type : 'select' ,
95138 message : 'Select platform' ,
@@ -101,3 +144,13 @@ export async function selectRequestedPlatformAsync(): Promise<AppPlatform> {
101144 } ) ;
102145 return requestedPlatform ;
103146}
147+
148+ function appPlatformtoPlatform ( appPlatform : AppPlatform ) : Platform {
149+ if ( appPlatform === AppPlatform . Android ) {
150+ return Platform . ANDROID ;
151+ } else if ( appPlatform === AppPlatform . Ios ) {
152+ return Platform . IOS ;
153+ } else {
154+ throw new Error ( 'Unsupported platform: ' + appPlatform ) ;
155+ }
156+ }
0 commit comments