@just-be/deploy 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +30 -5
  2. package/index.ts +4 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -8,6 +8,30 @@ Deploy static sites and setup routing for the wildcard subdomain service.
8
8
  - [Wrangler](https://developers.cloudflare.com/workers/wrangler/) CLI configured with Cloudflare credentials
9
9
  - A Cloudflare Workers wildcard subdomain service with R2 and KV configured
10
10
 
11
+ ## Configuration
12
+
13
+ The deploy script requires access to:
14
+
15
+ - **KV namespace** for routing rules (default: `6118ae3b937c4883b3c582dfef8a0c05`)
16
+ - **R2 bucket** for static file storage (default: `content-bucket`)
17
+
18
+ ### Environment Variables
19
+
20
+ To use different resources, set these environment variables:
21
+
22
+ ```bash
23
+ export KV_NAMESPACE_ID="your-kv-namespace-id"
24
+ export R2_BUCKET_NAME="your-bucket-name"
25
+ bunx @just-be/deploy
26
+ ```
27
+
28
+ You can find your KV namespace ID and R2 buckets by running:
29
+
30
+ ```bash
31
+ wrangler kv namespace list
32
+ wrangler r2 bucket list
33
+ ```
34
+
11
35
  ## Installation
12
36
 
13
37
  No installation needed! Run directly with `bunx`:
@@ -200,13 +224,14 @@ The package includes a JSON Schema (`deploy.schema.json`) for editor validation
200
224
  - Creates a KV entry with the routing configuration
201
225
  5. **Configures** the wildcard service to route requests for each subdomain
202
226
 
203
- ## Configuration
227
+ ## Wildcard Service Requirements
228
+
229
+ The script works with any wildcard service that has:
204
230
 
205
- The script expects your wildcard service to use:
231
+ - **R2 Bucket**: For storing static files (default: `content-bucket`)
232
+ - **KV Namespace**: For routing rules (default: `6118ae3b937c4883b3c582dfef8a0c05`)
206
233
 
207
- - **R2 Bucket**: `content-bucket`
208
- - **KV Binding**: `ROUTING_RULES`
209
- - **Wrangler Config**: `services/wildcard/wrangler.toml`
234
+ No local `wrangler.toml` file is required - the script accesses Cloudflare resources directly via the Wrangler CLI.
210
235
 
211
236
  ## Validation
212
237
 
package/index.ts CHANGED
@@ -45,8 +45,8 @@ import {
45
45
  subdomain,
46
46
  } from "@just-be/wildcard";
47
47
 
48
- const BUCKET_NAME = "content-bucket";
49
- const WRANGLER_CONFIG = "services/wildcard/wrangler.toml";
48
+ const BUCKET_NAME = process.env.R2_BUCKET_NAME || "content-bucket";
49
+ const KV_NAMESPACE_ID = process.env.KV_NAMESPACE_ID || "6118ae3b937c4883b3c582dfef8a0c05";
50
50
 
51
51
  /**
52
52
  * Run wrangler command using bunx to ensure it resolves from package dependencies
@@ -177,7 +177,7 @@ async function uploadToR2(localPath: string, r2Key: string): Promise<boolean> {
177
177
  */
178
178
  async function validateKVAccess(): Promise<boolean> {
179
179
  try {
180
- await wrangler`kv key list --binding ROUTING_RULES --config ${WRANGLER_CONFIG}`.quiet();
180
+ await wrangler`kv key list --namespace-id ${KV_NAMESPACE_ID}`.quiet();
181
181
  return true;
182
182
  } catch {
183
183
  return false;
@@ -213,7 +213,7 @@ function sanitizeBranchName(branch: string): string {
213
213
  */
214
214
  async function createKVEntry(subdomain: string, routeConfig: RouteConfig): Promise<void> {
215
215
  const configJson = JSON.stringify(routeConfig);
216
- await wrangler`kv key put --binding ROUTING_RULES ${subdomain} ${configJson} --config ${WRANGLER_CONFIG}`;
216
+ await wrangler`kv key put --namespace-id ${KV_NAMESPACE_ID} ${subdomain} ${configJson}`;
217
217
  }
218
218
 
219
219
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@just-be/deploy",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Deploy static sites to Cloudflare R2 with subdomain routing",
5
5
  "type": "module",
6
6
  "bin": {