@@ -10,7 +10,8 @@ import type { Package, Platform, Version } from 'types';
10
10
import { satisfies } from 'compare-versions' ;
11
11
import chalk from 'chalk' ;
12
12
13
- interface CommandOptions {
13
+ interface VersionCommandOptions {
14
+ appId ?: string ;
14
15
name ?: string ;
15
16
description ?: string ;
16
17
metaInfo ?: string ;
@@ -156,13 +157,13 @@ export const bindVersionToPackages = async ({
156
157
console . log ( t ( 'operationComplete' , { count : pkgs . length } ) ) ;
157
158
} ;
158
159
159
- export const commands = {
160
+ export const versionCommands = {
160
161
publish : async function ( {
161
162
args,
162
163
options,
163
164
} : {
164
165
args : string [ ] ;
165
- options : CommandOptions ;
166
+ options : VersionCommandOptions ;
166
167
} ) {
167
168
const fn = args [ 0 ] ;
168
169
const { name, description, metaInfo } = options ;
@@ -191,26 +192,52 @@ export const commands = {
191
192
saveToLocal ( fn , `${ appId } /ppk/${ id } .ppk` ) ;
192
193
console . log ( t ( 'packageUploadSuccess' , { id } ) ) ;
193
194
194
- const v = await question ( t ( 'updateNativePackageQuestion' ) ) ;
195
- if ( v . toLowerCase ( ) === 'y' ) {
196
- await this . update ( { args : [ ] , options : { versionId : id , platform } } ) ;
195
+ const {
196
+ packageId,
197
+ packageVersion,
198
+ packageVersionRange,
199
+ minPackageVersion,
200
+ maxPackageVersion,
201
+ rollout,
202
+ dryRun,
203
+ } = options ;
204
+
205
+ if (
206
+ packageId ||
207
+ packageVersion ||
208
+ packageVersionRange ||
209
+ minPackageVersion ||
210
+ maxPackageVersion
211
+ ) {
212
+ await this . update ( {
213
+ options : {
214
+ versionId : id ,
215
+ platform,
216
+ packageId,
217
+ packageVersion,
218
+ packageVersionRange,
219
+ minPackageVersion,
220
+ maxPackageVersion,
221
+ rollout,
222
+ dryRun,
223
+ } ,
224
+ } ) ;
225
+ } else {
226
+ const q = await question ( t ( 'updateNativePackageQuestion' ) ) ;
227
+ if ( q . toLowerCase ( ) === 'y' ) {
228
+ await this . update ( { options : { versionId : id , platform } } ) ;
229
+ }
197
230
}
198
231
return versionName ;
199
232
} ,
200
- versions : async ( { options } : { options : CommandOptions } ) => {
233
+ versions : async ( { options } : { options : VersionCommandOptions } ) => {
201
234
const platform = await getPlatform ( options . platform ) ;
202
235
const { appId } = await getSelectedApp ( platform ) ;
203
236
await listVersions ( appId ) ;
204
237
} ,
205
- update : async ( {
206
- args,
207
- options,
208
- } : {
209
- args : string [ ] ;
210
- options : CommandOptions ;
211
- } ) => {
238
+ update : async ( { options } : { options : VersionCommandOptions } ) => {
212
239
const platform = await getPlatform ( options . platform ) ;
213
- const { appId } = await getSelectedApp ( platform ) ;
240
+ const appId = options . appId || ( await getSelectedApp ( platform ) ) . appId ;
214
241
let versionId = options . versionId || ( await chooseVersion ( appId ) ) . id ;
215
242
if ( versionId === 'null' ) {
216
243
versionId = undefined ;
@@ -309,11 +336,9 @@ export const commands = {
309
336
} ) ;
310
337
} ,
311
338
updateVersionInfo : async ( {
312
- args,
313
339
options,
314
340
} : {
315
- args : string [ ] ;
316
- options : CommandOptions ;
341
+ options : VersionCommandOptions ;
317
342
} ) => {
318
343
const platform = await getPlatform ( options . platform ) ;
319
344
const { appId } = await getSelectedApp ( platform ) ;
0 commit comments