Skip to content

Commit

Permalink
fix: error and exit if init --type is used
Browse files Browse the repository at this point in the history
  • Loading branch information
petebacondarwin committed Dec 17, 2021
1 parent 3c0b7eb commit c716abc
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .changeset/forty-cooks-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"wrangler": patch
---

Error and exit if the `--type` option is used for the `init` command.

The `--type` option is no longer needed, nor supported.

The type of a project is implicitly javascript, even if it includes a wasm (e.g. built from rust).

Projects that would have had the `webpack` type need to be configured separately to have a custom build.
29 changes: 29 additions & 0 deletions packages/wrangler/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,35 @@ describe("wrangler", () => {
const { stderr } = await w("init");
expect(stderr).toContain("wrangler.toml file already exists!");
});

it("should error if `--type` is used", async () => {
const noValue = await w("init --type");
expect(noValue.stderr).toMatchInlineSnapshot(
`"The --type option is no longer supported."`
);
});

it("should error if `--type javascript` is used", async () => {
const javascriptValue = await w("init --type javascript");
expect(javascriptValue.stderr).toMatchInlineSnapshot(
`"The --type option is no longer supported."`
);
});

it("should error if `--type rust` is used", async () => {
const rustValue = await w("init --type rust");
expect(rustValue.stderr).toMatchInlineSnapshot(
`"The --type option is no longer supported."`
);
});

it("should error if `--type webpack` is used", async () => {
const webpackValue = await w("init --type webpack");
expect(webpackValue.stderr).toMatchInlineSnapshot(`
"The --type option is no longer supported.
If you wish to use webpack then you will need to create a custom build."
`);
});
});

describe("kv:namespace", () => {
Expand Down
13 changes: 12 additions & 1 deletion packages/wrangler/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,18 @@ export async function main(argv: string[]): Promise<void> {
type: "string",
});
},
async () => {
async (args) => {
if ("type" in args) {
let message = "The --type option is no longer supported.";
if (args.type === "webpack") {
message +=
"\nIf you wish to use webpack then you will need to create a custom build.";
// TODO: Add a link to docs
}
console.error(message);
return;
}

const destination = path.join(process.cwd(), "wrangler.toml");
if (fs.existsSync(destination)) {
console.error(
Expand Down

0 comments on commit c716abc

Please sign in to comment.