diff --git a/.changeset/tiny-ties-destroy.md b/.changeset/tiny-ties-destroy.md new file mode 100644 index 000000000000..2bc3f04de19f --- /dev/null +++ b/.changeset/tiny-ties-destroy.md @@ -0,0 +1,5 @@ +--- +"wrangler": patch +--- + +polish: improved visualization of the deprecation messages between serious and warnings with emojis. This also improves the delineation between messages. diff --git a/packages/wrangler/src/__tests__/configuration.test.ts b/packages/wrangler/src/__tests__/configuration.test.ts index 06ca09e454f8..5b3ea1049c64 100644 --- a/packages/wrangler/src/__tests__/configuration.test.ts +++ b/packages/wrangler/src/__tests__/configuration.test.ts @@ -322,7 +322,7 @@ describe("normalizeAndValidateConfig()", () => { `); expect(diagnostics.renderErrors()).toMatchInlineSnapshot(` "Processing wrangler configuration: - - DEPRECATION: \\"site.entry-point\\": + - 🚨 NO LONGER SUPPORTED: \\"site.entry-point\\": The \`site.entry-point\` config field is no longer used. The entry-point should be specified via the command line or the \`main\` config field." `); @@ -532,12 +532,12 @@ describe("normalizeAndValidateConfig()", () => { expect(diagnostics.hasErrors()).toBe(false); expect(diagnostics.hasWarnings()).toBe(true); expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(` - "Processing wrangler configuration: - - 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\\": - 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." - `); + "Processing wrangler configuration: + - 🦺 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\\": + 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." + `); }); }); }); @@ -699,15 +699,15 @@ 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: \`\`\` @@ -1448,19 +1448,19 @@ describe("normalizeAndValidateConfig()", () => { expect(diagnostics.hasErrors()).toBe(false); expect(diagnostics.hasWarnings()).toBe(true); expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(` - "Processing wrangler configuration: - - DEPRECATION: \\"zone_id\\": - This is unnecessary since we can deduce this from routes directly. - - 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]] - name = \\"NAME\\" - type = \\"service\\" - service = \\"SERVICE\\" - environment = \\"ENV\\" - \`\`\`" - `); + "Processing wrangler configuration: + - 🦺 DEPRECATION: \\"zone_id\\": + This is unnecessary since we can deduce this from routes directly. + - 🦺 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]] + name = \\"NAME\\" + type = \\"service\\" + service = \\"SERVICE\\" + environment = \\"ENV\\" + \`\`\`" + `); }); }); @@ -2615,9 +2615,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]] diff --git a/packages/wrangler/src/__tests__/index.test.ts b/packages/wrangler/src/__tests__/index.test.ts index 6a01a8f8d1b0..d8dd2d1c3970 100644 --- a/packages/wrangler/src/__tests__/index.test.ts +++ b/packages/wrangler/src/__tests__/index.test.ts @@ -845,14 +845,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. " @@ -970,7 +970,7 @@ 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" `); }); @@ -978,7 +978,7 @@ describe("wrangler", () => { 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" `); }); diff --git a/packages/wrangler/src/__tests__/publish.test.ts b/packages/wrangler/src/__tests__/publish.test.ts index 87079fd3642f..a5ff5ac24b57 100644 --- a/packages/wrangler/src/__tests__/publish.test.ts +++ b/packages/wrangler/src/__tests__/publish.test.ts @@ -443,7 +443,7 @@ describe("publish", () => { expect(std.err).toMatchInlineSnapshot(`""`); expect(std.warn).toMatchInlineSnapshot(` "Processing wrangler.toml configuration: - - 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: \`\`\` @@ -475,13 +475,13 @@ describe("publish", () => { expect(std.err).toMatchInlineSnapshot(`""`); expect(std.warn).toMatchInlineSnapshot(` "Processing ../wrangler.toml configuration: - - 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 = \\"foo/index.js\\" \`\`\` - - 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." `); }); @@ -655,7 +655,7 @@ export default{ await expect(runWrangler("publish ./index.js")).rejects .toThrowErrorMatchingInlineSnapshot(` "Processing wrangler.toml configuration: - - DEPRECATION: \\"site.entry-point\\": + - 🚨 NO LONGER SUPPORTED: \\"site.entry-point\\": The \`site.entry-point\` config field is no longer used. The entry-point should be specified via the command line or the \`main\` config field." `); @@ -663,7 +663,7 @@ export default{ expect(std.out).toMatchInlineSnapshot(`""`); expect(std.err).toMatchInlineSnapshot(` "Processing wrangler.toml configuration: - - DEPRECATION: \\"site.entry-point\\": + - 🚨 NO LONGER SUPPORTED: \\"site.entry-point\\": The \`site.entry-point\` config field is no longer used. The entry-point should be specified via the command line or the \`main\` config field. diff --git a/packages/wrangler/src/__tests__/route.test.ts b/packages/wrangler/src/__tests__/route.test.ts index 69c7d44231e1..92fe237d4845 100644 --- a/packages/wrangler/src/__tests__/route.test.ts +++ b/packages/wrangler/src/__tests__/route.test.ts @@ -9,7 +9,7 @@ describe("wrangler route", () => { it("shows a deprecation notice when `wrangler route` is run", async () => { await expect(runWrangler("route")).rejects .toThrowErrorMatchingInlineSnapshot(` - "DEPRECATION: + "🦺 DEPRECATION: \`wrangler route\` has been deprecated. Please use wrangler.toml and/or \`wrangler publish --routes\` to modify routes" `); @@ -18,7 +18,7 @@ describe("wrangler route", () => { it("shows a deprecation notice when `wrangler route delete` is run", async () => { await expect(runWrangler("route delete")).rejects .toThrowErrorMatchingInlineSnapshot(` - "DEPRECATION: + "🦺 DEPRECATION: \`wrangler route delete\` has been deprecated. Remove the unwanted route(s) from wrangler.toml and run \`wrangler publish\` to remove your worker from those routes." `); @@ -27,7 +27,7 @@ describe("wrangler route", () => { it("shows a deprecation notice when `wrangler route delete ` is run", async () => { await expect(runWrangler("route delete some-zone-id")).rejects .toThrowErrorMatchingInlineSnapshot(` - "DEPRECATION: + "🦺 DEPRECATION: \`wrangler route delete\` has been deprecated. Remove the unwanted route(s) from wrangler.toml and run \`wrangler publish\` to remove your worker from those routes." `); @@ -36,7 +36,7 @@ describe("wrangler route", () => { it("shows a deprecation notice when `wrangler route list` is run", async () => { await expect(runWrangler("route list")).rejects .toThrowErrorMatchingInlineSnapshot(` - "DEPRECATION: + "🦺 DEPRECATION: \`wrangler route list\` has been deprecated. Refer to wrangler.toml for a list of routes the worker will be deployed to upon publishing. Refer to the Cloudflare Dashboard to see the routes this worker is currently running on." diff --git a/packages/wrangler/src/config/validation-helpers.ts b/packages/wrangler/src/config/validation-helpers.ts index 8b890a81c933..724b7625ecf4 100644 --- a/packages/wrangler/src/config/validation-helpers.ts +++ b/packages/wrangler/src/config/validation-helpers.ts @@ -16,10 +16,13 @@ export function deprecated( remove: boolean, breaking = false ): void { + const diagonsticMessage = breaking + ? `🚨 NO LONGER SUPPORTED: "${fieldPath}":\n${message}` + : `🦺 DEPRECATION: "${fieldPath}":\n${message}`; const result = unwindPropertyPath(config, fieldPath); if (result !== undefined && result.field in result.container) { (breaking ? diagnostics.errors : diagnostics.warnings).push( - `DEPRECATION: "${fieldPath}":\n${message}` + diagonsticMessage ); if (remove) { delete (result.container as Record)[result.field]; diff --git a/packages/wrangler/src/errors.ts b/packages/wrangler/src/errors.ts index d183dfab2905..b3f96a1e8bde 100644 --- a/packages/wrangler/src/errors.ts +++ b/packages/wrangler/src/errors.ts @@ -1,6 +1,6 @@ export class DeprecationError extends Error { constructor(message: string) { - super(`DEPRECATION:\n${message}`); + super(`🦺 DEPRECATION:\n${message}`); } }