1616from typing import List
1717
1818from charon .config import get_config
19- from charon .utils .archive import detect_npm_archive , NpmArchiveType
19+ from charon .utils .archive import detect_npm_archives , NpmArchiveType
2020from charon .pkgs .maven import handle_maven_uploading
2121from charon .pkgs .npm import handle_npm_uploading
2222from charon .cmd .internal import (
2323 _decide_mode , _validate_prod_key ,
24- _get_local_repo , _get_targets ,
24+ _get_local_repos , _get_targets ,
2525 _get_ignore_patterns , _safe_delete
2626)
2727from click import command , option , argument
3535
3636
3737@argument (
38- "repo " ,
38+ "repos " ,
3939 type = str ,
40+ nargs = - 1 # This allows multiple arguments for zip urls
4041)
4142@option (
4243 "--product" ,
146147)
147148@command ()
148149def upload (
149- repo : str ,
150+ repos : List [ str ] ,
150151 product : str ,
151152 version : str ,
152153 targets : List [str ],
@@ -161,9 +162,10 @@ def upload(
161162 dryrun = False ,
162163 sign_result_file = None ,
163164):
164- """Upload all files from a released product REPO to Ronda
165- Service. The REPO points to a product released tarball which
166- is hosted in a remote url or a local path.
165+ """Upload all files from released product REPOs to Ronda
166+ Service. The REPOs point to a product released tarballs which
167+ are hosted in remote urls or local paths.
168+ Notes: It does not support multiple repos for NPM archives
167169 """
168170 tmp_dir = work_dir
169171 try :
@@ -182,8 +184,8 @@ def upload(
182184 logger .error ("No AWS profile specified!" )
183185 sys .exit (1 )
184186
185- archive_path = _get_local_repo ( repo )
186- npm_archive_type = detect_npm_archive ( archive_path )
187+ archive_paths = _get_local_repos ( repos )
188+ archive_types = detect_npm_archives ( archive_paths )
187189 product_key = f"{ product } -{ version } "
188190 manifest_bucket_name = conf .get_manifest_bucket ()
189191 targets_ = _get_targets (targets , conf )
@@ -194,31 +196,18 @@ def upload(
194196 " are set correctly." , targets_
195197 )
196198 sys .exit (1 )
197- if npm_archive_type != NpmArchiveType .NOT_NPM :
198- logger .info ("This is a npm archive" )
199- tmp_dir , succeeded = handle_npm_uploading (
200- archive_path ,
201- product_key ,
202- targets = targets_ ,
203- aws_profile = aws_profile ,
204- dir_ = work_dir ,
205- gen_sign = contain_signature ,
206- cf_enable = conf .is_aws_cf_enable (),
207- key = sign_key ,
208- dry_run = dryrun ,
209- manifest_bucket_name = manifest_bucket_name
210- )
211- if not succeeded :
212- sys .exit (1 )
213- else :
199+
200+ maven_count = archive_types .count (NpmArchiveType .NOT_NPM )
201+ npm_count = len (archive_types ) - maven_count
202+ if maven_count == len (archive_types ):
214203 ignore_patterns_list = None
215204 if ignore_patterns :
216205 ignore_patterns_list = ignore_patterns
217206 else :
218207 ignore_patterns_list = _get_ignore_patterns (conf )
219208 logger .info ("This is a maven archive" )
220209 tmp_dir , succeeded = handle_maven_uploading (
221- archive_path ,
210+ archive_paths ,
222211 product_key ,
223212 ignore_patterns_list ,
224213 root = root_path ,
@@ -235,6 +224,28 @@ def upload(
235224 )
236225 if not succeeded :
237226 sys .exit (1 )
227+ elif npm_count == len (archive_types ) and len (archive_types ) == 1 :
228+ logger .info ("This is a npm archive" )
229+ tmp_dir , succeeded = handle_npm_uploading (
230+ archive_paths [0 ],
231+ product_key ,
232+ targets = targets_ ,
233+ aws_profile = aws_profile ,
234+ dir_ = work_dir ,
235+ gen_sign = contain_signature ,
236+ cf_enable = conf .is_aws_cf_enable (),
237+ key = sign_key ,
238+ dry_run = dryrun ,
239+ manifest_bucket_name = manifest_bucket_name
240+ )
241+ if not succeeded :
242+ sys .exit (1 )
243+ elif npm_count == len (archive_types ) and len (archive_types ) > 1 :
244+ logger .error ("Doesn't support multiple upload for npm" )
245+ sys .exit (1 )
246+ else :
247+ logger .error ("Upload types are not consistent" )
248+ sys .exit (1 )
238249 except Exception :
239250 print (traceback .format_exc ())
240251 sys .exit (2 ) # distinguish between exception and bad config or bad state
0 commit comments