| 47 | readonly userConfig: Omit<Unstable_RawConfig, 'main' | '$schema'>; |
| 48 | |
| 49 | constructor( |
| 50 | userConfig: Omit<Unstable_RawConfig, 'main' | '$schema'> & |
| 51 | // TODO: Remove deprecated fields in next major version, and update type to just Omit<Unstable_RawConfig, 'main' | '$schema'>. |
| 52 | { |
| 53 | /** @deprecated Use `name` instead. */ |
| 54 | projectName?: string; |
| 55 | /** @deprecated This parameter is not used internally. */ |
| 56 | workerNamespace?: string; |
| 57 | /** @deprecated Use `d1_databases` instead. */ |
| 58 | d1Databases?: D1DatabaseBinding[]; |
| 59 | /** @deprecated Use `kv_namespaces` instead. */ |
| 60 | kvNamespaces?: KVNamespaceBinding[]; |
| 61 | }, |
| 62 | ) { |
| 63 | super({ name: 'CLOUDFLARE' }); |
| 64 | |
| 65 | // Use 'browser' platform for Workers-compatible module resolution. |
| 66 | // This ensures packages with conditional exports (like the Cloudflare SDK) |
| 67 | // resolve to browser/worker implementations instead of Node.js-specific code |
| 68 | // that depends on unavailable modules like 'https'. |
| 69 | this.platform = 'browser'; |
| 70 | |
| 71 | this.userConfig = { ...userConfig }; |
| 72 | |
| 73 | if (userConfig.workerNamespace) { |
| 74 | console.warn('[CloudflareDeployer]: `workerNamespace` is no longer used'); |
| 75 | } |
| 76 | if (!userConfig.name && userConfig.projectName) { |
| 77 | this.userConfig.name = userConfig.projectName; |
| 78 | console.warn('[CloudflareDeployer]: `projectName` is deprecated, use `name` instead'); |
| 79 | } |
| 80 | if (!userConfig.d1_databases && userConfig.d1Databases) { |
| 81 | this.userConfig.d1_databases = userConfig.d1Databases; |
| 82 | console.warn('[CloudflareDeployer]: `d1Databases` is deprecated, use `d1_databases` instead'); |
| 83 | } |
| 84 | if (!userConfig.kv_namespaces && userConfig.kvNamespaces) { |
| 85 | this.userConfig.kv_namespaces = userConfig.kvNamespaces; |
| 86 | console.warn('[CloudflareDeployer]: `kvNamespaces` is deprecated, use `kv_namespaces` instead'); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | async writeFiles(outputDirectory: string): Promise<void> { |
| 91 | const { |