@powerlines/plugin-cloudflare 0.6.2 → 0.6.3
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
CHANGED
|
@@ -27,7 +27,7 @@ This package is part of the <b>🔌 Powerlines</b> monorepo. Powerlines is the "
|
|
|
27
27
|
|
|
28
28
|
<h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
29
29
|
|
|
30
|
-
[](https://stormsoftware.com/projects/powerlines) [](http://commitizen.github.io/cz-cli/)  
|
|
31
31
|
|
|
32
32
|
<!-- prettier-ignore-start -->
|
|
33
33
|
<!-- markdownlint-disable -->
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { For } from \"@alloy-js/core\";\nimport { getCloudflarePreset } from \"@cloudflare/unenv-preset\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport { readEnvTypeReflection } from \"@powerlines/plugin-env/helpers\";\nimport { resolveModule } from \"@powerlines/plugin-esbuild/helpers/resolve\";\nimport unenv from \"@powerlines/plugin-unenv\";\nimport * as pulumiCloudflare from \"@pulumi/cloudflare\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { joinPaths, replaceExtension } from \"@stryke/path\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { PartialKeys } from \"@stryke/types\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\n// eslint-disable-next-line camelcase\nimport { unstable_readConfig } from \"wrangler\";\nimport { CloudflareEnvBuiltin } from \"./components\";\nimport { CloudflareBuiltin } from \"./components/cloudflare-builtin\";\nimport { WorkerEntry } from \"./components/worker-entry\";\nimport { resolveWranglerConfigPath } from \"./helpers/wrangler\";\nimport {\n CloudflarePluginContext,\n CloudflarePluginOptions,\n CloudflareWorkerEntryModule\n} from \"./types/plugin\";\nimport { WorkerModule } from \"./types/worker-module\";\nimport { WranglerResolvedConfig, WranglerUserConfig } from \"./types/wrangler\";\n\nexport * from \"./components\";\nexport type * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n cloudflare?: CloudflarePluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to assist in developing other Powerlines plugins.\n */\nexport function plugin<\n TContext extends CloudflarePluginContext = CloudflarePluginContext\n>(options: CloudflarePluginOptions = {}) {\n return [\n unenv(options.unenv),\n {\n name: \"cloudflare\",\n config() {\n return {\n cloudflare: defu(omit(options, [\"unenv\"]), {\n configPath: resolveWranglerConfigPath(this)\n }),\n resolve: {\n skipNodeModulesBundle: false\n },\n unenv: {\n presets: [\n getCloudflarePreset({\n compatibilityDate: this.config.compatibilityDate?.toString(),\n compatibilityFlags: [\"nodejs_als\"]\n })\n ]\n }\n };\n },\n configResolved() {\n this.devDependencies[\"@cloudflare/workers-types\"] = \"^4.20240616.0\";\n\n const config: PartialKeys<WranglerUserConfig, \"build\" | \"define\"> =\n unstable_readConfig(\n { config: this.config.cloudflare?.configPath },\n { preserveOriginalMain: true, hideWarnings: true }\n );\n this.cloudflare.wrangler = structuredClone(\n config\n ) as WranglerResolvedConfig;\n },\n async prepare() {\n const result = await readEnvTypeReflection(this, \"env\");\n\n return render(\n this,\n <>\n <CloudflareBuiltin />\n <CloudflareEnvBuiltin reflection={result} />\n </>\n );\n },\n build: {\n order: \"pre\",\n async handler() {\n this.cloudflare ??= { workers: [] };\n this.cloudflare.workers = await Promise.all(\n this.entry.map(async (entry, i, arr) => {\n if (!entry.input) {\n throw new Error(\n `Cloudflare Worker entry \"${entry.file}\" is missing an input file.`\n );\n }\n\n const workerModule = await resolveModule<WorkerModule>(\n this,\n entry.input\n );\n if (!workerModule?.default) {\n throw new Error(\n `Cloudflare Worker entry \"${\n entry.file\n }\" does not export a default handler. The Powerlines Cloudflare plugin expects each Worker entry module to export a default object matching the \\`ExportedHandler\\` interface from \"@cloudflare/workers-types\".`\n );\n }\n\n const name =\n workerModule.metadata?.name ||\n replaceExtension(entry.input.file || entry.file) ||\n arr.length > 1\n ? `${this.config.name}-${i}`\n : this.config.name;\n\n return {\n metadata: {\n name,\n pattern: `${name}.{domain}`,\n entry\n },\n fetch: isFunction(workerModule.default.fetch),\n tail: isFunction(workerModule.default.tail),\n trace: isFunction(workerModule.default.trace),\n tailStream: isFunction(workerModule.default.tailStream),\n scheduled: isFunction(workerModule.default.scheduled),\n test: isFunction(workerModule.default.test),\n email: isFunction(workerModule.default.email),\n queue: isFunction(workerModule.default.queue)\n } satisfies CloudflareWorkerEntryModule;\n })\n );\n\n return render(\n this,\n <For each={this.cloudflare.workers}>\n {worker => <WorkerEntry worker={worker} />}\n </For>\n );\n }\n },\n async deploy() {\n let apiToken = process.env.CLOUDFLARE_API_TOKEN;\n if (!apiToken) {\n apiToken = this.config.cloudflare.apiToken;\n if (apiToken) {\n this.warn(\n \"If possible, please use the `CLOUDFLARE_API_TOKEN` environment variable instead of using the `apiToken` option directly. The `apiToken` option will work; however, this is a less secure method of configuration.\"\n );\n } else {\n throw new Error(\n \"Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.\"\n );\n }\n }\n\n // for (const worker of this.cloudflare.workers) {\n // }\n },\n async deployPulumi() {\n let apiToken = process.env.CLOUDFLARE_API_TOKEN;\n if (!apiToken) {\n apiToken = this.config.cloudflare.apiToken;\n if (apiToken) {\n this.warn(\n \"If possible, please use the `CLOUDFLARE_API_TOKEN` environment variable instead of using the `apiToken` option directly. The `apiToken` option will work; however, this is a less secure method of configuration.\"\n );\n } else {\n throw new Error(\n \"Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.\"\n );\n }\n }\n\n await this.pulumi.setConfig(\"cloudflare:apiToken\", {\n value: apiToken\n });\n\n const provider = new pulumiCloudflare.Provider(\"cloudflare-provider\", {\n apiToken\n });\n\n const zone = await pulumiCloudflare.getZone(\n {\n filter: {\n account: { id: this.config.cloudflare.accountId },\n name: this.config.cloudflare.domain\n }\n },\n { provider }\n );\n\n const workers = [] as pulumiCloudflare.Worker[];\n const workerVersions = [] as pulumiCloudflare.WorkerVersion[];\n const workersDeployments = [] as pulumiCloudflare.WorkersDeployment[];\n const workersRoutes = [] as pulumiCloudflare.WorkersRoute[];\n const dnsRecords = [] as pulumiCloudflare.DnsRecord[];\n for (const worker of this.cloudflare.workers) {\n const resource = new pulumiCloudflare.Worker(\n `${this.config.organization ? `${this.config.organization}.` : \"\"}${\n kebabCase(this.config.name) === kebabCase(worker.metadata.name)\n ? kebabCase(this.config.name)\n : `${kebabCase(this.config.name)}.${kebabCase(\n worker.metadata.name\n )}`\n }.${kebabCase(this.config.mode)}.worker`,\n defu(\n {\n accountId: this.config.cloudflare.accountId,\n name: worker.metadata.name,\n tags: [\n `project:${kebabCase(this.config.name)}`,\n this.config.organization\n ? `organization:${kebabCase(this.config.organization)}`\n : undefined,\n this.config.mode\n ? `mode:${kebabCase(this.config.mode)}`\n : undefined\n ].filter(Boolean) as string[]\n },\n worker.metadata\n ) as pulumiCloudflare.WorkerArgs,\n { provider }\n );\n workers.push(resource);\n\n const workerVersion = new pulumiCloudflare.WorkerVersion(\n `${this.config.organization ? `${this.config.organization}.` : \"\"}${\n kebabCase(this.config.name) === kebabCase(worker.metadata.name)\n ? kebabCase(this.config.name)\n : `${kebabCase(this.config.name)}.${kebabCase(\n worker.metadata.name\n )}`\n }.${kebabCase(this.config.mode)}.worker-version`,\n defu(\n {\n accountId: this.config.cloudflare.accountId,\n workerId: resource.id,\n mainModule: joinPaths(this.config.output.path, \"index.mjs\"),\n modules: [\n {\n name: joinPaths(this.config.output.path, \"index.mjs\"),\n contentType: \"application/javascript+module\",\n contentFile: joinPaths(this.config.output.path, \"index.mjs\")\n }\n ]\n },\n worker.metadata,\n {\n compatibilityDate:\n this.config.compatibilityDate?.cloudflare?.toString() as string,\n compatibilityFlags: [\"nodejs_als\"]\n }\n ) as pulumiCloudflare.WorkerVersionArgs,\n { provider }\n );\n workerVersions.push(workerVersion);\n\n const workersDeployment = new pulumiCloudflare.WorkersDeployment(\n `${this.config.organization ? `${this.config.organization}.` : \"\"}${\n kebabCase(this.config.name) === kebabCase(worker.metadata.name)\n ? kebabCase(this.config.name)\n : `${kebabCase(this.config.name)}-${kebabCase(\n worker.metadata.name\n )}`\n }.${kebabCase(this.config.mode)}.workers-deployment`,\n defu({\n accountId: this.config.cloudflare.accountId,\n zoneId: zone.id,\n strategy: \"percentage\",\n scriptName: resource.name,\n versions: [\n {\n percentage: 100,\n versionId: workerVersion.id\n }\n ]\n }),\n { provider }\n );\n workersDeployments.push(workersDeployment);\n\n const workersRoute = new pulumiCloudflare.WorkersRoute(\n `${this.config.organization ? `${this.config.organization}.` : \"\"}${\n kebabCase(this.config.name) === kebabCase(worker.metadata.name)\n ? kebabCase(this.config.name)\n : `${kebabCase(this.config.name)}-${kebabCase(\n worker.metadata.name\n )}`\n }.${kebabCase(this.config.mode)}.workers-route`,\n defu({\n accountId: this.config.cloudflare.accountId,\n zoneId: zone.id,\n pattern: worker.metadata.pattern\n .replace(\"{domain}\", this.config.cloudflare.domain)\n .replace(\"{scriptName}\", worker.metadata.name)\n .replace(\"{mode}\", this.config.mode),\n script: resource.name\n }),\n { provider }\n );\n workersRoutes.push(workersRoute);\n\n const dnsRecord = new pulumiCloudflare.DnsRecord(\n `${this.config.organization ? `${this.config.organization}.` : \"\"}${\n kebabCase(this.config.name) === kebabCase(worker.metadata.name)\n ? kebabCase(this.config.name)\n : `${kebabCase(this.config.name)}-${kebabCase(\n worker.metadata.name\n )}`\n }.${kebabCase(this.config.mode)}.dns-record`,\n {\n name: workersRoute.pattern,\n type: \"A\",\n content: \"192.0.2.1\",\n zoneId: zone.id,\n proxied: true,\n ttl: 1\n },\n { provider }\n );\n dnsRecords.push(dnsRecord);\n }\n\n return {\n workers,\n workerVersions,\n workersDeployments,\n workersRoutes,\n dnsRecords\n };\n }\n }\n ] as Plugin<TContext>[];\n}\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAqDA,SAAA,OAAA,UAAA,EAAA,EAAA;;EAEE,MAAA;EACE,SAAC;AACH,UAAA;IACK,YAAS,KAAM,KAAA,SAAA,CAAA,QAAA,CAAA,EAAA,EACZ,YAAS,0BAA0B,KAAA,EACpC,CAAC;IACF,SAAC,EACC,uBAAc,OACpB;IACE,OAAO,EACP,SAAS,CAAA,oBAAA;KACP,mBAAO,KAAA,OAAA,mBAAA,UAAA;KACL,oBAAsB,CAAA,aAAW;KAChC,CAAC,CAAA,EACH;IACF;;EAEH,iBAAO;AACL,QAAI,gBAAO,+BAAA;GACX,MAAM,SAAS,oBAAA,EACb,QAAM,KAAA,OAAA,YAAoB,YAC3B,EAAE;IACD,sBAAQ;IACR,cAAO;IACR,CAAC;AACF,QAAI,WAAA,WAAA,gBAAA,OAAA;;EAEN,MAAG,UAAA;GACD,MAAA,SAAe,MAAE,sBAAA,MAAA,MAAA;AACjB,UAAO,OAAA,MAAA,CAAA,gBAA6B,mBAAsB,EAAA,CAAA,EAAA,gBAAW,sBAAA,sBAEpE,CAAC,CAAA,CAAA;;EAEJ,OAAO;GACL,OAAO;GACP,MAAK,UAAA;IACH,MAAK,SAAU;AACf,SAAE,eAAA,EACA,SAAG,EAAA,EACN;AACD,SAAM,WAAU,UAAA,MAAA,QAAA,IAAA,KAAA,MAAA,IAA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,SAAA,KAAA,GAAA,UAAA,KAAA,OAAA,KAAA,GAAA,GAAA,UAAA,KAAA,OAAA,KAAA,CAAA,GAAA,UAAA,OAAA,SAAA,KAAA,GAAA,GAAA,UAAA,KAAA,OAAA,KAAA,CAAA,cAAA;KAClE,MAAM,aAAY;KAClB,MAAM;KACN,SAAS;KACT,QAAQ,KAAE;KACV,SAAM;KACN,KAAE;KACH,EAAE,EACD,UACD,CAAC;AACF,eAAQ,KAAM,UAAA;;AAEhB,UAAO;IACL;IACA;IACA;IACA;IACA;IACD;;EAEJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { For } from \"@alloy-js/core\";\nimport { getCloudflarePreset } from \"@cloudflare/unenv-preset\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport { readEnvTypeReflection } from \"@powerlines/plugin-env/helpers\";\nimport { resolveModule } from \"@powerlines/plugin-esbuild/helpers/resolve\";\nimport unenv from \"@powerlines/plugin-unenv\";\nimport * as pulumiCloudflare from \"@pulumi/cloudflare\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { joinPaths, replaceExtension } from \"@stryke/path\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { PartialKeys } from \"@stryke/types\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\n\nimport { unstable_readConfig } from \"wrangler\";\nimport { CloudflareEnvBuiltin } from \"./components\";\nimport { CloudflareBuiltin } from \"./components/cloudflare-builtin\";\nimport { WorkerEntry } from \"./components/worker-entry\";\nimport { resolveWranglerConfigPath } from \"./helpers/wrangler\";\nimport {\n CloudflarePluginContext,\n CloudflarePluginOptions,\n CloudflareWorkerEntryModule\n} from \"./types/plugin\";\nimport { WorkerModule } from \"./types/worker-module\";\nimport { WranglerResolvedConfig, WranglerUserConfig } from \"./types/wrangler\";\n\nexport * from \"./components\";\nexport type * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n cloudflare?: CloudflarePluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to assist in developing other Powerlines plugins.\n */\nexport function plugin<\n TContext extends CloudflarePluginContext = CloudflarePluginContext\n>(options: CloudflarePluginOptions = {}) {\n return [\n unenv(options.unenv),\n {\n name: \"cloudflare\",\n config() {\n return {\n cloudflare: defu(omit(options, [\"unenv\"]), {\n configPath: resolveWranglerConfigPath(this)\n }),\n resolve: {\n skipNodeModulesBundle: false\n },\n unenv: {\n presets: [\n getCloudflarePreset({\n compatibilityDate: this.config.compatibilityDate?.toString(),\n compatibilityFlags: [\"nodejs_als\"]\n })\n ]\n }\n };\n },\n configResolved() {\n this.devDependencies[\"@cloudflare/workers-types\"] = \"^4.20240616.0\";\n\n const config: PartialKeys<WranglerUserConfig, \"build\" | \"define\"> =\n unstable_readConfig(\n { config: this.config.cloudflare?.configPath },\n { preserveOriginalMain: true, hideWarnings: true }\n );\n this.cloudflare.wrangler = structuredClone(\n config\n ) as WranglerResolvedConfig;\n },\n async prepare() {\n const result = await readEnvTypeReflection(this, \"env\");\n\n return render(\n this,\n <>\n <CloudflareBuiltin />\n <CloudflareEnvBuiltin reflection={result} />\n </>\n );\n },\n build: {\n order: \"pre\",\n async handler() {\n this.cloudflare ??= { workers: [] };\n this.cloudflare.workers = await Promise.all(\n this.entry.map(async (entry, i, arr) => {\n if (!entry.input) {\n throw new Error(\n `Cloudflare Worker entry \"${entry.file}\" is missing an input file.`\n );\n }\n\n const workerModule = await resolveModule<WorkerModule>(\n this,\n entry.input\n );\n if (!workerModule?.default) {\n throw new Error(\n `Cloudflare Worker entry \"${\n entry.file\n }\" does not export a default handler. The Powerlines Cloudflare plugin expects each Worker entry module to export a default object matching the \\`ExportedHandler\\` interface from \"@cloudflare/workers-types\".`\n );\n }\n\n const name =\n workerModule.metadata?.name ||\n replaceExtension(entry.input.file || entry.file) ||\n arr.length > 1\n ? `${this.config.name}-${i}`\n : this.config.name;\n\n return {\n metadata: {\n name,\n pattern: `${name}.{domain}`,\n entry\n },\n fetch: isFunction(workerModule.default.fetch),\n tail: isFunction(workerModule.default.tail),\n trace: isFunction(workerModule.default.trace),\n tailStream: isFunction(workerModule.default.tailStream),\n scheduled: isFunction(workerModule.default.scheduled),\n test: isFunction(workerModule.default.test),\n email: isFunction(workerModule.default.email),\n queue: isFunction(workerModule.default.queue)\n } satisfies CloudflareWorkerEntryModule;\n })\n );\n\n return render(\n this,\n <For each={this.cloudflare.workers}>\n {worker => <WorkerEntry worker={worker} />}\n </For>\n );\n }\n },\n async deploy() {\n let apiToken = process.env.CLOUDFLARE_API_TOKEN;\n if (!apiToken) {\n apiToken = this.config.cloudflare.apiToken;\n if (apiToken) {\n this.warn(\n \"If possible, please use the `CLOUDFLARE_API_TOKEN` environment variable instead of using the `apiToken` option directly. The `apiToken` option will work; however, this is a less secure method of configuration.\"\n );\n } else {\n throw new Error(\n \"Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.\"\n );\n }\n }\n\n // for (const worker of this.cloudflare.workers) {\n // }\n },\n async deployPulumi() {\n let apiToken = process.env.CLOUDFLARE_API_TOKEN;\n if (!apiToken) {\n apiToken = this.config.cloudflare.apiToken;\n if (apiToken) {\n this.warn(\n \"If possible, please use the `CLOUDFLARE_API_TOKEN` environment variable instead of using the `apiToken` option directly. The `apiToken` option will work; however, this is a less secure method of configuration.\"\n );\n } else {\n throw new Error(\n \"Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.\"\n );\n }\n }\n\n await this.pulumi.setConfig(\"cloudflare:apiToken\", {\n value: apiToken\n });\n\n const provider = new pulumiCloudflare.Provider(\"cloudflare-provider\", {\n apiToken\n });\n\n const zone = await pulumiCloudflare.getZone(\n {\n filter: {\n account: { id: this.config.cloudflare.accountId },\n name: this.config.cloudflare.domain\n }\n },\n { provider }\n );\n\n const workers = [] as pulumiCloudflare.Worker[];\n const workerVersions = [] as pulumiCloudflare.WorkerVersion[];\n const workersDeployments = [] as pulumiCloudflare.WorkersDeployment[];\n const workersRoutes = [] as pulumiCloudflare.WorkersRoute[];\n const dnsRecords = [] as pulumiCloudflare.DnsRecord[];\n for (const worker of this.cloudflare.workers) {\n const resource = new pulumiCloudflare.Worker(\n `${this.config.organization ? `${this.config.organization}.` : \"\"}${\n kebabCase(this.config.name) === kebabCase(worker.metadata.name)\n ? kebabCase(this.config.name)\n : `${kebabCase(this.config.name)}.${kebabCase(\n worker.metadata.name\n )}`\n }.${kebabCase(this.config.mode)}.worker`,\n defu(\n {\n accountId: this.config.cloudflare.accountId,\n name: worker.metadata.name,\n tags: [\n `project:${kebabCase(this.config.name)}`,\n this.config.organization\n ? `organization:${kebabCase(this.config.organization)}`\n : undefined,\n this.config.mode\n ? `mode:${kebabCase(this.config.mode)}`\n : undefined\n ].filter(Boolean) as string[]\n },\n worker.metadata\n ) as pulumiCloudflare.WorkerArgs,\n { provider }\n );\n workers.push(resource);\n\n const workerVersion = new pulumiCloudflare.WorkerVersion(\n `${this.config.organization ? `${this.config.organization}.` : \"\"}${\n kebabCase(this.config.name) === kebabCase(worker.metadata.name)\n ? kebabCase(this.config.name)\n : `${kebabCase(this.config.name)}.${kebabCase(\n worker.metadata.name\n )}`\n }.${kebabCase(this.config.mode)}.worker-version`,\n defu(\n {\n accountId: this.config.cloudflare.accountId,\n workerId: resource.id,\n mainModule: joinPaths(this.config.output.path, \"index.mjs\"),\n modules: [\n {\n name: joinPaths(this.config.output.path, \"index.mjs\"),\n contentType: \"application/javascript+module\",\n contentFile: joinPaths(this.config.output.path, \"index.mjs\")\n }\n ]\n },\n worker.metadata,\n {\n compatibilityDate:\n this.config.compatibilityDate?.cloudflare?.toString() as string,\n compatibilityFlags: [\"nodejs_als\"]\n }\n ) as pulumiCloudflare.WorkerVersionArgs,\n { provider }\n );\n workerVersions.push(workerVersion);\n\n const workersDeployment = new pulumiCloudflare.WorkersDeployment(\n `${this.config.organization ? `${this.config.organization}.` : \"\"}${\n kebabCase(this.config.name) === kebabCase(worker.metadata.name)\n ? kebabCase(this.config.name)\n : `${kebabCase(this.config.name)}-${kebabCase(\n worker.metadata.name\n )}`\n }.${kebabCase(this.config.mode)}.workers-deployment`,\n defu({\n accountId: this.config.cloudflare.accountId,\n zoneId: zone.id,\n strategy: \"percentage\",\n scriptName: resource.name,\n versions: [\n {\n percentage: 100,\n versionId: workerVersion.id\n }\n ]\n }),\n { provider }\n );\n workersDeployments.push(workersDeployment);\n\n const workersRoute = new pulumiCloudflare.WorkersRoute(\n `${this.config.organization ? `${this.config.organization}.` : \"\"}${\n kebabCase(this.config.name) === kebabCase(worker.metadata.name)\n ? kebabCase(this.config.name)\n : `${kebabCase(this.config.name)}-${kebabCase(\n worker.metadata.name\n )}`\n }.${kebabCase(this.config.mode)}.workers-route`,\n defu({\n accountId: this.config.cloudflare.accountId,\n zoneId: zone.id,\n pattern: worker.metadata.pattern\n .replace(\"{domain}\", this.config.cloudflare.domain)\n .replace(\"{scriptName}\", worker.metadata.name)\n .replace(\"{mode}\", this.config.mode),\n script: resource.name\n }),\n { provider }\n );\n workersRoutes.push(workersRoute);\n\n const dnsRecord = new pulumiCloudflare.DnsRecord(\n `${this.config.organization ? `${this.config.organization}.` : \"\"}${\n kebabCase(this.config.name) === kebabCase(worker.metadata.name)\n ? kebabCase(this.config.name)\n : `${kebabCase(this.config.name)}-${kebabCase(\n worker.metadata.name\n )}`\n }.${kebabCase(this.config.mode)}.dns-record`,\n {\n name: workersRoute.pattern,\n type: \"A\",\n content: \"192.0.2.1\",\n zoneId: zone.id,\n proxied: true,\n ttl: 1\n },\n { provider }\n );\n dnsRecords.push(dnsRecord);\n }\n\n return {\n workers,\n workerVersions,\n workersDeployments,\n workersRoutes,\n dnsRecords\n };\n }\n }\n ] as Plugin<TContext>[];\n}\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoDA,SAAE,OAAA,UAAA,EAAA,EAAA;AACF,QAAA,CAAA,MAAA,QAAA,MAAA,EAAA;;EAEE,SAAA;AACG,UAAA;IACH,YAAA,KAAA,KAAA,SAAA,CAAA,QAAA,CAAA,EAAA,EACK,YAAe,0BAAA,KAAA,EACpB,CAAQ;IACR,SAAS,EACF,uBAAA,OACA;IACL,OAAA,EACM,SAAG,CAAA,oBAAW;KACZ,mBAAG,KAAA,OAAA,mBAAA,UAAA;KACP,oBAAO,CAAA,aAAA;KACL,CAAA,CAAA,EACD;IACF;;EAEH,iBAAQ;AACN,QAAK,gBAAA,+BAAA;GACL,MAAI,SAAO,oBAAA,EACT,QAAI,KAAS,OAAA,YAAA,YACd,EAAE;IACD,sBAAQ;IACR,cAAQ;IACT,CAAC;AACF,QAAK,WAAC,WAAA,gBAAA,OAAA;;EAER,MAAK,UAAA;GACH,MAAC,SAAA,MAAA,sBAAA,MAAA,MAAA;AACD,UAAA,OAAc,MAAG,CAAA,gBAAA,mBAAA,EAAA,CAAA,EAAA,gBAAA,sBAAA,EACf,YAAK;;EAGT,OAAM;GACJ,OAAO;GACP,MAAM,UAAE;IACN,MAAG,SAAA;AACH,SAAK,eAAW,EACd,SAAA,EAAA,EACD;AACF,SAAA,WAAA,UAAA,MAAA,QAAA,IAAA,KAAA,MAAA,IAAA,OAAA,OAAA,GAAA,QAAA;AACD,SAAM,CAAA,MAAS,MACb,OAAM,IAAQ,MAAM,4BAA4B,MAAM,KAAC,6BAAA;KAEvD,MAAO,eAAM,MAAA,cAAA,MAAA,MAAA,MAAA;A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,OAAA,SAAA,KAAA,GAAA,GAAA,UAAA,KAAA,OAAA,KAAA,CAAA,cAAA;KACrE,MAAI,aAAe;KACnB,MAAM;KACN,SAAS;KACT,QAAQ,KAAE;KACV,SAAS;KACT,KAAK;KACN,EAAE,EACD,UACD,CAAC;AACF,eAAQ,KAAM,UAAO;;AAEvB,UAAO;IACL;IACA;IACA;IACA;IACA;IACD;;EAEJ,CAAC"}
|
package/dist/types/wrangler.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrangler.d.cts","names":[],"sources":["../../src/types/wrangler.ts"],"mappings":";;;;;KAyBY,iBAAA,WAA4B,EAAA,CAAG,QAAA,gBACzC,CAAA,SAAU,EAAA,CAAG,QAAA,GAAW,EAAA,CAAG,KAAA,CAAM,CAAA;AAAA,cAGtB,aAAA,EAAa,CAAA,CAAA,QAAA,WAAA,CAAA,CAAA,SAAA,EAAA,CAAA,CAAA,SAAA,EAAA,CAAA,CAAA,UAAA,EAAA,CAAA,CAAA,OAAA;AAAA,KAMd,OAAA,GAAU,CAAA,CAAE,KAAA,QAAa,aAAA;AAAA,KACzB,IAAA,GAAO,OAAA;EAAA,CAAa,GAAA,WAAc,IAAA;AAAA,IAAS,IAAA;AAAA,cAC1C,UAAA,EAAY,CAAA,CAAE,OAAA,CAAQ,IAAA;AAAA,iBASb,iBAAA,WAA4B,EAAA,CAAG,QAAA,CAAA,CACnD,WAAA,UACA,MAAA,EAAQ,CAAA,EACR,OAAA,EAAS,EAAA,CAAG,YAAA,OACZ,GAAA,EAAK,CAAA,CAAE,IAAA,CAAK,oBAAA,GAAoB,OAAA,CAAA,CAAA,CAAA,IAAA,CAAA,YAAA;AAAA,cASrB,UAAA,EAAU,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,SAAA,EAAA,CAAA,CAAA,YAAA;AAAA,iBAQP,QAAA,CAAS,KAAA,WAAgB,IAAA,GAAI,GAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"wrangler.d.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,CACnD,WAAA,UACA,MAAA,EAAQ,CAAA,EACR,OAAA,EAAS,EAAA,CAAG,YAAA,OACZ,GAAA,EAAK,CAAA,CAAE,IAAA,CAAK,oBAAA,GAAoB,OAAA,CAAA,CAAA,CAAA,IAAA,CAAA,YAAA;AAAA,cASrB,UAAA,EAAU,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,SAAA,EAAA,CAAA,CAAA,YAAA;AAAA,iBAQP,QAAA,CAAS,KAAA,WAAgB,IAAA,GAAI,GAAA;AAAA,KAWjC,kBAAA,GAAqB,kBAAA;;;;;;;;;;;;;AAjDjC;;KAkEY,sBAAA,GAAyB,eAAA;AAAA,cAExB,qBAAA,EAAuB,sBAAA;AAAA"}
|
package/dist/types/wrangler.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrangler.mjs","names":[],"sources":["../../src/types/wrangler.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport assert from \"node:assert\";\nimport path from \"node:path\";\n
|
|
1
|
+
{"version":3,"file":"wrangler.mjs","names":[],"sources":["../../src/types/wrangler.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport assert from \"node:assert\";\nimport path from \"node:path\";\n\nimport type { Unstable_Config, Unstable_RawConfig } from \"wrangler\";\nimport * as z from \"zod\";\nimport * as z4 from \"zod/v4/core\";\n\nexport type OptionalZodTypeOf<T extends z4.$ZodType | undefined> =\n T extends z4.$ZodType ? z4.infer<T> : undefined;\n\n// https://github.com/colinhacks/zod/blob/59768246aa57133184b2cf3f7c2a1ba5c3ab08c3/README.md?plain=1#L1302-L1317\nexport const LiteralSchema = z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null()\n]);\nexport type Literal = z.infer<typeof LiteralSchema>;\nexport type Json = Literal | { [key: string]: Json } | Json[];\nexport const JsonSchema: z.ZodType<Json> = z.lazy(() =>\n z.union([\n LiteralSchema,\n z.array(JsonSchema),\n z.record(z.string(), JsonSchema)\n ])\n);\n\nlet rootPath: string | undefined;\nexport async function parseWithRootPath<Z extends z4.$ZodType>(\n newRootPath: string,\n schema: Z,\n payload: z4.ParsePayload<any>,\n ctx: z.core.ParseContextInternal\n) {\n rootPath = newRootPath;\n try {\n return await schema._zod.parse(payload, ctx);\n } finally {\n rootPath = undefined;\n }\n}\nexport const PathSchema = z.string().transform(p => {\n assert(\n rootPath !== undefined,\n \"Expected `PathSchema` to be parsed within `parseWithRootPath()`\"\n );\n return path.resolve(rootPath, p);\n});\n\nexport function isCyclic(value: unknown, seen = new Set<unknown>()) {\n if (typeof value !== \"object\" || value === null) return false;\n for (const child of Object.values(value)) {\n if (seen.has(child)) return true;\n seen.add(child);\n if (isCyclic(child, seen)) return true;\n seen.delete(child);\n }\n return false;\n}\n\nexport type WranglerUserConfig = Unstable_RawConfig;\n\n/**\n * This is the static type definition for the configuration object.\n *\n * It reflects a normalized and validated version of the configuration that you can write in a Wrangler configuration file,\n * and optionally augment with arguments passed directly to wrangler.\n *\n * For more information about the configuration object, see the documentation at https://developers.cloudflare.com/workers/cli-wrangler/configuration\n *\n * @remarks\n * - Fields that are only specified in `ConfigFields` and not `Environment` can only appear\n * in the top level config and should not appear in any environments.\n * - Fields that are specified in `PagesConfigFields` are only relevant for Pages projects\n * - All top level fields in config and environments are optional in the Wrangler configuration file.\n */\n\nexport type WranglerResolvedConfig = Unstable_Config;\n\nexport const defaultWranglerConfig: WranglerResolvedConfig = {\n /* COMPUTED_FIELDS */\n configPath: undefined,\n userConfigPath: undefined,\n topLevelName: undefined,\n definedEnvironments: undefined,\n targetEnvironment: undefined,\n\n /*= =================================================== */\n /* Fields supported by both Workers & Pages */\n /*= =================================================== */\n /* TOP-LEVEL ONLY FIELDS */\n pages_build_output_dir: undefined,\n send_metrics: undefined,\n dev: {\n ip: process.platform === \"win32\" ? \"127.0.0.1\" : \"localhost\",\n port: undefined, // the default of 8787 is set at runtime\n inspector_port: undefined, // the default of 9229 is set at runtime\n inspector_ip: undefined, // the default of 127.0.0.1 is set at runtime\n local_protocol: \"http\",\n upstream_protocol: \"http\",\n host: undefined,\n // Note this one is also workers only\n enable_containers: true,\n container_engine: undefined,\n generate_types: false\n },\n\n /** INHERITABLE ENVIRONMENT FIELDS */\n name: undefined,\n compatibility_date: undefined,\n compatibility_flags: [],\n limits: undefined,\n placement: undefined,\n\n /** NON-INHERITABLE ENVIRONMENT FIELDS */\n vars: {},\n durable_objects: { bindings: [] },\n kv_namespaces: [],\n queues: {\n producers: [],\n consumers: [] // WORKERS SUPPORT ONLY!!\n },\n r2_buckets: [],\n d1_databases: [],\n vectorize: [],\n hyperdrive: [],\n workflows: [],\n secrets_store_secrets: [],\n services: [],\n analytics_engine_datasets: [],\n ai: undefined,\n images: undefined,\n stream: undefined,\n media: undefined,\n version_metadata: undefined,\n unstable_hello_world: [],\n ratelimits: [],\n worker_loaders: [],\n\n /*= =================================================== */\n /* Fields supported by Workers only */\n /*= =================================================== */\n /* TOP-LEVEL ONLY FIELDS */\n legacy_env: true,\n site: undefined,\n wasm_modules: undefined,\n text_blobs: undefined,\n data_blobs: undefined,\n keep_vars: undefined,\n alias: undefined,\n\n /** INHERITABLE ENVIRONMENT FIELDS */\n account_id: undefined,\n main: undefined,\n find_additional_modules: undefined,\n preserve_file_names: undefined,\n base_dir: undefined,\n workers_dev: undefined,\n preview_urls: undefined,\n route: undefined,\n routes: undefined,\n tsconfig: undefined,\n jsx_factory: \"React.createElement\",\n jsx_fragment: \"React.Fragment\",\n migrations: [],\n triggers: {\n crons: undefined\n },\n rules: [],\n build: { command: undefined, watch_dir: \"./src\", cwd: undefined },\n no_bundle: undefined,\n minify: undefined,\n keep_names: undefined,\n dispatch_namespaces: [],\n first_party_worker: undefined,\n logfwdr: { bindings: [] },\n logpush: undefined,\n upload_source_maps: undefined,\n assets: undefined,\n observability: { enabled: true },\n cache: undefined,\n /** The default here is undefined so that we can delegate to the CLOUDFLARE_COMPLIANCE_REGION environment variable. */\n compliance_region: undefined,\n python_modules: { exclude: [\"**/*.pyc\"] },\n\n /** NON-INHERITABLE ENVIRONMENT FIELDS */\n define: {},\n cloudchamber: {},\n containers: undefined,\n send_email: [],\n browser: undefined,\n unsafe: {},\n mtls_certificates: [],\n tail_consumers: undefined,\n streaming_tail_consumers: undefined,\n pipelines: [],\n vpc_services: []\n};\n"],"mappings":";;;;;AA6BA,MAAa,gBAAgB,EAAE,MAAM;CACnC,EAAE,QAAQ;CACV,EAAE,QAAQ;CACV,EAAE,SAAS;CACX,EAAE,MAAM;CACT,CAAC;AAGF,MAAa,aAA8B,EAAE,WAC3C,EAAE,MAAM;CACN;CACA,EAAE,MAAM,WAAW;CACnB,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW;CACjC,CAAC,CACH;AAED,IAAI;AACJ,eAAsB,kBACpB,aACA,QACA,SACA,KACA;AACA,YAAW;AACX,KAAI;AACF,SAAO,MAAM,OAAO,KAAK,MAAM,SAAS,IAAI;WACpC;AACR,aAAW;;;AAGf,MAAa,aAAa,EAAE,QAAQ,CAAC,WAAU,MAAK;AAClD,Q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qBAAqB;CACrB,UAAU;CACV,aAAa;CACb,cAAc;CACd,OAAO;CACP,QAAQ;CACR,UAAU;CACV,aAAa;CACb,cAAc;CACd,YAAY,EAAE;CACd,UAAU,EACR,OAAO,QACR;CACD,OAAO,EAAE;CACT,OAAO;EAAE,SAAS;EAAW,WAAW;EAAS,KAAK;EAAW;CACjE,WAAW;CACX,QAAQ;CACR,YAAY;CACZ,qBAAqB,EAAE;CACvB,oBAAoB;CACpB,SAAS,EAAE,UAAU,EAAE,EAAE;CACzB,SAAS;CACT,oBAAoB;CACpB,QAAQ;CACR,eAAe,EAAE,SAAS,MAAM;CAChC,OAAO;CAEP,mBAAmB;CACnB,gBAAgB,EAAE,SAAS,CAAC,WAAW,EAAE;CAGzC,QAAQ,EAAE;CACV,cAAc,EAAE;CAChB,YAAY;CACZ,YAAY,EAAE;CACd,SAAS;CACT,QAAQ,EAAE;CACV,mBAAmB,EAAE;CACrB,gBAAgB;CAChB,0BAA0B;CAC1B,WAAW,EAAE;CACb,cAAc,EAAE;CACjB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-cloudflare",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A Powerlines plugin that provides integration with Cloudflare services.",
|
|
6
6
|
"keywords": ["powerlines", "storm-software", "powerlines-plugin"],
|
|
@@ -209,12 +209,12 @@
|
|
|
209
209
|
"dependencies": {
|
|
210
210
|
"@alloy-js/core": "0.23.0-dev.8",
|
|
211
211
|
"@alloy-js/typescript": "0.23.0-dev.4",
|
|
212
|
-
"@powerlines/plugin-env": "^0.16.
|
|
213
|
-
"@powerlines/plugin-pulumi": "^0.6.
|
|
214
|
-
"@powerlines/plugin-unenv": "^0.1.
|
|
212
|
+
"@powerlines/plugin-env": "^0.16.104",
|
|
213
|
+
"@powerlines/plugin-pulumi": "^0.6.23",
|
|
214
|
+
"@powerlines/plugin-unenv": "^0.1.371",
|
|
215
215
|
"@pulumi/cloudflare": "^6.13.0",
|
|
216
216
|
"@pulumi/pulumi": "^3.228.0",
|
|
217
|
-
"@storm-software/config-tools": "^1.189.
|
|
217
|
+
"@storm-software/config-tools": "^1.189.60",
|
|
218
218
|
"@stryke/hash": "^0.13.17",
|
|
219
219
|
"@stryke/helpers": "^0.10.7",
|
|
220
220
|
"@stryke/path": "^0.27.3",
|
|
@@ -222,17 +222,17 @@
|
|
|
222
222
|
"@stryke/type-checks": "^0.6.0",
|
|
223
223
|
"@stryke/types": "^0.11.2",
|
|
224
224
|
"defu": "^6.1.4",
|
|
225
|
-
"powerlines": "^0.42.
|
|
225
|
+
"powerlines": "^0.42.23"
|
|
226
226
|
},
|
|
227
227
|
"devDependencies": {
|
|
228
228
|
"@cloudflare/unenv-preset": "^2.16.0",
|
|
229
229
|
"@cloudflare/workers-types": "^4.20260317.1",
|
|
230
|
-
"@powerlines/plugin-alloy": "^0.25.
|
|
231
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
230
|
+
"@powerlines/plugin-alloy": "^0.25.69",
|
|
231
|
+
"@powerlines/plugin-plugin": "^0.12.333",
|
|
232
232
|
"@types/node": "^25.5.0",
|
|
233
233
|
"wrangler": "^4.77.0",
|
|
234
234
|
"zod": "^4.3.6"
|
|
235
235
|
},
|
|
236
236
|
"publishConfig": { "access": "public" },
|
|
237
|
-
"gitHead": "
|
|
237
|
+
"gitHead": "4042ae8096ab1aae106c743a39ee41047307dce3"
|
|
238
238
|
}
|