Skip to content

Commit 41103f5

Browse files
Miscellaneous improvements and refactorings (#11414)
* pin the Typescript version * add error message info to debug where we are getting the api token from * allow C3 to import from workers-utils * clean up vitest config * Add PWD to turbo's global pass-through env * post review fixups * add changeset
1 parent 0b94e14 commit 41103f5

File tree

10 files changed

+40
-30
lines changed

10 files changed

+40
-30
lines changed

.changeset/ready-humans-thank.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
add extra logging to user log-in flow for diagnosing failed login requests

packages/create-cloudflare/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"compilerOptions": {
1515
"target": "ESNext",
1616
"module": "preserve",
17-
"moduleResolution": "node",
17+
"moduleResolution": "bundler",
1818
"allowJs": true,
1919
"strict": true,
2020
"esModuleInterop": true,

packages/workers-utils/tests/vitest.setup.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/workers-utils/vitest.config.mts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ export default defineConfig({
55
test: {
66
testTimeout: 15_000,
77
pool: "forks",
8-
retry: 0,
98
include: ["**/tests/**/*.test.ts"],
10-
setupFiles: path.resolve(__dirname, "tests/vitest.setup.ts"),
119
globalSetup: path.resolve(__dirname, "tests/vitest.global.ts"),
1210
reporters: ["default"],
13-
globals: true,
1411
snapshotFormat: {
1512
escapeString: true,
1613
printBasicPrototype: true,
1714
},
1815
unstubEnvs: true,
16+
mockReset: true,
1917
},
2018
});

packages/wrangler/src/__tests__/deploy.test.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -733,15 +733,21 @@ describe("deploy", () => {
733733
https://test-name.test-sub-domain.workers.dev
734734
Current Version ID: Galaxy-Class"
735735
`);
736-
expect(std.warn).toMatchInlineSnapshot(`
737-
"▲ [WARNING] It looks like you have used Wrangler v1's \`config\` command to login with an API token.
738736

739-
This is no longer supported in the current version of Wrangler.
740-
If you wish to authenticate via an API token then please set the \`CLOUDFLARE_API_TOKEN\`
741-
environment variable.
737+
// The current working directory is replaced with `<cwd>` to make the snapshot consistent across environments
738+
// But since the actual working directory could be a long string on some operating systems it is possible that the string gets wrapped to a new line.
739+
// To avoid failures across different environments, we remove any newline before `<cwd>` in the snapshot.
740+
expect(std.warn.replaceAll(/from[ \r\n]+<cwd>/g, "from <cwd>"))
741+
.toMatchInlineSnapshot(`
742+
"▲ [WARNING] It looks like you have used Wrangler v1's \`config\` command to login with an API token
742743

743-
"
744-
`);
744+
from <cwd>/home/.config/.wrangler/config/default.toml.
745+
This is no longer supported in the current version of Wrangler.
746+
If you wish to authenticate via an API token then please set the \`CLOUDFLARE_API_TOKEN\`
747+
environment variable.
748+
749+
"
750+
`);
745751
expect(std.err).toMatchInlineSnapshot(`""`);
746752
});
747753

packages/wrangler/src/__tests__/whoami.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,14 @@ describe("getUserInfo(COMPLIANCE_REGION_CONFIG_UNKNOWN)", () => {
198198
writeAuthConfigFile({ api_token: "API_TOKEN" });
199199
await getUserInfo(COMPLIANCE_REGION_CONFIG_UNKNOWN);
200200

201-
expect(std.warn).toMatchInlineSnapshot(`
202-
"▲ [WARNING] It looks like you have used Wrangler v1's \`config\` command to login with an API token.
203-
201+
// The current working directory is replaced with `<cwd>` to make the snapshot consistent across environments
202+
// But since the actual working directory could be a long string on some operating systems it is possible that the string gets wrapped to a new line.
203+
// To avoid failures across different environments, we remove any newline before `<cwd>` in the snapshot.
204+
expect(std.warn.replaceAll(/from[ \r\n]+<cwd>/g, "from <cwd>"))
205+
.toMatchInlineSnapshot(`
206+
"▲ [WARNING] It looks like you have used Wrangler v1's \`config\` command to login with an API token
207+
208+
from <cwd>/home/.config/.wrangler/config/default.toml.
204209
This is no longer supported in the current version of Wrangler.
205210
If you wish to authenticate via an API token then please set the \`CLOUDFLARE_API_TOKEN\`
206211
environment variable.

packages/wrangler/src/user/user.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ function getAuthTokens(config?: UserAuthConfig): AuthTokens | undefined {
422422
};
423423
} else if (api_token) {
424424
logger.warn(
425-
"It looks like you have used Wrangler v1's `config` command to login with an API token.\n" +
425+
"It looks like you have used Wrangler v1's `config` command to login with an API token\n" +
426+
`from ${config === undefined ? getAuthConfigFilePath() : "in-memory config"}.\n` +
426427
"This is no longer supported in the current version of Wrangler.\n" +
427428
"If you wish to authenticate via an API token then please set the `CLOUDFLARE_API_TOKEN` environment variable."
428429
);

pnpm-lock.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ catalog:
2424
"@vitest/ui": ~3.2.0
2525
# rimraf@6 requires node 20 or >=22
2626
rimraf: "^6.0.1"
27-
typescript: "^5.8.3"
27+
typescript: "~5.8.3"
2828
undici: "7.14.0"
2929
# Override undici-types from @types/node so that the Cloudflare SDK typings match our installed
3030
# version of Undici

turbo.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@
55
},
66
"globalEnv": ["CI_OS", "NODE_VERSION"],
77
"globalPassThroughEnv": [
8-
"NODE_EXTRA_CA_CERTS",
98
"CI",
10-
"VSCODE_INSPECTOR_OPTIONS",
11-
"WRANGLER_LOG_PATH",
12-
"TEST_REPORT_PATH",
139
"CLOUDFLARE_CONTAINER_REGISTRY",
1410
"DOCKER_HOST",
15-
"WRANGLER_DOCKER_HOST",
16-
"WRANGLER_LOG",
11+
"LOCAL_TESTS_WITHOUT_DOCKER",
12+
"NODE_EXTRA_CA_CERTS",
13+
"PWD",
14+
"TEST_REPORT_PATH",
15+
"VSCODE_INSPECTOR_OPTIONS",
1716
"WRANGLER_API_ENVIRONMENT",
18-
"LOCAL_TESTS_WITHOUT_DOCKER"
17+
"WRANGLER_DOCKER_HOST",
18+
"WRANGLER_LOG_PATH",
19+
"WRANGLER_LOG"
1920
],
2021
"tasks": {
2122
"dev": {

0 commit comments

Comments
 (0)