Skip to content

Commit fc9abcf

Browse files
committed
error for deploy and secret
1 parent 0c7b346 commit fc9abcf

File tree

5 files changed

+1026
-40
lines changed

5 files changed

+1026
-40
lines changed

packages/wrangler/src/__tests__/deploy.test.ts

+10
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,16 @@ describe("deploy", () => {
377377
`);
378378
});
379379

380+
it("should error helpfully if pages_build_output_dir is set in wrangler.toml", async () => {
381+
writeWranglerToml({
382+
pages_build_output_dir: "public",
383+
name: "test-name",
384+
});
385+
await expect(
386+
runWrangler("deploy")
387+
).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: This command is for Workers, for Pages please run \`wrangler pages deploy\`.]`);
388+
});
389+
380390
describe("output additional script information", () => {
381391
it("for first party workers, it should print worker information at log level", async () => {
382392
setIsTTY(false);

packages/wrangler/src/__tests__/secret.test.ts

+64
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,22 @@ describe("wrangler secret", () => {
8383
);
8484
}
8585

86+
it("should error helpfully if pages_build_output_dir is set", async () => {
87+
fs.writeFileSync(
88+
"wrangler.toml",
89+
TOML.stringify({
90+
pages_build_output_dir: "public",
91+
name: "script-name",
92+
}),
93+
"utf-8"
94+
);
95+
await expect(
96+
runWrangler("secret put secret-name")
97+
).rejects.toThrowErrorMatchingInlineSnapshot(
98+
`[Error: This command is for Workers, for Pages please run \`wrangler pages secret put\`.]`
99+
);
100+
});
101+
86102
describe("interactive", () => {
87103
beforeEach(() => {
88104
setIsTTY(true);
@@ -389,6 +405,22 @@ describe("wrangler secret", () => {
389405
);
390406
}
391407

408+
it("should error helpfully if pages_build_output_dir is set", async () => {
409+
fs.writeFileSync(
410+
"wrangler.toml",
411+
TOML.stringify({
412+
pages_build_output_dir: "public",
413+
name: "script-name",
414+
}),
415+
"utf-8"
416+
);
417+
await expect(
418+
runWrangler("secret delete secret-name")
419+
).rejects.toThrowErrorMatchingInlineSnapshot(
420+
`[Error: This command is for Workers, for Pages please run \`wrangler pages secret delete\`.]`
421+
);
422+
});
423+
392424
it("should delete a secret", async () => {
393425
mockDeleteRequest({ scriptName: "script-name", secretName: "the-key" });
394426
mockConfirm({
@@ -499,6 +531,22 @@ describe("wrangler secret", () => {
499531
);
500532
}
501533

534+
it("should error helpfully if pages_build_output_dir is set", async () => {
535+
fs.writeFileSync(
536+
"wrangler.toml",
537+
TOML.stringify({
538+
pages_build_output_dir: "public",
539+
name: "script-name",
540+
}),
541+
"utf-8"
542+
);
543+
await expect(
544+
runWrangler("secret list")
545+
).rejects.toThrowErrorMatchingInlineSnapshot(
546+
`[Error: This command is for Workers, for Pages please run \`wrangler pages secret list\`.]`
547+
);
548+
});
549+
502550
it("should list secrets", async () => {
503551
mockListRequest({ scriptName: "script-name" });
504552
await runWrangler("secret list --name script-name");
@@ -565,6 +613,22 @@ describe("wrangler secret", () => {
565613
});
566614

567615
describe("bulk", () => {
616+
it("should error helpfully if pages_build_output_dir is set", async () => {
617+
fs.writeFileSync(
618+
"wrangler.toml",
619+
TOML.stringify({
620+
pages_build_output_dir: "public",
621+
name: "script-name",
622+
}),
623+
"utf-8"
624+
);
625+
await expect(
626+
runWrangler("secret bulk")
627+
).rejects.toThrowErrorMatchingInlineSnapshot(
628+
`[Error: This command is for Workers, for Pages please run \`wrangler pages secret bulk\`.]`
629+
);
630+
});
631+
568632
it("should fail secret bulk w/ no pipe or JSON input", async () => {
569633
vi.spyOn(readline, "createInterface").mockImplementation(
570634
() => null as unknown as Interface

packages/wrangler/src/deploy/index.ts

+6
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,12 @@ export async function deployHandler(args: DeployArgs) {
254254
args.config || (args.script && findWranglerToml(path.dirname(args.script)));
255255
const projectRoot = configPath && path.dirname(configPath);
256256
const config = readConfig(configPath, args);
257+
if (config.pages_build_output_dir) {
258+
throw new UserError(
259+
"This command is for Workers, for Pages please run `wrangler pages deploy`."
260+
);
261+
}
262+
257263
const entry = await getEntry(args, config, "deploy");
258264

259265
if (args.public) {

packages/wrangler/src/secret/index.ts

+20
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ export const secret = (secretYargs: CommonYargsArgv) => {
144144
async (args) => {
145145
await printWranglerBanner();
146146
const config = readConfig(args.config, args);
147+
if (config.pages_build_output_dir) {
148+
throw new UserError(
149+
"This command is for Workers, for Pages please run `wrangler pages secret put`."
150+
);
151+
}
147152

148153
const scriptName = getLegacyScriptName(args, config);
149154
if (!scriptName) {
@@ -243,6 +248,11 @@ export const secret = (secretYargs: CommonYargsArgv) => {
243248
},
244249
async (args) => {
245250
const config = readConfig(args.config, args);
251+
if (config.pages_build_output_dir) {
252+
throw new UserError(
253+
"This command is for Workers, for Pages please run `wrangler pages secret delete`."
254+
);
255+
}
246256

247257
const scriptName = getLegacyScriptName(args, config);
248258
if (!scriptName) {
@@ -299,6 +309,11 @@ export const secret = (secretYargs: CommonYargsArgv) => {
299309
},
300310
async (args) => {
301311
const config = readConfig(args.config, args);
312+
if (config.pages_build_output_dir) {
313+
throw new UserError(
314+
"This command is for Workers, for Pages please run `wrangler pages secret list`."
315+
);
316+
}
302317

303318
const scriptName = getLegacyScriptName(args, config);
304319
if (!scriptName) {
@@ -360,6 +375,11 @@ type SecretBulkArgs = StrictYargsOptionsToInterface<typeof secretBulkOptions>;
360375
export const secretBulkHandler = async (secretBulkArgs: SecretBulkArgs) => {
361376
await printWranglerBanner();
362377
const config = readConfig(secretBulkArgs.config, secretBulkArgs);
378+
if (config.pages_build_output_dir) {
379+
throw new UserError(
380+
"This command is for Workers, for Pages please run `wrangler pages secret bulk`."
381+
);
382+
}
363383

364384
if (secretBulkArgs._.includes("secret:bulk")) {
365385
logger.warn(

0 commit comments

Comments
 (0)