@cloudflare/deploy-helpers 0.10.3 → 0.11.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/{chunk-PXVCTRCA.mjs → chunk-3G6JZQDH.mjs} +2 -1
- package/dist/{context-nFHuelHB.d.mts → context-Bo-P841x.d.mts} +6 -0
- package/dist/context.d.mts +2 -1
- package/dist/create-worker-upload-form.mjs +1 -1
- package/dist/index.d.mts +52 -62
- package/dist/index.mjs +945 -684
- package/dist/metafile-esm.json +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { fetchResult, fetchPagedListResult, logger, confirm, fetchListResult, prompt, select } from './chunk-Z4LB73IF.mjs';
|
|
2
2
|
export { initDeployHelpersContext } from './chunk-Z4LB73IF.mjs';
|
|
3
|
-
import { createWorkerUploadForm, moduleTypeMimeType } from './chunk-
|
|
4
|
-
export { createWorkerUploadForm, fromMimeType, handleUnsafeCapnp, moduleTypeMimeType } from './chunk-
|
|
3
|
+
import { createWorkerUploadForm, moduleTypeMimeType } from './chunk-3G6JZQDH.mjs';
|
|
4
|
+
export { createWorkerUploadForm, fromMimeType, handleUnsafeCapnp, moduleTypeMimeType } from './chunk-3G6JZQDH.mjs';
|
|
5
5
|
import { __commonJS, __name, __require, __toESM, __export } from './chunk-Q72B4Q5Z.mjs';
|
|
6
|
-
import
|
|
6
|
+
import assert5 from 'node:assert';
|
|
7
7
|
import { readFileSync, mkdirSync, writeFileSync, createReadStream } from 'node:fs';
|
|
8
8
|
import * as path from 'node:path';
|
|
9
9
|
import path__default, { resolve, isAbsolute, sep, extname } from 'node:path';
|
|
10
10
|
import url2, { URLSearchParams as URLSearchParams$1 } from 'node:url';
|
|
11
11
|
import * as cli from '@cloudflare/cli-shared-helpers';
|
|
12
|
-
import { cancel } from '@cloudflare/cli-shared-helpers';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import '@cloudflare/workers-utils/compliance';
|
|
16
|
-
import { INHERIT_SYMBOL, APIError, UserError, getEnvironmentVariableFactory, isNonInteractiveOrCI, getHostFromRoute, retryOnAPIFailure, ParseError, getComplianceRegionSubdomain, configFileName, formatTime, getSubdomainMixedStateCheckDisabled, LOGGER_LEVELS, SERVICE_TAG_PREFIX, ENVIRONMENT_TAG_PREFIX, getDurableObjectExports, partitionExports, 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, getBindings, hasDurableObjectExports, getDockerPath, parseNonHyphenedUuid, getWorkersCIBranchName, getCIOverrideName, getBindingTypeFriendlyName } from '@cloudflare/workers-utils';
|
|
12
|
+
import { updateStatus, cancel } from '@cloudflare/cli-shared-helpers';
|
|
13
|
+
import { SchedulingPolicy, ApplicationsService, listDurableObjects, resolveImageName, buildAndMaybePush, 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, getDurableObjectContainerApps, CONTAINER_IMAGES_BINDING, isDurableObjectContainerApp, getDockerPath, validateDurableObjectContainerApplications, getDurableObjectClassNameToUseSQLiteMap, SERVICE_TAG_PREFIX, ENVIRONMENT_TAG_PREFIX, getDurableObjectExports, partitionExports, 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, getBindings, hasDurableObjectExports, parseNonHyphenedUuid, getWorkersCIBranchName, getCIOverrideName, getBindingTypeFriendlyName } from '@cloudflare/workers-utils';
|
|
17
15
|
import { Response, FormData } from 'undici';
|
|
18
16
|
import chalk6 from 'chalk';
|
|
19
17
|
import PQueue from 'p-queue';
|
|
@@ -24,9 +22,12 @@ import { hash as hash$1 } from 'blake3-wasm';
|
|
|
24
22
|
import { Blob } from 'node:buffer';
|
|
25
23
|
import { gzipSync } from 'node:zlib';
|
|
26
24
|
import { brandColor, white, gray, bold, yellow, dim, red, blue } from '@cloudflare/cli-shared-helpers/colors';
|
|
25
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
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';
|
|
29
29
|
import { getFreshSourceMapSupport, getNodeCompat } from 'miniflare';
|
|
30
|
+
import { execSync } from 'node:child_process';
|
|
30
31
|
import { createHash } from 'node:crypto';
|
|
31
32
|
|
|
32
33
|
// ../../node_modules/.pnpm/ignore@5.3.1/node_modules/ignore/index.js
|
|
@@ -256,17 +257,17 @@ var require_ignore = __commonJS({
|
|
|
256
257
|
var throwError = /* @__PURE__ */ __name((message, Ctor) => {
|
|
257
258
|
throw new Ctor(message);
|
|
258
259
|
}, "throwError");
|
|
259
|
-
var checkPath = /* @__PURE__ */ __name((
|
|
260
|
-
if (!isString(
|
|
260
|
+
var checkPath = /* @__PURE__ */ __name((path10, originalPath, doThrow) => {
|
|
261
|
+
if (!isString(path10)) {
|
|
261
262
|
return doThrow(
|
|
262
263
|
`path must be a string, but got \`${originalPath}\``,
|
|
263
264
|
TypeError
|
|
264
265
|
);
|
|
265
266
|
}
|
|
266
|
-
if (!
|
|
267
|
+
if (!path10) {
|
|
267
268
|
return doThrow(`path must not be empty`, TypeError);
|
|
268
269
|
}
|
|
269
|
-
if (checkPath.isNotRelative(
|
|
270
|
+
if (checkPath.isNotRelative(path10)) {
|
|
270
271
|
const r = "`path.relative()`d";
|
|
271
272
|
return doThrow(
|
|
272
273
|
`path should be a ${r} string, but got "${originalPath}"`,
|
|
@@ -275,7 +276,7 @@ var require_ignore = __commonJS({
|
|
|
275
276
|
}
|
|
276
277
|
return true;
|
|
277
278
|
}, "checkPath");
|
|
278
|
-
var isNotRelative = /* @__PURE__ */ __name((
|
|
279
|
+
var isNotRelative = /* @__PURE__ */ __name((path10) => REGEX_TEST_INVALID_PATH.test(path10), "isNotRelative");
|
|
279
280
|
checkPath.isNotRelative = isNotRelative;
|
|
280
281
|
checkPath.convert = (p) => p;
|
|
281
282
|
var Ignore = class {
|
|
@@ -337,7 +338,7 @@ var require_ignore = __commonJS({
|
|
|
337
338
|
// setting `checkUnignored` to `false` could reduce additional
|
|
338
339
|
// path matching.
|
|
339
340
|
// @returns {TestResult} true if a file is ignored
|
|
340
|
-
_testOne(
|
|
341
|
+
_testOne(path10, checkUnignored) {
|
|
341
342
|
let ignored = false;
|
|
342
343
|
let unignored = false;
|
|
343
344
|
this._rules.forEach((rule) => {
|
|
@@ -345,7 +346,7 @@ var require_ignore = __commonJS({
|
|
|
345
346
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
346
347
|
return;
|
|
347
348
|
}
|
|
348
|
-
const matched = rule.regex.test(
|
|
349
|
+
const matched = rule.regex.test(path10);
|
|
349
350
|
if (matched) {
|
|
350
351
|
ignored = !negative;
|
|
351
352
|
unignored = negative;
|
|
@@ -358,24 +359,24 @@ var require_ignore = __commonJS({
|
|
|
358
359
|
}
|
|
359
360
|
// @returns {TestResult}
|
|
360
361
|
_test(originalPath, cache, checkUnignored, slices) {
|
|
361
|
-
const
|
|
362
|
+
const path10 = originalPath && checkPath.convert(originalPath);
|
|
362
363
|
checkPath(
|
|
363
|
-
|
|
364
|
+
path10,
|
|
364
365
|
originalPath,
|
|
365
366
|
this._allowRelativePaths ? RETURN_FALSE : throwError
|
|
366
367
|
);
|
|
367
|
-
return this._t(
|
|
368
|
+
return this._t(path10, cache, checkUnignored, slices);
|
|
368
369
|
}
|
|
369
|
-
_t(
|
|
370
|
-
if (
|
|
371
|
-
return cache[
|
|
370
|
+
_t(path10, cache, checkUnignored, slices) {
|
|
371
|
+
if (path10 in cache) {
|
|
372
|
+
return cache[path10];
|
|
372
373
|
}
|
|
373
374
|
if (!slices) {
|
|
374
|
-
slices =
|
|
375
|
+
slices = path10.split(SLASH);
|
|
375
376
|
}
|
|
376
377
|
slices.pop();
|
|
377
378
|
if (!slices.length) {
|
|
378
|
-
return cache[
|
|
379
|
+
return cache[path10] = this._testOne(path10, checkUnignored);
|
|
379
380
|
}
|
|
380
381
|
const parent = this._t(
|
|
381
382
|
slices.join(SLASH) + SLASH,
|
|
@@ -383,24 +384,24 @@ var require_ignore = __commonJS({
|
|
|
383
384
|
checkUnignored,
|
|
384
385
|
slices
|
|
385
386
|
);
|
|
386
|
-
return cache[
|
|
387
|
+
return cache[path10] = parent.ignored ? parent : this._testOne(path10, checkUnignored);
|
|
387
388
|
}
|
|
388
|
-
ignores(
|
|
389
|
-
return this._test(
|
|
389
|
+
ignores(path10) {
|
|
390
|
+
return this._test(path10, this._ignoreCache, false).ignored;
|
|
390
391
|
}
|
|
391
392
|
createFilter() {
|
|
392
|
-
return (
|
|
393
|
+
return (path10) => !this.ignores(path10);
|
|
393
394
|
}
|
|
394
395
|
filter(paths) {
|
|
395
396
|
return makeArray(paths).filter(this.createFilter());
|
|
396
397
|
}
|
|
397
398
|
// @returns {TestResult}
|
|
398
|
-
test(
|
|
399
|
-
return this._test(
|
|
399
|
+
test(path10) {
|
|
400
|
+
return this._test(path10, this._testCache, true);
|
|
400
401
|
}
|
|
401
402
|
};
|
|
402
403
|
var factory = /* @__PURE__ */ __name((options) => new Ignore(options), "factory");
|
|
403
|
-
var isPathValid = /* @__PURE__ */ __name((
|
|
404
|
+
var isPathValid = /* @__PURE__ */ __name((path10) => checkPath(path10 && checkPath.convert(path10), path10, RETURN_FALSE), "isPathValid");
|
|
404
405
|
factory.isPathValid = isPathValid;
|
|
405
406
|
factory.default = factory;
|
|
406
407
|
module.exports = factory;
|
|
@@ -411,7 +412,7 @@ var require_ignore = __commonJS({
|
|
|
411
412
|
const makePosix = /* @__PURE__ */ __name((str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/"), "makePosix");
|
|
412
413
|
checkPath.convert = makePosix;
|
|
413
414
|
const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
414
|
-
checkPath.isNotRelative = (
|
|
415
|
+
checkPath.isNotRelative = (path10) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path10) || isNotRelative(path10);
|
|
415
416
|
}
|
|
416
417
|
}
|
|
417
418
|
});
|
|
@@ -703,10 +704,10 @@ var require_heap2 = __commonJS({
|
|
|
703
704
|
var require_difflib = __commonJS({
|
|
704
705
|
"../../node_modules/.pnpm/@ewoudenberg+difflib@0.1.0/node_modules/@ewoudenberg/difflib/lib/difflib.js"(exports$1) {
|
|
705
706
|
(function() {
|
|
706
|
-
var Differ, Heap, IS_CHARACTER_JUNK, IS_LINE_JUNK, SequenceMatcher, _any2, _arrayCmp, _calculateRatio, _countLeading, _formatRangeContext, _formatRangeUnified, _has,
|
|
707
|
+
var Differ, Heap, IS_CHARACTER_JUNK, IS_LINE_JUNK, SequenceMatcher, _any2, _arrayCmp, _calculateRatio, _countLeading, _formatRangeContext, _formatRangeUnified, _has, assert12, contextDiff, floor, getCloseMatches, max, min, ndiff, restore, unifiedDiff, indexOf = [].indexOf;
|
|
707
708
|
({ floor, max, min } = Math);
|
|
708
709
|
Heap = require_heap2();
|
|
709
|
-
|
|
710
|
+
assert12 = __require("assert");
|
|
710
711
|
_calculateRatio = /* @__PURE__ */ __name(function(matches, length) {
|
|
711
712
|
if (length) {
|
|
712
713
|
return 2 * matches / length;
|
|
@@ -1277,7 +1278,7 @@ var require_difflib = __commonJS({
|
|
|
1277
1278
|
}
|
|
1278
1279
|
_plainReplace(a, alo, ahi, b, blo, bhi) {
|
|
1279
1280
|
var first, g, l, len, len1, line, lines, m, ref, second;
|
|
1280
|
-
|
|
1281
|
+
assert12(alo < ahi && blo < bhi);
|
|
1281
1282
|
if (bhi - blo < ahi - alo) {
|
|
1282
1283
|
first = this._dump("+", b, blo, bhi);
|
|
1283
1284
|
second = this._dump("-", a, alo, ahi);
|
|
@@ -2745,296 +2746,6 @@ var require_lib = __commonJS({
|
|
|
2745
2746
|
}
|
|
2746
2747
|
});
|
|
2747
2748
|
|
|
2748
|
-
// ../containers-shared/src/client/models/ApplicationRollout.ts
|
|
2749
|
-
var ApplicationRollout;
|
|
2750
|
-
((ApplicationRollout2) => {
|
|
2751
|
-
((kind2) => {
|
|
2752
|
-
kind2["FULL_AUTO"] = "full_auto";
|
|
2753
|
-
kind2["FULL_MANUAL"] = "full_manual";
|
|
2754
|
-
kind2["DURABLE_OBJECTS_AUTO"] = "durable_objects_auto";
|
|
2755
|
-
})(ApplicationRollout2.kind || (ApplicationRollout2.kind = {}));
|
|
2756
|
-
((strategy2) => {
|
|
2757
|
-
strategy2["ROLLING"] = "rolling";
|
|
2758
|
-
})(ApplicationRollout2.strategy || (ApplicationRollout2.strategy = {}));
|
|
2759
|
-
((status2) => {
|
|
2760
|
-
status2["PENDING"] = "pending";
|
|
2761
|
-
status2["PROGRESSING"] = "progressing";
|
|
2762
|
-
status2["COMPLETED"] = "completed";
|
|
2763
|
-
status2["REVERTED"] = "reverted";
|
|
2764
|
-
status2["REPLACED"] = "replaced";
|
|
2765
|
-
})(ApplicationRollout2.status || (ApplicationRollout2.status = {}));
|
|
2766
|
-
})(ApplicationRollout || (ApplicationRollout = {}));
|
|
2767
|
-
|
|
2768
|
-
// ../containers-shared/src/client/models/BadRequestWithCodeError.ts
|
|
2769
|
-
var BadRequestWithCodeError;
|
|
2770
|
-
((BadRequestWithCodeError2) => {
|
|
2771
|
-
((error52) => {
|
|
2772
|
-
error52["VALIDATE_INPUT"] = "VALIDATE_INPUT";
|
|
2773
|
-
})(BadRequestWithCodeError2.error || (BadRequestWithCodeError2.error = {}));
|
|
2774
|
-
})(BadRequestWithCodeError || (BadRequestWithCodeError = {}));
|
|
2775
|
-
|
|
2776
|
-
// ../containers-shared/src/client/models/CreateApplicationRolloutRequest.ts
|
|
2777
|
-
var CreateApplicationRolloutRequest;
|
|
2778
|
-
((CreateApplicationRolloutRequest2) => {
|
|
2779
|
-
((strategy2) => {
|
|
2780
|
-
strategy2["ROLLING"] = "rolling";
|
|
2781
|
-
})(CreateApplicationRolloutRequest2.strategy || (CreateApplicationRolloutRequest2.strategy = {}));
|
|
2782
|
-
((step_percentage2) => {
|
|
2783
|
-
step_percentage2[step_percentage2["_5"] = 5] = "_5";
|
|
2784
|
-
step_percentage2[step_percentage2["_10"] = 10] = "_10";
|
|
2785
|
-
step_percentage2[step_percentage2["_20"] = 20] = "_20";
|
|
2786
|
-
step_percentage2[step_percentage2["_25"] = 25] = "_25";
|
|
2787
|
-
step_percentage2[step_percentage2["_50"] = 50] = "_50";
|
|
2788
|
-
step_percentage2[step_percentage2["_100"] = 100] = "_100";
|
|
2789
|
-
})(CreateApplicationRolloutRequest2.step_percentage || (CreateApplicationRolloutRequest2.step_percentage = {}));
|
|
2790
|
-
((kind2) => {
|
|
2791
|
-
kind2["FULL_AUTO"] = "full_auto";
|
|
2792
|
-
kind2["FULL_MANUAL"] = "full_manual";
|
|
2793
|
-
})(CreateApplicationRolloutRequest2.kind || (CreateApplicationRolloutRequest2.kind = {}));
|
|
2794
|
-
})(CreateApplicationRolloutRequest || (CreateApplicationRolloutRequest = {}));
|
|
2795
|
-
|
|
2796
|
-
// ../containers-shared/src/client/models/DeploymentNotFoundError.ts
|
|
2797
|
-
var DeploymentNotFoundError;
|
|
2798
|
-
((DeploymentNotFoundError2) => {
|
|
2799
|
-
((error52) => {
|
|
2800
|
-
error52["DEPLOYMENT_NOT_FOUND"] = "DEPLOYMENT_NOT_FOUND";
|
|
2801
|
-
})(DeploymentNotFoundError2.error || (DeploymentNotFoundError2.error = {}));
|
|
2802
|
-
})(DeploymentNotFoundError || (DeploymentNotFoundError = {}));
|
|
2803
|
-
|
|
2804
|
-
// ../containers-shared/src/client/models/ImageRegistryAlreadyExistsError.ts
|
|
2805
|
-
var ImageRegistryAlreadyExistsError;
|
|
2806
|
-
((ImageRegistryAlreadyExistsError2) => {
|
|
2807
|
-
((error52) => {
|
|
2808
|
-
error52["IMAGE_REGISTRY_ALREADY_EXISTS"] = "IMAGE_REGISTRY_ALREADY_EXISTS";
|
|
2809
|
-
})(ImageRegistryAlreadyExistsError2.error || (ImageRegistryAlreadyExistsError2.error = {}));
|
|
2810
|
-
})(ImageRegistryAlreadyExistsError || (ImageRegistryAlreadyExistsError = {}));
|
|
2811
|
-
|
|
2812
|
-
// ../containers-shared/src/client/models/ImageRegistryIsPublic.ts
|
|
2813
|
-
var ImageRegistryIsPublic;
|
|
2814
|
-
((ImageRegistryIsPublic2) => {
|
|
2815
|
-
((error52) => {
|
|
2816
|
-
error52["IMAGE_REGISTRY_IS_PUBLIC"] = "IMAGE_REGISTRY_IS_PUBLIC";
|
|
2817
|
-
})(ImageRegistryIsPublic2.error || (ImageRegistryIsPublic2.error = {}));
|
|
2818
|
-
})(ImageRegistryIsPublic || (ImageRegistryIsPublic = {}));
|
|
2819
|
-
|
|
2820
|
-
// ../containers-shared/src/client/models/ImageRegistryNotAllowedError.ts
|
|
2821
|
-
var ImageRegistryNotAllowedError;
|
|
2822
|
-
((ImageRegistryNotAllowedError2) => {
|
|
2823
|
-
((error52) => {
|
|
2824
|
-
error52["IMAGE_REGISTRY_NOT_ALLOWED"] = "IMAGE_REGISTRY_NOT_ALLOWED";
|
|
2825
|
-
})(ImageRegistryNotAllowedError2.error || (ImageRegistryNotAllowedError2.error = {}));
|
|
2826
|
-
})(ImageRegistryNotAllowedError || (ImageRegistryNotAllowedError = {}));
|
|
2827
|
-
|
|
2828
|
-
// ../containers-shared/src/client/models/ImageRegistryNotFoundError.ts
|
|
2829
|
-
var ImageRegistryNotFoundError;
|
|
2830
|
-
((ImageRegistryNotFoundError2) => {
|
|
2831
|
-
((error52) => {
|
|
2832
|
-
error52["IMAGE_REGISTRY_NOT_FOUND"] = "IMAGE_REGISTRY_NOT_FOUND";
|
|
2833
|
-
})(ImageRegistryNotFoundError2.error || (ImageRegistryNotFoundError2.error = {}));
|
|
2834
|
-
})(ImageRegistryNotFoundError || (ImageRegistryNotFoundError = {}));
|
|
2835
|
-
|
|
2836
|
-
// ../containers-shared/src/client/models/ImageRegistryProtocolAlreadyExists.ts
|
|
2837
|
-
var ImageRegistryProtocolAlreadyExists;
|
|
2838
|
-
((ImageRegistryProtocolAlreadyExists2) => {
|
|
2839
|
-
((error52) => {
|
|
2840
|
-
error52["IMAGE_REGISTRY_PROTOCOL_ALREADY_EXISTS"] = "IMAGE_REGISTRY_PROTOCOL_ALREADY_EXISTS";
|
|
2841
|
-
})(ImageRegistryProtocolAlreadyExists2.error || (ImageRegistryProtocolAlreadyExists2.error = {}));
|
|
2842
|
-
})(ImageRegistryProtocolAlreadyExists || (ImageRegistryProtocolAlreadyExists = {}));
|
|
2843
|
-
|
|
2844
|
-
// ../containers-shared/src/client/models/ImageRegistryProtocolIsReferencedError.ts
|
|
2845
|
-
var ImageRegistryProtocolIsReferencedError;
|
|
2846
|
-
((ImageRegistryProtocolIsReferencedError2) => {
|
|
2847
|
-
((error52) => {
|
|
2848
|
-
error52["IMAGE_REGISTRY_PROTO_IS_REFERENCED"] = "IMAGE_REGISTRY_PROTO_IS_REFERENCED";
|
|
2849
|
-
})(ImageRegistryProtocolIsReferencedError2.error || (ImageRegistryProtocolIsReferencedError2.error = {}));
|
|
2850
|
-
})(ImageRegistryProtocolIsReferencedError || (ImageRegistryProtocolIsReferencedError = {}));
|
|
2851
|
-
|
|
2852
|
-
// ../containers-shared/src/client/models/ImageRegistryProtocolNotFound.ts
|
|
2853
|
-
var ImageRegistryProtocolNotFound;
|
|
2854
|
-
((ImageRegistryProtocolNotFound2) => {
|
|
2855
|
-
((error52) => {
|
|
2856
|
-
error52["IMAGE_REGISTRY_PROTOCOL_NOT_FOUND"] = "IMAGE_REGISTRY_PROTOCOL_NOT_FOUND";
|
|
2857
|
-
})(ImageRegistryProtocolNotFound2.error || (ImageRegistryProtocolNotFound2.error = {}));
|
|
2858
|
-
})(ImageRegistryProtocolNotFound || (ImageRegistryProtocolNotFound = {}));
|
|
2859
|
-
|
|
2860
|
-
// ../containers-shared/src/client/models/ProvisionerConfiguration.ts
|
|
2861
|
-
var ProvisionerConfiguration;
|
|
2862
|
-
((ProvisionerConfiguration2) => {
|
|
2863
|
-
((type2) => {
|
|
2864
|
-
type2["NONE"] = "none";
|
|
2865
|
-
type2["CLOUDINIT"] = "cloudinit";
|
|
2866
|
-
})(ProvisionerConfiguration2.type || (ProvisionerConfiguration2.type = {}));
|
|
2867
|
-
})(ProvisionerConfiguration || (ProvisionerConfiguration = {}));
|
|
2868
|
-
|
|
2869
|
-
// ../containers-shared/src/client/models/RolloutStep.ts
|
|
2870
|
-
var RolloutStep;
|
|
2871
|
-
((RolloutStep2) => {
|
|
2872
|
-
((status2) => {
|
|
2873
|
-
status2["PENDING"] = "pending";
|
|
2874
|
-
status2["PROGRESSING"] = "progressing";
|
|
2875
|
-
status2["REVERTING"] = "reverting";
|
|
2876
|
-
status2["COMPLETED"] = "completed";
|
|
2877
|
-
status2["REVERTED"] = "reverted";
|
|
2878
|
-
})(RolloutStep2.status || (RolloutStep2.status = {}));
|
|
2879
|
-
})(RolloutStep || (RolloutStep = {}));
|
|
2880
|
-
|
|
2881
|
-
// ../containers-shared/src/client/models/SecretNameAlreadyExists.ts
|
|
2882
|
-
var SecretNameAlreadyExists;
|
|
2883
|
-
((SecretNameAlreadyExists2) => {
|
|
2884
|
-
((error52) => {
|
|
2885
|
-
error52["SECRET_NAME_ALREADY_EXISTS"] = "SECRET_NAME_ALREADY_EXISTS";
|
|
2886
|
-
})(SecretNameAlreadyExists2.error || (SecretNameAlreadyExists2.error = {}));
|
|
2887
|
-
})(SecretNameAlreadyExists || (SecretNameAlreadyExists = {}));
|
|
2888
|
-
|
|
2889
|
-
// ../containers-shared/src/client/models/SecretNotFound.ts
|
|
2890
|
-
var SecretNotFound;
|
|
2891
|
-
((SecretNotFound2) => {
|
|
2892
|
-
((error52) => {
|
|
2893
|
-
error52["SECRET_NAME_NOT_FOUND"] = "SECRET_NAME_NOT_FOUND";
|
|
2894
|
-
})(SecretNotFound2.error || (SecretNotFound2.error = {}));
|
|
2895
|
-
})(SecretNotFound || (SecretNotFound = {}));
|
|
2896
|
-
|
|
2897
|
-
// ../containers-shared/src/client/models/SSHPublicKeyNotFoundError.ts
|
|
2898
|
-
var SSHPublicKeyNotFoundError;
|
|
2899
|
-
((SSHPublicKeyNotFoundError2) => {
|
|
2900
|
-
((error52) => {
|
|
2901
|
-
error52["SSH_PUBLIC_KEY_NOT_FOUND"] = "SSH_PUBLIC_KEY_NOT_FOUND";
|
|
2902
|
-
})(SSHPublicKeyNotFoundError2.error || (SSHPublicKeyNotFoundError2.error = {}));
|
|
2903
|
-
})(SSHPublicKeyNotFoundError || (SSHPublicKeyNotFoundError = {}));
|
|
2904
|
-
|
|
2905
|
-
// ../containers-shared/src/client/models/UpdateApplicationRolloutRequest.ts
|
|
2906
|
-
var UpdateApplicationRolloutRequest;
|
|
2907
|
-
((UpdateApplicationRolloutRequest2) => {
|
|
2908
|
-
((action2) => {
|
|
2909
|
-
action2["NEXT"] = "next";
|
|
2910
|
-
action2["PREVIOUS"] = "previous";
|
|
2911
|
-
action2["REVERT"] = "revert";
|
|
2912
|
-
})(UpdateApplicationRolloutRequest2.action || (UpdateApplicationRolloutRequest2.action = {}));
|
|
2913
|
-
})(UpdateApplicationRolloutRequest || (UpdateApplicationRolloutRequest = {}));
|
|
2914
|
-
|
|
2915
|
-
// ../containers-shared/src/utils.ts
|
|
2916
|
-
var runDockerCmd = /* @__PURE__ */ __name((dockerPath, args, stdio) => {
|
|
2917
|
-
let aborted2 = false;
|
|
2918
|
-
let resolve2;
|
|
2919
|
-
let reject;
|
|
2920
|
-
const ready = new Promise((res, rej) => {
|
|
2921
|
-
resolve2 = res;
|
|
2922
|
-
reject = rej;
|
|
2923
|
-
});
|
|
2924
|
-
const child = spawn(dockerPath, args, {
|
|
2925
|
-
stdio: stdio ?? "inherit",
|
|
2926
|
-
// We need to set detached to true so that the child process
|
|
2927
|
-
// will control all of its child processes and we can kill
|
|
2928
|
-
// all of them in case we need to abort the build process.
|
|
2929
|
-
// On Windows, detached: true opens a new console window per child
|
|
2930
|
-
// process, so we only set it on non-Windows platforms.
|
|
2931
|
-
detached: process.platform !== "win32",
|
|
2932
|
-
// Prevent child processes from opening visible console windows on Windows.
|
|
2933
|
-
// This is a no-op on non-Windows platforms.
|
|
2934
|
-
windowsHide: true
|
|
2935
|
-
});
|
|
2936
|
-
let errorHandled = false;
|
|
2937
|
-
child.on("close", (code) => {
|
|
2938
|
-
if (code === 0 || aborted2) {
|
|
2939
|
-
resolve2({ aborted: aborted2 });
|
|
2940
|
-
} else if (!errorHandled) {
|
|
2941
|
-
errorHandled = true;
|
|
2942
|
-
reject(
|
|
2943
|
-
new UserError$1(`Docker command exited with code: ${code}`, {
|
|
2944
|
-
telemetryMessage: false
|
|
2945
|
-
})
|
|
2946
|
-
);
|
|
2947
|
-
}
|
|
2948
|
-
});
|
|
2949
|
-
child.on("error", (err) => {
|
|
2950
|
-
if (!errorHandled) {
|
|
2951
|
-
errorHandled = true;
|
|
2952
|
-
reject(
|
|
2953
|
-
new UserError$1(`Docker command failed: ${err.message}`, {
|
|
2954
|
-
telemetryMessage: false
|
|
2955
|
-
})
|
|
2956
|
-
);
|
|
2957
|
-
}
|
|
2958
|
-
});
|
|
2959
|
-
return {
|
|
2960
|
-
abort: /* @__PURE__ */ __name(() => {
|
|
2961
|
-
aborted2 = true;
|
|
2962
|
-
child.unref();
|
|
2963
|
-
if (child.pid !== void 0) {
|
|
2964
|
-
if (process.platform === "win32") {
|
|
2965
|
-
child.kill();
|
|
2966
|
-
} else {
|
|
2967
|
-
process.kill(-child.pid);
|
|
2968
|
-
}
|
|
2969
|
-
}
|
|
2970
|
-
}, "abort"),
|
|
2971
|
-
ready,
|
|
2972
|
-
then: /* @__PURE__ */ __name(async (onResolve, onReject) => ready.then(onResolve).catch(onReject), "then")
|
|
2973
|
-
};
|
|
2974
|
-
}, "runDockerCmd");
|
|
2975
|
-
var isDockerRunning = /* @__PURE__ */ __name(async (dockerPath) => {
|
|
2976
|
-
try {
|
|
2977
|
-
await runDockerCmd(dockerPath, ["info"], ["inherit", "pipe", "pipe"]);
|
|
2978
|
-
} catch {
|
|
2979
|
-
return false;
|
|
2980
|
-
}
|
|
2981
|
-
return true;
|
|
2982
|
-
}, "isDockerRunning");
|
|
2983
|
-
var verifyDockerInstalled = /* @__PURE__ */ __name(async ({
|
|
2984
|
-
dockerPath,
|
|
2985
|
-
operation,
|
|
2986
|
-
imageNoun,
|
|
2987
|
-
hint
|
|
2988
|
-
}) => {
|
|
2989
|
-
const dockerIsRunning = await isDockerRunning(dockerPath);
|
|
2990
|
-
if (!dockerIsRunning) {
|
|
2991
|
-
throw new UserError$1(
|
|
2992
|
-
getFailedToRunDockerErrorMessage({
|
|
2993
|
-
operation,
|
|
2994
|
-
imageNoun,
|
|
2995
|
-
hint
|
|
2996
|
-
}),
|
|
2997
|
-
{
|
|
2998
|
-
telemetryMessage: false
|
|
2999
|
-
}
|
|
3000
|
-
);
|
|
3001
|
-
}
|
|
3002
|
-
}, "verifyDockerInstalled");
|
|
3003
|
-
function getFailedToRunDockerErrorMessage({
|
|
3004
|
-
operation,
|
|
3005
|
-
imageNoun,
|
|
3006
|
-
hint
|
|
3007
|
-
}) {
|
|
3008
|
-
const beforeOperation = operation ? ` before ${operation}` : "";
|
|
3009
|
-
const headline = `The Docker CLI is needed to build ${imageNoun}${beforeOperation} but could not be launched.`;
|
|
3010
|
-
let daemonHint;
|
|
3011
|
-
if (process.platform === "darwin") {
|
|
3012
|
-
daemonHint = "open the Docker Desktop app or run `open -a Docker`";
|
|
3013
|
-
} else if (process.platform === "win32") {
|
|
3014
|
-
daemonHint = "open the Docker Desktop app";
|
|
3015
|
-
} else {
|
|
3016
|
-
daemonHint = "run `sudo systemctl start docker`";
|
|
3017
|
-
}
|
|
3018
|
-
const steps = `To fix this, try the following:
|
|
3019
|
-
- If Docker is not installed, download it from https://docs.docker.com/get-started/get-docker/
|
|
3020
|
-
- If Docker is installed but the daemon is not running,
|
|
3021
|
-
${daemonHint}.
|
|
3022
|
-
- If you use an alternative Docker-compatible CLI (e.g. Podman),
|
|
3023
|
-
set the WRANGLER_DOCKER_BIN environment variable to its path and DOCKER_HOST to its socket.`;
|
|
3024
|
-
const alternatives = "Note: Other container tooling that is compatible with the Docker CLI and engine may work, but is not yet guaranteed to do so.";
|
|
3025
|
-
let message = `${headline}
|
|
3026
|
-
${steps}
|
|
3027
|
-
|
|
3028
|
-
${alternatives}`;
|
|
3029
|
-
if (hint) {
|
|
3030
|
-
message += `
|
|
3031
|
-
|
|
3032
|
-
${hint}`;
|
|
3033
|
-
}
|
|
3034
|
-
return message;
|
|
3035
|
-
}
|
|
3036
|
-
__name(getFailedToRunDockerErrorMessage, "getFailedToRunDockerErrorMessage");
|
|
3037
|
-
|
|
3038
2749
|
// src/deploy/helpers/error-codes.ts
|
|
3039
2750
|
var INVALID_INHERIT_BINDING_CODE = 10057;
|
|
3040
2751
|
var EXPORTS_RECONCILIATION_ERROR_CODE = 100402;
|
|
@@ -3262,14 +2973,14 @@ async function resolveOwnerWorkerTag(config2, accountId, scriptName) {
|
|
|
3262
2973
|
}
|
|
3263
2974
|
}
|
|
3264
2975
|
__name(resolveOwnerWorkerTag, "resolveOwnerWorkerTag");
|
|
3265
|
-
async function fetchEmailRoutingPlan(config2, accountId,
|
|
2976
|
+
async function fetchEmailRoutingPlan(config2, accountId, request) {
|
|
3266
2977
|
const deadline = Date.now() + PLAN_RETRY_TIMEOUT_MS;
|
|
3267
2978
|
for (; ; ) {
|
|
3268
2979
|
try {
|
|
3269
2980
|
return await fetchResult(
|
|
3270
2981
|
config2,
|
|
3271
2982
|
`/accounts/${accountId}/email/routing/rules/plan`,
|
|
3272
|
-
postJson(
|
|
2983
|
+
postJson(request)
|
|
3273
2984
|
);
|
|
3274
2985
|
} catch (e) {
|
|
3275
2986
|
const isWorkerNotFound = e instanceof APIError && e.code === PLAN_RETRY_WORKER_NOT_FOUND_CODE;
|
|
@@ -3287,8 +2998,8 @@ async function fetchEmailRoutingPlan(config2, accountId, request2) {
|
|
|
3287
2998
|
}
|
|
3288
2999
|
}
|
|
3289
3000
|
__name(fetchEmailRoutingPlan, "fetchEmailRoutingPlan");
|
|
3290
|
-
function putJson(config2,
|
|
3291
|
-
return fetchResult(config2,
|
|
3001
|
+
function putJson(config2, path10, body) {
|
|
3002
|
+
return fetchResult(config2, path10, {
|
|
3292
3003
|
method: "PUT",
|
|
3293
3004
|
headers: { "Content-Type": "application/json" },
|
|
3294
3005
|
body: JSON.stringify(body)
|
|
@@ -3357,12 +3068,12 @@ async function applyEmailRoutingAddresses({
|
|
|
3357
3068
|
return;
|
|
3358
3069
|
}
|
|
3359
3070
|
const ownerWorkerTag = workerTag ?? await resolveOwnerWorkerTag(config2, accountId, scriptName);
|
|
3360
|
-
const
|
|
3071
|
+
const request = buildEmailRoutingPlanRequest(
|
|
3361
3072
|
addresses,
|
|
3362
3073
|
scriptName,
|
|
3363
3074
|
ownerWorkerTag
|
|
3364
3075
|
);
|
|
3365
|
-
const plan = await fetchEmailRoutingPlan(config2, accountId,
|
|
3076
|
+
const plan = await fetchEmailRoutingPlan(config2, accountId, request);
|
|
3366
3077
|
if (!planHasChanges(plan)) {
|
|
3367
3078
|
logger.log("Email Routing rules are up to date.");
|
|
3368
3079
|
return;
|
|
@@ -3526,7 +3237,9 @@ function renderRoute(route) {
|
|
|
3526
3237
|
if (isCustomDomain) {
|
|
3527
3238
|
const flags = [];
|
|
3528
3239
|
if ("enabled" in route && route.enabled !== void 0) {
|
|
3529
|
-
flags.push(
|
|
3240
|
+
flags.push(
|
|
3241
|
+
route.enabled ? "production: enabled" : "production: disabled"
|
|
3242
|
+
);
|
|
3530
3243
|
}
|
|
3531
3244
|
if ("previews_enabled" in route && route.previews_enabled !== void 0) {
|
|
3532
3245
|
flags.push(
|
|
@@ -3666,7 +3379,7 @@ async function publishRoutesFallback(complianceConfig, routes, { scriptName, acc
|
|
|
3666
3379
|
return deployedRoutes;
|
|
3667
3380
|
}
|
|
3668
3381
|
__name(publishRoutesFallback, "publishRoutesFallback");
|
|
3669
|
-
async function publishCustomDomains(complianceConfig, workerUrl, accountId, domains) {
|
|
3382
|
+
async function publishCustomDomains(complianceConfig, workerUrl, accountId, scriptName, domains) {
|
|
3670
3383
|
const options = {
|
|
3671
3384
|
override_scope: true,
|
|
3672
3385
|
override_existing_origin: false,
|
|
@@ -3681,9 +3394,53 @@ async function publishCustomDomains(complianceConfig, workerUrl, accountId, doma
|
|
|
3681
3394
|
previews_enabled: "previews_enabled" in domainRoute ? domainRoute.previews_enabled : void 0
|
|
3682
3395
|
};
|
|
3683
3396
|
});
|
|
3397
|
+
let changeset;
|
|
3398
|
+
try {
|
|
3399
|
+
changeset = await fetchResult(
|
|
3400
|
+
complianceConfig,
|
|
3401
|
+
`${workerUrl}/domains/changeset?replace_state=true`,
|
|
3402
|
+
{
|
|
3403
|
+
method: "POST",
|
|
3404
|
+
body: JSON.stringify(origins),
|
|
3405
|
+
headers: {
|
|
3406
|
+
"Content-Type": "application/json"
|
|
3407
|
+
}
|
|
3408
|
+
}
|
|
3409
|
+
);
|
|
3410
|
+
} catch (error51) {
|
|
3411
|
+
if (process.stdout.isTTY) {
|
|
3412
|
+
throw error51;
|
|
3413
|
+
}
|
|
3414
|
+
changeset = { added: [], removed: [], updated: [], conflicting: [] };
|
|
3415
|
+
}
|
|
3416
|
+
const updatesRequired = changeset.updated.filter((domain2) => domain2.modified);
|
|
3417
|
+
const previewUpdates = updatesRequired.filter(
|
|
3418
|
+
(domain2) => domain2.previews_enabled === true
|
|
3419
|
+
);
|
|
3420
|
+
const fetchExistingDomain = /* @__PURE__ */ __name((domain2) => fetchResult(
|
|
3421
|
+
complianceConfig,
|
|
3422
|
+
`/accounts/${accountId}/workers/domains/records/${domain2.id}`
|
|
3423
|
+
), "fetchExistingDomain");
|
|
3424
|
+
let existing;
|
|
3425
|
+
if (process.stdout.isTTY) {
|
|
3426
|
+
existing = await Promise.all(updatesRequired.map(fetchExistingDomain));
|
|
3427
|
+
} else {
|
|
3428
|
+
const results = await Promise.allSettled(
|
|
3429
|
+
previewUpdates.map(fetchExistingDomain)
|
|
3430
|
+
);
|
|
3431
|
+
existing = results.flatMap(
|
|
3432
|
+
(result) => result.status === "fulfilled" ? [result.value] : []
|
|
3433
|
+
);
|
|
3434
|
+
}
|
|
3435
|
+
const existingById = new Map(existing.map((domain2) => [domain2.id, domain2]));
|
|
3436
|
+
const changed = changeset.added.some((domain2) => domain2.previews_enabled === true) || previewUpdates.some((domain2) => {
|
|
3437
|
+
const existingDomain = existingById.get(domain2.id);
|
|
3438
|
+
return existingDomain !== void 0 && (existingDomain.service !== scriptName || existingDomain.previews_enabled !== true);
|
|
3439
|
+
});
|
|
3684
3440
|
const fail = /* @__PURE__ */ __name(() => {
|
|
3685
3441
|
return {
|
|
3686
3442
|
targets: [],
|
|
3443
|
+
changed,
|
|
3687
3444
|
error: new UserError(
|
|
3688
3445
|
domains.length > 1 ? `Publishing to ${domains.length} Custom Domains was skipped, fix conflicts and try again` : `Publishing to Custom Domain "${domains[0].pattern}" was skipped, fix conflict and try again`,
|
|
3689
3446
|
{ telemetryMessage: "deploy custom domains skipped" }
|
|
@@ -3694,37 +3451,20 @@ async function publishCustomDomains(complianceConfig, workerUrl, accountId, doma
|
|
|
3694
3451
|
options.override_existing_origin = true;
|
|
3695
3452
|
options.override_existing_dns_record = true;
|
|
3696
3453
|
} else {
|
|
3697
|
-
const changeset = await fetchResult(
|
|
3698
|
-
complianceConfig,
|
|
3699
|
-
`${workerUrl}/domains/changeset?replace_state=true`,
|
|
3700
|
-
{
|
|
3701
|
-
method: "POST",
|
|
3702
|
-
body: JSON.stringify(origins),
|
|
3703
|
-
headers: {
|
|
3704
|
-
"Content-Type": "application/json"
|
|
3705
|
-
}
|
|
3706
|
-
}
|
|
3707
|
-
);
|
|
3708
|
-
const updatesRequired = changeset.updated.filter(
|
|
3709
|
-
(domain2) => domain2.modified
|
|
3710
|
-
);
|
|
3711
3454
|
if (updatesRequired.length > 0) {
|
|
3712
|
-
const
|
|
3713
|
-
|
|
3714
|
-
(domain2) => fetchResult(
|
|
3715
|
-
complianceConfig,
|
|
3716
|
-
`/accounts/${accountId}/workers/domains/records/${domain2.id}`
|
|
3717
|
-
)
|
|
3718
|
-
)
|
|
3455
|
+
const existingForOtherWorkers = existing.filter(
|
|
3456
|
+
(domain2) => domain2.service !== scriptName
|
|
3719
3457
|
);
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3458
|
+
if (existingForOtherWorkers.length > 0) {
|
|
3459
|
+
const existingRendered = existingForOtherWorkers.map(
|
|
3460
|
+
(domain2) => ` \u2022 ${domain2.hostname} (used as a domain for "${domain2.service}")`
|
|
3461
|
+
).join("\n");
|
|
3462
|
+
const message = `Custom Domains already exist for these domains:
|
|
3724
3463
|
${existingRendered}
|
|
3725
3464
|
Update them to point to this script instead?`;
|
|
3726
|
-
|
|
3727
|
-
|
|
3465
|
+
if (!await confirm(message)) {
|
|
3466
|
+
return fail();
|
|
3467
|
+
}
|
|
3728
3468
|
}
|
|
3729
3469
|
options.override_existing_origin = true;
|
|
3730
3470
|
}
|
|
@@ -3746,7 +3486,7 @@ Update them to point to this script instead?`;
|
|
|
3746
3486
|
"Content-Type": "application/json"
|
|
3747
3487
|
}
|
|
3748
3488
|
});
|
|
3749
|
-
return { targets: domains.map((domain2) => renderRoute(domain2)) };
|
|
3489
|
+
return { targets: domains.map((domain2) => renderRoute(domain2)), changed };
|
|
3750
3490
|
}
|
|
3751
3491
|
__name(publishCustomDomains, "publishCustomDomains");
|
|
3752
3492
|
async function listQueues(complianceConfig, accountId, page, name) {
|
|
@@ -4216,6 +3956,7 @@ async function registerSubdomain(complianceConfig, accountId, configPath, regist
|
|
|
4216
3956
|
__name(registerSubdomain, "registerSubdomain");
|
|
4217
3957
|
|
|
4218
3958
|
// src/triggers/deploy.ts
|
|
3959
|
+
var PREVIEW_DOMAIN_PROVISIONING_NOTE = "Note: DNS and TLS certificate provisioning for Preview domains may continue after this deploy. If a new Preview URL does not work immediately, wait a few minutes and retry.";
|
|
4219
3960
|
async function triggersDeploy(props) {
|
|
4220
3961
|
const { config: config2, scriptName, routes, crons } = props;
|
|
4221
3962
|
if (props.validated !== true) {
|
|
@@ -4226,7 +3967,7 @@ async function triggersDeploy(props) {
|
|
|
4226
3967
|
return;
|
|
4227
3968
|
}
|
|
4228
3969
|
const { accountId } = props;
|
|
4229
|
-
|
|
3970
|
+
assert5(accountId);
|
|
4230
3971
|
if (props.validated !== true) {
|
|
4231
3972
|
await ensureQueuesExistByConfig(config2, accountId, true, scriptName);
|
|
4232
3973
|
}
|
|
@@ -4347,6 +4088,7 @@ ${dashLink}`, {
|
|
|
4347
4088
|
config2,
|
|
4348
4089
|
workerUrl,
|
|
4349
4090
|
accountId,
|
|
4091
|
+
scriptName,
|
|
4350
4092
|
customDomainsOnly
|
|
4351
4093
|
).then(
|
|
4352
4094
|
(result) => ({ ...result, category: "Custom domains" }),
|
|
@@ -4572,6 +4314,14 @@ ${dashLink}`, {
|
|
|
4572
4314
|
} else {
|
|
4573
4315
|
logger.log("No targets deployed for", workerName, formatTime(deployMs));
|
|
4574
4316
|
}
|
|
4317
|
+
const customDomainDeployment = completedDeployments.find(
|
|
4318
|
+
(deployment) => deployment.category === "Custom domains"
|
|
4319
|
+
);
|
|
4320
|
+
if (customDomainsOnly.some(
|
|
4321
|
+
(domain2) => "previews_enabled" in domain2 && domain2.previews_enabled === true
|
|
4322
|
+
) && customDomainDeployment !== void 0 && customDomainDeployment.changed === true && customDomainDeployment.error === void 0) {
|
|
4323
|
+
logger.log(PREVIEW_DOMAIN_PROVISIONING_NOTE);
|
|
4324
|
+
}
|
|
4575
4325
|
const failedDeployments = completedDeployments.filter(
|
|
4576
4326
|
(deployment) => deployment.error !== void 0
|
|
4577
4327
|
);
|
|
@@ -6027,12 +5777,12 @@ var Mime = class {
|
|
|
6027
5777
|
}
|
|
6028
5778
|
return this;
|
|
6029
5779
|
}
|
|
6030
|
-
getType(
|
|
6031
|
-
if (typeof
|
|
5780
|
+
getType(path10) {
|
|
5781
|
+
if (typeof path10 !== "string")
|
|
6032
5782
|
return null;
|
|
6033
|
-
const last =
|
|
5783
|
+
const last = path10.replace(/^.*[/\\]/s, "").toLowerCase();
|
|
6034
5784
|
const ext = last.replace(/^.*\./s, "").toLowerCase();
|
|
6035
|
-
const hasPath = last.length <
|
|
5785
|
+
const hasPath = last.length < path10.length;
|
|
6036
5786
|
const hasDot = ext.length < last.length - 1;
|
|
6037
5787
|
if (!hasDot && hasPath)
|
|
6038
5788
|
return null;
|
|
@@ -6163,7 +5913,7 @@ var MAX_UPLOAD_ATTEMPTS = 5;
|
|
|
6163
5913
|
var MAX_UPLOAD_GATEWAY_ERRORS = 5;
|
|
6164
5914
|
var MAX_DIFF_LINES = 100;
|
|
6165
5915
|
var syncAssets = /* @__PURE__ */ __name(async (complianceConfig, accountId, assetDirectory, scriptName, dispatchNamespace) => {
|
|
6166
|
-
|
|
5916
|
+
assert5(accountId, "Missing accountId");
|
|
6167
5917
|
logger.info("\u{1F300} Building list of assets...");
|
|
6168
5918
|
const manifest = await buildAssetManifest(assetDirectory);
|
|
6169
5919
|
const url3 = dispatchNamespace ? `/accounts/${accountId}/workers/dispatch/namespaces/${dispatchNamespace}/scripts/${scriptName}/assets-upload-session` : `/accounts/${accountId}/workers/scripts/${scriptName}/assets-upload-session`;
|
|
@@ -6665,6 +6415,14 @@ __name(patchNonVersionedScriptSettings, "patchNonVersionedScriptSettings");
|
|
|
6665
6415
|
// src/deploy/helpers/confirm-latest-deployment-overwrite.ts
|
|
6666
6416
|
var BLANK_INPUT = "-";
|
|
6667
6417
|
async function confirmLatestDeploymentOverwrite(config2, accountId, scriptName) {
|
|
6418
|
+
return (await confirmLatestDeploymentOverwriteAndGetLatest(
|
|
6419
|
+
config2,
|
|
6420
|
+
accountId,
|
|
6421
|
+
scriptName
|
|
6422
|
+
)).confirmed;
|
|
6423
|
+
}
|
|
6424
|
+
__name(confirmLatestDeploymentOverwrite, "confirmLatestDeploymentOverwrite");
|
|
6425
|
+
async function confirmLatestDeploymentOverwriteAndGetLatest(config2, accountId, scriptName) {
|
|
6668
6426
|
try {
|
|
6669
6427
|
const latest = await fetchLatestDeployment(config2, accountId, scriptName);
|
|
6670
6428
|
if (latest && latest.versions.length >= 2) {
|
|
@@ -6682,7 +6440,7 @@ async function confirmLatestDeploymentOverwrite(config2, accountId, scriptName)
|
|
|
6682
6440
|
"last",
|
|
6683
6441
|
versionCache
|
|
6684
6442
|
);
|
|
6685
|
-
|
|
6443
|
+
const confirmed = await inputPrompt({
|
|
6686
6444
|
type: "confirm",
|
|
6687
6445
|
question: `"wrangler deploy" will upload a new version and deploy it globally immediately.
|
|
6688
6446
|
Are you sure you want to continue?`,
|
|
@@ -6690,15 +6448,17 @@ Are you sure you want to continue?`,
|
|
|
6690
6448
|
defaultValue: isNonInteractiveOrCI(),
|
|
6691
6449
|
acceptDefault: isNonInteractiveOrCI()
|
|
6692
6450
|
});
|
|
6451
|
+
return { confirmed, latestDeployment: latest };
|
|
6693
6452
|
}
|
|
6453
|
+
return { confirmed: true, latestDeployment: latest };
|
|
6694
6454
|
} catch (e) {
|
|
6695
6455
|
if (!isWorkerNotFoundError(e)) {
|
|
6696
6456
|
throw e;
|
|
6697
6457
|
}
|
|
6698
6458
|
}
|
|
6699
|
-
return true;
|
|
6459
|
+
return { confirmed: true, latestDeployment: void 0 };
|
|
6700
6460
|
}
|
|
6701
|
-
__name(
|
|
6461
|
+
__name(confirmLatestDeploymentOverwriteAndGetLatest, "confirmLatestDeploymentOverwriteAndGetLatest");
|
|
6702
6462
|
async function printDeployment(config2, accountId, workerName, deployment, adjective, versionCache) {
|
|
6703
6463
|
const [versions, traffic] = await fetchDeploymentVersions(
|
|
6704
6464
|
config2,
|
|
@@ -6730,6 +6490,172 @@ function formatVersions(versions, traffic) {
|
|
|
6730
6490
|
}).join("\n\n");
|
|
6731
6491
|
}
|
|
6732
6492
|
__name(formatVersions, "formatVersions");
|
|
6493
|
+
async function clearRemovedContainerImagesBindings(config2, bindings, workerUrl) {
|
|
6494
|
+
if (getDurableObjectContainerApps(config2.containers).length > 0) {
|
|
6495
|
+
return;
|
|
6496
|
+
}
|
|
6497
|
+
const settings = await fetchResult(
|
|
6498
|
+
config2,
|
|
6499
|
+
`${workerUrl}/settings`
|
|
6500
|
+
);
|
|
6501
|
+
if (settings.bindings.some(({ name }) => name === CONTAINER_IMAGES_BINDING)) {
|
|
6502
|
+
bindings[CONTAINER_IMAGES_BINDING] ??= { type: "json", value: {} };
|
|
6503
|
+
}
|
|
6504
|
+
}
|
|
6505
|
+
__name(clearRemovedContainerImagesBindings, "clearRemovedContainerImagesBindings");
|
|
6506
|
+
function addContainerImagesBinding(config2, bindings, preparedContainerImages, options = {}) {
|
|
6507
|
+
const containers = getDurableObjectContainerApps(config2.containers);
|
|
6508
|
+
const shouldInheritExisting = options.preserveExisting && options.workerExists && options.hasExistingBinding;
|
|
6509
|
+
if (options.preserveExisting && !shouldInheritExisting) {
|
|
6510
|
+
return;
|
|
6511
|
+
}
|
|
6512
|
+
if (containers.length === 0 && !shouldInheritExisting) {
|
|
6513
|
+
return;
|
|
6514
|
+
}
|
|
6515
|
+
if (bindings[CONTAINER_IMAGES_BINDING] !== void 0) {
|
|
6516
|
+
throw new UserError(
|
|
6517
|
+
`The binding name "${CONTAINER_IMAGES_BINDING}" is reserved for Durable Object-managed Container images.`,
|
|
6518
|
+
{
|
|
6519
|
+
telemetryMessage: "durable object container images binding name conflict"
|
|
6520
|
+
}
|
|
6521
|
+
);
|
|
6522
|
+
}
|
|
6523
|
+
if (options.preserveExisting) {
|
|
6524
|
+
bindings[CONTAINER_IMAGES_BINDING] = { type: "inherit" };
|
|
6525
|
+
return;
|
|
6526
|
+
}
|
|
6527
|
+
bindings[CONTAINER_IMAGES_BINDING] = {
|
|
6528
|
+
type: "json",
|
|
6529
|
+
value: Object.fromEntries(
|
|
6530
|
+
containers.map((container) => {
|
|
6531
|
+
const configuredImages = Object.keys(container.images ?? {});
|
|
6532
|
+
const preparedImages = preparedContainerImages[container.class_name];
|
|
6533
|
+
if (configuredImages.length > 0 && preparedImages === void 0) {
|
|
6534
|
+
throw new Error(
|
|
6535
|
+
`Container images for Durable Object class "${container.class_name}" were not prepared before upload.`
|
|
6536
|
+
);
|
|
6537
|
+
}
|
|
6538
|
+
return [container.class_name, preparedImages ?? {}];
|
|
6539
|
+
})
|
|
6540
|
+
)
|
|
6541
|
+
};
|
|
6542
|
+
}
|
|
6543
|
+
__name(addContainerImagesBinding, "addContainerImagesBinding");
|
|
6544
|
+
function getContainerMetadata(config2, preparedContainerImages = {}, options = {}) {
|
|
6545
|
+
const metadata = config2.containers?.map((container) => {
|
|
6546
|
+
if (isDurableObjectContainerApp(container)) {
|
|
6547
|
+
const configuredImages = Object.keys(container.images ?? {});
|
|
6548
|
+
const images = preparedContainerImages[container.class_name];
|
|
6549
|
+
if (configuredImages.length > 0 && images === void 0 && !options.allowUnprepared) {
|
|
6550
|
+
throw new Error(
|
|
6551
|
+
`Container images for Durable Object class "${container.class_name}" were not prepared before upload.`
|
|
6552
|
+
);
|
|
6553
|
+
}
|
|
6554
|
+
return {
|
|
6555
|
+
name: container.name,
|
|
6556
|
+
class_name: container.class_name,
|
|
6557
|
+
...images !== void 0 && { images }
|
|
6558
|
+
};
|
|
6559
|
+
}
|
|
6560
|
+
return {
|
|
6561
|
+
...container.name !== void 0 && { name: container.name },
|
|
6562
|
+
...container.class_name !== void 0 && {
|
|
6563
|
+
class_name: container.class_name
|
|
6564
|
+
}
|
|
6565
|
+
};
|
|
6566
|
+
}) ?? [];
|
|
6567
|
+
return config2.containers === void 0 ? void 0 : metadata;
|
|
6568
|
+
}
|
|
6569
|
+
__name(getContainerMetadata, "getContainerMetadata");
|
|
6570
|
+
async function getContainerMetadataForRolloutSkip(config2, {
|
|
6571
|
+
accountId,
|
|
6572
|
+
scriptName,
|
|
6573
|
+
dispatchNamespace,
|
|
6574
|
+
workerExists,
|
|
6575
|
+
latestDeployment,
|
|
6576
|
+
dryRun = false
|
|
6577
|
+
}) {
|
|
6578
|
+
const configuredMetadata = getContainerMetadata(
|
|
6579
|
+
config2,
|
|
6580
|
+
{},
|
|
6581
|
+
{
|
|
6582
|
+
allowUnprepared: true
|
|
6583
|
+
}
|
|
6584
|
+
);
|
|
6585
|
+
if (dryRun || !workerExists) {
|
|
6586
|
+
return {
|
|
6587
|
+
containers: configuredMetadata,
|
|
6588
|
+
hasExistingContainerImagesBinding: false
|
|
6589
|
+
};
|
|
6590
|
+
}
|
|
6591
|
+
if (dispatchNamespace !== void 0) {
|
|
6592
|
+
throw new UserError(
|
|
6593
|
+
"Cannot use --containers-rollout=none for an existing dispatch script because the Workers for Platforms API does not expose its deployed Container metadata. The Worker has not been uploaded. Deploy without this flag only when you intend to apply the local Container configuration.",
|
|
6594
|
+
{
|
|
6595
|
+
telemetryMessage: "rollout none dispatch container metadata unavailable"
|
|
6596
|
+
}
|
|
6597
|
+
);
|
|
6598
|
+
}
|
|
6599
|
+
if (accountId === void 0 || latestDeployment === void 0 || latestDeployment.versions.length === 0) {
|
|
6600
|
+
throw new UserError(
|
|
6601
|
+
"Cannot use --containers-rollout=none for an existing Worker because its deployed Container metadata could not be recovered. The Worker has not been uploaded. Deploy without this flag only when you intend to apply the local Container configuration.",
|
|
6602
|
+
{
|
|
6603
|
+
telemetryMessage: "rollout none deployed container metadata unavailable"
|
|
6604
|
+
}
|
|
6605
|
+
);
|
|
6606
|
+
}
|
|
6607
|
+
const versions = await fetchVersions(
|
|
6608
|
+
config2,
|
|
6609
|
+
accountId,
|
|
6610
|
+
scriptName,
|
|
6611
|
+
void 0,
|
|
6612
|
+
latestDeployment.versions.map(({ version_id }) => version_id)
|
|
6613
|
+
);
|
|
6614
|
+
const containerImagesBindingByVersion = versions.map(
|
|
6615
|
+
(version2) => version2.resources.bindings.some(
|
|
6616
|
+
(binding) => binding.name === CONTAINER_IMAGES_BINDING
|
|
6617
|
+
)
|
|
6618
|
+
);
|
|
6619
|
+
const hasExistingContainerImagesBinding = containerImagesBindingByVersion[0] ?? false;
|
|
6620
|
+
if (containerImagesBindingByVersion.some(
|
|
6621
|
+
(hasBinding) => hasBinding !== hasExistingContainerImagesBinding
|
|
6622
|
+
)) {
|
|
6623
|
+
throw new UserError(
|
|
6624
|
+
`All currently deployed Worker Versions must have identical ${CONTAINER_IMAGES_BINDING} binding presence when using --containers-rollout=none.`,
|
|
6625
|
+
{
|
|
6626
|
+
telemetryMessage: "rollout none inconsistent durable object container image binding"
|
|
6627
|
+
}
|
|
6628
|
+
);
|
|
6629
|
+
}
|
|
6630
|
+
const containerMetadataByVersion = versions.map(
|
|
6631
|
+
(version2) => version2.resources?.script_runtime?.containers
|
|
6632
|
+
);
|
|
6633
|
+
const existingMetadata = containerMetadataByVersion.filter(
|
|
6634
|
+
(metadata) => metadata !== void 0
|
|
6635
|
+
);
|
|
6636
|
+
if (existingMetadata.length === 0) {
|
|
6637
|
+
return {
|
|
6638
|
+
containers: void 0,
|
|
6639
|
+
hasExistingContainerImagesBinding
|
|
6640
|
+
};
|
|
6641
|
+
}
|
|
6642
|
+
const expectedMetadata = existingMetadata[0];
|
|
6643
|
+
if (existingMetadata.length !== containerMetadataByVersion.length || existingMetadata.some(
|
|
6644
|
+
(metadata) => !isDeepStrictEqual(metadata, expectedMetadata)
|
|
6645
|
+
)) {
|
|
6646
|
+
throw new UserError(
|
|
6647
|
+
"All currently deployed Worker Versions must have identical Container metadata when using --containers-rollout=none.",
|
|
6648
|
+
{
|
|
6649
|
+
telemetryMessage: "rollout none inconsistent deployed container metadata"
|
|
6650
|
+
}
|
|
6651
|
+
);
|
|
6652
|
+
}
|
|
6653
|
+
return {
|
|
6654
|
+
containers: existingMetadata[0],
|
|
6655
|
+
hasExistingContainerImagesBinding
|
|
6656
|
+
};
|
|
6657
|
+
}
|
|
6658
|
+
__name(getContainerMetadataForRolloutSkip, "getContainerMetadataForRolloutSkip");
|
|
6733
6659
|
|
|
6734
6660
|
// src/deploy/helpers/deploy-wfp.ts
|
|
6735
6661
|
function deployWfpUserWorker(dispatchNamespace, versionId) {
|
|
@@ -6737,6 +6663,344 @@ function deployWfpUserWorker(dispatchNamespace, versionId) {
|
|
|
6737
6663
|
logger.log("Current Version ID:", versionId);
|
|
6738
6664
|
}
|
|
6739
6665
|
__name(deployWfpUserWorker, "deployWfpUserWorker");
|
|
6666
|
+
var IMAGE_PREPARATION_POLL_INTERVAL_MS = 2e3;
|
|
6667
|
+
var IMAGE_PREPARATION_TIMEOUT_MS = 15 * 6e4;
|
|
6668
|
+
function isRegistryImage(image) {
|
|
6669
|
+
return typeof image.image === "string";
|
|
6670
|
+
}
|
|
6671
|
+
__name(isRegistryImage, "isRegistryImage");
|
|
6672
|
+
function toCreateApplicationRequest({ name }, namespaceId) {
|
|
6673
|
+
return {
|
|
6674
|
+
name,
|
|
6675
|
+
scheduling_policy: SchedulingPolicy.DURABLE_OBJECT,
|
|
6676
|
+
durable_objects: { namespace_id: namespaceId }
|
|
6677
|
+
};
|
|
6678
|
+
}
|
|
6679
|
+
__name(toCreateApplicationRequest, "toCreateApplicationRequest");
|
|
6680
|
+
async function createDurableObjectContainerApplication(application, namespaceId) {
|
|
6681
|
+
await ApplicationsService.createApplication(
|
|
6682
|
+
toCreateApplicationRequest(application, namespaceId)
|
|
6683
|
+
);
|
|
6684
|
+
}
|
|
6685
|
+
__name(createDurableObjectContainerApplication, "createDurableObjectContainerApplication");
|
|
6686
|
+
function getContainerImageClasses(version2) {
|
|
6687
|
+
const binding = version2.resources.bindings.find(
|
|
6688
|
+
(candidate) => candidate.name === CONTAINER_IMAGES_BINDING
|
|
6689
|
+
);
|
|
6690
|
+
if (binding === void 0) {
|
|
6691
|
+
return void 0;
|
|
6692
|
+
}
|
|
6693
|
+
if (binding.type !== "json" || typeof binding.json !== "object" || binding.json === null || Array.isArray(binding.json)) {
|
|
6694
|
+
throw new UserError(
|
|
6695
|
+
`Worker Version ${version2.id} has invalid ${CONTAINER_IMAGES_BINDING} metadata.`,
|
|
6696
|
+
{
|
|
6697
|
+
telemetryMessage: "versions deploy invalid durable object container image binding"
|
|
6698
|
+
}
|
|
6699
|
+
);
|
|
6700
|
+
}
|
|
6701
|
+
return new Set(Object.keys(binding.json));
|
|
6702
|
+
}
|
|
6703
|
+
__name(getContainerImageClasses, "getContainerImageClasses");
|
|
6704
|
+
function getNamespaceId(version2, scriptName, className) {
|
|
6705
|
+
const binding = version2.resources.bindings.find(
|
|
6706
|
+
(candidate) => candidate.type === "durable_object_namespace" && candidate.class_name === className && (candidate.script_name === void 0 || candidate.script_name === scriptName)
|
|
6707
|
+
);
|
|
6708
|
+
return binding?.type === "durable_object_namespace" ? binding.namespace_id : void 0;
|
|
6709
|
+
}
|
|
6710
|
+
__name(getNamespaceId, "getNamespaceId");
|
|
6711
|
+
function getDurableObjectContainerApplicationsFromVersion(version2, scriptName) {
|
|
6712
|
+
const containerClasses = getContainerImageClasses(version2);
|
|
6713
|
+
if (containerClasses === void 0) {
|
|
6714
|
+
return [];
|
|
6715
|
+
}
|
|
6716
|
+
const containers = version2.resources.script_runtime.containers ?? [];
|
|
6717
|
+
return [...containerClasses].sort().map((className) => {
|
|
6718
|
+
const matchingContainers = containers.filter(
|
|
6719
|
+
(container2) => container2.class_name === className
|
|
6720
|
+
);
|
|
6721
|
+
const [container] = matchingContainers;
|
|
6722
|
+
if (matchingContainers.length !== 1 || container?.name === void 0) {
|
|
6723
|
+
throw new UserError(
|
|
6724
|
+
`Worker Version ${version2.id} has invalid Durable Object-managed Container metadata for class "${className}".`,
|
|
6725
|
+
{
|
|
6726
|
+
telemetryMessage: "versions deploy invalid durable object container metadata"
|
|
6727
|
+
}
|
|
6728
|
+
);
|
|
6729
|
+
}
|
|
6730
|
+
return {
|
|
6731
|
+
class_name: className,
|
|
6732
|
+
name: container.name,
|
|
6733
|
+
namespaceId: getNamespaceId(version2, scriptName, className)
|
|
6734
|
+
};
|
|
6735
|
+
});
|
|
6736
|
+
}
|
|
6737
|
+
__name(getDurableObjectContainerApplicationsFromVersion, "getDurableObjectContainerApplicationsFromVersion");
|
|
6738
|
+
function getVersionedDurableObjectContainerApplications(versions, scriptName) {
|
|
6739
|
+
const applicationsByVersion = versions.map(
|
|
6740
|
+
(version2) => getDurableObjectContainerApplicationsFromVersion(version2, scriptName)
|
|
6741
|
+
);
|
|
6742
|
+
const [firstApplications = []] = applicationsByVersion;
|
|
6743
|
+
const expectedDefinition = JSON.stringify(
|
|
6744
|
+
firstApplications.map(({ class_name, name }) => ({ class_name, name }))
|
|
6745
|
+
);
|
|
6746
|
+
for (let index = 1; index < applicationsByVersion.length; index++) {
|
|
6747
|
+
const applications = applicationsByVersion[index] ?? [];
|
|
6748
|
+
const definition = JSON.stringify(
|
|
6749
|
+
applications.map(({ class_name, name }) => ({ class_name, name }))
|
|
6750
|
+
);
|
|
6751
|
+
if (definition !== expectedDefinition) {
|
|
6752
|
+
throw new UserError(
|
|
6753
|
+
"All Worker Versions in a multi-version deployment must declare identical Durable Object-managed Container applications.",
|
|
6754
|
+
{
|
|
6755
|
+
telemetryMessage: "versions deploy inconsistent durable object container applications"
|
|
6756
|
+
}
|
|
6757
|
+
);
|
|
6758
|
+
}
|
|
6759
|
+
}
|
|
6760
|
+
return firstApplications.map((application, applicationIndex) => {
|
|
6761
|
+
const namespaceIds = new Set(
|
|
6762
|
+
applicationsByVersion.map((applications) => applications[applicationIndex]?.namespaceId).filter((namespaceId) => Boolean(namespaceId))
|
|
6763
|
+
);
|
|
6764
|
+
if (namespaceIds.size > 1) {
|
|
6765
|
+
throw new UserError(
|
|
6766
|
+
"All Worker Versions in a multi-version deployment must reference the same Durable Object namespaces for their Container applications.",
|
|
6767
|
+
{
|
|
6768
|
+
telemetryMessage: "versions deploy inconsistent durable object container namespaces"
|
|
6769
|
+
}
|
|
6770
|
+
);
|
|
6771
|
+
}
|
|
6772
|
+
return {
|
|
6773
|
+
...application,
|
|
6774
|
+
namespaceId: namespaceIds.values().next().value
|
|
6775
|
+
};
|
|
6776
|
+
});
|
|
6777
|
+
}
|
|
6778
|
+
__name(getVersionedDurableObjectContainerApplications, "getVersionedDurableObjectContainerApplications");
|
|
6779
|
+
async function resolveVersionedDurableObjectContainerApplications(config2, {
|
|
6780
|
+
applications,
|
|
6781
|
+
accountId,
|
|
6782
|
+
scriptName,
|
|
6783
|
+
allowMissingNamespaces = false
|
|
6784
|
+
}) {
|
|
6785
|
+
if (applications.length === 0) {
|
|
6786
|
+
return [];
|
|
6787
|
+
}
|
|
6788
|
+
const namespaces = applications.some(
|
|
6789
|
+
(application) => application.namespaceId === void 0
|
|
6790
|
+
) ? await listDurableObjects(config2, accountId) : [];
|
|
6791
|
+
return applications.map((application) => {
|
|
6792
|
+
const namespaceId = application.namespaceId ?? namespaces.find(
|
|
6793
|
+
(namespace) => namespace.class === application.class_name && namespace.script === scriptName && namespace.preview === void 0 && namespace.dispatch_namespace === void 0
|
|
6794
|
+
)?.id;
|
|
6795
|
+
if (namespaceId === void 0) {
|
|
6796
|
+
if (allowMissingNamespaces) {
|
|
6797
|
+
return application;
|
|
6798
|
+
}
|
|
6799
|
+
throw new UserError(
|
|
6800
|
+
`Could not deploy Durable Object-managed Container application "${application.name}" because class "${application.class_name}" has no namespace after the Worker Version was deployed.`,
|
|
6801
|
+
{
|
|
6802
|
+
telemetryMessage: "versions deploy durable object container namespace missing"
|
|
6803
|
+
}
|
|
6804
|
+
);
|
|
6805
|
+
}
|
|
6806
|
+
return { ...application, namespaceId };
|
|
6807
|
+
});
|
|
6808
|
+
}
|
|
6809
|
+
__name(resolveVersionedDurableObjectContainerApplications, "resolveVersionedDurableObjectContainerApplications");
|
|
6810
|
+
async function deployVersionedDurableObjectContainerApplications(config2, args) {
|
|
6811
|
+
if (args.applications.length === 0) {
|
|
6812
|
+
return;
|
|
6813
|
+
}
|
|
6814
|
+
const applications = await resolveVersionedDurableObjectContainerApplications(
|
|
6815
|
+
config2,
|
|
6816
|
+
args
|
|
6817
|
+
);
|
|
6818
|
+
for (const application of applications) {
|
|
6819
|
+
if (application.namespaceId !== void 0) {
|
|
6820
|
+
await createDurableObjectContainerApplication(
|
|
6821
|
+
application,
|
|
6822
|
+
application.namespaceId
|
|
6823
|
+
);
|
|
6824
|
+
}
|
|
6825
|
+
}
|
|
6826
|
+
}
|
|
6827
|
+
__name(deployVersionedDurableObjectContainerApplications, "deployVersionedDurableObjectContainerApplications");
|
|
6828
|
+
function buildTag(scriptName, className, imageName) {
|
|
6829
|
+
const repository = `${scriptName}-${className}-${imageName}`.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
6830
|
+
return `${repository}:wrangler-${Date.now().toString(36)}`;
|
|
6831
|
+
}
|
|
6832
|
+
__name(buildTag, "buildTag");
|
|
6833
|
+
async function buildOrResolveImage(config2, container, imageName, imageConfig, scriptName, dryRun, accountId) {
|
|
6834
|
+
if (isRegistryImage(imageConfig)) {
|
|
6835
|
+
if (dryRun) {
|
|
6836
|
+
return imageConfig.image;
|
|
6837
|
+
}
|
|
6838
|
+
assert5(accountId, "Expected accountId to resolve container image name");
|
|
6839
|
+
return resolveImageName(accountId, imageConfig.image, config2);
|
|
6840
|
+
}
|
|
6841
|
+
const baseDir = config2.configPath ? path__default.dirname(config2.configPath) : process.cwd();
|
|
6842
|
+
const dockerfile = path__default.resolve(baseDir, imageConfig.dockerfile);
|
|
6843
|
+
const tag = buildTag(scriptName, container.class_name, imageName);
|
|
6844
|
+
logger.log("Building image", tag);
|
|
6845
|
+
const imageRef = await buildAndMaybePush(
|
|
6846
|
+
{
|
|
6847
|
+
tag,
|
|
6848
|
+
pathToDockerfile: dockerfile,
|
|
6849
|
+
buildContext: path__default.dirname(dockerfile),
|
|
6850
|
+
platform: "linux/amd64"
|
|
6851
|
+
},
|
|
6852
|
+
getDockerPath(),
|
|
6853
|
+
!dryRun,
|
|
6854
|
+
void 0,
|
|
6855
|
+
true,
|
|
6856
|
+
config2
|
|
6857
|
+
);
|
|
6858
|
+
return "remoteDigest" in imageRef ? imageRef.remoteDigest : imageRef.newTag;
|
|
6859
|
+
}
|
|
6860
|
+
__name(buildOrResolveImage, "buildOrResolveImage");
|
|
6861
|
+
async function waitForImagePreparation(image) {
|
|
6862
|
+
const deadline = Date.now() + IMAGE_PREPARATION_TIMEOUT_MS;
|
|
6863
|
+
while (Date.now() < deadline) {
|
|
6864
|
+
const preparation = await ContainerImagePreparationsService.prepareContainerImage({ image });
|
|
6865
|
+
switch (preparation.status) {
|
|
6866
|
+
case ContainerImagePreparationStatus.READY:
|
|
6867
|
+
return;
|
|
6868
|
+
case ContainerImagePreparationStatus.ERROR:
|
|
6869
|
+
throw new UserError(
|
|
6870
|
+
preparation.reason ?? "Container image preparation failed",
|
|
6871
|
+
{
|
|
6872
|
+
telemetryMessage: "durable object container image preparation failed"
|
|
6873
|
+
}
|
|
6874
|
+
);
|
|
6875
|
+
case ContainerImagePreparationStatus.PENDING:
|
|
6876
|
+
await setTimeout$1(IMAGE_PREPARATION_POLL_INTERVAL_MS);
|
|
6877
|
+
break;
|
|
6878
|
+
default:
|
|
6879
|
+
throw new UserError(
|
|
6880
|
+
`Container image preparation returned an unsupported status: ${String(preparation.status)}`,
|
|
6881
|
+
{
|
|
6882
|
+
telemetryMessage: "durable object container image preparation unsupported status"
|
|
6883
|
+
}
|
|
6884
|
+
);
|
|
6885
|
+
}
|
|
6886
|
+
}
|
|
6887
|
+
throw new UserError(
|
|
6888
|
+
"Timed out while preparing the container image on Cloudflare's network.",
|
|
6889
|
+
{
|
|
6890
|
+
telemetryMessage: "durable object container image preparation timed out"
|
|
6891
|
+
}
|
|
6892
|
+
);
|
|
6893
|
+
}
|
|
6894
|
+
__name(waitForImagePreparation, "waitForImagePreparation");
|
|
6895
|
+
async function prepareDurableObjectContainerApplications(config2, {
|
|
6896
|
+
accountId,
|
|
6897
|
+
dryRun,
|
|
6898
|
+
scriptName,
|
|
6899
|
+
dispatchNamespace
|
|
6900
|
+
}) {
|
|
6901
|
+
validateDurableObjectContainerApplications(config2);
|
|
6902
|
+
if (!dryRun) {
|
|
6903
|
+
assert5(accountId, "Expected accountId to prepare container applications");
|
|
6904
|
+
const storageByClass = getDurableObjectClassNameToUseSQLiteMap(
|
|
6905
|
+
config2.migrations,
|
|
6906
|
+
config2.exports
|
|
6907
|
+
);
|
|
6908
|
+
const unknownStorage = getDurableObjectContainerApps(
|
|
6909
|
+
config2.containers
|
|
6910
|
+
).filter(
|
|
6911
|
+
(container) => storageByClass.get(container.class_name) === void 0
|
|
6912
|
+
);
|
|
6913
|
+
if (unknownStorage.length > 0) {
|
|
6914
|
+
const namespaces = await listDurableObjects(config2, accountId);
|
|
6915
|
+
for (const container of unknownStorage) {
|
|
6916
|
+
if (namespaces.some(
|
|
6917
|
+
(namespace) => namespace.class === container.class_name && namespace.script === scriptName && namespace.preview === void 0 && namespace.dispatch_namespace === dispatchNamespace && namespace.use_sqlite === false
|
|
6918
|
+
)) {
|
|
6919
|
+
throw new UserError(
|
|
6920
|
+
`The container ${container.name} references Durable Object class ${container.class_name}, which uses the legacy KV storage backend. Durable Object-managed Containers require SQLite-backed Durable Objects.`,
|
|
6921
|
+
{
|
|
6922
|
+
telemetryMessage: "durable object container class uses legacy storage"
|
|
6923
|
+
}
|
|
6924
|
+
);
|
|
6925
|
+
}
|
|
6926
|
+
}
|
|
6927
|
+
}
|
|
6928
|
+
}
|
|
6929
|
+
const containers = getDurableObjectContainerApps(config2.containers).filter(
|
|
6930
|
+
(container) => Object.keys(container.images ?? {}).length > 0
|
|
6931
|
+
);
|
|
6932
|
+
if (containers.length === 0) {
|
|
6933
|
+
return {};
|
|
6934
|
+
}
|
|
6935
|
+
const imagesByClass = [];
|
|
6936
|
+
const preparedImages = /* @__PURE__ */ new Map();
|
|
6937
|
+
for (const container of containers) {
|
|
6938
|
+
const classImages = [];
|
|
6939
|
+
for (const [imageName, imageConfig] of Object.entries(
|
|
6940
|
+
container.images ?? {}
|
|
6941
|
+
)) {
|
|
6942
|
+
const source = isRegistryImage(imageConfig) ? `image:${imageConfig.image}` : `dockerfile:${path__default.resolve(
|
|
6943
|
+
config2.configPath ? path__default.dirname(config2.configPath) : process.cwd(),
|
|
6944
|
+
imageConfig.dockerfile
|
|
6945
|
+
)}`;
|
|
6946
|
+
let image = preparedImages.get(source);
|
|
6947
|
+
if (image === void 0) {
|
|
6948
|
+
image = await buildOrResolveImage(
|
|
6949
|
+
config2,
|
|
6950
|
+
container,
|
|
6951
|
+
imageName,
|
|
6952
|
+
imageConfig,
|
|
6953
|
+
scriptName,
|
|
6954
|
+
dryRun,
|
|
6955
|
+
accountId
|
|
6956
|
+
);
|
|
6957
|
+
if (!dryRun) {
|
|
6958
|
+
const imageLine = ` ${image}`;
|
|
6959
|
+
updateStatus(
|
|
6960
|
+
`Preparing ${imageName} for Cloudflare Containers
|
|
6961
|
+
${imageLine}`
|
|
6962
|
+
);
|
|
6963
|
+
await waitForImagePreparation(image);
|
|
6964
|
+
updateStatus(`${imageName} is ready to run
|
|
6965
|
+
${imageLine}`);
|
|
6966
|
+
}
|
|
6967
|
+
preparedImages.set(source, image);
|
|
6968
|
+
}
|
|
6969
|
+
classImages.push([imageName, image]);
|
|
6970
|
+
}
|
|
6971
|
+
imagesByClass.push([container.class_name, Object.fromEntries(classImages)]);
|
|
6972
|
+
}
|
|
6973
|
+
return Object.fromEntries(imagesByClass);
|
|
6974
|
+
}
|
|
6975
|
+
__name(prepareDurableObjectContainerApplications, "prepareDurableObjectContainerApplications");
|
|
6976
|
+
async function deployDurableObjectContainerApplications(config2, {
|
|
6977
|
+
versionId,
|
|
6978
|
+
accountId,
|
|
6979
|
+
scriptName,
|
|
6980
|
+
dispatchNamespace
|
|
6981
|
+
}) {
|
|
6982
|
+
const containers = getDurableObjectContainerApps(config2.containers);
|
|
6983
|
+
if (containers.length === 0) {
|
|
6984
|
+
return;
|
|
6985
|
+
}
|
|
6986
|
+
const resolveNamespaceId = createDurableObjectNamespaceResolver(config2, {
|
|
6987
|
+
versionId,
|
|
6988
|
+
accountId,
|
|
6989
|
+
scriptName,
|
|
6990
|
+
dispatchNamespace
|
|
6991
|
+
});
|
|
6992
|
+
const applications = [];
|
|
6993
|
+
for (const container of containers) {
|
|
6994
|
+
applications.push({
|
|
6995
|
+
container,
|
|
6996
|
+
namespaceId: await resolveNamespaceId(container.class_name)
|
|
6997
|
+
});
|
|
6998
|
+
}
|
|
6999
|
+
for (const { container, namespaceId } of applications) {
|
|
7000
|
+
await createDurableObjectContainerApplication(container, namespaceId);
|
|
7001
|
+
}
|
|
7002
|
+
}
|
|
7003
|
+
__name(deployDurableObjectContainerApplications, "deployDurableObjectContainerApplications");
|
|
6740
7004
|
function hasDefinedEnvironments(config2) {
|
|
6741
7005
|
return Boolean(config2.definedEnvironments?.length);
|
|
6742
7006
|
}
|
|
@@ -6776,7 +7040,7 @@ function tagsAreEqual(a, b) {
|
|
|
6776
7040
|
__name(tagsAreEqual, "tagsAreEqual");
|
|
6777
7041
|
async function getMigrationsToUpload(scriptName, props) {
|
|
6778
7042
|
const { config: config2, accountId } = props;
|
|
6779
|
-
|
|
7043
|
+
assert5(accountId, "Missing accountId");
|
|
6780
7044
|
let migrations;
|
|
6781
7045
|
if (config2.migrations.length > 0) {
|
|
6782
7046
|
let script;
|
|
@@ -6841,8 +7105,8 @@ var suppressNotFoundError = /* @__PURE__ */ __name((err) => {
|
|
|
6841
7105
|
}, "suppressNotFoundError");
|
|
6842
7106
|
async function resolveDoLifecyclePayload(props) {
|
|
6843
7107
|
const durableObjectExports = getDurableObjectExports(props.config.exports);
|
|
6844
|
-
const
|
|
6845
|
-
if (
|
|
7108
|
+
const hasDurableObjectExports3 = Object.keys(durableObjectExports).length > 0;
|
|
7109
|
+
if (hasDurableObjectExports3) {
|
|
6846
7110
|
return {
|
|
6847
7111
|
migrations: void 0,
|
|
6848
7112
|
exports: durableObjectExports
|
|
@@ -7383,7 +7647,7 @@ var R2Handler = class extends ProvisionResourceHandler {
|
|
|
7383
7647
|
);
|
|
7384
7648
|
}
|
|
7385
7649
|
async isConnectedToExistingResource() {
|
|
7386
|
-
|
|
7650
|
+
assert5(typeof this.binding.bucket_name !== "symbol");
|
|
7387
7651
|
if (!this.binding.bucket_name) {
|
|
7388
7652
|
return false;
|
|
7389
7653
|
}
|
|
@@ -7430,7 +7694,7 @@ var AISearchNamespaceHandler = class extends ProvisionResourceHandler {
|
|
|
7430
7694
|
);
|
|
7431
7695
|
}
|
|
7432
7696
|
async isConnectedToExistingResource() {
|
|
7433
|
-
|
|
7697
|
+
assert5(typeof this.binding.namespace !== "symbol");
|
|
7434
7698
|
if (!this.binding.namespace) {
|
|
7435
7699
|
return false;
|
|
7436
7700
|
}
|
|
@@ -7473,7 +7737,7 @@ var AgentMemoryNamespaceHandler = class extends ProvisionResourceHandler {
|
|
|
7473
7737
|
);
|
|
7474
7738
|
}
|
|
7475
7739
|
async isConnectedToExistingResource() {
|
|
7476
|
-
|
|
7740
|
+
assert5(typeof this.binding.namespace !== "symbol");
|
|
7477
7741
|
if (!this.binding.namespace) {
|
|
7478
7742
|
return false;
|
|
7479
7743
|
}
|
|
@@ -7528,7 +7792,7 @@ var QueueHandler = class extends ProvisionResourceHandler {
|
|
|
7528
7792
|
return true;
|
|
7529
7793
|
}
|
|
7530
7794
|
async isConnectedToExistingResource() {
|
|
7531
|
-
|
|
7795
|
+
assert5(typeof this.binding.queue_name !== "symbol");
|
|
7532
7796
|
if (!this.binding.queue_name) {
|
|
7533
7797
|
return false;
|
|
7534
7798
|
}
|
|
@@ -7584,7 +7848,7 @@ var DispatchNamespaceHandler = class extends ProvisionResourceHandler {
|
|
|
7584
7848
|
return true;
|
|
7585
7849
|
}
|
|
7586
7850
|
async isConnectedToExistingResource() {
|
|
7587
|
-
|
|
7851
|
+
assert5(typeof this.binding.namespace !== "symbol");
|
|
7588
7852
|
if (!this.binding.namespace) {
|
|
7589
7853
|
return false;
|
|
7590
7854
|
}
|
|
@@ -7709,7 +7973,7 @@ var D1Handler = class extends ProvisionResourceHandler {
|
|
|
7709
7973
|
return false;
|
|
7710
7974
|
}
|
|
7711
7975
|
async isConnectedToExistingResource() {
|
|
7712
|
-
|
|
7976
|
+
assert5(typeof this.binding.database_name !== "symbol");
|
|
7713
7977
|
if (!this.binding.database_name) {
|
|
7714
7978
|
return false;
|
|
7715
7979
|
}
|
|
@@ -8094,7 +8358,7 @@ async function provisionBindings(bindings, accountId, scriptName, autoCreate, co
|
|
|
8094
8358
|
const configPath = config2.userConfigPath ?? config2.configPath;
|
|
8095
8359
|
const { pendingResources, skippedProvisioning } = await collectPendingResources(config2, accountId, scriptName, bindings);
|
|
8096
8360
|
if (pendingResources.length > 0) {
|
|
8097
|
-
|
|
8361
|
+
assert5(
|
|
8098
8362
|
configPath,
|
|
8099
8363
|
"Provisioning resources is not possible without a config file"
|
|
8100
8364
|
);
|
|
@@ -9191,7 +9455,7 @@ __export(util_exports, {
|
|
|
9191
9455
|
NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
|
|
9192
9456
|
aborted: () => aborted,
|
|
9193
9457
|
allowsEval: () => allowsEval,
|
|
9194
|
-
assert: () =>
|
|
9458
|
+
assert: () => assert6,
|
|
9195
9459
|
assertEqual: () => assertEqual,
|
|
9196
9460
|
assertIs: () => assertIs,
|
|
9197
9461
|
assertNever: () => assertNever,
|
|
@@ -9265,9 +9529,9 @@ function assertNever(_x) {
|
|
|
9265
9529
|
throw new Error("Unexpected value in exhaustive check");
|
|
9266
9530
|
}
|
|
9267
9531
|
__name(assertNever, "assertNever");
|
|
9268
|
-
function
|
|
9532
|
+
function assert6(_) {
|
|
9269
9533
|
}
|
|
9270
|
-
__name(
|
|
9534
|
+
__name(assert6, "assert");
|
|
9271
9535
|
function getEnumValues(entries) {
|
|
9272
9536
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
9273
9537
|
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
@@ -9365,10 +9629,10 @@ function cloneDef(schema) {
|
|
|
9365
9629
|
return mergeDefs(schema._zod.def);
|
|
9366
9630
|
}
|
|
9367
9631
|
__name(cloneDef, "cloneDef");
|
|
9368
|
-
function getElementAtPath(obj,
|
|
9369
|
-
if (!
|
|
9632
|
+
function getElementAtPath(obj, path10) {
|
|
9633
|
+
if (!path10)
|
|
9370
9634
|
return obj;
|
|
9371
|
-
return
|
|
9635
|
+
return path10.reduce((acc, key) => acc?.[key], obj);
|
|
9372
9636
|
}
|
|
9373
9637
|
__name(getElementAtPath, "getElementAtPath");
|
|
9374
9638
|
function promiseAllObject(promisesObj) {
|
|
@@ -9801,11 +10065,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
9801
10065
|
return false;
|
|
9802
10066
|
}
|
|
9803
10067
|
__name(explicitlyAborted, "explicitlyAborted");
|
|
9804
|
-
function prefixIssues(
|
|
10068
|
+
function prefixIssues(path10, issues) {
|
|
9805
10069
|
return issues.map((iss) => {
|
|
9806
10070
|
var _a3;
|
|
9807
10071
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
9808
|
-
iss.path.unshift(
|
|
10072
|
+
iss.path.unshift(path10);
|
|
9809
10073
|
return iss;
|
|
9810
10074
|
});
|
|
9811
10075
|
}
|
|
@@ -9970,16 +10234,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
9970
10234
|
__name(flattenError, "flattenError");
|
|
9971
10235
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
9972
10236
|
const fieldErrors = { _errors: [] };
|
|
9973
|
-
const processError = /* @__PURE__ */ __name((error52,
|
|
10237
|
+
const processError = /* @__PURE__ */ __name((error52, path10 = []) => {
|
|
9974
10238
|
for (const issue2 of error52.issues) {
|
|
9975
10239
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
9976
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
10240
|
+
issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
|
|
9977
10241
|
} else if (issue2.code === "invalid_key") {
|
|
9978
|
-
processError({ issues: issue2.issues }, [...
|
|
10242
|
+
processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
|
|
9979
10243
|
} else if (issue2.code === "invalid_element") {
|
|
9980
|
-
processError({ issues: issue2.issues }, [...
|
|
10244
|
+
processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
|
|
9981
10245
|
} else {
|
|
9982
|
-
const fullpath = [...
|
|
10246
|
+
const fullpath = [...path10, ...issue2.path];
|
|
9983
10247
|
if (fullpath.length === 0) {
|
|
9984
10248
|
fieldErrors._errors.push(mapper(issue2));
|
|
9985
10249
|
} else {
|
|
@@ -10007,17 +10271,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
10007
10271
|
__name(formatError, "formatError");
|
|
10008
10272
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
10009
10273
|
const result = { errors: [] };
|
|
10010
|
-
const processError = /* @__PURE__ */ __name((error52,
|
|
10274
|
+
const processError = /* @__PURE__ */ __name((error52, path10 = []) => {
|
|
10011
10275
|
var _a3, _b;
|
|
10012
10276
|
for (const issue2 of error52.issues) {
|
|
10013
10277
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
10014
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
10278
|
+
issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
|
|
10015
10279
|
} else if (issue2.code === "invalid_key") {
|
|
10016
|
-
processError({ issues: issue2.issues }, [...
|
|
10280
|
+
processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
|
|
10017
10281
|
} else if (issue2.code === "invalid_element") {
|
|
10018
|
-
processError({ issues: issue2.issues }, [...
|
|
10282
|
+
processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
|
|
10019
10283
|
} else {
|
|
10020
|
-
const fullpath = [...
|
|
10284
|
+
const fullpath = [...path10, ...issue2.path];
|
|
10021
10285
|
if (fullpath.length === 0) {
|
|
10022
10286
|
result.errors.push(mapper(issue2));
|
|
10023
10287
|
continue;
|
|
@@ -10050,8 +10314,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
10050
10314
|
__name(treeifyError, "treeifyError");
|
|
10051
10315
|
function toDotPath(_path) {
|
|
10052
10316
|
const segs = [];
|
|
10053
|
-
const
|
|
10054
|
-
for (const seg of
|
|
10317
|
+
const path10 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
10318
|
+
for (const seg of path10) {
|
|
10055
10319
|
if (typeof seg === "number")
|
|
10056
10320
|
segs.push(`[${seg}]`);
|
|
10057
10321
|
else if (typeof seg === "symbol")
|
|
@@ -11700,13 +11964,13 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
11700
11964
|
}
|
|
11701
11965
|
return propValues;
|
|
11702
11966
|
});
|
|
11703
|
-
const
|
|
11967
|
+
const isObject2 = isObject;
|
|
11704
11968
|
const catchall = def.catchall;
|
|
11705
11969
|
let value;
|
|
11706
11970
|
inst._zod.parse = (payload, ctx) => {
|
|
11707
11971
|
value ?? (value = _normalized.value);
|
|
11708
11972
|
const input = payload.value;
|
|
11709
|
-
if (!
|
|
11973
|
+
if (!isObject2(input)) {
|
|
11710
11974
|
payload.issues.push({
|
|
11711
11975
|
expected: "object",
|
|
11712
11976
|
code: "invalid_type",
|
|
@@ -11833,7 +12097,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
11833
12097
|
return (payload, ctx) => fn(shape, payload, ctx);
|
|
11834
12098
|
}, "generateFastpass");
|
|
11835
12099
|
let fastpass;
|
|
11836
|
-
const
|
|
12100
|
+
const isObject2 = isObject;
|
|
11837
12101
|
const jit = !globalConfig.jitless;
|
|
11838
12102
|
const allowsEval2 = allowsEval;
|
|
11839
12103
|
const fastEnabled = jit && allowsEval2.value;
|
|
@@ -11842,7 +12106,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
11842
12106
|
inst._zod.parse = (payload, ctx) => {
|
|
11843
12107
|
value ?? (value = _normalized.value);
|
|
11844
12108
|
const input = payload.value;
|
|
11845
|
-
if (!
|
|
12109
|
+
if (!isObject2(input)) {
|
|
11846
12110
|
payload.issues.push({
|
|
11847
12111
|
expected: "object",
|
|
11848
12112
|
code: "invalid_type",
|
|
@@ -23107,13 +23371,13 @@ function resolveRef(ref, ctx) {
|
|
|
23107
23371
|
if (!ref.startsWith("#")) {
|
|
23108
23372
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
23109
23373
|
}
|
|
23110
|
-
const
|
|
23111
|
-
if (
|
|
23374
|
+
const path10 = ref.slice(1).split("/").filter(Boolean);
|
|
23375
|
+
if (path10.length === 0) {
|
|
23112
23376
|
return ctx.rootSchema;
|
|
23113
23377
|
}
|
|
23114
23378
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
23115
|
-
if (
|
|
23116
|
-
const key =
|
|
23379
|
+
if (path10[0] === defsKey) {
|
|
23380
|
+
const key = path10[1];
|
|
23117
23381
|
if (!key || !ctx.defs[key]) {
|
|
23118
23382
|
throw new Error(`Reference not found: ${ref}`);
|
|
23119
23383
|
}
|
|
@@ -23643,12 +23907,12 @@ function getSourceMappingPrepareStackTrace(retrieveSourceMap) {
|
|
|
23643
23907
|
// Make sure we're using fresh copies of files each time we source map
|
|
23644
23908
|
emptyCacheBetweenOperations: true,
|
|
23645
23909
|
// Allow retriever to be overridden at prepare stack trace time
|
|
23646
|
-
retrieveSourceMap(
|
|
23647
|
-
return retrieveSourceMapOverride?.(
|
|
23910
|
+
retrieveSourceMap(path10) {
|
|
23911
|
+
return retrieveSourceMapOverride?.(path10) ?? null;
|
|
23648
23912
|
}
|
|
23649
23913
|
});
|
|
23650
23914
|
sourceMappingPrepareStackTrace = Error.prepareStackTrace;
|
|
23651
|
-
|
|
23915
|
+
assert5(sourceMappingPrepareStackTrace !== void 0);
|
|
23652
23916
|
Error.prepareStackTrace = originalPrepareStackTrace;
|
|
23653
23917
|
return sourceMappingPrepareStackTrace;
|
|
23654
23918
|
}
|
|
@@ -23710,7 +23974,7 @@ function getSourceMappedString(value, retrieveSourceMap) {
|
|
|
23710
23974
|
}
|
|
23711
23975
|
const callSiteLine = callSiteLines[i][0];
|
|
23712
23976
|
const callSiteAtIndex = callSiteLine.indexOf("at");
|
|
23713
|
-
|
|
23977
|
+
assert5(callSiteAtIndex !== -1);
|
|
23714
23978
|
const callSiteLineLeftPad = callSiteLine.substring(0, callSiteAtIndex);
|
|
23715
23979
|
value = value.replace(
|
|
23716
23980
|
callSiteLine,
|
|
@@ -24430,10 +24694,10 @@ function populateConfigPatch(diff, patchObj, targetEnvironment) {
|
|
|
24430
24694
|
return;
|
|
24431
24695
|
}
|
|
24432
24696
|
if (Array.isArray(diff)) {
|
|
24433
|
-
|
|
24697
|
+
assert5(Array.isArray(patchObj));
|
|
24434
24698
|
return populateConfigPatchArray(diff, patchObj);
|
|
24435
24699
|
}
|
|
24436
|
-
|
|
24700
|
+
assert5(!Array.isArray(patchObj));
|
|
24437
24701
|
return populateConfigPatchObject(diff, patchObj, targetEnvironment);
|
|
24438
24702
|
}
|
|
24439
24703
|
__name(populateConfigPatch, "populateConfigPatch");
|
|
@@ -24767,7 +25031,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
24767
25031
|
if (props.command === "deploy") {
|
|
24768
25032
|
validateEventTriggerTargets(config2, name);
|
|
24769
25033
|
validateRoutes(props.routes, props.assetsOptions);
|
|
24770
|
-
|
|
25034
|
+
assert5(
|
|
24771
25035
|
!config2.site || config2.site.bucket,
|
|
24772
25036
|
"A [site] definition requires a `bucket` field with a path to the site's assets directory."
|
|
24773
25037
|
);
|
|
@@ -24778,7 +25042,9 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
24778
25042
|
);
|
|
24779
25043
|
}
|
|
24780
25044
|
} else {
|
|
24781
|
-
if (config2.containers
|
|
25045
|
+
if (config2.containers?.some(
|
|
25046
|
+
(container) => !isDurableObjectContainerApp(container)
|
|
25047
|
+
)) {
|
|
24782
25048
|
logger.warn(
|
|
24783
25049
|
`Your Worker has Containers configured. Container configuration changes (such as image, max_instances, etc.) will not be gradually rolled out with versions. These changes will only take effect after running \`deploy\`.`
|
|
24784
25050
|
);
|
|
@@ -24804,8 +25070,20 @@ async function preUploadApiChecks(props, config2) {
|
|
|
24804
25070
|
let workerTag = null;
|
|
24805
25071
|
let tags = [];
|
|
24806
25072
|
let workerExists = true;
|
|
24807
|
-
|
|
24808
|
-
|
|
25073
|
+
if (props.command === "deploy" && props.dispatchNamespace) {
|
|
25074
|
+
try {
|
|
25075
|
+
await fetchResult(
|
|
25076
|
+
config2,
|
|
25077
|
+
`/accounts/${accountId}/workers/dispatch/namespaces/${props.dispatchNamespace}/scripts/${name}`
|
|
25078
|
+
);
|
|
25079
|
+
} catch (e) {
|
|
25080
|
+
if (typeof e === "object" && e !== null && "code" in e && e.code === 10092) {
|
|
25081
|
+
workerExists = false;
|
|
25082
|
+
} else {
|
|
25083
|
+
throw e;
|
|
25084
|
+
}
|
|
25085
|
+
}
|
|
25086
|
+
} else {
|
|
24809
25087
|
try {
|
|
24810
25088
|
const serviceMetaData = await fetchResult(config2, `/accounts/${accountId}/workers/services/${name}`);
|
|
24811
25089
|
const {
|
|
@@ -24912,7 +25190,7 @@ Edits that have been made via the script API will be overridden by your local co
|
|
|
24912
25190
|
!props.resourcesProvision,
|
|
24913
25191
|
name
|
|
24914
25192
|
);
|
|
24915
|
-
const wantsWorkersDev = props.command === "deploy" && getSubdomainValues(config2.workers_dev, config2.preview_urls, props.routes).workers_dev;
|
|
25193
|
+
const wantsWorkersDev = props.command === "deploy" && props.dispatchNamespace === void 0 && getSubdomainValues(config2.workers_dev, config2.preview_urls, props.routes).workers_dev;
|
|
24916
25194
|
if (!workerExists && wantsWorkersDev) {
|
|
24917
25195
|
await getWorkersDevSubdomain(config2, accountId, {
|
|
24918
25196
|
autoRegisterSubdomain: props.autoRegisterWorkersDevSubdomain,
|
|
@@ -24980,19 +25258,23 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
24980
25258
|
const workerUrl = props.dispatchNamespace ? `/accounts/${accountId}/workers/dispatch/namespaces/${props.dispatchNamespace}/scripts/${scriptName}` : `/accounts/${accountId}/workers/scripts/${scriptName}`;
|
|
24981
25259
|
const { format } = entry;
|
|
24982
25260
|
const { projectRoot } = entry;
|
|
25261
|
+
let latestDeployment;
|
|
24983
25262
|
if (!props.dispatchNamespace && accountId && scriptName) {
|
|
24984
|
-
const
|
|
25263
|
+
const confirmation = await confirmLatestDeploymentOverwriteAndGetLatest(
|
|
24985
25264
|
config2,
|
|
24986
25265
|
accountId,
|
|
24987
25266
|
scriptName
|
|
24988
25267
|
);
|
|
24989
|
-
|
|
25268
|
+
latestDeployment = confirmation.latestDeployment;
|
|
25269
|
+
if (!confirmation.confirmed) {
|
|
24990
25270
|
cancel("Aborting deploy...");
|
|
24991
25271
|
return { versionId, workerTag };
|
|
24992
25272
|
}
|
|
24993
25273
|
}
|
|
24994
25274
|
const isDryRun = props.dryRun;
|
|
24995
|
-
const normalisedContainerConfig =
|
|
25275
|
+
const normalisedContainerConfig = props.normalisedContainerConfig;
|
|
25276
|
+
const builtContainerDeployments = props.builtContainerDeployments;
|
|
25277
|
+
const shouldDeployContainers = normalisedContainerConfig.length > 0 && props.containersRollout !== "none";
|
|
24996
25278
|
const {
|
|
24997
25279
|
modules,
|
|
24998
25280
|
dependencies,
|
|
@@ -25001,6 +25283,22 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
25001
25283
|
content,
|
|
25002
25284
|
sourceMaps
|
|
25003
25285
|
} = buildResult;
|
|
25286
|
+
const skipContainerChanges = props.containersRollout === "none";
|
|
25287
|
+
const preparedContainerImages = skipContainerChanges ? void 0 : await prepareDurableObjectContainerApplications(config2, {
|
|
25288
|
+
accountId,
|
|
25289
|
+
dryRun: Boolean(isDryRun),
|
|
25290
|
+
scriptName,
|
|
25291
|
+
dispatchNamespace: props.dispatchNamespace
|
|
25292
|
+
});
|
|
25293
|
+
const rolloutSkipContainerState = skipContainerChanges ? await getContainerMetadataForRolloutSkip(config2, {
|
|
25294
|
+
accountId,
|
|
25295
|
+
scriptName,
|
|
25296
|
+
dispatchNamespace: props.dispatchNamespace,
|
|
25297
|
+
workerExists,
|
|
25298
|
+
latestDeployment,
|
|
25299
|
+
dryRun: isDryRun
|
|
25300
|
+
}) : void 0;
|
|
25301
|
+
const containerMetadata = rolloutSkipContainerState ? rolloutSkipContainerState.containers : getContainerMetadata(config2, preparedContainerImages);
|
|
25004
25302
|
const { migrations, exports: exports$1 } = await resolveExportsUploadPayload({
|
|
25005
25303
|
scriptName,
|
|
25006
25304
|
isDryRun,
|
|
@@ -25054,6 +25352,14 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
25054
25352
|
type: "deploy",
|
|
25055
25353
|
workerExists
|
|
25056
25354
|
});
|
|
25355
|
+
if (!skipContainerChanges && keepVars && !isDryRun && workerExists) {
|
|
25356
|
+
await clearRemovedContainerImagesBindings(config2, bindings, workerUrl);
|
|
25357
|
+
}
|
|
25358
|
+
addContainerImagesBinding(config2, bindings, preparedContainerImages ?? {}, {
|
|
25359
|
+
preserveExisting: skipContainerChanges,
|
|
25360
|
+
workerExists,
|
|
25361
|
+
hasExistingBinding: rolloutSkipContainerState?.hasExistingContainerImagesBinding
|
|
25362
|
+
});
|
|
25057
25363
|
if (workersSitesAssets.manifest) {
|
|
25058
25364
|
modules.push({
|
|
25059
25365
|
name: "__STATIC_CONTENT_MANIFEST",
|
|
@@ -25076,7 +25382,7 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
25076
25382
|
migrations,
|
|
25077
25383
|
exports: exports$1,
|
|
25078
25384
|
modules,
|
|
25079
|
-
containers:
|
|
25385
|
+
containers: containerMetadata,
|
|
25080
25386
|
sourceMaps,
|
|
25081
25387
|
compatibility_date: compatibilityDate,
|
|
25082
25388
|
compatibility_flags: compatibilityFlags,
|
|
@@ -25112,36 +25418,11 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
25112
25418
|
);
|
|
25113
25419
|
const bundleSize = await getSize([...modules, { content }]);
|
|
25114
25420
|
printBundleSize(bundleSize);
|
|
25115
|
-
const canUseNewVersionsDeploymentsApi = workerExists && props.dispatchNamespace === void 0 && format === "modules" && migrations === void 0 && !hasDurableObjectExports(config2.exports) && !config2.first_party_worker && config2.containers === void 0
|
|
25421
|
+
const canUseNewVersionsDeploymentsApi = workerExists && props.dispatchNamespace === void 0 && format === "modules" && migrations === void 0 && !hasDurableObjectExports(config2.exports) && !config2.first_party_worker && config2.containers === void 0 && // Rollout skip can recover Container metadata absent from local config.
|
|
25422
|
+
containerMetadata === void 0;
|
|
25116
25423
|
let workerBundle;
|
|
25117
25424
|
const dockerPath = getDockerPath();
|
|
25118
|
-
if (normalisedContainerConfig.length && props.containersRollout !== "none") {
|
|
25119
|
-
const containersWithDockerfile = normalisedContainerConfig.filter(
|
|
25120
|
-
(container) => "dockerfile" in container
|
|
25121
|
-
);
|
|
25122
|
-
if (containersWithDockerfile.length > 0) {
|
|
25123
|
-
await verifyDockerInstalled({
|
|
25124
|
-
dockerPath,
|
|
25125
|
-
operation: `deploying${isDryRun ? " (even in dry-run mode)" : ""}`,
|
|
25126
|
-
imageNoun: containersWithDockerfile.length !== 1 ? "the configured images" : "the configured image",
|
|
25127
|
-
hint: "If you cannot run Docker locally, you can still deploy your Worker by passing --containers-rollout=none. This will not deploy or update your Container."
|
|
25128
|
-
});
|
|
25129
|
-
}
|
|
25130
|
-
}
|
|
25131
25425
|
if (isDryRun) {
|
|
25132
|
-
if (normalisedContainerConfig.length) {
|
|
25133
|
-
for (const container of normalisedContainerConfig) {
|
|
25134
|
-
if ("dockerfile" in container && props.containersRollout !== "none" && callbacks.buildContainer) {
|
|
25135
|
-
await callbacks.buildContainer(
|
|
25136
|
-
container,
|
|
25137
|
-
workerTag ?? "worker-tag",
|
|
25138
|
-
isDryRun,
|
|
25139
|
-
dockerPath,
|
|
25140
|
-
false
|
|
25141
|
-
);
|
|
25142
|
-
}
|
|
25143
|
-
}
|
|
25144
|
-
}
|
|
25145
25426
|
workerBundle = createWorkerUploadForm(
|
|
25146
25427
|
worker,
|
|
25147
25428
|
addWorkersSitesBindings(
|
|
@@ -25164,7 +25445,7 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
25164
25445
|
unsafeMetadata: config2.unsafe?.metadata
|
|
25165
25446
|
});
|
|
25166
25447
|
} else {
|
|
25167
|
-
|
|
25448
|
+
assert5(accountId, "Missing accountId");
|
|
25168
25449
|
let provisionBindingsResult;
|
|
25169
25450
|
if (assetsOptions?.routerConfig.has_user_worker === false) {
|
|
25170
25451
|
logger.debug("skipping provisioning on assets-only project");
|
|
@@ -25386,19 +25667,67 @@ async function deployWorker(props, config2, buildResult, callbacks) {
|
|
|
25386
25667
|
}
|
|
25387
25668
|
const uploadMs = Date.now() - start;
|
|
25388
25669
|
logger.log("Uploaded", workerName, formatTime(uploadMs));
|
|
25389
|
-
if (
|
|
25390
|
-
|
|
25391
|
-
|
|
25670
|
+
if (shouldDeployContainers) {
|
|
25671
|
+
assert5(versionId && accountId);
|
|
25672
|
+
initContainersSharedContext({ logger, fetchPagedListResult, fetchResult });
|
|
25673
|
+
const containerDeployments = [];
|
|
25674
|
+
for (const container of normalisedContainerConfig) {
|
|
25675
|
+
if ("dockerfile" in container) {
|
|
25676
|
+
const builtContainerDeployment = builtContainerDeployments.find(
|
|
25677
|
+
(deployment) => deployment.container === container
|
|
25678
|
+
);
|
|
25679
|
+
assert5(
|
|
25680
|
+
builtContainerDeployment,
|
|
25681
|
+
"Expected container image to be built before upload"
|
|
25682
|
+
);
|
|
25683
|
+
containerDeployments.push({
|
|
25684
|
+
container,
|
|
25685
|
+
imageRef: await pushBuiltContainerImage(
|
|
25686
|
+
builtContainerDeployment.builtImage,
|
|
25687
|
+
versionId,
|
|
25688
|
+
dockerPath,
|
|
25689
|
+
accountId,
|
|
25690
|
+
config2
|
|
25691
|
+
)
|
|
25692
|
+
});
|
|
25693
|
+
} else {
|
|
25694
|
+
containerDeployments.push({
|
|
25695
|
+
container,
|
|
25696
|
+
imageRef: { newTag: container.image_uri }
|
|
25697
|
+
});
|
|
25698
|
+
}
|
|
25699
|
+
}
|
|
25700
|
+
await deployContainers(config2, containerDeployments, {
|
|
25392
25701
|
versionId,
|
|
25393
25702
|
accountId,
|
|
25394
|
-
scriptName
|
|
25703
|
+
scriptName,
|
|
25704
|
+
dispatchNamespace: props.dispatchNamespace
|
|
25395
25705
|
});
|
|
25396
25706
|
}
|
|
25707
|
+
if (!skipContainerChanges && getDurableObjectContainerApps(config2.containers).length > 0) {
|
|
25708
|
+
assert5(versionId && accountId);
|
|
25709
|
+
try {
|
|
25710
|
+
await deployDurableObjectContainerApplications(config2, {
|
|
25711
|
+
versionId,
|
|
25712
|
+
accountId,
|
|
25713
|
+
scriptName,
|
|
25714
|
+
dispatchNamespace: props.dispatchNamespace
|
|
25715
|
+
});
|
|
25716
|
+
} catch (error51) {
|
|
25717
|
+
throw new UserError(
|
|
25718
|
+
"The Worker version was deployed, but Wrangler could not finish creating its Durable Object-managed Container applications. Re-run the same `wrangler deploy` command to retry the idempotent application creation and finish deployment.",
|
|
25719
|
+
{
|
|
25720
|
+
telemetryMessage: "deploy durable object container application creation failed after deployment",
|
|
25721
|
+
cause: error51
|
|
25722
|
+
}
|
|
25723
|
+
);
|
|
25724
|
+
}
|
|
25725
|
+
}
|
|
25397
25726
|
if (props.dispatchNamespace !== void 0) {
|
|
25398
25727
|
deployWfpUserWorker(props.dispatchNamespace, versionId);
|
|
25399
25728
|
return { versionId, workerTag, assetUploadStats, bundleSize };
|
|
25400
25729
|
}
|
|
25401
|
-
|
|
25730
|
+
assert5(accountId);
|
|
25402
25731
|
const targets = await triggersDeploy({
|
|
25403
25732
|
config: config2,
|
|
25404
25733
|
accountId,
|
|
@@ -25462,7 +25791,10 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
|
|
|
25462
25791
|
const { entry, compatibilityDate, compatibilityFlags, keepVars, accountId } = props;
|
|
25463
25792
|
const assetsOptions = resolveAssetOptions(props, config2);
|
|
25464
25793
|
const { name } = validateWorkerProps(props, config2);
|
|
25465
|
-
const { workerTag, tags, aborted: aborted2 } = await preUploadApiChecks(
|
|
25794
|
+
const { workerTag, tags, workerExists, aborted: aborted2 } = await preUploadApiChecks(
|
|
25795
|
+
props,
|
|
25796
|
+
config2
|
|
25797
|
+
);
|
|
25466
25798
|
if (aborted2) {
|
|
25467
25799
|
return { versionId: null, workerTag };
|
|
25468
25800
|
}
|
|
@@ -25496,6 +25828,17 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
|
|
|
25496
25828
|
config: config2,
|
|
25497
25829
|
dispatchNamespace: void 0
|
|
25498
25830
|
});
|
|
25831
|
+
if (migrations !== void 0) {
|
|
25832
|
+
throw new UserError(
|
|
25833
|
+
"This Worker has a pending Durable Object migration, which cannot be applied by `wrangler versions upload`. Durable Object migrations must be applied with `wrangler deploy`. Run `wrangler deploy` to apply the migration, then retry `wrangler versions upload`.",
|
|
25834
|
+
{ telemetryMessage: "versions upload pending durable object migration" }
|
|
25835
|
+
);
|
|
25836
|
+
}
|
|
25837
|
+
const preparedContainerImages = await prepareDurableObjectContainerApplications(config2, {
|
|
25838
|
+
accountId,
|
|
25839
|
+
dryRun: Boolean(props.dryRun),
|
|
25840
|
+
scriptName
|
|
25841
|
+
});
|
|
25499
25842
|
const assetsUploadResult = assetsOptions && !props.dryRun ? await syncAssets(config2, accountId, assetsOptions.directory, scriptName) : void 0;
|
|
25500
25843
|
const assetsJwt = assetsUploadResult?.jwt;
|
|
25501
25844
|
if (props.secretsFile) {
|
|
@@ -25512,6 +25855,10 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
|
|
|
25512
25855
|
}
|
|
25513
25856
|
}
|
|
25514
25857
|
addRequiredSecretsInheritBindings(config2, bindings, { type: "upload" });
|
|
25858
|
+
if (keepVars && !props.dryRun && workerExists) {
|
|
25859
|
+
await clearRemovedContainerImagesBindings(config2, bindings, workerUrl);
|
|
25860
|
+
}
|
|
25861
|
+
addContainerImagesBinding(config2, bindings, preparedContainerImages ?? {});
|
|
25515
25862
|
const placement = parseConfigPlacement(config2);
|
|
25516
25863
|
const entryPointName = path__default.basename(resolvedEntryPointPath);
|
|
25517
25864
|
const main = {
|
|
@@ -25526,7 +25873,7 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
|
|
|
25526
25873
|
migrations,
|
|
25527
25874
|
exports: exports$1,
|
|
25528
25875
|
modules,
|
|
25529
|
-
containers: config2
|
|
25876
|
+
containers: getContainerMetadata(config2, preparedContainerImages),
|
|
25530
25877
|
sourceMaps,
|
|
25531
25878
|
compatibility_date: compatibilityDate,
|
|
25532
25879
|
compatibility_flags: compatibilityFlags,
|
|
@@ -25575,7 +25922,7 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
|
|
|
25575
25922
|
unsafeMetadata: config2.unsafe?.metadata
|
|
25576
25923
|
});
|
|
25577
25924
|
} else {
|
|
25578
|
-
|
|
25925
|
+
assert5(accountId, "Missing accountId");
|
|
25579
25926
|
let provisionBindingsResult;
|
|
25580
25927
|
if (assetsOptions?.routerConfig.has_user_worker === false) {
|
|
25581
25928
|
logger.debug("skipping provisioning on assets-only project");
|
|
@@ -25689,7 +26036,15 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
|
|
|
25689
26036
|
logger.log(`--dry-run: exiting now.`);
|
|
25690
26037
|
return { versionId, workerTag, bundleSize };
|
|
25691
26038
|
}
|
|
25692
|
-
|
|
26039
|
+
assert5(accountId);
|
|
26040
|
+
if (!hasDurableObjectExports(config2.exports) && getDurableObjectContainerApps(config2.containers).length > 0) {
|
|
26041
|
+
assert5(versionId);
|
|
26042
|
+
await deployDurableObjectContainerApplications(config2, {
|
|
26043
|
+
versionId,
|
|
26044
|
+
accountId,
|
|
26045
|
+
scriptName
|
|
26046
|
+
});
|
|
26047
|
+
}
|
|
25693
26048
|
const uploadMs = Date.now() - start;
|
|
25694
26049
|
logger.log("Uploaded", workerName, formatTime(uploadMs));
|
|
25695
26050
|
logger.log("Worker Version ID:", versionId);
|
|
@@ -25868,7 +26223,7 @@ async function getPreview(config2, accountId, workerName, previewIdentifier) {
|
|
|
25868
26223
|
);
|
|
25869
26224
|
}
|
|
25870
26225
|
__name(getPreview, "getPreview");
|
|
25871
|
-
async function createPreview(config2, accountId, workerName,
|
|
26226
|
+
async function createPreview(config2, accountId, workerName, request, options) {
|
|
25872
26227
|
const queryParams = options?.ignoreBaseConfig ? new URLSearchParams({ ignore_base_config: "true" }) : void 0;
|
|
25873
26228
|
return fetchResult(
|
|
25874
26229
|
config2,
|
|
@@ -25876,13 +26231,13 @@ async function createPreview(config2, accountId, workerName, request2, options)
|
|
|
25876
26231
|
{
|
|
25877
26232
|
method: "POST",
|
|
25878
26233
|
headers: { "Content-Type": "application/json" },
|
|
25879
|
-
body: JSON.stringify(
|
|
26234
|
+
body: JSON.stringify(request)
|
|
25880
26235
|
},
|
|
25881
26236
|
queryParams
|
|
25882
26237
|
);
|
|
25883
26238
|
}
|
|
25884
26239
|
__name(createPreview, "createPreview");
|
|
25885
|
-
async function editPreview(config2, accountId, workerName, previewIdentifier,
|
|
26240
|
+
async function editPreview(config2, accountId, workerName, previewIdentifier, request) {
|
|
25886
26241
|
return fetchResult(
|
|
25887
26242
|
config2,
|
|
25888
26243
|
`/accounts/${accountId}/workers/workers/${workerName}/previews/${encodeURIComponent(
|
|
@@ -25891,7 +26246,7 @@ async function editPreview(config2, accountId, workerName, previewIdentifier, re
|
|
|
25891
26246
|
{
|
|
25892
26247
|
method: "PATCH",
|
|
25893
26248
|
headers: { "Content-Type": "application/json" },
|
|
25894
|
-
body: JSON.stringify(
|
|
26249
|
+
body: JSON.stringify(request)
|
|
25895
26250
|
}
|
|
25896
26251
|
);
|
|
25897
26252
|
}
|
|
@@ -25917,8 +26272,8 @@ async function getPreviewDeployment(config2, accountId, workerName, previewIdent
|
|
|
25917
26272
|
);
|
|
25918
26273
|
}
|
|
25919
26274
|
__name(getPreviewDeployment, "getPreviewDeployment");
|
|
25920
|
-
function createPreviewDeploymentForm(
|
|
25921
|
-
const { modules, ...metadata } =
|
|
26275
|
+
function createPreviewDeploymentForm(request) {
|
|
26276
|
+
const { modules, ...metadata } = request;
|
|
25922
26277
|
const formData = new FormData();
|
|
25923
26278
|
formData.set("metadata", JSON.stringify(metadata));
|
|
25924
26279
|
for (const module of modules ?? []) {
|
|
@@ -25930,7 +26285,7 @@ function createPreviewDeploymentForm(request2) {
|
|
|
25930
26285
|
return formData;
|
|
25931
26286
|
}
|
|
25932
26287
|
__name(createPreviewDeploymentForm, "createPreviewDeploymentForm");
|
|
25933
|
-
async function createPreviewDeployment(config2, accountId, workerName, previewIdentifier,
|
|
26288
|
+
async function createPreviewDeployment(config2, accountId, workerName, previewIdentifier, request) {
|
|
25934
26289
|
return fetchResult(
|
|
25935
26290
|
config2,
|
|
25936
26291
|
`/accounts/${accountId}/workers/workers/${workerName}/previews/${encodeURIComponent(
|
|
@@ -25939,7 +26294,7 @@ async function createPreviewDeployment(config2, accountId, workerName, previewId
|
|
|
25939
26294
|
{
|
|
25940
26295
|
method: "POST",
|
|
25941
26296
|
// Let undici set Content-Type with the generated multipart boundary.
|
|
25942
|
-
body: createPreviewDeploymentForm(
|
|
26297
|
+
body: createPreviewDeploymentForm(request)
|
|
25943
26298
|
}
|
|
25944
26299
|
);
|
|
25945
26300
|
}
|
|
@@ -25958,27 +26313,6 @@ async function patchPreviewDeployment(config2, accountId, workerName, previewIde
|
|
|
25958
26313
|
);
|
|
25959
26314
|
}
|
|
25960
26315
|
__name(patchPreviewDeployment, "patchPreviewDeployment");
|
|
25961
|
-
async function getWorkerPreviewDefaults(config2, accountId, workerName) {
|
|
25962
|
-
const worker = await fetchResult(
|
|
25963
|
-
config2,
|
|
25964
|
-
`/accounts/${accountId}/workers/workers/${workerName}`
|
|
25965
|
-
);
|
|
25966
|
-
return worker.preview_defaults ?? {};
|
|
25967
|
-
}
|
|
25968
|
-
__name(getWorkerPreviewDefaults, "getWorkerPreviewDefaults");
|
|
25969
|
-
async function editWorkerPreviewDefaults(config2, accountId, workerName, previewDefaults) {
|
|
25970
|
-
const worker = await fetchResult(
|
|
25971
|
-
config2,
|
|
25972
|
-
`/accounts/${accountId}/workers/workers/${workerName}`,
|
|
25973
|
-
{
|
|
25974
|
-
method: "PATCH",
|
|
25975
|
-
headers: { "Content-Type": "application/json" },
|
|
25976
|
-
body: JSON.stringify({ preview_defaults: previewDefaults })
|
|
25977
|
-
}
|
|
25978
|
-
);
|
|
25979
|
-
return worker.preview_defaults ?? {};
|
|
25980
|
-
}
|
|
25981
|
-
__name(editWorkerPreviewDefaults, "editWorkerPreviewDefaults");
|
|
25982
26316
|
async function getPreviewBaseConfig(config2, accountId, workerName) {
|
|
25983
26317
|
const worker = await fetchResult(
|
|
25984
26318
|
config2,
|
|
@@ -26478,27 +26812,6 @@ function assemblePreviewScriptSettings(config2) {
|
|
|
26478
26812
|
return result;
|
|
26479
26813
|
}
|
|
26480
26814
|
__name(assemblePreviewScriptSettings, "assemblePreviewScriptSettings");
|
|
26481
|
-
function assemblePreviewDefaults(config2) {
|
|
26482
|
-
const previews = config2.previews;
|
|
26483
|
-
const previewDefaults = {
|
|
26484
|
-
...assemblePreviewScriptSettings(config2)
|
|
26485
|
-
};
|
|
26486
|
-
const previewEnv = extractConfigBindings(config2);
|
|
26487
|
-
if (Object.keys(previewEnv).length > 0) {
|
|
26488
|
-
previewDefaults.env = previewEnv;
|
|
26489
|
-
}
|
|
26490
|
-
if (previews?.limits || config2.limits) {
|
|
26491
|
-
previewDefaults.limits = previews?.limits ?? config2.limits;
|
|
26492
|
-
}
|
|
26493
|
-
if (previews?.cache !== void 0 || config2.cache !== void 0) {
|
|
26494
|
-
previewDefaults.cache = previews?.cache ?? config2.cache;
|
|
26495
|
-
}
|
|
26496
|
-
if (config2.placement) {
|
|
26497
|
-
previewDefaults.placement = parseConfigPlacement(config2);
|
|
26498
|
-
}
|
|
26499
|
-
return previewDefaults;
|
|
26500
|
-
}
|
|
26501
|
-
__name(assemblePreviewDefaults, "assemblePreviewDefaults");
|
|
26502
26815
|
function buildPreviewContainerConfig(config2, parentWorkerName, previewSlug, previewContainers) {
|
|
26503
26816
|
const previews = config2.previews;
|
|
26504
26817
|
const previewDOBindings = previews?.durable_objects?.bindings ?? [];
|
|
@@ -26582,7 +26895,107 @@ async function prepareContainersForPreview(config2, workerName, previewSlug, cal
|
|
|
26582
26895
|
return { scopedContainerConfig, normalisedContainerConfig };
|
|
26583
26896
|
}
|
|
26584
26897
|
__name(prepareContainersForPreview, "prepareContainersForPreview");
|
|
26585
|
-
var NO_ACTIVE_PREVIEW_URLS_MESSAGE = "Note: This Preview deployment has no active URLs.
|
|
26898
|
+
var NO_ACTIVE_PREVIEW_URLS_MESSAGE = "Note: This Preview deployment has no active URLs.";
|
|
26899
|
+
function isCustomDomainRoute(route) {
|
|
26900
|
+
return typeof route === "object" && route.custom_domain === true;
|
|
26901
|
+
}
|
|
26902
|
+
__name(isCustomDomainRoute, "isCustomDomainRoute");
|
|
26903
|
+
function formatPreviewConfigUpdate(config2, update) {
|
|
26904
|
+
const configPath = config2.userConfigPath ?? config2.configPath;
|
|
26905
|
+
if (!config2.targetEnvironment) {
|
|
26906
|
+
return formatConfigSnippet(update, configPath).trimEnd();
|
|
26907
|
+
}
|
|
26908
|
+
return formatConfigSnippet(
|
|
26909
|
+
{ env: { [config2.targetEnvironment]: update } },
|
|
26910
|
+
configPath
|
|
26911
|
+
).trimEnd();
|
|
26912
|
+
}
|
|
26913
|
+
__name(formatPreviewConfigUpdate, "formatPreviewConfigUpdate");
|
|
26914
|
+
function formatNoActivePreviewUrlsMessage(config2) {
|
|
26915
|
+
const customDomainRouteEntries = (config2.routes ?? []).filter(isCustomDomainRoute).map((route) => ({ route, singular: false }));
|
|
26916
|
+
if (config2.route && isCustomDomainRoute(config2.route)) {
|
|
26917
|
+
customDomainRouteEntries.push({ route: config2.route, singular: true });
|
|
26918
|
+
}
|
|
26919
|
+
const customDomainRouteEntry = customDomainRouteEntries.find(
|
|
26920
|
+
({ route }) => route.previews_enabled === true
|
|
26921
|
+
) ?? customDomainRouteEntries[0];
|
|
26922
|
+
const customDomainRoute = customDomainRouteEntry?.route;
|
|
26923
|
+
const customDomain = customDomainRoute?.pattern ?? "previews.example.com";
|
|
26924
|
+
const configPath = config2.userConfigPath ?? config2.configPath;
|
|
26925
|
+
const configName = configFileName(configPath);
|
|
26926
|
+
const workersDevConfig = formatPreviewConfigUpdate(config2, {
|
|
26927
|
+
preview_urls: true
|
|
26928
|
+
});
|
|
26929
|
+
const customDomainRouteConfig = {
|
|
26930
|
+
...customDomainRoute ?? {
|
|
26931
|
+
pattern: customDomain,
|
|
26932
|
+
custom_domain: true,
|
|
26933
|
+
enabled: false
|
|
26934
|
+
},
|
|
26935
|
+
previews_enabled: true
|
|
26936
|
+
};
|
|
26937
|
+
let customDomainConfigUpdate;
|
|
26938
|
+
if (customDomainRouteEntry?.singular) {
|
|
26939
|
+
customDomainConfigUpdate = { route: customDomainRouteConfig };
|
|
26940
|
+
} else if (customDomainRoute) {
|
|
26941
|
+
customDomainConfigUpdate = {
|
|
26942
|
+
routes: (config2.routes ?? []).map(
|
|
26943
|
+
(route) => route === customDomainRoute ? customDomainRouteConfig : route
|
|
26944
|
+
)
|
|
26945
|
+
};
|
|
26946
|
+
} else {
|
|
26947
|
+
const routes = config2.routes ?? (config2.route ? [config2.route] : []);
|
|
26948
|
+
customDomainConfigUpdate = {
|
|
26949
|
+
routes: [...routes, customDomainRouteConfig]
|
|
26950
|
+
};
|
|
26951
|
+
}
|
|
26952
|
+
const customDomainConfig = formatPreviewConfigUpdate(
|
|
26953
|
+
config2,
|
|
26954
|
+
customDomainConfigUpdate
|
|
26955
|
+
);
|
|
26956
|
+
let productionStatus = "disabled";
|
|
26957
|
+
if (customDomainRoute?.enabled === true) {
|
|
26958
|
+
productionStatus = "enabled";
|
|
26959
|
+
} else if (customDomainRoute?.enabled === void 0 && customDomainRoute) {
|
|
26960
|
+
productionStatus = "enabled (default)";
|
|
26961
|
+
}
|
|
26962
|
+
const workersDevAlreadyConfigured = config2.preview_urls === true;
|
|
26963
|
+
const customDomainAlreadyConfigured = customDomainRoute?.previews_enabled === true;
|
|
26964
|
+
const cautionText = workersDevAlreadyConfigured && customDomainAlreadyConfigured ? "Caution: `wrangler deploy` publishes the code in your current checkout to the deployed Worker. If you have already made this change, confirm it was applied by running `wrangler deploy` from a clean checkout of your production branch. Then return to your feature branch and run `wrangler preview` again." : "Caution: `wrangler deploy` publishes the code in your current checkout to the deployed Worker, not only these settings. If you use Git, commit the configuration change and run `wrangler deploy` from a clean checkout of your production branch. Then return to your feature branch and run `wrangler preview` again.";
|
|
26965
|
+
let workersDevInstruction = `Add this to your ${configName}:`;
|
|
26966
|
+
if (config2.preview_urls === true) {
|
|
26967
|
+
workersDevInstruction = `Your ${configName} already contains:`;
|
|
26968
|
+
} else if (config2.preview_urls === false) {
|
|
26969
|
+
workersDevInstruction = `Update this in your ${configName}:`;
|
|
26970
|
+
}
|
|
26971
|
+
let customDomainInstruction = `Add or update this route in your ${configName}:`;
|
|
26972
|
+
if (customDomainRoute?.previews_enabled === true) {
|
|
26973
|
+
customDomainInstruction = `Your ${configName} already contains:`;
|
|
26974
|
+
} else if (customDomainRoute === void 0 && config2.route !== void 0) {
|
|
26975
|
+
customDomainInstruction = `Replace \`route\` with this in your ${configName}:`;
|
|
26976
|
+
}
|
|
26977
|
+
return [
|
|
26978
|
+
NO_ACTIVE_PREVIEW_URLS_MESSAGE,
|
|
26979
|
+
"",
|
|
26980
|
+
"For a Workers.dev URL such as:",
|
|
26981
|
+
" https://<preview-name>-<worker>.<subdomain>.workers.dev",
|
|
26982
|
+
workersDevInstruction,
|
|
26983
|
+
workersDevConfig,
|
|
26984
|
+
"",
|
|
26985
|
+
"For a custom-domain URL such as:",
|
|
26986
|
+
` https://<preview-name>.${customDomain}`,
|
|
26987
|
+
customDomainInstruction,
|
|
26988
|
+
customDomainConfig,
|
|
26989
|
+
"Resulting route behavior:",
|
|
26990
|
+
` Production: ${productionStatus}`,
|
|
26991
|
+
" Previews: enabled",
|
|
26992
|
+
"",
|
|
26993
|
+
cautionText,
|
|
26994
|
+
"",
|
|
26995
|
+
"See https://developers.cloudflare.com/workers/previews/custom-domains/ for more information."
|
|
26996
|
+
].join("\n");
|
|
26997
|
+
}
|
|
26998
|
+
__name(formatNoActivePreviewUrlsMessage, "formatNoActivePreviewUrlsMessage");
|
|
26586
26999
|
function getPreviewMigrationsToUpload(workerName, config2, currentMigrationTag) {
|
|
26587
27000
|
if (config2.migrations.length === 0) {
|
|
26588
27001
|
return void 0;
|
|
@@ -26664,13 +27077,13 @@ function buildResultToDeploymentModules(buildResult, assetFiles) {
|
|
|
26664
27077
|
__name(buildResultToDeploymentModules, "buildResultToDeploymentModules");
|
|
26665
27078
|
async function assemblePreviewDeploymentSettings(config2, buildResult, accountId, workerName, previewIdentifier, options) {
|
|
26666
27079
|
const previews = config2.previews;
|
|
26667
|
-
const
|
|
27080
|
+
const request = {};
|
|
26668
27081
|
const deploymentModules = buildResultToDeploymentModules(buildResult, {
|
|
26669
27082
|
_headers: options.assetsOptions?._headers,
|
|
26670
27083
|
_redirects: options.assetsOptions?._redirects
|
|
26671
27084
|
});
|
|
26672
|
-
|
|
26673
|
-
|
|
27085
|
+
request.main_module = deploymentModules.main_module;
|
|
27086
|
+
request.modules = deploymentModules.modules;
|
|
26674
27087
|
if (options.assetsOptions) {
|
|
26675
27088
|
const assetsUploadResult = await syncAssets(
|
|
26676
27089
|
config2,
|
|
@@ -26678,7 +27091,7 @@ async function assemblePreviewDeploymentSettings(config2, buildResult, accountId
|
|
|
26678
27091
|
options.assetsOptions.directory,
|
|
26679
27092
|
workerName
|
|
26680
27093
|
);
|
|
26681
|
-
|
|
27094
|
+
request.assets = {
|
|
26682
27095
|
jwt: assetsUploadResult.jwt,
|
|
26683
27096
|
config: {
|
|
26684
27097
|
html_handling: options.assetsOptions.assetConfig.html_handling,
|
|
@@ -26688,16 +27101,16 @@ async function assemblePreviewDeploymentSettings(config2, buildResult, accountId
|
|
|
26688
27101
|
};
|
|
26689
27102
|
}
|
|
26690
27103
|
if (config2.compatibility_date) {
|
|
26691
|
-
|
|
27104
|
+
request.compatibility_date = config2.compatibility_date;
|
|
26692
27105
|
}
|
|
26693
27106
|
if (config2.compatibility_flags && config2.compatibility_flags.length > 0) {
|
|
26694
|
-
|
|
27107
|
+
request.compatibility_flags = config2.compatibility_flags;
|
|
26695
27108
|
}
|
|
26696
27109
|
const repositoryUrl = options.repositoryUrl;
|
|
26697
27110
|
const pullRequest = options.pullRequest;
|
|
26698
27111
|
const commitSha = options.commitSha;
|
|
26699
27112
|
if (options.message || options.tag || repositoryUrl || pullRequest || commitSha) {
|
|
26700
|
-
|
|
27113
|
+
request.annotations = {
|
|
26701
27114
|
...commitSha && { "workers/commit_sha": commitSha },
|
|
26702
27115
|
...options.message && { "workers/message": options.message },
|
|
26703
27116
|
...pullRequest?.number && {
|
|
@@ -26733,21 +27146,21 @@ async function assemblePreviewDeploymentSettings(config2, buildResult, accountId
|
|
|
26733
27146
|
latestDeploymentMigrationTag
|
|
26734
27147
|
);
|
|
26735
27148
|
if (migrations) {
|
|
26736
|
-
|
|
27149
|
+
request.migrations = migrations;
|
|
26737
27150
|
}
|
|
26738
27151
|
}
|
|
26739
27152
|
if (previews?.limits !== void 0) {
|
|
26740
|
-
|
|
27153
|
+
request.limits = previews.limits;
|
|
26741
27154
|
} else if (config2.limits !== void 0) {
|
|
26742
|
-
|
|
27155
|
+
request.limits = config2.limits;
|
|
26743
27156
|
}
|
|
26744
27157
|
if (previews?.cache !== void 0) {
|
|
26745
|
-
|
|
27158
|
+
request.cache = previews.cache;
|
|
26746
27159
|
} else if (config2.cache !== void 0) {
|
|
26747
|
-
|
|
27160
|
+
request.cache = config2.cache;
|
|
26748
27161
|
}
|
|
26749
27162
|
if (config2.placement) {
|
|
26750
|
-
|
|
27163
|
+
request.placement = parseConfigPlacement(config2);
|
|
26751
27164
|
}
|
|
26752
27165
|
const previewContainers = previews?.containers ?? [];
|
|
26753
27166
|
if (previewContainers.length > 0) {
|
|
@@ -26756,14 +27169,14 @@ async function assemblePreviewDeploymentSettings(config2, buildResult, accountId
|
|
|
26756
27169
|
({ class_name }) => class_name !== void 0 && ownedDOClasses.has(class_name) ? [{ class_name }] : []
|
|
26757
27170
|
);
|
|
26758
27171
|
if (containers.length > 0) {
|
|
26759
|
-
|
|
27172
|
+
request.containers = containers;
|
|
26760
27173
|
}
|
|
26761
27174
|
}
|
|
26762
27175
|
const env = extractConfigBindings(config2);
|
|
26763
27176
|
if (Object.keys(env).length > 0) {
|
|
26764
|
-
|
|
27177
|
+
request.env = env;
|
|
26765
27178
|
}
|
|
26766
|
-
return
|
|
27179
|
+
return request;
|
|
26767
27180
|
}
|
|
26768
27181
|
__name(assemblePreviewDeploymentSettings, "assemblePreviewDeploymentSettings");
|
|
26769
27182
|
function formatUrlLines(label, urls) {
|
|
@@ -26780,7 +27193,7 @@ function formatUrlLines(label, urls) {
|
|
|
26780
27193
|
];
|
|
26781
27194
|
}
|
|
26782
27195
|
__name(formatUrlLines, "formatUrlLines");
|
|
26783
|
-
function formatPreviewDeploymentSummary(previewResource, deployment, isNew, pullRequest) {
|
|
27196
|
+
function formatPreviewDeploymentSummary(config2, previewResource, deployment, isNew, pullRequest) {
|
|
26784
27197
|
const statusLabel = isNew ? chalk6.green("(new)") : chalk6.dim("(updated)");
|
|
26785
27198
|
const pullRequestUrl = deployment.annotations?.["workers/pull_request_url"] ?? pullRequest?.url;
|
|
26786
27199
|
const pullRequestNumber = deployment.annotations?.["workers/pull_request_number"] ?? pullRequest?.number;
|
|
@@ -26794,7 +27207,7 @@ function formatPreviewDeploymentSummary(previewResource, deployment, isNew, pull
|
|
|
26794
27207
|
...pullRequestUrl || pullRequestNumber ? [
|
|
26795
27208
|
`${chalk6.bold("Pull Request:")} ${pullRequestUrl ?? `#${pullRequestNumber}`}`
|
|
26796
27209
|
] : [],
|
|
26797
|
-
...hasActiveUrls ? [] : [
|
|
27210
|
+
...hasActiveUrls ? [] : [formatNoActivePreviewUrlsMessage(config2)]
|
|
26798
27211
|
].join("\n");
|
|
26799
27212
|
}
|
|
26800
27213
|
__name(formatPreviewDeploymentSummary, "formatPreviewDeploymentSummary");
|
|
@@ -26965,6 +27378,7 @@ async function preview(accountId, args, config2, buildResult, assetsOptions, cal
|
|
|
26965
27378
|
} else {
|
|
26966
27379
|
logger.log(
|
|
26967
27380
|
formatPreviewDeploymentSummary(
|
|
27381
|
+
config2,
|
|
26968
27382
|
previewResource,
|
|
26969
27383
|
deployment,
|
|
26970
27384
|
isNewPreview,
|
|
@@ -26973,14 +27387,14 @@ async function preview(accountId, args, config2, buildResult, assetsOptions, cal
|
|
|
26973
27387
|
);
|
|
26974
27388
|
const topLevelBindings = getBindings(config2);
|
|
26975
27389
|
if (Object.keys(topLevelBindings).length > 0) {
|
|
26976
|
-
const
|
|
27390
|
+
const previewBaseConfig = await getPreviewBaseConfig(
|
|
26977
27391
|
config2,
|
|
26978
27392
|
accountId,
|
|
26979
27393
|
workerName
|
|
26980
27394
|
);
|
|
26981
27395
|
logMissingPreviewsBindingsWarning(
|
|
26982
27396
|
topLevelBindings,
|
|
26983
|
-
|
|
27397
|
+
previewBaseConfig.env,
|
|
26984
27398
|
extractConfigBindings(config2)
|
|
26985
27399
|
);
|
|
26986
27400
|
}
|
|
@@ -27145,159 +27559,6 @@ function formatBindings(env, indent = " ", options = {}) {
|
|
|
27145
27559
|
});
|
|
27146
27560
|
}
|
|
27147
27561
|
__name(formatBindings, "formatBindings");
|
|
27148
|
-
function formatPreviewsSettings(workerName, previewDefaults) {
|
|
27149
|
-
const lines = [];
|
|
27150
|
-
lines.push(`${chalk6.bold.hex("#FFA500")("Worker:")} ${workerName}`);
|
|
27151
|
-
lines.push("");
|
|
27152
|
-
lines.push(` ${chalk6.bold.underline("Previews settings")}`);
|
|
27153
|
-
lines.push("");
|
|
27154
|
-
const settingsRows = [];
|
|
27155
|
-
if (previewDefaults.observability && typeof previewDefaults.observability === "object") {
|
|
27156
|
-
const enabledLabel = previewDefaults.observability.enabled ? "enabled" : "disabled";
|
|
27157
|
-
const sampling = typeof previewDefaults.observability.head_sampling_rate === "number" ? `, ${previewDefaults.observability.head_sampling_rate.toFixed(
|
|
27158
|
-
1
|
|
27159
|
-
)} sampling` : "";
|
|
27160
|
-
settingsRows.push(["observability", `${enabledLabel}${sampling}`]);
|
|
27161
|
-
}
|
|
27162
|
-
if (typeof previewDefaults.logpush === "boolean") {
|
|
27163
|
-
settingsRows.push([
|
|
27164
|
-
"logpush",
|
|
27165
|
-
previewDefaults.logpush ? "enabled" : "disabled"
|
|
27166
|
-
]);
|
|
27167
|
-
}
|
|
27168
|
-
if (typeof previewDefaults.limits?.cpu_ms === "number" || typeof previewDefaults.limits?.subrequests === "number") {
|
|
27169
|
-
const limitParts = [
|
|
27170
|
-
typeof previewDefaults.limits?.cpu_ms === "number" ? `cpu_ms: ${previewDefaults.limits.cpu_ms}` : void 0,
|
|
27171
|
-
typeof previewDefaults.limits?.subrequests === "number" ? `subrequests: ${previewDefaults.limits.subrequests}` : void 0
|
|
27172
|
-
].filter((value) => value !== void 0);
|
|
27173
|
-
settingsRows.push(["limits", limitParts.join(", ")]);
|
|
27174
|
-
}
|
|
27175
|
-
if (typeof previewDefaults.placement?.mode === "string") {
|
|
27176
|
-
settingsRows.push(["placement", previewDefaults.placement.mode]);
|
|
27177
|
-
}
|
|
27178
|
-
if (previewDefaults.cache !== void 0) {
|
|
27179
|
-
settingsRows.push([
|
|
27180
|
-
"cache",
|
|
27181
|
-
previewDefaults.cache.enabled ? "enabled" : "disabled"
|
|
27182
|
-
]);
|
|
27183
|
-
}
|
|
27184
|
-
if (settingsRows.length > 0) {
|
|
27185
|
-
const labelWidth = Math.max(...settingsRows.map(([label]) => label.length));
|
|
27186
|
-
for (const [label, value] of settingsRows) {
|
|
27187
|
-
lines.push(
|
|
27188
|
-
` ${chalk6.cyan(padToVisibleWidth(label, labelWidth))} ${value}`
|
|
27189
|
-
);
|
|
27190
|
-
}
|
|
27191
|
-
}
|
|
27192
|
-
lines.push("");
|
|
27193
|
-
lines.push(chalk6.bold(" Bindings"));
|
|
27194
|
-
const env = Object.fromEntries(
|
|
27195
|
-
Object.entries(previewDefaults.env ?? {}).map(([name, binding]) => [
|
|
27196
|
-
name,
|
|
27197
|
-
{ ...binding, fromConfig: false }
|
|
27198
|
-
])
|
|
27199
|
-
);
|
|
27200
|
-
lines.push(...formatBindings(env));
|
|
27201
|
-
lines.push("");
|
|
27202
|
-
return drawBox(lines);
|
|
27203
|
-
}
|
|
27204
|
-
__name(formatPreviewsSettings, "formatPreviewsSettings");
|
|
27205
|
-
|
|
27206
|
-
// src/preview/merge-deep.ts
|
|
27207
|
-
function mergeDeep(target, source) {
|
|
27208
|
-
if (typeof target !== "object" || target === null) {
|
|
27209
|
-
return source;
|
|
27210
|
-
}
|
|
27211
|
-
if (typeof source !== "object" || source === null) {
|
|
27212
|
-
return target;
|
|
27213
|
-
}
|
|
27214
|
-
const result = { ...target };
|
|
27215
|
-
for (const key of Object.keys(source)) {
|
|
27216
|
-
const srcVal = source[key];
|
|
27217
|
-
const tgtVal = target[key];
|
|
27218
|
-
if (isObject2(tgtVal) && isObject2(srcVal)) {
|
|
27219
|
-
result[key] = mergeDeep(tgtVal, srcVal);
|
|
27220
|
-
} else {
|
|
27221
|
-
result[key] = srcVal;
|
|
27222
|
-
}
|
|
27223
|
-
}
|
|
27224
|
-
return result;
|
|
27225
|
-
}
|
|
27226
|
-
__name(mergeDeep, "mergeDeep");
|
|
27227
|
-
function isObject2(value) {
|
|
27228
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27229
|
-
}
|
|
27230
|
-
__name(isObject2, "isObject");
|
|
27231
|
-
async function previewSettingsGet(accountId, args, config2) {
|
|
27232
|
-
const workerName = resolveWorkerName(args, config2);
|
|
27233
|
-
const previewDefaults = await getWorkerPreviewDefaults(
|
|
27234
|
-
config2,
|
|
27235
|
-
accountId,
|
|
27236
|
-
workerName
|
|
27237
|
-
);
|
|
27238
|
-
if (args.json) {
|
|
27239
|
-
logger.log(JSON.stringify(previewDefaults, null, 2));
|
|
27240
|
-
return;
|
|
27241
|
-
}
|
|
27242
|
-
logger.log(formatPreviewsSettings(workerName, previewDefaults));
|
|
27243
|
-
}
|
|
27244
|
-
__name(previewSettingsGet, "previewSettingsGet");
|
|
27245
|
-
async function previewSettingsUpdate(accountId, args, config2) {
|
|
27246
|
-
const workerName = resolveWorkerName(args, config2);
|
|
27247
|
-
const currentPreviewDefaults = await getWorkerPreviewDefaults(
|
|
27248
|
-
config2,
|
|
27249
|
-
accountId,
|
|
27250
|
-
workerName
|
|
27251
|
-
);
|
|
27252
|
-
const resolvedConfigFileSettings = assemblePreviewDefaults(config2);
|
|
27253
|
-
const requestPayloadPreviewDefaults = mergeDeep(
|
|
27254
|
-
currentPreviewDefaults,
|
|
27255
|
-
resolvedConfigFileSettings
|
|
27256
|
-
);
|
|
27257
|
-
if (currentPreviewDefaults.env !== void 0 || resolvedConfigFileSettings.env !== void 0) {
|
|
27258
|
-
requestPayloadPreviewDefaults.env = {
|
|
27259
|
-
...currentPreviewDefaults.env,
|
|
27260
|
-
...resolvedConfigFileSettings.env
|
|
27261
|
-
};
|
|
27262
|
-
}
|
|
27263
|
-
const diff = diffJsonObjects(
|
|
27264
|
-
currentPreviewDefaults,
|
|
27265
|
-
requestPayloadPreviewDefaults
|
|
27266
|
-
);
|
|
27267
|
-
if (!diff) {
|
|
27268
|
-
logger.log(
|
|
27269
|
-
`
|
|
27270
|
-
\u2728 Previews settings for Worker ${chalk6.bold.cyan(
|
|
27271
|
-
workerName
|
|
27272
|
-
)} are already up to date.`
|
|
27273
|
-
);
|
|
27274
|
-
return;
|
|
27275
|
-
}
|
|
27276
|
-
logger.log(`${diff}`);
|
|
27277
|
-
if (!args.skipConfirmation) {
|
|
27278
|
-
const shouldProceed = await confirm(
|
|
27279
|
-
`Apply these updates to the Previews settings of Worker ${chalk6.bold.cyan(
|
|
27280
|
-
workerName
|
|
27281
|
-
)}?`
|
|
27282
|
-
);
|
|
27283
|
-
if (!shouldProceed) {
|
|
27284
|
-
logger.log("Aborted.");
|
|
27285
|
-
return;
|
|
27286
|
-
}
|
|
27287
|
-
}
|
|
27288
|
-
const updatedPreviewDefaults = await editWorkerPreviewDefaults(
|
|
27289
|
-
config2,
|
|
27290
|
-
accountId,
|
|
27291
|
-
workerName,
|
|
27292
|
-
requestPayloadPreviewDefaults
|
|
27293
|
-
);
|
|
27294
|
-
logger.log(
|
|
27295
|
-
`
|
|
27296
|
-
\u2728 Updated Previews settings for Worker ${chalk6.bold.cyan(workerName)}.`
|
|
27297
|
-
);
|
|
27298
|
-
logger.log(formatPreviewsSettings(workerName, updatedPreviewDefaults));
|
|
27299
|
-
}
|
|
27300
|
-
__name(previewSettingsUpdate, "previewSettingsUpdate");
|
|
27301
27562
|
/*!
|
|
27302
27563
|
* Copyright (c) 2011 Felix Geisendörfer (felix@debuggable.com)
|
|
27303
27564
|
*
|
|
@@ -27320,4 +27581,4 @@ __name(previewSettingsUpdate, "previewSettingsUpdate");
|
|
|
27320
27581
|
* THE SOFTWARE.
|
|
27321
27582
|
*/
|
|
27322
27583
|
|
|
27323
|
-
export { ACTOR_BINDING_DEPENDS_ON_EXPORT_CODE, EXPORTS_RECONCILIATION_ERROR_CODE, INCONSISTENT_EXPORTS_ACROSS_VERSIONS_CODE, INVALID_INHERIT_BINDING_CODE, NO_ACTIVE_PREVIEW_URLS_MESSAGE, NoInputError, WORKER_LEGACY_ENVIRONMENT_NOT_FOUND_ERR_CODE, WORKER_NOT_FOUND_ERR_CODE, WORKFLOW_CRON_REQUIRES_PAID_PLAN_CODE, WORKFLOW_NOT_FOUND_CODE, addRequiredSecretsInheritBindings, addWorkersSitesBindings, applyServiceAndEnvironmentTags,
|
|
27584
|
+
export { ACTOR_BINDING_DEPENDS_ON_EXPORT_CODE, EXPORTS_RECONCILIATION_ERROR_CODE, INCONSISTENT_EXPORTS_ACROSS_VERSIONS_CODE, INVALID_INHERIT_BINDING_CODE, NO_ACTIVE_PREVIEW_URLS_MESSAGE, NoInputError, PREVIEW_DOMAIN_PROVISIONING_NOTE, WORKER_LEGACY_ENVIRONMENT_NOT_FOUND_ERR_CODE, WORKER_NOT_FOUND_ERR_CODE, WORKFLOW_CRON_REQUIRES_PAID_PLAN_CODE, WORKFLOW_NOT_FOUND_CODE, addRequiredSecretsInheritBindings, addWorkersSitesBindings, applyServiceAndEnvironmentTags, assemblePreviewScriptSettings, buildAssetManifest, checkRemoteSecretsOverride, checkWorkflowConflicts, collectPackageDependencies, confirmLatestDeploymentOverwrite, createDeployment, createDurableObjectContainerApplication, createPreview, createPreviewDeployment, createPreviewDeploymentForm, createPreviewParentWorker, createTruncatedAlias, decodeJwtPayload, deletePreview, deletePullConsumer, deleteWorkerConsumer, deploy, deployDurableObjectContainerApplications, deployVersionedDurableObjectContainerApplications, deployWfpUserWorker, diagnoseScriptSizeError, diagnoseStartupError, diffJsonObjects, downloadWorkerConfig, drawBox, drawConnectedChildBox, editPreview, ensureQueuesExistByConfig, extractConfigBindings, fetchDeployableVersions, fetchDeploymentVersions, fetchLatestDeployment, fetchLatestDeployments, fetchSecrets, fetchVersion, fetchVersions, fetchWorkerConfig, formatAlignedRows, formatBindings, formatNoActivePreviewUrlsMessage, generatePreviewAlias, getBindingValue, getBranchName2 as getBranchName, getCommitSha, getConfigPatch, getDeployConfirmFunction, getEdgeKvUploadConcurrency, getHeadCommitMessage, getHeadCommitRef, getMigrationsToUpload, getPreview, getPreviewBaseConfig, getPreviewDeployment, getPreviewOwnedContainerClassNames, getPullRequestMetadata, getQueue, getRemoteConfigDiff, getRepositoryUrl, getSettings, getSize, getSourceMappedStack, getSourceMappedString, getSubdomainValues, getSubdomainValuesAPIMock, getVersionedDurableObjectContainerApplications, getWorkersDevSubdomain, getZoneForRoute, getZoneIdFromHost, handleMissingSecretsError, hasDefinedEnvironments, hashFile, helpIfErrorIsSizeOrScriptStartup, isExportsReconciliationErrorDetails, isJwtExpired, isModifiedDiffValue, isNonDestructive, isWorkerNotFoundError, listConsumers, listQueues, maybeRetrieveFileSourceMap, padToVisibleWidth, parseBulkInputToObject, parseConfigPlacement, patchNonVersionedScriptSettings, patchPreviewBaseConfig, patchPreviewDeployment, postConsumer, prepareDurableObjectContainerApplications, preview, previewContainerAppName, previewDelete, printBundleSize, printVersions, provisionBindings, publishCustomDomains, publishRoutes, putConsumer, putConsumerById, renderBindingDependsOnExportError, renderExportsReconciliationError, renderExportsReconciliationSuccess, renderInconsistentExportsAcrossVersionsError, renderRoute, resolveAssetOptions, resolveDoLifecyclePayload, resolveExportsUploadPayload, resolveVersionedDurableObjectContainerApplications, resolveWorkerName, sanitizeBranchName, shouldUseCIMetadataFallback, stripAnsi, syncAssets, tagsAreEqual, triggersDeploy, updateQueueConsumers, validateEventTriggerTargets, validateFileSecrets, validateNodeCompatMode, validateRoutes, verifyWorkerMatchesCITag, versionsUpload, visibleLength, warnOnErrorUpdatingServiceAndEnvironmentTags, workerNotFoundErrorMessage };
|