@cloudflare/deploy-helpers 0.26.4 → 0.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +7 -6
- package/dist/index.mjs +50 -33
- package/dist/metafile-esm.json +1 -1
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -7,7 +7,7 @@ export { createWorkerUploadForm, fromMimeType, moduleTypeMimeType } from './crea
|
|
|
7
7
|
import { Options } from '@cspotcode/source-map-support';
|
|
8
8
|
import Protocol from 'devtools-protocol';
|
|
9
9
|
import { NodeJSCompatMode } from '@cloudflare/workers-utils/node-compat';
|
|
10
|
-
import {
|
|
10
|
+
import { ParsedBuildOutputWorkerConfig, ParsedBuildOutputRootConfig, ParsedBuildOutputContainerConfig } from '@cloudflare/config';
|
|
11
11
|
import { ContainerNormalizedConfig } from '@cloudflare/containers-shared';
|
|
12
12
|
|
|
13
13
|
interface BundleSize {
|
|
@@ -842,6 +842,7 @@ type ResolveExportsUploadPayloadProps = Parameters<typeof resolveDoLifecyclePayl
|
|
|
842
842
|
declare function resolveExportsUploadPayload(props: ResolveExportsUploadPayloadProps): Promise<{
|
|
843
843
|
migrations: CfWorkerInit["migrations"];
|
|
844
844
|
exports: CfWorkerInit["exports"];
|
|
845
|
+
headers: Record<string, string> | undefined;
|
|
845
846
|
}>;
|
|
846
847
|
|
|
847
848
|
/**
|
|
@@ -1260,20 +1261,20 @@ type PreviewResult = {
|
|
|
1260
1261
|
deployment: DeploymentResource;
|
|
1261
1262
|
isNewPreview: boolean;
|
|
1262
1263
|
};
|
|
1263
|
-
type PreviewBuildOutputRootConfig =
|
|
1264
|
-
buildContext:
|
|
1264
|
+
type PreviewBuildOutputRootConfig = ParsedBuildOutputRootConfig & {
|
|
1265
|
+
buildContext: ParsedBuildOutputRootConfig["buildContext"] & {
|
|
1265
1266
|
isPreview: true;
|
|
1266
1267
|
};
|
|
1267
1268
|
};
|
|
1268
1269
|
type PreviewBuildOutput = {
|
|
1269
|
-
workerConfig:
|
|
1270
|
+
workerConfig: ParsedBuildOutputWorkerConfig;
|
|
1270
1271
|
rootConfig: PreviewBuildOutputRootConfig;
|
|
1271
1272
|
buildResult?: WorkerBuildResult;
|
|
1272
1273
|
assets?: Pick<PreviewAssetsOptions, "directory" | "_headers" | "_redirects">;
|
|
1273
|
-
containers?:
|
|
1274
|
+
containers?: ParsedBuildOutputContainerConfig[];
|
|
1274
1275
|
};
|
|
1275
1276
|
/** Verify that Build Output was produced with Preview configuration. */
|
|
1276
|
-
declare function assertPreviewBuildOutputRootConfig(rootConfig:
|
|
1277
|
+
declare function assertPreviewBuildOutputRootConfig(rootConfig: ParsedBuildOutputRootConfig | undefined): asserts rootConfig is PreviewBuildOutputRootConfig;
|
|
1277
1278
|
type PreviewOptions = {
|
|
1278
1279
|
deployCommand?: string;
|
|
1279
1280
|
previewCommand?: string;
|
package/dist/index.mjs
CHANGED
|
@@ -17,9 +17,9 @@ import { parseAndExpandDotEnv } from '@cloudflare/workers-utils/local-env';
|
|
|
17
17
|
import { Response, FormData } from 'undici';
|
|
18
18
|
import chalk6 from 'chalk';
|
|
19
19
|
import PQueue4 from 'p-queue';
|
|
20
|
-
import { isDeepStrictEqual, TextDecoder as TextDecoder$1 } from 'node:util';
|
|
21
20
|
import { spinner, inputPrompt, leftT } from '@cloudflare/cli-shared-helpers/interactive';
|
|
22
21
|
import { writeFile, access, readFile, readdir, stat } from 'node:fs/promises';
|
|
22
|
+
import { TextDecoder as TextDecoder$1, isDeepStrictEqual } from 'node:util';
|
|
23
23
|
import prettyBytes from 'pretty-bytes';
|
|
24
24
|
import { hash as hash$1 } from 'blake3-wasm';
|
|
25
25
|
import { Blob } from 'node:buffer';
|
|
@@ -2773,15 +2773,14 @@ function getWorkflowsOwnedByScript(config2, scriptName) {
|
|
|
2773
2773
|
for (const [className, workflowExport] of Object.entries(
|
|
2774
2774
|
partitionExports(config2.exports).workflow
|
|
2775
2775
|
)) {
|
|
2776
|
-
const binding = owned.get(workflowExport.name);
|
|
2777
2776
|
owned.set(workflowExport.name, {
|
|
2778
2777
|
name: workflowExport.name,
|
|
2779
2778
|
class_name: className,
|
|
2780
|
-
limits:
|
|
2781
|
-
concurrency:
|
|
2782
|
-
schedules:
|
|
2783
|
-
default_retention:
|
|
2784
|
-
jurisdiction:
|
|
2779
|
+
limits: workflowExport.limits,
|
|
2780
|
+
concurrency: workflowExport.concurrency,
|
|
2781
|
+
schedules: workflowExport.schedules,
|
|
2782
|
+
default_retention: workflowExport.default_retention,
|
|
2783
|
+
jurisdiction: workflowExport.jurisdiction
|
|
2785
2784
|
});
|
|
2786
2785
|
}
|
|
2787
2786
|
return [...owned.values()];
|
|
@@ -2790,19 +2789,15 @@ __name(getWorkflowsOwnedByScript, "getWorkflowsOwnedByScript");
|
|
|
2790
2789
|
function validateOwnedWorkflowDeclarations(config2, scriptName) {
|
|
2791
2790
|
const exportsByWorkflowName = new Map(
|
|
2792
2791
|
Object.entries(partitionExports(config2.exports).workflow).map(
|
|
2793
|
-
([className, workflowExport]) => [
|
|
2794
|
-
workflowExport.name,
|
|
2795
|
-
{ className, workflowExport }
|
|
2796
|
-
]
|
|
2792
|
+
([className, workflowExport]) => [workflowExport.name, className]
|
|
2797
2793
|
)
|
|
2798
2794
|
);
|
|
2799
2795
|
const errors = [];
|
|
2800
2796
|
for (const [index, workflow] of (config2.workflows ?? []).entries()) {
|
|
2801
|
-
const
|
|
2802
|
-
if (
|
|
2797
|
+
const className = exportsByWorkflowName.get(workflow.name);
|
|
2798
|
+
if (className === void 0) {
|
|
2803
2799
|
continue;
|
|
2804
2800
|
}
|
|
2805
|
-
const { className, workflowExport } = match;
|
|
2806
2801
|
if (!isWorkflowDefinedInThisScript(workflow, scriptName)) {
|
|
2807
2802
|
errors.push(
|
|
2808
2803
|
`"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.`
|
|
@@ -2821,11 +2816,9 @@ function validateOwnedWorkflowDeclarations(config2, scriptName) {
|
|
|
2821
2816
|
"default_retention",
|
|
2822
2817
|
"jurisdiction"
|
|
2823
2818
|
]) {
|
|
2824
|
-
|
|
2825
|
-
const exportValue = workflowExport[key];
|
|
2826
|
-
if (bindingValue !== void 0 && exportValue !== void 0 && !isDeepStrictEqual([bindingValue].flat(), [exportValue].flat())) {
|
|
2819
|
+
if (workflow[key] !== void 0) {
|
|
2827
2820
|
errors.push(
|
|
2828
|
-
`"workflows[${index}].${key}"
|
|
2821
|
+
`"workflows[${index}].${key}" configures the Workflow "${workflow.name}", which "exports.${className}" declares. Set "${key}" on the export instead.`
|
|
2829
2822
|
);
|
|
2830
2823
|
}
|
|
2831
2824
|
}
|
|
@@ -7700,23 +7693,21 @@ async function resolveDoLifecyclePayload(props) {
|
|
|
7700
7693
|
__name(resolveDoLifecyclePayload, "resolveDoLifecyclePayload");
|
|
7701
7694
|
|
|
7702
7695
|
// src/deploy/helpers/exports.ts
|
|
7696
|
+
var WORKFLOW_EXPORTS_SCRIPT_API_DATE = "2026-11-09";
|
|
7703
7697
|
async function resolveExportsUploadPayload(props) {
|
|
7704
7698
|
const partitionedExports = partitionExports(props.config.exports);
|
|
7705
7699
|
const { migrations, exports: durableObjectExports } = await resolveDoLifecyclePayload(props);
|
|
7706
7700
|
const exports$1 = {
|
|
7707
7701
|
...partitionedExports.worker,
|
|
7708
7702
|
...durableObjectExports ?? {},
|
|
7709
|
-
|
|
7710
|
-
// Workflow; the upload API only accepts the type and name.
|
|
7711
|
-
...Object.fromEntries(
|
|
7712
|
-
Object.entries(partitionedExports.workflow).map(
|
|
7713
|
-
([className, { name }]) => [className, { type: "workflow", name }]
|
|
7714
|
-
)
|
|
7715
|
-
)
|
|
7703
|
+
...partitionedExports.workflow
|
|
7716
7704
|
};
|
|
7717
7705
|
return {
|
|
7718
7706
|
migrations,
|
|
7719
|
-
exports: Object.keys(exports$1).length > 0 ? exports$1 : void 0
|
|
7707
|
+
exports: Object.keys(exports$1).length > 0 ? exports$1 : void 0,
|
|
7708
|
+
headers: Object.keys(partitionedExports.workflow).length > 0 ? {
|
|
7709
|
+
"Cloudflare-Workers-Script-Api-Date": WORKFLOW_EXPORTS_SCRIPT_API_DATE
|
|
7710
|
+
} : void 0
|
|
7720
7711
|
};
|
|
7721
7712
|
}
|
|
7722
7713
|
__name(resolveExportsUploadPayload, "resolveExportsUploadPayload");
|
|
@@ -31573,7 +31564,11 @@ async function deployWorker(props, config2, buildResult, options) {
|
|
|
31573
31564
|
const containerMetadata = rolloutSkipContainerState ? rolloutSkipContainerState.containers : getContainerMetadata(props.containers.source, preparedContainerImages, {
|
|
31574
31565
|
exports: config2.exports
|
|
31575
31566
|
});
|
|
31576
|
-
const {
|
|
31567
|
+
const {
|
|
31568
|
+
migrations,
|
|
31569
|
+
exports: exports$1,
|
|
31570
|
+
headers: exportsHeaders
|
|
31571
|
+
} = await resolveExportsUploadPayload({
|
|
31577
31572
|
scriptName,
|
|
31578
31573
|
isDryRun,
|
|
31579
31574
|
accountId,
|
|
@@ -31763,7 +31758,10 @@ async function deployWorker(props, config2, buildResult, options) {
|
|
|
31763
31758
|
{
|
|
31764
31759
|
method: "POST",
|
|
31765
31760
|
body: workerBundle,
|
|
31766
|
-
headers:
|
|
31761
|
+
headers: {
|
|
31762
|
+
...exportsHeaders,
|
|
31763
|
+
...props.sendMetrics && { metricsEnabled: "true" }
|
|
31764
|
+
}
|
|
31767
31765
|
},
|
|
31768
31766
|
new URLSearchParams$1({ bindings_inherit: "strict" })
|
|
31769
31767
|
),
|
|
@@ -31816,7 +31814,10 @@ async function deployWorker(props, config2, buildResult, options) {
|
|
|
31816
31814
|
{
|
|
31817
31815
|
method: "PUT",
|
|
31818
31816
|
body: workerBundle,
|
|
31819
|
-
headers:
|
|
31817
|
+
headers: {
|
|
31818
|
+
...exportsHeaders,
|
|
31819
|
+
...props.sendMetrics && { metricsEnabled: "true" }
|
|
31820
|
+
}
|
|
31820
31821
|
},
|
|
31821
31822
|
new URLSearchParams$1({
|
|
31822
31823
|
// pass excludeScript so the whole body of the
|
|
@@ -31896,6 +31897,16 @@ async function deployWorker(props, config2, buildResult, options) {
|
|
|
31896
31897
|
{ telemetryMessage: "deploy do exports reconciliation failed" }
|
|
31897
31898
|
);
|
|
31898
31899
|
}
|
|
31900
|
+
if (err instanceof APIError && err.code === WORKFLOW_CRON_REQUIRES_PAID_PLAN_CODE) {
|
|
31901
|
+
err.preventReport();
|
|
31902
|
+
throw new UserError(
|
|
31903
|
+
`A Workflow has "schedules" configured, but scheduled Workflows require a paid Workers plan.`,
|
|
31904
|
+
{
|
|
31905
|
+
cause: err,
|
|
31906
|
+
telemetryMessage: "deploy workflow cron requires paid plan"
|
|
31907
|
+
}
|
|
31908
|
+
);
|
|
31909
|
+
}
|
|
31899
31910
|
const message = await helpIfErrorIsSizeOrScriptStartup(
|
|
31900
31911
|
err,
|
|
31901
31912
|
dependencies,
|
|
@@ -32128,7 +32139,11 @@ async function uploadWorkerVersion(props, config2, buildResult, options) {
|
|
|
32128
32139
|
hidden: true
|
|
32129
32140
|
};
|
|
32130
32141
|
}
|
|
32131
|
-
const {
|
|
32142
|
+
const {
|
|
32143
|
+
migrations,
|
|
32144
|
+
exports: exports$1,
|
|
32145
|
+
headers: exportsHeaders
|
|
32146
|
+
} = await resolveExportsUploadPayload({
|
|
32132
32147
|
scriptName,
|
|
32133
32148
|
isDryRun: props.dryRun,
|
|
32134
32149
|
accountId,
|
|
@@ -32274,7 +32289,10 @@ async function uploadWorkerVersion(props, config2, buildResult, options) {
|
|
|
32274
32289
|
{
|
|
32275
32290
|
method: "POST",
|
|
32276
32291
|
body: workerBundle,
|
|
32277
|
-
headers:
|
|
32292
|
+
headers: {
|
|
32293
|
+
...exportsHeaders,
|
|
32294
|
+
...props.sendMetrics && { metricsEnabled: "true" }
|
|
32295
|
+
}
|
|
32278
32296
|
},
|
|
32279
32297
|
new URLSearchParams({ bindings_inherit: "strict" })
|
|
32280
32298
|
),
|
|
@@ -34066,10 +34084,9 @@ async function previewBuildOutput(accountId, args, buildOutput, options) {
|
|
|
34066
34084
|
}
|
|
34067
34085
|
);
|
|
34068
34086
|
}
|
|
34069
|
-
const { buildContext: _buildContext, ...settings } = rootConfig;
|
|
34070
34087
|
const { manifest: _manifest, ...worker } = workerConfig;
|
|
34071
34088
|
const convertedConfig = convertToWranglerConfig({
|
|
34072
|
-
...settings,
|
|
34089
|
+
...rootConfig.settings,
|
|
34073
34090
|
worker,
|
|
34074
34091
|
containers: []
|
|
34075
34092
|
});
|