Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polish: s/DEPRECATION/Deprecation #888

Merged
merged 1 commit into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/tiny-beds-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"wrangler": patch
---

polish: s/DEPRECATION/Deprecation

This removes the scary uppercase from DEPRECATION warnings. It also moves the service environment usage warning into `diagnostics` instead of logging it directly.
61 changes: 42 additions & 19 deletions packages/wrangler/src/__tests__/configuration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ describe("normalizeAndValidateConfig()", () => {
expect(normalizeSlashes(diagnostics.renderWarnings()))
.toMatchInlineSnapshot(`
"Processing wrangler configuration:
- DEPRECATION: \\"site.entry-point\\":
- Deprecation: \\"site.entry-point\\":
Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
\`\`\`
main = \\"my-site/index.js\\"
Expand Down Expand Up @@ -281,7 +281,7 @@ describe("normalizeAndValidateConfig()", () => {
expect(normalizeSlashes(diagnostics.renderWarnings()))
.toMatchInlineSnapshot(`
"Processing wrangler configuration:
- DEPRECATION: \\"site.entry-point\\":
- Deprecation: \\"site.entry-point\\":
Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
\`\`\`
main = \\"workers-site/index.js\\"
Expand Down Expand Up @@ -324,7 +324,7 @@ describe("normalizeAndValidateConfig()", () => {
expect(normalizeSlashes(diagnostics.renderWarnings()))
.toMatchInlineSnapshot(`
"Processing wrangler configuration:
- DEPRECATION: \\"site.entry-point\\":
- Deprecation: \\"site.entry-point\\":
Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
\`\`\`
main = \\"111/index.js\\"
Expand Down Expand Up @@ -358,7 +358,7 @@ describe("normalizeAndValidateConfig()", () => {
expect(normalizeSlashes(diagnostics.renderWarnings()))
.toMatchInlineSnapshot(`
"Processing wrangler configuration:
- DEPRECATION: \\"site.entry-point\\":
- Deprecation: \\"site.entry-point\\":
Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
\`\`\`
main = \\"some/other/script.js\\"
Expand Down Expand Up @@ -571,9 +571,9 @@ describe("normalizeAndValidateConfig()", () => {
expect(diagnostics.hasWarnings()).toBe(true);
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
"Processing wrangler configuration:
- DEPRECATION: \\"type\\":
- Deprecation: \\"type\\":
DO NOT USE THIS. Most common features now work out of the box with wrangler, including modules, jsx, typescript, etc. If you need anything more, use a custom build.
- DEPRECATION: \\"webpack_config\\":
- Deprecation: \\"webpack_config\\":
DO NOT USE THIS. Most common features now work out of the box with wrangler, including modules, jsx, typescript, etc. If you need anything more, use a custom build."
`);
});
Expand Down Expand Up @@ -869,17 +869,17 @@ describe("normalizeAndValidateConfig()", () => {
expect(normalizePath(diagnostics.renderWarnings()))
.toMatchInlineSnapshot(`
"Processing project/wrangler.toml configuration:
- DEPRECATION: \\"build.upload.format\\":
- Deprecation: \\"build.upload.format\\":
The format is inferred automatically from the code.
- DEPRECATION: \\"build.upload.main\\":
- Deprecation: \\"build.upload.main\\":
Delete the \`build.upload.main\` and \`build.upload.dir\` fields.
Then add the top level \`main\` field to your configuration file:
\`\`\`
main = \\"src/index.ts\\"
\`\`\`
- DEPRECATION: \\"build.upload.dir\\":
- Deprecation: \\"build.upload.dir\\":
Use the top level \\"main\\" field or a command-line argument to specify the entry-point for the Worker.
- DEPRECATION: The \`build.upload.rules\` config field is no longer used, the rules should be specified via the \`rules\` config field. Delete the \`build.upload\` field from the configuration file, and add this:
- Deprecation: The \`build.upload.rules\` config field is no longer used, the rules should be specified via the \`rules\` config field. Delete the \`build.upload\` field from the configuration file, and add this:
\`\`\`
[[rules]]
type = \\"Text\\"
Expand Down Expand Up @@ -1619,9 +1619,9 @@ describe("normalizeAndValidateConfig()", () => {
expect(diagnostics.hasWarnings()).toBe(true);
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
"Processing wrangler configuration:
- DEPRECATION: \\"zone_id\\":
- Deprecation: \\"zone_id\\":
This is unnecessary since we can deduce this from routes directly.
- DEPRECATION: \\"experimental_services\\":
- Deprecation: \\"experimental_services\\":
The \\"experimental_services\\" field is no longer supported. Instead, use [[unsafe.bindings]] to enable experimental features. Add this to your wrangler.toml:
\`\`\`
[[unsafe.bindings]]
Expand Down Expand Up @@ -1815,7 +1815,11 @@ describe("normalizeAndValidateConfig()", () => {

expect(config.name).toEqual("mock-name");
expect(diagnostics.hasErrors()).toBe(false);
expect(diagnostics.hasWarnings()).toBe(false);
expect(diagnostics.hasWarnings()).toBe(true);
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
"Processing wrangler configuration:
- Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
`);
});

it("should error if named environment contains a `name` field, even if there is no top-level name", () => {
Expand All @@ -1835,14 +1839,19 @@ describe("normalizeAndValidateConfig()", () => {
);

expect(config.name).toBeUndefined();
expect(diagnostics.hasWarnings()).toBe(true);
expect(diagnostics.hasErrors()).toBe(true);
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
"Processing wrangler configuration:
- Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
`);
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
"Processing wrangler configuration:

- \\"env.DEV\\" environment configuration
- The \\"name\\" field is not allowed in named service environments.
Please remove the field from this environment."
`);
expect(diagnostics.hasWarnings()).toBe(false);
});

it("should error if top-level config and a named environment both contain a `name` field", () => {
Expand All @@ -1863,14 +1872,19 @@ describe("normalizeAndValidateConfig()", () => {
);

expect(config.name).toEqual("mock-name");
expect(diagnostics.hasWarnings()).toBe(true);
expect(diagnostics.hasErrors()).toBe(true);
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
"Processing wrangler configuration:
- Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
`);
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
"Processing wrangler configuration:

- \\"env.DEV\\" environment configuration
- The \\"name\\" field is not allowed in named service environments.
Please remove the field from this environment."
`);
expect(diagnostics.hasWarnings()).toBe(false);
});
});

Expand All @@ -1890,15 +1904,19 @@ describe("normalizeAndValidateConfig()", () => {
{ env: "DEV" }
);

expect(diagnostics.hasWarnings()).toBe(true);
expect(config.account_id).toBeUndefined();
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
"Processing wrangler configuration:
- Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
`);
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
"Processing wrangler configuration:

- \\"env.DEV\\" environment configuration
- The \\"account_id\\" field is not allowed in named service environments.
Please remove the field from this environment."
`);
expect(diagnostics.hasWarnings()).toBe(false);
});

it("should error if top-level config and a named environment both contain a `account_id` field", () => {
Expand All @@ -1919,14 +1937,19 @@ describe("normalizeAndValidateConfig()", () => {
);

expect(config.account_id).toEqual("ACCOUNT_ID");
expect(diagnostics.hasErrors()).toBe(true);
expect(diagnostics.hasWarnings()).toBe(true);
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
"Processing wrangler configuration:
- Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
`);
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
"Processing wrangler configuration:

- \\"env.DEV\\" environment configuration
- The \\"account_id\\" field is not allowed in named service environments.
Please remove the field from this environment."
`);
expect(diagnostics.hasWarnings()).toBe(false);
});

it("should warn for non-inherited fields that are missing in environments", () => {
Expand Down Expand Up @@ -2843,9 +2866,9 @@ describe("normalizeAndValidateConfig()", () => {
"Processing wrangler configuration:

- \\"env.ENV1\\" environment configuration
- DEPRECATION: \\"zone_id\\":
- Deprecation: \\"zone_id\\":
This is unnecessary since we can deduce this from routes directly.
- DEPRECATION: \\"experimental_services\\":
- Deprecation: \\"experimental_services\\":
The \\"experimental_services\\" field is no longer supported. Instead, use [[unsafe.bindings]] to enable experimental features. Add this to your wrangler.toml:
\`\`\`
[[unsafe.bindings]]
Expand Down
8 changes: 4 additions & 4 deletions packages/wrangler/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ describe("wrangler", () => {
it("should throw an error if the deprecated command is used with positional arguments", async () => {
await expect(runWrangler("preview GET")).rejects
.toThrowErrorMatchingInlineSnapshot(`
"DEPRECATION:
"Deprecation:
The \`wrangler preview\` command has been deprecated.
Try using \`wrangler dev\` to to try out a worker during development.
"
`);
await expect(runWrangler(`preview GET "SomeBody"`)).rejects
.toThrowErrorMatchingInlineSnapshot(`
"DEPRECATION:
"Deprecation:
The \`wrangler preview\` command has been deprecated.
Try using \`wrangler dev\` to to try out a worker during development.
"
Expand Down Expand Up @@ -222,15 +222,15 @@ describe("wrangler", () => {
it("should print a deprecation message for 'generate'", async () => {
await runWrangler("generate").catch((err) => {
expect(err.message).toMatchInlineSnapshot(`
"DEPRECATION:
"Deprecation:
\`wrangler generate\` has been deprecated, please refer to https://github.com/cloudflare/wrangler2/blob/main/docs/deprecations.md#generate for alternatives"
`);
});
});
it("should print a deprecation message for 'build'", async () => {
await runWrangler("build").catch((err) => {
expect(err.message).toMatchInlineSnapshot(`
"DEPRECATION:
"Deprecation:
\`wrangler build\` has been deprecated, please refer to https://github.com/cloudflare/wrangler2/blob/main/docs/deprecations.md#build for alternatives"
`);
});
Expand Down
Loading