1+ import { Env , Platform } from '@expo/eas-build-job' ;
2+ import { EasJsonAccessor } from '@expo/eas-json' ;
13import { Flags } from '@oclif/core' ;
24
35import {
46 getFingerprintInfoFromLocalProjectForPlatformsAsync ,
57 stringToAppPlatform ,
68} from './compare' ;
79import { getExpoWebsiteBaseUrl } from '../../api' ;
10+ import { evaluateConfigWithEnvVarsAsync } from '../../build/evaluateConfigWithEnvVarsAsync' ;
811import EasCommand from '../../commandUtils/EasCommand' ;
912import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags' ;
1013import { AppPlatform } from '../../graphql/generated' ;
1114import { 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 --json --non-interactive --platform android \t # Output fingerprint json to stdout ' ,
2428 ] ;
2529
2630 static override flags = {
2731 platform : Flags . enum ( {
2832 char : 'p' ,
2933 options : [ 'android' , 'ios' ] ,
3034 } ) ,
35+ profile : Flags . string ( {
36+ char : 'e' ,
37+ description : 'Name of the build profile from eas.json.' ,
38+ } ) ,
3139 ...EasNonInteractiveAndJsonFlags ,
3240 } ;
3341
@@ -36,17 +44,24 @@ export default class FingerprintGenerate extends EasCommand {
3644 ...this . ContextOptions . ProjectConfig ,
3745 ...this . ContextOptions . LoggedIn ,
3846 ...this . ContextOptions . Vcs ,
47+ ...this . ContextOptions . DynamicProjectConfig ,
3948 } ;
4049
4150 async runAsync ( ) : Promise < void > {
4251 const { flags } = await this . parse ( FingerprintGenerate ) ;
43- const { json, 'non-interactive' : nonInteractive , platform : platformStringFlag } = flags ;
52+ const {
53+ json,
54+ 'non-interactive' : nonInteractive ,
55+ platform : platformStringFlag ,
56+ profile : buildProfileName ,
57+ } = flags ;
4458
4559 const {
4660 projectId,
4761 privateProjectConfig : { projectDir } ,
4862 loggedIn : { graphqlClient } ,
4963 vcsClient,
64+ getDynamicPrivateProjectConfigAsync,
5065 } = await this . getContextAsync ( FingerprintGenerate , {
5166 nonInteractive,
5267 withServerSideEnvironment : null ,
@@ -64,12 +79,39 @@ export default class FingerprintGenerate extends EasCommand {
6479 }
6580 platform = await selectRequestedPlatformAsync ( ) ;
6681 }
82+
83+ let env : Env | undefined ;
84+ if ( buildProfileName ) {
85+ const easJsonAccessor = EasJsonAccessor . fromProjectPath ( projectDir ) ;
86+ const buildProfile = (
87+ await getProfilesAsync ( {
88+ type : 'build' ,
89+ easJsonAccessor,
90+ platforms : [ appPlatformtoPlatform ( platform ) ] ,
91+ profileName : buildProfileName ?? undefined ,
92+ projectDir,
93+ } )
94+ ) [ 0 ] ;
95+ if ( ! buildProfile ) {
96+ throw new Error ( `Build profile ${ buildProfile } not found for platform: ${ platform } ` ) ;
97+ }
98+ const configResult = await evaluateConfigWithEnvVarsAsync ( {
99+ buildProfile : buildProfile . profile ,
100+ buildProfileName : buildProfile . profileName ,
101+ graphqlClient,
102+ getProjectConfig : getDynamicPrivateProjectConfigAsync ,
103+ opts : { env : buildProfile . profile . env } ,
104+ } ) ;
105+ env = configResult . env ;
106+ }
107+
67108 const fingerprint = await getFingerprintInfoFromLocalProjectForPlatformsAsync (
68109 graphqlClient ,
69110 projectDir ,
70111 projectId ,
71112 vcsClient ,
72- [ platform ]
113+ [ platform ] ,
114+ { env }
73115 ) ;
74116
75117 if ( json ) {
@@ -101,3 +143,13 @@ export async function selectRequestedPlatformAsync(): Promise<AppPlatform> {
101143 } ) ;
102144 return requestedPlatform ;
103145}
146+
147+ function appPlatformtoPlatform ( appPlatform : AppPlatform ) : Platform {
148+ if ( appPlatform === AppPlatform . Android ) {
149+ return Platform . ANDROID ;
150+ } else if ( appPlatform === AppPlatform . Ios ) {
151+ return Platform . IOS ;
152+ } else {
153+ throw new Error ( 'Unsupported platform: ' + appPlatform ) ;
154+ }
155+ }
0 commit comments