-
Notifications
You must be signed in to change notification settings - Fork 787
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
Add --compatibility-date
, --compatibility-flags
, --latest
cli arguments to dev
and publish
#215
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
3d4b86c
Add `--compatibility-date`, `--compatibility-flags`, `--latest` cli a…
threepointone e7f8f8d
remove the warning when using `--latest` for `wrangler dev`.
threepointone 3b89849
update changeset with the change to not log a warning during dev + la…
threepointone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
"wrangler": patch | ||
--- | ||
|
||
Add `--compatibility-date`, `--compatibility-flags`, `--latest` cli arguments to `dev` and `publish`. | ||
|
||
- A cli arg for adding a compatibility data, e.g `--compatibility_date 2022-01-05` | ||
- A shorthand `--latest` that sets `compatibility_date` to today's date. Usage of this flag logs a warning. | ||
- `latest` is NOT a config field in `wrangler.toml`. | ||
- In `dev`, when a compatibility date is not available in either `wrangler.toml` or as a cli arg, then we default to `--latest`, and log a warning. | ||
- In `publish` we error if a compatibility date is not available in either `wrangler.toml` or as a cli arg. Usage of `--latest` logs a warning. | ||
- We also accept compatibility flags via the cli, e.g: `--compatibility-flags formdata_parser_supports_files` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -435,6 +435,20 @@ export async function main(argv: string[]): Promise<void> { | |
type: "string", | ||
// TODO: get choices for the toml file? | ||
}) | ||
.option("compatibility-date", { | ||
describe: "Date to use for compatibility checks", | ||
type: "string", | ||
}) | ||
.option("compatibility-flags", { | ||
describe: "Flags to use for compatibility checks", | ||
type: "array", | ||
alias: "compatibility-flag", | ||
}) | ||
.option("latest", { | ||
describe: "Use the latest version of the worker runtime", | ||
type: "boolean", | ||
default: true, | ||
}) | ||
.option("ip", { | ||
describe: "IP address to listen on", | ||
type: "string", | ||
|
@@ -515,12 +529,18 @@ export async function main(argv: string[]): Promise<void> { | |
|
||
const envRootObj = args.env ? config.env[args.env] || {} : config; | ||
|
||
if (!envRootObj.compatibility_date && !args["compatibility-date"]) { | ||
console.warn( | ||
"⚠️ Using the latest version of the Workers runtime. To silence this warning, please choose a specific version of the runtime with --compatibility-date, or add a compatibility_date to your wrangler.toml.\n" | ||
); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @petebacondarwin that the warning during dev is unnecessary. Removing it. |
||
// TODO: this error shouldn't actually happen, | ||
// but we haven't fixed it internally yet | ||
if ("durable_objects" in envRootObj) { | ||
if (!(args.name || config.name)) { | ||
console.warn( | ||
'A worker with durable objects need to be named, or it may not work as expected. Add a "name" into wrangler.toml, or pass it in the command line with --name.' | ||
'A worker with durable objects needs to be named, or it may not work as expected. Add a "name" into wrangler.toml, or pass it in the command line with --name.' | ||
); | ||
} | ||
// TODO: if not already published, publish a draft worker | ||
|
@@ -539,8 +559,15 @@ export async function main(argv: string[]): Promise<void> { | |
site={args.site || config.site?.bucket} | ||
port={args.port || config.dev?.port} | ||
public={args["experimental-public"]} | ||
compatibilityDate={config.compatibility_date} | ||
compatibilityFlags={config.compatibility_flags} | ||
compatibilityDate={ | ||
args["compatibility-date"] || | ||
config.compatibility_date || | ||
new Date().toISOString().substring(0, 10) | ||
} | ||
compatibilityFlags={ | ||
(args["compatibility-flags"] as string[]) || | ||
config.compatibility_flags | ||
} | ||
usageModel={config.usage_model} | ||
bindings={{ | ||
kv_namespaces: envRootObj.kv_namespaces?.map( | ||
|
@@ -592,6 +619,20 @@ export async function main(argv: string[]): Promise<void> { | |
describe: "name to use when uploading", | ||
type: "string", | ||
}) | ||
.option("compatibility-date", { | ||
describe: "Date to use for compatibility checks", | ||
type: "string", | ||
}) | ||
.option("compatibility-flags", { | ||
describe: "Flags to use for compatibility checks", | ||
type: "array", | ||
alias: "compatibility-flag", | ||
}) | ||
.option("latest", { | ||
describe: "Use the latest version of the worker runtime", | ||
type: "boolean", | ||
default: false, | ||
}) | ||
.option("experimental-public", { | ||
describe: "Static assets to be served", | ||
type: "string", | ||
|
@@ -645,6 +686,12 @@ export async function main(argv: string[]): Promise<void> { | |
|
||
const config = args.config as Config; | ||
|
||
if (args.latest) { | ||
console.warn( | ||
"⚠️ Using the latest version of the Workers runtime. To silence this warning, please choose a specific version of the runtime with --compatibility-date, or add a compatibility_date to your wrangler.toml.\n" | ||
); | ||
} | ||
|
||
// -- snip, extract -- | ||
if (!args.local) { | ||
const loggedIn = await loginOrRefreshIfRequired(); | ||
|
@@ -668,6 +715,10 @@ export async function main(argv: string[]): Promise<void> { | |
name: args.name, | ||
script: args.script, | ||
env: args.env, | ||
compatibilityDate: args.latest | ||
? new Date().toISOString().substring(0, 10) | ||
: args["compatibility-date"], | ||
compatibilityFlags: args["compatibility-flags"] as string[], | ||
triggers: args.triggers, | ||
jsxFactory: args["jsx-factory"], | ||
jsxFragment: args["jsx-fragment"], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we error if
compatibility-date
andlatest
are both used?Should we log a warning if there is a compatibility-date set in config and is being overridden by
--latest
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I... hrmm. I'd push back against the error; the use case is the commands been generated by some other tooling, or literally just inside an npm script, and you're overriding it manually to try the latest runtime version. Would be annoying if an error blocked you then. We have the warning anyway, and it's an annoying one that you can't miss.