From ed2dc1e1a7f806a7cdc72dfbf7098e17e3efacfb Mon Sep 17 00:00:00 2001 From: Eric Ghildyal Date: Thu, 6 Nov 2025 23:38:29 +0100 Subject: [PATCH] Update Cloudflare guide and bump version in readme --- README.md | 2 +- guides/getting-started-cloudflare-workers.md | 81 ++++++++------------ 2 files changed, 32 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 9a7ef4e..a949942 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ brew install wack/tap/multi **Installing with curl:** ```sh -curl --proto '=https' --tlsv1.2 -LsSf https://github.com/wack/multitool/releases/download/v0.3.0/multitool-installer.sh | sh +curl --proto '=https' --tlsv1.2 -LsSf https://github.com/wack/multitool/releases/download/v0.3.4/multitool-installer.sh | sh ``` Check the [releases page](https://github.com/wack/canary/releases) for pre-built binaries, checksums, and guides to install on additional platforms. diff --git a/guides/getting-started-cloudflare-workers.md b/guides/getting-started-cloudflare-workers.md index 5270894..ee7e425 100644 --- a/guides/getting-started-cloudflare-workers.md +++ b/guides/getting-started-cloudflare-workers.md @@ -26,7 +26,7 @@ You will: - [ ] Cloudflare Wrangler CLI installed - - [ ] Create an Cloudflare API Token with Workers Observability - read and Workers Scripts - edit permissions. + - [ ] Create an Cloudflare API Token with `Workers Observability - read` and `Workers Scripts - edit` permissions. - [ ] Run `npx wrangler login` and follow the prompts to login to Cloudflare @@ -36,51 +36,26 @@ You will: ## ๐Ÿ—๏ธ Step 1: Create the Worker -Create a new "Hello World" Cloudflare Worker +Create a new "Hello World" Cloudflare Worker using [C3](https://developers.cloudflare.com/pages/get-started/c3/) and [our template](https://github.com/wack/multitool-cloudflare-quickstart) ```bash -npm create cloudflare@latest -- multitool-quickstart --type hello-world --lang js --no-git -y +npm create cloudflare@latest -- multitool-quickstart --template git@github.com:wack/multitool-cloudflare-quickstart.git --no-git ``` -## ๐Ÿ“ฆ Step 2: Create and package the Worker code - -This tutorial simulates two versions of a Worker: +This template contains two versions of a Worker: - A โ€œhealthyโ€ version that always returns a `200` HTTP status code - A โ€œbuggyโ€ version that randomly fails with a `400` HTTP status code 50% of the time -We'll overwrite the `index.js` file and add a new file for the buggy version: - -### Create the healthy version - -This version always returns a `200` HTTP status code response. - -```bash -cat << EOF > multitool-quickstart/src/index.js -export default { - async fetch(request, env, ctx) { - return new Response('Hello World!', { status: 200 }); - }, -}; -EOF -``` +## โš™๏ธ Step 2: Update variables -### Create the buggy version +You'll need to update some variables before we can deploy the worker: -This version introduces a simulated bug by returning a `400` HTTP status code 50% of the time. +In `wrangler.jsonc` update `MY_CLOUDFLARE_ACCOUNT_ID` to your cloudflare account number -```bash -cat << EOF > multitool-quickstart/src/index_errors.js -export default { - async fetch(request, env, ctx) { - const rand = Math.random(); - return new Response(rand < 0.5 ? 'Bad Request' : 'Hello World!', { status: rand < 0.5 ? 400 : 200 }); - }, -}; -EOF -``` +๐Ÿ“ **Note:** To get your Cloudflare Account ID, [follow the instructions here](https://developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/). -## โš™๏ธ Step 3: Deploy the worker +## โฌ†๏ธ Step 3: Deploy the worker Now that we added the updated code to our worker, let's deploy it. @@ -123,40 +98,40 @@ Now that the Worker is deployed and accessible via its URL, create the applicati From the MultiTool app: 1. Create a workspace -2. Create an application named `quickstart` +2. Create an application -After the application is set up, login to the MultiTool CLI if needed: +After the application is set up, login to the MultiTool CLI, if needed: ```bash multi login ``` -## โš™๏ธ Step 6: Add your configuration file - -Now that we have our workspace and app set up in the MultiTool app, we need to create a manfiest file called `MultiTool.toml` so the MultiTool CLI knows how to deploy your application. +## โš™๏ธ Step 6: Update your configuration file -If you used the sample values throughout this tutorial, you can use this file, but make sure to replace MY_WORKSPACE_NAME, and MY_CLOUDFLARE_ACCOUNT_ID with the correct values: +Now that we have our workspace and app set up in the MultiTool app, we need to update the manfiest file called `MultiTool.toml` so the MultiTool CLI knows how to deploy your application. -๐Ÿ“ **Note:** To get your Cloudflare Account ID, [follow the instructions here](https://developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/). +If you used the sample values throughout this tutorial, you can use this file, but make sure to replace MY_WORKSPACE_NAME and MY_APPLICATION_NAME: ```bash -cat << EOF > MultiTool.toml workspace = "MY_WORKSPACE_NAME" -application = "quickstart" +application = "MY_APPLICATION_NAME" [config.cloudflare] worker-name = "multitool-quickstart" -account-id = "MY_CLOUDFLARE_ACCOUNT_ID" -main-module = "index.ts" -artifact-path = "src/" -EOF +project-dir = "src/" ``` ## ๐Ÿš€ Step 7: Roll out healthy code and simulate stable traffic -๐Ÿ“ **Note:** Exiting the terminal before a CLI operation finishes can leave your rollout in a stuck state due to a known bug. Please wait for the operation to complete before closing the terminal. If you've already run into this issue, contact support@wack.run and weโ€™ll help resolve it. A fix is on the way. +๐Ÿ“ **Note:** Exiting the terminal before a CLI operation finishes can leave your rollout in a stuck state for a few minutes. Please wait for the operation to complete before closing the terminal. If you've already run into this issue, contact support@wack.run and weโ€™ll help resolve it. + +Ensure `index.ts` is set as the `main` value in your `wrangler.jsonc` file: -Start the rollout using `index.ts` as the `main-module` value in your `MultiTool.toml` file: +```json +"main": "src/index_errors.js", +``` + +Then start the rollout by running MultiTool: ```bash multi run --cloudflare-api-token $MY_CLOUDFLARE_TOKEN @@ -188,7 +163,13 @@ As traffic hits the new version, MultiTool will evaluate its behavior and promot To test a broken rollout, use the `index_errors.ts` file. -Start the rollout using `index_errors.ts` as the `main-module` value in your `MultiTool.toml` file: +Update the `main` value in your `wrangler.jsonc` file: + +```json +"main": "src/index_errors.js", +``` + +Then re-run MultiTool ```bash multi run --cloudflare-api-token $MY_CLOUDFLARE_TOKEN