Skip to content

Commit

Permalink
fix: remove bold font from additional lines of warnings and errors
Browse files Browse the repository at this point in the history
Previously, when a warning or error was logged, the entire message
was formatted in bold font. This change makes only the first line of
the message bold, and the rest is formatted with a normal font.
  • Loading branch information
petebacondarwin committed May 4, 2022
1 parent 57c1354 commit 8134bdc
Show file tree
Hide file tree
Showing 8 changed files with 212 additions and 139 deletions.
9 changes: 9 additions & 0 deletions .changeset/itchy-windows-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"wrangler": patch
---

fix: remove bold font from additional lines of warnings and errors

Previously, when a warning or error was logged, the entire message
was formatted in bold font. This change makes only the first line of
the message bold, and the rest is formatted with a normal font.
40 changes: 22 additions & 18 deletions packages/wrangler/src/__tests__/dev.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,17 @@ describe("wrangler dev", () => {
expect(std.out).toMatchInlineSnapshot(`""`);
expect(std.warn.replaceAll(currentDate, "<current-date>"))
.toMatchInlineSnapshot(`
"▲ [WARNING] No compatibility_date was specified. Using today's date: <current-date>.
Add one to your wrangler.toml file:
\`\`\`
compatibility_date = \\"<current-date>\\"
\`\`\`
or pass it in your terminal:
\`\`\`
--compatibility-date=<current-date>
\`\`\`
See https://developers.cloudflare.com/workers/platform/compatibility-dates for more information.
"▲ [WARNING] No compatibility_date was specified. Using today's date: <current-date>.
Add one to your wrangler.toml file:
\`\`\`
compatibility_date = \\"<current-date>\\"
\`\`\`
or pass it in your terminal:
\`\`\`
--compatibility-date=<current-date>
\`\`\`
See https://developers.cloudflare.com/workers/platform/compatibility-dates for more information.
"
`);
Expand Down Expand Up @@ -476,9 +477,10 @@ describe("wrangler dev", () => {
);
expect(std.out).toMatchInlineSnapshot(`""`);
expect(std.warn).toMatchInlineSnapshot(`
"▲ [WARNING] Setting upstream-protocol to http is not currently implemented.
If this is required in your project, please add your use case to the following issue:
https://github.com/cloudflare/wrangler2/issues/583.
"▲ [WARNING] Setting upstream-protocol to http is not currently implemented.
If this is required in your project, please add your use case to the following issue:
https://github.com/cloudflare/wrangler2/issues/583.
"
`);
Expand Down Expand Up @@ -604,11 +606,13 @@ describe("wrangler dev", () => {
expect((Dev as jest.Mock).mock.calls[0][0].ip).toEqual("localhost");
expect(std.out).toMatchInlineSnapshot(`""`);
expect(std.warn).toMatchInlineSnapshot(`
"▲ [WARNING] WARNING: You have Durable Object bindings that are not defined locally in the worker being developed.
Be aware that changes to the data stored in these Durable Objects will be permanent and affect the live instances.
Remote Durable Objects that are affected:
- {\\"name\\":\\"NAME_2\\",\\"class_name\\":\\"CLASS_2\\",\\"script_name\\":\\"SCRIPT_A\\"}
- {\\"name\\":\\"NAME_4\\",\\"class_name\\":\\"CLASS_4\\",\\"script_name\\":\\"SCRIPT_B\\"}
"▲ [WARNING] WARNING: You have Durable Object bindings that are not defined locally in the worker being developed.
Be aware that changes to the data stored in these Durable Objects will be permanent and affect the
live instances.
Remote Durable Objects that are affected:
- {\\"name\\":\\"NAME_2\\",\\"class_name\\":\\"CLASS_2\\",\\"script_name\\":\\"SCRIPT_A\\"}
- {\\"name\\":\\"NAME_4\\",\\"class_name\\":\\"CLASS_4\\",\\"script_name\\":\\"SCRIPT_B\\"}
"
`);
Expand Down
2 changes: 2 additions & 0 deletions packages/wrangler/src/__tests__/helpers/mock-console.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as util from "node:util";
import { logger } from "../../logger";

/**
* We use this module to mock console methods, and optionally
Expand Down Expand Up @@ -39,6 +40,7 @@ function captureCalls(spy: jest.SpyInstance): string {

export function mockConsoleMethods() {
beforeEach(() => {
logger.columns = 100;
debugSpy = jest.spyOn(console, "debug").mockImplementation();
logSpy = jest.spyOn(console, "log").mockImplementation();
errorSpy = jest.spyOn(console, "error").mockImplementation();
Expand Down
5 changes: 3 additions & 2 deletions packages/wrangler/src/__tests__/https-options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ describe("getHttpsOptions()", () => {
`"Generating new self-signed certificate..."`
);
expect(std.warn).toMatchInlineSnapshot(`
"▲ [WARNING] Unable to cache generated self-signed certificate in home/.wrangler/local-cert.
ERROR: Cannot write file
"▲ [WARNING] Unable to cache generated self-signed certificate in home/.wrangler/local-cert.
ERROR: Cannot write file
"
`);
Expand Down
10 changes: 6 additions & 4 deletions packages/wrangler/src/__tests__/kv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,9 @@ describe("wrangler", () => {
--namespace-id The id of the namespace to delete [string]
-e, --env Perform on a specific environment [string]
--preview Interact with a preview namespace [boolean]
X [ERROR] Not able to delete namespace.
A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\".
X [ERROR] Not able to delete namespace.
A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\".
"
`);
Expand Down Expand Up @@ -1229,8 +1230,9 @@ describe("wrangler", () => {
If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new."
`);
expect(std.warn).toMatchInlineSnapshot(`
"▲ [WARNING] Unexpected key-value properties in \\"keys.json\\".
The item at index 4 contains unexpected properties: [\\"invalid\\"].
"▲ [WARNING] Unexpected key-value properties in \\"keys.json\\".
The item at index 4 contains unexpected properties: [\\"invalid\\"].
"
`);
Expand Down
Loading

0 comments on commit 8134bdc

Please sign in to comment.