@@ -37,19 +37,14 @@ const command = new Command({
3737 builder : ( yargs ) => {
3838 yargs
3939 . option ( AWS . keyId . cliFlag , {
40- describe : 'Amazon access key id' ,
41- default : process . env [ AWS . keyId . awsEnvVar ] ,
42- required : true ,
40+ describe : `Amazon access key id [default: ${ AWS . keyId . awsEnvVar } env]` ,
41+
4342 } )
4443 . option ( AWS . secretKey . cliFlag , {
45- describe : 'Amazon access secret key with permissions to the bucket' ,
46- default : process . env [ AWS . secretKey . awsEnvVar ] ,
47- required : true ,
44+ describe : `Amazon access secret key with permissions to the bucket [default: ${ AWS . secretKey . awsEnvVar } env]` ,
4845 } )
4946 . option ( AWS . region . cliFlag , {
50- describe : 'Amazon default region' ,
51- default : process . env [ AWS . region . awsEnvVar ] ,
52- required : true ,
47+ describe : `Amazon default region [default: ${ AWS . region . awsEnvVar } env]` ,
5348 } )
5449 . option ( 'bucket' , {
5550 describe : 'Name of the bucket' ,
@@ -58,6 +53,25 @@ const command = new Command({
5853 return yargs ;
5954 } ,
6055 handler : async ( argv ) => {
56+ const awsKeyId = argv [ AWS . keyId . cliFlag ] || process . env [ AWS . keyId . awsEnvVar ] ;
57+ const awsSecretKey = argv [ AWS . secretKey . cliFlag ] || process . env [ AWS . secretKey . awsEnvVar ] ;
58+ const awsRegion = argv [ AWS . region . cliFlag ] || process . env [ AWS . region . awsEnvVar ] ;
59+ if ( ! awsKeyId ) {
60+ throw new CFError ( {
61+ message : `Either ${ AWS . keyId . awsEnvVar } env, or --${ AWS . keyId . cliFlag } option is required` ,
62+ } ) ;
63+ }
64+ if ( ! awsSecretKey ) {
65+ throw new CFError ( {
66+ message : `Either ${ AWS . secretKey . awsEnvVar } env, or --${ AWS . secretKey . cliFlag } option is required` ,
67+ } ) ;
68+ }
69+ if ( ! awsRegion ) {
70+ throw new CFError ( {
71+ message : `Either ${ AWS . region . awsEnvVar } env, or --${ AWS . region . cliFlag } option is required` ,
72+ } ) ;
73+ }
74+
6175 let bucket = '' ;
6276 if ( argv . bucket . startsWith ( 's3://' ) ) {
6377 ( { bucket } = argv ) ;
@@ -76,9 +90,9 @@ const command = new Command({
7690 data : {
7791 repositoryUrl : bucket ,
7892 variables : {
79- [ AWS . keyId . awsEnvVar ] : argv [ AWS . keyId . cliFlag ] ,
80- [ AWS . secretKey . awsEnvVar ] : argv [ AWS . secretKey . cliFlag ] ,
81- [ AWS . region . awsEnvVar ] : argv [ AWS . region . cliFlag ] ,
93+ [ AWS . keyId . awsEnvVar ] : awsKeyId ,
94+ [ AWS . secretKey . awsEnvVar ] : awsSecretKey ,
95+ [ AWS . region . awsEnvVar ] : awsRegion ,
8296 } ,
8397 } ,
8498 } ,
0 commit comments