@powerlines/plugin-cloudflare 0.6.7 → 0.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +150 -144
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +149 -144
- package/dist/index.mjs.map +1 -1
- package/dist/types/plugin.d.cts +7 -3
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +7 -3
- package/dist/types/plugin.d.mts.map +1 -1
- package/package.json +13 -13
package/dist/index.cjs
CHANGED
|
@@ -11,6 +11,8 @@ let _cloudflare_unenv_preset = require("@cloudflare/unenv-preset");
|
|
|
11
11
|
let _powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
|
|
12
12
|
let _powerlines_plugin_env_helpers = require("@powerlines/plugin-env/helpers");
|
|
13
13
|
let _powerlines_plugin_esbuild_helpers_resolve = require("@powerlines/plugin-esbuild/helpers/resolve");
|
|
14
|
+
let _powerlines_plugin_pulumi = require("@powerlines/plugin-pulumi");
|
|
15
|
+
_powerlines_plugin_pulumi = require_runtime.__toESM(_powerlines_plugin_pulumi);
|
|
14
16
|
let _powerlines_plugin_unenv = require("@powerlines/plugin-unenv");
|
|
15
17
|
_powerlines_plugin_unenv = require_runtime.__toESM(_powerlines_plugin_unenv);
|
|
16
18
|
let _pulumi_cloudflare = require("@pulumi/cloudflare");
|
|
@@ -28,152 +30,156 @@ let wrangler = require("wrangler");
|
|
|
28
30
|
* A Powerlines plugin to assist in developing other Powerlines plugins.
|
|
29
31
|
*/
|
|
30
32
|
function plugin(options = {}) {
|
|
31
|
-
return [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
33
|
+
return [
|
|
34
|
+
(0, _powerlines_plugin_unenv.default)(options.unenv),
|
|
35
|
+
...(0, _powerlines_plugin_pulumi.default)(options.pulumi),
|
|
36
|
+
{
|
|
37
|
+
name: "cloudflare",
|
|
38
|
+
config() {
|
|
39
|
+
return {
|
|
40
|
+
cloudflare: (0, defu.default)((0, _stryke_helpers_omit.omit)(options, ["unenv", "pulumi"]), { configPath: require_helpers_wrangler.resolveWranglerConfigPath(this) }),
|
|
41
|
+
resolve: { skipNodeModulesBundle: false },
|
|
42
|
+
unenv: { presets: [(0, _cloudflare_unenv_preset.getCloudflarePreset)({
|
|
43
|
+
compatibilityDate: this.config.compatibilityDate?.toString(),
|
|
44
|
+
compatibilityFlags: ["nodejs_als"]
|
|
45
|
+
})] }
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
configResolved() {
|
|
49
|
+
this.devDependencies["@cloudflare/workers-types"] = "^4.20240616.0";
|
|
50
|
+
const config = (0, wrangler.unstable_readConfig)({ config: this.config.cloudflare?.configPath }, {
|
|
51
|
+
preserveOriginalMain: true,
|
|
52
|
+
hideWarnings: true
|
|
53
|
+
});
|
|
54
|
+
this.cloudflare.wrangler = structuredClone(config);
|
|
55
|
+
},
|
|
56
|
+
async prepare() {
|
|
57
|
+
const result = await (0, _powerlines_plugin_env_helpers.readEnvTypeReflection)(this, "env");
|
|
58
|
+
return (0, _powerlines_plugin_alloy_render.render)(this, [(0, _alloy_js_core_jsx_runtime.createComponent)(require_components_cloudflare_builtin.CloudflareBuiltin, {}), (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_env_builtin.CloudflareEnvBuiltin, { reflection: result })]);
|
|
59
|
+
},
|
|
60
|
+
build: {
|
|
61
|
+
order: "pre",
|
|
62
|
+
async handler() {
|
|
63
|
+
const _self$ = this;
|
|
64
|
+
this.cloudflare ??= { workers: [] };
|
|
65
|
+
this.cloudflare.workers = await Promise.all(this.entry.map(async (entry, i, arr) => {
|
|
66
|
+
if (!entry.input) throw new Error(`Cloudflare Worker entry "${entry.file}" is missing an input file.`);
|
|
67
|
+
const workerModule = await (0, _powerlines_plugin_esbuild_helpers_resolve.resolveModule)(this, entry.input);
|
|
68
|
+
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".`);
|
|
69
|
+
const name = workerModule.metadata?.name || (0, _stryke_path.replaceExtension)(entry.input.file || entry.file) || arr.length > 1 ? `${this.config.name}-${i}` : this.config.name;
|
|
70
|
+
return {
|
|
71
|
+
metadata: {
|
|
72
|
+
name,
|
|
73
|
+
pattern: `${name}.{domain}`,
|
|
74
|
+
entry
|
|
75
|
+
},
|
|
76
|
+
fetch: (0, _stryke_type_checks_is_function.isFunction)(workerModule.default.fetch),
|
|
77
|
+
tail: (0, _stryke_type_checks_is_function.isFunction)(workerModule.default.tail),
|
|
78
|
+
trace: (0, _stryke_type_checks_is_function.isFunction)(workerModule.default.trace),
|
|
79
|
+
tailStream: (0, _stryke_type_checks_is_function.isFunction)(workerModule.default.tailStream),
|
|
80
|
+
scheduled: (0, _stryke_type_checks_is_function.isFunction)(workerModule.default.scheduled),
|
|
81
|
+
test: (0, _stryke_type_checks_is_function.isFunction)(workerModule.default.test),
|
|
82
|
+
email: (0, _stryke_type_checks_is_function.isFunction)(workerModule.default.email),
|
|
83
|
+
queue: (0, _stryke_type_checks_is_function.isFunction)(workerModule.default.queue)
|
|
84
|
+
};
|
|
85
|
+
}));
|
|
86
|
+
return (0, _powerlines_plugin_alloy_render.render)(this, (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
87
|
+
get each() {
|
|
88
|
+
return _self$.cloudflare.workers;
|
|
70
89
|
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
this.config.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
zoneId: zone.id,
|
|
163
|
-
proxied: true,
|
|
164
|
-
ttl: 1
|
|
165
|
-
}, { provider });
|
|
166
|
-
dnsRecords.push(dnsRecord);
|
|
167
|
-
}
|
|
168
|
-
return {
|
|
169
|
-
workers,
|
|
170
|
-
workerVersions,
|
|
171
|
-
workersDeployments,
|
|
172
|
-
workersRoutes,
|
|
173
|
-
dnsRecords
|
|
174
|
-
};
|
|
90
|
+
children: (worker) => (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_worker_entry.WorkerEntry, { worker })
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
async deploy() {
|
|
95
|
+
let apiToken = process.env.CLOUDFLARE_API_TOKEN;
|
|
96
|
+
if (!apiToken) {
|
|
97
|
+
apiToken = this.config.cloudflare.apiToken;
|
|
98
|
+
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.");
|
|
99
|
+
else throw new Error("Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.");
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
pulumi: { async deploy() {
|
|
103
|
+
let apiToken = process.env.CLOUDFLARE_API_TOKEN;
|
|
104
|
+
if (!apiToken) {
|
|
105
|
+
apiToken = this.config.cloudflare.apiToken;
|
|
106
|
+
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.");
|
|
107
|
+
else throw new Error("Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.");
|
|
108
|
+
}
|
|
109
|
+
await this.pulumi.setConfig("cloudflare:apiToken", { value: apiToken });
|
|
110
|
+
const provider = new _pulumi_cloudflare.Provider("cloudflare-provider", { apiToken });
|
|
111
|
+
const zone = await _pulumi_cloudflare.getZone({ filter: {
|
|
112
|
+
account: { id: this.config.cloudflare.accountId },
|
|
113
|
+
name: this.config.cloudflare.domain
|
|
114
|
+
} }, { provider });
|
|
115
|
+
const workers = [];
|
|
116
|
+
const workerVersions = [];
|
|
117
|
+
const workersDeployments = [];
|
|
118
|
+
const workersRoutes = [];
|
|
119
|
+
const dnsRecords = [];
|
|
120
|
+
for (const worker of this.cloudflare.workers) {
|
|
121
|
+
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)({
|
|
122
|
+
accountId: this.config.cloudflare.accountId,
|
|
123
|
+
name: worker.metadata.name,
|
|
124
|
+
tags: [
|
|
125
|
+
`project:${(0, _stryke_string_format_kebab_case.kebabCase)(this.config.name)}`,
|
|
126
|
+
this.config.organization ? `organization:${(0, _stryke_string_format_kebab_case.kebabCase)(this.config.organization)}` : void 0,
|
|
127
|
+
this.config.mode ? `mode:${(0, _stryke_string_format_kebab_case.kebabCase)(this.config.mode)}` : void 0
|
|
128
|
+
].filter(Boolean)
|
|
129
|
+
}, worker.metadata), { provider });
|
|
130
|
+
workers.push(resource);
|
|
131
|
+
const workerVersion = new _pulumi_cloudflare.WorkerVersion(`${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-version`, (0, defu.default)({
|
|
132
|
+
accountId: this.config.cloudflare.accountId,
|
|
133
|
+
workerId: resource.id,
|
|
134
|
+
mainModule: (0, _stryke_path.joinPaths)(this.config.output.path, "index.mjs"),
|
|
135
|
+
modules: [{
|
|
136
|
+
name: (0, _stryke_path.joinPaths)(this.config.output.path, "index.mjs"),
|
|
137
|
+
contentType: "application/javascript+module",
|
|
138
|
+
contentFile: (0, _stryke_path.joinPaths)(this.config.output.path, "index.mjs")
|
|
139
|
+
}]
|
|
140
|
+
}, worker.metadata, {
|
|
141
|
+
compatibilityDate: this.config.compatibilityDate?.cloudflare?.toString(),
|
|
142
|
+
compatibilityFlags: ["nodejs_als"]
|
|
143
|
+
}), { provider });
|
|
144
|
+
workerVersions.push(workerVersion);
|
|
145
|
+
const workersDeployment = new _pulumi_cloudflare.WorkersDeployment(`${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)}.workers-deployment`, (0, defu.default)({
|
|
146
|
+
accountId: this.config.cloudflare.accountId,
|
|
147
|
+
zoneId: zone.id,
|
|
148
|
+
strategy: "percentage",
|
|
149
|
+
scriptName: resource.name,
|
|
150
|
+
versions: [{
|
|
151
|
+
percentage: 100,
|
|
152
|
+
versionId: workerVersion.id
|
|
153
|
+
}]
|
|
154
|
+
}), { provider });
|
|
155
|
+
workersDeployments.push(workersDeployment);
|
|
156
|
+
const workersRoute = new _pulumi_cloudflare.WorkersRoute(`${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)}.workers-route`, (0, defu.default)({
|
|
157
|
+
accountId: this.config.cloudflare.accountId,
|
|
158
|
+
zoneId: zone.id,
|
|
159
|
+
pattern: worker.metadata.pattern.replace("{domain}", this.config.cloudflare.domain).replace("{scriptName}", worker.metadata.name).replace("{mode}", this.config.mode),
|
|
160
|
+
script: resource.name
|
|
161
|
+
}), { provider });
|
|
162
|
+
workersRoutes.push(workersRoute);
|
|
163
|
+
const dnsRecord = new _pulumi_cloudflare.DnsRecord(`${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)}.dns-record`, {
|
|
164
|
+
name: workersRoute.pattern,
|
|
165
|
+
type: "A",
|
|
166
|
+
content: "192.0.2.1",
|
|
167
|
+
zoneId: zone.id,
|
|
168
|
+
proxied: true,
|
|
169
|
+
ttl: 1
|
|
170
|
+
}, { provider });
|
|
171
|
+
dnsRecords.push(dnsRecord);
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
workers,
|
|
175
|
+
workerVersions,
|
|
176
|
+
workersDeployments,
|
|
177
|
+
workersRoutes,
|
|
178
|
+
dnsRecords
|
|
179
|
+
};
|
|
180
|
+
} }
|
|
175
181
|
}
|
|
176
|
-
|
|
182
|
+
];
|
|
177
183
|
}
|
|
178
184
|
|
|
179
185
|
//#endregion
|
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":";;;;;;;;;;YAmDY,MAAA;IACR,UAAA,GAAa,uBAAA;EAAA;AAAA;;;AAJY;iBAWb,MAAA,kBACG,uBAAA,GAA0B,uBAAA,CAAA,CAC3C,OAAA,GAAS,uBAAA,GAA+B,MAAA,CAAO,QAAA"}
|
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":";;;;;;;;;;YAmDY,MAAA;IACR,UAAA,GAAa,uBAAA;EAAA;AAAA;;;AAJY;iBAWb,MAAA,kBACG,uBAAA,GAA0B,uBAAA,CAAA,CAC3C,OAAA,GAAS,uBAAA,GAA+B,MAAA,CAAO,QAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import { getCloudflarePreset } from "@cloudflare/unenv-preset";
|
|
|
9
9
|
import { render } from "@powerlines/plugin-alloy/render";
|
|
10
10
|
import { readEnvTypeReflection } from "@powerlines/plugin-env/helpers";
|
|
11
11
|
import { resolveModule } from "@powerlines/plugin-esbuild/helpers/resolve";
|
|
12
|
+
import pulumi from "@powerlines/plugin-pulumi";
|
|
12
13
|
import unenv from "@powerlines/plugin-unenv";
|
|
13
14
|
import * as pulumiCloudflare from "@pulumi/cloudflare";
|
|
14
15
|
import { omit } from "@stryke/helpers/omit";
|
|
@@ -23,152 +24,156 @@ import { unstable_readConfig } from "wrangler";
|
|
|
23
24
|
* A Powerlines plugin to assist in developing other Powerlines plugins.
|
|
24
25
|
*/
|
|
25
26
|
function plugin(options = {}) {
|
|
26
|
-
return [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
27
|
+
return [
|
|
28
|
+
unenv(options.unenv),
|
|
29
|
+
...pulumi(options.pulumi),
|
|
30
|
+
{
|
|
31
|
+
name: "cloudflare",
|
|
32
|
+
config() {
|
|
33
|
+
return {
|
|
34
|
+
cloudflare: defu(omit(options, ["unenv", "pulumi"]), { configPath: resolveWranglerConfigPath(this) }),
|
|
35
|
+
resolve: { skipNodeModulesBundle: false },
|
|
36
|
+
unenv: { presets: [getCloudflarePreset({
|
|
37
|
+
compatibilityDate: this.config.compatibilityDate?.toString(),
|
|
38
|
+
compatibilityFlags: ["nodejs_als"]
|
|
39
|
+
})] }
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
configResolved() {
|
|
43
|
+
this.devDependencies["@cloudflare/workers-types"] = "^4.20240616.0";
|
|
44
|
+
const config = unstable_readConfig({ config: this.config.cloudflare?.configPath }, {
|
|
45
|
+
preserveOriginalMain: true,
|
|
46
|
+
hideWarnings: true
|
|
47
|
+
});
|
|
48
|
+
this.cloudflare.wrangler = structuredClone(config);
|
|
49
|
+
},
|
|
50
|
+
async prepare() {
|
|
51
|
+
const result = await readEnvTypeReflection(this, "env");
|
|
52
|
+
return render(this, [createComponent(CloudflareBuiltin, {}), createComponent(CloudflareEnvBuiltin, { reflection: result })]);
|
|
53
|
+
},
|
|
54
|
+
build: {
|
|
55
|
+
order: "pre",
|
|
56
|
+
async handler() {
|
|
57
|
+
const _self$ = this;
|
|
58
|
+
this.cloudflare ??= { workers: [] };
|
|
59
|
+
this.cloudflare.workers = await Promise.all(this.entry.map(async (entry, i, arr) => {
|
|
60
|
+
if (!entry.input) throw new Error(`Cloudflare Worker entry "${entry.file}" is missing an input file.`);
|
|
61
|
+
const workerModule = await resolveModule(this, entry.input);
|
|
62
|
+
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".`);
|
|
63
|
+
const name = workerModule.metadata?.name || replaceExtension(entry.input.file || entry.file) || arr.length > 1 ? `${this.config.name}-${i}` : this.config.name;
|
|
64
|
+
return {
|
|
65
|
+
metadata: {
|
|
66
|
+
name,
|
|
67
|
+
pattern: `${name}.{domain}`,
|
|
68
|
+
entry
|
|
69
|
+
},
|
|
70
|
+
fetch: isFunction(workerModule.default.fetch),
|
|
71
|
+
tail: isFunction(workerModule.default.tail),
|
|
72
|
+
trace: isFunction(workerModule.default.trace),
|
|
73
|
+
tailStream: isFunction(workerModule.default.tailStream),
|
|
74
|
+
scheduled: isFunction(workerModule.default.scheduled),
|
|
75
|
+
test: isFunction(workerModule.default.test),
|
|
76
|
+
email: isFunction(workerModule.default.email),
|
|
77
|
+
queue: isFunction(workerModule.default.queue)
|
|
78
|
+
};
|
|
79
|
+
}));
|
|
80
|
+
return render(this, createComponent(For, {
|
|
81
|
+
get each() {
|
|
82
|
+
return _self$.cloudflare.workers;
|
|
65
83
|
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
this.config.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
zoneId: zone.id,
|
|
158
|
-
proxied: true,
|
|
159
|
-
ttl: 1
|
|
160
|
-
}, { provider });
|
|
161
|
-
dnsRecords.push(dnsRecord);
|
|
162
|
-
}
|
|
163
|
-
return {
|
|
164
|
-
workers,
|
|
165
|
-
workerVersions,
|
|
166
|
-
workersDeployments,
|
|
167
|
-
workersRoutes,
|
|
168
|
-
dnsRecords
|
|
169
|
-
};
|
|
84
|
+
children: (worker) => createComponent(WorkerEntry, { worker })
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
async deploy() {
|
|
89
|
+
let apiToken = process.env.CLOUDFLARE_API_TOKEN;
|
|
90
|
+
if (!apiToken) {
|
|
91
|
+
apiToken = this.config.cloudflare.apiToken;
|
|
92
|
+
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.");
|
|
93
|
+
else throw new Error("Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.");
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
pulumi: { async deploy() {
|
|
97
|
+
let apiToken = process.env.CLOUDFLARE_API_TOKEN;
|
|
98
|
+
if (!apiToken) {
|
|
99
|
+
apiToken = this.config.cloudflare.apiToken;
|
|
100
|
+
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.");
|
|
101
|
+
else throw new Error("Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.");
|
|
102
|
+
}
|
|
103
|
+
await this.pulumi.setConfig("cloudflare:apiToken", { value: apiToken });
|
|
104
|
+
const provider = new pulumiCloudflare.Provider("cloudflare-provider", { apiToken });
|
|
105
|
+
const zone = await pulumiCloudflare.getZone({ filter: {
|
|
106
|
+
account: { id: this.config.cloudflare.accountId },
|
|
107
|
+
name: this.config.cloudflare.domain
|
|
108
|
+
} }, { provider });
|
|
109
|
+
const workers = [];
|
|
110
|
+
const workerVersions = [];
|
|
111
|
+
const workersDeployments = [];
|
|
112
|
+
const workersRoutes = [];
|
|
113
|
+
const dnsRecords = [];
|
|
114
|
+
for (const worker of this.cloudflare.workers) {
|
|
115
|
+
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({
|
|
116
|
+
accountId: this.config.cloudflare.accountId,
|
|
117
|
+
name: worker.metadata.name,
|
|
118
|
+
tags: [
|
|
119
|
+
`project:${kebabCase(this.config.name)}`,
|
|
120
|
+
this.config.organization ? `organization:${kebabCase(this.config.organization)}` : void 0,
|
|
121
|
+
this.config.mode ? `mode:${kebabCase(this.config.mode)}` : void 0
|
|
122
|
+
].filter(Boolean)
|
|
123
|
+
}, worker.metadata), { provider });
|
|
124
|
+
workers.push(resource);
|
|
125
|
+
const workerVersion = new pulumiCloudflare.WorkerVersion(`${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-version`, defu({
|
|
126
|
+
accountId: this.config.cloudflare.accountId,
|
|
127
|
+
workerId: resource.id,
|
|
128
|
+
mainModule: joinPaths(this.config.output.path, "index.mjs"),
|
|
129
|
+
modules: [{
|
|
130
|
+
name: joinPaths(this.config.output.path, "index.mjs"),
|
|
131
|
+
contentType: "application/javascript+module",
|
|
132
|
+
contentFile: joinPaths(this.config.output.path, "index.mjs")
|
|
133
|
+
}]
|
|
134
|
+
}, worker.metadata, {
|
|
135
|
+
compatibilityDate: this.config.compatibilityDate?.cloudflare?.toString(),
|
|
136
|
+
compatibilityFlags: ["nodejs_als"]
|
|
137
|
+
}), { provider });
|
|
138
|
+
workerVersions.push(workerVersion);
|
|
139
|
+
const workersDeployment = new pulumiCloudflare.WorkersDeployment(`${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)}.workers-deployment`, defu({
|
|
140
|
+
accountId: this.config.cloudflare.accountId,
|
|
141
|
+
zoneId: zone.id,
|
|
142
|
+
strategy: "percentage",
|
|
143
|
+
scriptName: resource.name,
|
|
144
|
+
versions: [{
|
|
145
|
+
percentage: 100,
|
|
146
|
+
versionId: workerVersion.id
|
|
147
|
+
}]
|
|
148
|
+
}), { provider });
|
|
149
|
+
workersDeployments.push(workersDeployment);
|
|
150
|
+
const workersRoute = new pulumiCloudflare.WorkersRoute(`${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)}.workers-route`, defu({
|
|
151
|
+
accountId: this.config.cloudflare.accountId,
|
|
152
|
+
zoneId: zone.id,
|
|
153
|
+
pattern: worker.metadata.pattern.replace("{domain}", this.config.cloudflare.domain).replace("{scriptName}", worker.metadata.name).replace("{mode}", this.config.mode),
|
|
154
|
+
script: resource.name
|
|
155
|
+
}), { provider });
|
|
156
|
+
workersRoutes.push(workersRoute);
|
|
157
|
+
const dnsRecord = new pulumiCloudflare.DnsRecord(`${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)}.dns-record`, {
|
|
158
|
+
name: workersRoute.pattern,
|
|
159
|
+
type: "A",
|
|
160
|
+
content: "192.0.2.1",
|
|
161
|
+
zoneId: zone.id,
|
|
162
|
+
proxied: true,
|
|
163
|
+
ttl: 1
|
|
164
|
+
}, { provider });
|
|
165
|
+
dnsRecords.push(dnsRecord);
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
workers,
|
|
169
|
+
workerVersions,
|
|
170
|
+
workersDeployments,
|
|
171
|
+
workersRoutes,
|
|
172
|
+
dnsRecords
|
|
173
|
+
};
|
|
174
|
+
} }
|
|
170
175
|
}
|
|
171
|
-
|
|
176
|
+
];
|
|
172
177
|
}
|
|
173
178
|
|
|
174
179
|
//#endregion
|
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\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":";;;;;;;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ACD;;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 pulumi from \"@powerlines/plugin-pulumi\";\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 = {}): Plugin<TContext>[] {\n return [\n unenv<TContext>(options.unenv),\n ...pulumi<TContext>(options.pulumi),\n {\n name: \"cloudflare\",\n config() {\n return {\n cloudflare: defu(omit(options, [\"unenv\", \"pulumi\"]), {\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 };\n })\n )) as CloudflareWorkerEntryModule[];\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 pulumi: {\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 await this.pulumi.setConfig(\"cloudflare:apiToken\", {\n value: apiToken\n });\n\n const provider = new pulumiCloudflare.Provider(\n \"cloudflare-provider\",\n {\n apiToken\n }\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(\n this.config.output.path,\n \"index.mjs\"\n )\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 }\n ] as Plugin<TContext>[];\n}\n\nexport default plugin;\n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A,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;MAC3D,MAAM,aAAe;MACrB,MAAK;MACH,SAAM;MACN,QAAK,KAAK;MACV,SAAI;MACJ,KAAK;MACN,EAAE,EACD,UACD,CAAC;AACF,gBAAQ,KAAA,UAAe;;AAEzB,WAAO;KACL;KACA;KACA;KACA;KACA;KACD;MAEJ;GACF;EAAC"}
|
package/dist/types/plugin.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { WranglerResolvedConfig } from "./wrangler.cjs";
|
|
|
2
2
|
import { WorkerModuleMetadata } from "./worker-module.cjs";
|
|
3
3
|
import { ExportedHandler } from "@cloudflare/workers-types";
|
|
4
4
|
import { EnvPluginContext, EnvPluginResolvedConfig, EnvPluginUserConfig } from "@powerlines/plugin-env";
|
|
5
|
-
import { PulumiPluginContext, PulumiPluginResolvedConfig, PulumiPluginUserConfig } from "@powerlines/plugin-pulumi";
|
|
5
|
+
import { PulumiPluginContext, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginUserConfig } from "@powerlines/plugin-pulumi";
|
|
6
6
|
import { UnenvPluginContext, UnenvPluginOptions, UnenvPluginResolvedConfig, UnenvPluginUserConfig } from "@powerlines/plugin-unenv";
|
|
7
7
|
import { RequiredKeys } from "@stryke/types/base";
|
|
8
8
|
import { PluginContext, ResolvedEntryTypeDefinition } from "powerlines";
|
|
@@ -45,18 +45,22 @@ interface CloudflarePluginOptions {
|
|
|
45
45
|
* The plugin will automatically include the Cloudflare preset for unenv, which provides compatibility with Cloudflare Workers runtimes. You can customize the unenv configuration by providing options here, but the Cloudflare preset will always be included.
|
|
46
46
|
*/
|
|
47
47
|
unenv?: UnenvPluginOptions;
|
|
48
|
+
/**
|
|
49
|
+
* The configuration options for Pulumi.
|
|
50
|
+
*/
|
|
51
|
+
pulumi?: PulumiPluginOptions;
|
|
48
52
|
}
|
|
49
53
|
type CloudflarePluginUserConfig = EnvPluginUserConfig & PulumiPluginUserConfig & UnenvPluginUserConfig & {
|
|
50
54
|
/**
|
|
51
55
|
* Options for the Cloudflare plugin.
|
|
52
56
|
*/
|
|
53
|
-
cloudflare?: Omit<CloudflarePluginOptions, "unenv">;
|
|
57
|
+
cloudflare?: Omit<CloudflarePluginOptions, "unenv" | "pulumi">;
|
|
54
58
|
};
|
|
55
59
|
type CloudflarePluginResolvedConfig = EnvPluginResolvedConfig & PulumiPluginResolvedConfig & UnenvPluginResolvedConfig & {
|
|
56
60
|
/**
|
|
57
61
|
* Options for the Cloudflare plugin.
|
|
58
62
|
*/
|
|
59
|
-
cloudflare: Required<Omit<CloudflarePluginOptions, "unenv">>;
|
|
63
|
+
cloudflare: Required<Omit<CloudflarePluginOptions, "unenv" | "pulumi">>;
|
|
60
64
|
};
|
|
61
65
|
type CloudflareWorkerMetadata = RequiredKeys<WorkerModuleMetadata, "name" | "pattern"> & {
|
|
62
66
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;;;;;;UAyCiB,uBAAA;;AAAjB;;;;;;;EASE,SAAA;EA+BA;;;;;;AAQF;;EA7BE,QAAA;EA6BuC;;;;;;EArBvC,UAAA;EAqBuC;;;EAhBvC,MAAA;EAsBe;;;;AAGjB;;EAjBE,KAAA,GAAQ,kBAAA;EAiBmC;;;EAZ3C,MAAA,GAAS,mBAAA;AAAA;AAAA,KAGC,0BAAA,GAA6B,mBAAA,GACvC,sBAAA,GACA,qBAAA;EAasB;;;EATpB,UAAA,GAAa,IAAA,CAAK,uBAAA;AAAA;AAAA,KAGV,8BAAA,GAAiC,uBAAA,GAC3C,0BAAA,GACA,yBAAA;EAIc;;;EAAZ,UAAA,EAAY,QAAA,CAAS,IAAA,CAAK,uBAAA;AAAA;AAAA,KAGlB,wBAAA,GAA2B,YAAA,CACrC,oBAAA;EADkC;;;EAOlC,KAAA,EAAO,2BAAA;AAAA;AAAA,KAGG,2BAAA,GAA8B,MAAA,OAClC,eAAA;EAJ4B;;;EAUlC,QAAA,EAAU,wBAAA;AAAA;AAAA,KAGA,uBAAA,yBACc,8BAAA,GACtB,8BAAA,IACA,aAAA,CAAc,eAAA,IAChB,gBAAA,CAAiB,eAAA,IACjB,mBAAA,CAAoB,eAAA,IACpB,kBAAA,CAAmB,eAAA;EACjB,UAAA;IACE,QAAA,GAAW,sBAAA;IACX,OAAA,EAAS,2BAAA;EAAA;AAAA;AAAA"}
|
package/dist/types/plugin.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { WranglerResolvedConfig } from "./wrangler.mjs";
|
|
2
2
|
import { WorkerModuleMetadata } from "./worker-module.mjs";
|
|
3
|
+
import { PulumiPluginContext, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginUserConfig } from "@powerlines/plugin-pulumi";
|
|
3
4
|
import { UnenvPluginContext, UnenvPluginOptions, UnenvPluginResolvedConfig, UnenvPluginUserConfig } from "@powerlines/plugin-unenv";
|
|
4
5
|
import { ExportedHandler } from "@cloudflare/workers-types";
|
|
5
6
|
import { EnvPluginContext, EnvPluginResolvedConfig, EnvPluginUserConfig } from "@powerlines/plugin-env";
|
|
6
|
-
import { PulumiPluginContext, PulumiPluginResolvedConfig, PulumiPluginUserConfig } from "@powerlines/plugin-pulumi";
|
|
7
7
|
import { RequiredKeys } from "@stryke/types/base";
|
|
8
8
|
import { PluginContext, ResolvedEntryTypeDefinition } from "powerlines";
|
|
9
9
|
|
|
@@ -45,18 +45,22 @@ interface CloudflarePluginOptions {
|
|
|
45
45
|
* The plugin will automatically include the Cloudflare preset for unenv, which provides compatibility with Cloudflare Workers runtimes. You can customize the unenv configuration by providing options here, but the Cloudflare preset will always be included.
|
|
46
46
|
*/
|
|
47
47
|
unenv?: UnenvPluginOptions;
|
|
48
|
+
/**
|
|
49
|
+
* The configuration options for Pulumi.
|
|
50
|
+
*/
|
|
51
|
+
pulumi?: PulumiPluginOptions;
|
|
48
52
|
}
|
|
49
53
|
type CloudflarePluginUserConfig = EnvPluginUserConfig & PulumiPluginUserConfig & UnenvPluginUserConfig & {
|
|
50
54
|
/**
|
|
51
55
|
* Options for the Cloudflare plugin.
|
|
52
56
|
*/
|
|
53
|
-
cloudflare?: Omit<CloudflarePluginOptions, "unenv">;
|
|
57
|
+
cloudflare?: Omit<CloudflarePluginOptions, "unenv" | "pulumi">;
|
|
54
58
|
};
|
|
55
59
|
type CloudflarePluginResolvedConfig = EnvPluginResolvedConfig & PulumiPluginResolvedConfig & UnenvPluginResolvedConfig & {
|
|
56
60
|
/**
|
|
57
61
|
* Options for the Cloudflare plugin.
|
|
58
62
|
*/
|
|
59
|
-
cloudflare: Required<Omit<CloudflarePluginOptions, "unenv">>;
|
|
63
|
+
cloudflare: Required<Omit<CloudflarePluginOptions, "unenv" | "pulumi">>;
|
|
60
64
|
};
|
|
61
65
|
type CloudflareWorkerMetadata = RequiredKeys<WorkerModuleMetadata, "name" | "pattern"> & {
|
|
62
66
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;;;;;;UAyCiB,uBAAA;;AAAjB;;;;;;;EASE,SAAA;EA+BA;;;;;;AAQF;;EA7BE,QAAA;EA6BuC;;;;;;EArBvC,UAAA;EAqBuC;;;EAhBvC,MAAA;EAsBe;;;;AAGjB;;EAjBE,KAAA,GAAQ,kBAAA;EAiBmC;;;EAZ3C,MAAA,GAAS,mBAAA;AAAA;AAAA,KAGC,0BAAA,GAA6B,mBAAA,GACvC,sBAAA,GACA,qBAAA;EAasB;;;EATpB,UAAA,GAAa,IAAA,CAAK,uBAAA;AAAA;AAAA,KAGV,8BAAA,GAAiC,uBAAA,GAC3C,0BAAA,GACA,yBAAA;EAIc;;;EAAZ,UAAA,EAAY,QAAA,CAAS,IAAA,CAAK,uBAAA;AAAA;AAAA,KAGlB,wBAAA,GAA2B,YAAA,CACrC,oBAAA;EADkC;;;EAOlC,KAAA,EAAO,2BAAA;AAAA;AAAA,KAGG,2BAAA,GAA8B,MAAA,OAClC,eAAA;EAJ4B;;;EAUlC,QAAA,EAAU,wBAAA;AAAA;AAAA,KAGA,uBAAA,yBACc,8BAAA,GACtB,8BAAA,IACA,aAAA,CAAc,eAAA,IAChB,gBAAA,CAAiB,eAAA,IACjB,mBAAA,CAAoB,eAAA,IACpB,kBAAA,CAAmB,eAAA;EACjB,UAAA;IACE,QAAA,GAAW,sBAAA;IACX,OAAA,EAAS,2BAAA;EAAA;AAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-cloudflare",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.9",
|
|
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,11 +209,11 @@
|
|
|
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.
|
|
215
|
-
"@pulumi/cloudflare": "^6.
|
|
216
|
-
"@pulumi/pulumi": "^3.
|
|
212
|
+
"@powerlines/plugin-env": "^0.16.110",
|
|
213
|
+
"@powerlines/plugin-pulumi": "^0.6.29",
|
|
214
|
+
"@powerlines/plugin-unenv": "^0.1.377",
|
|
215
|
+
"@pulumi/cloudflare": "^6.14.0",
|
|
216
|
+
"@pulumi/pulumi": "^3.229.0",
|
|
217
217
|
"@storm-software/config-tools": "^1.189.72",
|
|
218
218
|
"@stryke/hash": "^0.13.17",
|
|
219
219
|
"@stryke/helpers": "^0.10.7",
|
|
@@ -222,17 +222,17 @@
|
|
|
222
222
|
"@stryke/type-checks": "^0.6.0",
|
|
223
223
|
"@stryke/types": "^0.11.2",
|
|
224
224
|
"defu": "^6.1.6",
|
|
225
|
-
"powerlines": "^0.42.
|
|
225
|
+
"powerlines": "^0.42.29"
|
|
226
226
|
},
|
|
227
227
|
"devDependencies": {
|
|
228
228
|
"@cloudflare/unenv-preset": "^2.16.0",
|
|
229
|
-
"@cloudflare/workers-types": "^4.
|
|
230
|
-
"@powerlines/plugin-alloy": "^0.26.
|
|
231
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
232
|
-
"@types/node": "^25.5.
|
|
233
|
-
"wrangler": "^4.
|
|
229
|
+
"@cloudflare/workers-types": "^4.20260403.1",
|
|
230
|
+
"@powerlines/plugin-alloy": "^0.26.4",
|
|
231
|
+
"@powerlines/plugin-plugin": "^0.12.339",
|
|
232
|
+
"@types/node": "^25.5.2",
|
|
233
|
+
"wrangler": "^4.80.0",
|
|
234
234
|
"zod": "^4.3.6"
|
|
235
235
|
},
|
|
236
236
|
"publishConfig": { "access": "public" },
|
|
237
|
-
"gitHead": "
|
|
237
|
+
"gitHead": "a3bf899dc847341452a0c384eb598c096b186a11"
|
|
238
238
|
}
|