@@ -16,6 +16,7 @@ export type WithWranglerArgs<T = unknown> = T & {
16
16
// Array of arguments that can be given to wrangler commands, including the `--config` and `--env` args.
17
17
wranglerArgs : string [ ] ;
18
18
configPath : string | undefined ;
19
+ config : string | undefined ;
19
20
env : string | undefined ;
20
21
} ;
21
22
@@ -97,12 +98,17 @@ export function readWranglerConfig(args: WithWranglerArgs) {
97
98
*/
98
99
export function withWranglerOptions < T extends yargs . Argv > ( args : T ) {
99
100
return args
100
- . options ( "configPath ", {
101
+ . option ( "config ", {
101
102
type : "string" ,
102
- alias : [ "config" , "c" ] ,
103
+ alias : "c" ,
103
104
desc : "Path to Wrangler configuration file" ,
104
105
} )
105
- . options ( "env" , {
106
+ . option ( "configPath" , {
107
+ type : "string" ,
108
+ desc : "Path to Wrangler configuration file" ,
109
+ deprecated : true ,
110
+ } )
111
+ . option ( "env" , {
106
112
type : "string" ,
107
113
alias : "e" ,
108
114
desc : "Wrangler environment to use for operations" ,
@@ -114,13 +120,21 @@ export function withWranglerOptions<T extends yargs.Argv>(args: T) {
114
120
* @param args
115
121
* @returns An array of arguments that can be given to wrangler commands, including the `--config` and `--env` args.
116
122
*/
117
- function getWranglerArgs ( args : {
118
- _ : ( string | number ) [ ] ;
119
- configPath : string | undefined ;
120
- env : string | undefined ;
121
- } ) : string [ ] {
123
+ function getWranglerArgs ( args : Omit < WithWranglerArgs < { _ : ( string | number ) [ ] } > , "wranglerArgs" > ) : string [ ] {
124
+ if ( args . configPath ) {
125
+ logger . warn ( "The `--configPath` flag is deprecated, please use `--config` instead." ) ;
126
+
127
+ if ( args . config ) {
128
+ logger . error (
129
+ "Multiple config flags found. Please use the `--config` flag for your Wrangler config path."
130
+ ) ;
131
+ process . exit ( 1 ) ;
132
+ }
133
+ }
134
+
122
135
return [
123
136
...( args . configPath ? [ "--config" , args . configPath ] : [ ] ) ,
137
+ ...( args . config ? [ "--config" , args . config ] : [ ] ) ,
124
138
...( args . env ? [ "--env" , args . env ] : [ ] ) ,
125
139
// Note: the first args in `_` will be the commands.
126
140
...args . _ . slice ( args . _ [ 0 ] === "populateCache" ? 2 : 1 ) . map ( ( a ) => `${ a } ` ) ,
@@ -133,10 +147,7 @@ function getWranglerArgs(args: {
133
147
* @returns The inputted args, and an array of arguments that can be given to wrangler commands, including the `--config` and `--env` args.
134
148
*/
135
149
export function withWranglerPassthroughArgs <
136
- T extends yargs . ArgumentsCamelCase < {
137
- configPath : string | undefined ;
138
- env : string | undefined ;
139
- } > ,
150
+ T extends yargs . ArgumentsCamelCase < Omit < WithWranglerArgs , "wranglerArgs" > > ,
140
151
> ( args : T ) {
141
152
return { ...args , wranglerArgs : getWranglerArgs ( args ) } ;
142
153
}
0 commit comments