Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't attempt to login during a --dryRun #1037

Merged
merged 4 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@threepointone Is it an issue that during --dry-run, accountId won't be set even if you're logged in? We're not like generating a manifest with accountIds/paths that rely on accountId being set?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well we want zero requests during dry run, so maybe it's good that we enforce it doubly here. We'll want to generate a manifest, but we probably won't include account id in it (yet).

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