Patch Changes
-
#523
8c99449
Thanks @threepointone! - feat: secrets + environmentsThis implements environment support for
wrangler secret
(both legacy and services). We now consistently generate the right script name across commands with thegetScriptName()
helper.Based on the work by @mitchelvanbever in #95.
-
#554
18ac439
Thanks @petebacondarwin! - fix: limit bulk put API requests to batches of 5,000The
kv:bulk put
command now batches up put requests in groups of 5,000,
displaying progress for each request. -
#437
2805205
Thanks @jacobbednarz! - feat: useCLOUDFLARE_...
environment variables deprecatingCF_...
Now one should use
CLOUDFLARE_API_TOKEN
,CLOUDFLARE_ACCOUNT_ID
andCLOUDFLARE_API_BASE_URL
rather thanCF_API_TOKEN
,CF_ACCOUNT_ID
andCF_API_BASE_URL
, which have been deprecated.If you use the deprecated variables they will still work but you will see a warning message.
Within the Cloudflare tooling ecosystem, we have a mix of
CF_
andCLOUDFLARE_
for prefixing environment variables. Until recently, many of the tools
were fine withCF_
however, there started to be conflicts with
external tools (such as Cloudfoundary CLI), which also usesCF_
as a
prefix, and would potentially be reading and writing the same value the
Cloudflare tooling.The Go SDK1, Terraform2 and cf-terraforming3 have made the jump to
theCLOUDFLARE_
prefix for environment variable prefix.In future, all SDKs will use this prefix for consistency and to allow all the tooling to reuse the same environment variables in the scenario where they are present.
-
#530
fdb4afd
Thanks @threepointone! - feat: implementrules
config fieldThis implements the top level
rules
configuration field. It lets you specify transport rules for non-js modules. For example, you can specify*.md
files to be included as a text file with -[[rules]] {type = "Text", globs = ["**/*.md"]}
We also include a default ruleset -
{ type: "Text", globs: ["**/*.txt", "**/*.html"] }, { type: "Data", globs: ["**/*.bin"] }, { type: "CompiledWasm", globs: ["**/*.wasm"] },
More info at https://developers.cloudflare.com/workers/cli-wrangler/configuration/#build.
Known issues -
- non-wasm module types do not work in
--local
mode Data
type does not work in service worker format, in either mode
- non-wasm module types do not work in
-
#517
201a6bb
Thanks @threepointone! - fix: publish environment specific routesThis adds some tests for publishing routes, and fixes a couple of bugs with the flow.
- fixes publishing environment specific routes, closes #513
- default
workers_dev
tofalse
if there are any routes specified - catches a hanging promise when we were toggling off a
workers.dev
subdomain (which should have been caught by theno-floating-promises
lint rule, so that's concerning) - this also fixes publishing environment specific crons, but I'll write tests for that when I'm doing that feature in depth
-
#528
26f5ad2
Thanks @threepointone! - feat: top levelmain
config fieldThis implements a top level
main
field forwrangler.toml
to define an entry point for the worker , and adds a deprecation warning forbuild.upload.main
. The deprecation warning is detailed enough to give the exact line to copy-paste into your config file. Example -The `build.upload` field is deprecated. Delete the `build.upload` field, and add this to your configuration file: main = "src/chat.mjs"
This also makes
./dist
a default forbuild.upload.dir
, to match wrangler 1's behaviour.Closes #488
-
#521
5947bfe
Thanks @threepointone! - chore: update esbuild from 0.14.18 to 0.14.23 -
#480
10cb789
Thanks @caass! - Refactored tail functionality in preparation for adding pretty printing.- Moved the
debug
toggle from a build-time constant to a (hidden) CLI flag - Implemented pretty-printing logs, togglable via
--format pretty
CLI option - Added stronger typing for tail event messages
- Moved the
-
#525
9d5c14d
Thanks @threepointone! - feat: tail+envsThis implements service environment support for
wrangler tail
. Fairly simple, we just generate the right URLs. wrangler tail already works for legacy envs, so there's nothing to do there. -
#553
bc85682
Thanks @threepointone! - feat: disable tunnel inwrangler dev
Disables sharing local development server on the internet. We will bring this back after it's more polished/ready.
Fixes #550
-
#522
a283836
Thanks @threepointone! - fix: websocketsThis fixes websockets in
wrangler dev
. It looks like we broke it in #503. I've reverted the specific changes made toproxy.ts
.Test plan -
cd packages/wrangler npm run build cd ../workers-chat-demo npx wrangler dev
-
#481
8874548
Thanks @threepointone! - fix: replace the word "deploy" with "publish" everywhere.We should be consistent with the word that describes how we get a worker to the edge. The command is
publish
, so let's use that everywhere. -
#537
b978db4
Thanks @threepointone! - feat:--local
mode only applies inwrangler dev
We'd originally planned for
--local
mode to be a thing across all wrangler commands. In hindsight, that didn't make much sense, since every command other thanwrangler dev
assumes some interaction with cloudflare and their API. The only command other than dev where this "worked" waskv
, but even that didn't make sense because wrangler dev wouldn't even read from it. We also have--experimental-enable-local-persistence
there anyway.So this moves the
--local
flag to only apply forwrangler dev
and removes any trace from other commands. -
#518
72f035e
Thanks @threepointone! - feat: implement[text_blobs]
This implements support for
[text_blobs]
as defined by cloudflare/wrangler-legacy#1677.Text blobs can be defined in service-worker format with configuration in
wrangler.toml
as -[text_blobs] MYTEXT = "./path/to/my-text.file"
The content of the file will then be available as the global
MYTEXT
inside your code. Note that this ONLY makes sense in service-worker format workers (for now).Workers Sites now uses
[text_blobs]
internally. Previously, we were inlining the asset manifest into the worker itself, but we now attach the asset manifest to the uploaded worker. I also added an additional example of Workers Sites with a modules format worker. -
#532
046b17d
Thanks @threepointone! - feat: dev+envsThis implements service environments +
wrangler dev
. Fairly simple, it just needed the right url when creating the edge preview token.I tested this by publishing a service under one env, adding secrets under it in the dashboard, and then trying to dev under another env, and verifying that the secrets didn't leak.
-
#552
3cee150
Thanks @petebacondarwin! - feat: add confirmation and success messages tokv:bulk delete
commandAdded the following:
- When the deletion completes, we get
Success!
logged to the console. - Before deleting, the user is now asked to confirm is that is desired.
- A new flag
--force
/-f
to avoid the confirmation check.
- When the deletion completes, we get
-
#533
1b3a5f7
Thanks @threepointone! - feat: default to legacy environmentsWhile implementing support for service environments, we unearthed a small number of usage issues. While we work those out, we should default to using regular "legacy" environments.
-
#519
93576a8
Thanks @caass! - fix: Improve port selection forwrangler dev
for both worker ports and inspector ports.Previously when running
wrangler dev
on multiple workers at the same time, you couldn't attach DevTools to both workers, since they were both listening on port 9229.
With this PR, that behavior is improved -- you can now pass an--inspector-port
flag to specify a port for DevTools to connect to on a per-worker basis, or
if the option is omitted, wrangler will assign a random unused port for you.This "if no option is given, assign a random unused port" behavior has also been added to
wrangler dev --port
, so runningwrangler dev
on two
workers at once should now "just work". Hopefully. -
#545
9e89dd7
Thanks @threepointone! - feat: zoned worker support forwrangler dev
This implements support for zoned workers in
wrangler dev
. Of note, since we're deprecatingzone_id
, we instead use the domain provided via--host
/config.dev.host
/--routes
/--route
/config.routes
/config.route
and infer the zone id from it.Fixes #544
-
#494
6e6c30f
Thanks @caass! - - Add tests covering pretty-printing of logs inwrangler tail
- Modify
RequestEvent
types- Change
Date
types tonumber
to make parsing easier - Change
exception
andlog
message
properties tounknown
- Change
- Add datetime to pretty-printed request events
- Modify
-
#496
5a640f0
Thanks @jahands! - chore: Remove acorn/acorn-walk dependency used in Pages Functions filepath-routing.This shouldn't cause any functional changes, Pages Functions filepath-routing now uses esbuild to find exports.
-
#419
04f4332
Thanks @Electroid! - refactor: use esbuild's message formatting for cleaner error messagesThis is the first step in making a standard format for error messages. For now, this uses esbuild's error formatting, which is nice and colored, but we could decide to customize our own later. Moreover, we should use the
parseJSON
,parseTOML
, andreadFile
utilities so there are pretty errors for any configuration. -
#501
824d8c0
Thanks @petebacondarwin! - refactor: delegate deprecatedpreview
command todev
if possibleThe
preview
command is deprecated and not supported in this version of Wrangler.
Instead, one should use thedev
command for mostpreview
use-cases.This change attempts to delegate any use of
preview
todev
failing if the command line contains positional arguments that are not compatible withdev
.Resolves #9
-
#541
371e6c5
Thanks @threepointone! - chore: refactor some common code intorequireAuth()
There was a common chunk of code across most commands that ensures a user is logged in, and retrieves an account ID. I'd resisted making this into an abstraction for a while. Now that the codebase is stable, and #537 removes some surrounding code there, I made an abstraction for this common code as
requireAuth()
. This gets a mention in the changelog simply because it touches a bunch of code, although it's mostly mechanical deletion/replacement. -
#551
afd4b0e
Thanks @petebacondarwin! - fix: do not log thenull
returned fromkv:bulk put
andkv:bulk delete
-
#503
e5c7ed8
Thanks @petebacondarwin! - refact: consolidate onws
websocket libraryRemoves the
faye-websocket
library and usesws
across the code base. -
#502
b30349a
Thanks @petebacondarwin! - fix(pages): ensure remaining args passed topages dev
command are capturedIt is common to pass additional commands to
pages dev
to generate the input source.
For example:npx wrangler@beta pages dev -- npm run dev
Previously the args after
--
were being dropped.
This change ensures that these are captured and used correctly.Fixes #482
-
#512
b093df7
Thanks @threepointone! - feat: a bettertsconfig.json
This makes a better
tsconfig.json
when usingwrangler init
. Of note, it takes the defaulttsconfig.json
generated bytsc --init
, and adds our modifications. -
#510
9534c7f
Thanks @threepointone! - feat:--legacy-env
cli arg /legacy_env
configThis is the first of a few changes to codify how we do environments in wrangler2, both older legacy style environments, and newer service environments. Here, we add a cli arg and a config field for specifying whether to enable/disable legacy style environments, and pass it on to dev/publish commands. We also fix how we were generating kv namespaces for Workers Sites, among other smaller fixes.
-
#549
3d2ce01
Thanks @petebacondarwin! - fix: kv:bulk should JSON encode its contentsThe body passed to
kv:bulk delete
andkv:bulk put
must be JSON encoded.
This change fixes that and adds some tests to prove it.Fixes #547
-
#554
6e5319b
Thanks @petebacondarwin! - fix: limit bulk delete API requests to batches of 5,000The
kv:bulk delete
command now batches up delete requests in groups of 5,000,
displaying progress for each request. -
#538
4b6c973
Thanks @threepointone! - feat: withwrangler init
, create a new directory for named workersCurrently, when creating a new project, we usually first have to create a directory before running
wrangler init
, since it defaults to creating thewrangler.toml
,package.json
, etc in the current working directory. This fix introduces an enhancement, where using thewrangler init [name]
form creates a directory named[name]
and initialises the project files inside it. This matches the usage pattern a little better, and still preserves the older behaviour when we're creating a worker inside existing projects. -
#548
e3cab74
Thanks @petebacondarwin! - refactor: clean up unnecessary async functionsThe
readFile()
andreadConfig()
helpers do not need to be async.
Doing so just adds complexity to their call sites. -
#529
9d7e946
Thanks @petebacondarwin! - feat: add more comprehensive config validation checkingThe configuration for a Worker is complicated since we can define different "environments", and each environment can have its own configuration.
There is a default ("top-level") environment and then named environments that provide environment specific configuration.This is further complicated by the fact that there are three kinds of environment configuration:
- non-overridable: these values are defined once in the top-level configuration, apply to all environments and cannot be overridden by an environment.
- inheritable: these values can be defined at the top-level but can also be overridden by environment specific values.
Named environments do not need to provide their own values, in which case they inherit the value from the top-level. - non-inheritable: these values must be explicitly defined in each environment if they are defined at the top-level.
Named environments do not inherit such configuration and must provide their own values.
All configuration values in
wrangler.toml
are optional and will receive a default value if not defined.This change adds more strict interfaces for top-level
Config
andEnvironment
types,
as well as validation and normalization of the optional fields that are read fromwrangler.toml
. -
#486
ff8c9f6
Thanks @threepointone! - fix: remove warning if worker with a durable object doesn't have a nameWe were warning if you were trying to develop a durable object with an unnamed worker. Further, the internal api would actually throw if you tried to develop with a named worker if it wasn't already published. The latter is being fixed internally and should live soon, and this fix removes the warning completely.