@cloudflare/deploy-helpers 0.15.1 → 0.17.0
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.d.mts +4 -2
- package/dist/index.mjs +302 -143
- package/dist/metafile-esm.json +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -11,10 +11,11 @@ import url2, { URLSearchParams as URLSearchParams$1 } from 'node:url';
|
|
|
11
11
|
import * as cli from '@cloudflare/cli-shared-helpers';
|
|
12
12
|
import { updateStatus, cancel } from '@cloudflare/cli-shared-helpers';
|
|
13
13
|
import { SchedulingPolicy, ApplicationsService, listDurableObjects, ApiError, resolveImageName, pushImageIfChanged, ContainerImagePreparationsService, ContainerImagePreparationStatus, createDurableObjectNamespaceResolver, initContainersSharedContext, pushBuiltContainerImage, deployContainers, verifyDockerInstalled } from '@cloudflare/containers-shared';
|
|
14
|
-
import { INHERIT_SYMBOL, APIError, UserError, getEnvironmentVariableFactory, isNonInteractiveOrCI, getHostFromRoute, retryOnAPIFailure, ParseError, getComplianceRegionSubdomain, configFileName, formatTime, getSubdomainMixedStateCheckDisabled, LOGGER_LEVELS, getResolvedDurableObjectContainerApps, isDurableObjectContainerApp, getDockerPath, validateDurableObjectContainerApplications, getDurableObjectClassNameToUseSQLiteMap, SERVICE_TAG_PREFIX, ENVIRONMENT_TAG_PREFIX, getDurableObjectExports,
|
|
14
|
+
import { INHERIT_SYMBOL, APIError, UserError, getEnvironmentVariableFactory, partitionExports, isNonInteractiveOrCI, getHostFromRoute, retryOnAPIFailure, ParseError, getComplianceRegionSubdomain, configFileName, formatTime, getSubdomainMixedStateCheckDisabled, LOGGER_LEVELS, getResolvedDurableObjectContainerApps, isDurableObjectContainerApp, getDockerPath, validateDurableObjectContainerApplications, getDurableObjectClassNameToUseSQLiteMap, SERVICE_TAG_PREFIX, ENVIRONMENT_TAG_PREFIX, getDurableObjectExports, getWranglerTmpDir, parsePackageJSON, getInstalledPackageVersion, FatalError, readFileSync as readFileSync$1, parseJSON, printBindings, experimental_readRawConfig, experimental_patchConfig, PatchConfigError, COMPLIANCE_REGION_CONFIG_UNKNOWN, constructWranglerConfig, getCIMatchTag, formatConfigSnippet, DEFAULT_COMPAT_DATE, writeOutput, getDurableObjectContainerApps, getBindings, hasDurableObjectExports, parseNonHyphenedUuid, getWorkersCIBranchName, getCIOverrideName, isLiveDurableObjectExport, getBindingTypeFriendlyName, defaultWranglerConfig } from '@cloudflare/workers-utils';
|
|
15
15
|
import { Response, FormData } from 'undici';
|
|
16
16
|
import chalk6 from 'chalk';
|
|
17
17
|
import PQueue from 'p-queue';
|
|
18
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
18
19
|
import { spinner, inputPrompt, leftT } from '@cloudflare/cli-shared-helpers/interactive';
|
|
19
20
|
import { writeFile, access, readFile, readdir, stat } from 'node:fs/promises';
|
|
20
21
|
import prettyBytes from 'pretty-bytes';
|
|
@@ -22,7 +23,6 @@ import { hash as hash$1 } from 'blake3-wasm';
|
|
|
22
23
|
import { Blob } from 'node:buffer';
|
|
23
24
|
import { gzipSync } from 'node:zlib';
|
|
24
25
|
import { brandColor, white, gray, bold, yellow, dim, red, blue } from '@cloudflare/cli-shared-helpers/colors';
|
|
25
|
-
import { isDeepStrictEqual } from 'node:util';
|
|
26
26
|
import { setTimeout as setTimeout$1 } from 'node:timers/promises';
|
|
27
27
|
import readline from 'node:readline';
|
|
28
28
|
import { parse as parse$1 } from 'dotenv';
|
|
@@ -2753,6 +2753,82 @@ var EXPORTS_RECONCILIATION_ERROR_CODE = 100402;
|
|
|
2753
2753
|
var INCONSISTENT_EXPORTS_ACROSS_VERSIONS_CODE = 100405;
|
|
2754
2754
|
var ACTOR_BINDING_DEPENDS_ON_EXPORT_CODE = 100406;
|
|
2755
2755
|
var WORKFLOW_CRON_REQUIRES_PAID_PLAN_CODE = 10208;
|
|
2756
|
+
function isWorkflowDefinedInThisScript(workflow, scriptName) {
|
|
2757
|
+
return workflow.script_name === void 0 || workflow.script_name === scriptName;
|
|
2758
|
+
}
|
|
2759
|
+
__name(isWorkflowDefinedInThisScript, "isWorkflowDefinedInThisScript");
|
|
2760
|
+
function getWorkflowsOwnedByScript(config2, scriptName) {
|
|
2761
|
+
const owned = /* @__PURE__ */ new Map();
|
|
2762
|
+
for (const workflow of config2.workflows ?? []) {
|
|
2763
|
+
if (isWorkflowDefinedInThisScript(workflow, scriptName)) {
|
|
2764
|
+
owned.set(workflow.name, workflow);
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
for (const [className, workflowExport] of Object.entries(
|
|
2768
|
+
partitionExports(config2.exports).workflow
|
|
2769
|
+
)) {
|
|
2770
|
+
const binding = owned.get(workflowExport.name);
|
|
2771
|
+
owned.set(workflowExport.name, {
|
|
2772
|
+
name: workflowExport.name,
|
|
2773
|
+
class_name: className,
|
|
2774
|
+
limits: binding?.limits ?? workflowExport.limits,
|
|
2775
|
+
concurrency: binding?.concurrency ?? workflowExport.concurrency,
|
|
2776
|
+
schedules: binding?.schedules ?? workflowExport.schedules,
|
|
2777
|
+
default_retention: binding?.default_retention ?? workflowExport.default_retention
|
|
2778
|
+
});
|
|
2779
|
+
}
|
|
2780
|
+
return [...owned.values()];
|
|
2781
|
+
}
|
|
2782
|
+
__name(getWorkflowsOwnedByScript, "getWorkflowsOwnedByScript");
|
|
2783
|
+
function validateOwnedWorkflowDeclarations(config2, scriptName) {
|
|
2784
|
+
const exportsByWorkflowName = new Map(
|
|
2785
|
+
Object.entries(partitionExports(config2.exports).workflow).map(
|
|
2786
|
+
([className, workflowExport]) => [
|
|
2787
|
+
workflowExport.name,
|
|
2788
|
+
{ className, workflowExport }
|
|
2789
|
+
]
|
|
2790
|
+
)
|
|
2791
|
+
);
|
|
2792
|
+
const errors = [];
|
|
2793
|
+
for (const [index, workflow] of (config2.workflows ?? []).entries()) {
|
|
2794
|
+
const match = exportsByWorkflowName.get(workflow.name);
|
|
2795
|
+
if (match === void 0) {
|
|
2796
|
+
continue;
|
|
2797
|
+
}
|
|
2798
|
+
const { className, workflowExport } = match;
|
|
2799
|
+
if (!isWorkflowDefinedInThisScript(workflow, scriptName)) {
|
|
2800
|
+
errors.push(
|
|
2801
|
+
`"workflows[${index}]" binds the Workflow "${workflow.name}" of the Worker "${workflow.script_name}", but "exports.${className}" declares it in this Worker. Workflow names are unique per account, so remove "script_name" from the binding or give the export a different name.`
|
|
2802
|
+
);
|
|
2803
|
+
continue;
|
|
2804
|
+
}
|
|
2805
|
+
if (workflow.class_name !== className) {
|
|
2806
|
+
errors.push(
|
|
2807
|
+
`"workflows[${index}]" and "exports.${className}" both declare the Workflow "${workflow.name}", but with different classes ("${workflow.class_name}" and "${className}").`
|
|
2808
|
+
);
|
|
2809
|
+
}
|
|
2810
|
+
for (const key of [
|
|
2811
|
+
"limits",
|
|
2812
|
+
"concurrency",
|
|
2813
|
+
"schedules",
|
|
2814
|
+
"default_retention"
|
|
2815
|
+
]) {
|
|
2816
|
+
const bindingValue = workflow[key];
|
|
2817
|
+
const exportValue = workflowExport[key];
|
|
2818
|
+
if (bindingValue !== void 0 && exportValue !== void 0 && !isDeepStrictEqual([bindingValue].flat(), [exportValue].flat())) {
|
|
2819
|
+
errors.push(
|
|
2820
|
+
`"workflows[${index}].${key}" and "exports.${className}.${key}" both configure the Workflow "${workflow.name}", but with different values. Set "${key}" in only one of them.`
|
|
2821
|
+
);
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
if (errors.length > 0) {
|
|
2826
|
+
throw new UserError(errors.join("\n"), {
|
|
2827
|
+
telemetryMessage: "workflow binding and export declarations conflict"
|
|
2828
|
+
});
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
__name(validateOwnedWorkflowDeclarations, "validateOwnedWorkflowDeclarations");
|
|
2756
2832
|
|
|
2757
2833
|
// src/deploy/helpers/worker-not-found-error.ts
|
|
2758
2834
|
var WORKER_NOT_FOUND_ERR_CODE = 10007;
|
|
@@ -4007,6 +4083,7 @@ async function triggersDeploy(props) {
|
|
|
4007
4083
|
const { config: config2, scriptName, routes, crons } = props;
|
|
4008
4084
|
if (props.validated !== true) {
|
|
4009
4085
|
validateEventTriggerTargets(config2, scriptName);
|
|
4086
|
+
validateOwnedWorkflowDeclarations(config2, scriptName);
|
|
4010
4087
|
}
|
|
4011
4088
|
if (props.dryRun) {
|
|
4012
4089
|
logger.log(`--dry-run: exiting now.`);
|
|
@@ -4031,9 +4108,7 @@ async function triggersDeploy(props) {
|
|
|
4031
4108
|
const uploadMs = Date.now() - start;
|
|
4032
4109
|
const deployments = [];
|
|
4033
4110
|
const workflowDeployments = [];
|
|
4034
|
-
const
|
|
4035
|
-
(workflow) => isWorkflowDefinedInThisScript(workflow, scriptName)
|
|
4036
|
-
);
|
|
4111
|
+
const ownedWorkflows = getWorkflowsOwnedByScript(config2, scriptName);
|
|
4037
4112
|
const { wantWorkersDev, workersDevInSync } = await subdomainDeploy(
|
|
4038
4113
|
props,
|
|
4039
4114
|
accountId,
|
|
@@ -4101,7 +4176,7 @@ ${dashLink}`, {
|
|
|
4101
4176
|
});
|
|
4102
4177
|
}
|
|
4103
4178
|
}
|
|
4104
|
-
if (!wantWorkersDev &&
|
|
4179
|
+
if (!wantWorkersDev && ownedWorkflows.length > 0) {
|
|
4105
4180
|
await getWorkersDevSubdomain(config2, accountId, {
|
|
4106
4181
|
configPath: config2.configPath,
|
|
4107
4182
|
registrationContext: "workflows"
|
|
@@ -4182,98 +4257,97 @@ ${dashLink}`, {
|
|
|
4182
4257
|
)
|
|
4183
4258
|
);
|
|
4184
4259
|
}
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
if (
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
);
|
|
4195
|
-
}
|
|
4196
|
-
if (workflow.concurrency) {
|
|
4197
|
-
throw new UserError(
|
|
4198
|
-
`Workflow "${workflow.name}" has "concurrency" configured but references external script "${workflow.script_name}". Configure concurrency on the worker that defines the workflow.`,
|
|
4199
|
-
{
|
|
4200
|
-
telemetryMessage: "triggers deploy workflow concurrency external script"
|
|
4201
|
-
}
|
|
4202
|
-
);
|
|
4203
|
-
}
|
|
4204
|
-
if (workflow.schedules) {
|
|
4205
|
-
throw new UserError(
|
|
4206
|
-
`Workflow "${workflow.name}" has "schedules" configured but references external script "${workflow.script_name}". Configure schedules on the worker that defines the workflow.`,
|
|
4207
|
-
{
|
|
4208
|
-
telemetryMessage: "triggers deploy workflow schedules external script"
|
|
4209
|
-
}
|
|
4210
|
-
);
|
|
4211
|
-
}
|
|
4212
|
-
if (workflow.default_retention) {
|
|
4213
|
-
throw new UserError(
|
|
4214
|
-
`Workflow "${workflow.name}" has "default_retention" configured but references external script "${workflow.script_name}". Configure default_retention on the worker that defines the workflow.`,
|
|
4215
|
-
{
|
|
4216
|
-
telemetryMessage: "triggers deploy workflow default_retention external script"
|
|
4217
|
-
}
|
|
4218
|
-
);
|
|
4219
|
-
}
|
|
4220
|
-
continue;
|
|
4260
|
+
for (const workflow of config2.workflows) {
|
|
4261
|
+
if (!isWorkflowDefinedInThisScript(workflow, scriptName)) {
|
|
4262
|
+
if (workflow.limits) {
|
|
4263
|
+
throw new UserError(
|
|
4264
|
+
`Workflow "${workflow.name}" has "limits" configured but references external script "${workflow.script_name}". Configure limits on the worker that defines the workflow.`,
|
|
4265
|
+
{
|
|
4266
|
+
telemetryMessage: "triggers deploy workflow limits external script"
|
|
4267
|
+
}
|
|
4268
|
+
);
|
|
4221
4269
|
}
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
config2,
|
|
4226
|
-
`/accounts/${accountId}/workflows/${workflow.name}`,
|
|
4270
|
+
if (workflow.concurrency) {
|
|
4271
|
+
throw new UserError(
|
|
4272
|
+
`Workflow "${workflow.name}" has "concurrency" configured but references external script "${workflow.script_name}". Configure concurrency on the worker that defines the workflow.`,
|
|
4227
4273
|
{
|
|
4228
|
-
|
|
4229
|
-
body: JSON.stringify({
|
|
4230
|
-
script_name: scriptName,
|
|
4231
|
-
class_name: workflow.class_name,
|
|
4232
|
-
...workflow.limits && { limits: workflow.limits },
|
|
4233
|
-
...workflow.concurrency && {
|
|
4234
|
-
concurrency: workflow.concurrency
|
|
4235
|
-
},
|
|
4236
|
-
...workflow.schedules && {
|
|
4237
|
-
schedules: (Array.isArray(workflow.schedules) ? workflow.schedules : [workflow.schedules]).map((cron) => ({ cron }))
|
|
4238
|
-
},
|
|
4239
|
-
...workflow.default_retention && {
|
|
4240
|
-
default_retention: workflow.default_retention
|
|
4241
|
-
}
|
|
4242
|
-
}),
|
|
4243
|
-
headers: {
|
|
4244
|
-
"Content-Type": "application/json"
|
|
4245
|
-
}
|
|
4274
|
+
telemetryMessage: "triggers deploy workflow concurrency external script"
|
|
4246
4275
|
}
|
|
4247
|
-
)
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
}
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4276
|
+
);
|
|
4277
|
+
}
|
|
4278
|
+
if (workflow.schedules) {
|
|
4279
|
+
throw new UserError(
|
|
4280
|
+
`Workflow "${workflow.name}" has "schedules" configured but references external script "${workflow.script_name}". Configure schedules on the worker that defines the workflow.`,
|
|
4281
|
+
{
|
|
4282
|
+
telemetryMessage: "triggers deploy workflow schedules external script"
|
|
4283
|
+
}
|
|
4284
|
+
);
|
|
4285
|
+
}
|
|
4286
|
+
if (workflow.default_retention) {
|
|
4287
|
+
throw new UserError(
|
|
4288
|
+
`Workflow "${workflow.name}" has "default_retention" configured but references external script "${workflow.script_name}". Configure default_retention on the worker that defines the workflow.`,
|
|
4289
|
+
{
|
|
4290
|
+
telemetryMessage: "triggers deploy workflow default_retention external script"
|
|
4291
|
+
}
|
|
4292
|
+
);
|
|
4293
|
+
}
|
|
4294
|
+
}
|
|
4295
|
+
}
|
|
4296
|
+
for (const workflow of ownedWorkflows) {
|
|
4297
|
+
workflowDeployments.push({
|
|
4298
|
+
name: workflow.name,
|
|
4299
|
+
deployment: fetchResult(
|
|
4300
|
+
config2,
|
|
4301
|
+
`/accounts/${accountId}/workflows/${workflow.name}`,
|
|
4302
|
+
{
|
|
4303
|
+
method: "PUT",
|
|
4304
|
+
body: JSON.stringify({
|
|
4305
|
+
script_name: scriptName,
|
|
4306
|
+
class_name: workflow.class_name,
|
|
4307
|
+
...workflow.limits && { limits: workflow.limits },
|
|
4308
|
+
...workflow.concurrency && {
|
|
4309
|
+
concurrency: workflow.concurrency
|
|
4310
|
+
},
|
|
4311
|
+
...workflow.schedules && {
|
|
4312
|
+
schedules: (Array.isArray(workflow.schedules) ? workflow.schedules : [workflow.schedules]).map((cron) => ({ cron }))
|
|
4313
|
+
},
|
|
4314
|
+
...workflow.default_retention && {
|
|
4315
|
+
default_retention: workflow.default_retention
|
|
4266
4316
|
}
|
|
4317
|
+
}),
|
|
4318
|
+
headers: {
|
|
4319
|
+
"Content-Type": "application/json"
|
|
4320
|
+
}
|
|
4321
|
+
}
|
|
4322
|
+
).then(
|
|
4323
|
+
() => ({
|
|
4324
|
+
category: "Workflows",
|
|
4325
|
+
targets: [`workflow: ${workflow.name}`]
|
|
4326
|
+
}),
|
|
4327
|
+
(error51) => {
|
|
4328
|
+
if (error51 instanceof APIError && error51.code === WORKFLOW_CRON_REQUIRES_PAID_PLAN_CODE && workflow.schedules) {
|
|
4329
|
+
error51.preventReport();
|
|
4267
4330
|
return {
|
|
4268
4331
|
category: "Workflows",
|
|
4269
|
-
resource: `Workflow "${workflow.name}"`,
|
|
4270
4332
|
targets: [],
|
|
4271
|
-
error:
|
|
4333
|
+
error: new UserError(
|
|
4334
|
+
`Workflow "${workflow.name}" has "schedules" configured, but scheduled Workflows require a paid Workers plan.`,
|
|
4335
|
+
{
|
|
4336
|
+
cause: error51,
|
|
4337
|
+
telemetryMessage: "triggers deploy workflow cron requires paid plan"
|
|
4338
|
+
}
|
|
4339
|
+
)
|
|
4272
4340
|
};
|
|
4273
4341
|
}
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4342
|
+
return {
|
|
4343
|
+
category: "Workflows",
|
|
4344
|
+
resource: `Workflow "${workflow.name}"`,
|
|
4345
|
+
targets: [],
|
|
4346
|
+
error: error51
|
|
4347
|
+
};
|
|
4348
|
+
}
|
|
4349
|
+
)
|
|
4350
|
+
});
|
|
4277
4351
|
}
|
|
4278
4352
|
const completedWorkflowDeployments = await Promise.all(
|
|
4279
4353
|
workflowDeployments.map(async ({ name, deployment }) => ({
|
|
@@ -4570,12 +4644,12 @@ async function subdomainDeploy(props, accountId, scriptName, workerUrl, routes,
|
|
|
4570
4644
|
}
|
|
4571
4645
|
__name(subdomainDeploy, "subdomainDeploy");
|
|
4572
4646
|
function validateEventTriggerTargets(config2, scriptName) {
|
|
4647
|
+
const ownedWorkflowNames = new Set(
|
|
4648
|
+
getWorkflowsOwnedByScript(config2, scriptName).map(({ name }) => name)
|
|
4649
|
+
);
|
|
4573
4650
|
for (const event of config2.triggers?.events ?? []) {
|
|
4574
4651
|
for (const target of event.targets) {
|
|
4575
|
-
|
|
4576
|
-
(workflow) => workflow.name === target.workflow_name && isWorkflowDefinedInThisScript(workflow, scriptName)
|
|
4577
|
-
);
|
|
4578
|
-
if (!isDefinedByThisWorker) {
|
|
4652
|
+
if (!ownedWorkflowNames.has(target.workflow_name)) {
|
|
4579
4653
|
throw new UserError(
|
|
4580
4654
|
`Event trigger "${event.type}" targets Workflow "${target.workflow_name}", but that Workflow is not defined by this Worker.
|
|
4581
4655
|
|
|
@@ -4589,10 +4663,6 @@ Add it to the "workflows" configuration or remove the event trigger target.`,
|
|
|
4589
4663
|
}
|
|
4590
4664
|
}
|
|
4591
4665
|
__name(validateEventTriggerTargets, "validateEventTriggerTargets");
|
|
4592
|
-
function isWorkflowDefinedInThisScript(workflow, scriptName) {
|
|
4593
|
-
return workflow.script_name === void 0 || workflow.script_name === scriptName;
|
|
4594
|
-
}
|
|
4595
|
-
__name(isWorkflowDefinedInThisScript, "isWorkflowDefinedInThisScript");
|
|
4596
4666
|
|
|
4597
4667
|
// ../workers-shared/utils/configuration/constants.ts
|
|
4598
4668
|
var MAX_ROUTES_RULES = 100;
|
|
@@ -6679,10 +6749,16 @@ var IMAGE_PREPARATION_POLL_INTERVAL_MS = 2e3;
|
|
|
6679
6749
|
var IMAGE_PREPARATION_TIMEOUT_MS = 15 * 6e4;
|
|
6680
6750
|
function getApplicationSettings(container) {
|
|
6681
6751
|
const flags = container.unsafe?.configuration?.experimental_flags;
|
|
6752
|
+
const configuration = {
|
|
6753
|
+
...flags !== void 0 && { experimental_flags: flags },
|
|
6754
|
+
// The Containers API calls `ssh` `wrangler_ssh`.
|
|
6755
|
+
...container.ssh !== void 0 && { wrangler_ssh: container.ssh },
|
|
6756
|
+
...container.authorized_keys !== void 0 && {
|
|
6757
|
+
authorized_keys: container.authorized_keys
|
|
6758
|
+
}
|
|
6759
|
+
};
|
|
6682
6760
|
return {
|
|
6683
|
-
...
|
|
6684
|
-
configuration: { experimental_flags: flags }
|
|
6685
|
-
},
|
|
6761
|
+
...Object.keys(configuration).length > 0 && { configuration },
|
|
6686
6762
|
...container.observability !== void 0 && {
|
|
6687
6763
|
observability: {
|
|
6688
6764
|
logs: {
|
|
@@ -6697,6 +6773,13 @@ function normalizeFlags(flags = []) {
|
|
|
6697
6773
|
return [...new Set(flags)].sort();
|
|
6698
6774
|
}
|
|
6699
6775
|
__name(normalizeFlags, "normalizeFlags");
|
|
6776
|
+
function hasConfigurationChanged(configured, existing = {}) {
|
|
6777
|
+
return configured.experimental_flags !== void 0 && !isDeepStrictEqual(
|
|
6778
|
+
normalizeFlags(configured.experimental_flags),
|
|
6779
|
+
normalizeFlags(existing.experimental_flags)
|
|
6780
|
+
) || configured.wrangler_ssh !== void 0 && !isDeepStrictEqual(configured.wrangler_ssh, existing.wrangler_ssh) || configured.authorized_keys !== void 0 && !isDeepStrictEqual(configured.authorized_keys, existing.authorized_keys);
|
|
6781
|
+
}
|
|
6782
|
+
__name(hasConfigurationChanged, "hasConfigurationChanged");
|
|
6700
6783
|
function isRegistryImage(image) {
|
|
6701
6784
|
return typeof image.image === "string";
|
|
6702
6785
|
}
|
|
@@ -6863,10 +6946,7 @@ async function applyApplication(application, namespaceId, settings = {}, updateE
|
|
|
6863
6946
|
return;
|
|
6864
6947
|
}
|
|
6865
6948
|
const patch = {};
|
|
6866
|
-
if (settings.configuration !== void 0 &&
|
|
6867
|
-
normalizeFlags(settings.configuration.experimental_flags),
|
|
6868
|
-
normalizeFlags(existing.configuration?.experimental_flags)
|
|
6869
|
-
)) {
|
|
6949
|
+
if (settings.configuration !== void 0 && hasConfigurationChanged(settings.configuration, existing.configuration)) {
|
|
6870
6950
|
patch.configuration = settings.configuration;
|
|
6871
6951
|
}
|
|
6872
6952
|
if (settings.observability !== void 0 && !isDeepStrictEqual(settings.observability, existing.observability)) {
|
|
@@ -7267,7 +7347,14 @@ async function resolveExportsUploadPayload(props) {
|
|
|
7267
7347
|
const { migrations, exports: durableObjectExports } = await resolveDoLifecyclePayload(props);
|
|
7268
7348
|
const exports$1 = {
|
|
7269
7349
|
...partitionedExports.worker,
|
|
7270
|
-
...durableObjectExports ?? {}
|
|
7350
|
+
...durableObjectExports ?? {},
|
|
7351
|
+
// Workflow settings are applied when `triggers deploy` provisions the
|
|
7352
|
+
// Workflow; the upload API only accepts the type and name.
|
|
7353
|
+
...Object.fromEntries(
|
|
7354
|
+
Object.entries(partitionedExports.workflow).map(
|
|
7355
|
+
([className, { name }]) => [className, { type: "workflow", name }]
|
|
7356
|
+
)
|
|
7357
|
+
)
|
|
7271
7358
|
};
|
|
7272
7359
|
return {
|
|
7273
7360
|
migrations,
|
|
@@ -24384,10 +24471,8 @@ async function getWorkflow(config2, accountId, workflowName) {
|
|
|
24384
24471
|
}
|
|
24385
24472
|
__name(getWorkflow, "getWorkflow");
|
|
24386
24473
|
async function checkWorkflowConflicts(config2, accountId, scriptName) {
|
|
24387
|
-
const workflowsToDeploy = config2
|
|
24388
|
-
|
|
24389
|
-
);
|
|
24390
|
-
if (!workflowsToDeploy?.length) {
|
|
24474
|
+
const workflowsToDeploy = getWorkflowsOwnedByScript(config2, scriptName);
|
|
24475
|
+
if (!workflowsToDeploy.length) {
|
|
24391
24476
|
return { hasConflicts: false };
|
|
24392
24477
|
}
|
|
24393
24478
|
const workflowChecks = await Promise.all(
|
|
@@ -25165,6 +25250,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
25165
25250
|
{ telemetryMessage: "data_blobs with es module worker" }
|
|
25166
25251
|
);
|
|
25167
25252
|
}
|
|
25253
|
+
validateOwnedWorkflowDeclarations(config2, name);
|
|
25168
25254
|
if (props.command === "deploy") {
|
|
25169
25255
|
validateEventTriggerTargets(config2, name);
|
|
25170
25256
|
validateRoutes(props.routes, props.assetsOptions);
|
|
@@ -25312,13 +25398,11 @@ Edits that have been made via the script API will be overridden by your local co
|
|
|
25312
25398
|
return { workerTag, tags, workerExists, aborted: true };
|
|
25313
25399
|
}
|
|
25314
25400
|
}
|
|
25315
|
-
|
|
25316
|
-
|
|
25317
|
-
|
|
25318
|
-
|
|
25319
|
-
|
|
25320
|
-
return { workerTag, tags, workerExists, aborted: true };
|
|
25321
|
-
}
|
|
25401
|
+
const workflowCheck = await checkWorkflowConflicts(config2, accountId, name);
|
|
25402
|
+
if (workflowCheck.hasConflicts) {
|
|
25403
|
+
logger.warn(workflowCheck.message);
|
|
25404
|
+
if (!await deployConfirm("Do you want to continue?")) {
|
|
25405
|
+
return { workerTag, tags, workerExists, aborted: true };
|
|
25322
25406
|
}
|
|
25323
25407
|
}
|
|
25324
25408
|
await ensureQueuesExistByConfig(
|
|
@@ -25841,12 +25925,16 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
25841
25925
|
});
|
|
25842
25926
|
}
|
|
25843
25927
|
}
|
|
25844
|
-
await deployContainers(
|
|
25845
|
-
|
|
25846
|
-
|
|
25847
|
-
|
|
25848
|
-
|
|
25849
|
-
|
|
25928
|
+
await deployContainers(
|
|
25929
|
+
{ ...config2, containers: props.containers.source },
|
|
25930
|
+
containerDeployments,
|
|
25931
|
+
{
|
|
25932
|
+
versionId,
|
|
25933
|
+
accountId,
|
|
25934
|
+
scriptName,
|
|
25935
|
+
dispatchNamespace: props.dispatchNamespace
|
|
25936
|
+
}
|
|
25937
|
+
);
|
|
25850
25938
|
}
|
|
25851
25939
|
if (!skipContainerChanges && durableObjectContainerConfig.length > 0) {
|
|
25852
25940
|
assert6(versionId && accountId);
|
|
@@ -26985,7 +27073,7 @@ function getDeclaredDOClassNames(config2) {
|
|
|
26985
27073
|
for (const [className, entry] of Object.entries(
|
|
26986
27074
|
getDurableObjectExports(config2.exports)
|
|
26987
27075
|
)) {
|
|
26988
|
-
if (entry
|
|
27076
|
+
if (isLiveDurableObjectExport(entry)) {
|
|
26989
27077
|
declared.add(className);
|
|
26990
27078
|
}
|
|
26991
27079
|
}
|
|
@@ -27042,6 +27130,68 @@ function assertPreviewBuildOutputRootConfig(rootConfig) {
|
|
|
27042
27130
|
}
|
|
27043
27131
|
}
|
|
27044
27132
|
__name(assertPreviewBuildOutputRootConfig, "assertPreviewBuildOutputRootConfig");
|
|
27133
|
+
function convertBuildOutputContainerToInput(container) {
|
|
27134
|
+
if ("image" in container) {
|
|
27135
|
+
const { image, ...config2 } = container;
|
|
27136
|
+
return {
|
|
27137
|
+
...config2,
|
|
27138
|
+
image: {
|
|
27139
|
+
reference: "reference" in image ? image.reference : image.localReference
|
|
27140
|
+
}
|
|
27141
|
+
};
|
|
27142
|
+
}
|
|
27143
|
+
throw new UserError(
|
|
27144
|
+
"Preview uploads from Build Output don't support Durable Object-managed Containers.",
|
|
27145
|
+
{
|
|
27146
|
+
telemetryMessage: "preview build output durable object container not supported"
|
|
27147
|
+
}
|
|
27148
|
+
);
|
|
27149
|
+
}
|
|
27150
|
+
__name(convertBuildOutputContainerToInput, "convertBuildOutputContainerToInput");
|
|
27151
|
+
function getLocalContainerImageReferences(containers, previewContainers) {
|
|
27152
|
+
const localReferences = /* @__PURE__ */ new Map();
|
|
27153
|
+
for (const container of containers ?? []) {
|
|
27154
|
+
if ("image" in container && "localReference" in container.image) {
|
|
27155
|
+
localReferences.set(container.name, container.image.localReference);
|
|
27156
|
+
}
|
|
27157
|
+
}
|
|
27158
|
+
return new Map(
|
|
27159
|
+
previewContainers.flatMap((container) => {
|
|
27160
|
+
const localReference = container.name === void 0 ? void 0 : localReferences.get(container.name);
|
|
27161
|
+
return localReference === void 0 || container.class_name === void 0 ? [] : [[container.class_name, localReference]];
|
|
27162
|
+
})
|
|
27163
|
+
);
|
|
27164
|
+
}
|
|
27165
|
+
__name(getLocalContainerImageReferences, "getLocalContainerImageReferences");
|
|
27166
|
+
function convertBuildOutputContainers(containers, exports$1) {
|
|
27167
|
+
const containerClassNames = /* @__PURE__ */ new Map();
|
|
27168
|
+
for (const [className, configExport] of Object.entries(
|
|
27169
|
+
getDurableObjectExports(exports$1)
|
|
27170
|
+
)) {
|
|
27171
|
+
if (isLiveDurableObjectExport(configExport) && configExport.container !== void 0) {
|
|
27172
|
+
containerClassNames.set(configExport.container, className);
|
|
27173
|
+
}
|
|
27174
|
+
}
|
|
27175
|
+
const containerNames = new Set(containers?.map(({ name }) => name));
|
|
27176
|
+
for (const [containerName, className] of containerClassNames) {
|
|
27177
|
+
if (!containerNames.has(containerName)) {
|
|
27178
|
+
throw new UserError(
|
|
27179
|
+
`The Durable Object class "${className}" references the Container "${containerName}", but that Container was not included in the Build Output.`,
|
|
27180
|
+
{
|
|
27181
|
+
telemetryMessage: "preview build output container missing"
|
|
27182
|
+
}
|
|
27183
|
+
);
|
|
27184
|
+
}
|
|
27185
|
+
}
|
|
27186
|
+
const converted = convertToWranglerConfig({
|
|
27187
|
+
containers: (containers ?? []).map(convertBuildOutputContainerToInput)
|
|
27188
|
+
}).containers;
|
|
27189
|
+
return (converted ?? []).map((container) => ({
|
|
27190
|
+
...container,
|
|
27191
|
+
class_name: container.name === void 0 ? void 0 : containerClassNames.get(container.name)
|
|
27192
|
+
}));
|
|
27193
|
+
}
|
|
27194
|
+
__name(convertBuildOutputContainers, "convertBuildOutputContainers");
|
|
27045
27195
|
function buildPreviewContainerConfig(config2, parentWorkerName, previewSlug, previewContainers) {
|
|
27046
27196
|
const previews = config2.previews;
|
|
27047
27197
|
const previewDOBindings = previews?.durable_objects?.bindings ?? [];
|
|
@@ -27101,7 +27251,7 @@ function getPreviewExports(exports$1) {
|
|
|
27101
27251
|
return previewExports;
|
|
27102
27252
|
}
|
|
27103
27253
|
__name(getPreviewExports, "getPreviewExports");
|
|
27104
|
-
async function prepareContainersForPreview(config2, workerName, previewSlug, callbacks) {
|
|
27254
|
+
async function prepareContainersForPreview(config2, workerName, previewSlug, callbacks, localImageReferences) {
|
|
27105
27255
|
const previewContainers = config2.previews?.containers ?? [];
|
|
27106
27256
|
if (previewContainers.length === 0 || !callbacks.getNormalizedContainerOptions) {
|
|
27107
27257
|
return { scopedContainerConfig: void 0, normalisedContainerConfig: [] };
|
|
@@ -27121,11 +27271,11 @@ async function prepareContainersForPreview(config2, workerName, previewSlug, cal
|
|
|
27121
27271
|
const containersNeedingDocker = normalisedContainerConfig.filter(
|
|
27122
27272
|
(container) => "dockerfile" in container
|
|
27123
27273
|
);
|
|
27124
|
-
if (containersNeedingDocker.length > 0) {
|
|
27274
|
+
if (containersNeedingDocker.length > 0 || localImageReferences.size > 0) {
|
|
27125
27275
|
await verifyDockerInstalled({
|
|
27126
27276
|
dockerPath: getDockerPath(),
|
|
27127
27277
|
operation: "creating a preview",
|
|
27128
|
-
imageNoun: containersNeedingDocker.length !== 1 ? "the configured images" : "the configured image",
|
|
27278
|
+
imageNoun: containersNeedingDocker.length + localImageReferences.size !== 1 ? "the configured images" : "the configured image",
|
|
27129
27279
|
hint: 'If you cannot run Docker locally, set "image" to a prebuilt registry image instead of a Dockerfile path for the affected entries in "previews.containers".'
|
|
27130
27280
|
});
|
|
27131
27281
|
}
|
|
@@ -27563,7 +27713,7 @@ async function provisionParentWorker(config2, accountId, workerName, json2) {
|
|
|
27563
27713
|
);
|
|
27564
27714
|
}
|
|
27565
27715
|
__name(provisionParentWorker, "provisionParentWorker");
|
|
27566
|
-
async function runPreview(accountId, args, config2, buildResult, assetsOptions, callbacks, workerName, replaceTailConsumersAfterCreate = false) {
|
|
27716
|
+
async function runPreview(accountId, args, config2, buildResult, assetsOptions, callbacks, workerName, replaceTailConsumersAfterCreate = false, localImageReferences = /* @__PURE__ */ new Map()) {
|
|
27567
27717
|
let secrets;
|
|
27568
27718
|
if (args.secretsFile) {
|
|
27569
27719
|
secrets = (await parseBulkInputToObject(args.secretsFile))?.content;
|
|
@@ -27642,7 +27792,8 @@ async function runPreview(accountId, args, config2, buildResult, assetsOptions,
|
|
|
27642
27792
|
config2,
|
|
27643
27793
|
workerName,
|
|
27644
27794
|
previewResource.slug,
|
|
27645
|
-
callbacks
|
|
27795
|
+
callbacks,
|
|
27796
|
+
localImageReferences
|
|
27646
27797
|
);
|
|
27647
27798
|
const deploymentRequest = await assemblePreviewDeploymentSettings(
|
|
27648
27799
|
config2,
|
|
@@ -27680,7 +27831,7 @@ async function runPreview(accountId, args, config2, buildResult, assetsOptions,
|
|
|
27680
27831
|
normalisedContainerConfig,
|
|
27681
27832
|
deployment,
|
|
27682
27833
|
accountId,
|
|
27683
|
-
{ quiet: args.json === true }
|
|
27834
|
+
{ quiet: args.json === true, localImageReferences }
|
|
27684
27835
|
);
|
|
27685
27836
|
} catch (error51) {
|
|
27686
27837
|
logger.warn(
|
|
@@ -27737,7 +27888,7 @@ async function preview(accountId, args, config2, buildResult, assetsOptions, cal
|
|
|
27737
27888
|
);
|
|
27738
27889
|
}
|
|
27739
27890
|
__name(preview, "preview");
|
|
27740
|
-
async function previewBuildOutput(accountId, args, buildOutput) {
|
|
27891
|
+
async function previewBuildOutput(accountId, args, buildOutput, callbacks) {
|
|
27741
27892
|
const { workerConfig, rootConfig, buildResult, assets } = buildOutput;
|
|
27742
27893
|
assertPreviewBuildOutputRootConfig(rootConfig);
|
|
27743
27894
|
if (workerConfig.domains?.length) {
|
|
@@ -27764,16 +27915,6 @@ async function previewBuildOutput(accountId, args, buildOutput) {
|
|
|
27764
27915
|
}
|
|
27765
27916
|
);
|
|
27766
27917
|
}
|
|
27767
|
-
if (Object.values(workerConfig.exports ?? {}).some(
|
|
27768
|
-
(configExport) => "container" in configExport && configExport.container !== void 0
|
|
27769
|
-
)) {
|
|
27770
|
-
throw new UserError(
|
|
27771
|
-
"Preview uploads from Build Output don't support Container-backed Durable Objects.",
|
|
27772
|
-
{
|
|
27773
|
-
telemetryMessage: "preview build output containers not supported"
|
|
27774
|
-
}
|
|
27775
|
-
);
|
|
27776
|
-
}
|
|
27777
27918
|
if (workerConfig.unsafe?.capnp !== void 0 || Object.keys(workerConfig.unsafe?.metadata ?? {}).length > 0) {
|
|
27778
27919
|
throw new UserError(
|
|
27779
27920
|
"Preview uploads from Build Output don't support unsafe metadata or Cap'n Proto schemas.",
|
|
@@ -27787,9 +27928,24 @@ async function previewBuildOutput(accountId, args, buildOutput) {
|
|
|
27787
27928
|
const convertedConfig = convertToWranglerConfig({
|
|
27788
27929
|
...settings,
|
|
27789
27930
|
worker,
|
|
27790
|
-
// TODO: Add support for Containers in Preview uploads from Build Output.
|
|
27791
27931
|
containers: []
|
|
27792
27932
|
});
|
|
27933
|
+
const previewContainers = convertBuildOutputContainers(
|
|
27934
|
+
buildOutput.containers,
|
|
27935
|
+
convertedConfig.exports
|
|
27936
|
+
);
|
|
27937
|
+
const localImageReferences = getLocalContainerImageReferences(
|
|
27938
|
+
buildOutput.containers,
|
|
27939
|
+
previewContainers
|
|
27940
|
+
);
|
|
27941
|
+
if (previewContainers.length > 0 && (callbacks?.getNormalizedContainerOptions === void 0 || callbacks.deployPreviewContainers === void 0)) {
|
|
27942
|
+
throw new UserError(
|
|
27943
|
+
"Preview uploads from Build Output with Containers require container deployment callbacks.",
|
|
27944
|
+
{
|
|
27945
|
+
telemetryMessage: "preview build output container callbacks missing"
|
|
27946
|
+
}
|
|
27947
|
+
);
|
|
27948
|
+
}
|
|
27793
27949
|
const previewBuildResult = buildResult && {
|
|
27794
27950
|
...buildResult,
|
|
27795
27951
|
mainModuleName: workerConfig.manifest?.mainModule
|
|
@@ -27797,6 +27953,7 @@ async function previewBuildOutput(accountId, args, buildOutput) {
|
|
|
27797
27953
|
const bindings = extractBuildOutputBindings(convertedConfig);
|
|
27798
27954
|
const previewConfig = {
|
|
27799
27955
|
...defaultWranglerConfig,
|
|
27956
|
+
account_id: accountId,
|
|
27800
27957
|
compliance_region: convertedConfig.compliance_region,
|
|
27801
27958
|
name: workerConfig.name,
|
|
27802
27959
|
compatibility_date: convertedConfig.compatibility_date,
|
|
@@ -27810,6 +27967,7 @@ async function previewBuildOutput(accountId, args, buildOutput) {
|
|
|
27810
27967
|
workers_dev: false,
|
|
27811
27968
|
preview_urls: true,
|
|
27812
27969
|
previews: {
|
|
27970
|
+
containers: previewContainers,
|
|
27813
27971
|
tail_consumers: convertedConfig.tail_consumers ?? (workerConfig.tailConsumers === void 0 ? void 0 : []),
|
|
27814
27972
|
unsafe: {
|
|
27815
27973
|
bindings: Object.entries(bindings).map(([name, binding]) => ({
|
|
@@ -27836,12 +27994,13 @@ async function previewBuildOutput(accountId, args, buildOutput) {
|
|
|
27836
27994
|
previewConfig,
|
|
27837
27995
|
previewBuildResult,
|
|
27838
27996
|
assetsOptions,
|
|
27839
|
-
{
|
|
27997
|
+
callbacks ?? {
|
|
27840
27998
|
getNormalizedContainerOptions: void 0,
|
|
27841
27999
|
deployPreviewContainers: void 0
|
|
27842
28000
|
},
|
|
27843
28001
|
workerConfig.name,
|
|
27844
|
-
true
|
|
28002
|
+
true,
|
|
28003
|
+
localImageReferences
|
|
27845
28004
|
);
|
|
27846
28005
|
}
|
|
27847
28006
|
__name(previewBuildOutput, "previewBuildOutput");
|