@authrim/setup 0.1.103 → 0.1.104
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/dist/cli/commands/deploy.js +1 -1
- package/dist/cli/commands/deploy.js.map +1 -1
- package/dist/core/admin.d.ts.map +1 -1
- package/dist/core/admin.js +15 -12
- package/dist/core/admin.js.map +1 -1
- package/dist/core/deploy.d.ts +2 -0
- package/dist/core/deploy.d.ts.map +1 -1
- package/dist/core/deploy.js +8 -8
- package/dist/core/deploy.js.map +1 -1
- package/dist/core/naming.d.ts +0 -8
- package/dist/core/naming.d.ts.map +1 -1
- package/dist/core/naming.js +0 -10
- package/dist/core/naming.js.map +1 -1
- package/dist/core/wrangler-sync.d.ts +13 -3
- package/dist/core/wrangler-sync.d.ts.map +1 -1
- package/dist/core/wrangler-sync.js +27 -15
- package/dist/core/wrangler-sync.js.map +1 -1
- package/dist/core/wrangler.d.ts +10 -1
- package/dist/core/wrangler.d.ts.map +1 -1
- package/dist/core/wrangler.js +238 -97
- package/dist/core/wrangler.js.map +1 -1
- package/dist/web/api.d.ts.map +1 -1
- package/dist/web/api.js +3 -2
- package/dist/web/api.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
* Wrangler Configuration Sync Utility
|
|
3
3
|
*
|
|
4
4
|
* Manages synchronization between master wrangler.toml files in .authrim/{env}/wrangler/
|
|
5
|
-
* and the deployment copies in packages/ar-star/wrangler.
|
|
5
|
+
* and the deployment copies in packages/ar-star/wrangler.toml (with [env.xxx] sections).
|
|
6
6
|
*
|
|
7
7
|
* Features:
|
|
8
8
|
* - Detects manual modifications to deployment configs
|
|
9
9
|
* - Protects user edits from being overwritten
|
|
10
10
|
* - Maintains portable master copies in environment directory
|
|
11
|
+
* - Generates [env.xxx] format for Cloudflare's official environment support
|
|
11
12
|
*/
|
|
12
13
|
import { existsSync } from 'node:fs';
|
|
13
14
|
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
@@ -37,15 +38,21 @@ export function getMasterWranglerPath(envPaths, component) {
|
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
39
40
|
* Get the deploy wrangler.toml path for a component
|
|
41
|
+
*
|
|
42
|
+
* Returns the unified wrangler.toml path (not environment-specific).
|
|
43
|
+
* Environment-specific settings are defined within [env.xxx] sections.
|
|
40
44
|
*/
|
|
41
|
-
export function getDeployWranglerPath(packagesDir, component
|
|
42
|
-
return join(packagesDir, component,
|
|
45
|
+
export function getDeployWranglerPath(packagesDir, component) {
|
|
46
|
+
return join(packagesDir, component, 'wrangler.toml');
|
|
43
47
|
}
|
|
44
48
|
// =============================================================================
|
|
45
49
|
// Status Check
|
|
46
50
|
// =============================================================================
|
|
47
51
|
/**
|
|
48
52
|
* Check the sync status of all wrangler configs
|
|
53
|
+
*
|
|
54
|
+
* Note: With the new [env.xxx] format, comparison checks if the environment section
|
|
55
|
+
* in the deploy file matches the master config content.
|
|
49
56
|
*/
|
|
50
57
|
export async function checkWranglerStatus(options) {
|
|
51
58
|
const { baseDir, env, packagesDir } = options;
|
|
@@ -53,13 +60,14 @@ export async function checkWranglerStatus(options) {
|
|
|
53
60
|
const results = [];
|
|
54
61
|
for (const component of CORE_WORKER_COMPONENTS) {
|
|
55
62
|
const masterPath = getMasterWranglerPath(envPaths, component);
|
|
56
|
-
const deployPath = getDeployWranglerPath(packagesDir, component
|
|
63
|
+
const deployPath = getDeployWranglerPath(packagesDir, component);
|
|
57
64
|
const masterExists = existsSync(masterPath);
|
|
58
65
|
const deployExists = existsSync(deployPath);
|
|
59
66
|
let inSync = true;
|
|
60
67
|
if (masterExists && deployExists) {
|
|
61
68
|
const masterContent = await readFile(masterPath, 'utf-8');
|
|
62
69
|
const deployContent = await readFile(deployPath, 'utf-8');
|
|
70
|
+
// Compare the relevant [env.xxx] section content
|
|
63
71
|
inSync = normalizeToml(masterContent) === normalizeToml(deployContent);
|
|
64
72
|
}
|
|
65
73
|
else if (masterExists !== deployExists) {
|
|
@@ -97,7 +105,8 @@ export async function saveMasterWranglerConfigs(config, resourceIds, options) {
|
|
|
97
105
|
for (const component of CORE_WORKER_COMPONENTS) {
|
|
98
106
|
try {
|
|
99
107
|
const wranglerConfig = generateWranglerConfig(component, config, resourceIds, workersSubdomain ?? undefined);
|
|
100
|
-
|
|
108
|
+
// Generate TOML with [env.{env}] section format
|
|
109
|
+
const tomlContent = toToml(wranglerConfig, env);
|
|
101
110
|
const masterPath = getMasterWranglerPath(envPaths, component);
|
|
102
111
|
if (!dryRun) {
|
|
103
112
|
await writeFile(masterPath, tomlContent, 'utf-8');
|
|
@@ -120,8 +129,11 @@ export async function saveMasterWranglerConfigs(config, resourceIds, options) {
|
|
|
120
129
|
/**
|
|
121
130
|
* Sync master wrangler configs to deployment locations
|
|
122
131
|
*
|
|
123
|
-
* This copies from .authrim/{env}/wrangler/ to packages/ar-star/wrangler.
|
|
132
|
+
* This copies from .authrim/{env}/wrangler/ to packages/ar-star/wrangler.toml
|
|
124
133
|
* while detecting and protecting manual edits.
|
|
134
|
+
*
|
|
135
|
+
* With the new [env.xxx] format, each deploy file contains environment-specific
|
|
136
|
+
* sections, allowing multiple environments to coexist in a single wrangler.toml.
|
|
125
137
|
*/
|
|
126
138
|
export async function syncWranglerConfigs(options, onManualEdit) {
|
|
127
139
|
const { baseDir, env, packagesDir, force, dryRun, onProgress } = options;
|
|
@@ -141,7 +153,7 @@ export async function syncWranglerConfigs(options, onManualEdit) {
|
|
|
141
153
|
}
|
|
142
154
|
for (const component of CORE_WORKER_COMPONENTS) {
|
|
143
155
|
const masterPath = getMasterWranglerPath(envPaths, component);
|
|
144
|
-
const deployPath = getDeployWranglerPath(packagesDir, component
|
|
156
|
+
const deployPath = getDeployWranglerPath(packagesDir, component);
|
|
145
157
|
const componentDir = join(packagesDir, component);
|
|
146
158
|
// Skip if component directory doesn't exist
|
|
147
159
|
if (!existsSync(componentDir)) {
|
|
@@ -190,10 +202,10 @@ export async function syncWranglerConfigs(options, onManualEdit) {
|
|
|
190
202
|
// Write master content to deploy location
|
|
191
203
|
if (!dryRun) {
|
|
192
204
|
await writeFile(deployPath, masterContent, 'utf-8');
|
|
193
|
-
onProgress?.(` ${component}: Synced`);
|
|
205
|
+
onProgress?.(` ${component}: Synced to wrangler.toml`);
|
|
194
206
|
}
|
|
195
207
|
else {
|
|
196
|
-
onProgress?.(` ${component}: Would sync`);
|
|
208
|
+
onProgress?.(` ${component}: Would sync to wrangler.toml`);
|
|
197
209
|
}
|
|
198
210
|
result.synced.push(component);
|
|
199
211
|
}
|
|
@@ -211,16 +223,16 @@ export async function syncWranglerConfigs(options, onManualEdit) {
|
|
|
211
223
|
* Backup deploy wrangler configs before sync
|
|
212
224
|
*/
|
|
213
225
|
export async function backupDeployConfigs(options) {
|
|
214
|
-
const {
|
|
226
|
+
const { packagesDir, onProgress } = options;
|
|
215
227
|
const backedUp = [];
|
|
216
228
|
for (const component of CORE_WORKER_COMPONENTS) {
|
|
217
|
-
const deployPath = getDeployWranglerPath(packagesDir, component
|
|
229
|
+
const deployPath = getDeployWranglerPath(packagesDir, component);
|
|
218
230
|
if (existsSync(deployPath)) {
|
|
219
231
|
const content = await readFile(deployPath, 'utf-8');
|
|
220
232
|
const backupPath = deployPath + '.backup';
|
|
221
233
|
await writeFile(backupPath, content, 'utf-8');
|
|
222
234
|
backedUp.push(component);
|
|
223
|
-
onProgress?.(` Backed up ${component}/wrangler
|
|
235
|
+
onProgress?.(` Backed up ${component}/wrangler.toml`);
|
|
224
236
|
}
|
|
225
237
|
}
|
|
226
238
|
return backedUp;
|
|
@@ -229,16 +241,16 @@ export async function backupDeployConfigs(options) {
|
|
|
229
241
|
* Restore deploy wrangler configs from backup
|
|
230
242
|
*/
|
|
231
243
|
export async function restoreDeployConfigs(options) {
|
|
232
|
-
const {
|
|
244
|
+
const { packagesDir, onProgress } = options;
|
|
233
245
|
const restored = [];
|
|
234
246
|
for (const component of CORE_WORKER_COMPONENTS) {
|
|
235
|
-
const deployPath = getDeployWranglerPath(packagesDir, component
|
|
247
|
+
const deployPath = getDeployWranglerPath(packagesDir, component);
|
|
236
248
|
const backupPath = deployPath + '.backup';
|
|
237
249
|
if (existsSync(backupPath)) {
|
|
238
250
|
const content = await readFile(backupPath, 'utf-8');
|
|
239
251
|
await writeFile(deployPath, content, 'utf-8');
|
|
240
252
|
restored.push(component);
|
|
241
|
-
onProgress?.(` Restored ${component}/wrangler
|
|
253
|
+
onProgress?.(` Restored ${component}/wrangler.toml`);
|
|
242
254
|
}
|
|
243
255
|
}
|
|
244
256
|
return restored;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrangler-sync.js","sourceRoot":"","sources":["../../src/core/wrangler-sync.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"wrangler-sync.js","sourceRoot":"","sources":["../../src/core/wrangler-sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,EAAoB,MAAM,eAAe,CAAC;AAEjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAiDtD,gFAAgF;AAChF,oBAAoB;AACpB,gFAAgF;AAEhF;;GAEG;AACH,SAAS,aAAa,CAAC,OAAe;IACpC,OAAO,OAAO;SACX,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC1B,MAAM,CAAC,CAAC,IAAI,E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UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3B,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YACpD,MAAM,SAAS,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC9C,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACzB,UAAU,EAAE,CAAC,cAAc,SAAS,gBAAgB,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/core/wrangler.d.ts
CHANGED
|
@@ -84,8 +84,17 @@ export interface WranglerConfig {
|
|
|
84
84
|
export declare function generateWranglerConfig(component: WorkerComponent, config: AuthrimConfig, resourceIds: ResourceIds, workersSubdomain?: string): WranglerConfig;
|
|
85
85
|
/**
|
|
86
86
|
* Convert WranglerConfig to TOML string
|
|
87
|
+
*
|
|
88
|
+
* When envName is provided, generates the new Cloudflare [env.xxx] section format:
|
|
89
|
+
* - Top-level: main, compatibility_date, compatibility_flags, migrations
|
|
90
|
+
* - [env.{envName}]: name, workers_dev, placement, kv, d1, do, vars, services, routes
|
|
91
|
+
*
|
|
92
|
+
* When envName is not provided, generates the legacy flat format (for backward compatibility).
|
|
93
|
+
*
|
|
94
|
+
* @param config - Wrangler configuration object
|
|
95
|
+
* @param envName - Optional environment name (e.g., "conformance", "prod")
|
|
87
96
|
*/
|
|
88
|
-
export declare function toToml(config: WranglerConfig): string;
|
|
97
|
+
export declare function toToml(config: WranglerConfig, envName?: string): string;
|
|
89
98
|
/**
|
|
90
99
|
* Generate route configurations for custom domains
|
|
91
100
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrangler.d.ts","sourceRoot":"","sources":["../../src/core/wrangler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAKL,KAAK,eAAe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CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IACnE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvD,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,KAAK,CAAC;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KACvD,CAAC;IACF,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACxD;AAyLD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,eAAe,EAC1B,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,WAAW,EACxB,gBAAgB,CAAC,EAAE,MAAM,GACxB,cAAc,CAyJhB;AAuLD;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAwRvE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,eAAe,EAC1B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,KAAK,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAkD/C"}
|
package/dist/core/wrangler.js
CHANGED
|
@@ -477,125 +477,266 @@ function generateDOMigrations() {
|
|
|
477
477
|
// =============================================================================
|
|
478
478
|
/**
|
|
479
479
|
* Convert WranglerConfig to TOML string
|
|
480
|
+
*
|
|
481
|
+
* When envName is provided, generates the new Cloudflare [env.xxx] section format:
|
|
482
|
+
* - Top-level: main, compatibility_date, compatibility_flags, migrations
|
|
483
|
+
* - [env.{envName}]: name, workers_dev, placement, kv, d1, do, vars, services, routes
|
|
484
|
+
*
|
|
485
|
+
* When envName is not provided, generates the legacy flat format (for backward compatibility).
|
|
486
|
+
*
|
|
487
|
+
* @param config - Wrangler configuration object
|
|
488
|
+
* @param envName - Optional environment name (e.g., "conformance", "prod")
|
|
480
489
|
*/
|
|
481
|
-
export function toToml(config) {
|
|
490
|
+
export function toToml(config, envName) {
|
|
482
491
|
const lines = [];
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
if (config.placement) {
|
|
492
|
-
lines.push('[placement]');
|
|
493
|
-
lines.push(`mode = "${config.placement.mode}"`);
|
|
492
|
+
if (envName) {
|
|
493
|
+
// =========================================================================
|
|
494
|
+
// New format: [env.xxx] sections
|
|
495
|
+
// =========================================================================
|
|
496
|
+
// Top-level: shared settings (main, compatibility)
|
|
497
|
+
lines.push(`main = "${config.main}"`);
|
|
498
|
+
lines.push(`compatibility_date = "${config.compatibility_date}"`);
|
|
499
|
+
lines.push(`compatibility_flags = [${config.compatibility_flags.map((f) => `"${f}"`).join(', ')}]`);
|
|
494
500
|
lines.push('');
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
501
|
+
// Migrations at top level (for Durable Objects definitions - applies to all envs)
|
|
502
|
+
if (config.migrations && config.migrations.length > 0) {
|
|
503
|
+
lines.push('# Durable Objects Migrations');
|
|
504
|
+
for (const migration of config.migrations) {
|
|
505
|
+
lines.push('[[migrations]]');
|
|
506
|
+
lines.push(`tag = "${migration.tag}"`);
|
|
507
|
+
if (migration.new_sqlite_classes && migration.new_sqlite_classes.length > 0) {
|
|
508
|
+
lines.push('new_sqlite_classes = [');
|
|
509
|
+
for (const cls of migration.new_sqlite_classes) {
|
|
510
|
+
lines.push(` "${cls}",`);
|
|
511
|
+
}
|
|
512
|
+
lines.push(']');
|
|
513
|
+
}
|
|
514
|
+
lines.push('');
|
|
505
515
|
}
|
|
506
|
-
lines.push('');
|
|
507
516
|
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
+
// Environment-specific section
|
|
518
|
+
lines.push(`# Environment: ${envName}`);
|
|
519
|
+
lines.push(`[env.${envName}]`);
|
|
520
|
+
// Explicitly set worker name to maintain current naming convention ({env}-{component})
|
|
521
|
+
lines.push(`name = "${config.name}"`);
|
|
522
|
+
lines.push(`workers_dev = ${config.workers_dev}`);
|
|
523
|
+
lines.push('');
|
|
524
|
+
// Placement
|
|
525
|
+
if (config.placement) {
|
|
526
|
+
lines.push(`[env.${envName}.placement]`);
|
|
527
|
+
lines.push(`mode = "${config.placement.mode}"`);
|
|
517
528
|
lines.push('');
|
|
518
529
|
}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
530
|
+
// KV Namespaces
|
|
531
|
+
if (config.kv_namespaces && config.kv_namespaces.length > 0) {
|
|
532
|
+
lines.push('# KV Namespaces');
|
|
533
|
+
for (const kv of config.kv_namespaces) {
|
|
534
|
+
lines.push(`[[env.${envName}.kv_namespaces]]`);
|
|
535
|
+
lines.push(`binding = "${kv.binding}"`);
|
|
536
|
+
lines.push(`id = "${kv.id}"`);
|
|
537
|
+
if (kv.preview_id) {
|
|
538
|
+
lines.push(`preview_id = "${kv.preview_id}"`);
|
|
539
|
+
}
|
|
540
|
+
lines.push('');
|
|
541
|
+
}
|
|
528
542
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
543
|
+
// D1 Databases
|
|
544
|
+
if (config.d1_databases && config.d1_databases.length > 0) {
|
|
545
|
+
lines.push('# D1 Databases');
|
|
546
|
+
for (const db of config.d1_databases) {
|
|
547
|
+
lines.push(`[[env.${envName}.d1_databases]]`);
|
|
548
|
+
lines.push(`binding = "${db.binding}"`);
|
|
549
|
+
lines.push(`database_name = "${db.database_name}"`);
|
|
550
|
+
lines.push(`database_id = "${db.database_id}"`);
|
|
551
|
+
lines.push('');
|
|
552
|
+
}
|
|
538
553
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
if (dob.script_name) {
|
|
548
|
-
lines.push(`script_name = "${dob.script_name}"`);
|
|
554
|
+
// R2 Buckets
|
|
555
|
+
if (config.r2_buckets && config.r2_buckets.length > 0) {
|
|
556
|
+
lines.push('# R2 Buckets');
|
|
557
|
+
for (const r2 of config.r2_buckets) {
|
|
558
|
+
lines.push(`[[env.${envName}.r2_buckets]]`);
|
|
559
|
+
lines.push(`binding = "${r2.binding}"`);
|
|
560
|
+
lines.push(`bucket_name = "${r2.bucket_name}"`);
|
|
561
|
+
lines.push('');
|
|
549
562
|
}
|
|
550
|
-
lines.push('');
|
|
551
563
|
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
564
|
+
// Queues
|
|
565
|
+
if (config.queues?.producers && config.queues.producers.length > 0) {
|
|
566
|
+
lines.push('# Cloudflare Queues');
|
|
567
|
+
for (const producer of config.queues.producers) {
|
|
568
|
+
lines.push(`[[env.${envName}.queues.producers]]`);
|
|
569
|
+
lines.push(`queue = "${producer.queue}"`);
|
|
570
|
+
lines.push(`binding = "${producer.binding}"`);
|
|
571
|
+
lines.push('');
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
// Durable Objects
|
|
575
|
+
if (config.durable_objects?.bindings && config.durable_objects.bindings.length > 0) {
|
|
576
|
+
lines.push('# Durable Objects Bindings');
|
|
577
|
+
for (const dob of config.durable_objects.bindings) {
|
|
578
|
+
lines.push(`[[env.${envName}.durable_objects.bindings]]`);
|
|
579
|
+
lines.push(`name = "${dob.name}"`);
|
|
580
|
+
lines.push(`class_name = "${dob.class_name}"`);
|
|
581
|
+
if (dob.script_name) {
|
|
582
|
+
lines.push(`script_name = "${dob.script_name}"`);
|
|
583
|
+
}
|
|
584
|
+
lines.push('');
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
// Environment variables
|
|
588
|
+
if (Object.keys(config.vars).length > 0) {
|
|
589
|
+
lines.push('# Environment Variables');
|
|
590
|
+
lines.push(`[env.${envName}.vars]`);
|
|
591
|
+
for (const [key, value] of Object.entries(config.vars)) {
|
|
592
|
+
if (value) {
|
|
593
|
+
lines.push(`${key} = "${value}"`);
|
|
563
594
|
}
|
|
564
|
-
lines.push(']');
|
|
565
595
|
}
|
|
566
596
|
lines.push('');
|
|
567
597
|
}
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
lines.push(
|
|
598
|
+
// Service Bindings
|
|
599
|
+
if (config.services && config.services.length > 0) {
|
|
600
|
+
lines.push('# Service Bindings');
|
|
601
|
+
for (const svc of config.services) {
|
|
602
|
+
lines.push(`[[env.${envName}.services]]`);
|
|
603
|
+
lines.push(`binding = "${svc.binding}"`);
|
|
604
|
+
lines.push(`service = "${svc.service}"`);
|
|
605
|
+
lines.push('');
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
// Routes
|
|
609
|
+
if (config.routes && config.routes.length > 0) {
|
|
610
|
+
lines.push('# Routes');
|
|
611
|
+
for (const route of config.routes) {
|
|
612
|
+
lines.push(`[[env.${envName}.routes]]`);
|
|
613
|
+
lines.push(`pattern = "${route.pattern}"`);
|
|
614
|
+
lines.push(`zone_name = "${route.zone_name}"`);
|
|
615
|
+
lines.push('');
|
|
576
616
|
}
|
|
577
617
|
}
|
|
578
|
-
lines.push('');
|
|
579
618
|
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
619
|
+
else {
|
|
620
|
+
// =========================================================================
|
|
621
|
+
// Legacy format: flat structure (backward compatibility)
|
|
622
|
+
// =========================================================================
|
|
623
|
+
// Basic fields
|
|
624
|
+
lines.push(`name = "${config.name}"`);
|
|
625
|
+
lines.push(`main = "${config.main}"`);
|
|
626
|
+
lines.push(`compatibility_date = "${config.compatibility_date}"`);
|
|
627
|
+
lines.push(`compatibility_flags = [${config.compatibility_flags.map((f) => `"${f}"`).join(', ')}]`);
|
|
628
|
+
lines.push(`workers_dev = ${config.workers_dev}`);
|
|
629
|
+
lines.push('');
|
|
630
|
+
// Placement
|
|
631
|
+
if (config.placement) {
|
|
632
|
+
lines.push('[placement]');
|
|
633
|
+
lines.push(`mode = "${config.placement.mode}"`);
|
|
587
634
|
lines.push('');
|
|
588
635
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
636
|
+
// KV Namespaces
|
|
637
|
+
if (config.kv_namespaces && config.kv_namespaces.length > 0) {
|
|
638
|
+
lines.push('# KV Namespaces');
|
|
639
|
+
for (const kv of config.kv_namespaces) {
|
|
640
|
+
lines.push('[[kv_namespaces]]');
|
|
641
|
+
lines.push(`binding = "${kv.binding}"`);
|
|
642
|
+
lines.push(`id = "${kv.id}"`);
|
|
643
|
+
if (kv.preview_id) {
|
|
644
|
+
lines.push(`preview_id = "${kv.preview_id}"`);
|
|
645
|
+
}
|
|
646
|
+
lines.push('');
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
// D1 Databases
|
|
650
|
+
if (config.d1_databases && config.d1_databases.length > 0) {
|
|
651
|
+
lines.push('# D1 Databases');
|
|
652
|
+
for (const db of config.d1_databases) {
|
|
653
|
+
lines.push('[[d1_databases]]');
|
|
654
|
+
lines.push(`binding = "${db.binding}"`);
|
|
655
|
+
lines.push(`database_name = "${db.database_name}"`);
|
|
656
|
+
lines.push(`database_id = "${db.database_id}"`);
|
|
657
|
+
lines.push('');
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
// R2 Buckets
|
|
661
|
+
if (config.r2_buckets && config.r2_buckets.length > 0) {
|
|
662
|
+
lines.push('# R2 Buckets');
|
|
663
|
+
for (const r2 of config.r2_buckets) {
|
|
664
|
+
lines.push('[[r2_buckets]]');
|
|
665
|
+
lines.push(`binding = "${r2.binding}"`);
|
|
666
|
+
lines.push(`bucket_name = "${r2.bucket_name}"`);
|
|
667
|
+
lines.push('');
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
// Queues
|
|
671
|
+
if (config.queues?.producers && config.queues.producers.length > 0) {
|
|
672
|
+
lines.push('# Cloudflare Queues');
|
|
673
|
+
for (const producer of config.queues.producers) {
|
|
674
|
+
lines.push('[[queues.producers]]');
|
|
675
|
+
lines.push(`queue = "${producer.queue}"`);
|
|
676
|
+
lines.push(`binding = "${producer.binding}"`);
|
|
677
|
+
lines.push('');
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
// Durable Objects
|
|
681
|
+
if (config.durable_objects?.bindings && config.durable_objects.bindings.length > 0) {
|
|
682
|
+
lines.push('# Durable Objects Bindings');
|
|
683
|
+
for (const dob of config.durable_objects.bindings) {
|
|
684
|
+
lines.push('[[durable_objects.bindings]]');
|
|
685
|
+
lines.push(`name = "${dob.name}"`);
|
|
686
|
+
lines.push(`class_name = "${dob.class_name}"`);
|
|
687
|
+
if (dob.script_name) {
|
|
688
|
+
lines.push(`script_name = "${dob.script_name}"`);
|
|
689
|
+
}
|
|
690
|
+
lines.push('');
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
// Migrations
|
|
694
|
+
if (config.migrations && config.migrations.length > 0) {
|
|
695
|
+
lines.push('# Durable Objects Migrations');
|
|
696
|
+
for (const migration of config.migrations) {
|
|
697
|
+
lines.push('[[migrations]]');
|
|
698
|
+
lines.push(`tag = "${migration.tag}"`);
|
|
699
|
+
if (migration.new_sqlite_classes && migration.new_sqlite_classes.length > 0) {
|
|
700
|
+
lines.push('new_sqlite_classes = [');
|
|
701
|
+
for (const cls of migration.new_sqlite_classes) {
|
|
702
|
+
lines.push(` "${cls}",`);
|
|
703
|
+
}
|
|
704
|
+
lines.push(']');
|
|
705
|
+
}
|
|
706
|
+
lines.push('');
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
// Environment variables
|
|
710
|
+
if (Object.keys(config.vars).length > 0) {
|
|
711
|
+
lines.push('# Environment Variables');
|
|
712
|
+
lines.push('[vars]');
|
|
713
|
+
for (const [key, value] of Object.entries(config.vars)) {
|
|
714
|
+
if (value) {
|
|
715
|
+
lines.push(`${key} = "${value}"`);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
597
718
|
lines.push('');
|
|
598
719
|
}
|
|
720
|
+
// Service Bindings
|
|
721
|
+
if (config.services && config.services.length > 0) {
|
|
722
|
+
lines.push('# Service Bindings');
|
|
723
|
+
for (const svc of config.services) {
|
|
724
|
+
lines.push('[[services]]');
|
|
725
|
+
lines.push(`binding = "${svc.binding}"`);
|
|
726
|
+
lines.push(`service = "${svc.service}"`);
|
|
727
|
+
lines.push('');
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
// Routes
|
|
731
|
+
if (config.routes && config.routes.length > 0) {
|
|
732
|
+
lines.push('# Routes');
|
|
733
|
+
for (const route of config.routes) {
|
|
734
|
+
lines.push('[[routes]]');
|
|
735
|
+
lines.push(`pattern = "${route.pattern}"`);
|
|
736
|
+
lines.push(`zone_name = "${route.zone_name}"`);
|
|
737
|
+
lines.push('');
|
|
738
|
+
}
|
|
739
|
+
}
|
|
599
740
|
}
|
|
600
741
|
return lines.join('\n');
|
|
601
742
|
}
|