Skip to content

Commit

Permalink
fix: don't attempt to login during a --dryRun (#1037)
Browse files Browse the repository at this point in the history
* fix: don't attempt to login during a --dryRun

* Create wild-seas-breathe.md

* chore: update test to explicitly set CLOUDFLARE_ACCOUNT_ID to an empty string
  • Loading branch information
rozenmd authored May 17, 2022
1 parent 95852c3 commit 963e9e0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/wild-seas-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

fix: don't attempt to login during a --dryRun
1 change: 1 addition & 0 deletions packages/wrangler/src/__tests__/publish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ export async function main(argv: string[]): Promise<void> {
);
}

const accountId = await requireAuth(config);
const accountId = args.dryRun ? undefined : await requireAuth(config);

const assetPaths = getAssetPaths(
config,
Expand Down
3 changes: 2 additions & 1 deletion packages/wrangler/src/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -325,6 +325,7 @@ export default async function publish(props: Props): Promise<void> {
logger.log(`--dry-run: exiting now.`);
return;
}
assert(accountId, "Missing accountId");

const uploadMs = Date.now() - start;
const deployments: Promise<string[]>[] = [];
Expand Down
4 changes: 3 additions & 1 deletion packages/wrangler/src/sites.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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,
Expand All @@ -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" : ""
Expand Down

0 comments on commit 963e9e0

Please sign in to comment.