@cloudflare/deploy-helpers 0.16.0 → 0.18.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/{chunk-QBZBEHZB.mjs → chunk-M77HNR46.mjs} +5 -1
- package/dist/{chunk-Q72B4Q5Z.mjs → chunk-U6NEESU5.mjs} +6 -3
- package/dist/{chunk-Z4LB73IF.mjs → chunk-Y4VATABS.mjs} +4 -1
- package/dist/{context-DXCcvY4T.d.mts → context-BjoLoNIB.d.mts} +3 -1
- package/dist/context.d.mts +1 -1
- package/dist/context.mjs +5 -2
- package/dist/create-worker-upload-form.mjs +5 -2
- package/dist/index.d.mts +7 -5
- package/dist/index.mjs +121 -36
- package/dist/metafile-esm.json +1 -1
- package/dist/startup-profile.mjs +4 -2
- package/package.json +6 -6
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { __name } from './chunk-U6NEESU5.mjs';
|
|
2
3
|
import assert from 'node:assert';
|
|
3
4
|
import { readFileSync } from 'node:fs';
|
|
4
5
|
import path, { resolve } from 'node:path';
|
|
@@ -7,6 +8,7 @@ import { FormData } from 'undici';
|
|
|
7
8
|
import { spawnSync } from 'node:child_process';
|
|
8
9
|
import { sync } from 'command-exists';
|
|
9
10
|
|
|
11
|
+
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
10
12
|
function handleUnsafeCapnp(capnp) {
|
|
11
13
|
if (capnp.compiled_schema) {
|
|
12
14
|
return readFileSync(resolve(capnp.compiled_schema));
|
|
@@ -74,6 +76,7 @@ function createWorkerUploadForm(worker, bindings, options) {
|
|
|
74
76
|
main,
|
|
75
77
|
sourceMaps,
|
|
76
78
|
migrations,
|
|
79
|
+
code_update_strategy,
|
|
77
80
|
exports: configuredExports,
|
|
78
81
|
compatibility_date,
|
|
79
82
|
compatibility_flags,
|
|
@@ -756,6 +759,7 @@ function createWorkerUploadForm(worker, bindings, options) {
|
|
|
756
759
|
compatibility_flags
|
|
757
760
|
},
|
|
758
761
|
...migrations && { migrations },
|
|
762
|
+
...code_update_strategy && { code_update_strategy },
|
|
759
763
|
...configuredExports && Object.keys(configuredExports).length > 0 && {
|
|
760
764
|
exports: configuredExports
|
|
761
765
|
},
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
|
|
3
|
+
const require$1 = createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
1
4
|
var __create = Object.create;
|
|
2
5
|
var __defProp = Object.defineProperty;
|
|
3
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -5,10 +8,10 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
5
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
10
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
11
|
+
var __require = /* @__PURE__ */ ((x) => typeof require$1 !== "undefined" ? require$1 : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
12
|
+
get: (a, b) => (typeof require$1 !== "undefined" ? require$1 : a)[b]
|
|
10
13
|
}) : x)(function(x) {
|
|
11
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
14
|
+
if (typeof require$1 !== "undefined") return require$1.apply(this, arguments);
|
|
12
15
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
16
|
});
|
|
14
17
|
var __commonJS = (cb, mod) => function __require2() {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { __name } from './chunk-U6NEESU5.mjs';
|
|
3
|
+
|
|
4
|
+
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
2
5
|
|
|
3
6
|
// src/shared/context.ts
|
|
4
7
|
var logger;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BuiltImage, ContainerNormalizedConfig, BuiltContainerImage } from '@cloudflare/containers-shared';
|
|
2
|
-
import { ContainerApp, Config, FetchResultFetcher, FetchListResultFetcher, FetchPagedListResultFetcher, FetchKVGetValueFetcher, Logger, Entry, ValidatedAssetsOptions, LegacyAssetPaths, Route, CfModule, CfWorkerSourceMap, CfModuleType } from '@cloudflare/workers-utils';
|
|
2
|
+
import { ContainerApp, Config, FetchResultFetcher, FetchListResultFetcher, FetchPagedListResultFetcher, FetchKVGetValueFetcher, Logger, Entry, ValidatedAssetsOptions, LegacyAssetPaths, Route, DurableObjectCodeUpdateStrategy, CfModule, CfWorkerSourceMap, CfModuleType } from '@cloudflare/workers-utils';
|
|
3
3
|
|
|
4
4
|
/** API, logging, and prompt implementations supplied by the consumer. */
|
|
5
5
|
type DeployHelpersContext = {
|
|
@@ -126,6 +126,8 @@ type DeployProps = SharedDeployVersionsProps & {
|
|
|
126
126
|
oldAssetTtl: number | undefined;
|
|
127
127
|
/** From --containers-rollout arg. Deploy-only. */
|
|
128
128
|
containersRollout: "immediate" | "gradual" | "none" | undefined;
|
|
129
|
+
/** Controls how Durable Object code updates are applied. */
|
|
130
|
+
durableObjectsCodeUpdateStrategy?: DurableObjectCodeUpdateStrategy;
|
|
129
131
|
/**
|
|
130
132
|
* When true, an existing Worker with the same name aborts the deploy instead
|
|
131
133
|
* of updating it, because this run cannot confirm the local project owns the
|
package/dist/context.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { d as confirm, f as fetchKVGetValue, e as fetchListResult, g as fetchPagedListResult, h as fetchResult, i as initDeployHelpersContext, l as logger, p as prompt, s as select } from './context-
|
|
1
|
+
export { d as confirm, f as fetchKVGetValue, e as fetchListResult, g as fetchPagedListResult, h as fetchResult, i as initDeployHelpersContext, l as logger, p as prompt, s as select } from './context-BjoLoNIB.mjs';
|
|
2
2
|
import '@cloudflare/workers-utils';
|
|
3
3
|
import '@cloudflare/containers-shared';
|
package/dist/context.mjs
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
export { confirm, fetchKVGetValue, fetchListResult, fetchPagedListResult, fetchResult, initDeployHelpersContext, logger, prompt, select } from './chunk-Y4VATABS.mjs';
|
|
3
|
+
import './chunk-U6NEESU5.mjs';
|
|
4
|
+
|
|
5
|
+
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
export { createWorkerUploadForm, fromMimeType, moduleTypeMimeType } from './chunk-M77HNR46.mjs';
|
|
3
|
+
import './chunk-U6NEESU5.mjs';
|
|
4
|
+
|
|
5
|
+
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SharedDeployVersionsProps, D as DeployProps, C as ContainerlessConfig, W as WorkerBuildResult, V as VersionsUploadProps, T as TriggerProps, a as TriggerDeployment, B as BuiltDurableObjectContainerImage } from './context-
|
|
2
|
-
export { b as ContainerDeployConfig, c as DeployHelpersContext, i as initDeployHelpersContext } from './context-
|
|
1
|
+
import { S as SharedDeployVersionsProps, D as DeployProps, C as ContainerlessConfig, W as WorkerBuildResult, V as VersionsUploadProps, T as TriggerProps, a as TriggerDeployment, B as BuiltDurableObjectContainerImage } from './context-BjoLoNIB.mjs';
|
|
2
|
+
export { b as ContainerDeployConfig, c as DeployHelpersContext, i as initDeployHelpersContext } from './context-BjoLoNIB.mjs';
|
|
3
3
|
import * as _cloudflare_workers_utils from '@cloudflare/workers-utils';
|
|
4
4
|
import { CfModule, Config, AssetsOptions, ComplianceConfig, LegacyAssetPaths, Route, ZoneIdRoute, ZoneNameRoute, CustomDomainRoute, CfPlacement, Binding as Binding$1, RawConfig, CfCapnp, CfScriptFormat, ParseError, WorkerMetadataBinding, CfUserLimits, CfWorkerInit, TailConsumer, StreamingTailConsumer, Observability, ResolvedDurableObjectContainerApp, DurableObjectContainerApp, ExportsReconciliationErrorDetail, ExportsReconciliationResult, StartDevWorkerInput, Json, CacheOptions, PreviewsConfig } from '@cloudflare/workers-utils';
|
|
5
5
|
import { FormData } from 'undici';
|
|
@@ -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 'miniflare';
|
|
10
|
-
import { ParsedOutputWorkerConfig, ParsedOutputRootConfig } from '@cloudflare/config';
|
|
10
|
+
import { ParsedOutputWorkerConfig, ParsedOutputRootConfig, ParsedOutputContainerConfig } from '@cloudflare/config';
|
|
11
11
|
import { ContainerNormalizedConfig } from '@cloudflare/containers-shared';
|
|
12
12
|
|
|
13
13
|
interface BundleSize {
|
|
@@ -584,7 +584,7 @@ declare function fetchLatestDeployments(complianceConfig: ComplianceConfig, acco
|
|
|
584
584
|
declare function fetchLatestDeployment(complianceConfig: ComplianceConfig, accountId: string, workerName: string): Promise<ApiDeployment | undefined>;
|
|
585
585
|
declare function fetchDeploymentVersions(complianceConfig: ComplianceConfig, accountId: string, workerName: string, deployment: ApiDeployment | undefined, versionCache: VersionCache): Promise<[ApiVersion[], Map<VersionId, Percentage>]>;
|
|
586
586
|
declare function fetchDeployableVersions(complianceConfig: ComplianceConfig, accountId: string, workerName: string, versionCache: VersionCache): Promise<ApiVersion[]>;
|
|
587
|
-
declare function createDeployment(complianceConfig: ComplianceConfig, accountId: string, workerName: string, versionTraffic: Map<VersionId, Percentage>, message: string | undefined, force: boolean | undefined): Promise<{
|
|
587
|
+
declare function createDeployment(complianceConfig: ComplianceConfig, accountId: string, workerName: string, versionTraffic: Map<VersionId, Percentage>, message: string | undefined, force: boolean | undefined, codeUpdateStrategy?: unknown): Promise<{
|
|
588
588
|
id: string;
|
|
589
589
|
}>;
|
|
590
590
|
type NonVersionedScriptSettings = {
|
|
@@ -1197,6 +1197,7 @@ type PreviewBuildOutput = {
|
|
|
1197
1197
|
rootConfig: PreviewBuildOutputRootConfig;
|
|
1198
1198
|
buildResult?: WorkerBuildResult;
|
|
1199
1199
|
assets?: Pick<PreviewAssetsOptions, "directory" | "_headers" | "_redirects">;
|
|
1200
|
+
containers?: ParsedOutputContainerConfig[];
|
|
1200
1201
|
};
|
|
1201
1202
|
/** Verify that Build Output was produced with Preview configuration. */
|
|
1202
1203
|
declare function assertPreviewBuildOutputRootConfig(rootConfig: ParsedOutputRootConfig | undefined): asserts rootConfig is PreviewBuildOutputRootConfig;
|
|
@@ -1210,6 +1211,7 @@ type PreviewCallbacks = {
|
|
|
1210
1211
|
}) => Promise<ContainerNormalizedConfig[]>) | undefined;
|
|
1211
1212
|
deployPreviewContainers: ((scopedConfig: Config, normalisedContainerConfig: ContainerNormalizedConfig[], deployment: DeploymentResource, accountId: string, options: {
|
|
1212
1213
|
quiet: boolean;
|
|
1214
|
+
localImageReferences?: Map<string, string>;
|
|
1213
1215
|
}) => Promise<void>) | undefined;
|
|
1214
1216
|
verifyContainersScope?: (scopedConfig: Config) => Promise<void>;
|
|
1215
1217
|
};
|
|
@@ -1236,7 +1238,7 @@ declare function preview(accountId: string, args: PreviewArgs, config: Config, b
|
|
|
1236
1238
|
* @param args Preview name and deployment annotations.
|
|
1237
1239
|
* @param buildOutput Exact configuration and artifacts emitted by the build.
|
|
1238
1240
|
*/
|
|
1239
|
-
declare function previewBuildOutput(accountId: string, args: Pick<PreviewArgs, "name" | "tag" | "message" | "json">, buildOutput: PreviewBuildOutput): Promise<PreviewResult>;
|
|
1241
|
+
declare function previewBuildOutput(accountId: string, args: Pick<PreviewArgs, "name" | "tag" | "message" | "json">, buildOutput: PreviewBuildOutput, callbacks?: PreviewCallbacks): Promise<PreviewResult>;
|
|
1240
1242
|
/**
|
|
1241
1243
|
* Delete a preview and all its deployments.
|
|
1242
1244
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { fetchResult, fetchPagedListResult, logger, confirm, fetchListResult, prompt, select } from './chunk-Y4VATABS.mjs';
|
|
3
|
+
export { initDeployHelpersContext } from './chunk-Y4VATABS.mjs';
|
|
4
|
+
import { createWorkerUploadForm, moduleTypeMimeType } from './chunk-M77HNR46.mjs';
|
|
5
|
+
export { createWorkerUploadForm, fromMimeType, handleUnsafeCapnp, moduleTypeMimeType } from './chunk-M77HNR46.mjs';
|
|
6
|
+
import { __commonJS, __name, __require, __toESM, __export } from './chunk-U6NEESU5.mjs';
|
|
6
7
|
import assert6 from 'node:assert';
|
|
7
8
|
import { readFileSync, mkdirSync, writeFileSync, createReadStream } from 'node:fs';
|
|
8
9
|
import * as path from 'node:path';
|
|
@@ -11,7 +12,7 @@ import url2, { URLSearchParams as URLSearchParams$1 } from 'node:url';
|
|
|
11
12
|
import * as cli from '@cloudflare/cli-shared-helpers';
|
|
12
13
|
import { updateStatus, cancel } from '@cloudflare/cli-shared-helpers';
|
|
13
14
|
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, 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, getBindingTypeFriendlyName, defaultWranglerConfig } from '@cloudflare/workers-utils';
|
|
15
|
+
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
16
|
import { Response, FormData } from 'undici';
|
|
16
17
|
import chalk6 from 'chalk';
|
|
17
18
|
import PQueue from 'p-queue';
|
|
@@ -31,6 +32,8 @@ import { execSync } from 'node:child_process';
|
|
|
31
32
|
import { createHash } from 'node:crypto';
|
|
32
33
|
import { convertToWranglerConfig } from '@cloudflare/config';
|
|
33
34
|
|
|
35
|
+
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
36
|
+
|
|
34
37
|
// ../../node_modules/.pnpm/ignore@5.3.1/node_modules/ignore/index.js
|
|
35
38
|
var require_ignore = __commonJS({
|
|
36
39
|
"../../node_modules/.pnpm/ignore@5.3.1/node_modules/ignore/index.js"(exports$1, module) {
|
|
@@ -6524,7 +6527,7 @@ async function fetchDeployableVersions(complianceConfig, accountId, workerName,
|
|
|
6524
6527
|
return versions;
|
|
6525
6528
|
}
|
|
6526
6529
|
__name(fetchDeployableVersions, "fetchDeployableVersions");
|
|
6527
|
-
async function createDeployment(complianceConfig, accountId, workerName, versionTraffic, message, force) {
|
|
6530
|
+
async function createDeployment(complianceConfig, accountId, workerName, versionTraffic, message, force, codeUpdateStrategy) {
|
|
6528
6531
|
return await fetchResult(
|
|
6529
6532
|
complianceConfig,
|
|
6530
6533
|
`/accounts/${accountId}/workers/scripts/${workerName}/deployments${force ? "?force=true" : ""}`,
|
|
@@ -6538,7 +6541,8 @@ async function createDeployment(complianceConfig, accountId, workerName, version
|
|
|
6538
6541
|
),
|
|
6539
6542
|
annotations: {
|
|
6540
6543
|
"workers/message": message
|
|
6541
|
-
}
|
|
6544
|
+
},
|
|
6545
|
+
code_update_strategy: codeUpdateStrategy
|
|
6542
6546
|
})
|
|
6543
6547
|
}
|
|
6544
6548
|
);
|
|
@@ -25647,6 +25651,9 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
25647
25651
|
printBundleSize(bundleSize);
|
|
25648
25652
|
const canUseNewVersionsDeploymentsApi = workerExists && props.dispatchNamespace === void 0 && format === "modules" && migrations === void 0 && !hasDurableObjectExports(config2.exports) && !config2.first_party_worker && props.containers.source === void 0 && // Rollout skip can recover Container metadata absent from local config.
|
|
25649
25653
|
containerMetadata === void 0;
|
|
25654
|
+
if (!canUseNewVersionsDeploymentsApi) {
|
|
25655
|
+
worker.code_update_strategy = props.durableObjectsCodeUpdateStrategy;
|
|
25656
|
+
}
|
|
25650
25657
|
let workerBundle;
|
|
25651
25658
|
const dockerPath = getDockerPath();
|
|
25652
25659
|
if (isDryRun) {
|
|
@@ -25719,13 +25726,16 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
25719
25726
|
);
|
|
25720
25727
|
const versionMap = /* @__PURE__ */ new Map();
|
|
25721
25728
|
versionMap.set(versionResult.id, 100);
|
|
25729
|
+
const unsafeMetadata = config2.unsafe?.metadata;
|
|
25730
|
+
const codeUpdateStrategy = unsafeMetadata !== void 0 && "code_update_strategy" in unsafeMetadata ? unsafeMetadata.code_update_strategy : props.durableObjectsCodeUpdateStrategy;
|
|
25722
25731
|
await createDeployment(
|
|
25723
25732
|
config2,
|
|
25724
25733
|
accountId,
|
|
25725
25734
|
scriptName,
|
|
25726
25735
|
versionMap,
|
|
25727
25736
|
props.message,
|
|
25728
|
-
void 0
|
|
25737
|
+
void 0,
|
|
25738
|
+
codeUpdateStrategy
|
|
25729
25739
|
);
|
|
25730
25740
|
const nextTags = applyServiceAndEnvironmentTags(config2, tags);
|
|
25731
25741
|
try {
|
|
@@ -25925,12 +25935,16 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
25925
25935
|
});
|
|
25926
25936
|
}
|
|
25927
25937
|
}
|
|
25928
|
-
await deployContainers(
|
|
25929
|
-
|
|
25930
|
-
|
|
25931
|
-
|
|
25932
|
-
|
|
25933
|
-
|
|
25938
|
+
await deployContainers(
|
|
25939
|
+
{ ...config2, containers: props.containers.source },
|
|
25940
|
+
containerDeployments,
|
|
25941
|
+
{
|
|
25942
|
+
versionId,
|
|
25943
|
+
accountId,
|
|
25944
|
+
scriptName,
|
|
25945
|
+
dispatchNamespace: props.dispatchNamespace
|
|
25946
|
+
}
|
|
25947
|
+
);
|
|
25934
25948
|
}
|
|
25935
25949
|
if (!skipContainerChanges && durableObjectContainerConfig.length > 0) {
|
|
25936
25950
|
assert6(versionId && accountId);
|
|
@@ -27069,7 +27083,7 @@ function getDeclaredDOClassNames(config2) {
|
|
|
27069
27083
|
for (const [className, entry] of Object.entries(
|
|
27070
27084
|
getDurableObjectExports(config2.exports)
|
|
27071
27085
|
)) {
|
|
27072
|
-
if (entry
|
|
27086
|
+
if (isLiveDurableObjectExport(entry)) {
|
|
27073
27087
|
declared.add(className);
|
|
27074
27088
|
}
|
|
27075
27089
|
}
|
|
@@ -27126,6 +27140,68 @@ function assertPreviewBuildOutputRootConfig(rootConfig) {
|
|
|
27126
27140
|
}
|
|
27127
27141
|
}
|
|
27128
27142
|
__name(assertPreviewBuildOutputRootConfig, "assertPreviewBuildOutputRootConfig");
|
|
27143
|
+
function convertBuildOutputContainerToInput(container) {
|
|
27144
|
+
if ("image" in container) {
|
|
27145
|
+
const { image, ...config2 } = container;
|
|
27146
|
+
return {
|
|
27147
|
+
...config2,
|
|
27148
|
+
image: {
|
|
27149
|
+
reference: "reference" in image ? image.reference : image.localReference
|
|
27150
|
+
}
|
|
27151
|
+
};
|
|
27152
|
+
}
|
|
27153
|
+
throw new UserError(
|
|
27154
|
+
"Preview uploads from Build Output don't support Durable Object-managed Containers.",
|
|
27155
|
+
{
|
|
27156
|
+
telemetryMessage: "preview build output durable object container not supported"
|
|
27157
|
+
}
|
|
27158
|
+
);
|
|
27159
|
+
}
|
|
27160
|
+
__name(convertBuildOutputContainerToInput, "convertBuildOutputContainerToInput");
|
|
27161
|
+
function getLocalContainerImageReferences(containers, previewContainers) {
|
|
27162
|
+
const localReferences = /* @__PURE__ */ new Map();
|
|
27163
|
+
for (const container of containers ?? []) {
|
|
27164
|
+
if ("image" in container && "localReference" in container.image) {
|
|
27165
|
+
localReferences.set(container.name, container.image.localReference);
|
|
27166
|
+
}
|
|
27167
|
+
}
|
|
27168
|
+
return new Map(
|
|
27169
|
+
previewContainers.flatMap((container) => {
|
|
27170
|
+
const localReference = container.name === void 0 ? void 0 : localReferences.get(container.name);
|
|
27171
|
+
return localReference === void 0 || container.class_name === void 0 ? [] : [[container.class_name, localReference]];
|
|
27172
|
+
})
|
|
27173
|
+
);
|
|
27174
|
+
}
|
|
27175
|
+
__name(getLocalContainerImageReferences, "getLocalContainerImageReferences");
|
|
27176
|
+
function convertBuildOutputContainers(containers, exports$1) {
|
|
27177
|
+
const containerClassNames = /* @__PURE__ */ new Map();
|
|
27178
|
+
for (const [className, configExport] of Object.entries(
|
|
27179
|
+
getDurableObjectExports(exports$1)
|
|
27180
|
+
)) {
|
|
27181
|
+
if (isLiveDurableObjectExport(configExport) && configExport.container !== void 0) {
|
|
27182
|
+
containerClassNames.set(configExport.container, className);
|
|
27183
|
+
}
|
|
27184
|
+
}
|
|
27185
|
+
const containerNames = new Set(containers?.map(({ name }) => name));
|
|
27186
|
+
for (const [containerName, className] of containerClassNames) {
|
|
27187
|
+
if (!containerNames.has(containerName)) {
|
|
27188
|
+
throw new UserError(
|
|
27189
|
+
`The Durable Object class "${className}" references the Container "${containerName}", but that Container was not included in the Build Output.`,
|
|
27190
|
+
{
|
|
27191
|
+
telemetryMessage: "preview build output container missing"
|
|
27192
|
+
}
|
|
27193
|
+
);
|
|
27194
|
+
}
|
|
27195
|
+
}
|
|
27196
|
+
const converted = convertToWranglerConfig({
|
|
27197
|
+
containers: (containers ?? []).map(convertBuildOutputContainerToInput)
|
|
27198
|
+
}).containers;
|
|
27199
|
+
return (converted ?? []).map((container) => ({
|
|
27200
|
+
...container,
|
|
27201
|
+
class_name: container.name === void 0 ? void 0 : containerClassNames.get(container.name)
|
|
27202
|
+
}));
|
|
27203
|
+
}
|
|
27204
|
+
__name(convertBuildOutputContainers, "convertBuildOutputContainers");
|
|
27129
27205
|
function buildPreviewContainerConfig(config2, parentWorkerName, previewSlug, previewContainers) {
|
|
27130
27206
|
const previews = config2.previews;
|
|
27131
27207
|
const previewDOBindings = previews?.durable_objects?.bindings ?? [];
|
|
@@ -27185,7 +27261,7 @@ function getPreviewExports(exports$1) {
|
|
|
27185
27261
|
return previewExports;
|
|
27186
27262
|
}
|
|
27187
27263
|
__name(getPreviewExports, "getPreviewExports");
|
|
27188
|
-
async function prepareContainersForPreview(config2, workerName, previewSlug, callbacks) {
|
|
27264
|
+
async function prepareContainersForPreview(config2, workerName, previewSlug, callbacks, localImageReferences) {
|
|
27189
27265
|
const previewContainers = config2.previews?.containers ?? [];
|
|
27190
27266
|
if (previewContainers.length === 0 || !callbacks.getNormalizedContainerOptions) {
|
|
27191
27267
|
return { scopedContainerConfig: void 0, normalisedContainerConfig: [] };
|
|
@@ -27205,11 +27281,11 @@ async function prepareContainersForPreview(config2, workerName, previewSlug, cal
|
|
|
27205
27281
|
const containersNeedingDocker = normalisedContainerConfig.filter(
|
|
27206
27282
|
(container) => "dockerfile" in container
|
|
27207
27283
|
);
|
|
27208
|
-
if (containersNeedingDocker.length > 0) {
|
|
27284
|
+
if (containersNeedingDocker.length > 0 || localImageReferences.size > 0) {
|
|
27209
27285
|
await verifyDockerInstalled({
|
|
27210
27286
|
dockerPath: getDockerPath(),
|
|
27211
27287
|
operation: "creating a preview",
|
|
27212
|
-
imageNoun: containersNeedingDocker.length !== 1 ? "the configured images" : "the configured image",
|
|
27288
|
+
imageNoun: containersNeedingDocker.length + localImageReferences.size !== 1 ? "the configured images" : "the configured image",
|
|
27213
27289
|
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".'
|
|
27214
27290
|
});
|
|
27215
27291
|
}
|
|
@@ -27647,7 +27723,7 @@ async function provisionParentWorker(config2, accountId, workerName, json2) {
|
|
|
27647
27723
|
);
|
|
27648
27724
|
}
|
|
27649
27725
|
__name(provisionParentWorker, "provisionParentWorker");
|
|
27650
|
-
async function runPreview(accountId, args, config2, buildResult, assetsOptions, callbacks, workerName, replaceTailConsumersAfterCreate = false) {
|
|
27726
|
+
async function runPreview(accountId, args, config2, buildResult, assetsOptions, callbacks, workerName, replaceTailConsumersAfterCreate = false, localImageReferences = /* @__PURE__ */ new Map()) {
|
|
27651
27727
|
let secrets;
|
|
27652
27728
|
if (args.secretsFile) {
|
|
27653
27729
|
secrets = (await parseBulkInputToObject(args.secretsFile))?.content;
|
|
@@ -27726,7 +27802,8 @@ async function runPreview(accountId, args, config2, buildResult, assetsOptions,
|
|
|
27726
27802
|
config2,
|
|
27727
27803
|
workerName,
|
|
27728
27804
|
previewResource.slug,
|
|
27729
|
-
callbacks
|
|
27805
|
+
callbacks,
|
|
27806
|
+
localImageReferences
|
|
27730
27807
|
);
|
|
27731
27808
|
const deploymentRequest = await assemblePreviewDeploymentSettings(
|
|
27732
27809
|
config2,
|
|
@@ -27764,7 +27841,7 @@ async function runPreview(accountId, args, config2, buildResult, assetsOptions,
|
|
|
27764
27841
|
normalisedContainerConfig,
|
|
27765
27842
|
deployment,
|
|
27766
27843
|
accountId,
|
|
27767
|
-
{ quiet: args.json === true }
|
|
27844
|
+
{ quiet: args.json === true, localImageReferences }
|
|
27768
27845
|
);
|
|
27769
27846
|
} catch (error51) {
|
|
27770
27847
|
logger.warn(
|
|
@@ -27821,7 +27898,7 @@ async function preview(accountId, args, config2, buildResult, assetsOptions, cal
|
|
|
27821
27898
|
);
|
|
27822
27899
|
}
|
|
27823
27900
|
__name(preview, "preview");
|
|
27824
|
-
async function previewBuildOutput(accountId, args, buildOutput) {
|
|
27901
|
+
async function previewBuildOutput(accountId, args, buildOutput, callbacks) {
|
|
27825
27902
|
const { workerConfig, rootConfig, buildResult, assets } = buildOutput;
|
|
27826
27903
|
assertPreviewBuildOutputRootConfig(rootConfig);
|
|
27827
27904
|
if (workerConfig.domains?.length) {
|
|
@@ -27848,16 +27925,6 @@ async function previewBuildOutput(accountId, args, buildOutput) {
|
|
|
27848
27925
|
}
|
|
27849
27926
|
);
|
|
27850
27927
|
}
|
|
27851
|
-
if (Object.values(workerConfig.exports ?? {}).some(
|
|
27852
|
-
(configExport) => "container" in configExport && configExport.container !== void 0
|
|
27853
|
-
)) {
|
|
27854
|
-
throw new UserError(
|
|
27855
|
-
"Preview uploads from Build Output don't support Container-backed Durable Objects.",
|
|
27856
|
-
{
|
|
27857
|
-
telemetryMessage: "preview build output containers not supported"
|
|
27858
|
-
}
|
|
27859
|
-
);
|
|
27860
|
-
}
|
|
27861
27928
|
if (workerConfig.unsafe?.capnp !== void 0 || Object.keys(workerConfig.unsafe?.metadata ?? {}).length > 0) {
|
|
27862
27929
|
throw new UserError(
|
|
27863
27930
|
"Preview uploads from Build Output don't support unsafe metadata or Cap'n Proto schemas.",
|
|
@@ -27871,9 +27938,24 @@ async function previewBuildOutput(accountId, args, buildOutput) {
|
|
|
27871
27938
|
const convertedConfig = convertToWranglerConfig({
|
|
27872
27939
|
...settings,
|
|
27873
27940
|
worker,
|
|
27874
|
-
// TODO: Add support for Containers in Preview uploads from Build Output.
|
|
27875
27941
|
containers: []
|
|
27876
27942
|
});
|
|
27943
|
+
const previewContainers = convertBuildOutputContainers(
|
|
27944
|
+
buildOutput.containers,
|
|
27945
|
+
convertedConfig.exports
|
|
27946
|
+
);
|
|
27947
|
+
const localImageReferences = getLocalContainerImageReferences(
|
|
27948
|
+
buildOutput.containers,
|
|
27949
|
+
previewContainers
|
|
27950
|
+
);
|
|
27951
|
+
if (previewContainers.length > 0 && (callbacks?.getNormalizedContainerOptions === void 0 || callbacks.deployPreviewContainers === void 0)) {
|
|
27952
|
+
throw new UserError(
|
|
27953
|
+
"Preview uploads from Build Output with Containers require container deployment callbacks.",
|
|
27954
|
+
{
|
|
27955
|
+
telemetryMessage: "preview build output container callbacks missing"
|
|
27956
|
+
}
|
|
27957
|
+
);
|
|
27958
|
+
}
|
|
27877
27959
|
const previewBuildResult = buildResult && {
|
|
27878
27960
|
...buildResult,
|
|
27879
27961
|
mainModuleName: workerConfig.manifest?.mainModule
|
|
@@ -27881,6 +27963,7 @@ async function previewBuildOutput(accountId, args, buildOutput) {
|
|
|
27881
27963
|
const bindings = extractBuildOutputBindings(convertedConfig);
|
|
27882
27964
|
const previewConfig = {
|
|
27883
27965
|
...defaultWranglerConfig,
|
|
27966
|
+
account_id: accountId,
|
|
27884
27967
|
compliance_region: convertedConfig.compliance_region,
|
|
27885
27968
|
name: workerConfig.name,
|
|
27886
27969
|
compatibility_date: convertedConfig.compatibility_date,
|
|
@@ -27894,6 +27977,7 @@ async function previewBuildOutput(accountId, args, buildOutput) {
|
|
|
27894
27977
|
workers_dev: false,
|
|
27895
27978
|
preview_urls: true,
|
|
27896
27979
|
previews: {
|
|
27980
|
+
containers: previewContainers,
|
|
27897
27981
|
tail_consumers: convertedConfig.tail_consumers ?? (workerConfig.tailConsumers === void 0 ? void 0 : []),
|
|
27898
27982
|
unsafe: {
|
|
27899
27983
|
bindings: Object.entries(bindings).map(([name, binding]) => ({
|
|
@@ -27920,12 +28004,13 @@ async function previewBuildOutput(accountId, args, buildOutput) {
|
|
|
27920
28004
|
previewConfig,
|
|
27921
28005
|
previewBuildResult,
|
|
27922
28006
|
assetsOptions,
|
|
27923
|
-
{
|
|
28007
|
+
callbacks ?? {
|
|
27924
28008
|
getNormalizedContainerOptions: void 0,
|
|
27925
28009
|
deployPreviewContainers: void 0
|
|
27926
28010
|
},
|
|
27927
28011
|
workerConfig.name,
|
|
27928
|
-
true
|
|
28012
|
+
true,
|
|
28013
|
+
localImageReferences
|
|
27929
28014
|
);
|
|
27930
28015
|
}
|
|
27931
28016
|
__name(previewBuildOutput, "previewBuildOutput");
|