@@ -10,7 +10,8 @@ import type { Package, Platform, Version } from 'types';
1010import { satisfies } from 'compare-versions' ;
1111import chalk from 'chalk' ;
1212
13- interface CommandOptions {
13+ interface VersionCommandOptions {
14+ appId ?: string ;
1415 name ?: string ;
1516 description ?: string ;
1617 metaInfo ?: string ;
@@ -156,13 +157,13 @@ export const bindVersionToPackages = async ({
156157 console . log ( t ( 'operationComplete' , { count : pkgs . length } ) ) ;
157158} ;
158159
159- export const commands = {
160+ export const versionCommands = {
160161 publish : async function ( {
161162 args,
162163 options,
163164 } : {
164165 args : string [ ] ;
165- options : CommandOptions ;
166+ options : VersionCommandOptions ;
166167 } ) {
167168 const fn = args [ 0 ] ;
168169 const { name, description, metaInfo } = options ;
@@ -191,26 +192,52 @@ export const commands = {
191192 saveToLocal ( fn , `${ appId } /ppk/${ id } .ppk` ) ;
192193 console . log ( t ( 'packageUploadSuccess' , { id } ) ) ;
193194
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+ }
197230 }
198231 return versionName ;
199232 } ,
200- versions : async ( { options } : { options : CommandOptions } ) => {
233+ versions : async ( { options } : { options : VersionCommandOptions } ) => {
201234 const platform = await getPlatform ( options . platform ) ;
202235 const { appId } = await getSelectedApp ( platform ) ;
203236 await listVersions ( appId ) ;
204237 } ,
205- update : async ( {
206- args,
207- options,
208- } : {
209- args : string [ ] ;
210- options : CommandOptions ;
211- } ) => {
238+ update : async ( { options } : { options : VersionCommandOptions } ) => {
212239 const platform = await getPlatform ( options . platform ) ;
213- const { appId } = await getSelectedApp ( platform ) ;
240+ const appId = options . appId || ( await getSelectedApp ( platform ) ) . appId ;
214241 let versionId = options . versionId || ( await chooseVersion ( appId ) ) . id ;
215242 if ( versionId === 'null' ) {
216243 versionId = undefined ;
@@ -309,11 +336,9 @@ export const commands = {
309336 } ) ;
310337 } ,
311338 updateVersionInfo : async ( {
312- args,
313339 options,
314340 } : {
315- args : string [ ] ;
316- options : CommandOptions ;
341+ options : VersionCommandOptions ;
317342 } ) => {
318343 const platform = await getPlatform ( options . platform ) ;
319344 const { appId } = await getSelectedApp ( platform ) ;
0 commit comments