@@ -16,6 +16,7 @@ export type WithWranglerArgs<T = unknown> = T & {
1616 // Array of arguments that can be given to wrangler commands, including the `--config` and `--env` args.
1717 wranglerArgs : string [ ] ;
1818 configPath : string | undefined ;
19+ config : string | undefined ;
1920 env : string | undefined ;
2021} ;
2122
@@ -97,12 +98,17 @@ export function readWranglerConfig(args: WithWranglerArgs) {
9798 */
9899export function withWranglerOptions < T extends yargs . Argv > ( args : T ) {
99100 return args
100- . options ( "configPath ", {
101+ . option ( "config ", {
101102 type : "string" ,
102- alias : [ "config" , "c" ] ,
103+ alias : "c" ,
103104 desc : "Path to Wrangler configuration file" ,
104105 } )
105- . options ( "env" , {
106+ . option ( "configPath" , {
107+ type : "string" ,
108+ desc : "Path to Wrangler configuration file" ,
109+ deprecated : true ,
110+ } )
111+ . option ( "env" , {
106112 type : "string" ,
107113 alias : "e" ,
108114 desc : "Wrangler environment to use for operations" ,
@@ -114,13 +120,21 @@ export function withWranglerOptions<T extends yargs.Argv>(args: T) {
114120 * @param args
115121 * @returns An array of arguments that can be given to wrangler commands, including the `--config` and `--env` args.
116122 */
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+
122135 return [
123136 ...( args . configPath ? [ "--config" , args . configPath ] : [ ] ) ,
137+ ...( args . config ? [ "--config" , args . config ] : [ ] ) ,
124138 ...( args . env ? [ "--env" , args . env ] : [ ] ) ,
125139 // Note: the first args in `_` will be the commands.
126140 ...args . _ . slice ( args . _ [ 0 ] === "populateCache" ? 2 : 1 ) . map ( ( a ) => `${ a } ` ) ,
@@ -133,10 +147,7 @@ function getWranglerArgs(args: {
133147 * @returns The inputted args, and an array of arguments that can be given to wrangler commands, including the `--config` and `--env` args.
134148 */
135149export function withWranglerPassthroughArgs <
136- T extends yargs . ArgumentsCamelCase < {
137- configPath : string | undefined ;
138- env : string | undefined ;
139- } > ,
150+ T extends yargs . ArgumentsCamelCase < Omit < WithWranglerArgs , "wranglerArgs" > > ,
140151> ( args : T ) {
141152 return { ...args , wranglerArgs : getWranglerArgs ( args ) } ;
142153}
0 commit comments