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

rename: worker_namespaces / dispatch_namespaces #1725

Merged
merged 1 commit into from
Aug 23, 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
7 changes: 7 additions & 0 deletions .changeset/eleven-moons-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"wrangler": patch
---

rename: `worker_namespaces` / `dispatch_namespaces`

The Worker-for-Platforms team would like to rename this field to more closely match what it's called internally. This fix does a search+replace on this term. This feature already had an experimental warning, and no one's using it at the moment, so we're not going to add a warning/backward compat for existing customers.
9 changes: 5 additions & 4 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ packages/wrangler/emitted-types/
packages/wrangler/coverage/
packages/wrangler/CHANGELOG.md
packages/jest-environment-wrangler/CHANGELOG.md
packages/examples/worker-app/dist/
packages/examples/remix-pages-app/build
packages/examples/remix-pages-app/public/
packages/prerelease-registry/_worker.js
packages/jest-environment-wrangler/dist/
packages/wranglerjs-compat-webpack-plugin/lib
packages/wrangler-devtools/built-devtools
fixtures/pages-plugin-example/index.js
fixtures/remix-pages-app/build/
fixtures/remix-pages-app/public/build/
fixtures/remix-pages-app/public/build/
fixtures/worker-app/dist/
fixtures/remix-pages-app/build
fixtures/remix-pages-app/public/
fixtures/pages-functions-app/public/
54 changes: 27 additions & 27 deletions packages/wrangler/src/__tests__/configuration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe("normalizeAndValidateConfig()", () => {
unsafe: {
bindings: [],
},
worker_namespaces: [],
dispatch_namespaces: [],
usage_model: undefined,
vars: {},
define: {},
Expand Down Expand Up @@ -1913,11 +1913,11 @@ describe("normalizeAndValidateConfig()", () => {
});
});

describe("[worker_namespaces]", () => {
it("should log an experimental warning when worker_namespaces is used", () => {
describe("[dispatch_namespaces]", () => {
it("should log an experimental warning when dispatch_namespaces is used", () => {
const { config, diagnostics } = normalizeAndValidateConfig(
{
worker_namespaces: [
dispatch_namespaces: [
{
binding: "BINDING_1",
namespace: "NAMESPACE_1",
Expand All @@ -1928,62 +1928,62 @@ describe("normalizeAndValidateConfig()", () => {
{ env: undefined }
);
expect(config).toEqual(
expect.not.objectContaining({ worker_namespaces: expect.anything })
expect.not.objectContaining({ dispatch_namespaces: expect.anything })
);
expect(diagnostics.hasWarnings()).toBe(true);
expect(diagnostics.hasErrors()).toBe(false);
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
"Processing wrangler configuration:
- \\"worker_namespaces\\" fields are experimental and may change or break at any time."
- \\"dispatch_namespaces\\" fields are experimental and may change or break at any time."
`);
});

it("should error if worker_namespaces is not an array", () => {
it("should error if dispatch_namespaces is not an array", () => {
const { config, diagnostics } = normalizeAndValidateConfig(
{
worker_namespaces: "just a string",
dispatch_namespaces: "just a string",
} as unknown as RawConfig,
undefined,
{ env: undefined }
);

expect(config).toEqual(
expect.not.objectContaining({ worker_namespaces: expect.anything })
expect.not.objectContaining({ dispatch_namespaces: expect.anything })
);
expect(diagnostics.hasWarnings()).toBe(true);
expect(diagnostics.hasErrors()).toBe(true);
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
"Processing wrangler configuration:
- \\"worker_namespaces\\" fields are experimental and may change or break at any time."
- \\"dispatch_namespaces\\" fields are experimental and may change or break at any time."
`);
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
"Processing wrangler configuration:
- The field \\"worker_namespaces\\" should be an array but got \\"just a string\\"."
- The field \\"dispatch_namespaces\\" should be an array but got \\"just a string\\"."
`);
});

it("should error on non valid worker_namespaces", () => {
it("should error on non valid dispatch_namespaces", () => {
const { config, diagnostics } = normalizeAndValidateConfig(
{
worker_namespaces: [
dispatch_namespaces: [
"a string",
123,
{
binding: 123,
namespace: 456,
},
{
binding: "WORKER_NAMESPACE_BINDING_1",
binding: "DISPATCH_NAMESPACE_BINDING_1",
namespace: 456,
},
// this one is valid
{
binding: "WORKER_NAMESPACE_BINDING_1",
namespace: "WORKER_NAMESPACE_BINDING_NAMESPACE_1",
binding: "DISPATCH_NAMESPACE_BINDING_1",
namespace: "DISPATCH_NAMESPACE_BINDING_NAMESPACE_1",
},
{
binding: 123,
namespace: "WORKER_NAMESPACE_BINDING_SERVICE_1",
namespace: "DISPATCH_NAMESPACE_BINDING_SERVICE_1",
},
{
binding: 123,
Expand All @@ -1996,25 +1996,25 @@ describe("normalizeAndValidateConfig()", () => {
);
expect(config).toEqual(
expect.not.objectContaining({
worker_namespaces: expect.anything,
dispatch_namespaces: expect.anything,
})
);
expect(diagnostics.hasWarnings()).toBe(true);
expect(diagnostics.hasErrors()).toBe(true);
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
"Processing wrangler configuration:
- \\"worker_namespaces\\" fields are experimental and may change or break at any time."
- \\"dispatch_namespaces\\" fields are experimental and may change or break at any time."
`);
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
"Processing wrangler configuration:
- \\"worker_namespaces[0]\\" binding should be objects, but got \\"a string\\"
- \\"worker_namespaces[1]\\" binding should be objects, but got 123
- \\"worker_namespaces[2]\\" should have a string \\"binding\\" field but got {\\"binding\\":123,\\"namespace\\":456}.
- \\"worker_namespaces[2]\\" should have a string \\"namespace\\" field but got {\\"binding\\":123,\\"namespace\\":456}.
- \\"worker_namespaces[3]\\" should have a string \\"namespace\\" field but got {\\"binding\\":\\"WORKER_NAMESPACE_BINDING_1\\",\\"namespace\\":456}.
- \\"worker_namespaces[5]\\" should have a string \\"binding\\" field but got {\\"binding\\":123,\\"namespace\\":\\"WORKER_NAMESPACE_BINDING_SERVICE_1\\"}.
- \\"worker_namespaces[6]\\" should have a string \\"binding\\" field but got {\\"binding\\":123,\\"service\\":456}.
- \\"worker_namespaces[6]\\" should have a string \\"namespace\\" field but got {\\"binding\\":123,\\"service\\":456}."
- \\"dispatch_namespaces[0]\\" binding should be objects, but got \\"a string\\"
- \\"dispatch_namespaces[1]\\" binding should be objects, but got 123
- \\"dispatch_namespaces[2]\\" should have a string \\"binding\\" field but got {\\"binding\\":123,\\"namespace\\":456}.
- \\"dispatch_namespaces[2]\\" should have a string \\"namespace\\" field but got {\\"binding\\":123,\\"namespace\\":456}.
- \\"dispatch_namespaces[3]\\" should have a string \\"namespace\\" field but got {\\"binding\\":\\"DISPATCH_NAMESPACE_BINDING_1\\",\\"namespace\\":456}.
- \\"dispatch_namespaces[5]\\" should have a string \\"binding\\" field but got {\\"binding\\":123,\\"namespace\\":\\"DISPATCH_NAMESPACE_BINDING_SERVICE_1\\"}.
- \\"dispatch_namespaces[6]\\" should have a string \\"binding\\" field but got {\\"binding\\":123,\\"service\\":456}.
- \\"dispatch_namespaces[6]\\" should have a string \\"namespace\\" field but got {\\"binding\\":123,\\"service\\":456}."
`);
});
});
Expand Down
60 changes: 30 additions & 30 deletions packages/wrangler/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ describe("wrangler", () => {
"wrangler

Commands:
wrangler init [name] 📥 Create a wrangler.toml configuration file
wrangler dev [script] 👂 Start a local server for developing your worker
wrangler publish [script] 🆙 Publish your Worker to Cloudflare.
wrangler tail [worker] 🦚 Starts a log tailing session for a published Worker.
wrangler secret 🤫 Generate a secret that can be referenced in a Worker
wrangler kv:namespace 🗂️ Interact with your Workers KV Namespaces
wrangler kv:key 🔑 Individually manage Workers KV key-value pairs
wrangler kv:bulk 💪 Interact with multiple Workers KV key-value pairs at once
wrangler pages ⚡️ Configure Cloudflare Pages
wrangler r2 📦 Interact with an R2 store
wrangler worker-namespace 📦 Interact with a worker namespace
wrangler pubsub 📮 Interact and manage Pub/Sub Brokers
wrangler login 🔓 Login to Cloudflare
wrangler logout 🚪 Logout from Cloudflare
wrangler whoami 🕵️ Retrieve your user info and test your auth config
wrangler init [name] 📥 Create a wrangler.toml configuration file
wrangler dev [script] 👂 Start a local server for developing your worker
wrangler publish [script] 🆙 Publish your Worker to Cloudflare.
wrangler tail [worker] 🦚 Starts a log tailing session for a published Worker.
wrangler secret 🤫 Generate a secret that can be referenced in a Worker
wrangler kv:namespace 🗂️ Interact with your Workers KV Namespaces
wrangler kv:key 🔑 Individually manage Workers KV key-value pairs
wrangler kv:bulk 💪 Interact with multiple Workers KV key-value pairs at once
wrangler pages ⚡️ Configure Cloudflare Pages
wrangler r2 📦 Interact with an R2 store
wrangler dispatch-namespace 📦 Interact with a dispatch namespace
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this intentionally vague?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's an experimental feature, so it's not super documented or widely available yet. I suspect this will change a little in the future, so it's fine for now?

wrangler pubsub 📮 Interact and manage Pub/Sub Brokers
wrangler login 🔓 Login to Cloudflare
wrangler logout 🚪 Logout from Cloudflare
wrangler whoami 🕵️ Retrieve your user info and test your auth config

Flags:
-c, --config Path to .toml configuration file [string]
Expand All @@ -70,21 +70,21 @@ describe("wrangler", () => {
wrangler

Commands:
wrangler init [name] 📥 Create a wrangler.toml configuration file
wrangler dev [script] 👂 Start a local server for developing your worker
wrangler publish [script] 🆙 Publish your Worker to Cloudflare.
wrangler tail [worker] 🦚 Starts a log tailing session for a published Worker.
wrangler secret 🤫 Generate a secret that can be referenced in a Worker
wrangler kv:namespace 🗂️ Interact with your Workers KV Namespaces
wrangler kv:key 🔑 Individually manage Workers KV key-value pairs
wrangler kv:bulk 💪 Interact with multiple Workers KV key-value pairs at once
wrangler pages ⚡️ Configure Cloudflare Pages
wrangler r2 📦 Interact with an R2 store
wrangler worker-namespace 📦 Interact with a worker namespace
wrangler pubsub 📮 Interact and manage Pub/Sub Brokers
wrangler login 🔓 Login to Cloudflare
wrangler logout 🚪 Logout from Cloudflare
wrangler whoami 🕵️ Retrieve your user info and test your auth config
wrangler init [name] 📥 Create a wrangler.toml configuration file
wrangler dev [script] 👂 Start a local server for developing your worker
wrangler publish [script] 🆙 Publish your Worker to Cloudflare.
wrangler tail [worker] 🦚 Starts a log tailing session for a published Worker.
wrangler secret 🤫 Generate a secret that can be referenced in a Worker
wrangler kv:namespace 🗂️ Interact with your Workers KV Namespaces
wrangler kv:key 🔑 Individually manage Workers KV key-value pairs
wrangler kv:bulk 💪 Interact with multiple Workers KV key-value pairs at once
wrangler pages ⚡️ Configure Cloudflare Pages
wrangler r2 📦 Interact with an R2 store
wrangler dispatch-namespace 📦 Interact with a dispatch namespace
wrangler pubsub 📮 Interact and manage Pub/Sub Brokers
wrangler login 🔓 Login to Cloudflare
wrangler logout 🚪 Logout from Cloudflare
wrangler whoami 🕵️ Retrieve your user info and test your auth config

Flags:
-c, --config Path to .toml configuration file [string]
Expand Down
10 changes: 5 additions & 5 deletions packages/wrangler/src/__tests__/publish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5514,10 +5514,10 @@ addEventListener('fetch', event => {});`
});
});

describe("[worker_namespaces]", () => {
it("should support bindings to a worker namespace", async () => {
describe("[dispatch_namespaces]", () => {
it("should support bindings to a dispatch namespace", async () => {
writeWranglerToml({
worker_namespaces: [
dispatch_namespaces: [
{
binding: "foo",
namespace: "Foo",
Expand All @@ -5538,7 +5538,7 @@ addEventListener('fetch', event => {});`
await runWrangler("publish index.js");
expect(std.out).toMatchInlineSnapshot(`
"Your worker has access to the following bindings:
- Worker Namespaces:
- dispatch namespaces:
- foo: Foo
Total Upload: 0xx KiB / gzip: 0xx KiB
Uploaded test-name (TIMINGS)
Expand All @@ -5549,7 +5549,7 @@ addEventListener('fetch', event => {});`
expect(std.warn).toMatchInlineSnapshot(`
"▲ [WARNING] Processing wrangler.toml configuration:

- \\"worker_namespaces\\" fields are experimental and may change or break at any time.
- \\"dispatch_namespaces\\" fields are experimental and may change or break at any time.

"
`);
Expand Down
Loading