Skip to content

Commit

Permalink
throw error if config is specified in pages (#1278)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximo-Guk authored Jun 23, 2022
1 parent b824226 commit 8201733
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/rotten-radios-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

Throw error if user attempts to use config with pages
14 changes: 13 additions & 1 deletion packages/wrangler/src/__tests__/pages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ describe("pages", () => {
directory The directory of static files to upload [string]
Flags:
-c, --config Path to .toml configuration file [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down Expand Up @@ -969,6 +968,19 @@ describe("pages", () => {

expect(std.err).toMatchInlineSnapshot(`""`);
});

it("should throw an error if user attempts to use config with pages", async () => {
await expect(
runWrangler("pages dev --config foo.toml")
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Pages does not support wrangler.toml"`
);
await expect(
runWrangler("pages publish --config foo.toml")
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Pages does not support wrangler.toml"`
);
});
});

describe("project upload", () => {
Expand Down
13 changes: 11 additions & 2 deletions packages/wrangler/src/pages/dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ export function Options(yargs: Argv): Argv<PagesDevArgs> {
type: "boolean",
hidden: true,
},
config: {
describe: "Pages does not support wrangler.toml",
type: "string",
hidden: true,
},
// // TODO: Miniflare user options
})
.epilogue(pagesBetaWarning);
Expand All @@ -108,14 +113,18 @@ export const Handler = async ({
do: durableObjects = [],
"live-reload": liveReload,
"node-compat": nodeCompat,
config: config,
_: [_pages, _dev, ...remaining],
}: ArgumentsCamelCase<PagesDevArgs>) => {
// Beta message for `wrangler pages <commands>` usage
logger.log(pagesBetaWarning);

if (!local) {
logger.error("Only local mode is supported at the moment.");
return;
throw new FatalError("Only local mode is supported at the moment.", 1);
}

if (config) {
throw new FatalError("Pages does not support wrangler.toml", 1);
}

const functionsDirectory = "./functions";
Expand Down
10 changes: 10 additions & 0 deletions packages/wrangler/src/pages/publish.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ export function Options(yargs: Argv): Argv<PublishArgs> {
description:
"Whether or not the workspace should be considered dirty for this deployment",
},
config: {
describe: "Pages does not support wrangler.toml",
type: "string",
hidden: true,
},
})
.epilogue(pagesBetaWarning);
}
Expand All @@ -70,7 +75,12 @@ export const Handler = async ({
commitHash,
commitMessage,
commitDirty,
config: wranglerConfig,
}: ArgumentsCamelCase<PublishArgs>) => {
if (wranglerConfig) {
throw new FatalError("Pages does not support wrangler.toml", 1);
}

if (!directory) {
throw new FatalError("Must specify a directory.", 1);
}
Expand Down

0 comments on commit 8201733

Please sign in to comment.