From ba90d744922b31159a4d52e2cb5a84c760907d95 Mon Sep 17 00:00:00 2001 From: Rahul Sethi <5822355+RamIdeas@users.noreply.github.com> Date: Mon, 30 Sep 2024 16:57:25 +0100 Subject: [PATCH 1/6] wip --- packages/wrangler/how-to-bindings.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 packages/wrangler/how-to-bindings.md diff --git a/packages/wrangler/how-to-bindings.md b/packages/wrangler/how-to-bindings.md new file mode 100644 index 000000000000..c8cf1934f5fe --- /dev/null +++ b/packages/wrangler/how-to-bindings.md @@ -0,0 +1,15 @@ +# How to register a binding + +1. register wrangler.toml section in: packages/wrangler/src/config/environment.ts [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-c024f5de2a1dafa359fc46af77eef571b76b1fd11c800a202009daa7829bc8c4R757-R773) +1. register validation functions in: packages/wrangler/src/config/validation.ts [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-0ec779a40744e36b45a9b28dee06739afa8aa2f00bb9388b68556e7fd87ab99eR1447-R1456) [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-0ec779a40744e36b45a9b28dee06739afa8aa2f00bb9388b68556e7fd87ab99eR3117-R3149) +1. add empty state for binding everywhere typescript tells you +1. add type for deployment bundle to: + - CfWorkerInit in: packages/wrangler/src/deployment-bundle/worker.ts [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-8506c95c57e660444d7817667859954028b3f5089896ecfe29bd2fb6d1f215beR229-R233) + - WorkerMetadataBinding in: packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-f5add872789053bab9670e1b80475de151c770dff0f7018793818c4d92b81038R113) [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-f5add872789053bab9670e1b80475de151c770dff0f7018793818c4d92b81038R320-R327) +1. add user-friendly output for printBindings in: packages/wrangler/src/config/index.ts [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-80a0404f59f781e58a6e6892e5457ca6bd1c7b7e5687155159bde57f6cc65452R447-R456) +1. add mapping functions to: + - createWorkerUploadForm in: packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-f5add872789053bab9670e1b80475de151c770dff0f7018793818c4d92b81038R320-R327) + - convertCfWorkerInitBindingstoBindings in: packages/wrangler/src/api/startDevWorker/utils.ts [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-9c39e489b2145dc4a898e07dd679a30abb956239f4e70f9c4d2ed6075f5fb7f0R247-R252) + - convertBindingsToCfWorkerInitBindings in: packages/wrangler/src/api/startDevWorker/utils.ts [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-9c39e489b2145dc4a898e07dd679a30abb956239f4e70f9c4d2ed6075f5fb7f0R367-R369) +1. test binding is deployed + printed in: packages/wrangler/src/**tests**/deploy.test.ts [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-81706a80fd0b3a4bce16ab020267448ff21ad04a71e22802937633c3080dffbfR10469-R10509) +1. test your validation in: packages/wrangler/src/**tests**/configuration.test.ts [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-6bc0db7244bb7b5515bba8027b3a8dca71c2cdf4fd976b65b0d76cebc06ad896R3185-R3292) From 85cbb796b24442c787041f008089829b7991e2e4 Mon Sep 17 00:00:00 2001 From: Rahul Sethi <5822355+RamIdeas@users.noreply.github.com> Date: Mon, 30 Sep 2024 16:58:47 +0100 Subject: [PATCH 2/6] update --- packages/wrangler/how-to-bindings.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/wrangler/how-to-bindings.md b/packages/wrangler/how-to-bindings.md index c8cf1934f5fe..9745d5b97de0 100644 --- a/packages/wrangler/how-to-bindings.md +++ b/packages/wrangler/how-to-bindings.md @@ -1,15 +1,15 @@ # How to register a binding -1. register wrangler.toml section in: packages/wrangler/src/config/environment.ts [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-c024f5de2a1dafa359fc46af77eef571b76b1fd11c800a202009daa7829bc8c4R757-R773) -1. register validation functions in: packages/wrangler/src/config/validation.ts [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-0ec779a40744e36b45a9b28dee06739afa8aa2f00bb9388b68556e7fd87ab99eR1447-R1456) [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-0ec779a40744e36b45a9b28dee06739afa8aa2f00bb9388b68556e7fd87ab99eR3117-R3149) +1. register wrangler.toml section in: packages/wrangler/src/config/environment.ts [ref](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-c024f5de2a1dafa359fc46af77eef571b76b1fd11c800a202009daa7829bc8c4R757-R773) +1. register validation functions in: packages/wrangler/src/config/validation.ts [ref-1](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-0ec779a40744e36b45a9b28dee06739afa8aa2f00bb9388b68556e7fd87ab99eR1447-R1456) [ref-2](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-0ec779a40744e36b45a9b28dee06739afa8aa2f00bb9388b68556e7fd87ab99eR3117-R3149) 1. add empty state for binding everywhere typescript tells you 1. add type for deployment bundle to: - - CfWorkerInit in: packages/wrangler/src/deployment-bundle/worker.ts [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-8506c95c57e660444d7817667859954028b3f5089896ecfe29bd2fb6d1f215beR229-R233) - - WorkerMetadataBinding in: packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-f5add872789053bab9670e1b80475de151c770dff0f7018793818c4d92b81038R113) [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-f5add872789053bab9670e1b80475de151c770dff0f7018793818c4d92b81038R320-R327) -1. add user-friendly output for printBindings in: packages/wrangler/src/config/index.ts [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-80a0404f59f781e58a6e6892e5457ca6bd1c7b7e5687155159bde57f6cc65452R447-R456) + - CfWorkerInit in: packages/wrangler/src/deployment-bundle/worker.ts [ref](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-8506c95c57e660444d7817667859954028b3f5089896ecfe29bd2fb6d1f215beR229-R233) + - WorkerMetadataBinding in: packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts [ref-1](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-f5add872789053bab9670e1b80475de151c770dff0f7018793818c4d92b81038R113) [ref-2](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-f5add872789053bab9670e1b80475de151c770dff0f7018793818c4d92b81038R320-R327) +1. add user-friendly output for printBindings in: packages/wrangler/src/config/index.ts [ref](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-80a0404f59f781e58a6e6892e5457ca6bd1c7b7e5687155159bde57f6cc65452R447-R456) 1. add mapping functions to: - - createWorkerUploadForm in: packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-f5add872789053bab9670e1b80475de151c770dff0f7018793818c4d92b81038R320-R327) - - convertCfWorkerInitBindingstoBindings in: packages/wrangler/src/api/startDevWorker/utils.ts [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-9c39e489b2145dc4a898e07dd679a30abb956239f4e70f9c4d2ed6075f5fb7f0R247-R252) - - convertBindingsToCfWorkerInitBindings in: packages/wrangler/src/api/startDevWorker/utils.ts [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-9c39e489b2145dc4a898e07dd679a30abb956239f4e70f9c4d2ed6075f5fb7f0R367-R369) -1. test binding is deployed + printed in: packages/wrangler/src/**tests**/deploy.test.ts [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-81706a80fd0b3a4bce16ab020267448ff21ad04a71e22802937633c3080dffbfR10469-R10509) -1. test your validation in: packages/wrangler/src/**tests**/configuration.test.ts [example](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-6bc0db7244bb7b5515bba8027b3a8dca71c2cdf4fd976b65b0d76cebc06ad896R3185-R3292) + - createWorkerUploadForm in: packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts [ref](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-f5add872789053bab9670e1b80475de151c770dff0f7018793818c4d92b81038R320-R327) + - convertCfWorkerInitBindingstoBindings in: packages/wrangler/src/api/startDevWorker/utils.ts [ref](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-9c39e489b2145dc4a898e07dd679a30abb956239f4e70f9c4d2ed6075f5fb7f0R247-R252) + - convertBindingsToCfWorkerInitBindings in: packages/wrangler/src/api/startDevWorker/utils.ts [ref](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-9c39e489b2145dc4a898e07dd679a30abb956239f4e70f9c4d2ed6075f5fb7f0R367-R369) +1. test binding is deployed + printed in: packages/wrangler/src/**tests**/deploy.test.ts [ref](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-81706a80fd0b3a4bce16ab020267448ff21ad04a71e22802937633c3080dffbfR10469-R10509) +1. test your validation in: packages/wrangler/src/**tests**/configuration.test.ts [ref](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-6bc0db7244bb7b5515bba8027b3a8dca71c2cdf4fd976b65b0d76cebc06ad896R3185-R3292) From 1970d22371c67aa7fc8c485b8a4866421d5c1074 Mon Sep 17 00:00:00 2001 From: Rahul Sethi <5822355+RamIdeas@users.noreply.github.com> Date: Mon, 30 Sep 2024 17:49:18 +0100 Subject: [PATCH 3/6] pipelines ref -> kv ref --- packages/wrangler/how-to-bindings.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/wrangler/how-to-bindings.md b/packages/wrangler/how-to-bindings.md index 9745d5b97de0..213687246bde 100644 --- a/packages/wrangler/how-to-bindings.md +++ b/packages/wrangler/how-to-bindings.md @@ -1,15 +1,15 @@ # How to register a binding -1. register wrangler.toml section in: packages/wrangler/src/config/environment.ts [ref](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-c024f5de2a1dafa359fc46af77eef571b76b1fd11c800a202009daa7829bc8c4R757-R773) -1. register validation functions in: packages/wrangler/src/config/validation.ts [ref-1](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-0ec779a40744e36b45a9b28dee06739afa8aa2f00bb9388b68556e7fd87ab99eR1447-R1456) [ref-2](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-0ec779a40744e36b45a9b28dee06739afa8aa2f00bb9388b68556e7fd87ab99eR3117-R3149) -1. add empty state for binding everywhere typescript tells you -1. add type for deployment bundle to: - - CfWorkerInit in: packages/wrangler/src/deployment-bundle/worker.ts [ref](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-8506c95c57e660444d7817667859954028b3f5089896ecfe29bd2fb6d1f215beR229-R233) - - WorkerMetadataBinding in: packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts [ref-1](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-f5add872789053bab9670e1b80475de151c770dff0f7018793818c4d92b81038R113) [ref-2](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-f5add872789053bab9670e1b80475de151c770dff0f7018793818c4d92b81038R320-R327) -1. add user-friendly output for printBindings in: packages/wrangler/src/config/index.ts [ref](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-80a0404f59f781e58a6e6892e5457ca6bd1c7b7e5687155159bde57f6cc65452R447-R456) -1. add mapping functions to: - - createWorkerUploadForm in: packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts [ref](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-f5add872789053bab9670e1b80475de151c770dff0f7018793818c4d92b81038R320-R327) - - convertCfWorkerInitBindingstoBindings in: packages/wrangler/src/api/startDevWorker/utils.ts [ref](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-9c39e489b2145dc4a898e07dd679a30abb956239f4e70f9c4d2ed6075f5fb7f0R247-R252) - - convertBindingsToCfWorkerInitBindings in: packages/wrangler/src/api/startDevWorker/utils.ts [ref](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-9c39e489b2145dc4a898e07dd679a30abb956239f4e70f9c4d2ed6075f5fb7f0R367-R369) -1. test binding is deployed + printed in: packages/wrangler/src/**tests**/deploy.test.ts [ref](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-81706a80fd0b3a4bce16ab020267448ff21ad04a71e22802937633c3080dffbfR10469-R10509) -1. test your validation in: packages/wrangler/src/**tests**/configuration.test.ts [ref](https://github.com/cloudflare/workers-sdk/pull/6651/files#diff-6bc0db7244bb7b5515bba8027b3a8dca71c2cdf4fd976b65b0d76cebc06ad896R3185-R3292) +1. Register wrangler.toml section in: `packages/wrangler/src/config/environment.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/config/environment.ts#L431-L451) +1. Register validation functions in: `packages/wrangler/src/config/validation.ts` [ref-1](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/config/validation.ts#L1297-L1306) +1. Add empty state for binding everywhere typescript tells you (use your editor to find errors, or run: `pnpm check:type` from within `packages/wrangler`) +1. Add type for deployment bundle to: + - `CfWorkerInit` in: `packages/wrangler/src/deployment-bundle/worker.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/deployment-bundle/worker.ts#L79C1-L85C2) + - `WorkerMetadataBinding` in: `packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts` [ref-1](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts#L65) [ref-2](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts#L219-L225) +1. Add user-friendly output for printBindings in: `packages/wrangler/src/config/index.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/config/index.ts#L270-L280) +1. Add mapping functions to: + - `createWorkerUploadForm` in: `packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts#L219-L225) + - `convertCfWorkerInitBindingstoBindings` in: `packages/wrangler/src/api/startDevWorker/utils.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/api/startDevWorker/utils.ts#L118-L123) + - `convertBindingsToCfWorkerInitBindings` in: `packages/wrangler/src/api/startDevWorker/utils.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/api/startDevWorker/utils.ts#L303-L305) +1. Test binding is deployed + printed in: `packages/wrangler/src/**tests**/deploy.test.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/__tests__/deploy.test.ts#L7604) +1. Test your validation in: `packages/wrangler/src/**tests**/configuration.test.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/__tests__/configuration.test.ts#L2234) From a02a88e9840e5570567856ebbc31b4f477da02fe Mon Sep 17 00:00:00 2001 From: Rahul Sethi <5822355+RamIdeas@users.noreply.github.com> Date: Mon, 30 Sep 2024 18:14:41 +0100 Subject: [PATCH 4/6] address feedback --- packages/wrangler/how-to-bindings.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/wrangler/how-to-bindings.md b/packages/wrangler/how-to-bindings.md index 213687246bde..a0f05de50def 100644 --- a/packages/wrangler/how-to-bindings.md +++ b/packages/wrangler/how-to-bindings.md @@ -6,6 +6,7 @@ 1. Add type for deployment bundle to: - `CfWorkerInit` in: `packages/wrangler/src/deployment-bundle/worker.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/deployment-bundle/worker.ts#L79C1-L85C2) - `WorkerMetadataBinding` in: `packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts` [ref-1](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts#L65) [ref-2](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts#L219-L225) +1. Add type to DevEnv Binding union in: `packages/wrangler/src/api/startDevWorker/types.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/api/startDevWorker/types.ts#L246) 1. Add user-friendly output for printBindings in: `packages/wrangler/src/config/index.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/config/index.ts#L270-L280) 1. Add mapping functions to: - `createWorkerUploadForm` in: `packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts#L219-L225) @@ -13,3 +14,5 @@ - `convertBindingsToCfWorkerInitBindings` in: `packages/wrangler/src/api/startDevWorker/utils.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/api/startDevWorker/utils.ts#L303-L305) 1. Test binding is deployed + printed in: `packages/wrangler/src/**tests**/deploy.test.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/__tests__/deploy.test.ts#L7604) 1. Test your validation in: `packages/wrangler/src/**tests**/configuration.test.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/__tests__/configuration.test.ts#L2234) +1. Enable `wrangler init --from-dash` to include your binding in the wrangler.toml it generates in: `packages/wrangler/src/init.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/init.ts#L1036-L1043) +1. Enable `wrangler types` to emit your binding type in: `packages/src/type-generation/index.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/type-generation/index.ts#L115) From cf91f928429dbfaf70ffd6df03eaa5a387f93c59 Mon Sep 17 00:00:00 2001 From: Rahul Sethi <5822355+RamIdeas@users.noreply.github.com> Date: Wed, 16 Oct 2024 15:53:49 +0100 Subject: [PATCH 5/6] mv to docs/how-to --- .../wrangler/{how-to-bindings.md => docs/how-to/add-a-binding.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/wrangler/{how-to-bindings.md => docs/how-to/add-a-binding.md} (100%) diff --git a/packages/wrangler/how-to-bindings.md b/packages/wrangler/docs/how-to/add-a-binding.md similarity index 100% rename from packages/wrangler/how-to-bindings.md rename to packages/wrangler/docs/how-to/add-a-binding.md From d91f6158c6ed0112a85e4c2d5c76dfc5c13077cb Mon Sep 17 00:00:00 2001 From: Rahul Sethi <5822355+RamIdeas@users.noreply.github.com> Date: Thu, 17 Oct 2024 12:11:07 +0100 Subject: [PATCH 6/6] address feedback --- packages/wrangler/docs/how-to/add-a-binding.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/wrangler/docs/how-to/add-a-binding.md b/packages/wrangler/docs/how-to/add-a-binding.md index a0f05de50def..45d06ff3411e 100644 --- a/packages/wrangler/docs/how-to/add-a-binding.md +++ b/packages/wrangler/docs/how-to/add-a-binding.md @@ -1,18 +1,18 @@ # How to register a binding -1. Register wrangler.toml section in: `packages/wrangler/src/config/environment.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/config/environment.ts#L431-L451) -1. Register validation functions in: `packages/wrangler/src/config/validation.ts` [ref-1](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/config/validation.ts#L1297-L1306) -1. Add empty state for binding everywhere typescript tells you (use your editor to find errors, or run: `pnpm check:type` from within `packages/wrangler`) +1. Register `wrangler.toml` section in: `packages/wrangler/src/config/environment.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/config/environment.ts#L431-L451) +1. Register validation functions in: `packages/wrangler/src/config/validation.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/config/validation.ts#L1297-L1306) +1. Add empty state for bindings, as necessary (tip: use typescript to guide you -- either via your editor or run: `pnpm check:type` from within `packages/wrangler`) 1. Add type for deployment bundle to: - `CfWorkerInit` in: `packages/wrangler/src/deployment-bundle/worker.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/deployment-bundle/worker.ts#L79C1-L85C2) - `WorkerMetadataBinding` in: `packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts` [ref-1](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts#L65) [ref-2](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts#L219-L225) -1. Add type to DevEnv Binding union in: `packages/wrangler/src/api/startDevWorker/types.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/api/startDevWorker/types.ts#L246) -1. Add user-friendly output for printBindings in: `packages/wrangler/src/config/index.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/config/index.ts#L270-L280) +1. Add type to DevEnv `Binding` union in: `packages/wrangler/src/api/startDevWorker/types.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/api/startDevWorker/types.ts#L246) +1. Add user-friendly output for `printBindings` in: `packages/wrangler/src/config/index.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/config/index.ts#L270-L280) 1. Add mapping functions to: - `createWorkerUploadForm` in: `packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts#L219-L225) - `convertCfWorkerInitBindingstoBindings` in: `packages/wrangler/src/api/startDevWorker/utils.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/api/startDevWorker/utils.ts#L118-L123) - `convertBindingsToCfWorkerInitBindings` in: `packages/wrangler/src/api/startDevWorker/utils.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/api/startDevWorker/utils.ts#L303-L305) -1. Test binding is deployed + printed in: `packages/wrangler/src/**tests**/deploy.test.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/__tests__/deploy.test.ts#L7604) +1. Test binding is deployed and printed in: `packages/wrangler/src/**tests**/deploy.test.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/__tests__/deploy.test.ts#L7604) 1. Test your validation in: `packages/wrangler/src/**tests**/configuration.test.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/__tests__/configuration.test.ts#L2234) -1. Enable `wrangler init --from-dash` to include your binding in the wrangler.toml it generates in: `packages/wrangler/src/init.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/init.ts#L1036-L1043) +1. Enable `wrangler init --from-dash` to include your binding in the `wrangler.toml` it generates in: `packages/wrangler/src/init.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/init.ts#L1036-L1043) 1. Enable `wrangler types` to emit your binding type in: `packages/src/type-generation/index.ts` [ref](https://github.com/cloudflare/workers-sdk/blob/ce7db9d9cb4f5bcd5a326b86dde051cb54b999fb/packages/wrangler/src/type-generation/index.ts#L115)