diff --git a/.changeset/wild-seas-breathe.md b/.changeset/wild-seas-breathe.md new file mode 100644 index 000000000000..2c95d3784802 --- /dev/null +++ b/.changeset/wild-seas-breathe.md @@ -0,0 +1,5 @@ +--- +"wrangler": patch +--- + +fix: don't attempt to login during a --dryRun diff --git a/packages/wrangler/src/__tests__/publish.test.ts b/packages/wrangler/src/__tests__/publish.test.ts index 926a5e79e4d4..25d18f83d868 100644 --- a/packages/wrangler/src/__tests__/publish.test.ts +++ b/packages/wrangler/src/__tests__/publish.test.ts @@ -4677,6 +4677,7 @@ addEventListener('fetch', event => {});` migrations: [{ tag: "v1", new_classes: ["SomeClass"] }], }); writeWorkerSource(); + process.env.CLOUDFLARE_ACCOUNT_ID = ""; await runWrangler("publish index.js --dry-run"); expect(std).toMatchInlineSnapshot(` Object { diff --git a/packages/wrangler/src/index.tsx b/packages/wrangler/src/index.tsx index c75639300643..e56a42112e8a 100644 --- a/packages/wrangler/src/index.tsx +++ b/packages/wrangler/src/index.tsx @@ -1270,7 +1270,7 @@ export async function main(argv: string[]): Promise { ); } - const accountId = await requireAuth(config); + const accountId = args.dryRun ? undefined : await requireAuth(config); const assetPaths = getAssetPaths( config, diff --git a/packages/wrangler/src/publish.ts b/packages/wrangler/src/publish.ts index a327f6729c6c..124caa9634c3 100644 --- a/packages/wrangler/src/publish.ts +++ b/packages/wrangler/src/publish.ts @@ -15,7 +15,7 @@ import type { CfWorkerInit } from "./worker"; type Props = { config: Config; - accountId: string; + accountId: string | undefined; entry: Entry; rules: Config["rules"]; name: string | undefined; @@ -325,6 +325,7 @@ export default async function publish(props: Props): Promise { logger.log(`--dry-run: exiting now.`); return; } + assert(accountId, "Missing accountId"); const uploadMs = Date.now() - start; const deployments: Promise[] = []; diff --git a/packages/wrangler/src/sites.tsx b/packages/wrangler/src/sites.tsx index fda7df28b550..457441c3525c 100644 --- a/packages/wrangler/src/sites.tsx +++ b/packages/wrangler/src/sites.tsx @@ -1,3 +1,4 @@ +import assert from "node:assert"; import { readdir, readFile, stat } from "node:fs/promises"; import * as path from "node:path"; import ignore from "ignore"; @@ -103,7 +104,7 @@ async function createKVNamespaceIfNotAlreadyExisting( * asset in the KV namespace. */ export async function syncAssets( - accountId: string, + accountId: string | undefined, scriptName: string, siteAssets: AssetPaths | undefined, preview: boolean, @@ -120,6 +121,7 @@ export async function syncAssets( logger.log("(Note: doing a dry run, not uploading or deleting anything.)"); return { manifest: undefined, namespace: undefined }; } + assert(accountId, "Missing accountId"); const title = `__${scriptName}-workers_sites_assets${ preview ? "_preview" : ""