Skip to content

Commit 078e979

Browse files
committed
rename internal var to wranglerConfigPath
1 parent afd7dc2 commit 078e979

File tree

5 files changed

+27
-18
lines changed

5 files changed

+27
-18
lines changed

packages/cloudflare/src/cli/commands/deploy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export async function deployCommand(args: WithWranglerArgs<{ cacheChunkSize: num
2828
const wranglerConfig = readWranglerConfig(args);
2929

3030
const envVars = await getEnvFromPlatformProxy({
31-
configPath: args.configPath,
31+
configPath: args.wranglerConfigPath,
3232
environment: args.env,
3333
});
3434

@@ -37,7 +37,7 @@ export async function deployCommand(args: WithWranglerArgs<{ cacheChunkSize: num
3737
await populateCache(options, config, wranglerConfig, {
3838
target: "remote",
3939
environment: args.env,
40-
configPath: args.configPath,
40+
wranglerConfigPath: args.wranglerConfigPath,
4141
cacheChunkSize: args.cacheChunkSize,
4242
});
4343

packages/cloudflare/src/cli/commands/populate-cache.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export function getCacheAssets(opts: BuildOptions): CacheAsset[] {
107107
type PopulateCacheOptions = {
108108
target: WranglerTarget;
109109
environment?: string;
110-
configPath?: string;
110+
wranglerConfigPath?: string;
111111
cacheChunkSize?: number;
112112
};
113113

@@ -148,7 +148,7 @@ async function populateR2IncrementalCache(
148148
],
149149
{
150150
target: populateCacheOptions.target,
151-
configPath: populateCacheOptions.configPath,
151+
configPath: populateCacheOptions.wranglerConfigPath,
152152
// R2 does not support the environment flag and results in the following error:
153153
// Incorrect type for the 'cacheExpiry' field on 'HttpMetadata': the provided value is not of type 'date'.
154154
environment: undefined,
@@ -200,7 +200,7 @@ async function populateKVIncrementalCache(
200200
runWrangler(options, ["kv bulk put", quoteShellMeta(chunkPath), `--binding ${KV_CACHE_BINDING_NAME}`], {
201201
target: populateCacheOptions.target,
202202
environment: populateCacheOptions.environment,
203-
configPath: populateCacheOptions.configPath,
203+
configPath: populateCacheOptions.wranglerConfigPath,
204204
logging: "error",
205205
});
206206

@@ -232,7 +232,7 @@ function populateD1TagCache(
232232
{
233233
target: populateCacheOptions.target,
234234
environment: populateCacheOptions.environment,
235-
configPath: populateCacheOptions.configPath,
235+
configPath: populateCacheOptions.wranglerConfigPath,
236236
logging: "error",
237237
}
238238
);
@@ -313,7 +313,7 @@ async function populateCacheCommand(
313313
await populateCache(options, config, wranglerConfig, {
314314
target,
315315
environment: args.env,
316-
configPath: args.configPath,
316+
wranglerConfigPath: args.wranglerConfigPath,
317317
cacheChunkSize: args.cacheChunkSize,
318318
});
319319
}

packages/cloudflare/src/cli/commands/preview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export async function previewCommand(args: WithWranglerArgs<{ cacheChunkSize: nu
2727
await populateCache(options, config, wranglerConfig, {
2828
target: "local",
2929
environment: args.env,
30-
configPath: args.configPath,
30+
wranglerConfigPath: args.wranglerConfigPath,
3131
cacheChunkSize: args.cacheChunkSize,
3232
});
3333

packages/cloudflare/src/cli/commands/upload.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export async function uploadCommand(args: WithWranglerArgs<{ cacheChunkSize: num
2828
const wranglerConfig = readWranglerConfig(args);
2929

3030
const envVars = await getEnvFromPlatformProxy({
31-
configPath: args.configPath,
31+
configPath: args.wranglerConfigPath,
3232
environment: args.env,
3333
});
3434

@@ -37,7 +37,7 @@ export async function uploadCommand(args: WithWranglerArgs<{ cacheChunkSize: num
3737
await populateCache(options, config, wranglerConfig, {
3838
target: "remote",
3939
environment: args.env,
40-
configPath: args.configPath,
40+
wranglerConfigPath: args.wranglerConfigPath,
4141
cacheChunkSize: args.cacheChunkSize,
4242
});
4343

packages/cloudflare/src/cli/commands/utils.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import { createOpenNextConfigIfNotExistent, ensureCloudflareConfig } from "../bu
1515
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[];
18-
configPath: string | undefined;
19-
config: string | undefined;
18+
wranglerConfigPath: string | undefined;
2019
env: string | undefined;
2120
};
2221

@@ -90,7 +89,7 @@ export function getNormalizedOptions(config: OpenNextConfig, buildDir = nextAppD
9089
* @returns Wrangler config.
9190
*/
9291
export function readWranglerConfig(args: WithWranglerArgs) {
93-
return unstable_readConfig({ env: args.env, config: args.configPath });
92+
return unstable_readConfig({ env: args.env, config: args.wranglerConfigPath });
9493
}
9594

9695
/**
@@ -115,12 +114,18 @@ export function withWranglerOptions<T extends yargs.Argv>(args: T) {
115114
});
116115
}
117116

117+
type WranglerInputArgs = {
118+
configPath: string | undefined;
119+
config: string | undefined;
120+
env: string | undefined;
121+
};
122+
118123
/**
119124
*
120125
* @param args
121126
* @returns An array of arguments that can be given to wrangler commands, including the `--config` and `--env` args.
122127
*/
123-
function getWranglerArgs(args: Omit<WithWranglerArgs<{ _: (string | number)[] }>, "wranglerArgs">): string[] {
128+
function getWranglerArgs(args: WranglerInputArgs & { _: (string | number)[] }): string[] {
124129
if (args.configPath) {
125130
logger.warn("The `--configPath` flag is deprecated, please use `--config` instead.");
126131

@@ -146,8 +151,12 @@ function getWranglerArgs(args: Omit<WithWranglerArgs<{ _: (string | number)[] }>
146151
* @param args
147152
* @returns The inputted args, and an array of arguments that can be given to wrangler commands, including the `--config` and `--env` args.
148153
*/
149-
export function withWranglerPassthroughArgs<
150-
T extends yargs.ArgumentsCamelCase<Omit<WithWranglerArgs, "wranglerArgs">>,
151-
>(args: T) {
152-
return { ...args, wranglerArgs: getWranglerArgs(args) };
154+
export function withWranglerPassthroughArgs<T extends yargs.ArgumentsCamelCase<WranglerInputArgs>>(
155+
args: T
156+
): WithWranglerArgs<T> {
157+
return {
158+
...args,
159+
wranglerConfigPath: args.config ?? args.configPath,
160+
wranglerArgs: getWranglerArgs(args),
161+
};
153162
}

0 commit comments

Comments
 (0)