@ereo/deploy-cloudflare 0.1.6

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.
package/README.md ADDED
@@ -0,0 +1,187 @@
1
+ # @ereo/deploy-cloudflare
2
+
3
+ Cloudflare deployment adapter for the EreoJS framework. Generates build configuration and wrangler.toml files for deploying to Cloudflare Workers.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add @ereo/deploy-cloudflare
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { defineConfig } from '@ereo/core';
15
+ import { cloudflare } from '@ereo/deploy-cloudflare';
16
+
17
+ export default defineConfig({
18
+ ...cloudflare(),
19
+ });
20
+ ```
21
+
22
+ This sets the build target to `'cloudflare'` in your EreoJS configuration.
23
+
24
+ ## API Reference
25
+
26
+ ### `cloudflare(config?)`
27
+
28
+ Generates EreoJS configuration for Cloudflare deployment.
29
+
30
+ **Parameters:**
31
+ - `config` (optional): `CloudflareConfig` object
32
+
33
+ **Returns:** `Partial<FrameworkConfig>` - Always returns:
34
+ ```typescript
35
+ {
36
+ build: {
37
+ target: 'cloudflare'
38
+ }
39
+ }
40
+ ```
41
+
42
+ **Note:** The current implementation returns the same output regardless of configuration options passed. Configuration properties are accepted for future compatibility but are not yet utilized.
43
+
44
+ ```typescript
45
+ import { cloudflare } from '@ereo/deploy-cloudflare';
46
+
47
+ const config = cloudflare();
48
+ // Returns: { build: { target: 'cloudflare' } }
49
+ ```
50
+
51
+ ### `generateWranglerToml(config)`
52
+
53
+ Generates a wrangler.toml configuration string.
54
+
55
+ **Parameters:**
56
+ - `config`: `CloudflareConfig` object
57
+
58
+ **Returns:** `string` - wrangler.toml content
59
+
60
+ **Supported Options:**
61
+ - `routes`: Array of route patterns (e.g., `['example.com/*']`)
62
+ - `kvNamespaces`: Array of KV namespace binding names
63
+
64
+ **Example:**
65
+
66
+ ```typescript
67
+ import { generateWranglerToml } from '@ereo/deploy-cloudflare';
68
+
69
+ const toml = generateWranglerToml({
70
+ routes: ['api.example.com/*'],
71
+ kvNamespaces: ['CACHE', 'SESSIONS'],
72
+ });
73
+
74
+ await Bun.write('wrangler.toml', toml);
75
+ ```
76
+
77
+ **Output:**
78
+
79
+ ```toml
80
+ name = "ereo-app"
81
+ compatibility_date = "2024-01-01"
82
+ main = "dist/server.js"
83
+
84
+ routes = ["api.example.com/*"]
85
+
86
+ [[kv_namespaces]]
87
+ binding = "CACHE"
88
+ id = "your-namespace-id"
89
+
90
+ [[kv_namespaces]]
91
+ binding = "SESSIONS"
92
+ id = "your-namespace-id"
93
+ ```
94
+
95
+ **Important:** You must manually replace `"your-namespace-id"` with your actual Cloudflare KV namespace IDs.
96
+
97
+ ### `CloudflareConfig` Interface
98
+
99
+ ```typescript
100
+ interface CloudflareConfig {
101
+ /** Deployment target: 'pages' or 'workers' (not currently used) */
102
+ target?: 'pages' | 'workers';
103
+
104
+ /** Cloudflare account ID (not currently used) */
105
+ accountId?: string;
106
+
107
+ /** Custom domain routes - included in wrangler.toml output */
108
+ routes?: string[];
109
+
110
+ /** KV namespace bindings - included in wrangler.toml output */
111
+ kvNamespaces?: string[];
112
+
113
+ /** Durable Object bindings (not currently used) */
114
+ durableObjects?: string[];
115
+ }
116
+ ```
117
+
118
+ ### Default Export
119
+
120
+ The package default export is the `cloudflare` function:
121
+
122
+ ```typescript
123
+ import cloudflare from '@ereo/deploy-cloudflare';
124
+ // Equivalent to: import { cloudflare } from '@ereo/deploy-cloudflare';
125
+ ```
126
+
127
+ ## Deployment Workflow
128
+
129
+ ### 1. Configure EreoJS
130
+
131
+ ```typescript
132
+ // ereo.config.ts
133
+ import { defineConfig } from '@ereo/core';
134
+ import { cloudflare } from '@ereo/deploy-cloudflare';
135
+
136
+ export default defineConfig({
137
+ ...cloudflare(),
138
+ });
139
+ ```
140
+
141
+ ### 2. Generate wrangler.toml
142
+
143
+ ```typescript
144
+ // scripts/generate-wrangler.ts
145
+ import { generateWranglerToml } from '@ereo/deploy-cloudflare';
146
+
147
+ const toml = generateWranglerToml({
148
+ routes: ['myapp.example.com/*'],
149
+ kvNamespaces: ['CACHE'],
150
+ });
151
+
152
+ await Bun.write('wrangler.toml', toml);
153
+ console.log('Generated wrangler.toml - remember to update KV namespace IDs!');
154
+ ```
155
+
156
+ ### 3. Deploy with Wrangler
157
+
158
+ ```bash
159
+ # Build the application
160
+ bun run build
161
+
162
+ # Deploy to Cloudflare
163
+ wrangler deploy
164
+ ```
165
+
166
+ ## Current Limitations
167
+
168
+ This package provides minimal configuration scaffolding. The following features are defined in the interface but not yet implemented:
169
+
170
+ - `target` option does not differentiate between Pages and Workers
171
+ - `accountId` is not used in any output
172
+ - `durableObjects` bindings are not generated in wrangler.toml
173
+ - KV namespace IDs must be manually configured (placeholder values are generated)
174
+
175
+ For full Cloudflare configuration, manually edit the generated wrangler.toml or create one from scratch following [Cloudflare's documentation](https://developers.cloudflare.com/workers/wrangler/configuration/).
176
+
177
+ ## Documentation
178
+
179
+ For full documentation, visit [https://ereo.dev/docs/deploy-cloudflare](https://ereo.dev/docs/deploy-cloudflare)
180
+
181
+ ## Part of EreoJS
182
+
183
+ This package is part of the [EreoJS monorepo](https://github.com/anthropics/ereo-js).
184
+
185
+ ## License
186
+
187
+ MIT
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @ereo/deploy-cloudflare - Cloudflare deployment adapter
3
+ */
4
+ import type { FrameworkConfig } from '@ereo/core';
5
+ /** Cloudflare deployment configuration */
6
+ export interface CloudflareConfig {
7
+ /** Deployment target: 'pages' or 'workers' */
8
+ target?: 'pages' | 'workers';
9
+ /** Account ID */
10
+ accountId?: string;
11
+ /** Custom domains */
12
+ routes?: string[];
13
+ /** KV namespace bindings */
14
+ kvNamespaces?: string[];
15
+ /** Durable Object bindings */
16
+ durableObjects?: string[];
17
+ }
18
+ /** Generate Cloudflare configuration */
19
+ export declare function cloudflare(config?: CloudflareConfig): Partial<FrameworkConfig>;
20
+ /** Generate wrangler.toml configuration */
21
+ export declare function generateWranglerToml(config: CloudflareConfig): string;
22
+ export default cloudflare;
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,0CAA0C;AAC1C,MAAM,WAAW,gBAAgB;IAC/B,8CAA8C;IAC9C,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qBAAqB;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,4BAA4B;IAC5B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,8BAA8B;IAC9B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,wCAAwC;AACxC,wBAAgB,UAAU,CAAC,MAAM,GAAE,gBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CAMlF;AAED,2CAA2C;AAC3C,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAmBrE;AAED,eAAe,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,35 @@
1
+ // @bun
2
+ // src/index.ts
3
+ function cloudflare(config = {}) {
4
+ return {
5
+ build: {
6
+ target: "cloudflare"
7
+ }
8
+ };
9
+ }
10
+ function generateWranglerToml(config) {
11
+ const bindings = [];
12
+ if (config.kvNamespaces) {
13
+ for (const ns of config.kvNamespaces) {
14
+ bindings.push(`[[kv_namespaces]]
15
+ binding = "${ns}"
16
+ id = "your-namespace-id"`);
17
+ }
18
+ }
19
+ return `name = "ereo-app"
20
+ compatibility_date = "2024-01-01"
21
+ main = "dist/server.js"
22
+
23
+ ${config.routes ? `routes = ${JSON.stringify(config.routes)}` : ""}
24
+
25
+ ${bindings.join(`
26
+
27
+ `)}
28
+ `;
29
+ }
30
+ var src_default = cloudflare;
31
+ export {
32
+ generateWranglerToml,
33
+ src_default as default,
34
+ cloudflare
35
+ };
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@ereo/deploy-cloudflare",
3
+ "version": "0.1.6",
4
+ "license": "MIT",
5
+ "author": "Ereo Team",
6
+ "homepage": "https://ereo.dev",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/ereojs/ereo.git",
10
+ "directory": "packages/deploy-cloudflare"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/ereojs/ereo/issues"
14
+ },
15
+ "description": "Cloudflare Pages/Workers deployment adapter for EreoJS framework",
16
+ "type": "module",
17
+ "main": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "import": "./dist/index.js"
23
+ }
24
+ },
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "scripts": {
29
+ "build": "bun build ./src/index.ts --outdir ./dist --target bun --external @ereo/core && bun run build:types",
30
+ "build:types": "tsc --emitDeclarationOnly --outDir dist",
31
+ "dev": "bun build ./src/index.ts --outdir ./dist --target bun --watch",
32
+ "test": "bun test",
33
+ "typecheck": "tsc --noEmit"
34
+ },
35
+ "dependencies": {
36
+ "@ereo/core": "workspace:*"
37
+ },
38
+ "devDependencies": {
39
+ "@types/bun": "^1.1.0",
40
+ "typescript": "^5.4.0"
41
+ }
42
+ }