Skip to content

Commit d5f26cd

Browse files
authored
Move to new wrangler.jsonc config file format (#957)
* Move to new wrangler.jsonc config file format * Fix docs and test config
1 parent 9c2bcc5 commit d5f26cd

10 files changed

+110
-92
lines changed

Diff for: .editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ trim_trailing_whitespace = true
1010
insert_final_newline = true
1111
max_line_length = 100
1212

13-
[*.{json,js,ts,tsx,jsx,mjs,cjs}]
13+
[*.{json,jsonc,js,ts,tsx,jsx,mjs,cjs}]
1414
indent_size = 2
1515

1616
[*.vue]

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ For those who have forked this repository, feel free to delete the [release.yml]
7474

7575
This project sets up a [cron trigger](https://developers.cloudflare.com/workers/platform/triggers/cron-triggers/) for Cloudflare workers, which automatically deletes old cache files within the bound R2 bucket. This behavior can be customized:
7676

77-
- To disable the automatic deletion, remove the [triggers] configuration in [wrangler.toml](./wrangler.toml)
78-
- To change the retention period for objects, adjust the `BUCKET_OBJECT_EXPIRATION_HOURS` option in [wrangler.toml](./wrangler.toml) or set it via [workers environment variables](https://developers.cloudflare.com/workers/platform/environment-variables/)
77+
- To disable the automatic deletion, remove the [triggers] configuration in [wrangler.jsonc](./wrangler.jsonc)
78+
- To change the retention period for objects, adjust the `BUCKET_OBJECT_EXPIRATION_HOURS` option in [wrangler.jsonc](./wrangler.jsonc) or set it via [workers environment variables](https://developers.cloudflare.com/workers/platform/environment-variables/)
7979

8080
## ▲ Setting up remote caching in your Turborepo project
8181

Diff for: docs/configuration/kv-storage.md

+23-16
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,28 @@ kv_namespaces = [
3939
4040
## 2. Update Your Configuration
4141
42-
Update your `wrangler.toml` file to include the KV namespace details.
43-
44-
```toml{11,12}
45-
name = "turborepo-remote-cache"
46-
# Other settings...
47-
48-
# [[r2_buckets]]
49-
# binding = 'R2_STORE'
50-
# bucket_name = 'turborepo-cache'
51-
# preview_bucket_name = 'turborepo-cache-preview'
52-
53-
[[kv_namespaces]] // [!code focus]
54-
binding = "KV_STORE" // [!code focus]
55-
id = "ea20b0eb60f44b13b8d013eeace98ca2" // [!code focus]
56-
preview_id = "ea20b0eb60f44b13b8d013eeace98ca2" // [!code focus]
42+
Update your `wrangler.jsonc` file to include the KV namespace details.
43+
44+
```jsonc{12-18}
45+
{
46+
"name": "turborepo-remote-cache",
47+
// Other settings...
48+
49+
// "r2_buckets": [
50+
// {
51+
// "binding": "R2_STORE",
52+
// "bucket_name": "turborepo-cache",
53+
// "preview_bucket_name": "turborepo-cache-preview"
54+
// }
55+
// ],
56+
"kv_namespaces": [
57+
{
58+
"binding": "KV_STORE",
59+
"id": "ea20b0eb60f44b13b8d013eeace98ca2",
60+
"preview_id": "ea20b0eb60f44b13b8d013eeace98ca2"
61+
}
62+
]
63+
}
5764
```
5865
5966
::: info
@@ -62,5 +69,5 @@ If you want to use KV as the store, ensure that the `r2_buckets` section is comm
6269
6370
## 3. Deploy Your Worker
6471
65-
Once you've updated your Worker script and `wrangler.toml` file, deploy your Worker using the Wrangler CLI or your GitHub actions workflow.
72+
Once you've updated your Worker script and `wrangler.jsonc` file, deploy your Worker using the Wrangler CLI or your GitHub actions workflow.
6673
And that's it! Your build artifacts will now be stored in Cloudflare KV.

Diff for: docs/configuration/project-configuration.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ layout: doc
88

99
This project sets up a [cron trigger](https://developers.cloudflare.com/workers/platform/triggers/cron-triggers/) for Cloudflare workers, which automatically deletes old cache files within the bound R2 bucket. This behavior can be customized:
1010

11-
- To disable the automatic deletion, remove the [triggers] configuration in [wrangler.toml](https://github.com/AdiRishi/turborepo-remote-cache-cloudflare/blob/master/wrangler.toml)
12-
- To change the retention period for objects, adjust the `BUCKET_OBJECT_EXPIRATION_HOURS` option in [wrangler.toml](https://github.com/AdiRishi/turborepo-remote-cache-cloudflare/blob/master/wrangler.toml) or set it via [workers environment variables](https://developers.cloudflare.com/workers/platform/environment-variables/)
11+
- To disable the automatic deletion, remove the [triggers] configuration in [wrangler.jsonc](https://github.com/AdiRishi/turborepo-remote-cache-cloudflare/blob/master/wrangler.jsonc)
12+
- To change the retention period for objects, adjust the `BUCKET_OBJECT_EXPIRATION_HOURS` option in [wrangler.jsonc](https://github.com/AdiRishi/turborepo-remote-cache-cloudflare/blob/master/wrangler.jsonc) or set it via [workers environment variables](https://developers.cloudflare.com/workers/platform/environment-variables/)

Diff for: docs/configuration/r2-storage.md

+24-17
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,29 @@ You can find the list of regions and their codes [here](https://developers.cloud
4646

4747
## 2. Update Your Configuration
4848

49-
Update your `wrangler.toml` file to include the R2 bucket details.
50-
51-
```toml{6,8}
52-
name = "turborepo-remote-cache"
53-
# Other settings...
54-
55-
[[r2_buckets]] // [!code focus]
56-
binding = 'R2_STORE' // [!code focus]
57-
bucket_name = 'your-bucket-name' // [!code focus]
58-
# Preview bucket can be the same as the main bucket // [!code focus]
59-
preview_bucket_name = 'your-preview-bucket-name' // [!code focus]
60-
61-
# [[kv_namespaces]]
62-
# binding = "KV_STORE"
63-
# id = "ea20b0eb60f44b13b8d013eeace98ca2"
64-
# preview_id = "ea20b0eb60f44b13b8d013eeace98ca2"
49+
Update your `wrangler.jsonc` file to include the R2 bucket details.
50+
51+
```jsonc{5-11}
52+
{
53+
"name": "turborepo-remote-cache",
54+
// Other settings...
55+
56+
"r2_buckets": [
57+
{
58+
"binding": "R2_STORE",
59+
"bucket_name": "your-bucket-name",
60+
"preview_bucket_name": "your-preview-bucket-name"
61+
}
62+
],
63+
64+
// "kv_namespaces": [
65+
// {
66+
// "binding": "KV_STORE",
67+
// "id": "ea20b0eb60f44b13b8d013eeace98ca2",
68+
// "preview_id": "ea20b0eb60f44b13b8d013eeace98ca2"
69+
// }
70+
// ]
71+
}
6572
```
6673

6774
::: info
@@ -70,5 +77,5 @@ If you want to use R2 as the store, ensure that the `kv_namespaces` section is c
7077

7178
## 3. Deploy Your Worker
7279

73-
Once you've updated your Worker script and `wrangler.toml` file, deploy your Worker using the Wrangler CLI or your GitHub actions workflow.
80+
Once you've updated your Worker script and `wrangler.jsonc` file, deploy your Worker using the Wrangler CLI or your GitHub actions workflow.
7481
And that's it! Your build artifacts will now be stored in Cloudflare R2.

Diff for: vitest.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default defineWorkersConfig({
1212
},
1313
},
1414
wrangler: {
15-
configPath: './wrangler.vitest.toml',
15+
configPath: './wrangler.vitest.jsonc',
1616
},
1717
},
1818
},

Diff for: wrangler.jsonc

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"$schema": "node_modules/wrangler/config-schema.json",
3+
"name": "turborepo-remote-cache",
4+
"main": "src/index.ts",
5+
"compatibility_date": "2025-02-24",
6+
"upload_source_maps": true,
7+
"observability": {
8+
"enabled": true,
9+
},
10+
"vars": {
11+
"ENVIRONMENT": "production",
12+
// - TURBO_TOKEN (must a valid Bearer auth token)
13+
// Run `echo <VALUE> | wrangler secret put <NAME>` for each of these
14+
"BUCKET_OBJECT_EXPIRATION_HOURS": 720,
15+
},
16+
"r2_buckets": [
17+
{
18+
"binding": "R2_STORE",
19+
"bucket_name": "turborepo-cache",
20+
"preview_bucket_name": "turborepo-cache-preview",
21+
},
22+
],
23+
// "kv_namespaces": [{"binding": "KV_STORE", "id": "ea20b0eb60f44b13b8d013eeace98ca2", "preview_id": "ea20b0eb60f44b13b8d013eeace98ca2"}],
24+
"triggers": {
25+
"crons": ["0 3 * * *"],
26+
},
27+
}

Diff for: wrangler.toml

-28
This file was deleted.

Diff for: wrangler.vitest.jsonc

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"$schema": "node_modules/wrangler/config-schema.json",
3+
"name": "turborepo-remote-cache",
4+
"main": "src/index.ts",
5+
"compatibility_date": "2025-02-24",
6+
"compatibility_flags": ["nodejs_compat"],
7+
"vars": {
8+
"ENVIRONMENT": "production",
9+
// - TURBO_TOKEN (must a valid Bearer auth token)
10+
// Run `echo <VALUE> | wrangler secret put <NAME>` for each of these
11+
"BUCKET_OBJECT_EXPIRATION_HOURS": 720, // 30 days
12+
},
13+
"r2_buckets": [
14+
{
15+
"binding": "R2_STORE",
16+
"bucket_name": "turborepo-cache",
17+
"preview_bucket_name": "turborepo-cache-preview",
18+
},
19+
],
20+
"kv_namespaces": [
21+
{
22+
"binding": "KV_STORE",
23+
"id": "ea20b0eb60f44b13b8d013eeace98ca2",
24+
"preview_id": "ea20b0eb60f44b13b8d013eeace98ca2",
25+
},
26+
],
27+
"triggers": {
28+
"crons": ["0 3 * * *"],
29+
},
30+
}

Diff for: wrangler.vitest.toml

-25
This file was deleted.

0 commit comments

Comments
 (0)