@@ -11,7 +11,7 @@ import { v4 as uuidv4 } from 'uuid';
11
11
import { getBuildLogsUrl } from '../build/utils/url' ;
12
12
import EasCommand from '../commandUtils/EasCommand' ;
13
13
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient' ;
14
- import { EASNonInteractiveFlag } from '../commandUtils/flags' ;
14
+ import { EasNonInteractiveAndJsonFlags } from '../commandUtils/flags' ;
15
15
import {
16
16
DistributionType ,
17
17
LocalBuildArchiveSourceType ,
@@ -24,6 +24,7 @@ import Log from '../log';
24
24
import { promptAsync } from '../prompts' ;
25
25
import * as xcode from '../run/ios/xcode' ;
26
26
import { uploadFileAtPathToGCSAsync } from '../uploads' ;
27
+ import { enableJsonOutput , printJsonOnlyOutput } from '../utils/json' ;
27
28
import { getTmpDirectory } from '../utils/paths' ;
28
29
import { createProgressTracker } from '../utils/progress' ;
29
30
@@ -42,7 +43,7 @@ export default class BuildUpload extends EasCommand {
42
43
fingerprint : Flags . string ( {
43
44
description : 'Fingerprint hash of the local build' ,
44
45
} ) ,
45
- ...EASNonInteractiveFlag ,
46
+ ...EasNonInteractiveAndJsonFlags ,
46
47
} ;
47
48
48
49
static override contextDefinition = {
@@ -52,16 +53,29 @@ export default class BuildUpload extends EasCommand {
52
53
53
54
async runAsync ( ) : Promise < void > {
54
55
const { flags } = await this . parse ( BuildUpload ) ;
55
- const { 'build-path' : buildPath , fingerprint : manualFingerprintHash } = flags ;
56
+ const {
57
+ 'build-path' : buildPath ,
58
+ fingerprint : manualFingerprintHash ,
59
+ json : jsonFlag ,
60
+ 'non-interactive' : nonInteractive ,
61
+ } = flags ;
56
62
const {
57
63
projectId,
58
64
loggedIn : { graphqlClient } ,
59
65
} = await this . getContextAsync ( BuildUpload , {
60
- nonInteractive : false ,
66
+ nonInteractive,
61
67
} ) ;
62
68
63
- const platform = await this . selectPlatformAsync ( flags . platform ) ;
64
- const localBuildPath = await resolveLocalBuildPathAsync ( platform , buildPath ) ;
69
+ if ( jsonFlag ) {
70
+ enableJsonOutput ( ) ;
71
+ }
72
+
73
+ const platform = await this . selectPlatformAsync ( { platform : flags . platform , nonInteractive } ) ;
74
+ const localBuildPath = await resolveLocalBuildPathAsync ( {
75
+ platform,
76
+ inputBuildPath : buildPath ,
77
+ nonInteractive,
78
+ } ) ;
65
79
66
80
const {
67
81
fingerprintHash : buildFingerprintHash ,
@@ -74,7 +88,8 @@ export default class BuildUpload extends EasCommand {
74
88
if (
75
89
manualFingerprintHash &&
76
90
buildFingerprintHash &&
77
- manualFingerprintHash !== buildFingerprintHash
91
+ manualFingerprintHash !== buildFingerprintHash &&
92
+ ! nonInteractive
78
93
) {
79
94
const selectedAnswer = await promptAsync ( {
80
95
name : 'fingerprint' ,
@@ -107,10 +122,26 @@ export default class BuildUpload extends EasCommand {
107
122
{ distribution : DistributionType . Internal , fingerprintHash : fingerprint , developmentClient }
108
123
) ;
109
124
110
- Log . withTick ( `Here is a sharable link of your build: ${ getBuildLogsUrl ( build ) } ` ) ;
125
+ if ( jsonFlag ) {
126
+ printJsonOnlyOutput ( { url : getBuildLogsUrl ( build ) } ) ;
127
+ return ;
128
+ }
129
+
130
+ Log . withTick ( `Shareable link to the build: ${ getBuildLogsUrl ( build ) } ` ) ;
131
+
111
132
}
112
133
113
- private async selectPlatformAsync ( platform ?: Platform ) : Promise < Platform > {
134
+ private async selectPlatformAsync ( {
135
+ nonInteractive,
136
+ platform,
137
+ } : {
138
+ nonInteractive : boolean ;
139
+ platform ?: Platform ;
140
+ } ) : Promise < Platform > {
141
+ if ( nonInteractive && ! platform ) {
142
+ throw new Error ( 'Platform must be provided in non-interactive mode' ) ;
143
+ }
144
+
114
145
if ( platform ) {
115
146
return platform ;
116
147
}
@@ -127,10 +158,15 @@ export default class BuildUpload extends EasCommand {
127
158
}
128
159
}
129
160
130
- async function resolveLocalBuildPathAsync (
131
- platform : Platform ,
132
- inputBuildPath ?: string
133
- ) : Promise < string > {
161
+ async function resolveLocalBuildPathAsync ( {
162
+ platform,
163
+ inputBuildPath,
164
+ nonInteractive,
165
+ } : {
166
+ platform : Platform ;
167
+ inputBuildPath ?: string ;
168
+ nonInteractive : boolean ;
169
+ } ) : Promise < string > {
134
170
const rootDir = process . cwd ( ) ;
135
171
let applicationArchivePatternOrPath : string [ ] = [ ] ;
136
172
@@ -156,7 +192,7 @@ async function resolveLocalBuildPathAsync(
156
192
patternOrPathArray : applicationArchivePatternOrPath ,
157
193
} ) ;
158
194
159
- if ( applicationArchives . length === 0 && ! inputBuildPath ) {
195
+ if ( applicationArchives . length === 0 && ! nonInteractive && ! inputBuildPath ) {
160
196
Log . warn ( `No application archives found at ${ applicationArchivePatternOrPath } .` ) ;
161
197
const { path } = await promptAsync ( {
162
198
type : 'text' ,
@@ -175,6 +211,10 @@ async function resolveLocalBuildPathAsync(
175
211
}
176
212
177
213
if ( applicationArchives . length > 1 ) {
214
+ if ( nonInteractive ) {
215
+ return applicationArchives [ 0 ] ;
216
+ }
217
+
178
218
const { path } = await promptAsync ( {
179
219
type : 'select' ,
180
220
name : 'path' ,
0 commit comments