@cloudflare/deploy-helpers 0.7.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-LRKPOFWK.mjs → chunk-ZV7SJ2MZ.mjs} +35 -10
- package/dist/{context-DPzCSVQh.d.mts → context-nFHuelHB.d.mts} +7 -4
- package/dist/context.d.mts +1 -1
- package/dist/create-worker-upload-form.d.mts +1 -1
- package/dist/create-worker-upload-form.mjs +1 -1
- package/dist/index.d.mts +101 -9
- package/dist/index.mjs +544 -97
- package/dist/metafile-esm.json +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { fetchResult, fetchPagedListResult, logger, confirm, fetchListResult, prompt, select } from './chunk-Z4LB73IF.mjs';
|
|
2
2
|
export { initDeployHelpersContext } from './chunk-Z4LB73IF.mjs';
|
|
3
|
-
import { extractBindingsOfType, isUnsafeBindingType, getBindings, createWorkerUploadForm, moduleTypeMimeType } from './chunk-
|
|
4
|
-
export { convertConfigToBindings, createWorkerUploadForm, extractBindingsOfType, fromMimeType, getBindings, handleUnsafeCapnp, isUnsafeBindingType, moduleTypeMimeType } from './chunk-
|
|
3
|
+
import { extractBindingsOfType, isUnsafeBindingType, getBindings, createWorkerUploadForm, moduleTypeMimeType } from './chunk-ZV7SJ2MZ.mjs';
|
|
4
|
+
export { convertConfigToBindings, createWorkerUploadForm, extractBindingsOfType, fromMimeType, getBindings, handleUnsafeCapnp, isUnsafeBindingType, moduleTypeMimeType } from './chunk-ZV7SJ2MZ.mjs';
|
|
5
5
|
import { __commonJS, __name, __require, __toESM, __export } from './chunk-Q72B4Q5Z.mjs';
|
|
6
|
-
import
|
|
6
|
+
import assert4 from 'node:assert';
|
|
7
7
|
import { readFileSync, mkdirSync, writeFileSync, createReadStream } from 'node:fs';
|
|
8
8
|
import * as path from 'node:path';
|
|
9
|
-
import path__default, { resolve,
|
|
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
12
|
import { cancel } from '@cloudflare/cli-shared-helpers';
|
|
13
|
-
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, getBindingTypeFriendlyName, getBindingLocalSupport, assertNever, experimental_readRawConfig, experimental_patchConfig, PatchConfigError, COMPLIANCE_REGION_CONFIG_UNKNOWN, constructWranglerConfig, getCIMatchTag, formatConfigSnippet, DEFAULT_COMPAT_DATE, hasDurableObjectExports, getDockerPath, parseNonHyphenedUuid, getWorkersCIBranchName } from '@cloudflare/workers-utils';
|
|
13
|
+
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, getBindingTypeFriendlyName, getBindingLocalSupport, assertNever, experimental_readRawConfig, experimental_patchConfig, PatchConfigError, COMPLIANCE_REGION_CONFIG_UNKNOWN, constructWranglerConfig, getCIMatchTag, formatConfigSnippet, DEFAULT_COMPAT_DATE, writeOutput, hasDurableObjectExports, getDockerPath, parseNonHyphenedUuid, getWorkersCIBranchName } from '@cloudflare/workers-utils';
|
|
14
14
|
import { execSync, spawn } from 'node:child_process';
|
|
15
15
|
import { Response, FormData } from 'undici';
|
|
16
16
|
import chalk6 from 'chalk';
|
|
@@ -30,7 +30,7 @@ import { createHash } from 'node:crypto';
|
|
|
30
30
|
|
|
31
31
|
// ../../node_modules/.pnpm/ignore@5.3.1/node_modules/ignore/index.js
|
|
32
32
|
var require_ignore = __commonJS({
|
|
33
|
-
"../../node_modules/.pnpm/ignore@5.3.1/node_modules/ignore/index.js"(exports, module) {
|
|
33
|
+
"../../node_modules/.pnpm/ignore@5.3.1/node_modules/ignore/index.js"(exports$1, module) {
|
|
34
34
|
function makeArray(subject) {
|
|
35
35
|
return Array.isArray(subject) ? subject : [subject];
|
|
36
36
|
}
|
|
@@ -417,7 +417,7 @@ var require_ignore = __commonJS({
|
|
|
417
417
|
|
|
418
418
|
// ../../node_modules/.pnpm/heap@0.2.7/node_modules/heap/lib/heap.js
|
|
419
419
|
var require_heap = __commonJS({
|
|
420
|
-
"../../node_modules/.pnpm/heap@0.2.7/node_modules/heap/lib/heap.js"(exports, module) {
|
|
420
|
+
"../../node_modules/.pnpm/heap@0.2.7/node_modules/heap/lib/heap.js"(exports$1, module) {
|
|
421
421
|
(function() {
|
|
422
422
|
var Heap, defaultCmp, floor, heapify, heappop, heappush, heappushpop, heapreplace, insort, min, nlargest, nsmallest, updateItem, _siftdown, _siftup;
|
|
423
423
|
floor = Math.floor, min = Math.min;
|
|
@@ -679,7 +679,7 @@ var require_heap = __commonJS({
|
|
|
679
679
|
(function(root, factory) {
|
|
680
680
|
if (typeof define === "function" && define.amd) {
|
|
681
681
|
return define([], factory);
|
|
682
|
-
} else if (typeof exports === "object") {
|
|
682
|
+
} else if (typeof exports$1 === "object") {
|
|
683
683
|
return module.exports = factory();
|
|
684
684
|
} else {
|
|
685
685
|
return root.Heap = factory();
|
|
@@ -687,25 +687,25 @@ var require_heap = __commonJS({
|
|
|
687
687
|
})(this, function() {
|
|
688
688
|
return Heap;
|
|
689
689
|
});
|
|
690
|
-
}).call(exports);
|
|
690
|
+
}).call(exports$1);
|
|
691
691
|
}
|
|
692
692
|
});
|
|
693
693
|
|
|
694
694
|
// ../../node_modules/.pnpm/heap@0.2.7/node_modules/heap/index.js
|
|
695
695
|
var require_heap2 = __commonJS({
|
|
696
|
-
"../../node_modules/.pnpm/heap@0.2.7/node_modules/heap/index.js"(exports, module) {
|
|
696
|
+
"../../node_modules/.pnpm/heap@0.2.7/node_modules/heap/index.js"(exports$1, module) {
|
|
697
697
|
module.exports = require_heap();
|
|
698
698
|
}
|
|
699
699
|
});
|
|
700
700
|
|
|
701
701
|
// ../../node_modules/.pnpm/@ewoudenberg+difflib@0.1.0/node_modules/@ewoudenberg/difflib/lib/difflib.js
|
|
702
702
|
var require_difflib = __commonJS({
|
|
703
|
-
"../../node_modules/.pnpm/@ewoudenberg+difflib@0.1.0/node_modules/@ewoudenberg/difflib/lib/difflib.js"(exports) {
|
|
703
|
+
"../../node_modules/.pnpm/@ewoudenberg+difflib@0.1.0/node_modules/@ewoudenberg/difflib/lib/difflib.js"(exports$1) {
|
|
704
704
|
(function() {
|
|
705
|
-
var Differ, Heap, IS_CHARACTER_JUNK, IS_LINE_JUNK, SequenceMatcher, _any2, _arrayCmp, _calculateRatio, _countLeading, _formatRangeContext, _formatRangeUnified, _has,
|
|
705
|
+
var Differ, Heap, IS_CHARACTER_JUNK, IS_LINE_JUNK, SequenceMatcher, _any2, _arrayCmp, _calculateRatio, _countLeading, _formatRangeContext, _formatRangeUnified, _has, assert11, contextDiff, floor, getCloseMatches, max, min, ndiff, restore, unifiedDiff, indexOf = [].indexOf;
|
|
706
706
|
({ floor, max, min } = Math);
|
|
707
707
|
Heap = require_heap2();
|
|
708
|
-
|
|
708
|
+
assert11 = __require("assert");
|
|
709
709
|
_calculateRatio = /* @__PURE__ */ __name(function(matches, length) {
|
|
710
710
|
if (length) {
|
|
711
711
|
return 2 * matches / length;
|
|
@@ -1276,7 +1276,7 @@ var require_difflib = __commonJS({
|
|
|
1276
1276
|
}
|
|
1277
1277
|
_plainReplace(a, alo, ahi, b, blo, bhi) {
|
|
1278
1278
|
var first, g, l, len, len1, line, lines, m, ref, second;
|
|
1279
|
-
|
|
1279
|
+
assert11(alo < ahi && blo < bhi);
|
|
1280
1280
|
if (bhi - blo < ahi - alo) {
|
|
1281
1281
|
first = this._dump("+", b, blo, bhi);
|
|
1282
1282
|
second = this._dump("-", a, alo, ahi);
|
|
@@ -1620,33 +1620,33 @@ var require_difflib = __commonJS({
|
|
|
1620
1620
|
}
|
|
1621
1621
|
return lines;
|
|
1622
1622
|
}, "restore");
|
|
1623
|
-
exports._arrayCmp = _arrayCmp;
|
|
1624
|
-
exports.SequenceMatcher = SequenceMatcher;
|
|
1625
|
-
exports.getCloseMatches = getCloseMatches;
|
|
1626
|
-
exports._countLeading = _countLeading;
|
|
1627
|
-
exports.Differ = Differ;
|
|
1628
|
-
exports.IS_LINE_JUNK = IS_LINE_JUNK;
|
|
1629
|
-
exports.IS_CHARACTER_JUNK = IS_CHARACTER_JUNK;
|
|
1630
|
-
exports._formatRangeUnified = _formatRangeUnified;
|
|
1631
|
-
exports.unifiedDiff = unifiedDiff;
|
|
1632
|
-
exports._formatRangeContext = _formatRangeContext;
|
|
1633
|
-
exports.contextDiff = contextDiff;
|
|
1634
|
-
exports.ndiff = ndiff;
|
|
1635
|
-
exports.restore = restore;
|
|
1636
|
-
}).call(exports);
|
|
1623
|
+
exports$1._arrayCmp = _arrayCmp;
|
|
1624
|
+
exports$1.SequenceMatcher = SequenceMatcher;
|
|
1625
|
+
exports$1.getCloseMatches = getCloseMatches;
|
|
1626
|
+
exports$1._countLeading = _countLeading;
|
|
1627
|
+
exports$1.Differ = Differ;
|
|
1628
|
+
exports$1.IS_LINE_JUNK = IS_LINE_JUNK;
|
|
1629
|
+
exports$1.IS_CHARACTER_JUNK = IS_CHARACTER_JUNK;
|
|
1630
|
+
exports$1._formatRangeUnified = _formatRangeUnified;
|
|
1631
|
+
exports$1.unifiedDiff = unifiedDiff;
|
|
1632
|
+
exports$1._formatRangeContext = _formatRangeContext;
|
|
1633
|
+
exports$1.contextDiff = contextDiff;
|
|
1634
|
+
exports$1.ndiff = ndiff;
|
|
1635
|
+
exports$1.restore = restore;
|
|
1636
|
+
}).call(exports$1);
|
|
1637
1637
|
}
|
|
1638
1638
|
});
|
|
1639
1639
|
|
|
1640
1640
|
// ../../node_modules/.pnpm/@ewoudenberg+difflib@0.1.0/node_modules/@ewoudenberg/difflib/index.js
|
|
1641
1641
|
var require_difflib2 = __commonJS({
|
|
1642
|
-
"../../node_modules/.pnpm/@ewoudenberg+difflib@0.1.0/node_modules/@ewoudenberg/difflib/index.js"(exports, module) {
|
|
1642
|
+
"../../node_modules/.pnpm/@ewoudenberg+difflib@0.1.0/node_modules/@ewoudenberg/difflib/index.js"(exports$1, module) {
|
|
1643
1643
|
module.exports = require_difflib();
|
|
1644
1644
|
}
|
|
1645
1645
|
});
|
|
1646
1646
|
|
|
1647
1647
|
// ../../node_modules/.pnpm/json-diff@1.0.6/node_modules/json-diff/lib/util.js
|
|
1648
1648
|
var require_util = __commonJS({
|
|
1649
|
-
"../../node_modules/.pnpm/json-diff@1.0.6/node_modules/json-diff/lib/util.js"(exports, module) {
|
|
1649
|
+
"../../node_modules/.pnpm/json-diff@1.0.6/node_modules/json-diff/lib/util.js"(exports$1, module) {
|
|
1650
1650
|
var extendedTypeOf = /* @__PURE__ */ __name(function(obj) {
|
|
1651
1651
|
const result = typeof obj;
|
|
1652
1652
|
if (obj == null) {
|
|
@@ -1680,7 +1680,7 @@ var require_util = __commonJS({
|
|
|
1680
1680
|
|
|
1681
1681
|
// ../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/styles.js
|
|
1682
1682
|
var require_styles = __commonJS({
|
|
1683
|
-
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/styles.js"(exports, module) {
|
|
1683
|
+
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/styles.js"(exports$1, module) {
|
|
1684
1684
|
var styles = {};
|
|
1685
1685
|
module["exports"] = styles;
|
|
1686
1686
|
var codes = {
|
|
@@ -1747,7 +1747,7 @@ var require_styles = __commonJS({
|
|
|
1747
1747
|
|
|
1748
1748
|
// ../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/system/has-flag.js
|
|
1749
1749
|
var require_has_flag = __commonJS({
|
|
1750
|
-
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/system/has-flag.js"(exports, module) {
|
|
1750
|
+
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/system/has-flag.js"(exports$1, module) {
|
|
1751
1751
|
module.exports = function(flag, argv) {
|
|
1752
1752
|
argv = argv || process.argv;
|
|
1753
1753
|
var terminatorPos = argv.indexOf("--");
|
|
@@ -1760,7 +1760,7 @@ var require_has_flag = __commonJS({
|
|
|
1760
1760
|
|
|
1761
1761
|
// ../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/system/supports-colors.js
|
|
1762
1762
|
var require_supports_colors = __commonJS({
|
|
1763
|
-
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/system/supports-colors.js"(exports, module) {
|
|
1763
|
+
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/system/supports-colors.js"(exports$1, module) {
|
|
1764
1764
|
var os = __require("os");
|
|
1765
1765
|
var hasFlag = require_has_flag();
|
|
1766
1766
|
var env = process.env;
|
|
@@ -1858,7 +1858,7 @@ var require_supports_colors = __commonJS({
|
|
|
1858
1858
|
|
|
1859
1859
|
// ../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/custom/trap.js
|
|
1860
1860
|
var require_trap = __commonJS({
|
|
1861
|
-
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/custom/trap.js"(exports, module) {
|
|
1861
|
+
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/custom/trap.js"(exports$1, module) {
|
|
1862
1862
|
module["exports"] = /* @__PURE__ */ __name(function runTheTrap(text, options) {
|
|
1863
1863
|
var result = "";
|
|
1864
1864
|
text = text || "Run the trap, drop the bass";
|
|
@@ -1927,7 +1927,7 @@ var require_trap = __commonJS({
|
|
|
1927
1927
|
|
|
1928
1928
|
// ../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/custom/zalgo.js
|
|
1929
1929
|
var require_zalgo = __commonJS({
|
|
1930
|
-
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/custom/zalgo.js"(exports, module) {
|
|
1930
|
+
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/custom/zalgo.js"(exports$1, module) {
|
|
1931
1931
|
module["exports"] = /* @__PURE__ */ __name(function zalgo(text, options) {
|
|
1932
1932
|
text = text || " he is here ";
|
|
1933
1933
|
var soul = {
|
|
@@ -2117,7 +2117,7 @@ var require_zalgo = __commonJS({
|
|
|
2117
2117
|
|
|
2118
2118
|
// ../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/maps/america.js
|
|
2119
2119
|
var require_america = __commonJS({
|
|
2120
|
-
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/maps/america.js"(exports, module) {
|
|
2120
|
+
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/maps/america.js"(exports$1, module) {
|
|
2121
2121
|
module["exports"] = function(colors) {
|
|
2122
2122
|
return function(letter, i, exploded) {
|
|
2123
2123
|
if (letter === " ") return letter;
|
|
@@ -2136,7 +2136,7 @@ var require_america = __commonJS({
|
|
|
2136
2136
|
|
|
2137
2137
|
// ../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/maps/zebra.js
|
|
2138
2138
|
var require_zebra = __commonJS({
|
|
2139
|
-
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/maps/zebra.js"(exports, module) {
|
|
2139
|
+
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/maps/zebra.js"(exports$1, module) {
|
|
2140
2140
|
module["exports"] = function(colors) {
|
|
2141
2141
|
return function(letter, i, exploded) {
|
|
2142
2142
|
return i % 2 === 0 ? letter : colors.inverse(letter);
|
|
@@ -2147,7 +2147,7 @@ var require_zebra = __commonJS({
|
|
|
2147
2147
|
|
|
2148
2148
|
// ../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/maps/rainbow.js
|
|
2149
2149
|
var require_rainbow = __commonJS({
|
|
2150
|
-
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/maps/rainbow.js"(exports, module) {
|
|
2150
|
+
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/maps/rainbow.js"(exports$1, module) {
|
|
2151
2151
|
module["exports"] = function(colors) {
|
|
2152
2152
|
var rainbowColors = ["red", "yellow", "green", "blue", "magenta"];
|
|
2153
2153
|
return function(letter, i, exploded) {
|
|
@@ -2163,7 +2163,7 @@ var require_rainbow = __commonJS({
|
|
|
2163
2163
|
|
|
2164
2164
|
// ../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/maps/random.js
|
|
2165
2165
|
var require_random = __commonJS({
|
|
2166
|
-
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/maps/random.js"(exports, module) {
|
|
2166
|
+
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/maps/random.js"(exports$1, module) {
|
|
2167
2167
|
module["exports"] = function(colors) {
|
|
2168
2168
|
var available = [
|
|
2169
2169
|
"underline",
|
|
@@ -2193,7 +2193,7 @@ var require_random = __commonJS({
|
|
|
2193
2193
|
|
|
2194
2194
|
// ../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/colors.js
|
|
2195
2195
|
var require_colors = __commonJS({
|
|
2196
|
-
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/colors.js"(exports, module) {
|
|
2196
|
+
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/lib/colors.js"(exports$1, module) {
|
|
2197
2197
|
var colors = {};
|
|
2198
2198
|
module["exports"] = colors;
|
|
2199
2199
|
colors.themes = {};
|
|
@@ -2340,7 +2340,7 @@ var require_colors = __commonJS({
|
|
|
2340
2340
|
|
|
2341
2341
|
// ../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/safe.js
|
|
2342
2342
|
var require_safe = __commonJS({
|
|
2343
|
-
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/safe.js"(exports, module) {
|
|
2343
|
+
"../../node_modules/.pnpm/colors@1.4.0/node_modules/colors/safe.js"(exports$1, module) {
|
|
2344
2344
|
var colors = require_colors();
|
|
2345
2345
|
module["exports"] = colors;
|
|
2346
2346
|
}
|
|
@@ -2348,7 +2348,7 @@ var require_safe = __commonJS({
|
|
|
2348
2348
|
|
|
2349
2349
|
// ../../node_modules/.pnpm/json-diff@1.0.6/node_modules/json-diff/lib/colorize.js
|
|
2350
2350
|
var require_colorize = __commonJS({
|
|
2351
|
-
"../../node_modules/.pnpm/json-diff@1.0.6/node_modules/json-diff/lib/colorize.js"(exports, module) {
|
|
2351
|
+
"../../node_modules/.pnpm/json-diff@1.0.6/node_modules/json-diff/lib/colorize.js"(exports$1, module) {
|
|
2352
2352
|
var color = require_safe();
|
|
2353
2353
|
var { extendedTypeOf } = require_util();
|
|
2354
2354
|
var Theme = {
|
|
@@ -2460,7 +2460,7 @@ var require_colorize = __commonJS({
|
|
|
2460
2460
|
|
|
2461
2461
|
// ../../node_modules/.pnpm/json-diff@1.0.6/node_modules/json-diff/lib/index.js
|
|
2462
2462
|
var require_lib = __commonJS({
|
|
2463
|
-
"../../node_modules/.pnpm/json-diff@1.0.6/node_modules/json-diff/lib/index.js"(exports, module) {
|
|
2463
|
+
"../../node_modules/.pnpm/json-diff@1.0.6/node_modules/json-diff/lib/index.js"(exports$1, module) {
|
|
2464
2464
|
var { SequenceMatcher } = require_difflib2();
|
|
2465
2465
|
var { extendedTypeOf, roundObj } = require_util();
|
|
2466
2466
|
var { colorize, colorizeToCallback } = require_colorize();
|
|
@@ -4216,8 +4216,19 @@ __name(registerSubdomain, "registerSubdomain");
|
|
|
4216
4216
|
|
|
4217
4217
|
// src/triggers/deploy.ts
|
|
4218
4218
|
async function triggersDeploy(props) {
|
|
4219
|
-
const { config: config2,
|
|
4220
|
-
|
|
4219
|
+
const { config: config2, scriptName, routes, crons } = props;
|
|
4220
|
+
if (props.validated !== true) {
|
|
4221
|
+
validateEventTriggerTargets(config2, scriptName);
|
|
4222
|
+
}
|
|
4223
|
+
if (props.dryRun) {
|
|
4224
|
+
logger.log(`--dry-run: exiting now.`);
|
|
4225
|
+
return;
|
|
4226
|
+
}
|
|
4227
|
+
const { accountId } = props;
|
|
4228
|
+
assert4(accountId);
|
|
4229
|
+
if (props.validated !== true) {
|
|
4230
|
+
await ensureQueuesExistByConfig(config2, accountId, true, scriptName);
|
|
4231
|
+
}
|
|
4221
4232
|
const routesOnly = [];
|
|
4222
4233
|
const customDomainsOnly = [];
|
|
4223
4234
|
for (const route of routes) {
|
|
@@ -4403,6 +4414,14 @@ ${dashLink}`, {
|
|
|
4403
4414
|
}
|
|
4404
4415
|
);
|
|
4405
4416
|
}
|
|
4417
|
+
if (workflow.default_retention) {
|
|
4418
|
+
throw new UserError(
|
|
4419
|
+
`Workflow "${workflow.name}" has "default_retention" configured but references external script "${workflow.script_name}". Configure default_retention on the worker that defines the workflow.`,
|
|
4420
|
+
{
|
|
4421
|
+
telemetryMessage: "triggers deploy workflow default_retention external script"
|
|
4422
|
+
}
|
|
4423
|
+
);
|
|
4424
|
+
}
|
|
4406
4425
|
continue;
|
|
4407
4426
|
}
|
|
4408
4427
|
workflowDeployments.push({
|
|
@@ -4418,6 +4437,9 @@ ${dashLink}`, {
|
|
|
4418
4437
|
...workflow.limits && { limits: workflow.limits },
|
|
4419
4438
|
...workflow.schedules && {
|
|
4420
4439
|
schedules: (Array.isArray(workflow.schedules) ? workflow.schedules : [workflow.schedules]).map((cron) => ({ cron }))
|
|
4440
|
+
},
|
|
4441
|
+
...workflow.default_retention && {
|
|
4442
|
+
default_retention: workflow.default_retention
|
|
4421
4443
|
}
|
|
4422
4444
|
}),
|
|
4423
4445
|
headers: {
|
|
@@ -6129,7 +6151,7 @@ var MAX_UPLOAD_ATTEMPTS = 5;
|
|
|
6129
6151
|
var MAX_UPLOAD_GATEWAY_ERRORS = 5;
|
|
6130
6152
|
var MAX_DIFF_LINES = 100;
|
|
6131
6153
|
var syncAssets = /* @__PURE__ */ __name(async (complianceConfig, accountId, assetDirectory, scriptName, dispatchNamespace) => {
|
|
6132
|
-
|
|
6154
|
+
assert4(accountId, "Missing accountId");
|
|
6133
6155
|
logger.info("\u{1F300} Building list of assets...");
|
|
6134
6156
|
const manifest = await buildAssetManifest(assetDirectory);
|
|
6135
6157
|
const url3 = dispatchNamespace ? `/accounts/${accountId}/workers/dispatch/namespaces/${dispatchNamespace}/scripts/${scriptName}/assets-upload-session` : `/accounts/${accountId}/workers/scripts/${scriptName}/assets-upload-session`;
|
|
@@ -6743,7 +6765,7 @@ function tagsAreEqual(a, b) {
|
|
|
6743
6765
|
__name(tagsAreEqual, "tagsAreEqual");
|
|
6744
6766
|
async function getMigrationsToUpload(scriptName, props) {
|
|
6745
6767
|
const { config: config2, accountId } = props;
|
|
6746
|
-
|
|
6768
|
+
assert4(accountId, "Missing accountId");
|
|
6747
6769
|
let migrations;
|
|
6748
6770
|
if (config2.migrations.length > 0) {
|
|
6749
6771
|
let script;
|
|
@@ -6831,13 +6853,13 @@ __name(resolveDoLifecyclePayload, "resolveDoLifecyclePayload");
|
|
|
6831
6853
|
async function resolveExportsUploadPayload(props) {
|
|
6832
6854
|
const partitionedExports = partitionExports(props.config.exports);
|
|
6833
6855
|
const { migrations, exports: durableObjectExports } = await resolveDoLifecyclePayload(props);
|
|
6834
|
-
const exports = {
|
|
6856
|
+
const exports$1 = {
|
|
6835
6857
|
...partitionedExports.worker,
|
|
6836
6858
|
...durableObjectExports ?? {}
|
|
6837
6859
|
};
|
|
6838
6860
|
return {
|
|
6839
6861
|
migrations,
|
|
6840
|
-
exports: Object.keys(exports).length > 0 ? exports : void 0
|
|
6862
|
+
exports: Object.keys(exports$1).length > 0 ? exports$1 : void 0
|
|
6841
6863
|
};
|
|
6842
6864
|
}
|
|
6843
6865
|
__name(resolveExportsUploadPayload, "resolveExportsUploadPayload");
|
|
@@ -7373,7 +7395,7 @@ function printBindings(bindings, tailConsumers = [], streamingTailConsumers = []
|
|
|
7373
7395
|
}
|
|
7374
7396
|
if (workflows.length > 0) {
|
|
7375
7397
|
output.push(
|
|
7376
|
-
...workflows.map(({ class_name, script_name, binding
|
|
7398
|
+
...workflows.map(({ class_name, script_name, binding }) => {
|
|
7377
7399
|
let value = class_name;
|
|
7378
7400
|
if (script_name) {
|
|
7379
7401
|
value += ` (defined in ${script_name})`;
|
|
@@ -7383,7 +7405,7 @@ function printBindings(bindings, tailConsumers = [], streamingTailConsumers = []
|
|
|
7383
7405
|
type: getBindingTypeFriendlyName("workflow"),
|
|
7384
7406
|
value,
|
|
7385
7407
|
mode: getMode({
|
|
7386
|
-
isSimulatedLocally:
|
|
7408
|
+
isSimulatedLocally: true
|
|
7387
7409
|
})
|
|
7388
7410
|
};
|
|
7389
7411
|
})
|
|
@@ -8179,7 +8201,7 @@ var R2Handler = class extends ProvisionResourceHandler {
|
|
|
8179
8201
|
);
|
|
8180
8202
|
}
|
|
8181
8203
|
async isConnectedToExistingResource() {
|
|
8182
|
-
|
|
8204
|
+
assert4(typeof this.binding.bucket_name !== "symbol");
|
|
8183
8205
|
if (!this.binding.bucket_name) {
|
|
8184
8206
|
return false;
|
|
8185
8207
|
}
|
|
@@ -8226,7 +8248,7 @@ var AISearchNamespaceHandler = class extends ProvisionResourceHandler {
|
|
|
8226
8248
|
);
|
|
8227
8249
|
}
|
|
8228
8250
|
async isConnectedToExistingResource() {
|
|
8229
|
-
|
|
8251
|
+
assert4(typeof this.binding.namespace !== "symbol");
|
|
8230
8252
|
if (!this.binding.namespace) {
|
|
8231
8253
|
return false;
|
|
8232
8254
|
}
|
|
@@ -8269,7 +8291,7 @@ var AgentMemoryNamespaceHandler = class extends ProvisionResourceHandler {
|
|
|
8269
8291
|
);
|
|
8270
8292
|
}
|
|
8271
8293
|
async isConnectedToExistingResource() {
|
|
8272
|
-
|
|
8294
|
+
assert4(typeof this.binding.namespace !== "symbol");
|
|
8273
8295
|
if (!this.binding.namespace) {
|
|
8274
8296
|
return false;
|
|
8275
8297
|
}
|
|
@@ -8324,7 +8346,7 @@ var QueueHandler = class extends ProvisionResourceHandler {
|
|
|
8324
8346
|
return true;
|
|
8325
8347
|
}
|
|
8326
8348
|
async isConnectedToExistingResource() {
|
|
8327
|
-
|
|
8349
|
+
assert4(typeof this.binding.queue_name !== "symbol");
|
|
8328
8350
|
if (!this.binding.queue_name) {
|
|
8329
8351
|
return false;
|
|
8330
8352
|
}
|
|
@@ -8380,7 +8402,7 @@ var DispatchNamespaceHandler = class extends ProvisionResourceHandler {
|
|
|
8380
8402
|
return true;
|
|
8381
8403
|
}
|
|
8382
8404
|
async isConnectedToExistingResource() {
|
|
8383
|
-
|
|
8405
|
+
assert4(typeof this.binding.namespace !== "symbol");
|
|
8384
8406
|
if (!this.binding.namespace) {
|
|
8385
8407
|
return false;
|
|
8386
8408
|
}
|
|
@@ -8505,7 +8527,7 @@ var D1Handler = class extends ProvisionResourceHandler {
|
|
|
8505
8527
|
return false;
|
|
8506
8528
|
}
|
|
8507
8529
|
async isConnectedToExistingResource() {
|
|
8508
|
-
|
|
8530
|
+
assert4(typeof this.binding.database_name !== "symbol");
|
|
8509
8531
|
if (!this.binding.database_name) {
|
|
8510
8532
|
return false;
|
|
8511
8533
|
}
|
|
@@ -8826,7 +8848,7 @@ async function provisionBindings(bindings, accountId, scriptName, autoCreate, co
|
|
|
8826
8848
|
bindings
|
|
8827
8849
|
);
|
|
8828
8850
|
if (pendingResources.length > 0) {
|
|
8829
|
-
|
|
8851
|
+
assert4(
|
|
8830
8852
|
configPath,
|
|
8831
8853
|
"Provisioning resources is not possible without a config file"
|
|
8832
8854
|
);
|
|
@@ -9904,7 +9926,7 @@ __export(util_exports, {
|
|
|
9904
9926
|
NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
|
|
9905
9927
|
aborted: () => aborted,
|
|
9906
9928
|
allowsEval: () => allowsEval,
|
|
9907
|
-
assert: () =>
|
|
9929
|
+
assert: () => assert5,
|
|
9908
9930
|
assertEqual: () => assertEqual,
|
|
9909
9931
|
assertIs: () => assertIs,
|
|
9910
9932
|
assertNever: () => assertNever2,
|
|
@@ -9978,9 +10000,9 @@ function assertNever2(_x) {
|
|
|
9978
10000
|
throw new Error("Unexpected value in exhaustive check");
|
|
9979
10001
|
}
|
|
9980
10002
|
__name(assertNever2, "assertNever");
|
|
9981
|
-
function
|
|
10003
|
+
function assert5(_) {
|
|
9982
10004
|
}
|
|
9983
|
-
__name(
|
|
10005
|
+
__name(assert5, "assert");
|
|
9984
10006
|
function getEnumValues(entries) {
|
|
9985
10007
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
9986
10008
|
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
@@ -24361,7 +24383,7 @@ function getSourceMappingPrepareStackTrace(retrieveSourceMap) {
|
|
|
24361
24383
|
}
|
|
24362
24384
|
});
|
|
24363
24385
|
sourceMappingPrepareStackTrace = Error.prepareStackTrace;
|
|
24364
|
-
|
|
24386
|
+
assert4(sourceMappingPrepareStackTrace !== void 0);
|
|
24365
24387
|
Error.prepareStackTrace = originalPrepareStackTrace;
|
|
24366
24388
|
return sourceMappingPrepareStackTrace;
|
|
24367
24389
|
}
|
|
@@ -24423,7 +24445,7 @@ function getSourceMappedString(value, retrieveSourceMap) {
|
|
|
24423
24445
|
}
|
|
24424
24446
|
const callSiteLine = callSiteLines[i][0];
|
|
24425
24447
|
const callSiteAtIndex = callSiteLine.indexOf("at");
|
|
24426
|
-
|
|
24448
|
+
assert4(callSiteAtIndex !== -1);
|
|
24427
24449
|
const callSiteLineLeftPad = callSiteLine.substring(0, callSiteAtIndex);
|
|
24428
24450
|
value = value.replace(
|
|
24429
24451
|
callSiteLine,
|
|
@@ -24888,11 +24910,6 @@ function removeRemoteConfigFieldFromBindings(normalizedConfig) {
|
|
|
24888
24910
|
({ remote: _, ...binding }) => binding
|
|
24889
24911
|
);
|
|
24890
24912
|
}
|
|
24891
|
-
if (normalizedConfig.workflows?.length) {
|
|
24892
|
-
normalizedConfig.workflows = normalizedConfig.workflows.map(
|
|
24893
|
-
({ remote: _, ...binding }) => binding
|
|
24894
|
-
);
|
|
24895
|
-
}
|
|
24896
24913
|
if (normalizedConfig.dispatch_namespaces?.length) {
|
|
24897
24914
|
normalizedConfig.dispatch_namespaces = normalizedConfig.dispatch_namespaces.map(
|
|
24898
24915
|
({ remote: _, ...binding }) => binding
|
|
@@ -25147,10 +25164,10 @@ function populateConfigPatch(diff, patchObj, targetEnvironment) {
|
|
|
25147
25164
|
return;
|
|
25148
25165
|
}
|
|
25149
25166
|
if (Array.isArray(diff)) {
|
|
25150
|
-
|
|
25167
|
+
assert4(Array.isArray(patchObj));
|
|
25151
25168
|
return populateConfigPatchArray(diff, patchObj);
|
|
25152
25169
|
}
|
|
25153
|
-
|
|
25170
|
+
assert4(!Array.isArray(patchObj));
|
|
25154
25171
|
return populateConfigPatchObject(diff, patchObj, targetEnvironment);
|
|
25155
25172
|
}
|
|
25156
25173
|
__name(populateConfigPatch, "populateConfigPatch");
|
|
@@ -25484,7 +25501,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
25484
25501
|
if (props.command === "deploy") {
|
|
25485
25502
|
validateEventTriggerTargets(config2, name);
|
|
25486
25503
|
validateRoutes(props.routes, props.assetsOptions);
|
|
25487
|
-
|
|
25504
|
+
assert4(
|
|
25488
25505
|
!config2.site || config2.site.bucket,
|
|
25489
25506
|
"A [site] definition requires a `bucket` field with a path to the site's assets directory."
|
|
25490
25507
|
);
|
|
@@ -25661,6 +25678,21 @@ __name(addWorkersSitesBindings, "addWorkersSitesBindings");
|
|
|
25661
25678
|
|
|
25662
25679
|
// src/deploy/deploy.ts
|
|
25663
25680
|
async function deploy(props, config2, buildResult, callbacks) {
|
|
25681
|
+
const result = await deployWorker(props, config2, buildResult, callbacks);
|
|
25682
|
+
writeOutput({
|
|
25683
|
+
type: "deploy",
|
|
25684
|
+
version: 1,
|
|
25685
|
+
worker_name: props.name ?? null,
|
|
25686
|
+
worker_tag: result.workerTag,
|
|
25687
|
+
version_id: result.versionId,
|
|
25688
|
+
targets: result.targets,
|
|
25689
|
+
wrangler_environment: props.env,
|
|
25690
|
+
worker_name_overridden: props.workerNameOverridden ?? false
|
|
25691
|
+
});
|
|
25692
|
+
return result;
|
|
25693
|
+
}
|
|
25694
|
+
__name(deploy, "deploy");
|
|
25695
|
+
async function deployWorker(props, config2, buildResult, callbacks) {
|
|
25664
25696
|
const { entry, compatibilityDate, compatibilityFlags, keepVars, accountId } = props;
|
|
25665
25697
|
const assetsOptions = resolveAssetOptions(props, config2);
|
|
25666
25698
|
const { name } = validateWorkerProps({ ...props, assetsOptions }, config2);
|
|
@@ -25699,7 +25731,7 @@ async function deploy(props, config2, buildResult, callbacks) {
|
|
|
25699
25731
|
content,
|
|
25700
25732
|
sourceMaps
|
|
25701
25733
|
} = buildResult;
|
|
25702
|
-
const { migrations, exports } = await resolveExportsUploadPayload({
|
|
25734
|
+
const { migrations, exports: exports$1 } = await resolveExportsUploadPayload({
|
|
25703
25735
|
scriptName,
|
|
25704
25736
|
isDryRun,
|
|
25705
25737
|
accountId,
|
|
@@ -25772,7 +25804,7 @@ async function deploy(props, config2, buildResult, callbacks) {
|
|
|
25772
25804
|
name: scriptName,
|
|
25773
25805
|
main,
|
|
25774
25806
|
migrations,
|
|
25775
|
-
exports,
|
|
25807
|
+
exports: exports$1,
|
|
25776
25808
|
modules,
|
|
25777
25809
|
containers: config2.containers,
|
|
25778
25810
|
sourceMaps,
|
|
@@ -25863,7 +25895,7 @@ async function deploy(props, config2, buildResult, callbacks) {
|
|
|
25863
25895
|
{ warnIfNoBindings: true, unsafeMetadata: config2.unsafe?.metadata }
|
|
25864
25896
|
);
|
|
25865
25897
|
} else {
|
|
25866
|
-
|
|
25898
|
+
assert4(accountId, "Missing accountId");
|
|
25867
25899
|
if (assetsOptions?.routerConfig.has_user_worker === false) {
|
|
25868
25900
|
logger.debug("skipping provisioning on assets-only project");
|
|
25869
25901
|
} else if (props.resourcesProvision) {
|
|
@@ -26084,7 +26116,7 @@ async function deploy(props, config2, buildResult, callbacks) {
|
|
|
26084
26116
|
const uploadMs = Date.now() - start;
|
|
26085
26117
|
logger.log("Uploaded", workerName, formatTime(uploadMs));
|
|
26086
26118
|
if (normalisedContainerConfig.length && props.containersRollout !== "none" && callbacks.deployContainers) {
|
|
26087
|
-
|
|
26119
|
+
assert4(versionId && accountId);
|
|
26088
26120
|
await callbacks.deployContainers(config2, normalisedContainerConfig, {
|
|
26089
26121
|
versionId,
|
|
26090
26122
|
accountId,
|
|
@@ -26095,16 +26127,17 @@ async function deploy(props, config2, buildResult, callbacks) {
|
|
|
26095
26127
|
deployWfpUserWorker(props.dispatchNamespace, versionId);
|
|
26096
26128
|
return { versionId, workerTag, assetUploadStats };
|
|
26097
26129
|
}
|
|
26098
|
-
|
|
26130
|
+
assert4(accountId);
|
|
26099
26131
|
const targets = await triggersDeploy({
|
|
26100
26132
|
config: config2,
|
|
26101
26133
|
accountId,
|
|
26102
26134
|
scriptName,
|
|
26103
26135
|
workerTag,
|
|
26104
|
-
env: props.env,
|
|
26105
26136
|
crons: props.triggers,
|
|
26106
26137
|
firstDeploy: !workerExists,
|
|
26107
|
-
routes: props.routes
|
|
26138
|
+
routes: props.routes,
|
|
26139
|
+
validated: true,
|
|
26140
|
+
dryRun: false
|
|
26108
26141
|
});
|
|
26109
26142
|
logger.log("Current Version ID:", versionId);
|
|
26110
26143
|
return {
|
|
@@ -26115,7 +26148,7 @@ async function deploy(props, config2, buildResult, callbacks) {
|
|
|
26115
26148
|
targets: targets ?? []
|
|
26116
26149
|
};
|
|
26117
26150
|
}
|
|
26118
|
-
__name(
|
|
26151
|
+
__name(deployWorker, "deployWorker");
|
|
26119
26152
|
|
|
26120
26153
|
// src/deploy/helpers/binding-depends-on-export.ts
|
|
26121
26154
|
function renderBindingDependsOnExportError(serverMessage) {
|
|
@@ -26129,6 +26162,27 @@ __name(renderBindingDependsOnExportError, "renderBindingDependsOnExportError");
|
|
|
26129
26162
|
|
|
26130
26163
|
// src/deploy/versions-upload.ts
|
|
26131
26164
|
async function versionsUpload(props, config2, buildResult, callbacks) {
|
|
26165
|
+
const result = await uploadWorkerVersion(
|
|
26166
|
+
props,
|
|
26167
|
+
config2,
|
|
26168
|
+
buildResult,
|
|
26169
|
+
callbacks
|
|
26170
|
+
);
|
|
26171
|
+
writeOutput({
|
|
26172
|
+
type: "version-upload",
|
|
26173
|
+
version: 1,
|
|
26174
|
+
worker_name: props.name ?? null,
|
|
26175
|
+
worker_tag: result.workerTag,
|
|
26176
|
+
version_id: result.versionId,
|
|
26177
|
+
preview_url: result.versionPreviewUrl,
|
|
26178
|
+
preview_alias_url: result.versionPreviewAliasUrl,
|
|
26179
|
+
wrangler_environment: props.env,
|
|
26180
|
+
worker_name_overridden: props.workerNameOverridden ?? false
|
|
26181
|
+
});
|
|
26182
|
+
return result;
|
|
26183
|
+
}
|
|
26184
|
+
__name(versionsUpload, "versionsUpload");
|
|
26185
|
+
async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
|
|
26132
26186
|
const { entry, compatibilityDate, compatibilityFlags, keepVars, accountId } = props;
|
|
26133
26187
|
const assetsOptions = resolveAssetOptions(props, config2);
|
|
26134
26188
|
const { name } = validateWorkerProps(props, config2);
|
|
@@ -26159,7 +26213,7 @@ async function versionsUpload(props, config2, buildResult, callbacks) {
|
|
|
26159
26213
|
hidden: true
|
|
26160
26214
|
};
|
|
26161
26215
|
}
|
|
26162
|
-
const { migrations, exports } = await resolveExportsUploadPayload({
|
|
26216
|
+
const { migrations, exports: exports$1 } = await resolveExportsUploadPayload({
|
|
26163
26217
|
scriptName,
|
|
26164
26218
|
isDryRun: props.dryRun,
|
|
26165
26219
|
accountId,
|
|
@@ -26194,7 +26248,7 @@ async function versionsUpload(props, config2, buildResult, callbacks) {
|
|
|
26194
26248
|
name: scriptName,
|
|
26195
26249
|
main,
|
|
26196
26250
|
migrations,
|
|
26197
|
-
exports,
|
|
26251
|
+
exports: exports$1,
|
|
26198
26252
|
modules,
|
|
26199
26253
|
containers: config2.containers,
|
|
26200
26254
|
sourceMaps,
|
|
@@ -26248,7 +26302,7 @@ async function versionsUpload(props, config2, buildResult, callbacks) {
|
|
|
26248
26302
|
{ unsafeMetadata: config2.unsafe?.metadata }
|
|
26249
26303
|
);
|
|
26250
26304
|
} else {
|
|
26251
|
-
|
|
26305
|
+
assert4(accountId, "Missing accountId");
|
|
26252
26306
|
if (assetsOptions?.routerConfig.has_user_worker === false) {
|
|
26253
26307
|
logger.debug("skipping provisioning on assets-only project");
|
|
26254
26308
|
} else if (props.resourcesProvision) {
|
|
@@ -26362,7 +26416,7 @@ async function versionsUpload(props, config2, buildResult, callbacks) {
|
|
|
26362
26416
|
logger.log(`--dry-run: exiting now.`);
|
|
26363
26417
|
return { versionId, workerTag };
|
|
26364
26418
|
}
|
|
26365
|
-
|
|
26419
|
+
assert4(accountId);
|
|
26366
26420
|
const uploadMs = Date.now() - start;
|
|
26367
26421
|
logger.log("Uploaded", workerName, formatTime(uploadMs));
|
|
26368
26422
|
logger.log("Worker Version ID:", versionId);
|
|
@@ -26402,7 +26456,19 @@ Changes to triggers (routes, custom domains, cron schedules, etc) must be applie
|
|
|
26402
26456
|
versionPreviewAliasUrl
|
|
26403
26457
|
};
|
|
26404
26458
|
}
|
|
26405
|
-
__name(
|
|
26459
|
+
__name(uploadWorkerVersion, "uploadWorkerVersion");
|
|
26460
|
+
var SHORT_HASH_LENGTH = 7;
|
|
26461
|
+
function truncateWithSuffix(body, suffix, maxLength) {
|
|
26462
|
+
const maxBodyLength = Math.max(0, maxLength - suffix.length);
|
|
26463
|
+
return `${body.slice(0, maxBodyLength)}${suffix}`;
|
|
26464
|
+
}
|
|
26465
|
+
__name(truncateWithSuffix, "truncateWithSuffix");
|
|
26466
|
+
function shortHash(input) {
|
|
26467
|
+
return createHash("sha256").update(input).digest().readUInt32BE(0).toString(36).padStart(SHORT_HASH_LENGTH, "0");
|
|
26468
|
+
}
|
|
26469
|
+
__name(shortHash, "shortHash");
|
|
26470
|
+
|
|
26471
|
+
// src/deploy/helpers/preview-alias.ts
|
|
26406
26472
|
var MAX_DNS_LABEL_LENGTH = 63;
|
|
26407
26473
|
var HASH_LENGTH = 4;
|
|
26408
26474
|
var ALIAS_VALIDATION_REGEX = /^[a-z](?:[a-z0-9-]*[a-z0-9])?$/i;
|
|
@@ -26424,14 +26490,12 @@ function getBranchName() {
|
|
|
26424
26490
|
}
|
|
26425
26491
|
__name(getBranchName, "getBranchName");
|
|
26426
26492
|
function createTruncatedAlias(branchName, sanitizedAlias, availableSpace) {
|
|
26427
|
-
const
|
|
26428
|
-
const
|
|
26429
|
-
if (
|
|
26493
|
+
const hash2 = createHash("sha256").update(branchName).digest("hex").slice(0, HASH_LENGTH);
|
|
26494
|
+
const suffix = `-${hash2}`;
|
|
26495
|
+
if (availableSpace - suffix.length < 1) {
|
|
26430
26496
|
return void 0;
|
|
26431
26497
|
}
|
|
26432
|
-
|
|
26433
|
-
const truncatedPrefix = sanitizedAlias.slice(0, maxPrefixLength);
|
|
26434
|
-
return `${truncatedPrefix}-${hash2}`;
|
|
26498
|
+
return truncateWithSuffix(sanitizedAlias, suffix, availableSpace);
|
|
26435
26499
|
}
|
|
26436
26500
|
__name(createTruncatedAlias, "createTruncatedAlias");
|
|
26437
26501
|
function generatePreviewAlias(scriptName) {
|
|
@@ -26509,6 +26573,20 @@ function renderInconsistentExportsAcrossVersionsError(serverMessage) {
|
|
|
26509
26573
|
__name(renderInconsistentExportsAcrossVersionsError, "renderInconsistentExportsAcrossVersionsError");
|
|
26510
26574
|
|
|
26511
26575
|
// src/preview/api.ts
|
|
26576
|
+
async function createPreviewParentWorker(config2, accountId, workerName, workersDevEnabled, previewsEnabled) {
|
|
26577
|
+
await fetchResult(config2, `/accounts/${accountId}/workers/workers`, {
|
|
26578
|
+
method: "POST",
|
|
26579
|
+
headers: { "Content-Type": "application/json" },
|
|
26580
|
+
body: JSON.stringify({
|
|
26581
|
+
name: workerName,
|
|
26582
|
+
subdomain: {
|
|
26583
|
+
enabled: workersDevEnabled,
|
|
26584
|
+
previews_enabled: previewsEnabled
|
|
26585
|
+
}
|
|
26586
|
+
})
|
|
26587
|
+
});
|
|
26588
|
+
}
|
|
26589
|
+
__name(createPreviewParentWorker, "createPreviewParentWorker");
|
|
26512
26590
|
async function getPreview(config2, accountId, workerName, previewIdentifier) {
|
|
26513
26591
|
return fetchResult(
|
|
26514
26592
|
config2,
|
|
@@ -26637,6 +26715,7 @@ async function patchPreviewBaseConfig(config2, accountId, workerName, previewBas
|
|
|
26637
26715
|
return worker.previews_base_config ?? {};
|
|
26638
26716
|
}
|
|
26639
26717
|
__name(patchPreviewBaseConfig, "patchPreviewBaseConfig");
|
|
26718
|
+
var MAX_CONTAINER_APP_NAME_LENGTH = 253;
|
|
26640
26719
|
function getBranchName2() {
|
|
26641
26720
|
const workersCIBranch = getWorkersCIBranchName();
|
|
26642
26721
|
if (workersCIBranch) {
|
|
@@ -26680,6 +26759,141 @@ function getHeadCommitMessage() {
|
|
|
26680
26759
|
}
|
|
26681
26760
|
}
|
|
26682
26761
|
__name(getHeadCommitMessage, "getHeadCommitMessage");
|
|
26762
|
+
function getCommitSha() {
|
|
26763
|
+
return process.env.GITHUB_SHA || process.env.CI_COMMIT_SHA || process.env.CIRCLE_SHA1 || process.env.COMMIT_SHA || void 0;
|
|
26764
|
+
}
|
|
26765
|
+
__name(getCommitSha, "getCommitSha");
|
|
26766
|
+
function normalizeRepositoryUrl(repositoryUrl) {
|
|
26767
|
+
const trimmed = repositoryUrl.trim();
|
|
26768
|
+
if (!trimmed) {
|
|
26769
|
+
return void 0;
|
|
26770
|
+
}
|
|
26771
|
+
const scpLikeSshMatch = trimmed.match(/^git@([^:]+):(.+)$/);
|
|
26772
|
+
if (scpLikeSshMatch) {
|
|
26773
|
+
const [, host, pathname] = scpLikeSshMatch;
|
|
26774
|
+
return `https://${host}/${pathname.replace(/\.git$/, "")}`;
|
|
26775
|
+
}
|
|
26776
|
+
try {
|
|
26777
|
+
const url3 = new URL(trimmed);
|
|
26778
|
+
if (url3.protocol === "ssh:" && url3.username === "git") {
|
|
26779
|
+
return `https://${url3.host}${url3.pathname.replace(/\.git$/, "")}`;
|
|
26780
|
+
}
|
|
26781
|
+
if (url3.protocol !== "https:" && url3.protocol !== "http:") {
|
|
26782
|
+
return void 0;
|
|
26783
|
+
}
|
|
26784
|
+
url3.username = "";
|
|
26785
|
+
url3.password = "";
|
|
26786
|
+
url3.search = "";
|
|
26787
|
+
url3.hash = "";
|
|
26788
|
+
url3.pathname = url3.pathname.replace(/\.git$/, "");
|
|
26789
|
+
return url3.toString().replace(/\/$/, "");
|
|
26790
|
+
} catch {
|
|
26791
|
+
return void 0;
|
|
26792
|
+
}
|
|
26793
|
+
}
|
|
26794
|
+
__name(normalizeRepositoryUrl, "normalizeRepositoryUrl");
|
|
26795
|
+
function getRepositoryUrl() {
|
|
26796
|
+
const repositoryUrl = process.env.CI_PROJECT_URL || process.env.CI_REPOSITORY_URL || process.env.CIRCLE_REPOSITORY_URL || process.env.BUILDKITE_REPO || process.env.BITBUCKET_GIT_HTTP_ORIGIN || process.env.BITBUCKET_GIT_SSH_ORIGIN || process.env.REPOSITORY_URL;
|
|
26797
|
+
if (repositoryUrl) {
|
|
26798
|
+
return normalizeRepositoryUrl(repositoryUrl);
|
|
26799
|
+
}
|
|
26800
|
+
if (process.env.GITHUB_REPOSITORY) {
|
|
26801
|
+
const githubServerUrl = process.env.GITHUB_SERVER_URL || "https://github.com";
|
|
26802
|
+
return normalizeRepositoryUrl(
|
|
26803
|
+
`${githubServerUrl.replace(/\/$/, "")}/${process.env.GITHUB_REPOSITORY}`
|
|
26804
|
+
);
|
|
26805
|
+
}
|
|
26806
|
+
if (!shouldUseCIMetadataFallback()) {
|
|
26807
|
+
return void 0;
|
|
26808
|
+
}
|
|
26809
|
+
try {
|
|
26810
|
+
execSync(`git rev-parse --is-inside-work-tree`, { stdio: "ignore" });
|
|
26811
|
+
return normalizeRepositoryUrl(
|
|
26812
|
+
execSync(`git config --get remote.origin.url`).toString()
|
|
26813
|
+
);
|
|
26814
|
+
} catch {
|
|
26815
|
+
return void 0;
|
|
26816
|
+
}
|
|
26817
|
+
}
|
|
26818
|
+
__name(getRepositoryUrl, "getRepositoryUrl");
|
|
26819
|
+
function normalizePullRequestNumber(number4) {
|
|
26820
|
+
if (number4 === void 0) {
|
|
26821
|
+
return void 0;
|
|
26822
|
+
}
|
|
26823
|
+
const normalizedNumber = String(number4).trim();
|
|
26824
|
+
return normalizedNumber ? normalizedNumber : void 0;
|
|
26825
|
+
}
|
|
26826
|
+
__name(normalizePullRequestNumber, "normalizePullRequestNumber");
|
|
26827
|
+
function normalizePullRequestTitle(title) {
|
|
26828
|
+
if (title === void 0) {
|
|
26829
|
+
return void 0;
|
|
26830
|
+
}
|
|
26831
|
+
const trimmedTitle = title.trim();
|
|
26832
|
+
return trimmedTitle || void 0;
|
|
26833
|
+
}
|
|
26834
|
+
__name(normalizePullRequestTitle, "normalizePullRequestTitle");
|
|
26835
|
+
function getGitHubPullRequestMetadata() {
|
|
26836
|
+
if (process.env.GITHUB_EVENT_PATH) {
|
|
26837
|
+
try {
|
|
26838
|
+
const event = JSON.parse(
|
|
26839
|
+
readFileSync(process.env.GITHUB_EVENT_PATH, "utf8")
|
|
26840
|
+
);
|
|
26841
|
+
const number5 = normalizePullRequestNumber(event.pull_request?.number);
|
|
26842
|
+
const url3 = event.pull_request?.html_url ? normalizeRepositoryUrl(event.pull_request.html_url) : void 0;
|
|
26843
|
+
const title = normalizePullRequestTitle(event.pull_request?.title);
|
|
26844
|
+
if (number5 || url3 || title) {
|
|
26845
|
+
return { number: number5, url: url3, title };
|
|
26846
|
+
}
|
|
26847
|
+
} catch {
|
|
26848
|
+
}
|
|
26849
|
+
}
|
|
26850
|
+
const refPullRequestNumber = process.env.GITHUB_REF?.match(/^refs\/pull\/(\d+)\//)?.[1];
|
|
26851
|
+
const number4 = normalizePullRequestNumber(refPullRequestNumber);
|
|
26852
|
+
if (!number4 || !process.env.GITHUB_REPOSITORY) {
|
|
26853
|
+
return void 0;
|
|
26854
|
+
}
|
|
26855
|
+
const githubServerUrl = process.env.GITHUB_SERVER_URL || "https://github.com";
|
|
26856
|
+
return {
|
|
26857
|
+
number: number4,
|
|
26858
|
+
url: normalizeRepositoryUrl(
|
|
26859
|
+
`${githubServerUrl.replace(/\/$/, "")}/${process.env.GITHUB_REPOSITORY}/pull/${number4}`
|
|
26860
|
+
)
|
|
26861
|
+
};
|
|
26862
|
+
}
|
|
26863
|
+
__name(getGitHubPullRequestMetadata, "getGitHubPullRequestMetadata");
|
|
26864
|
+
function getGitLabPullRequestMetadata() {
|
|
26865
|
+
const number4 = normalizePullRequestNumber(process.env.CI_MERGE_REQUEST_IID);
|
|
26866
|
+
const projectUrl = process.env.CI_MERGE_REQUEST_PROJECT_URL || process.env.CI_PROJECT_URL;
|
|
26867
|
+
if (!number4 || !projectUrl) {
|
|
26868
|
+
return void 0;
|
|
26869
|
+
}
|
|
26870
|
+
const normalizedProjectUrl = projectUrl.replace(/\.git$/, "").replace(/\/$/, "");
|
|
26871
|
+
return {
|
|
26872
|
+
number: number4,
|
|
26873
|
+
url: normalizeRepositoryUrl(
|
|
26874
|
+
`${normalizedProjectUrl}/-/merge_requests/${number4}`
|
|
26875
|
+
),
|
|
26876
|
+
title: normalizePullRequestTitle(process.env.CI_MERGE_REQUEST_TITLE)
|
|
26877
|
+
};
|
|
26878
|
+
}
|
|
26879
|
+
__name(getGitLabPullRequestMetadata, "getGitLabPullRequestMetadata");
|
|
26880
|
+
function getDirectPullRequestMetadata() {
|
|
26881
|
+
const directUrl = process.env.PULL_REQUEST_URL || process.env.PR_URL || process.env.CHANGE_URL || process.env.CIRCLE_PULL_REQUEST;
|
|
26882
|
+
const number4 = normalizePullRequestNumber(
|
|
26883
|
+
process.env.PULL_REQUEST_NUMBER || process.env.PR_NUMBER || process.env.CHANGE_ID
|
|
26884
|
+
);
|
|
26885
|
+
const url3 = directUrl ? normalizeRepositoryUrl(directUrl) : void 0;
|
|
26886
|
+
const title = normalizePullRequestTitle(process.env.PULL_REQUEST_TITLE);
|
|
26887
|
+
if (number4 || url3 || title) {
|
|
26888
|
+
return { number: number4, url: url3, title };
|
|
26889
|
+
}
|
|
26890
|
+
return void 0;
|
|
26891
|
+
}
|
|
26892
|
+
__name(getDirectPullRequestMetadata, "getDirectPullRequestMetadata");
|
|
26893
|
+
function getPullRequestMetadata() {
|
|
26894
|
+
return getDirectPullRequestMetadata() ?? getGitHubPullRequestMetadata() ?? getGitLabPullRequestMetadata();
|
|
26895
|
+
}
|
|
26896
|
+
__name(getPullRequestMetadata, "getPullRequestMetadata");
|
|
26683
26897
|
function resolveWorkerName(args, config2) {
|
|
26684
26898
|
const workerName = args.workerName ?? args["worker-name"] ?? config2.name;
|
|
26685
26899
|
if (!workerName) {
|
|
@@ -26910,6 +27124,56 @@ function extractConfigBindings(config2) {
|
|
|
26910
27124
|
return env;
|
|
26911
27125
|
}
|
|
26912
27126
|
__name(extractConfigBindings, "extractConfigBindings");
|
|
27127
|
+
function getDeclaredDOClassNames(config2) {
|
|
27128
|
+
const declared = /* @__PURE__ */ new Set();
|
|
27129
|
+
for (const migration of config2.migrations ?? []) {
|
|
27130
|
+
for (const className of migration.deleted_classes ?? []) {
|
|
27131
|
+
declared.delete(className);
|
|
27132
|
+
}
|
|
27133
|
+
for (const { from, to } of migration.renamed_classes ?? []) {
|
|
27134
|
+
declared.delete(from);
|
|
27135
|
+
declared.add(to);
|
|
27136
|
+
}
|
|
27137
|
+
for (const className of migration.new_classes ?? []) {
|
|
27138
|
+
declared.add(className);
|
|
27139
|
+
}
|
|
27140
|
+
for (const className of migration.new_sqlite_classes ?? []) {
|
|
27141
|
+
declared.add(className);
|
|
27142
|
+
}
|
|
27143
|
+
}
|
|
27144
|
+
for (const [className, entry] of Object.entries(
|
|
27145
|
+
getDurableObjectExports(config2.exports)
|
|
27146
|
+
)) {
|
|
27147
|
+
if (entry.state === void 0 || entry.state === "created" || entry.state === "expecting-transfer") {
|
|
27148
|
+
declared.add(className);
|
|
27149
|
+
}
|
|
27150
|
+
}
|
|
27151
|
+
return declared;
|
|
27152
|
+
}
|
|
27153
|
+
__name(getDeclaredDOClassNames, "getDeclaredDOClassNames");
|
|
27154
|
+
function getPreviewOwnedContainerClassNames(config2, previews) {
|
|
27155
|
+
const owned = getDeclaredDOClassNames(config2);
|
|
27156
|
+
for (const binding of previews?.durable_objects?.bindings ?? []) {
|
|
27157
|
+
if (binding.script_name === void 0) {
|
|
27158
|
+
owned.add(binding.class_name);
|
|
27159
|
+
}
|
|
27160
|
+
}
|
|
27161
|
+
return owned;
|
|
27162
|
+
}
|
|
27163
|
+
__name(getPreviewOwnedContainerClassNames, "getPreviewOwnedContainerClassNames");
|
|
27164
|
+
function previewContainerAppName(parentWorkerName, previewSlug, className) {
|
|
27165
|
+
const composed = `${parentWorkerName}_${previewSlug}_${className}`;
|
|
27166
|
+
const normalised = composed.replace(/[^A-Za-z0-9_-]/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "").replace(/^(?=[0-9])/, "w");
|
|
27167
|
+
if (normalised === composed && normalised.length <= MAX_CONTAINER_APP_NAME_LENGTH) {
|
|
27168
|
+
return normalised;
|
|
27169
|
+
}
|
|
27170
|
+
return truncateWithSuffix(
|
|
27171
|
+
normalised,
|
|
27172
|
+
`_${shortHash(composed)}`,
|
|
27173
|
+
MAX_CONTAINER_APP_NAME_LENGTH
|
|
27174
|
+
);
|
|
27175
|
+
}
|
|
27176
|
+
__name(previewContainerAppName, "previewContainerAppName");
|
|
26913
27177
|
function assemblePreviewScriptSettings(config2) {
|
|
26914
27178
|
const previews = config2.previews;
|
|
26915
27179
|
const result = {};
|
|
@@ -26950,6 +27214,90 @@ function assemblePreviewDefaults(config2) {
|
|
|
26950
27214
|
return previewDefaults;
|
|
26951
27215
|
}
|
|
26952
27216
|
__name(assemblePreviewDefaults, "assemblePreviewDefaults");
|
|
27217
|
+
function buildPreviewContainerConfig(config2, parentWorkerName, previewSlug, previewContainers) {
|
|
27218
|
+
const previews = config2.previews;
|
|
27219
|
+
const previewDOBindings = previews?.durable_objects?.bindings ?? [];
|
|
27220
|
+
const ownedDOClasses = getPreviewOwnedContainerClassNames(config2, previews);
|
|
27221
|
+
const linkedContainers = previewContainers.map((container) => {
|
|
27222
|
+
const className = container.class_name;
|
|
27223
|
+
if (className === void 0) {
|
|
27224
|
+
throw new UserError(
|
|
27225
|
+
`A container entry in "previews.containers" is missing "class_name". A preview container must name the Durable Object class it backs, even where a Durable Object declared in "exports" names its container instead.`,
|
|
27226
|
+
{
|
|
27227
|
+
telemetryMessage: "preview container missing class_name"
|
|
27228
|
+
}
|
|
27229
|
+
);
|
|
27230
|
+
}
|
|
27231
|
+
return { container, className };
|
|
27232
|
+
});
|
|
27233
|
+
for (const { className } of linkedContainers) {
|
|
27234
|
+
if (ownedDOClasses.has(className) || previewDOBindings.some((b) => b.class_name === className)) {
|
|
27235
|
+
continue;
|
|
27236
|
+
}
|
|
27237
|
+
throw new UserError(
|
|
27238
|
+
`The container class_name "${className}" in "previews.containers" does not match any Durable Object class in your ${configFileName(config2.configPath)} file. Declare the class in "migrations" or "exports", or bind it under "previews.durable_objects".`,
|
|
27239
|
+
{
|
|
27240
|
+
telemetryMessage: "no preview DO class matches container class_name"
|
|
27241
|
+
}
|
|
27242
|
+
);
|
|
27243
|
+
}
|
|
27244
|
+
const filteredContainers = linkedContainers.filter(({ className }) => ownedDOClasses.has(className)).map(({ container, className }) => ({
|
|
27245
|
+
...container,
|
|
27246
|
+
name: previewContainerAppName(parentWorkerName, previewSlug, className)
|
|
27247
|
+
}));
|
|
27248
|
+
if (filteredContainers.length === 0) {
|
|
27249
|
+
return void 0;
|
|
27250
|
+
}
|
|
27251
|
+
const localBindingsFirst = [
|
|
27252
|
+
...previewDOBindings.filter((b) => b.script_name === void 0),
|
|
27253
|
+
...previewDOBindings.filter((b) => b.script_name !== void 0)
|
|
27254
|
+
];
|
|
27255
|
+
const observability = previews?.observability ?? config2.observability;
|
|
27256
|
+
return {
|
|
27257
|
+
...config2,
|
|
27258
|
+
containers: filteredContainers,
|
|
27259
|
+
durable_objects: {
|
|
27260
|
+
bindings: localBindingsFirst
|
|
27261
|
+
},
|
|
27262
|
+
observability
|
|
27263
|
+
};
|
|
27264
|
+
}
|
|
27265
|
+
__name(buildPreviewContainerConfig, "buildPreviewContainerConfig");
|
|
27266
|
+
async function prepareContainersForPreview(config2, workerName, previewSlug, callbacks) {
|
|
27267
|
+
const previewContainers = config2.previews?.containers ?? [];
|
|
27268
|
+
if (previewContainers.length === 0 || !callbacks.getNormalizedContainerOptions) {
|
|
27269
|
+
return { scopedContainerConfig: void 0, normalisedContainerConfig: [] };
|
|
27270
|
+
}
|
|
27271
|
+
const scopedContainerConfig = buildPreviewContainerConfig(
|
|
27272
|
+
config2,
|
|
27273
|
+
workerName,
|
|
27274
|
+
previewSlug,
|
|
27275
|
+
previewContainers
|
|
27276
|
+
);
|
|
27277
|
+
if (!scopedContainerConfig) {
|
|
27278
|
+
return { scopedContainerConfig: void 0, normalisedContainerConfig: [] };
|
|
27279
|
+
}
|
|
27280
|
+
const normalisedContainerConfig = await callbacks.getNormalizedContainerOptions(scopedContainerConfig, {
|
|
27281
|
+
dryRun: false
|
|
27282
|
+
});
|
|
27283
|
+
const containersNeedingDocker = normalisedContainerConfig.filter(
|
|
27284
|
+
(container) => "dockerfile" in container
|
|
27285
|
+
);
|
|
27286
|
+
if (containersNeedingDocker.length > 0) {
|
|
27287
|
+
await verifyDockerInstalled({
|
|
27288
|
+
dockerPath: getDockerPath(),
|
|
27289
|
+
operation: "creating a preview",
|
|
27290
|
+
imageNoun: containersNeedingDocker.length !== 1 ? "the configured images" : "the configured image",
|
|
27291
|
+
hint: 'If you cannot run Docker locally, set "image" to a prebuilt registry image instead of a Dockerfile path for the affected entries in "previews.containers".'
|
|
27292
|
+
});
|
|
27293
|
+
}
|
|
27294
|
+
if (callbacks.verifyContainersScope) {
|
|
27295
|
+
await callbacks.verifyContainersScope(scopedContainerConfig);
|
|
27296
|
+
}
|
|
27297
|
+
return { scopedContainerConfig, normalisedContainerConfig };
|
|
27298
|
+
}
|
|
27299
|
+
__name(prepareContainersForPreview, "prepareContainersForPreview");
|
|
27300
|
+
var NO_ACTIVE_PREVIEW_URLS_MESSAGE = "Note: This Preview deployment has no active URLs. To get one, enable Preview Deployments on workers.dev or a custom domain. See https://developers.cloudflare.com/workers/previews/custom-domains/ for more information";
|
|
26953
27301
|
function toBase64(content) {
|
|
26954
27302
|
return Buffer.from(content).toString("base64");
|
|
26955
27303
|
}
|
|
@@ -27064,9 +27412,21 @@ async function assemblePreviewDeploymentSettings(config2, buildResult, accountId
|
|
|
27064
27412
|
if (config2.compatibility_flags && config2.compatibility_flags.length > 0) {
|
|
27065
27413
|
request2.compatibility_flags = config2.compatibility_flags;
|
|
27066
27414
|
}
|
|
27067
|
-
|
|
27415
|
+
const repositoryUrl = options.repositoryUrl;
|
|
27416
|
+
const pullRequest = options.pullRequest;
|
|
27417
|
+
const commitSha = options.commitSha;
|
|
27418
|
+
if (options.message || options.tag || repositoryUrl || pullRequest || commitSha) {
|
|
27068
27419
|
request2.annotations = {
|
|
27420
|
+
...commitSha && { "workers/commit_sha": commitSha },
|
|
27069
27421
|
...options.message && { "workers/message": options.message },
|
|
27422
|
+
...pullRequest?.number && {
|
|
27423
|
+
"workers/pull_request_number": pullRequest.number
|
|
27424
|
+
},
|
|
27425
|
+
...pullRequest?.title && {
|
|
27426
|
+
"workers/pull_request_title": pullRequest.title
|
|
27427
|
+
},
|
|
27428
|
+
...pullRequest?.url && { "workers/pull_request_url": pullRequest.url },
|
|
27429
|
+
...repositoryUrl && { "workers/repository_url": repositoryUrl },
|
|
27070
27430
|
...options.tag && { "workers/tag": options.tag }
|
|
27071
27431
|
};
|
|
27072
27432
|
}
|
|
@@ -27108,6 +27468,16 @@ async function assemblePreviewDeploymentSettings(config2, buildResult, accountId
|
|
|
27108
27468
|
if (config2.placement) {
|
|
27109
27469
|
request2.placement = parseConfigPlacement(config2);
|
|
27110
27470
|
}
|
|
27471
|
+
const previewContainers = previews?.containers ?? [];
|
|
27472
|
+
if (previewContainers.length > 0) {
|
|
27473
|
+
const ownedDOClasses = getPreviewOwnedContainerClassNames(config2, previews);
|
|
27474
|
+
const containers = previewContainers.flatMap(
|
|
27475
|
+
({ class_name }) => class_name !== void 0 && ownedDOClasses.has(class_name) ? [{ class_name }] : []
|
|
27476
|
+
);
|
|
27477
|
+
if (containers.length > 0) {
|
|
27478
|
+
request2.containers = containers;
|
|
27479
|
+
}
|
|
27480
|
+
}
|
|
27111
27481
|
const env = extractConfigBindings(config2);
|
|
27112
27482
|
if (Object.keys(env).length > 0) {
|
|
27113
27483
|
request2.env = env;
|
|
@@ -27129,14 +27499,21 @@ function formatUrlLines(label, urls) {
|
|
|
27129
27499
|
];
|
|
27130
27500
|
}
|
|
27131
27501
|
__name(formatUrlLines, "formatUrlLines");
|
|
27132
|
-
function formatPreviewDeploymentSummary(previewResource, deployment, isNew) {
|
|
27502
|
+
function formatPreviewDeploymentSummary(previewResource, deployment, isNew, pullRequest) {
|
|
27133
27503
|
const statusLabel = isNew ? chalk6.green("(new)") : chalk6.dim("(updated)");
|
|
27504
|
+
const pullRequestUrl = deployment.annotations?.["workers/pull_request_url"] ?? pullRequest?.url;
|
|
27505
|
+
const pullRequestNumber = deployment.annotations?.["workers/pull_request_number"] ?? pullRequest?.number;
|
|
27506
|
+
const hasActiveUrls = (previewResource.urls?.length ?? 0) > 0 || (deployment.urls?.length ?? 0) > 0;
|
|
27134
27507
|
return [
|
|
27135
27508
|
`${chalk6.bold("Preview:")} ${previewResource.name} ${statusLabel}`,
|
|
27136
27509
|
...formatUrlLines("Preview", previewResource.urls),
|
|
27137
27510
|
"",
|
|
27138
27511
|
`${chalk6.bold("Deployment ID:")} ${deployment.id}`,
|
|
27139
|
-
...formatUrlLines("Deployment", deployment.urls)
|
|
27512
|
+
...formatUrlLines("Deployment", deployment.urls),
|
|
27513
|
+
...pullRequestUrl || pullRequestNumber ? [
|
|
27514
|
+
`${chalk6.bold("Pull Request:")} ${pullRequestUrl ?? `#${pullRequestNumber}`}`
|
|
27515
|
+
] : [],
|
|
27516
|
+
...hasActiveUrls ? [] : [NO_ACTIVE_PREVIEW_URLS_MESSAGE]
|
|
27140
27517
|
].join("\n");
|
|
27141
27518
|
}
|
|
27142
27519
|
__name(formatPreviewDeploymentSummary, "formatPreviewDeploymentSummary");
|
|
@@ -27163,7 +27540,37 @@ ${Object.entries(missingBindings).map(
|
|
|
27163
27540
|
Either include these bindings in the ${chalk6.cyan(`"previews"`)} field of your Wrangler config or update the Previews settings of your Worker in the Cloudflare dashboard.`);
|
|
27164
27541
|
}
|
|
27165
27542
|
__name(logMissingPreviewsBindingsWarning, "logMissingPreviewsBindingsWarning");
|
|
27166
|
-
async function
|
|
27543
|
+
async function provisionParentWorker(config2, accountId, workerName, json2) {
|
|
27544
|
+
const confirmed = json2 || await confirm(
|
|
27545
|
+
`Worker "${workerName}" does not exist yet. Would you like to create it for this Preview?`,
|
|
27546
|
+
// Default to true so CI and Workers Builds can create Previews unattended.
|
|
27547
|
+
{ defaultValue: true, fallbackValue: true }
|
|
27548
|
+
);
|
|
27549
|
+
if (!confirmed) {
|
|
27550
|
+
throw new UserError(
|
|
27551
|
+
`Cannot create a Preview because the Worker "${workerName}" does not exist.`,
|
|
27552
|
+
{ telemetryMessage: "preview command parent worker not created" }
|
|
27553
|
+
);
|
|
27554
|
+
}
|
|
27555
|
+
if (!json2) {
|
|
27556
|
+
logger.log(`\u{1F300} Creating new Worker "${workerName}"...`);
|
|
27557
|
+
}
|
|
27558
|
+
const routes = config2.routes ?? (config2.route ? [config2.route] : []);
|
|
27559
|
+
const { workers_dev, preview_urls } = getSubdomainValues(
|
|
27560
|
+
config2.workers_dev,
|
|
27561
|
+
config2.preview_urls,
|
|
27562
|
+
routes
|
|
27563
|
+
);
|
|
27564
|
+
await createPreviewParentWorker(
|
|
27565
|
+
config2,
|
|
27566
|
+
accountId,
|
|
27567
|
+
workerName,
|
|
27568
|
+
workers_dev,
|
|
27569
|
+
preview_urls ?? workers_dev
|
|
27570
|
+
);
|
|
27571
|
+
}
|
|
27572
|
+
__name(provisionParentWorker, "provisionParentWorker");
|
|
27573
|
+
async function preview(accountId, args, config2, buildResult, assetsOptions, callbacks) {
|
|
27167
27574
|
const workerName = resolveWorkerName(args, config2);
|
|
27168
27575
|
let previewName = args.name;
|
|
27169
27576
|
if (!previewName) {
|
|
@@ -27179,6 +27586,9 @@ async function preview(accountId, args, config2, buildResult, assetsOptions) {
|
|
|
27179
27586
|
const ignoreBaseConfig = args.ignoreBaseConfig;
|
|
27180
27587
|
const fallbackTag = !args.tag && shouldUseCIMetadataFallback() ? getHeadCommitRef() : void 0;
|
|
27181
27588
|
const fallbackMessage = !args.message && shouldUseCIMetadataFallback() ? getHeadCommitMessage() : void 0;
|
|
27589
|
+
const repositoryUrl = getRepositoryUrl();
|
|
27590
|
+
const pullRequest = getPullRequestMetadata();
|
|
27591
|
+
const commitSha = getCommitSha();
|
|
27182
27592
|
let existingPreview = null;
|
|
27183
27593
|
try {
|
|
27184
27594
|
existingPreview = await getPreview(
|
|
@@ -27188,7 +27598,14 @@ async function preview(accountId, args, config2, buildResult, assetsOptions) {
|
|
|
27188
27598
|
previewIdentifier
|
|
27189
27599
|
);
|
|
27190
27600
|
} catch (e) {
|
|
27191
|
-
if (
|
|
27601
|
+
if (isWorkerNotFoundError(e)) {
|
|
27602
|
+
await provisionParentWorker(
|
|
27603
|
+
config2,
|
|
27604
|
+
accountId,
|
|
27605
|
+
workerName,
|
|
27606
|
+
args.json ?? false
|
|
27607
|
+
);
|
|
27608
|
+
} else if (!(e instanceof Error && "code" in e && e.code === 10025)) {
|
|
27192
27609
|
throw e;
|
|
27193
27610
|
}
|
|
27194
27611
|
}
|
|
@@ -27216,6 +27633,12 @@ async function preview(accountId, args, config2, buildResult, assetsOptions) {
|
|
|
27216
27633
|
previewResource = existingPreview;
|
|
27217
27634
|
}
|
|
27218
27635
|
}
|
|
27636
|
+
const { scopedContainerConfig, normalisedContainerConfig } = await prepareContainersForPreview(
|
|
27637
|
+
config2,
|
|
27638
|
+
workerName,
|
|
27639
|
+
previewResource.slug,
|
|
27640
|
+
callbacks
|
|
27641
|
+
);
|
|
27219
27642
|
const deploymentRequest = await assemblePreviewDeploymentSettings(
|
|
27220
27643
|
config2,
|
|
27221
27644
|
buildResult,
|
|
@@ -27225,6 +27648,9 @@ async function preview(accountId, args, config2, buildResult, assetsOptions) {
|
|
|
27225
27648
|
{
|
|
27226
27649
|
message: args.message ?? fallbackMessage,
|
|
27227
27650
|
tag: args.tag ?? fallbackTag,
|
|
27651
|
+
repositoryUrl,
|
|
27652
|
+
pullRequest,
|
|
27653
|
+
commitSha,
|
|
27228
27654
|
assetsOptions
|
|
27229
27655
|
}
|
|
27230
27656
|
);
|
|
@@ -27235,13 +27661,34 @@ async function preview(accountId, args, config2, buildResult, assetsOptions) {
|
|
|
27235
27661
|
previewResource.id,
|
|
27236
27662
|
deploymentRequest
|
|
27237
27663
|
);
|
|
27664
|
+
if (normalisedContainerConfig.length > 0 && scopedContainerConfig && callbacks.deployPreviewContainers) {
|
|
27665
|
+
try {
|
|
27666
|
+
await callbacks.deployPreviewContainers(
|
|
27667
|
+
scopedContainerConfig,
|
|
27668
|
+
normalisedContainerConfig,
|
|
27669
|
+
deployment,
|
|
27670
|
+
accountId,
|
|
27671
|
+
{ quiet: args.json === true }
|
|
27672
|
+
);
|
|
27673
|
+
} catch (error51) {
|
|
27674
|
+
logger.warn(
|
|
27675
|
+
`The preview "${previewResource.name}" was created, but its containers did not come up. Its Durable Objects have no container backing them until the containers are applied successfully.`
|
|
27676
|
+
);
|
|
27677
|
+
throw error51;
|
|
27678
|
+
}
|
|
27679
|
+
}
|
|
27238
27680
|
if (args.json) {
|
|
27239
27681
|
logger.log(
|
|
27240
27682
|
JSON.stringify({ preview: previewResource, deployment }, null, 2)
|
|
27241
27683
|
);
|
|
27242
27684
|
} else {
|
|
27243
27685
|
logger.log(
|
|
27244
|
-
formatPreviewDeploymentSummary(
|
|
27686
|
+
formatPreviewDeploymentSummary(
|
|
27687
|
+
previewResource,
|
|
27688
|
+
deployment,
|
|
27689
|
+
isNewPreview,
|
|
27690
|
+
pullRequest
|
|
27691
|
+
)
|
|
27245
27692
|
);
|
|
27246
27693
|
const topLevelBindings = getBindings(config2);
|
|
27247
27694
|
if (Object.keys(topLevelBindings).length > 0) {
|
|
@@ -27592,4 +28039,4 @@ __name(previewSettingsUpdate, "previewSettingsUpdate");
|
|
|
27592
28039
|
* THE SOFTWARE.
|
|
27593
28040
|
*/
|
|
27594
28041
|
|
|
27595
|
-
export { ACTOR_BINDING_DEPENDS_ON_EXPORT_CODE, EXPORTS_RECONCILIATION_ERROR_CODE, INCONSISTENT_EXPORTS_ACROSS_VERSIONS_CODE, INVALID_INHERIT_BINDING_CODE, 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, assemblePreviewDefaults, assemblePreviewScriptSettings, buildAssetManifest, checkRemoteSecretsOverride, checkWorkflowConflicts, collectPackageDependencies, confirmLatestDeploymentOverwrite, createDeployment, createPreview, createPreviewDeployment, createTruncatedAlias, decodeJwtPayload, deletePreview, deletePullConsumer, deleteWorkerConsumer, deploy, deployWfpUserWorker, diagnoseScriptSizeError, diagnoseStartupError, diffJsonObjects, downloadWorkerConfig, drawBox, drawConnectedChildBox, editPreview, editWorkerPreviewDefaults, ensureQueuesExistByConfig, extractConfigBindings, fetchDeployableVersions, fetchDeploymentVersions, fetchLatestDeployment, fetchLatestDeployments, fetchSecrets, fetchVersion, fetchVersions, fetchWorkerConfig, formatAlignedRows, formatBindings, formatPreviewsSettings, generatePreviewAlias, getBindingValue, getBranchName2 as getBranchName, getConfigPatch, getDeployConfirmFunction, getEdgeKvUploadConcurrency, getHeadCommitMessage, getHeadCommitRef, getMigrationsToUpload, getPreview, getPreviewBaseConfig, getPreviewDeployment, getQueue, getRemoteConfigDiff, getSettings, getSourceMappedStack, getSourceMappedString, getSubdomainValues, getSubdomainValuesAPIMock, getWorkerPreviewDefaults, getWorkersDevSubdomain, getZoneForRoute, getZoneIdFromHost, handleMissingSecretsError, hasDefinedEnvironments, hashFile, helpIfErrorIsSizeOrScriptStartup, isExportsReconciliationErrorDetails, isJwtExpired, isModifiedDiffValue, isNonDestructive, isWorkerNotFoundError, listConsumers, listQueues, maybeRetrieveFileSourceMap, mergeDeep, padToVisibleWidth, parseBulkInputToObject, parseConfigPlacement, patchNonVersionedScriptSettings, patchPreviewBaseConfig, patchPreviewDeployment, postConsumer, preview, previewDelete, previewSettingsGet, previewSettingsUpdate, printBindings, printBundleSize, printVersions, provisionBindings, publishCustomDomains, publishRoutes, putConsumer, putConsumerById, renderBindingDependsOnExportError, renderExportsReconciliationError, renderExportsReconciliationSuccess, renderInconsistentExportsAcrossVersionsError, renderRoute, resolveAssetOptions, resolveDoLifecyclePayload, resolveExportsUploadPayload, resolveWorkerName, sanitizeBranchName, shouldUseCIMetadataFallback, stripAnsi, syncAssets, tagsAreEqual, triggersDeploy, updateQueueConsumers, validateEventTriggerTargets, validateFileSecrets, validateNodeCompatMode, validateRoutes, verifyWorkerMatchesCITag, versionsUpload, visibleLength, warnOnErrorUpdatingServiceAndEnvironmentTags, warnOrError, workerNotFoundErrorMessage };
|
|
28042
|
+
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, assemblePreviewDefaults, assemblePreviewScriptSettings, buildAssetManifest, checkRemoteSecretsOverride, checkWorkflowConflicts, collectPackageDependencies, confirmLatestDeploymentOverwrite, createDeployment, createPreview, createPreviewDeployment, createPreviewParentWorker, createTruncatedAlias, decodeJwtPayload, deletePreview, deletePullConsumer, deleteWorkerConsumer, deploy, deployWfpUserWorker, diagnoseScriptSizeError, diagnoseStartupError, diffJsonObjects, downloadWorkerConfig, drawBox, drawConnectedChildBox, editPreview, editWorkerPreviewDefaults, ensureQueuesExistByConfig, extractConfigBindings, fetchDeployableVersions, fetchDeploymentVersions, fetchLatestDeployment, fetchLatestDeployments, fetchSecrets, fetchVersion, fetchVersions, fetchWorkerConfig, formatAlignedRows, formatBindings, formatPreviewsSettings, generatePreviewAlias, getBindingValue, getBranchName2 as getBranchName, getCommitSha, getConfigPatch, getDeployConfirmFunction, getEdgeKvUploadConcurrency, getHeadCommitMessage, getHeadCommitRef, getMigrationsToUpload, getPreview, getPreviewBaseConfig, getPreviewDeployment, getPreviewOwnedContainerClassNames, getPullRequestMetadata, getQueue, getRemoteConfigDiff, getRepositoryUrl, getSettings, getSourceMappedStack, getSourceMappedString, getSubdomainValues, getSubdomainValuesAPIMock, getWorkerPreviewDefaults, getWorkersDevSubdomain, getZoneForRoute, getZoneIdFromHost, handleMissingSecretsError, hasDefinedEnvironments, hashFile, helpIfErrorIsSizeOrScriptStartup, isExportsReconciliationErrorDetails, isJwtExpired, isModifiedDiffValue, isNonDestructive, isWorkerNotFoundError, listConsumers, listQueues, maybeRetrieveFileSourceMap, mergeDeep, padToVisibleWidth, parseBulkInputToObject, parseConfigPlacement, patchNonVersionedScriptSettings, patchPreviewBaseConfig, patchPreviewDeployment, postConsumer, preview, previewContainerAppName, previewDelete, previewSettingsGet, previewSettingsUpdate, printBindings, printBundleSize, printVersions, provisionBindings, publishCustomDomains, publishRoutes, putConsumer, putConsumerById, renderBindingDependsOnExportError, renderExportsReconciliationError, renderExportsReconciliationSuccess, renderInconsistentExportsAcrossVersionsError, renderRoute, resolveAssetOptions, resolveDoLifecyclePayload, resolveExportsUploadPayload, resolveWorkerName, sanitizeBranchName, shouldUseCIMetadataFallback, stripAnsi, syncAssets, tagsAreEqual, triggersDeploy, updateQueueConsumers, validateEventTriggerTargets, validateFileSecrets, validateNodeCompatMode, validateRoutes, verifyWorkerMatchesCITag, versionsUpload, visibleLength, warnOnErrorUpdatingServiceAndEnvironmentTags, warnOrError, workerNotFoundErrorMessage };
|