Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Merge 09/12 merges to master into feat-kv-commands #580

Merged
merged 44 commits into from
Sep 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
4f519fe
Remove link to docs for installation because they link back to wrangl…
EverlastingBugstopper Aug 30, 2019
4c3f30a
Merge branch 'master' into avery/update-readme
EverlastingBugstopper Sep 3, 2019
4cf3f83
Merge branch 'master' into avery/update-readme
EverlastingBugstopper Sep 6, 2019
404cb16
Merge branch 'master' into avery/update-readme
EverlastingBugstopper Sep 9, 2019
e9c94c8
Add environment documentation to build, preview, and publish sections…
EverlastingBugstopper Sep 10, 2019
e81e122
md formatting newline
EverlastingBugstopper Sep 10, 2019
c36493e
Fix ordering of subdomain registration steps
EverlastingBugstopper Sep 10, 2019
ced3387
Break up publish targets into separate subheadings
EverlastingBugstopper Sep 10, 2019
33dbedf
Update prose based on Victoria's comments
EverlastingBugstopper Sep 10, 2019
d8e645e
Add period to end of install sentence
EverlastingBugstopper Sep 10, 2019
359e9b0
Merge branch 'master' into avery/update-readme
EverlastingBugstopper Sep 10, 2019
b96728d
Merge pull request #494 from cloudflare/avery/update-readme
EverlastingBugstopper Sep 11, 2019
a77779d
Merge branch 'master' into avery/environments-docs
EverlastingBugstopper Sep 11, 2019
a96f58c
Add namespaces to environments documentation
EverlastingBugstopper Sep 11, 2019
9a30d01
Fix indentation and clarify environments wording
EverlastingBugstopper Sep 11, 2019
3142b97
Update kv namespaces configuration documentation
EverlastingBugstopper Sep 11, 2019
c77b950
Add environment heading
EverlastingBugstopper Sep 11, 2019
6d5f11d
standardize to KV Namespace
EverlastingBugstopper Sep 11, 2019
9d2d0ab
Remove option 2 from kv namespace config docs
EverlastingBugstopper Sep 11, 2019
a9d91c3
Remove option 2 from env kv namespace config docs
EverlastingBugstopper Sep 11, 2019
758d432
give `e.g.` newline
ashleymichal Sep 11, 2019
5175f88
Remove e.g. and replace w for example
EverlastingBugstopper Sep 11, 2019
dcaf43b
Remove e.g. and replace w for example
EverlastingBugstopper Sep 11, 2019
089d324
Merge pull request #556 from cloudflare/avery/kv-docs
EverlastingBugstopper Sep 11, 2019
0483ef5
Merge branch 'master' into avery/environments-docs
EverlastingBugstopper Sep 11, 2019
9f8422b
Gabbis comments
EverlastingBugstopper Sep 11, 2019
c60e68f
Merge pull request #544 from cloudflare/avery/environments-docs
EverlastingBugstopper Sep 11, 2019
d2b103d
Add workers_dot_dev to test fixtures
EverlastingBugstopper Sep 12, 2019
826d00f
Rename to node test and add web test
EverlastingBugstopper Sep 12, 2019
a99480f
Merge pull request #564 from cloudflare/avery/rename-test
EverlastingBugstopper Sep 12, 2019
65926a3
Remove message from bundle cleanup helper
EverlastingBugstopper Sep 12, 2019
413bade
Merge pull request #563 from cloudflare/avery/env-tests
xtuc Sep 12, 2019
af0b722
Guard test against potential races
xtuc Sep 12, 2019
8688bc2
Merge branch 'master' into hotfix-guard-test
EverlastingBugstopper Sep 12, 2019
41c2154
Merge pull request #567 from cloudflare/hotfix-guard-test
EverlastingBugstopper Sep 12, 2019
e67b874
Change 'this command will fail' to 'this command may act unexpectedly
EverlastingBugstopper Sep 12, 2019
b9e7439
Update env docs to reflect message change
EverlastingBugstopper Sep 12, 2019
079ff6d
Replace my name with generic subdomain
EverlastingBugstopper Sep 12, 2019
122d587
Merge pull request #575 from cloudflare/avery/fix-1-5-0-message
EverlastingBugstopper Sep 12, 2019
7fb210d
Rename workers_dot_dev to workers_dev (#569)
EverlastingBugstopper Sep 12, 2019
d9dc914
fix merge conflicts
gabbifish Sep 12, 2019
44ea49f
fix merge conflicts from master
gabbifish Sep 12, 2019
9fa3e43
fix links
gabbifish Sep 12, 2019
737ce4a
oop! doubled up header!
gabbifish Sep 12, 2019
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
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,19 @@ General documentation surrounding workers development and using `wrangler` can b
wrangler subdomain <name>
```

After you have registered a subdomain, add `workers_dot_dev` to your `wrangler.toml`.
After you have registered a subdomain, add `workers_dev` to your `wrangler.toml`.

| Key | Value | Example |
| --------------- | ----- | ------------------------ |
| workers_dot_dev | true | `workers_dot_dev = true` |
| workers_dev | true | `workers_dev = true` |

#### Publishing to your own domain

If you would like to publish to your own domain, you will need to specify these three fields in your `wrangler.toml`.

| Key | Value | Example |
| --------------- | ---------------------------------------------------------------------- | ---------------------------------------------- |
| workers_dot_dev | false | `workers_dot_dev = false` |
| workers_dev | false | `workers_dev = false` |
| route | The route you would like to publish to | `route = "example.com/my-worker/*"` |
| zone_id | Your Cloudflare zone ID, this can be found in the Cloudflare dashboard | `zone_id = "b6558acaf2b4cad1f2b51c5236a6b972"` |

Expand Down Expand Up @@ -198,17 +198,17 @@ There are two types of configuration that `wrangler` uses: global user and per p
- `webpack`: This project contains any number of JavaScript files or Rust/C/C++ files that compile to
WebAssembly. Rust files will be built with `wasm-pack`.
This project type uses webpack and webpack plugins in the background to build your worker.
- `zone_id`: This is the ID of the "zone" or domain you want to run your script on. This is optional if you are using a [workers.dev](https://workers.dev) subdomain and is only required when `workers_dot_dev` is false, or excluded from an [environment](https://github.com/cloudflare/wrangler/blob/master/docs/environments.md) configuration.
- `zone_id`: This is the ID of the "zone" or domain you want to run your script on. This is optional if you are using a [workers.dev](https://workers.dev) subdomain and is only required when `workers_dev` is false, or excluded from an [environment](https://github.com/cloudflare/wrangler/blob/master/docs/environments.md) configuration.
- `account_id`: This is the ID of the account associated with your zone. You might have more than one account, so make sure to use the ID of the account associated with the `zone_id` you provide, if you provide one.
- `route`: This is the route you'd like to use your worker on. You need to include the hostname. Examples:

- `*example.com/*`
- `http://example.com/hello`

This key is optional if you are using a [workers.dev](https://workers.dev) subdomain and is only required when `workers_dot_dev` is false, or excluded from an [environment](https://github.com/cloudflare/wrangler/blob/master/docs/environments.md).
This key is optional if you are using a [workers.dev](https://workers.dev) subdomain and is only required when `workers_dev` is false, or excluded from an [environment](https://github.com/cloudflare/wrangler/blob/master/docs/environments.md).

- `webpack_config`: This is the path to the webpack configuration file for your worker. This is optional and defaults to `webpack.config.js`
- `workers_dot_dev`: This is a boolean flag that specifies if your worker will be deployed to your [workers.dev](https://workers.dev) subdomain. For more information, please read the [environments documentation](https://github.com/cloudflare/wrangler/blob/master/docs/environments.md).
- `workers_dev`: This is a boolean flag that specifies if your worker will be deployed to your [workers.dev](https://workers.dev) subdomain. For more information, please read the [environments documentation](https://github.com/cloudflare/wrangler/blob/master/docs/environments.md).
- `kv-namespaces`: These specify any [Workers KV](https://workers.cloudflare.com/docs/reference/storage/) Namespaces you want to access from
inside your Worker. Each namespace you include should have an entry in your `wrangler.toml` that includes:

Expand Down
64 changes: 32 additions & 32 deletions docs/content/environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ name = "my-worker-dev"
account_id = "12345678901234567890"
zone_id = "09876543210987654321"
route = "dev.example.com/*"
workers_dot_dev = false
workers_dev = false

# environment configuration
[env.staging]
Expand All @@ -34,7 +34,7 @@ route = "example.com/*"
The most common use case for environments is deploying to a staging subdomain before your production environment. `wrangler publish` will look at your top level configuration, and you can specify other environments beneath it. Each of these environments will inherit the values from the top level configuration if they are not specified, with the following caveats.

* `type` will always be inherited from the top-level configuration; you cannot specify different types for different environments.
* Fields that can be inherited from the top level are `account_id`, `zone_id`, `workers_dot_dev`, and `webpack_config`. `kv_namespaces` and `route` must be defined for each environment and will not be inherited.
* Fields that can be inherited from the top level are `account_id`, `zone_id`, `workers_dev`, and `webpack_config`. `kv_namespaces` and `route` must be defined for each environment and will not be inherited.
* `name` is inherited. If left out of the environment configuration, a Worker project named `my-worker` with an environment `[env.dev]` would become `my-worker-dev`.

### Examples
Expand All @@ -51,7 +51,7 @@ name = "my-worker"
account_id = "12345678901234567890"
zone_id = "09876543210987654321"
route = "example.com/*"
workers_dot_dev = false # this field specifies that the worker should not be deployed to workers.dev
workers_dev = false # this field specifies that the worker should not be deployed to workers.dev
```

```console
Expand All @@ -69,7 +69,7 @@ This `wrangler.toml` has no environments defined and will publish `my-worker` to
type = "webpack"
name = "my-worker"
account_id = "12345678901234567890"
workers_dot_dev = true # this field specifies that the worker should be deployed to workers.dev
workers_dev = true # this field specifies that the worker should be deployed to workers.dev
```

```console
Expand All @@ -89,7 +89,7 @@ name = "my-worker-dev"
account_id = "12345678901234567890"
zone_id = "09876543210987654321"
route = "dev.example.com/*"
workers_dot_dev = false
workers_dev = false

[env.staging]
name = "my-worker-staging"
Expand Down Expand Up @@ -127,18 +127,18 @@ $ wrangler publish --env production

#### Staging Environment with workers.dev

In order to deploy your code to workers.dev, you must include `workers_dot_dev = true` in the desired environment. Your `wrangler.toml` may look like this:
In order to deploy your code to workers.dev, you must include `workers_dev = true` in the desired environment. Your `wrangler.toml` may look like this:

```toml
name = "my-worker"
type = "webpack"
account_id = "12345678901234567890"
zone_id = "09876543210987654321"
route = "example.com/*"
workers_dot_dev = false
workers_dev = false

[env.staging]
workers_dot_dev = true
workers_dev = true
```

With this configuration, Wrangler will behave in the following manner:
Expand All @@ -165,7 +165,7 @@ If you only want to deploy to workers.dev you can configure Wrangler like so:
name = "my-worker-dev"
type = "webpack"
account_id = "12345678901234567890"
workers_dot_dev = true
workers_dev = true

[env.production]
name = "my-worker"
Expand Down Expand Up @@ -205,7 +205,7 @@ You can specify different webpack configurations for different environments.
name = "my-worker-dev"
type = "webpack"
account_id = "12345678901234567890"
workers_dot_dev = true
workers_dev = true
webpack_config = "webpack.dev.js"

[env.production]
Expand All @@ -226,7 +226,7 @@ You can specify different kv namespaces for different environments.
name = "my-worker"
type = "webpack"
account_id = "12345678901234567890"
workers_dot_dev = true
workers_dev = true
kv-namespaces = [
{ binding = "KV", id = "06779da6940b431db6e566b4846d64db" }
]
Expand All @@ -249,7 +249,7 @@ type = "webpack"
account_id = "12345678901234567890"
zone_id = "09876543210987654321"
route = "example.com/*"
workers_dot_dev = true
workers_dev = true

[env.staging]
type = "rust"
Expand All @@ -267,11 +267,11 @@ type = "webpack"
account_id = "12345678901234567890"
zone_id = "09876543210987654321"
route = "example.com/*"
workers_dot_dev = false
workers_dev = false

[env.staging]
name = "my-worker"
workers_dot_dev = true
workers_dev = true
```

```console
Expand All @@ -294,42 +294,42 @@ zone_id = "09876543210987654321"
route = "example.com/*
```

You will be warned if `workers_dot_dev` is left out of the top level configuration because if it is not specified, it is unclear what the behavior of `wrangler publish` should be. See [the section on backwards compatibility](#Backwards-compatibility) for more information.
You will be warned if `workers_dev` is left out of the top level configuration because if it is not specified, it is unclear what the behavior of `wrangler publish` should be. See [the section on backwards compatibility](#Backwards-compatibility) for more information.

```console
$ wrangler publish
⚠️ Please specify the workers_dot_dev boolean in the top level of your wrangler.toml.
⚠️ This command will fail in v1.5.0. Please see https://github.com/cloudflare/wrangler/blob/master/docs/content/environments.md for more information.
⚠️ Please specify the workers_dev boolean in the top level of your wrangler.toml.
⚠️ If you do not add workers_dev, this command may act unexpectedly in v1.5.0. Please see https://github.com/cloudflare/wrangler/blob/master/docs/content/environments.md for more information.
✨ Built successfully, built project size is 517 bytes.
✨ Successfully published your script.
✨ Success! Your worker was successfully published. You can view it at https://my-worker.avery.workers.dev
✨ Success! Your worker was successfully published. You can view it at https://my-worker.<your-subdomain>.workers.dev
```

### Defining workers_dot_dev and route
### Defining workers_dev and route

```toml
name = "my-worker"
type = "webpack"
account_id = "12345678901234567890"
zone_id = "09876543210987654321"
route = "example.com/*"
workers_dot_dev = true
workers_dev = true

[env.staging]
workers_dot_dev = true
workers_dev = true
route = "staging.example.com/*"
```

Wrangler will fail to publish to an environment where `route` is defined alongside `workers_dot_dev = true`.
Wrangler will fail to publish to an environment where `route` is defined alongside `workers_dev = true`.

```console
$ wrangler publish
Error: ⚠️ Your environment should only include `workers_dot_dev` or `route`. If you are trying to publish to workers.dev, remove `route` from your wrangler.toml, if you are trying to publish to your own domain, remove `workers_dot_dev`.
Error: ⚠️ Your environment should only include `workers_dev` or `route`. If you are trying to publish to workers.dev, remove `route` from your wrangler.toml, if you are trying to publish to your own domain, remove `workers_dev`.
```

```console
$ wrangler publish --env staging
Error: ⚠️ Your environment should only include `workers_dot_dev` or `route`. If you are trying to publish to workers.dev, remove `route` from your wrangler.toml, if you are trying to publish to your own domain, remove `workers_dot_dev`.
Error: ⚠️ Your environment should only include `workers_dev` or `route`. If you are trying to publish to workers.dev, remove `route` from your wrangler.toml, if you are trying to publish to your own domain, remove `workers_dev`.
```

## Backwards compatibility
Expand All @@ -353,9 +353,9 @@ With this configuration, Wrangler will behave in the following manner:

```console
$ wrangler publish
⚠️ The `private` field is deprecated; please use `workers_dot_dev` to toggle between publishing to your workers.dev subdomain and your own domain.
⚠️ Please specify the workers_dot_dev boolean in the top level of your wrangler.toml.
⚠️ This command will fail in v1.5.0. Please see https://github.com/cloudflare/wrangler/blob/master/docs/content/environments.md for more information.
⚠️ The `private` field is deprecated; please use `workers_dev` to toggle between publishing to your workers.dev subdomain and your own domain.
⚠️ Please specify the workers_dev boolean in the top level of your wrangler.toml.
⚠️ If you do not add workers_dev, this command may act unexpectedly in v1.5.0. Please see https://github.com/cloudflare/wrangler/blob/master/docs/content/environments.md for more information.
✨ Built successfully, built project size is 517 bytes.
✨ Successfully published your script.
✨ Success! Your worker was successfully published. You can view it at https://my-worker.<your-subdomain>.workers.dev
Expand All @@ -364,14 +364,14 @@ $ wrangler publish
```console
$ wrangler publish --release
⚠️ --release will be deprecated.
⚠️ The `private` field is deprecated; please use `workers_dot_dev` to toggle between publishing to your workers.dev subdomain and your own domain.
⚠️ Please specify the workers_dot_dev boolean in the top level of your wrangler.toml.
⚠️ This command will fail in v1.5.0. Please see https://github.com/cloudflare/wrangler/blob/master/docs/content/environments.md for more information.
⚠️ The `private` field is deprecated; please use `workers_dev` to toggle between publishing to your workers.dev subdomain and your own domain.
⚠️ Please specify the workers_dev boolean in the top level of your wrangler.toml.
⚠️ If you do not add workers_dev, this command may act unexpectedly in v1.5.0. Please see https://github.com/cloudflare/wrangler/blob/master/docs/content/environments.md for more information.
✨ Built successfully, built project size is 517 bytes.
✨ Successfully published your script.
✨ Success! Your worker was successfully published. You can view it at example.com/*
```

This backwards compatibility is the reason that a warning is thrown if `workers_dot_dev` is not specified at the top of `wrangler.toml`.
This backwards compatibility is the reason that a warning is thrown if `workers_dev` is not specified at the top of `wrangler.toml`.

It is important to note that both of these commands will issue a deprecation warning. To remove these warnings, you can configure Wrangler with the `workers_dot_dev` boolean to separate deploys to workers.dev from deploys to workers routes.
It is important to note that both of these commands will issue a deprecation warning. To remove these warnings, you can configure Wrangler with the `workers_dev` boolean to separate deploys to workers.dev from deploys to workers routes.
2 changes: 1 addition & 1 deletion docs/content/kv_commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ type = "webpack"
name = "my-worker"
account_id = "<account id here>"
route = "staging.example.com/*"
workers_dot_dev = false
workers_dev = false

kv-namespaces = [
{ binding = "KV", id = "06779da6940b431db6e566b4846d64db" }
Expand Down
3 changes: 0 additions & 3 deletions src/commands/build/wranglerjs/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ use std::io::prelude::*;
use std::path::{Path, PathBuf};

use crate::commands::build::wranglerjs::output::WranglerjsOutput;
#[cfg(test)]
use crate::terminal::message;

// Directory where we should write the {Bundle}. It represents the built
// artifact.
Expand Down Expand Up @@ -142,7 +140,6 @@ mod tests {
fn cleanup(name: String) {
let current_dir = env::current_dir().unwrap();
let path = Path::new(&current_dir).join(name);
message::info(&format!("p: {:?}", path));
fs::remove_dir_all(path).unwrap();
}
}
3 changes: 1 addition & 2 deletions src/commands/build/wranglerjs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ fn run_npm_install(dir: PathBuf) -> Result<(), failure::Error> {
info!("skipping npm install because node_modules exists");
}

// TODO(sven): figure out why the file doesn't exits in some cases? Even if
// the thread should have locked it.
// TODO(sven): figure out why the file doesn't exits in some cases?
if flock_path.exists() {
fs::remove_file(&flock_path)?;
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/kv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ mod tests {
route: None,
routes: None,
webpack_config: None,
workers_dot_dev: false,
workers_dev: false,
zone_id: None,
};
assert!(kv::get_namespace_id(&target_with_dup_kv_bindings, "").is_err());
Expand Down
6 changes: 3 additions & 3 deletions src/commands/publish/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::settings::target::Target;
use crate::terminal::{emoji, message};

pub fn publish(user: &GlobalUser, target: &Target) -> Result<(), failure::Error> {
info!("workers_dot_dev = {}", target.workers_dot_dev);
info!("workers_dev = {}", target.workers_dev);

validate_target(target)?;
commands::build(&target)?;
Expand Down Expand Up @@ -51,7 +51,7 @@ fn publish_script(user: &GlobalUser, target: &Target) -> Result<(), failure::Err
)
}

let pattern = if !target.workers_dot_dev {
let pattern = if !target.workers_dev {
let route = Route::new(&target)?;
Route::publish(&user, &target, &route)?;
info!("publishing to route");
Expand Down Expand Up @@ -127,7 +127,7 @@ fn validate_target(target: &Target) -> Result<(), failure::Error> {
None => {}
}

let destination = if !target.workers_dot_dev {
let destination = if !target.workers_dev {
// check required fields for release
if target
.zone_id
Expand Down
Loading