@powerlines/plugin-cloudflare 0.5.20 → 0.6.1
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 +1 -1
- package/dist/components/worker-entry.cjs +2 -2
- package/dist/components/worker-entry.mjs +2 -2
- package/dist/components/worker-entry.mjs.map +1 -1
- package/dist/helpers/constants.cjs +7 -0
- package/dist/helpers/constants.d.cts +5 -0
- package/dist/helpers/constants.d.cts.map +1 -0
- package/dist/helpers/constants.d.mts +5 -0
- package/dist/helpers/constants.d.mts.map +1 -0
- package/dist/helpers/constants.mjs +6 -0
- package/dist/helpers/constants.mjs.map +1 -0
- package/dist/helpers/wrangler.cjs +21 -0
- package/dist/helpers/wrangler.d.cts +36 -0
- package/dist/helpers/wrangler.d.cts.map +1 -0
- package/dist/helpers/wrangler.d.mts +36 -0
- package/dist/helpers/wrangler.d.mts.map +1 -0
- package/dist/helpers/wrangler.mjs +20 -0
- package/dist/helpers/wrangler.mjs.map +1 -0
- package/dist/index.cjs +22 -6
- package/dist/index.d.cts +2 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +21 -5
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.cjs +9 -0
- package/dist/types/index.d.cts +2 -1
- package/dist/types/index.d.mts +2 -1
- package/dist/types/index.mjs +3 -1
- package/dist/types/plugin.d.cts +12 -1
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +12 -1
- package/dist/types/plugin.d.mts.map +1 -1
- package/dist/types/worker-module.d.cts +9 -2
- package/dist/types/worker-module.d.cts.map +1 -1
- package/dist/types/worker-module.d.mts +9 -2
- package/dist/types/worker-module.d.mts.map +1 -1
- package/dist/types/wrangler.cjs +152 -0
- package/dist/types/wrangler.d.cts +40 -0
- package/dist/types/wrangler.d.cts.map +1 -0
- package/dist/types/wrangler.d.mts +40 -0
- package/dist/types/wrangler.d.mts.map +1 -0
- package/dist/types/wrangler.mjs +143 -0
- package/dist/types/wrangler.mjs.map +1 -0
- package/package.json +67 -19
- package/dist/_virtual/_rolldown/runtime.mjs +0 -3
- package/dist/node_modules/.pnpm/@cloudflare_unenv-preset@2.16.0_unenv@2.0.0-rc.24/node_modules/@cloudflare/unenv-preset/dist/index.cjs +0 -370
- package/dist/node_modules/.pnpm/@cloudflare_unenv-preset@2.16.0_unenv@2.0.0-rc.24/node_modules/@cloudflare/unenv-preset/dist/index.mjs +0 -367
- package/dist/node_modules/.pnpm/@cloudflare_unenv-preset@2.16.0_unenv@2.0.0-rc.24/node_modules/@cloudflare/unenv-preset/dist/index.mjs.map +0 -1
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 -->
|
|
@@ -23,9 +23,9 @@ function WorkerEntry(props) {
|
|
|
23
23
|
"builtinImports"
|
|
24
24
|
]);
|
|
25
25
|
const context = (0, _powerlines_plugin_alloy_core_contexts.usePowerlines)();
|
|
26
|
-
const entryPath = (0, _alloy_js_core.computed)(() => `./${(0, _stryke_path_replace.replaceExtension)((0, _stryke_path_find.relativePath)(context.entryPath, worker.entry.input?.file || worker.entry.file))}`);
|
|
26
|
+
const entryPath = (0, _alloy_js_core.computed)(() => `./${(0, _stryke_path_replace.replaceExtension)((0, _stryke_path_find.relativePath)(context.entryPath, worker.metadata.entry.input?.file || worker.metadata.entry.file))}`);
|
|
27
27
|
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_entry_file.EntryFile, (0, _alloy_js_core_jsx_runtime.mergeProps)({ get path() {
|
|
28
|
-
return `worker-${(0, _stryke_hash.murmurhash)(worker.entry, { maxLength: 8 })}-entry.ts`;
|
|
28
|
+
return `worker-${(0, _stryke_hash.murmurhash)(worker.metadata.entry, { maxLength: 8 })}-entry.ts`;
|
|
29
29
|
} }, rest, {
|
|
30
30
|
get imports() {
|
|
31
31
|
return (0, defu.default)({
|
|
@@ -20,9 +20,9 @@ function WorkerEntry(props) {
|
|
|
20
20
|
"builtinImports"
|
|
21
21
|
]);
|
|
22
22
|
const context = usePowerlines();
|
|
23
|
-
const entryPath = computed(() => `./${replaceExtension(relativePath(context.entryPath, worker.entry.input?.file || worker.entry.file))}`);
|
|
23
|
+
const entryPath = computed(() => `./${replaceExtension(relativePath(context.entryPath, worker.metadata.entry.input?.file || worker.metadata.entry.file))}`);
|
|
24
24
|
return createComponent(EntryFile, mergeProps({ get path() {
|
|
25
|
-
return `worker-${murmurhash(worker.entry, { maxLength: 8 })}-entry.ts`;
|
|
25
|
+
return `worker-${murmurhash(worker.metadata.entry, { maxLength: 8 })}-entry.ts`;
|
|
26
26
|
} }, rest, {
|
|
27
27
|
get imports() {
|
|
28
28
|
return defu({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-entry.mjs","names":[],"sources":["../../src/components/worker-entry.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 { code, computed, Show, splitProps } from \"@alloy-js/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts\";\nimport {\n EntryFile,\n EntryFileProps\n} from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { murmurhash } from \"@stryke/hash\";\nimport { relativePath } from \"@stryke/path/find\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport defu from \"defu\";\nimport { CloudflarePluginContext, CloudflareWorkerEntryModule } from \"../types\";\n\nexport type WorkerEntryProps = Partial<EntryFileProps> &\n Omit<EntryFileProps, \"path\"> & {\n worker: CloudflareWorkerEntryModule;\n };\n\n/**\n * Generates a [Cloudflare Worker](https://developers.cloudflare.com/workers/runtime-apis/handlers/) entry module for the Powerlines project, providing a runtime context and utilities for integrating with Cloudflare services. This module defines a `CloudflareContext` interface, an `AsyncLocalStorage` instance for managing the context, and helper functions for retrieving and running code within the context. The generated module is designed to be used as a built-in file within the Powerlines environment, allowing developers to easily access Cloudflare-specific functionality in their applications.\n */\nexport function WorkerEntry(props: WorkerEntryProps) {\n const [{ worker, children, imports, builtinImports }, rest] = splitProps(\n props,\n [\"worker\", \"children\", \"imports\", \"builtinImports\"]\n );\n\n const context = usePowerlines<CloudflarePluginContext>();\n const entryPath = computed(\n () =>\n `./${replaceExtension(\n relativePath(\n context.entryPath,\n worker.entry.input?.file || worker.entry.file\n )\n )}`\n );\n\n return (\n <EntryFile\n path={`worker-${murmurhash(worker.entry, {\n maxLength: 8\n })}-entry.ts`}\n {...rest}\n imports={defu(\n {\n \"@cloudflare/workers-types\": [\n { name: \"Request\", type: true },\n { name: \"Response\", type: true },\n { name: \"ExecutionContext\", type: true },\n { name: \"IncomingRequestCfProperties\", type: true },\n { name: \"ScheduledController\", type: true },\n { name: \"ForwardableEmailMessage\", type: true },\n { name: \"MessageBatch\", type: true },\n { name: \"TailStream\", type: true },\n { name: \"TraceItem\", type: true },\n { name: \"TailStream.TailEvent\", type: true },\n { name: \"TailStream.Onset\", type: true },\n { name: \"TailStream.TailEventHandlerType\", type: true }\n ],\n [entryPath.value]: \"worker\"\n },\n imports ?? {}\n )}\n builtinImports={defu(\n {\n cloudflare: [\n \"withFetchContext\",\n \"withTailContext\",\n \"withTraceContext\",\n \"withTailStreamContext\",\n \"withScheduledContext\",\n \"withTestContext\",\n \"withEmailContext\",\n \"withQueueContext\"\n ]\n },\n builtinImports ?? {}\n )}>\n {code`export default { `}\n <hbr />\n <Show when={worker.fetch}>\n {code` async fetch(request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: CloudflareBindings, ctx: ExecutionContext): Promise<Response> {\n return await withFetchContext({ request, env, ctx }, async (context) => {\n return worker.fetch(context.request, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.tail}>\n {code` async tail(events: TraceItem[], env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withTailContext({ events, env, ctx }, async (context) => {\n return worker.tail(context.events, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.trace}>\n {code` async trace(traces: TraceItem[], env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withTraceContext({ traces, env, ctx }, async (context) => {\n return worker.trace(context.traces, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.tailStream}>\n {code` async tailStream(event: TailStream.TailEvent<TailStream.Onset>, env: CloudflareBindings, ctx: ExecutionContext): Promise<ReadableStream> {\n return await withTailStreamContext({ event, env, ctx }, async (context) => {\n return await worker.tailStream(context.event, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.scheduled}>\n {code` async scheduled(controller: ScheduledController, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withScheduledContext({ controller, env, ctx }, async (context) => {\n return worker.scheduled(context.controller, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.test}>\n {code` async test(controller: TestController, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withTestContext({ controller, env, ctx }, async (context) => {\n return worker.test(context.controller, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.email}>\n {code` async email(message: ForwardableEmailMessage, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withEmailContext({ message, env, ctx }, async (context) => {\n return worker.email(context.message, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.queue}>\n {code` async queue(batch: MessageBatch, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withQueueContext({ batch, env, ctx }, async (context) => {\n return worker.queue(context.batch, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n {code` } satisfies ExportedHandler<CloudflareBindings>; `}\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </EntryFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;CAoCE,MAAA,CAAA,EACC,QACD,UACF,SACE,kBACE,QAAK,WAAA,OAAA;EAAA;EAAA;EAAA;EAAA;EAAA,CAAA;CACP,MAAI,UAAU,eAAsC;CACpD,MAAC,YAAA,eAAA,KAAA,iBAAA,aAAA,QAAA,WAAA,OAAA,MAAA,OAAA,QAAA,OAAA,MAAA,KAAA,CAAA,GAAA;gDAED,IAAM,OAAO;AACb,SAAM,UAAY,WAAQ,OAAA,OAAA,EACpB,WAAA,GACD,CAAC,CAAC;IAEN,EAAE,MAAK;EACN,IAAI,UAAS;AACX,UAAE,KAAA;IACA,6BAAA;KAAA;MACL,MAAA;;MAEM;KAAA;MACJ,MAAA;MACK,MAAG;MACL;KAAA;MACE,MAAM;MACN,MAAI;MACR;KAAA;MACE,MAAA;MACE,MAAE;MACH;KAAE;MACD,MAAI;MACJ,MAAI;MACL;KAAE;MACD,MAAI;MACJ,MAAI;MACL;KAAE;MACD,MAAI;MACJ,MAAI;MACL;KAAE;MACD,MAAI;MACJ,MAAI;MACL;KAAE;MACD,MAAC;MACF,MAAA;MACD;KAAA;MACD,MAAA;MACD,MAAA;MACE;KAAA;MACE,MAAA;MACA,MAAG;MAC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|
|
1
|
+
{"version":3,"file":"worker-entry.mjs","names":[],"sources":["../../src/components/worker-entry.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 { code, computed, Show, splitProps } from \"@alloy-js/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts\";\nimport {\n EntryFile,\n EntryFileProps\n} from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { murmurhash } from \"@stryke/hash\";\nimport { relativePath } from \"@stryke/path/find\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport defu from \"defu\";\nimport { CloudflarePluginContext, CloudflareWorkerEntryModule } from \"../types\";\n\nexport type WorkerEntryProps = Partial<EntryFileProps> &\n Omit<EntryFileProps, \"path\"> & {\n worker: CloudflareWorkerEntryModule;\n };\n\n/**\n * Generates a [Cloudflare Worker](https://developers.cloudflare.com/workers/runtime-apis/handlers/) entry module for the Powerlines project, providing a runtime context and utilities for integrating with Cloudflare services. This module defines a `CloudflareContext` interface, an `AsyncLocalStorage` instance for managing the context, and helper functions for retrieving and running code within the context. The generated module is designed to be used as a built-in file within the Powerlines environment, allowing developers to easily access Cloudflare-specific functionality in their applications.\n */\nexport function WorkerEntry(props: WorkerEntryProps) {\n const [{ worker, children, imports, builtinImports }, rest] = splitProps(\n props,\n [\"worker\", \"children\", \"imports\", \"builtinImports\"]\n );\n\n const context = usePowerlines<CloudflarePluginContext>();\n const entryPath = computed(\n () =>\n `./${replaceExtension(\n relativePath(\n context.entryPath,\n worker.metadata.entry.input?.file || worker.metadata.entry.file\n )\n )}`\n );\n\n return (\n <EntryFile\n path={`worker-${murmurhash(worker.metadata.entry, {\n maxLength: 8\n })}-entry.ts`}\n {...rest}\n imports={defu(\n {\n \"@cloudflare/workers-types\": [\n { name: \"Request\", type: true },\n { name: \"Response\", type: true },\n { name: \"ExecutionContext\", type: true },\n { name: \"IncomingRequestCfProperties\", type: true },\n { name: \"ScheduledController\", type: true },\n { name: \"ForwardableEmailMessage\", type: true },\n { name: \"MessageBatch\", type: true },\n { name: \"TailStream\", type: true },\n { name: \"TraceItem\", type: true },\n { name: \"TailStream.TailEvent\", type: true },\n { name: \"TailStream.Onset\", type: true },\n { name: \"TailStream.TailEventHandlerType\", type: true }\n ],\n [entryPath.value]: \"worker\"\n },\n imports ?? {}\n )}\n builtinImports={defu(\n {\n cloudflare: [\n \"withFetchContext\",\n \"withTailContext\",\n \"withTraceContext\",\n \"withTailStreamContext\",\n \"withScheduledContext\",\n \"withTestContext\",\n \"withEmailContext\",\n \"withQueueContext\"\n ]\n },\n builtinImports ?? {}\n )}>\n {code`export default { `}\n <hbr />\n <Show when={worker.fetch}>\n {code` async fetch(request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: CloudflareBindings, ctx: ExecutionContext): Promise<Response> {\n return await withFetchContext({ request, env, ctx }, async (context) => {\n return worker.fetch(context.request, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.tail}>\n {code` async tail(events: TraceItem[], env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withTailContext({ events, env, ctx }, async (context) => {\n return worker.tail(context.events, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.trace}>\n {code` async trace(traces: TraceItem[], env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withTraceContext({ traces, env, ctx }, async (context) => {\n return worker.trace(context.traces, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.tailStream}>\n {code` async tailStream(event: TailStream.TailEvent<TailStream.Onset>, env: CloudflareBindings, ctx: ExecutionContext): Promise<ReadableStream> {\n return await withTailStreamContext({ event, env, ctx }, async (context) => {\n return await worker.tailStream(context.event, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.scheduled}>\n {code` async scheduled(controller: ScheduledController, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withScheduledContext({ controller, env, ctx }, async (context) => {\n return worker.scheduled(context.controller, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.test}>\n {code` async test(controller: TestController, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withTestContext({ controller, env, ctx }, async (context) => {\n return worker.test(context.controller, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.email}>\n {code` async email(message: ForwardableEmailMessage, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withEmailContext({ message, env, ctx }, async (context) => {\n return worker.email(context.message, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.queue}>\n {code` async queue(batch: MessageBatch, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withQueueContext({ batch, env, ctx }, async (context) => {\n return worker.queue(context.batch, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n {code` } satisfies ExportedHandler<CloudflareBindings>; `}\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </EntryFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;CAoCE,MAAA,CAAA,EACC,QACD,UACF,SACE,kBACE,QAAK,WAAA,OAAA;EAAA;EAAA;EAAA;EAAA;EAAA,CAAA;CACP,MAAI,UAAU,eAAsC;CACpD,MAAC,YAAA,eAAA,KAAA,iBAAA,aAAA,QAAA,WAAA,OAAA,SAAA,MAAA,OAAA,QAAA,OAAA,SAAA,MAAA,KAAA,CAAA,GAAA;gDAED,IAAM,OAAO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A;;;;;KAKL,CAAC;IAAE,gBAAA,OAAA,EAAA,CAAA;IAAA,gBAAA,MAAA;KACF,IAAE,OAAA;AACF,aAAI,OAAA;;KAEL,UAAW,IAAA;;;;;KAKX,CAAC;IAAE,gBAAA,OAAA,EAAA,CAAA;IAAA,gBAAA,MAAA;KACF,IAAI,OAAA;AACF,aAAE,OAAA;;KAEJ,UAAO,IAAM;;;;;KAKd,CAAC;IAAA,gBAAI,OAAA,EAAA,CAAA;IAAA,gBAAA,MAAA;KACL,IAAK,OAAA;AACL,aAAU,OAAO;;KAEhB,UAAO,IAAA;;;;;KAKR,CAAA;IAAG,gBAAE,OAAA,EAAA,CAAA;IAAA,gBAAA,MAAA;KACL,IAAK,OAAG;AACR,aAAS,OAAA;;KAEV,UAAS,IAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.cts","names":[],"sources":["../../src/helpers/constants.ts"],"mappings":";cAkBa,qBAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.mts","names":[],"sources":["../../src/helpers/constants.ts"],"mappings":";cAkBa,qBAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":[],"sources":["../../src/helpers/constants.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\nexport const PATH_TO_DEPLOY_CONFIG = \".wrangler/deploy/config.json\";\n"],"mappings":";AAkBA,MAAa,wBAAwB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let _stryke_path = require("@stryke/path");
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/wrangler.ts
|
|
6
|
+
/**
|
|
7
|
+
* Resolves the Wrangler configuration file path by checking for allowed extensions in the specified root directory.
|
|
8
|
+
*
|
|
9
|
+
* @param context - The Cloudflare plugin context containing the configuration and file system access.
|
|
10
|
+
* @returns The absolute path to the found configuration file, or undefined if no file is found.
|
|
11
|
+
*/
|
|
12
|
+
function resolveWranglerConfigPath(context) {
|
|
13
|
+
for (const extension of [
|
|
14
|
+
"jsonc",
|
|
15
|
+
"json",
|
|
16
|
+
"toml"
|
|
17
|
+
]) if (context.fs.existsSync((0, _stryke_path.joinPaths)(context.config.root, `wrangler.${extension}`))) return (0, _stryke_path.joinPaths)(context.config.root, `wrangler.${extension}`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
exports.resolveWranglerConfigPath = resolveWranglerConfigPath;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { UnresolvedContext } from "powerlines";
|
|
2
|
+
|
|
3
|
+
//#region src/helpers/wrangler.d.ts
|
|
4
|
+
interface ResolveConfigPathOptions {
|
|
5
|
+
useRedirectIfAvailable?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface ConfigPaths {
|
|
8
|
+
/**
|
|
9
|
+
* Absolute path to the actual configuration being used (possibly redirected from the user's config).
|
|
10
|
+
*/
|
|
11
|
+
configPath: string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Absolute path to the user's configuration, which may not be the same as `configPath` if it was redirected.
|
|
14
|
+
*/
|
|
15
|
+
userConfigPath: string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Absolute path to the deploy config path used
|
|
18
|
+
*/
|
|
19
|
+
deployConfigPath: string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Was a redirected config file read?
|
|
22
|
+
*/
|
|
23
|
+
redirected: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Resolves the Wrangler configuration file path by checking for allowed extensions in the specified root directory.
|
|
27
|
+
*
|
|
28
|
+
* @param context - The Cloudflare plugin context containing the configuration and file system access.
|
|
29
|
+
* @returns The absolute path to the found configuration file, or undefined if no file is found.
|
|
30
|
+
*/
|
|
31
|
+
declare function resolveWranglerConfigPath(context: UnresolvedContext): string | undefined;
|
|
32
|
+
declare type __ΩResolveConfigPathOptions = any[];
|
|
33
|
+
declare type __ΩConfigPaths = any[];
|
|
34
|
+
//#endregion
|
|
35
|
+
export { ConfigPaths, ResolveConfigPathOptions, __ΩConfigPaths, __ΩResolveConfigPathOptions, resolveWranglerConfigPath };
|
|
36
|
+
//# sourceMappingURL=wrangler.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrangler.d.cts","names":[],"sources":["../../src/helpers/wrangler.ts"],"mappings":";;;UAqBiB,wBAAA;EACf,sBAAA;AAAA;AAAA,UAGe,WAAA;;;;EAIf,UAAA;EAJ0B;;;EAQ1B,cAAA;EAAA;;;EAIA,gBAAA;EAIU;AASZ;;EATE,UAAA;AAAA;;;;;;;iBASc,yBAAA,CACd,OAAA,EAAS,iBAAA;AAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { UnresolvedContext } from "powerlines";
|
|
2
|
+
|
|
3
|
+
//#region src/helpers/wrangler.d.ts
|
|
4
|
+
interface ResolveConfigPathOptions {
|
|
5
|
+
useRedirectIfAvailable?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface ConfigPaths {
|
|
8
|
+
/**
|
|
9
|
+
* Absolute path to the actual configuration being used (possibly redirected from the user's config).
|
|
10
|
+
*/
|
|
11
|
+
configPath: string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Absolute path to the user's configuration, which may not be the same as `configPath` if it was redirected.
|
|
14
|
+
*/
|
|
15
|
+
userConfigPath: string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Absolute path to the deploy config path used
|
|
18
|
+
*/
|
|
19
|
+
deployConfigPath: string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Was a redirected config file read?
|
|
22
|
+
*/
|
|
23
|
+
redirected: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Resolves the Wrangler configuration file path by checking for allowed extensions in the specified root directory.
|
|
27
|
+
*
|
|
28
|
+
* @param context - The Cloudflare plugin context containing the configuration and file system access.
|
|
29
|
+
* @returns The absolute path to the found configuration file, or undefined if no file is found.
|
|
30
|
+
*/
|
|
31
|
+
declare function resolveWranglerConfigPath(context: UnresolvedContext): string | undefined;
|
|
32
|
+
declare type __ΩResolveConfigPathOptions = any[];
|
|
33
|
+
declare type __ΩConfigPaths = any[];
|
|
34
|
+
//#endregion
|
|
35
|
+
export { ConfigPaths, ResolveConfigPathOptions, __ΩConfigPaths, __ΩResolveConfigPathOptions, resolveWranglerConfigPath };
|
|
36
|
+
//# sourceMappingURL=wrangler.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrangler.d.mts","names":[],"sources":["../../src/helpers/wrangler.ts"],"mappings":";;;UAqBiB,wBAAA;EACf,sBAAA;AAAA;AAAA,UAGe,WAAA;;;;EAIf,UAAA;EAJ0B;;;EAQ1B,cAAA;EAAA;;;EAIA,gBAAA;EAIU;AASZ;;EATE,UAAA;AAAA;;;;;;;iBASc,yBAAA,CACd,OAAA,EAAS,iBAAA;AAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { joinPaths } from "@stryke/path";
|
|
2
|
+
|
|
3
|
+
//#region src/helpers/wrangler.ts
|
|
4
|
+
/**
|
|
5
|
+
* Resolves the Wrangler configuration file path by checking for allowed extensions in the specified root directory.
|
|
6
|
+
*
|
|
7
|
+
* @param context - The Cloudflare plugin context containing the configuration and file system access.
|
|
8
|
+
* @returns The absolute path to the found configuration file, or undefined if no file is found.
|
|
9
|
+
*/
|
|
10
|
+
function resolveWranglerConfigPath(context) {
|
|
11
|
+
for (const extension of [
|
|
12
|
+
"jsonc",
|
|
13
|
+
"json",
|
|
14
|
+
"toml"
|
|
15
|
+
]) if (context.fs.existsSync(joinPaths(context.config.root, `wrangler.${extension}`))) return joinPaths(context.config.root, `wrangler.${extension}`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { resolveWranglerConfigPath };
|
|
20
|
+
//# sourceMappingURL=wrangler.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrangler.mjs","names":[],"sources":["../../src/helpers/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 { joinPaths } from \"@stryke/path\";\nimport { UnresolvedContext } from \"powerlines\";\n\nexport interface ResolveConfigPathOptions {\n useRedirectIfAvailable?: boolean;\n}\n\nexport interface ConfigPaths {\n /**\n * Absolute path to the actual configuration being used (possibly redirected from the user's config).\n */\n configPath: string | undefined;\n /**\n * Absolute path to the user's configuration, which may not be the same as `configPath` if it was redirected.\n */\n userConfigPath: string | undefined;\n /**\n * Absolute path to the deploy config path used\n */\n deployConfigPath: string | undefined;\n /**\n * Was a redirected config file read?\n */\n redirected: boolean;\n}\n\n/**\n * Resolves the Wrangler configuration file path by checking for allowed extensions in the specified root directory.\n *\n * @param context - The Cloudflare plugin context containing the configuration and file system access.\n * @returns The absolute path to the found configuration file, or undefined if no file is found.\n */\nexport function resolveWranglerConfigPath(\n context: UnresolvedContext\n): string | undefined {\n for (const extension of [\"jsonc\", \"json\", \"toml\"]) {\n if (\n context.fs.existsSync(\n joinPaths(context.config.root, `wrangler.${extension}`)\n )\n ) {\n return joinPaths(context.config.root, `wrangler.${extension}`);\n }\n }\n\n return undefined;\n}\n"],"mappings":";;;;;;;;;AAkDA,SAAgB,0BACd,SACoB;AACpB,MAAK,MAAM,aAAa;EAAC;EAAS;EAAQ;EAAO,CAC/C,KACE,QAAQ,GAAG,WACT,UAAU,QAAQ,OAAO,MAAM,YAAY,YAAY,CACxD,CAED,QAAO,UAAU,QAAQ,OAAO,MAAM,YAAY,YAAY"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
2
|
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_index = require('./node_modules/.pnpm/@cloudflare_unenv-preset@2.16.0_unenv@2.0.0-rc.24/node_modules/@cloudflare/unenv-preset/dist/index.cjs');
|
|
4
3
|
const require_components_cloudflare_builtin = require('./components/cloudflare-builtin.cjs');
|
|
5
4
|
const require_components_env_builtin = require('./components/env-builtin.cjs');
|
|
6
5
|
const require_components_worker_entry = require('./components/worker-entry.cjs');
|
|
7
6
|
require('./components/index.cjs');
|
|
7
|
+
const require_helpers_wrangler = require('./helpers/wrangler.cjs');
|
|
8
8
|
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
9
9
|
let _alloy_js_core = require("@alloy-js/core");
|
|
10
|
+
let _cloudflare_unenv_preset = require("@cloudflare/unenv-preset");
|
|
10
11
|
let _powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
|
|
11
12
|
let _powerlines_plugin_env_helpers = require("@powerlines/plugin-env/helpers");
|
|
12
13
|
let _powerlines_plugin_esbuild_helpers_resolve = require("@powerlines/plugin-esbuild/helpers/resolve");
|
|
@@ -20,6 +21,7 @@ let _stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case
|
|
|
20
21
|
let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
21
22
|
let defu = require("defu");
|
|
22
23
|
defu = require_runtime.__toESM(defu);
|
|
24
|
+
let wrangler = require("wrangler");
|
|
23
25
|
|
|
24
26
|
//#region src/index.tsx
|
|
25
27
|
/**
|
|
@@ -30,9 +32,9 @@ function plugin(options = {}) {
|
|
|
30
32
|
name: "cloudflare",
|
|
31
33
|
config() {
|
|
32
34
|
return {
|
|
33
|
-
cloudflare: (0, defu.default)((0, _stryke_helpers_omit.omit)(options, ["unenv"]), {}),
|
|
35
|
+
cloudflare: (0, defu.default)((0, _stryke_helpers_omit.omit)(options, ["unenv"]), { configPath: require_helpers_wrangler.resolveWranglerConfigPath(this) }),
|
|
34
36
|
resolve: { skipNodeModulesBundle: false },
|
|
35
|
-
unenv: { presets: [
|
|
37
|
+
unenv: { presets: [(0, _cloudflare_unenv_preset.getCloudflarePreset)({
|
|
36
38
|
compatibilityDate: this.config.compatibilityDate?.toString(),
|
|
37
39
|
compatibilityFlags: ["nodejs_als"]
|
|
38
40
|
})] }
|
|
@@ -40,6 +42,11 @@ function plugin(options = {}) {
|
|
|
40
42
|
},
|
|
41
43
|
configResolved() {
|
|
42
44
|
this.devDependencies["@cloudflare/workers-types"] = "^4.20240616.0";
|
|
45
|
+
const config = (0, wrangler.unstable_readConfig)({ config: this.config.cloudflare?.configPath }, {
|
|
46
|
+
preserveOriginalMain: true,
|
|
47
|
+
hideWarnings: true
|
|
48
|
+
});
|
|
49
|
+
this.cloudflare.wrangler = structuredClone(config);
|
|
43
50
|
},
|
|
44
51
|
async prepare() {
|
|
45
52
|
const result = await (0, _powerlines_plugin_env_helpers.readEnvTypeReflection)(this, "env");
|
|
@@ -49,7 +56,8 @@ function plugin(options = {}) {
|
|
|
49
56
|
order: "pre",
|
|
50
57
|
async handler() {
|
|
51
58
|
const _self$ = this;
|
|
52
|
-
this.
|
|
59
|
+
this.cloudflare ??= { workers: [] };
|
|
60
|
+
this.cloudflare.workers = await Promise.all(this.entry.map(async (entry, i, arr) => {
|
|
53
61
|
if (!entry.input) throw new Error(`Cloudflare Worker entry "${entry.file}" is missing an input file.`);
|
|
54
62
|
const workerModule = await (0, _powerlines_plugin_esbuild_helpers_resolve.resolveModule)(this, entry.input);
|
|
55
63
|
if (!workerModule?.default) throw new Error(`Cloudflare Worker entry "${entry.file}" 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".`);
|
|
@@ -72,12 +80,20 @@ function plugin(options = {}) {
|
|
|
72
80
|
}));
|
|
73
81
|
return (0, _powerlines_plugin_alloy_render.render)(this, (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
74
82
|
get each() {
|
|
75
|
-
return _self$.workers;
|
|
83
|
+
return _self$.cloudflare.workers;
|
|
76
84
|
},
|
|
77
85
|
children: (worker) => (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_worker_entry.WorkerEntry, { worker })
|
|
78
86
|
}));
|
|
79
87
|
}
|
|
80
88
|
},
|
|
89
|
+
async deploy() {
|
|
90
|
+
let apiToken = process.env.CLOUDFLARE_API_TOKEN;
|
|
91
|
+
if (!apiToken) {
|
|
92
|
+
apiToken = this.config.cloudflare.apiToken;
|
|
93
|
+
if (apiToken) this.warn("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.");
|
|
94
|
+
else throw new Error("Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.");
|
|
95
|
+
}
|
|
96
|
+
},
|
|
81
97
|
async deployPulumi() {
|
|
82
98
|
let apiToken = process.env.CLOUDFLARE_API_TOKEN;
|
|
83
99
|
if (!apiToken) {
|
|
@@ -96,7 +112,7 @@ function plugin(options = {}) {
|
|
|
96
112
|
const workersDeployments = [];
|
|
97
113
|
const workersRoutes = [];
|
|
98
114
|
const dnsRecords = [];
|
|
99
|
-
for (const worker of this.workers) {
|
|
115
|
+
for (const worker of this.cloudflare.workers) {
|
|
100
116
|
const resource = new _pulumi_cloudflare.Worker(`${this.config.organization ? `${this.config.organization}.` : ""}${(0, _stryke_string_format_kebab_case.kebabCase)(this.config.name) === (0, _stryke_string_format_kebab_case.kebabCase)(worker.metadata.name) ? (0, _stryke_string_format_kebab_case.kebabCase)(this.config.name) : `${(0, _stryke_string_format_kebab_case.kebabCase)(this.config.name)}.${(0, _stryke_string_format_kebab_case.kebabCase)(worker.metadata.name)}`}.${(0, _stryke_string_format_kebab_case.kebabCase)(this.config.mode)}.worker`, (0, defu.default)({
|
|
101
117
|
accountId: this.config.cloudflare.accountId,
|
|
102
118
|
name: worker.metadata.name,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CloudflareBuiltin, CloudflareBuiltinProps, __ΩCloudflareBuiltinProps } from "./components/cloudflare-builtin.cjs";
|
|
2
2
|
import { CloudflareEnvBuiltin, CloudflareEnvBuiltinProps, __ΩCloudflareEnvBuiltinProps } from "./components/env-builtin.cjs";
|
|
3
|
+
import { Json, JsonSchema, Literal, LiteralSchema, OptionalZodTypeOf, PathSchema, WranglerResolvedConfig, WranglerUserConfig, __ΩJson, __ΩLiteral, __ΩOptionalZodTypeOf, __ΩWranglerResolvedConfig, __ΩWranglerUserConfig, defaultWranglerConfig, isCyclic, parseWithRootPath } from "./types/wrangler.cjs";
|
|
3
4
|
import { WorkerModule, WorkerModuleMetadata, __ΩWorkerModule, __ΩWorkerModuleMetadata } from "./types/worker-module.cjs";
|
|
4
5
|
import { CloudflarePluginContext, CloudflarePluginOptions, CloudflarePluginResolvedConfig, CloudflarePluginUserConfig, CloudflareWorkerEntryModule, CloudflareWorkerMetadata, __ΩCloudflarePluginContext, __ΩCloudflarePluginOptions, __ΩCloudflarePluginResolvedConfig, __ΩCloudflarePluginUserConfig, __ΩCloudflareWorkerEntryModule, __ΩCloudflareWorkerMetadata } from "./types/plugin.cjs";
|
|
5
6
|
import { WorkerEntry, WorkerEntryProps, __ΩWorkerEntryProps } from "./components/worker-entry.cjs";
|
|
@@ -16,5 +17,5 @@ declare module "powerlines" {
|
|
|
16
17
|
*/
|
|
17
18
|
declare function plugin<TContext extends CloudflarePluginContext = CloudflarePluginContext>(options?: CloudflarePluginOptions): Plugin<TContext>[];
|
|
18
19
|
//#endregion
|
|
19
|
-
export { CloudflareBuiltin, CloudflareBuiltinProps, CloudflareEnvBuiltin, CloudflareEnvBuiltinProps, CloudflarePluginContext, CloudflarePluginOptions, CloudflarePluginResolvedConfig, CloudflarePluginUserConfig, CloudflareWorkerEntryModule, CloudflareWorkerMetadata, WorkerEntry, WorkerEntryProps, WorkerModule, WorkerModuleMetadata, __ΩCloudflareBuiltinProps, __ΩCloudflareEnvBuiltinProps, __ΩCloudflarePluginContext, __ΩCloudflarePluginOptions, __ΩCloudflarePluginResolvedConfig, __ΩCloudflarePluginUserConfig, __ΩCloudflareWorkerEntryModule, __ΩCloudflareWorkerMetadata, __ΩWorkerEntryProps, __ΩWorkerModule, __ΩWorkerModuleMetadata, plugin as default, plugin };
|
|
20
|
+
export { CloudflareBuiltin, CloudflareBuiltinProps, CloudflareEnvBuiltin, CloudflareEnvBuiltinProps, CloudflarePluginContext, CloudflarePluginOptions, CloudflarePluginResolvedConfig, CloudflarePluginUserConfig, CloudflareWorkerEntryModule, CloudflareWorkerMetadata, Json, JsonSchema, Literal, LiteralSchema, OptionalZodTypeOf, PathSchema, WorkerEntry, WorkerEntryProps, WorkerModule, WorkerModuleMetadata, WranglerResolvedConfig, WranglerUserConfig, __ΩCloudflareBuiltinProps, __ΩCloudflareEnvBuiltinProps, __ΩCloudflarePluginContext, __ΩCloudflarePluginOptions, __ΩCloudflarePluginResolvedConfig, __ΩCloudflarePluginUserConfig, __ΩCloudflareWorkerEntryModule, __ΩCloudflareWorkerMetadata, __ΩJson, __ΩLiteral, __ΩOptionalZodTypeOf, __ΩWorkerEntryProps, __ΩWorkerModule, __ΩWorkerModuleMetadata, __ΩWranglerResolvedConfig, __ΩWranglerUserConfig, plugin as default, plugin, defaultWranglerConfig, isCyclic, parseWithRootPath };
|
|
20
21
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;;;;;YAkDY,MAAA;IACR,UAAA,GAAa,uBAAA;EAAA;AAAA;;;AAJY;iBAWb,MAAA,kBACG,uBAAA,GAA0B,uBAAA,CAAA,CAC3C,OAAA,GAAS,uBAAA,GAuSJ,MAAA,CAAO,QAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CloudflareBuiltin, CloudflareBuiltinProps, __ΩCloudflareBuiltinProps } from "./components/cloudflare-builtin.mjs";
|
|
2
2
|
import { CloudflareEnvBuiltin, CloudflareEnvBuiltinProps, __ΩCloudflareEnvBuiltinProps } from "./components/env-builtin.mjs";
|
|
3
|
+
import { Json, JsonSchema, Literal, LiteralSchema, OptionalZodTypeOf, PathSchema, WranglerResolvedConfig, WranglerUserConfig, __ΩJson, __ΩLiteral, __ΩOptionalZodTypeOf, __ΩWranglerResolvedConfig, __ΩWranglerUserConfig, defaultWranglerConfig, isCyclic, parseWithRootPath } from "./types/wrangler.mjs";
|
|
3
4
|
import { WorkerModule, WorkerModuleMetadata, __ΩWorkerModule, __ΩWorkerModuleMetadata } from "./types/worker-module.mjs";
|
|
4
5
|
import { CloudflarePluginContext, CloudflarePluginOptions, CloudflarePluginResolvedConfig, CloudflarePluginUserConfig, CloudflareWorkerEntryModule, CloudflareWorkerMetadata, __ΩCloudflarePluginContext, __ΩCloudflarePluginOptions, __ΩCloudflarePluginResolvedConfig, __ΩCloudflarePluginUserConfig, __ΩCloudflareWorkerEntryModule, __ΩCloudflareWorkerMetadata } from "./types/plugin.mjs";
|
|
5
6
|
import { WorkerEntry, WorkerEntryProps, __ΩWorkerEntryProps } from "./components/worker-entry.mjs";
|
|
@@ -16,5 +17,5 @@ declare module "powerlines" {
|
|
|
16
17
|
*/
|
|
17
18
|
declare function plugin<TContext extends CloudflarePluginContext = CloudflarePluginContext>(options?: CloudflarePluginOptions): Plugin<TContext>[];
|
|
18
19
|
//#endregion
|
|
19
|
-
export { CloudflareBuiltin, CloudflareBuiltinProps, CloudflareEnvBuiltin, CloudflareEnvBuiltinProps, CloudflarePluginContext, CloudflarePluginOptions, CloudflarePluginResolvedConfig, CloudflarePluginUserConfig, CloudflareWorkerEntryModule, CloudflareWorkerMetadata, WorkerEntry, WorkerEntryProps, WorkerModule, WorkerModuleMetadata, __ΩCloudflareBuiltinProps, __ΩCloudflareEnvBuiltinProps, __ΩCloudflarePluginContext, __ΩCloudflarePluginOptions, __ΩCloudflarePluginResolvedConfig, __ΩCloudflarePluginUserConfig, __ΩCloudflareWorkerEntryModule, __ΩCloudflareWorkerMetadata, __ΩWorkerEntryProps, __ΩWorkerModule, __ΩWorkerModuleMetadata, plugin as default, plugin };
|
|
20
|
+
export { CloudflareBuiltin, CloudflareBuiltinProps, CloudflareEnvBuiltin, CloudflareEnvBuiltinProps, CloudflarePluginContext, CloudflarePluginOptions, CloudflarePluginResolvedConfig, CloudflarePluginUserConfig, CloudflareWorkerEntryModule, CloudflareWorkerMetadata, Json, JsonSchema, Literal, LiteralSchema, OptionalZodTypeOf, PathSchema, WorkerEntry, WorkerEntryProps, WorkerModule, WorkerModuleMetadata, WranglerResolvedConfig, WranglerUserConfig, __ΩCloudflareBuiltinProps, __ΩCloudflareEnvBuiltinProps, __ΩCloudflarePluginContext, __ΩCloudflarePluginOptions, __ΩCloudflarePluginResolvedConfig, __ΩCloudflarePluginUserConfig, __ΩCloudflareWorkerEntryModule, __ΩCloudflareWorkerMetadata, __ΩJson, __ΩLiteral, __ΩOptionalZodTypeOf, __ΩWorkerEntryProps, __ΩWorkerModule, __ΩWorkerModuleMetadata, __ΩWranglerResolvedConfig, __ΩWranglerUserConfig, plugin as default, plugin, defaultWranglerConfig, isCyclic, parseWithRootPath };
|
|
20
21
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;;;;;YAkDY,MAAA;IACR,UAAA,GAAa,uBAAA;EAAA;AAAA;;;AAJY;iBAWb,MAAA,kBACG,uBAAA,GAA0B,uBAAA,CAAA,CAC3C,OAAA,GAAS,uBAAA,GAuSJ,MAAA,CAAO,QAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { getCloudflarePreset } from "./node_modules/.pnpm/@cloudflare_unenv-preset@2.16.0_unenv@2.0.0-rc.24/node_modules/@cloudflare/unenv-preset/dist/index.mjs";
|
|
2
1
|
import { CloudflareBuiltin } from "./components/cloudflare-builtin.mjs";
|
|
3
2
|
import { CloudflareEnvBuiltin } from "./components/env-builtin.mjs";
|
|
4
3
|
import { WorkerEntry } from "./components/worker-entry.mjs";
|
|
5
4
|
import "./components/index.mjs";
|
|
5
|
+
import { resolveWranglerConfigPath } from "./helpers/wrangler.mjs";
|
|
6
6
|
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
7
7
|
import { For } from "@alloy-js/core";
|
|
8
|
+
import { getCloudflarePreset } from "@cloudflare/unenv-preset";
|
|
8
9
|
import { render } from "@powerlines/plugin-alloy/render";
|
|
9
10
|
import { readEnvTypeReflection } from "@powerlines/plugin-env/helpers";
|
|
10
11
|
import { resolveModule } from "@powerlines/plugin-esbuild/helpers/resolve";
|
|
@@ -15,6 +16,7 @@ import { joinPaths, replaceExtension } from "@stryke/path";
|
|
|
15
16
|
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
16
17
|
import { isFunction } from "@stryke/type-checks/is-function";
|
|
17
18
|
import defu from "defu";
|
|
19
|
+
import { unstable_readConfig } from "wrangler";
|
|
18
20
|
|
|
19
21
|
//#region src/index.tsx
|
|
20
22
|
/**
|
|
@@ -25,7 +27,7 @@ function plugin(options = {}) {
|
|
|
25
27
|
name: "cloudflare",
|
|
26
28
|
config() {
|
|
27
29
|
return {
|
|
28
|
-
cloudflare: defu(omit(options, ["unenv"]), {}),
|
|
30
|
+
cloudflare: defu(omit(options, ["unenv"]), { configPath: resolveWranglerConfigPath(this) }),
|
|
29
31
|
resolve: { skipNodeModulesBundle: false },
|
|
30
32
|
unenv: { presets: [getCloudflarePreset({
|
|
31
33
|
compatibilityDate: this.config.compatibilityDate?.toString(),
|
|
@@ -35,6 +37,11 @@ function plugin(options = {}) {
|
|
|
35
37
|
},
|
|
36
38
|
configResolved() {
|
|
37
39
|
this.devDependencies["@cloudflare/workers-types"] = "^4.20240616.0";
|
|
40
|
+
const config = unstable_readConfig({ config: this.config.cloudflare?.configPath }, {
|
|
41
|
+
preserveOriginalMain: true,
|
|
42
|
+
hideWarnings: true
|
|
43
|
+
});
|
|
44
|
+
this.cloudflare.wrangler = structuredClone(config);
|
|
38
45
|
},
|
|
39
46
|
async prepare() {
|
|
40
47
|
const result = await readEnvTypeReflection(this, "env");
|
|
@@ -44,7 +51,8 @@ function plugin(options = {}) {
|
|
|
44
51
|
order: "pre",
|
|
45
52
|
async handler() {
|
|
46
53
|
const _self$ = this;
|
|
47
|
-
this.
|
|
54
|
+
this.cloudflare ??= { workers: [] };
|
|
55
|
+
this.cloudflare.workers = await Promise.all(this.entry.map(async (entry, i, arr) => {
|
|
48
56
|
if (!entry.input) throw new Error(`Cloudflare Worker entry "${entry.file}" is missing an input file.`);
|
|
49
57
|
const workerModule = await resolveModule(this, entry.input);
|
|
50
58
|
if (!workerModule?.default) throw new Error(`Cloudflare Worker entry "${entry.file}" 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".`);
|
|
@@ -67,12 +75,20 @@ function plugin(options = {}) {
|
|
|
67
75
|
}));
|
|
68
76
|
return render(this, createComponent(For, {
|
|
69
77
|
get each() {
|
|
70
|
-
return _self$.workers;
|
|
78
|
+
return _self$.cloudflare.workers;
|
|
71
79
|
},
|
|
72
80
|
children: (worker) => createComponent(WorkerEntry, { worker })
|
|
73
81
|
}));
|
|
74
82
|
}
|
|
75
83
|
},
|
|
84
|
+
async deploy() {
|
|
85
|
+
let apiToken = process.env.CLOUDFLARE_API_TOKEN;
|
|
86
|
+
if (!apiToken) {
|
|
87
|
+
apiToken = this.config.cloudflare.apiToken;
|
|
88
|
+
if (apiToken) this.warn("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.");
|
|
89
|
+
else throw new Error("Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.");
|
|
90
|
+
}
|
|
91
|
+
},
|
|
76
92
|
async deployPulumi() {
|
|
77
93
|
let apiToken = process.env.CLOUDFLARE_API_TOKEN;
|
|
78
94
|
if (!apiToken) {
|
|
@@ -91,7 +107,7 @@ function plugin(options = {}) {
|
|
|
91
107
|
const workersDeployments = [];
|
|
92
108
|
const workersRoutes = [];
|
|
93
109
|
const dnsRecords = [];
|
|
94
|
-
for (const worker of this.workers) {
|
|
110
|
+
for (const worker of this.cloudflare.workers) {
|
|
95
111
|
const resource = new pulumiCloudflare.Worker(`${this.config.organization ? `${this.config.organization}.` : ""}${kebabCase(this.config.name) === kebabCase(worker.metadata.name) ? kebabCase(this.config.name) : `${kebabCase(this.config.name)}.${kebabCase(worker.metadata.name)}`}.${kebabCase(this.config.mode)}.worker`, defu({
|
|
96
112
|
accountId: this.config.cloudflare.accountId,
|
|
97
113
|
name: worker.metadata.name,
|
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 defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport { CloudflareEnvBuiltin } from \"./components\";\nimport { CloudflareBuiltin } from \"./components/cloudflare-builtin\";\nimport { WorkerEntry } from \"./components/worker-entry\";\nimport {\n CloudflarePluginContext,\n CloudflarePluginOptions,\n CloudflareWorkerEntryModule\n} from \"./types/plugin\";\nimport { WorkerModule } from \"./types/worker-module\";\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 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 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.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.workers}>\n {worker => <WorkerEntry worker={worker} />}\n </For>\n );\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.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":";;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAA,OAAA,UAAA,EAAA,EAAA;;EAEE,MAAA;EACE,SAAC;AACH,UAAA;IACK,YAAS,KAAM,KAAA,SAAA,CAAA,QAAA,CAAA,EAAA,EAAA,CAAA;IACpB,SAAS,EACD,uBAAC,OACF;IACL,OAAM,EACN,SAAA,CAAA,oBAAA;KACQ,mBAAY,KAAA,OAAA,mBAAA,UAAA;KACZ,oBAAG,CAAA,aAAA;KACP,CAAA,CAAA,EACC;IACF;;EAEH,iBAAO;AACL,QAAI,gBAAO,+BAAA;;EAEb,MAAM,UAAI;GACR,MAAM,SAAI,MAAA,sBAA+B,MAAA,MAAA;AACzC,UAAO,OAAG,MAAA,CAAA,gBAAsB,mBAAW,EAAA,CAAA,EAAA,gBAAA,sBAAA,EACzC,YAAO,QACR,CAAC,CAAC,CAAC;;EAEN,OAAK;GACH,OAAC;GACD,MAAA,UAAgB;IACd,MAAK,SAAA;AACN,SAAA,UAAA,MAAA,QAAA,IAAA,KAAA,MAAA,IAAA,OAAA,OAAA,GAAA,QAAA;AACD,SAAM,CAAA,MAAS,MACb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MAAM,YAAM,IAAA,iBAAA,UAAA,GAAA,KAAA,OAAA,eAAA,GAAA,KAAA,OAAA,aAAA,KAAA,KAAA,UAAA,KAAA,OAAA,KAAA,KAAA,UAAA,OAAA,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;KACV,MAAM,aAAU;KAChB,MAAM;KACN,SAAI;KACJ,QAAM,KAAA;KACN,SAAM;KACN,KAAK;KACN,EAAE,EACD,UACD,CAAC;AACF,eAAW,KAAG,UAAS;;AAEzB,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// 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,IAAA,OAAA,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AAA,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"}
|
package/dist/types/index.cjs
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_types_wrangler = require('./wrangler.cjs');
|
|
3
|
+
|
|
4
|
+
exports.JsonSchema = require_types_wrangler.JsonSchema;
|
|
5
|
+
exports.LiteralSchema = require_types_wrangler.LiteralSchema;
|
|
6
|
+
exports.PathSchema = require_types_wrangler.PathSchema;
|
|
7
|
+
exports.defaultWranglerConfig = require_types_wrangler.defaultWranglerConfig;
|
|
8
|
+
exports.isCyclic = require_types_wrangler.isCyclic;
|
|
9
|
+
exports.parseWithRootPath = require_types_wrangler.parseWithRootPath;
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Json, JsonSchema, Literal, LiteralSchema, OptionalZodTypeOf, PathSchema, WranglerResolvedConfig, WranglerUserConfig, __ΩJson, __ΩLiteral, __ΩOptionalZodTypeOf, __ΩWranglerResolvedConfig, __ΩWranglerUserConfig, defaultWranglerConfig, isCyclic, parseWithRootPath } from "./wrangler.cjs";
|
|
1
2
|
import { WorkerModule, WorkerModuleMetadata, __ΩWorkerModule, __ΩWorkerModuleMetadata } from "./worker-module.cjs";
|
|
2
3
|
import { CloudflarePluginContext, CloudflarePluginOptions, CloudflarePluginResolvedConfig, CloudflarePluginUserConfig, CloudflareWorkerEntryModule, CloudflareWorkerMetadata, __ΩCloudflarePluginContext, __ΩCloudflarePluginOptions, __ΩCloudflarePluginResolvedConfig, __ΩCloudflarePluginUserConfig, __ΩCloudflareWorkerEntryModule, __ΩCloudflareWorkerMetadata } from "./plugin.cjs";
|
|
3
|
-
export { CloudflarePluginContext, CloudflarePluginOptions, CloudflarePluginResolvedConfig, CloudflarePluginUserConfig, CloudflareWorkerEntryModule, CloudflareWorkerMetadata, WorkerModule, WorkerModuleMetadata, __ΩCloudflarePluginContext, __ΩCloudflarePluginOptions, __ΩCloudflarePluginResolvedConfig, __ΩCloudflarePluginUserConfig, __ΩCloudflareWorkerEntryModule, __ΩCloudflareWorkerMetadata, __ΩWorkerModule, __ΩWorkerModuleMetadata };
|
|
4
|
+
export { CloudflarePluginContext, CloudflarePluginOptions, CloudflarePluginResolvedConfig, CloudflarePluginUserConfig, CloudflareWorkerEntryModule, CloudflareWorkerMetadata, Json, JsonSchema, Literal, LiteralSchema, OptionalZodTypeOf, PathSchema, WorkerModule, WorkerModuleMetadata, WranglerResolvedConfig, WranglerUserConfig, __ΩCloudflarePluginContext, __ΩCloudflarePluginOptions, __ΩCloudflarePluginResolvedConfig, __ΩCloudflarePluginUserConfig, __ΩCloudflareWorkerEntryModule, __ΩCloudflareWorkerMetadata, __ΩJson, __ΩLiteral, __ΩOptionalZodTypeOf, __ΩWorkerModule, __ΩWorkerModuleMetadata, __ΩWranglerResolvedConfig, __ΩWranglerUserConfig, defaultWranglerConfig, isCyclic, parseWithRootPath };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Json, JsonSchema, Literal, LiteralSchema, OptionalZodTypeOf, PathSchema, WranglerResolvedConfig, WranglerUserConfig, __ΩJson, __ΩLiteral, __ΩOptionalZodTypeOf, __ΩWranglerResolvedConfig, __ΩWranglerUserConfig, defaultWranglerConfig, isCyclic, parseWithRootPath } from "./wrangler.mjs";
|
|
1
2
|
import { WorkerModule, WorkerModuleMetadata, __ΩWorkerModule, __ΩWorkerModuleMetadata } from "./worker-module.mjs";
|
|
2
3
|
import { CloudflarePluginContext, CloudflarePluginOptions, CloudflarePluginResolvedConfig, CloudflarePluginUserConfig, CloudflareWorkerEntryModule, CloudflareWorkerMetadata, __ΩCloudflarePluginContext, __ΩCloudflarePluginOptions, __ΩCloudflarePluginResolvedConfig, __ΩCloudflarePluginUserConfig, __ΩCloudflareWorkerEntryModule, __ΩCloudflareWorkerMetadata } from "./plugin.mjs";
|
|
3
|
-
export { CloudflarePluginContext, CloudflarePluginOptions, CloudflarePluginResolvedConfig, CloudflarePluginUserConfig, CloudflareWorkerEntryModule, CloudflareWorkerMetadata, WorkerModule, WorkerModuleMetadata, __ΩCloudflarePluginContext, __ΩCloudflarePluginOptions, __ΩCloudflarePluginResolvedConfig, __ΩCloudflarePluginUserConfig, __ΩCloudflareWorkerEntryModule, __ΩCloudflareWorkerMetadata, __ΩWorkerModule, __ΩWorkerModuleMetadata };
|
|
4
|
+
export { CloudflarePluginContext, CloudflarePluginOptions, CloudflarePluginResolvedConfig, CloudflarePluginUserConfig, CloudflareWorkerEntryModule, CloudflareWorkerMetadata, Json, JsonSchema, Literal, LiteralSchema, OptionalZodTypeOf, PathSchema, WorkerModule, WorkerModuleMetadata, WranglerResolvedConfig, WranglerUserConfig, __ΩCloudflarePluginContext, __ΩCloudflarePluginOptions, __ΩCloudflarePluginResolvedConfig, __ΩCloudflarePluginUserConfig, __ΩCloudflareWorkerEntryModule, __ΩCloudflareWorkerMetadata, __ΩJson, __ΩLiteral, __ΩOptionalZodTypeOf, __ΩWorkerModule, __ΩWorkerModuleMetadata, __ΩWranglerResolvedConfig, __ΩWranglerUserConfig, defaultWranglerConfig, isCyclic, parseWithRootPath };
|
package/dist/types/index.mjs
CHANGED