@@ -37,19 +37,14 @@ const command = new Command({
37
37
builder : ( yargs ) => {
38
38
yargs
39
39
. 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
+
43
42
} )
44
43
. 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]` ,
48
45
} )
49
46
. 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]` ,
53
48
} )
54
49
. option ( 'bucket' , {
55
50
describe : 'Name of the bucket' ,
@@ -58,6 +53,25 @@ const command = new Command({
58
53
return yargs ;
59
54
} ,
60
55
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
+
61
75
let bucket = '' ;
62
76
if ( argv . bucket . startsWith ( 's3://' ) ) {
63
77
( { bucket } = argv ) ;
@@ -76,9 +90,9 @@ const command = new Command({
76
90
data : {
77
91
repositoryUrl : bucket ,
78
92
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 ,
82
96
} ,
83
97
} ,
84
98
} ,
0 commit comments