Skip to content

Commit

Permalink
rename --public as --experimental-public (#214)
Browse files Browse the repository at this point in the history
This PR is a breaking change. We'll keep it as a patch release tho.

We want to change the behaviour of `--public` to closer match Pages behaviour, and only really expose it in v2.1 (maybe even after that).

This PR renames the field as `experimental-public`, and adds warnings. In a future PR we'll actually change the behaviour.
  • Loading branch information
threepointone authored Jan 7, 2022
1 parent caa0143 commit 79d0f2d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/new-carrots-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

rename `--public` as `--experimental-public`
32 changes: 28 additions & 4 deletions packages/wrangler/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ export async function main(argv: string[]): Promise<void> {
describe: "Protocol to listen to requests on, defaults to http.",
choices: ["http", "https"],
})
.option("public", {
.option("experimental-public", {
describe: "Static assets to be served",
type: "string",
})
Expand All @@ -482,6 +482,18 @@ export async function main(argv: string[]): Promise<void> {
const { filename, format } = args;
const config = args.config as Config;

if (args["experimental-public"]) {
console.warn(
"🚨 The --experimental-public field is experimental and will change in the future."
);
}

if (args.public) {
throw new Error(
"🚨 The --public field has been renamed to --experimental-public, and will change behaviour in the future."
);
}

// -- snip, extract --

if (!args.local) {
Expand Down Expand Up @@ -526,7 +538,7 @@ export async function main(argv: string[]): Promise<void> {
accountId={config.account_id}
site={args.site || config.site?.bucket}
port={args.port || config.dev?.port}
public={args.public}
public={args["experimental-public"]}
compatibilityDate={config.compatibility_date}
compatibilityFlags={config.compatibility_flags}
usageModel={config.usage_model}
Expand Down Expand Up @@ -580,7 +592,7 @@ export async function main(argv: string[]): Promise<void> {
describe: "name to use when uploading",
type: "string",
})
.option("public", {
.option("experimental-public", {
describe: "Static assets to be served",
type: "string",
})
Expand Down Expand Up @@ -619,6 +631,18 @@ export async function main(argv: string[]): Promise<void> {
"🚫 Local publishing is not yet supported"
);
}

if (args["experimental-public"]) {
console.warn(
"🚨 The --experimental-public field is experimental and will change in the future."
);
}
if (args.public) {
throw new Error(
"🚨 The --public field has been renamed to --experimental-public, and will change behaviour in the future."
);
}

const config = args.config as Config;

// -- snip, extract --
Expand Down Expand Up @@ -648,7 +672,7 @@ export async function main(argv: string[]): Promise<void> {
jsxFactory: args["jsx-factory"],
jsxFragment: args["jsx-fragment"],
routes: args.routes,
public: args.public,
public: args["experimental-public"],
site: args.site,
});
}
Expand Down

0 comments on commit 79d0f2d

Please sign in to comment.