Skip to content

Commit ed2dc1e

Browse files
committed
Update Cloudflare guide and bump version in readme
1 parent 0e3dd3f commit ed2dc1e

File tree

2 files changed

+32
-51
lines changed

2 files changed

+32
-51
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ brew install wack/tap/multi
3737
**Installing with curl:**
3838

3939
```sh
40-
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/wack/multitool/releases/download/v0.3.0/multitool-installer.sh | sh
40+
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/wack/multitool/releases/download/v0.3.4/multitool-installer.sh | sh
4141
```
4242

4343
Check the [releases page](https://github.com/wack/canary/releases) for pre-built binaries, checksums, and guides to install on additional platforms.

guides/getting-started-cloudflare-workers.md

Lines changed: 31 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ You will:
2626

2727
- [ ] <a href="https://developers.cloudflare.com/workers/wrangler/install-and-update/" target="_blank">Cloudflare Wrangler CLI installed</a>
2828

29-
- [ ] Create an <a href="https://developers.cloudflare.com/fundamentals/api/get-started/create-token/" target="_blank">Cloudflare API Token</a> with Workers Observability - read and Workers Scripts - edit permissions.
29+
- [ ] Create an <a href="https://developers.cloudflare.com/fundamentals/api/get-started/create-token/" target="_blank">Cloudflare API Token</a> with `Workers Observability - read` and `Workers Scripts - edit` permissions.
3030

3131
- [ ] Run `npx wrangler login` and follow the prompts to login to Cloudflare
3232

@@ -36,51 +36,26 @@ You will:
3636

3737
## 🏗️ Step 1: Create the Worker
3838

39-
Create a new "Hello World" Cloudflare Worker
39+
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)
4040

4141
```bash
42-
npm create cloudflare@latest -- multitool-quickstart --type hello-world --lang js --no-git -y
42+
npm create cloudflare@latest -- multitool-quickstart --template [email protected]:wack/multitool-cloudflare-quickstart.git --no-git
4343
```
4444

45-
## 📦 Step 2: Create and package the Worker code
46-
47-
This tutorial simulates two versions of a Worker:
45+
This template contains two versions of a Worker:
4846

4947
- A “healthy” version that always returns a `200` HTTP status code
5048
- A “buggy” version that randomly fails with a `400` HTTP status code 50% of the time
5149

52-
We'll overwrite the `index.js` file and add a new file for the buggy version:
53-
54-
### Create the healthy version
55-
56-
This version always returns a `200` HTTP status code response.
57-
58-
```bash
59-
cat << EOF > multitool-quickstart/src/index.js
60-
export default {
61-
async fetch(request, env, ctx) {
62-
return new Response('Hello World!', { status: 200 });
63-
},
64-
};
65-
EOF
66-
```
50+
## ⚙️ Step 2: Update variables
6751

68-
### Create the buggy version
52+
You'll need to update some variables before we can deploy the worker:
6953

70-
This version introduces a simulated bug by returning a `400` HTTP status code 50% of the time.
54+
In `wrangler.jsonc` update `MY_CLOUDFLARE_ACCOUNT_ID` to your cloudflare account number
7155

72-
```bash
73-
cat << EOF > multitool-quickstart/src/index_errors.js
74-
export default {
75-
async fetch(request, env, ctx) {
76-
const rand = Math.random();
77-
return new Response(rand < 0.5 ? 'Bad Request' : 'Hello World!', { status: rand < 0.5 ? 400 : 200 });
78-
},
79-
};
80-
EOF
81-
```
56+
📝 **Note:** To get your Cloudflare Account ID, [follow the instructions here](https://developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/).
8257

83-
## ️ Step 3: Deploy the worker
58+
## ️ Step 3: Deploy the worker
8459

8560
Now that we added the updated code to our worker, let's deploy it.
8661

@@ -123,40 +98,40 @@ Now that the Worker is deployed and accessible via its URL, create the applicati
12398
From the MultiTool app:
12499

125100
1. Create a workspace
126-
2. Create an application named `quickstart`
101+
2. Create an application
127102

128-
After the application is set up, login to the MultiTool CLI if needed:
103+
After the application is set up, login to the MultiTool CLI, if needed:
129104

130105
```bash
131106
multi login
132107
```
133108

134-
## ⚙️ Step 6: Add your configuration file
135-
136-
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.
109+
## ⚙️ Step 6: Update your configuration file
137110

138-
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:
111+
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.
139112

140-
📝 **Note:** To get your Cloudflare Account ID, [follow the instructions here](https://developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/).
113+
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:
141114

142115
```bash
143-
cat << EOF > MultiTool.toml
144116
workspace = "MY_WORKSPACE_NAME"
145-
application = "quickstart"
117+
application = "MY_APPLICATION_NAME"
146118

147119
[config.cloudflare]
148120
worker-name = "multitool-quickstart"
149-
account-id = "MY_CLOUDFLARE_ACCOUNT_ID"
150-
main-module = "index.ts"
151-
artifact-path = "src/"
152-
EOF
121+
project-dir = "src/"
153122
```
154123

155124
## 🚀 Step 7: Roll out healthy code and simulate stable traffic
156125

157-
📝 **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 [email protected] and we’ll help resolve it. A fix is on the way.
126+
📝 **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 [email protected] and we’ll help resolve it.
127+
128+
Ensure `index.ts` is set as the `main` value in your `wrangler.jsonc` file:
158129

159-
Start the rollout using `index.ts` as the `main-module` value in your `MultiTool.toml` file:
130+
```json
131+
"main": "src/index_errors.js",
132+
```
133+
134+
Then start the rollout by running MultiTool:
160135

161136
```bash
162137
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
188163

189164
To test a broken rollout, use the `index_errors.ts` file.
190165

191-
Start the rollout using `index_errors.ts` as the `main-module` value in your `MultiTool.toml` file:
166+
Update the `main` value in your `wrangler.jsonc` file:
167+
168+
```json
169+
"main": "src/index_errors.js",
170+
```
171+
172+
Then re-run MultiTool
192173

193174
```bash
194175
multi run --cloudflare-api-token $MY_CLOUDFLARE_TOKEN

0 commit comments

Comments
 (0)