@@ -18,6 +18,8 @@ type Flags = {
1818 traits ?: string [ ] ;
1919 name ?: string ;
2020 json ?: boolean ;
21+ all ?: boolean ;
22+ allButLatest ?: boolean ;
2123} ;
2224
2325async function remoteCache ( {
@@ -55,14 +57,26 @@ async function remoteCache({
5557
5658 switch ( action ) {
5759 case 'list' : {
58- const artifacts = await remoteBuildCache . list ( { artifactName } ) ;
59- const artifact = artifacts [ 0 ] ;
60- if ( artifact ) {
60+ const artifacts = await remoteBuildCache . list ( {
61+ artifactName,
62+ limit : args . all ? undefined : 1 ,
63+ } ) ;
64+ if ( artifacts . length > 0 && ! args . all ) {
65+ const artifact = artifacts [ 0 ] ;
6166 if ( isJsonOutput ) {
6267 console . log ( JSON . stringify ( artifact , null , 2 ) ) ;
6368 } else {
6469 logger . log ( `- name: ${ artifact . name }
65- - url: ${ artifact . url } ` ) ;
70+ - url: ${ artifact . url } ` ) ;
71+ }
72+ } else if ( artifacts . length > 0 && args . all ) {
73+ if ( isJsonOutput ) {
74+ console . log ( JSON . stringify ( artifacts , null , 2 ) ) ;
75+ } else {
76+ artifacts . forEach ( ( artifact ) => {
77+ logger . log ( `- name: ${ artifact . name }
78+ - url: ${ artifact . url } ` ) ;
79+ } ) ;
6680 }
6781 }
6882 break ;
@@ -117,7 +131,11 @@ async function remoteCache({
117131 break ;
118132 }
119133 case 'delete' : {
120- const deletedArtifacts = await remoteBuildCache . delete ( { artifactName } ) ;
134+ const deletedArtifacts = await remoteBuildCache . delete ( {
135+ artifactName,
136+ limit : args . all || args . allButLatest ? undefined : 1 ,
137+ skipLatest : args . allButLatest ,
138+ } ) ;
121139 if ( isJsonOutput ) {
122140 console . log ( JSON . stringify ( deletedArtifacts , null , 2 ) ) ;
123141 } else {
@@ -144,6 +162,10 @@ function validateArgs(args: Flags, action: string) {
144162 'Action is required. Available actions: list, list-all, download, upload, delete'
145163 ) ;
146164 }
165+ if ( action === 'list-all' ) {
166+ // return early as we don't need to validate name or platform to list all artifacts
167+ return ;
168+ }
147169 if ( args . name && ( args . platform || args . traits ) ) {
148170 throw new RnefError (
149171 'Cannot use "--name" together with "--platform" or "--traits". Use either name or platform with traits'
@@ -193,6 +215,16 @@ export const remoteCachePlugin =
193215 name : '--name <string>' ,
194216 description : 'Full artifact name' ,
195217 } ,
218+ {
219+ name : '--all' ,
220+ description :
221+ 'List or delete all matching artifacts. Affects "list" and "delete" actions only' ,
222+ } ,
223+ {
224+ name : '--all-but-latest' ,
225+ description :
226+ 'Delete all but the latest matching artifact. Affects "delete" action only' ,
227+ } ,
196228 {
197229 name : '-p, --platform <string>' ,
198230 description : 'Select platform, e.g. ios or android' ,
0 commit comments