wrangler 3.71.0 → 3.72.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/config-schema.json +9 -0
- package/package.json +5 -5
- package/templates/startDevWorker/ProxyWorker.ts +22 -22
- package/wrangler-dist/ProxyWorker.js +21 -22
- package/wrangler-dist/ProxyWorker.js.map +1 -1
- package/wrangler-dist/cli.d.ts +3 -0
- package/wrangler-dist/cli.js +499 -412
- package/wrangler-dist/cli.js.map +4 -4
package/wrangler-dist/cli.js
CHANGED
@@ -80778,7 +80778,7 @@ var require_send = __commonJS({
|
|
80778
80778
|
var join18 = path74.join;
|
80779
80779
|
var normalize4 = path74.normalize;
|
80780
80780
|
var resolve22 = path74.resolve;
|
80781
|
-
var
|
80781
|
+
var sep4 = path74.sep;
|
80782
80782
|
var BYTES_RANGE_REGEXP = /^ *bytes=/;
|
80783
80783
|
var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
|
80784
80784
|
var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
|
@@ -80988,14 +80988,14 @@ var require_send = __commonJS({
|
|
80988
80988
|
var parts;
|
80989
80989
|
if (root !== null) {
|
80990
80990
|
if (path75) {
|
80991
|
-
path75 = normalize4("." +
|
80991
|
+
path75 = normalize4("." + sep4 + path75);
|
80992
80992
|
}
|
80993
80993
|
if (UP_PATH_REGEXP.test(path75)) {
|
80994
80994
|
debug('malicious path "%s"', path75);
|
80995
80995
|
this.error(403);
|
80996
80996
|
return res;
|
80997
80997
|
}
|
80998
|
-
parts = path75.split(
|
80998
|
+
parts = path75.split(sep4);
|
80999
80999
|
path75 = normalize4(join18(root, path75));
|
81000
81000
|
} else {
|
81001
81001
|
if (UP_PATH_REGEXP.test(path75)) {
|
@@ -81003,7 +81003,7 @@ var require_send = __commonJS({
|
|
81003
81003
|
this.error(403);
|
81004
81004
|
return res;
|
81005
81005
|
}
|
81006
|
-
parts = normalize4(path75).split(
|
81006
|
+
parts = normalize4(path75).split(sep4);
|
81007
81007
|
path75 = resolve22(path75);
|
81008
81008
|
}
|
81009
81009
|
if (containsDotFile(parts)) {
|
@@ -81102,7 +81102,7 @@ var require_send = __commonJS({
|
|
81102
81102
|
var self2 = this;
|
81103
81103
|
debug('stat "%s"', path75);
|
81104
81104
|
fs26.stat(path75, /* @__PURE__ */ __name(function onstat(err, stat6) {
|
81105
|
-
if (err && err.code === "ENOENT" && !extname5(path75) && path75[path75.length - 1] !==
|
81105
|
+
if (err && err.code === "ENOENT" && !extname5(path75) && path75[path75.length - 1] !== sep4) {
|
81106
81106
|
return next(err);
|
81107
81107
|
}
|
81108
81108
|
if (err)
|
@@ -100662,9 +100662,9 @@ var require_prompts = __commonJS({
|
|
100662
100662
|
$3.date = (args) => toPrompt("DatePrompt", args);
|
100663
100663
|
$3.confirm = (args) => toPrompt("ConfirmPrompt", args);
|
100664
100664
|
$3.list = (args) => {
|
100665
|
-
const
|
100665
|
+
const sep4 = args.separator || ",";
|
100666
100666
|
return toPrompt("TextPrompt", args, {
|
100667
|
-
onSubmit: (str) => str.split(
|
100667
|
+
onSubmit: (str) => str.split(sep4).map((s) => s.trim())
|
100668
100668
|
});
|
100669
100669
|
};
|
100670
100670
|
$3.toggle = (args) => toPrompt("TogglePrompt", args);
|
@@ -103117,9 +103117,9 @@ var require_prompts2 = __commonJS({
|
|
103117
103117
|
$3.date = (args) => toPrompt("DatePrompt", args);
|
103118
103118
|
$3.confirm = (args) => toPrompt("ConfirmPrompt", args);
|
103119
103119
|
$3.list = (args) => {
|
103120
|
-
const
|
103120
|
+
const sep4 = args.separator || ",";
|
103121
103121
|
return toPrompt("TextPrompt", args, {
|
103122
|
-
onSubmit: (str) => str.split(
|
103122
|
+
onSubmit: (str) => str.split(sep4).map((s) => s.trim())
|
103123
103123
|
});
|
103124
103124
|
};
|
103125
103125
|
$3.toggle = (args) => toPrompt("TogglePrompt", args);
|
@@ -137868,13 +137868,13 @@ ${err.stack}`;
|
|
137868
137868
|
});
|
137869
137869
|
|
137870
137870
|
// ../pages-shared/asset-server/rulesEngine.ts
|
137871
|
-
var
|
137871
|
+
var ESCAPE_REGEX_CHARACTERS2, escapeRegex2, HOST_PLACEHOLDER_REGEX, PLACEHOLDER_REGEX2, replacer, generateRulesMatcher;
|
137872
137872
|
var init_rulesEngine = __esm({
|
137873
137873
|
"../pages-shared/asset-server/rulesEngine.ts"() {
|
137874
137874
|
init_import_meta_url();
|
137875
|
-
|
137876
|
-
|
137877
|
-
return str.replace(
|
137875
|
+
ESCAPE_REGEX_CHARACTERS2 = /[-/\\^$*+?.()|[\]{}]/g;
|
137876
|
+
escapeRegex2 = /* @__PURE__ */ __name((str) => {
|
137877
|
+
return str.replace(ESCAPE_REGEX_CHARACTERS2, "\\$&");
|
137878
137878
|
}, "escapeRegex");
|
137879
137879
|
HOST_PLACEHOLDER_REGEX = /(?<=^https:\\\/\\\/[^/]*?):([A-Za-z]\w*)(?=\\)/g;
|
137880
137880
|
PLACEHOLDER_REGEX2 = /:([A-Za-z]\w*)/g;
|
@@ -137890,7 +137890,7 @@ var init_rulesEngine = __esm({
|
|
137890
137890
|
}
|
137891
137891
|
const compiledRules = Object.entries(rules).map(([rule, match]) => {
|
137892
137892
|
const crossHost = rule.startsWith("https://");
|
137893
|
-
rule = rule.split("*").map(
|
137893
|
+
rule = rule.split("*").map(escapeRegex2).join("(?<splat>.*)");
|
137894
137894
|
const host_matches = rule.matchAll(HOST_PLACEHOLDER_REGEX);
|
137895
137895
|
for (const host_match of host_matches) {
|
137896
137896
|
rule = rule.split(host_match[0]).join(`(?<${host_match[1]}>[^/.]+)`);
|
@@ -151359,6 +151359,10 @@ function convertCfWorkerInitBindingstoBindings(inputBindings) {
|
|
151359
151359
|
}
|
151360
151360
|
break;
|
151361
151361
|
}
|
151362
|
+
case "experimental_assets": {
|
151363
|
+
output[info["binding"]] = { type: "assets" };
|
151364
|
+
break;
|
151365
|
+
}
|
151362
151366
|
default: {
|
151363
151367
|
assertNever(type);
|
151364
151368
|
}
|
@@ -151389,7 +151393,8 @@ async function convertBindingsToCfWorkerInitBindings(inputBindings) {
|
|
151389
151393
|
dispatch_namespaces: void 0,
|
151390
151394
|
mtls_certificates: void 0,
|
151391
151395
|
logfwdr: void 0,
|
151392
|
-
unsafe: void 0
|
151396
|
+
unsafe: void 0,
|
151397
|
+
experimental_assets: void 0
|
151393
151398
|
};
|
151394
151399
|
const fetchers = {};
|
151395
151400
|
for (const [name, binding] of Object.entries(inputBindings ?? {})) {
|
@@ -152688,7 +152693,7 @@ init_import_meta_url();
|
|
152688
152693
|
init_import_meta_url();
|
152689
152694
|
|
152690
152695
|
// package.json
|
152691
|
-
var version = "3.
|
152696
|
+
var version = "3.72.1";
|
152692
152697
|
var package_default = {
|
152693
152698
|
name: "wrangler",
|
152694
152699
|
version,
|
@@ -156341,23 +156346,29 @@ Please add a binding for "${configBindingName}" to "env.${envName}.${field}.bind
|
|
156341
156346
|
return isValid;
|
156342
156347
|
}, "validateBindingArray");
|
156343
156348
|
var validateCloudchamberConfig = /* @__PURE__ */ __name((diagnostics, field, value) => {
|
156344
|
-
if (typeof value !== "object" || value === null) {
|
156349
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
156345
156350
|
diagnostics.errors.push(
|
156346
156351
|
`"cloudchamber" should be an object, but got ${JSON.stringify(value)}`
|
156347
156352
|
);
|
156348
156353
|
return false;
|
156349
156354
|
}
|
156355
|
+
const optionalAttrsByType = {
|
156356
|
+
string: ["memory", "image", "location"],
|
156357
|
+
boolean: ["ipv4"],
|
156358
|
+
number: ["vcpu"]
|
156359
|
+
};
|
156350
156360
|
let isValid = true;
|
156351
|
-
|
156352
|
-
|
156353
|
-
|
156354
|
-
|
156355
|
-
|
156356
|
-
|
156357
|
-
|
156358
|
-
|
156359
|
-
|
156360
|
-
|
156361
|
+
Object.entries(optionalAttrsByType).forEach(([attrType, attrNames]) => {
|
156362
|
+
attrNames.forEach((key) => {
|
156363
|
+
if (!isOptionalProperty(value, key, attrType)) {
|
156364
|
+
diagnostics.errors.push(
|
156365
|
+
`"${field}" bindings should, optionally, have a ${attrType} "${key}" field but got ${JSON.stringify(
|
156366
|
+
value
|
156367
|
+
)}.`
|
156368
|
+
);
|
156369
|
+
isValid = false;
|
156370
|
+
}
|
156371
|
+
});
|
156361
156372
|
});
|
156362
156373
|
return isValid;
|
156363
156374
|
}, "validateCloudchamberConfig");
|
@@ -158994,6 +159005,10 @@ async function writeAdditionalModules(modules, destination) {
|
|
158994
159005
|
__name(writeAdditionalModules, "writeAdditionalModules");
|
158995
159006
|
|
158996
159007
|
// src/deployment-bundle/bundle.ts
|
159008
|
+
var ESCAPE_REGEX_CHARACTERS = /[-/\\^$*+?.()|[\]{}]/g;
|
159009
|
+
var escapeRegex = /* @__PURE__ */ __name((str) => {
|
159010
|
+
return str.replace(ESCAPE_REGEX_CHARACTERS, "\\$&");
|
159011
|
+
}, "escapeRegex");
|
158997
159012
|
var COMMON_ESBUILD_OPTIONS = {
|
158998
159013
|
// Our workerd runtime uses the same V8 version as recent Chrome, which is highly ES2022 compliant: https://kangax.github.io/compat-table/es2016plus/
|
158999
159014
|
target: "es2022",
|
@@ -159111,6 +159126,30 @@ async function bundleWorker(entry, destination, {
|
|
159111
159126
|
if (watch9) {
|
159112
159127
|
inject.push(path12.resolve(getBasePath(), "templates/modules-watch-stub.js"));
|
159113
159128
|
}
|
159129
|
+
const aliasPlugin = {
|
159130
|
+
name: "alias",
|
159131
|
+
setup(build5) {
|
159132
|
+
if (!alias) {
|
159133
|
+
return;
|
159134
|
+
}
|
159135
|
+
const filter = new RegExp(
|
159136
|
+
Object.keys(alias).map((key) => escapeRegex(key)).join("|")
|
159137
|
+
);
|
159138
|
+
build5.onResolve({ filter }, (args) => {
|
159139
|
+
const aliasPath = alias[args.path];
|
159140
|
+
if (aliasPath) {
|
159141
|
+
return {
|
159142
|
+
// resolve with node resolution
|
159143
|
+
path: require.resolve(aliasPath, {
|
159144
|
+
// From the esbuild alias docs: "Note that when an import path is substituted using an alias, the resulting import path is resolved in the working directory instead of in the directory containing the source file with the import path."
|
159145
|
+
// https://esbuild.github.io/api/#alias:~:text=Note%20that%20when%20an%20import%20path%20is%20substituted%20using%20an%20alias%2C%20the%20resulting%20import%20path%20is%20resolved%20in%20the%20working%20directory%20instead%20of%20in%20the%20directory%20containing%20the%20source%20file%20with%20the%20import%20path.
|
159146
|
+
paths: [entry.directory]
|
159147
|
+
})
|
159148
|
+
};
|
159149
|
+
}
|
159150
|
+
});
|
159151
|
+
}
|
159152
|
+
};
|
159114
159153
|
const buildOptions2 = {
|
159115
159154
|
// Don't use entryFile here as the file may have been changed when applying the middleware
|
159116
159155
|
entryPoints: [entry.file],
|
@@ -159144,12 +159183,12 @@ async function bundleWorker(entry, destination, {
|
|
159144
159183
|
...define2
|
159145
159184
|
}
|
159146
159185
|
},
|
159147
|
-
alias,
|
159148
159186
|
loader: {
|
159149
159187
|
...COMMON_ESBUILD_OPTIONS.loader,
|
159150
159188
|
...loader || {}
|
159151
159189
|
},
|
159152
159190
|
plugins: [
|
159191
|
+
aliasPlugin,
|
159153
159192
|
moduleCollector.plugin,
|
159154
159193
|
...nodejsCompatMode === "legacy" ? [
|
159155
159194
|
(0, import_node_globals_polyfill.default)({ buffer: true }),
|
@@ -162867,6 +162906,9 @@ function handleRuntimeStdio(stdout2, stderr2) {
|
|
162867
162906
|
},
|
162868
162907
|
isCodeMovedWarning(chunk) {
|
162869
162908
|
return /CODE_MOVED for unknown code block/.test(chunk);
|
162909
|
+
},
|
162910
|
+
isAccessViolation(chunk) {
|
162911
|
+
return chunk.includes("access violation;");
|
162870
162912
|
}
|
162871
162913
|
};
|
162872
162914
|
stdout2.on("data", (chunk) => {
|
@@ -162889,8 +162931,17 @@ function handleRuntimeStdio(stdout2, stderr2) {
|
|
162889
162931
|
logger.error(
|
162890
162932
|
`Address already in use (${address}). Please check that you are not already running a server on this address or specify a different port with --port.`
|
162891
162933
|
);
|
162934
|
+
logger.debug(chunk);
|
162935
|
+
} else if (classifiers.isAccessViolation(chunk)) {
|
162936
|
+
let error2 = "There was an access violation in the runtime.";
|
162937
|
+
if (process.platform === "win32") {
|
162938
|
+
error2 += "\nOn Windows, this may be caused by an outdated Microsoft Visual C++ Redistributable library.\nCheck that you have the latest version installed.\nSee https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist.";
|
162939
|
+
}
|
162940
|
+
logger.error(error2);
|
162941
|
+
logger.debug(chunk);
|
162942
|
+
} else {
|
162943
|
+
logger.debug(chunk);
|
162892
162944
|
}
|
162893
|
-
logger.debug(chunk);
|
162894
162945
|
} else if (classifiers.isWarning(chunk)) {
|
162895
162946
|
logger.warn(chunk);
|
162896
162947
|
} else if (classifiers.isCodeMovedWarning(chunk)) {
|
@@ -162997,7 +163048,10 @@ ${err}`
|
|
162997
163048
|
host: "127.0.0.1",
|
162998
163049
|
port: 0
|
162999
163050
|
}
|
163000
|
-
]
|
163051
|
+
],
|
163052
|
+
assetsPath: config.experimentalAssets.directory,
|
163053
|
+
assetsKVBindingName: "ASSETS_KV_NAMESPACE",
|
163054
|
+
assetsManifestBindingName: "ASSETS_MANIFEST"
|
163001
163055
|
}
|
163002
163056
|
];
|
163003
163057
|
}
|
@@ -163302,6 +163356,8 @@ var shapes = {
|
|
163302
163356
|
dash: "\u2500",
|
163303
163357
|
radioInactive: "\u25CB",
|
163304
163358
|
radioActive: "\u25CF",
|
163359
|
+
backActive: "\u25C0",
|
163360
|
+
backInactive: "\u25C1",
|
163305
163361
|
bar: "\u2502",
|
163306
163362
|
leftT: "\u251C",
|
163307
163363
|
rigthT: "\u2524",
|
@@ -163591,12 +163647,12 @@ function createWorkerUploadForm(worker) {
|
|
163591
163647
|
tail_consumers,
|
163592
163648
|
limits,
|
163593
163649
|
annotations,
|
163594
|
-
|
163650
|
+
experimental_assets_jwt
|
163595
163651
|
} = worker;
|
163596
|
-
if (
|
163652
|
+
if (main2.name === "no-op-assets-worker.js" && experimental_assets_jwt) {
|
163597
163653
|
formData.set(
|
163598
163654
|
"metadata",
|
163599
|
-
JSON.stringify({ assets:
|
163655
|
+
JSON.stringify({ assets: experimental_assets_jwt })
|
163600
163656
|
);
|
163601
163657
|
return formData;
|
163602
163658
|
}
|
@@ -163761,6 +163817,12 @@ function createWorkerUploadForm(worker) {
|
|
163761
163817
|
type: "version_metadata"
|
163762
163818
|
});
|
163763
163819
|
}
|
163820
|
+
if (bindings.experimental_assets !== void 0) {
|
163821
|
+
metadataBindings.push({
|
163822
|
+
name: bindings.experimental_assets.binding,
|
163823
|
+
type: "assets"
|
163824
|
+
});
|
163825
|
+
}
|
163764
163826
|
for (const [name, filePath] of Object.entries(bindings.text_blobs || {})) {
|
163765
163827
|
metadataBindings.push({
|
163766
163828
|
name,
|
@@ -163880,7 +163942,8 @@ function createWorkerUploadForm(worker) {
|
|
163880
163942
|
...placement && { placement },
|
163881
163943
|
...tail_consumers && { tail_consumers },
|
163882
163944
|
...limits && { limits },
|
163883
|
-
...annotations && { annotations }
|
163945
|
+
...annotations && { annotations },
|
163946
|
+
...experimental_assets_jwt && { assets: experimental_assets_jwt }
|
163884
163947
|
};
|
163885
163948
|
if (bindings.unsafe?.metadata !== void 0) {
|
163886
163949
|
for (const key of Object.keys(bindings.unsafe.metadata)) {
|
@@ -165046,13 +165109,13 @@ function usage(yargs, shim3) {
|
|
165046
165109
|
};
|
165047
165110
|
self2.stringifiedValues = /* @__PURE__ */ __name(function stringifiedValues(values, separator) {
|
165048
165111
|
let string = "";
|
165049
|
-
const
|
165112
|
+
const sep4 = separator || ", ";
|
165050
165113
|
const array = [].concat(values);
|
165051
165114
|
if (!values || !array.length)
|
165052
165115
|
return string;
|
165053
165116
|
array.forEach((value) => {
|
165054
165117
|
if (string.length)
|
165055
|
-
string +=
|
165118
|
+
string += sep4;
|
165056
165119
|
string += JSON.stringify(value);
|
165057
165120
|
});
|
165058
165121
|
return string;
|
@@ -168921,7 +168984,7 @@ var getSelectRenderers = /* @__PURE__ */ __name((config) => {
|
|
168921
168984
|
const color = isInListOfValues || active2 ? blue : white;
|
168922
168985
|
const text = active2 ? color.underline(optionLabel) : color(optionLabel);
|
168923
168986
|
const sublabel = opt.sublabel ? color.grey(opt.sublabel) : "";
|
168924
|
-
const indicator = isInListOfValues || active2 && !Array.isArray(value) ? color(shapes.radioActive) : color(shapes.radioInactive);
|
168987
|
+
const indicator = isInListOfValues || active2 && !Array.isArray(value) ? color(opt.activeIcon ?? shapes.radioActive) : color(opt.inactiveIcon ?? shapes.radioInactive);
|
168925
168988
|
return `${space(2)}${indicator} ${text} ${sublabel}`;
|
168926
168989
|
}, "renderOption");
|
168927
168990
|
const renderOptionCondition = /* @__PURE__ */ __name((_3, i) => {
|
@@ -170496,19 +170559,15 @@ init_import_meta_url();
|
|
170496
170559
|
// ../cli/args.ts
|
170497
170560
|
init_import_meta_url();
|
170498
170561
|
var processArgument = /* @__PURE__ */ __name(async (args, name, promptConfig) => {
|
170499
|
-
|
170500
|
-
const
|
170501
|
-
|
170502
|
-
|
170503
|
-
|
170504
|
-
|
170505
|
-
|
170506
|
-
|
170507
|
-
|
170508
|
-
return value;
|
170509
|
-
}
|
170510
|
-
value = await inputPrompt(promptConfig);
|
170511
|
-
return value;
|
170562
|
+
const value = args[name];
|
170563
|
+
const result = await inputPrompt({
|
170564
|
+
...promptConfig,
|
170565
|
+
// Accept the default value if the arg is already set
|
170566
|
+
acceptDefault: promptConfig.acceptDefault ?? value !== void 0,
|
170567
|
+
defaultValue: value ?? promptConfig.defaultValue
|
170568
|
+
});
|
170569
|
+
args[name] = result;
|
170570
|
+
return result;
|
170512
170571
|
}, "processArgument");
|
170513
170572
|
|
170514
170573
|
// src/cloudchamber/cli/index.ts
|
@@ -171288,9 +171347,16 @@ async function createCommand(args, config) {
|
|
171288
171347
|
);
|
171289
171348
|
const labels = collectLabels(args.label);
|
171290
171349
|
if (!interactWithUser(args)) {
|
171350
|
+
if (config.cloudchamber.image != void 0 && args.image == void 0) {
|
171351
|
+
args.image = config.cloudchamber.image;
|
171352
|
+
}
|
171353
|
+
if (config.cloudchamber.location != void 0 && args.location == void 0) {
|
171354
|
+
args.location = config.cloudchamber.location;
|
171355
|
+
}
|
171291
171356
|
const body = checkEverythingIsSet(args, ["image", "location"]);
|
171292
171357
|
const keysToAdd = args.allSshKeys ? (await pollSSHKeysUntilCondition(() => true)).map((key) => key.id) : [];
|
171293
|
-
const
|
171358
|
+
const useIpv4 = args.ipv4 ?? config.cloudchamber.ipv4;
|
171359
|
+
const network = useIpv4 === true ? { assign_ipv4: "predefined" /* PREDEFINED */ } : void 0;
|
171294
171360
|
const deployment = await DeploymentsService.createDeploymentV2({
|
171295
171361
|
image: body.image,
|
171296
171362
|
location: body.location,
|
@@ -171376,7 +171442,8 @@ __name(askWhichSSHKeysDoTheyWantToAdd, "askWhichSSHKeysDoTheyWantToAdd");
|
|
171376
171442
|
async function handleCreateCommand(args, config, environmentVariables, labels) {
|
171377
171443
|
startSection("Create a Cloudflare container", "Step 1 of 2");
|
171378
171444
|
const sshKeyID = await sshPrompts(args);
|
171379
|
-
const
|
171445
|
+
const givenImage = args.image ?? config.cloudchamber.image;
|
171446
|
+
const image = await processArgument({ image: givenImage }, "image", {
|
171380
171447
|
question: whichImageQuestion,
|
171381
171448
|
label: "image",
|
171382
171449
|
validate: (value) => {
|
@@ -171390,14 +171457,18 @@ async function handleCreateCommand(args, config, environmentVariables, labels) {
|
|
171390
171457
|
return "we don't allow :latest tags";
|
171391
171458
|
}
|
171392
171459
|
},
|
171393
|
-
defaultValue:
|
171394
|
-
initialValue:
|
171460
|
+
defaultValue: givenImage ?? "",
|
171461
|
+
initialValue: givenImage ?? "",
|
171395
171462
|
helpText: 'i.e. "docker.io/org/app:1.2", :latest tags are not allowed!',
|
171396
171463
|
type: "text"
|
171397
171464
|
});
|
171398
|
-
const location = await getLocation2(
|
171465
|
+
const location = await getLocation2({
|
171466
|
+
location: args.location ?? config.cloudchamber.location
|
171467
|
+
});
|
171399
171468
|
const keys = await askWhichSSHKeysDoTheyWantToAdd(args, sshKeyID);
|
171400
|
-
const network = await getNetworkInput(
|
171469
|
+
const network = await getNetworkInput({
|
171470
|
+
ipv4: args.ipv4 ?? config.cloudchamber.ipv4
|
171471
|
+
});
|
171401
171472
|
const selectedEnvironmentVariables = await promptForEnvironmentVariables(
|
171402
171473
|
environmentVariables,
|
171403
171474
|
[],
|
@@ -172079,8 +172150,8 @@ async function modifyCommand(modifyArgs, config) {
|
|
172079
172150
|
const deployment = await DeploymentsService.modifyDeploymentV2(
|
172080
172151
|
modifyArgs.deploymentId,
|
172081
172152
|
{
|
172082
|
-
image: modifyArgs.image,
|
172083
|
-
location: modifyArgs.location,
|
172153
|
+
image: modifyArgs.image ?? config.cloudchamber.image,
|
172154
|
+
location: modifyArgs.location ?? config.cloudchamber.location,
|
172084
172155
|
environment_variables: environmentVariables,
|
172085
172156
|
labels,
|
172086
172157
|
ssh_public_key_ids: modifyArgs.sshPublicKeyId,
|
@@ -172138,8 +172209,9 @@ async function handleModifyCommand(args, config) {
|
|
172138
172209
|
startSection("Modify deployment");
|
172139
172210
|
const deployment = await pickDeployment(args.deploymentId);
|
172140
172211
|
const keys = await handleSSH(args, config, deployment);
|
172212
|
+
const givenImage = args.image ?? config.cloudchamber.image;
|
172141
172213
|
const imagePrompt = await processArgument(
|
172142
|
-
{ image:
|
172214
|
+
{ image: givenImage },
|
172143
172215
|
"image",
|
172144
172216
|
{
|
172145
172217
|
question: modifyImageQuestion,
|
@@ -172152,14 +172224,17 @@ async function handleModifyCommand(args, config) {
|
|
172152
172224
|
return "we don't allow :latest tags";
|
172153
172225
|
}
|
172154
172226
|
},
|
172155
|
-
defaultValue:
|
172156
|
-
initialValue:
|
172227
|
+
defaultValue: givenImage ?? "",
|
172228
|
+
initialValue: givenImage ?? "",
|
172157
172229
|
helpText: "if you don't want to modify the image, press return",
|
172158
172230
|
type: "text"
|
172159
172231
|
}
|
172160
172232
|
);
|
172161
172233
|
const image = !imagePrompt ? void 0 : imagePrompt;
|
172162
|
-
const locationPick = await getLocation2(
|
172234
|
+
const locationPick = await getLocation2(
|
172235
|
+
{ location: args.location ?? config.cloudchamber.location },
|
172236
|
+
{ skipLocation: true }
|
172237
|
+
);
|
172163
172238
|
const location = locationPick === "Skip" ? void 0 : locationPick;
|
172164
172239
|
const environmentVariables = collectEnvironmentVariables(
|
172165
172240
|
deployment.environment_variables,
|
@@ -178010,10 +178085,10 @@ var import_node_path36 = __toESM(require("node:path"));
|
|
178010
178085
|
|
178011
178086
|
// src/experimental-assets.ts
|
178012
178087
|
init_import_meta_url();
|
178013
|
-
var
|
178088
|
+
var import_node_assert15 = __toESM(require("node:assert"));
|
178014
178089
|
var import_node_fs20 = require("node:fs");
|
178015
|
-
var
|
178016
|
-
var
|
178090
|
+
var import_promises13 = require("node:fs/promises");
|
178091
|
+
var path39 = __toESM(require("node:path"));
|
178017
178092
|
var import_mime3 = __toESM(require_mime2());
|
178018
178093
|
|
178019
178094
|
// ../../node_modules/.pnpm/p-queue@7.2.0/node_modules/p-queue/dist/index.js
|
@@ -178881,11 +178956,291 @@ function Progress({ done, total }) {
|
|
178881
178956
|
}
|
178882
178957
|
__name(Progress, "Progress");
|
178883
178958
|
|
178959
|
+
// src/experimental-assets.ts
|
178960
|
+
var BULK_UPLOAD_CONCURRENCY2 = 3;
|
178961
|
+
var MAX_ASSET_COUNT2 = 2e4;
|
178962
|
+
var MAX_ASSET_SIZE2 = 25 * 1024 * 1024;
|
178963
|
+
var MAX_UPLOAD_ATTEMPTS2 = 5;
|
178964
|
+
var MAX_UPLOAD_GATEWAY_ERRORS2 = 5;
|
178965
|
+
var syncExperimentalAssets = /* @__PURE__ */ __name(async (accountId, scriptName, assetDirectory) => {
|
178966
|
+
(0, import_node_assert15.default)(accountId, "Missing accountId");
|
178967
|
+
logger.info("\u{1F300} Building list of assets...");
|
178968
|
+
const manifest = await walk(assetDirectory, {});
|
178969
|
+
logger.info("\u{1F300} Starting asset upload...");
|
178970
|
+
const initializeAssetsResponse = await fetchResult(
|
178971
|
+
`/accounts/${accountId}/workers/scripts/${scriptName}/assets-upload-session`,
|
178972
|
+
{
|
178973
|
+
headers: { "Content-Type": "application/json" },
|
178974
|
+
method: "POST",
|
178975
|
+
body: JSON.stringify({ manifest })
|
178976
|
+
}
|
178977
|
+
);
|
178978
|
+
if (initializeAssetsResponse.buckets.flat().length === 0) {
|
178979
|
+
if (!initializeAssetsResponse.jwt) {
|
178980
|
+
throw new FatalError(
|
178981
|
+
"Could not find assets information to attach to deployment. Please try again.",
|
178982
|
+
1
|
178983
|
+
);
|
178984
|
+
}
|
178985
|
+
logger.info(`No files to upload. Proceeding with deployment...`);
|
178986
|
+
return initializeAssetsResponse.jwt;
|
178987
|
+
}
|
178988
|
+
const numberFilesToUpload = initializeAssetsResponse.buckets.flat().length;
|
178989
|
+
logger.info(
|
178990
|
+
`\u{1F300} Found ${numberFilesToUpload} file${numberFilesToUpload > 1 ? "s" : ""} to upload. Proceeding with upload...`
|
178991
|
+
);
|
178992
|
+
const manifestLookup = Object.entries(manifest);
|
178993
|
+
let assetLogCount = 0;
|
178994
|
+
const assetBuckets = initializeAssetsResponse.buckets.map((bucket) => {
|
178995
|
+
return bucket.map((fileHash) => {
|
178996
|
+
const manifestEntry = manifestLookup.find(
|
178997
|
+
(file) => file[1].hash === fileHash
|
178998
|
+
);
|
178999
|
+
if (manifestEntry === void 0) {
|
179000
|
+
throw new FatalError(
|
179001
|
+
`A file was requested that does not appear to exist.`,
|
179002
|
+
1
|
179003
|
+
);
|
179004
|
+
}
|
179005
|
+
assetLogCount = logAssetUpload(`+ ${manifestEntry[0]}`, assetLogCount);
|
179006
|
+
return manifestEntry;
|
179007
|
+
});
|
179008
|
+
});
|
179009
|
+
const queue = new PQueue({ concurrency: BULK_UPLOAD_CONCURRENCY2 });
|
179010
|
+
let attempts = 0;
|
179011
|
+
const start = Date.now();
|
179012
|
+
let completionJwt = "";
|
179013
|
+
for (const [bucketIndex, bucket] of assetBuckets.entries()) {
|
179014
|
+
attempts = 0;
|
179015
|
+
let gatewayErrors = 0;
|
179016
|
+
const doUpload = /* @__PURE__ */ __name(async () => {
|
179017
|
+
const payload = await Promise.all(
|
179018
|
+
bucket.map(async (manifestEntry) => {
|
179019
|
+
const absFilePath = path39.join(assetDirectory, manifestEntry[0]);
|
179020
|
+
return {
|
179021
|
+
base64: true,
|
179022
|
+
key: manifestEntry[1].hash,
|
179023
|
+
metadata: {
|
179024
|
+
contentType: (0, import_mime3.getType)(absFilePath) || "application/octet-stream"
|
179025
|
+
},
|
179026
|
+
value: (await (0, import_promises13.readFile)(absFilePath)).toString("base64")
|
179027
|
+
};
|
179028
|
+
})
|
179029
|
+
);
|
179030
|
+
try {
|
179031
|
+
const res = await fetchResult(
|
179032
|
+
`/accounts/${accountId}/workers/assets/upload`,
|
179033
|
+
{
|
179034
|
+
method: "POST",
|
179035
|
+
headers: {
|
179036
|
+
"Content-Type": "application/jsonl",
|
179037
|
+
Authorization: `Bearer ${initializeAssetsResponse.jwt}`
|
179038
|
+
},
|
179039
|
+
body: payload.map((x2) => JSON.stringify(x2)).join("\n")
|
179040
|
+
}
|
179041
|
+
);
|
179042
|
+
logger.info(
|
179043
|
+
`Uploaded bucket ${bucketIndex + 1}/${initializeAssetsResponse.buckets.length}`
|
179044
|
+
);
|
179045
|
+
return res;
|
179046
|
+
} catch (e3) {
|
179047
|
+
if (attempts < MAX_UPLOAD_ATTEMPTS2) {
|
179048
|
+
logger.info(
|
179049
|
+
source_default.dim(
|
179050
|
+
`Bucket ${bucketIndex + 1}/${initializeAssetsResponse.buckets.length} upload failed. Retrying...
|
179051
|
+
`,
|
179052
|
+
e3
|
179053
|
+
)
|
179054
|
+
);
|
179055
|
+
await new Promise(
|
179056
|
+
(resolvePromise) => setTimeout(resolvePromise, Math.pow(2, attempts) * 1e3)
|
179057
|
+
);
|
179058
|
+
if (e3 instanceof APIError && e3.isGatewayError()) {
|
179059
|
+
queue.concurrency = 1;
|
179060
|
+
await new Promise(
|
179061
|
+
(resolvePromise) => setTimeout(resolvePromise, Math.pow(2, gatewayErrors) * 5e3)
|
179062
|
+
);
|
179063
|
+
gatewayErrors++;
|
179064
|
+
if (gatewayErrors >= MAX_UPLOAD_GATEWAY_ERRORS2) {
|
179065
|
+
attempts++;
|
179066
|
+
}
|
179067
|
+
} else {
|
179068
|
+
attempts++;
|
179069
|
+
}
|
179070
|
+
return doUpload();
|
179071
|
+
} else if (isJwtExpired(initializeAssetsResponse.jwt)) {
|
179072
|
+
throw new FatalError(
|
179073
|
+
`Upload took too long.
|
179074
|
+
Asset upload took too long on bucket ${bucketIndex + 1}/${initializeAssetsResponse.buckets.length}. Please try again.
|
179075
|
+
Assets already uploaded have been saved, so the next attempt will automatically resume from this point.`
|
179076
|
+
);
|
179077
|
+
} else {
|
179078
|
+
throw e3;
|
179079
|
+
}
|
179080
|
+
}
|
179081
|
+
}, "doUpload");
|
179082
|
+
void queue.add(
|
179083
|
+
() => doUpload().then((res) => {
|
179084
|
+
completionJwt = res.jwt || completionJwt;
|
179085
|
+
})
|
179086
|
+
);
|
179087
|
+
}
|
179088
|
+
queue.on("error", (error2) => {
|
179089
|
+
logger.error(error2.message);
|
179090
|
+
throw error2;
|
179091
|
+
});
|
179092
|
+
await queue.onIdle();
|
179093
|
+
if (!completionJwt) {
|
179094
|
+
throw new FatalError(
|
179095
|
+
"Failed to complete asset upload. Please try again.",
|
179096
|
+
1
|
179097
|
+
);
|
179098
|
+
}
|
179099
|
+
const uploadMs = Date.now() - start;
|
179100
|
+
const skipped = Object.keys(manifest).length - numberFilesToUpload;
|
179101
|
+
const skippedMessage = skipped > 0 ? `(${skipped} already uploaded) ` : "";
|
179102
|
+
logger.log(
|
179103
|
+
`\u2728 Success! Uploaded ${numberFilesToUpload} file${numberFilesToUpload > 1 ? "s" : ""} ${skippedMessage}${formatTime2(uploadMs)}
|
179104
|
+
`
|
179105
|
+
);
|
179106
|
+
return completionJwt;
|
179107
|
+
}, "syncExperimentalAssets");
|
179108
|
+
var walk = /* @__PURE__ */ __name(async (dir, manifest, startingDir = dir) => {
|
179109
|
+
const files = await (0, import_promises13.readdir)(dir);
|
179110
|
+
let counter = 0;
|
179111
|
+
await Promise.all(
|
179112
|
+
files.map(async (file) => {
|
179113
|
+
const filepath = path39.join(dir, file);
|
179114
|
+
const relativeFilepath = path39.relative(startingDir, filepath);
|
179115
|
+
const filestat = await (0, import_promises13.stat)(filepath);
|
179116
|
+
if (filestat.isSymbolicLink()) {
|
179117
|
+
return;
|
179118
|
+
}
|
179119
|
+
if (filestat.isDirectory()) {
|
179120
|
+
manifest = await walk(filepath, manifest, startingDir);
|
179121
|
+
} else {
|
179122
|
+
if (counter >= MAX_ASSET_COUNT2) {
|
179123
|
+
throw new UserError(
|
179124
|
+
`Maximum number of assets exceeded.
|
179125
|
+
Cloudflare Workers supports up to ${MAX_ASSET_COUNT2.toLocaleString()} assets in a version. We found ${counter.toLocaleString()} files in the specified assets directory "${startingDir}".
|
179126
|
+
Ensure your assets directory contains a maximum of ${MAX_ASSET_COUNT2.toLocaleString()} files, and that you have specified your assets directory correctly.`
|
179127
|
+
);
|
179128
|
+
}
|
179129
|
+
if (filestat.size > MAX_ASSET_SIZE2) {
|
179130
|
+
throw new UserError(
|
179131
|
+
`Asset too large.
|
179132
|
+
Cloudflare Workers supports assets with sizes of up to ${prettyBytes(
|
179133
|
+
MAX_ASSET_SIZE2,
|
179134
|
+
{
|
179135
|
+
binary: true
|
179136
|
+
}
|
179137
|
+
)}. We found a file ${filepath} with a size of ${prettyBytes(
|
179138
|
+
filestat.size,
|
179139
|
+
{
|
179140
|
+
binary: true
|
179141
|
+
}
|
179142
|
+
)}.
|
179143
|
+
Ensure all assets in your assets directory "${startingDir}" conform with the Workers maximum size requirement.`
|
179144
|
+
);
|
179145
|
+
}
|
179146
|
+
manifest[encodeFilePath(relativeFilepath)] = {
|
179147
|
+
hash: hashFile(filepath),
|
179148
|
+
size: filestat.size
|
179149
|
+
};
|
179150
|
+
counter++;
|
179151
|
+
}
|
179152
|
+
})
|
179153
|
+
);
|
179154
|
+
return manifest;
|
179155
|
+
}, "walk");
|
179156
|
+
var MAX_DIFF_LINES = 100;
|
179157
|
+
function logAssetUpload(line, diffCount) {
|
179158
|
+
const level = logger.loggerLevel;
|
179159
|
+
if (LOGGER_LEVELS[level] >= LOGGER_LEVELS.debug) {
|
179160
|
+
logger.debug(line);
|
179161
|
+
} else if (diffCount < MAX_DIFF_LINES) {
|
179162
|
+
logger.info(line);
|
179163
|
+
} else if (diffCount === MAX_DIFF_LINES) {
|
179164
|
+
const msg = " (truncating changed assets log, set `WRANGLER_LOG=debug` environment variable to see full diff)";
|
179165
|
+
logger.info(source_default.dim(msg));
|
179166
|
+
}
|
179167
|
+
return diffCount++;
|
179168
|
+
}
|
179169
|
+
__name(logAssetUpload, "logAssetUpload");
|
179170
|
+
function getExperimentalAssetsBasePath(config, experimentalAssetsCommandLineArg) {
|
179171
|
+
return experimentalAssetsCommandLineArg ? process.cwd() : path39.resolve(path39.dirname(config.configPath ?? "wrangler.toml"));
|
179172
|
+
}
|
179173
|
+
__name(getExperimentalAssetsBasePath, "getExperimentalAssetsBasePath");
|
179174
|
+
function processExperimentalAssetsArg(args, config) {
|
179175
|
+
const experimentalAssets = args.experimentalAssets ? { directory: args.experimentalAssets } : config.experimental_assets;
|
179176
|
+
if (experimentalAssets) {
|
179177
|
+
const experimentalAssetsBasePath = getExperimentalAssetsBasePath(
|
179178
|
+
config,
|
179179
|
+
args.experimentalAssets
|
179180
|
+
);
|
179181
|
+
const resolvedExperimentalAssetsPath = path39.resolve(
|
179182
|
+
experimentalAssetsBasePath,
|
179183
|
+
experimentalAssets.directory
|
179184
|
+
);
|
179185
|
+
if (!(0, import_node_fs20.existsSync)(resolvedExperimentalAssetsPath)) {
|
179186
|
+
const sourceOfTruthMessage = args.experimentalAssets ? '"--experimental-assets" command line argument' : '"experimental_assets.directory" field in your configuration file';
|
179187
|
+
throw new UserError(
|
179188
|
+
`The directory specified by the ${sourceOfTruthMessage} does not exist:
|
179189
|
+
${resolvedExperimentalAssetsPath}`
|
179190
|
+
);
|
179191
|
+
}
|
179192
|
+
experimentalAssets.directory = resolvedExperimentalAssetsPath;
|
179193
|
+
}
|
179194
|
+
return experimentalAssets;
|
179195
|
+
}
|
179196
|
+
__name(processExperimentalAssetsArg, "processExperimentalAssetsArg");
|
179197
|
+
var encodeFilePath = /* @__PURE__ */ __name((filePath) => {
|
179198
|
+
const encodedPath = filePath.split(path39.sep).map((segment) => encodeURIComponent(segment)).join("/");
|
179199
|
+
return "/" + encodedPath;
|
179200
|
+
}, "encodeFilePath");
|
179201
|
+
|
179202
|
+
// src/output.ts
|
179203
|
+
init_import_meta_url();
|
179204
|
+
var import_node_crypto6 = require("node:crypto");
|
179205
|
+
var import_node_fs21 = require("node:fs");
|
179206
|
+
var import_node_path35 = require("node:path");
|
179207
|
+
function writeOutput(entry) {
|
179208
|
+
if (outputFilePath === void 0) {
|
179209
|
+
outputFilePath = getOutputFilePath();
|
179210
|
+
}
|
179211
|
+
if (outputFilePath !== null) {
|
179212
|
+
ensureDirectoryExistsSync(outputFilePath);
|
179213
|
+
const entryJSON = JSON.stringify({
|
179214
|
+
...entry,
|
179215
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
179216
|
+
});
|
179217
|
+
(0, import_node_fs21.appendFileSync)(outputFilePath, entryJSON + "\n");
|
179218
|
+
}
|
179219
|
+
}
|
179220
|
+
__name(writeOutput, "writeOutput");
|
179221
|
+
var outputFilePath = void 0;
|
179222
|
+
function getOutputFilePath() {
|
179223
|
+
const outputFilePathFromEnv = getOutputFilePathFromEnv();
|
179224
|
+
if (outputFilePathFromEnv) {
|
179225
|
+
return outputFilePathFromEnv;
|
179226
|
+
}
|
179227
|
+
const outputFileDirectoryFromEnv = getOutputFileDirectoryFromEnv();
|
179228
|
+
if (outputFileDirectoryFromEnv) {
|
179229
|
+
const date = (/* @__PURE__ */ new Date()).toISOString().replaceAll(":", "-").replace(".", "_").replace("T", "_").replace("Z", "");
|
179230
|
+
return (0, import_node_path35.resolve)(
|
179231
|
+
outputFileDirectoryFromEnv,
|
179232
|
+
`wrangler-output-${date}-${(0, import_node_crypto6.randomBytes)(3).toString("hex")}.json`
|
179233
|
+
);
|
179234
|
+
}
|
179235
|
+
return null;
|
179236
|
+
}
|
179237
|
+
__name(getOutputFilePath, "getOutputFilePath");
|
179238
|
+
|
178884
179239
|
// src/sites.ts
|
178885
179240
|
init_import_meta_url();
|
178886
|
-
var
|
178887
|
-
var
|
178888
|
-
var
|
179241
|
+
var import_node_assert16 = __toESM(require("node:assert"));
|
179242
|
+
var import_promises14 = require("node:fs/promises");
|
179243
|
+
var path40 = __toESM(require("node:path"));
|
178889
179244
|
var import_ignore = __toESM(require_ignore());
|
178890
179245
|
|
178891
179246
|
// ../../node_modules/.pnpm/xxhash-wasm@1.0.1/node_modules/xxhash-wasm/esm/xxhash-wasm.js
|
@@ -178955,7 +179310,7 @@ var HIDDEN_FILES_TO_INCLUDE = /* @__PURE__ */ new Set([
|
|
178955
179310
|
// See https://datatracker.ietf.org/doc/html/rfc8615
|
178956
179311
|
]);
|
178957
179312
|
async function* getFilesInFolder(dirPath) {
|
178958
|
-
const files = await (0,
|
179313
|
+
const files = await (0, import_promises14.readdir)(dirPath, { withFileTypes: true });
|
178959
179314
|
for (const file of files) {
|
178960
179315
|
if (ALWAYS_IGNORE.has(file.name)) {
|
178961
179316
|
continue;
|
@@ -178964,9 +179319,9 @@ async function* getFilesInFolder(dirPath) {
|
|
178964
179319
|
continue;
|
178965
179320
|
}
|
178966
179321
|
if (file.isDirectory()) {
|
178967
|
-
yield* await getFilesInFolder(
|
179322
|
+
yield* await getFilesInFolder(path40.join(dirPath, file.name));
|
178968
179323
|
} else {
|
178969
|
-
yield
|
179324
|
+
yield path40.join(dirPath, file.name);
|
178970
179325
|
}
|
178971
179326
|
}
|
178972
179327
|
}
|
@@ -178976,11 +179331,11 @@ function hashFileContent(hasher, content) {
|
|
178976
179331
|
}
|
178977
179332
|
__name(hashFileContent, "hashFileContent");
|
178978
179333
|
function hashAsset(hasher, filePath, content) {
|
178979
|
-
const extName =
|
178980
|
-
const baseName =
|
178981
|
-
const directory =
|
179334
|
+
const extName = path40.extname(filePath) || "";
|
179335
|
+
const baseName = path40.basename(filePath, extName);
|
179336
|
+
const directory = path40.dirname(filePath);
|
178982
179337
|
const hash = hashFileContent(hasher, content);
|
178983
|
-
return urlSafe(
|
179338
|
+
return urlSafe(path40.join(directory, `${baseName}.${hash}${extName}`));
|
178984
179339
|
}
|
178985
179340
|
__name(hashAsset, "hashAsset");
|
178986
179341
|
async function createKVNamespaceIfNotAlreadyExisting(title, accountId) {
|
@@ -178997,7 +179352,7 @@ async function createKVNamespaceIfNotAlreadyExisting(title, accountId) {
|
|
178997
179352
|
};
|
178998
179353
|
}
|
178999
179354
|
__name(createKVNamespaceIfNotAlreadyExisting, "createKVNamespaceIfNotAlreadyExisting");
|
179000
|
-
var
|
179355
|
+
var MAX_DIFF_LINES2 = 100;
|
179001
179356
|
var MAX_BUCKET_SIZE2 = 98 * 1e3 * 1e3;
|
179002
179357
|
var MAX_BUCKET_KEYS = BATCH_KEY_MAX;
|
179003
179358
|
var MAX_BATCH_OPERATIONS = 5;
|
@@ -179013,7 +179368,7 @@ async function syncLegacyAssets(accountId, scriptName, siteAssets, preview, dryR
|
|
179013
179368
|
logger.log("(Note: doing a dry run, not uploading or deleting anything.)");
|
179014
179369
|
return { manifest: void 0, namespace: void 0 };
|
179015
179370
|
}
|
179016
|
-
(0,
|
179371
|
+
(0, import_node_assert16.default)(accountId, "Missing accountId");
|
179017
179372
|
const title = `__${scriptName}-workers_sites_assets${preview ? "_preview" : ""}`;
|
179018
179373
|
const { id: namespace } = await createKVNamespaceIfNotAlreadyExisting(
|
179019
179374
|
title,
|
@@ -179023,7 +179378,7 @@ async function syncLegacyAssets(accountId, scriptName, siteAssets, preview, dryR
|
|
179023
179378
|
const namespaceKeysResponse = await listKVNamespaceKeys(accountId, namespace);
|
179024
179379
|
const namespaceKeyInfoMap = new Map(namespaceKeysResponse.map((x2) => [x2.name, x2]));
|
179025
179380
|
const namespaceKeys = new Set(namespaceKeysResponse.map((x2) => x2.name));
|
179026
|
-
const assetDirectory =
|
179381
|
+
const assetDirectory = path40.join(
|
179027
179382
|
siteAssets.baseDirectory,
|
179028
179383
|
siteAssets.assetDirectory
|
179029
179384
|
);
|
@@ -179041,9 +179396,9 @@ async function syncLegacyAssets(accountId, scriptName, siteAssets, preview, dryR
|
|
179041
179396
|
const level = logger.loggerLevel;
|
179042
179397
|
if (LOGGER_LEVELS[level] >= LOGGER_LEVELS.debug) {
|
179043
179398
|
logger.debug(line);
|
179044
|
-
} else if (diffCount <
|
179399
|
+
} else if (diffCount < MAX_DIFF_LINES2) {
|
179045
179400
|
logger.info(line);
|
179046
|
-
} else if (diffCount ===
|
179401
|
+
} else if (diffCount === MAX_DIFF_LINES2) {
|
179047
179402
|
const msg = " (truncating changed assets log, set `WRANGLER_LOG=debug` environment variable to see full diff)";
|
179048
179403
|
logger.info(source_default.dim(msg));
|
179049
179404
|
}
|
@@ -179052,11 +179407,11 @@ async function syncLegacyAssets(accountId, scriptName, siteAssets, preview, dryR
|
|
179052
179407
|
__name(logDiff, "logDiff");
|
179053
179408
|
logger.info("Building list of assets to upload...");
|
179054
179409
|
for await (const absAssetFile of getFilesInFolder(assetDirectory)) {
|
179055
|
-
const assetFile =
|
179410
|
+
const assetFile = path40.relative(assetDirectory, absAssetFile);
|
179056
179411
|
if (!include(assetFile) || exclude(assetFile)) {
|
179057
179412
|
continue;
|
179058
179413
|
}
|
179059
|
-
const content = await (0,
|
179414
|
+
const content = await (0, import_promises14.readFile)(absAssetFile, "base64");
|
179060
179415
|
const assetSize = Buffer.byteLength(content);
|
179061
179416
|
await validateAssetSize(absAssetFile, assetFile);
|
179062
179417
|
const assetKey = hashAsset(hasher, assetFile, content);
|
@@ -179078,7 +179433,7 @@ async function syncLegacyAssets(accountId, scriptName, siteAssets, preview, dryR
|
|
179078
179433
|
skipCount++;
|
179079
179434
|
}
|
179080
179435
|
namespaceKeys.delete(assetKey);
|
179081
|
-
const manifestKey = urlSafe(
|
179436
|
+
const manifestKey = urlSafe(path40.relative(assetDirectory, absAssetFile));
|
179082
179437
|
manifest[manifestKey] = assetKey;
|
179083
179438
|
}
|
179084
179439
|
if (uploadBucket.length > 0) {
|
@@ -179111,7 +179466,7 @@ async function syncLegacyAssets(accountId, scriptName, siteAssets, preview, dryR
|
|
179111
179466
|
for (const [absAssetFile, assetKey] of nextBucket) {
|
179112
179467
|
bucket.push({
|
179113
179468
|
key: assetKey,
|
179114
|
-
value: await (0,
|
179469
|
+
value: await (0, import_promises14.readFile)(absAssetFile, "base64"),
|
179115
179470
|
base64: true
|
179116
179471
|
});
|
179117
179472
|
if (controller.signal.aborted) {
|
@@ -179199,7 +179554,7 @@ function createPatternMatcher(patterns, exclude) {
|
|
179199
179554
|
}
|
179200
179555
|
__name(createPatternMatcher, "createPatternMatcher");
|
179201
179556
|
async function validateAssetSize(absFilePath, relativeFilePath) {
|
179202
|
-
const { size } = await (0,
|
179557
|
+
const { size } = await (0, import_promises14.stat)(absFilePath);
|
179203
179558
|
if (size > 25 * 1024 * 1024) {
|
179204
179559
|
throw new UserError(
|
179205
179560
|
`File ${relativeFilePath} is too big, it should be under 25 MiB. See https://developers.cloudflare.com/workers/platform/limits#kv-limits`
|
@@ -179220,7 +179575,7 @@ function urlSafe(filePath) {
|
|
179220
179575
|
}
|
179221
179576
|
__name(urlSafe, "urlSafe");
|
179222
179577
|
function getLegacyAssetPaths(config, assetDirectory) {
|
179223
|
-
const baseDirectory = assetDirectory ? process.cwd() :
|
179578
|
+
const baseDirectory = assetDirectory ? process.cwd() : path40.resolve(path40.dirname(config.configPath ?? "wrangler.toml"));
|
179224
179579
|
assetDirectory ??= typeof config.legacy_assets === "string" ? config.legacy_assets : config.legacy_assets !== void 0 ? config.legacy_assets.bucket : void 0;
|
179225
179580
|
const includePatterns = typeof config.legacy_assets !== "string" && config.legacy_assets?.include || [];
|
179226
179581
|
const excludePatterns = typeof config.legacy_assets !== "string" && config.legacy_assets?.exclude || [];
|
@@ -179233,7 +179588,7 @@ function getLegacyAssetPaths(config, assetDirectory) {
|
|
179233
179588
|
}
|
179234
179589
|
__name(getLegacyAssetPaths, "getLegacyAssetPaths");
|
179235
179590
|
function getSiteAssetPaths(config, assetDirectory, includePatterns = config.site?.include ?? [], excludePatterns = config.site?.exclude ?? []) {
|
179236
|
-
const baseDirectory = assetDirectory ? process.cwd() :
|
179591
|
+
const baseDirectory = assetDirectory ? process.cwd() : path40.resolve(path40.dirname(config.configPath ?? "wrangler.toml"));
|
179237
179592
|
assetDirectory ??= config.site?.bucket;
|
179238
179593
|
if (assetDirectory) {
|
179239
179594
|
return {
|
@@ -179248,283 +179603,6 @@ function getSiteAssetPaths(config, assetDirectory, includePatterns = config.site
|
|
179248
179603
|
}
|
179249
179604
|
__name(getSiteAssetPaths, "getSiteAssetPaths");
|
179250
179605
|
|
179251
|
-
// src/experimental-assets.ts
|
179252
|
-
var BULK_UPLOAD_CONCURRENCY2 = 3;
|
179253
|
-
var MAX_ASSET_COUNT2 = 2e4;
|
179254
|
-
var MAX_ASSET_SIZE2 = 25 * 1024 * 1024;
|
179255
|
-
var MAX_UPLOAD_ATTEMPTS2 = 5;
|
179256
|
-
var MAX_UPLOAD_GATEWAY_ERRORS2 = 5;
|
179257
|
-
var syncExperimentalAssets = /* @__PURE__ */ __name(async (accountId, scriptName, assetDirectory) => {
|
179258
|
-
(0, import_node_assert16.default)(accountId, "Missing accountId");
|
179259
|
-
logger.info("\u{1F300} Building list of assets...");
|
179260
|
-
const manifest = await walk(assetDirectory, {});
|
179261
|
-
logger.info("\u{1F300} Starting asset upload...");
|
179262
|
-
const initializeAssetsResponse = await fetchResult(
|
179263
|
-
`/accounts/${accountId}/workers/scripts/${scriptName}/assets-upload-session`,
|
179264
|
-
{
|
179265
|
-
headers: { "Content-Type": "application/json" },
|
179266
|
-
method: "POST",
|
179267
|
-
body: JSON.stringify({ manifest })
|
179268
|
-
}
|
179269
|
-
);
|
179270
|
-
if (initializeAssetsResponse.buckets.flat().length === 0) {
|
179271
|
-
if (!initializeAssetsResponse.jwt) {
|
179272
|
-
throw new FatalError(
|
179273
|
-
"Could not find assets information to attach to deployment. Please try again.",
|
179274
|
-
1
|
179275
|
-
);
|
179276
|
-
}
|
179277
|
-
logger.info(`No files to upload. Proceeding with deployment...`);
|
179278
|
-
return initializeAssetsResponse.jwt;
|
179279
|
-
}
|
179280
|
-
const numberFilesToUpload = initializeAssetsResponse.buckets.flat().length;
|
179281
|
-
logger.info(
|
179282
|
-
`\u{1F300} Found ${numberFilesToUpload} file${numberFilesToUpload > 1 ? "s" : ""} to upload. Proceeding with upload...`
|
179283
|
-
);
|
179284
|
-
const manifestLookup = Object.entries(manifest);
|
179285
|
-
let assetLogCount = 0;
|
179286
|
-
const assetBuckets = initializeAssetsResponse.buckets.map((bucket) => {
|
179287
|
-
return bucket.map((fileHash) => {
|
179288
|
-
const manifestEntry = manifestLookup.find(
|
179289
|
-
(file) => file[1].hash === fileHash
|
179290
|
-
);
|
179291
|
-
if (manifestEntry === void 0) {
|
179292
|
-
throw new FatalError(
|
179293
|
-
`A file was requested that does not appear to exist.`,
|
179294
|
-
1
|
179295
|
-
);
|
179296
|
-
}
|
179297
|
-
assetLogCount = logAssetUpload(`+ ${manifestEntry[0]}`, assetLogCount);
|
179298
|
-
return manifestEntry;
|
179299
|
-
});
|
179300
|
-
});
|
179301
|
-
const queue = new PQueue({ concurrency: BULK_UPLOAD_CONCURRENCY2 });
|
179302
|
-
let attempts = 0;
|
179303
|
-
const start = Date.now();
|
179304
|
-
let completionJwt = "";
|
179305
|
-
for (const [bucketIndex, bucket] of assetBuckets.entries()) {
|
179306
|
-
attempts = 0;
|
179307
|
-
let gatewayErrors = 0;
|
179308
|
-
const doUpload = /* @__PURE__ */ __name(async () => {
|
179309
|
-
const payload = await Promise.all(
|
179310
|
-
bucket.map(async (manifestEntry) => {
|
179311
|
-
const absFilePath = path40.join(assetDirectory, manifestEntry[0]);
|
179312
|
-
return {
|
179313
|
-
base64: true,
|
179314
|
-
key: manifestEntry[1].hash,
|
179315
|
-
metadata: {
|
179316
|
-
contentType: (0, import_mime3.getType)(absFilePath) || "application/octet-stream"
|
179317
|
-
},
|
179318
|
-
value: (await (0, import_promises14.readFile)(absFilePath)).toString("base64")
|
179319
|
-
};
|
179320
|
-
})
|
179321
|
-
);
|
179322
|
-
try {
|
179323
|
-
const res = await fetchResult(
|
179324
|
-
`/accounts/${accountId}/workers/assets/upload`,
|
179325
|
-
{
|
179326
|
-
method: "POST",
|
179327
|
-
headers: {
|
179328
|
-
"Content-Type": "application/x-ndjson",
|
179329
|
-
Authorization: `Bearer ${initializeAssetsResponse.jwt}`
|
179330
|
-
},
|
179331
|
-
body: payload.map((x2) => JSON.stringify(x2)).join("\n")
|
179332
|
-
}
|
179333
|
-
);
|
179334
|
-
logger.info(
|
179335
|
-
`Uploaded bucket ${bucketIndex + 1}/${initializeAssetsResponse.buckets.length}`
|
179336
|
-
);
|
179337
|
-
return res;
|
179338
|
-
} catch (e3) {
|
179339
|
-
if (attempts < MAX_UPLOAD_ATTEMPTS2) {
|
179340
|
-
logger.info(
|
179341
|
-
source_default.dim(
|
179342
|
-
`Bucket ${bucketIndex + 1}/${initializeAssetsResponse.buckets.length} upload failed. Retrying...
|
179343
|
-
`,
|
179344
|
-
e3
|
179345
|
-
)
|
179346
|
-
);
|
179347
|
-
await new Promise(
|
179348
|
-
(resolvePromise) => setTimeout(resolvePromise, Math.pow(2, attempts) * 1e3)
|
179349
|
-
);
|
179350
|
-
if (e3 instanceof APIError && e3.isGatewayError()) {
|
179351
|
-
queue.concurrency = 1;
|
179352
|
-
await new Promise(
|
179353
|
-
(resolvePromise) => setTimeout(resolvePromise, Math.pow(2, gatewayErrors) * 5e3)
|
179354
|
-
);
|
179355
|
-
gatewayErrors++;
|
179356
|
-
if (gatewayErrors >= MAX_UPLOAD_GATEWAY_ERRORS2) {
|
179357
|
-
attempts++;
|
179358
|
-
}
|
179359
|
-
} else {
|
179360
|
-
attempts++;
|
179361
|
-
}
|
179362
|
-
return doUpload();
|
179363
|
-
} else if (isJwtExpired(initializeAssetsResponse.jwt)) {
|
179364
|
-
throw new FatalError(
|
179365
|
-
`Upload took too long.
|
179366
|
-
Asset upload took too long on bucket ${bucketIndex + 1}/${initializeAssetsResponse.buckets.length}. Please try again.
|
179367
|
-
Assets already uploaded have been saved, so the next attempt will automatically resume from this point.`
|
179368
|
-
);
|
179369
|
-
} else {
|
179370
|
-
throw e3;
|
179371
|
-
}
|
179372
|
-
}
|
179373
|
-
}, "doUpload");
|
179374
|
-
void queue.add(
|
179375
|
-
() => doUpload().then((res) => {
|
179376
|
-
completionJwt = res.jwt || completionJwt;
|
179377
|
-
})
|
179378
|
-
);
|
179379
|
-
}
|
179380
|
-
queue.on("error", (error2) => {
|
179381
|
-
logger.error(error2.message);
|
179382
|
-
throw error2;
|
179383
|
-
});
|
179384
|
-
await queue.onIdle();
|
179385
|
-
if (!completionJwt) {
|
179386
|
-
throw new FatalError(
|
179387
|
-
"Failed to complete asset upload. Please try again.",
|
179388
|
-
1
|
179389
|
-
);
|
179390
|
-
}
|
179391
|
-
const uploadMs = Date.now() - start;
|
179392
|
-
const skipped = Object.keys(manifest).length - numberFilesToUpload;
|
179393
|
-
const skippedMessage = skipped > 0 ? `(${skipped} already uploaded) ` : "";
|
179394
|
-
logger.log(
|
179395
|
-
`\u2728 Success! Uploaded ${numberFilesToUpload} file${numberFilesToUpload > 1 ? "s" : ""} ${skippedMessage}${formatTime2(uploadMs)}
|
179396
|
-
`
|
179397
|
-
);
|
179398
|
-
return completionJwt;
|
179399
|
-
}, "syncExperimentalAssets");
|
179400
|
-
var walk = /* @__PURE__ */ __name(async (dir, manifest, startingDir = dir) => {
|
179401
|
-
const files = await (0, import_promises14.readdir)(dir);
|
179402
|
-
let counter = 0;
|
179403
|
-
await Promise.all(
|
179404
|
-
files.map(async (file) => {
|
179405
|
-
const filepath = path40.join(dir, file);
|
179406
|
-
const relativeFilepath = path40.relative(startingDir, filepath);
|
179407
|
-
const filestat = await (0, import_promises14.stat)(filepath);
|
179408
|
-
if (filestat.isSymbolicLink()) {
|
179409
|
-
return;
|
179410
|
-
}
|
179411
|
-
if (filestat.isDirectory()) {
|
179412
|
-
manifest = await walk(filepath, manifest, startingDir);
|
179413
|
-
} else {
|
179414
|
-
if (counter >= MAX_ASSET_COUNT2) {
|
179415
|
-
throw new UserError(
|
179416
|
-
`Maximum number of assets exceeded.
|
179417
|
-
Cloudflare Workers supports up to ${MAX_ASSET_COUNT2.toLocaleString()} assets in a version. We found ${counter.toLocaleString()} files in the specified assets directory "${startingDir}".
|
179418
|
-
Ensure your assets directory contains a maximum of ${MAX_ASSET_COUNT2.toLocaleString()} files, and that you have specified your assets directory correctly.`
|
179419
|
-
);
|
179420
|
-
}
|
179421
|
-
const name = urlSafe(relativeFilepath);
|
179422
|
-
if (filestat.size > MAX_ASSET_SIZE2) {
|
179423
|
-
throw new UserError(
|
179424
|
-
`Asset too large.
|
179425
|
-
Cloudflare Workers supports assets with sizes of up to ${prettyBytes(
|
179426
|
-
MAX_ASSET_SIZE2,
|
179427
|
-
{
|
179428
|
-
binary: true
|
179429
|
-
}
|
179430
|
-
)}. We found a file ${filepath} with a size of ${prettyBytes(
|
179431
|
-
filestat.size,
|
179432
|
-
{
|
179433
|
-
binary: true
|
179434
|
-
}
|
179435
|
-
)}.
|
179436
|
-
Ensure all assets in your assets directory "${startingDir}" conform with the Workers maximum size requirement.`
|
179437
|
-
);
|
179438
|
-
}
|
179439
|
-
manifest[urlSafe(path40.join("/", name))] = {
|
179440
|
-
hash: hashFile(filepath),
|
179441
|
-
size: filestat.size
|
179442
|
-
};
|
179443
|
-
counter++;
|
179444
|
-
}
|
179445
|
-
})
|
179446
|
-
);
|
179447
|
-
return manifest;
|
179448
|
-
}, "walk");
|
179449
|
-
var MAX_DIFF_LINES2 = 100;
|
179450
|
-
function logAssetUpload(line, diffCount) {
|
179451
|
-
const level = logger.loggerLevel;
|
179452
|
-
if (LOGGER_LEVELS[level] >= LOGGER_LEVELS.debug) {
|
179453
|
-
logger.debug(line);
|
179454
|
-
} else if (diffCount < MAX_DIFF_LINES2) {
|
179455
|
-
logger.info(line);
|
179456
|
-
} else if (diffCount === MAX_DIFF_LINES2) {
|
179457
|
-
const msg = " (truncating changed assets log, set `WRANGLER_LOG=debug` environment variable to see full diff)";
|
179458
|
-
logger.info(source_default.dim(msg));
|
179459
|
-
}
|
179460
|
-
return diffCount++;
|
179461
|
-
}
|
179462
|
-
__name(logAssetUpload, "logAssetUpload");
|
179463
|
-
function getExperimentalAssetsBasePath(config, experimentalAssetsCommandLineArg) {
|
179464
|
-
return experimentalAssetsCommandLineArg ? process.cwd() : path40.resolve(path40.dirname(config.configPath ?? "wrangler.toml"));
|
179465
|
-
}
|
179466
|
-
__name(getExperimentalAssetsBasePath, "getExperimentalAssetsBasePath");
|
179467
|
-
function processExperimentalAssetsArg(args, config) {
|
179468
|
-
const experimentalAssets = args.experimentalAssets ? { directory: args.experimentalAssets } : config.experimental_assets;
|
179469
|
-
if (experimentalAssets) {
|
179470
|
-
const experimentalAssetsBasePath = getExperimentalAssetsBasePath(
|
179471
|
-
config,
|
179472
|
-
args.experimentalAssets
|
179473
|
-
);
|
179474
|
-
const resolvedExperimentalAssetsPath = path40.resolve(
|
179475
|
-
experimentalAssetsBasePath,
|
179476
|
-
experimentalAssets.directory
|
179477
|
-
);
|
179478
|
-
if (!(0, import_node_fs20.existsSync)(resolvedExperimentalAssetsPath)) {
|
179479
|
-
const sourceOfTruthMessage = args.experimentalAssets ? '"--experimental-assets" command line argument' : '"experimental_assets.directory" field in your configuration file';
|
179480
|
-
throw new UserError(
|
179481
|
-
`The directory specified by the ${sourceOfTruthMessage} does not exist:
|
179482
|
-
${resolvedExperimentalAssetsPath}`
|
179483
|
-
);
|
179484
|
-
}
|
179485
|
-
experimentalAssets.directory = resolvedExperimentalAssetsPath;
|
179486
|
-
}
|
179487
|
-
return experimentalAssets;
|
179488
|
-
}
|
179489
|
-
__name(processExperimentalAssetsArg, "processExperimentalAssetsArg");
|
179490
|
-
|
179491
|
-
// src/output.ts
|
179492
|
-
init_import_meta_url();
|
179493
|
-
var import_node_crypto6 = require("node:crypto");
|
179494
|
-
var import_node_fs21 = require("node:fs");
|
179495
|
-
var import_node_path35 = require("node:path");
|
179496
|
-
function writeOutput(entry) {
|
179497
|
-
if (outputFilePath === void 0) {
|
179498
|
-
outputFilePath = getOutputFilePath();
|
179499
|
-
}
|
179500
|
-
if (outputFilePath !== null) {
|
179501
|
-
ensureDirectoryExistsSync(outputFilePath);
|
179502
|
-
const entryJSON = JSON.stringify({
|
179503
|
-
...entry,
|
179504
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
179505
|
-
});
|
179506
|
-
(0, import_node_fs21.appendFileSync)(outputFilePath, entryJSON + "\n");
|
179507
|
-
}
|
179508
|
-
}
|
179509
|
-
__name(writeOutput, "writeOutput");
|
179510
|
-
var outputFilePath = void 0;
|
179511
|
-
function getOutputFilePath() {
|
179512
|
-
const outputFilePathFromEnv = getOutputFilePathFromEnv();
|
179513
|
-
if (outputFilePathFromEnv) {
|
179514
|
-
return outputFilePathFromEnv;
|
179515
|
-
}
|
179516
|
-
const outputFileDirectoryFromEnv = getOutputFileDirectoryFromEnv();
|
179517
|
-
if (outputFileDirectoryFromEnv) {
|
179518
|
-
const date = (/* @__PURE__ */ new Date()).toISOString().replaceAll(":", "-").replace(".", "_").replace("T", "_").replace("Z", "");
|
179519
|
-
return (0, import_node_path35.resolve)(
|
179520
|
-
outputFileDirectoryFromEnv,
|
179521
|
-
`wrangler-output-${date}-${(0, import_node_crypto6.randomBytes)(3).toString("hex")}.json`
|
179522
|
-
);
|
179523
|
-
}
|
179524
|
-
return null;
|
179525
|
-
}
|
179526
|
-
__name(getOutputFilePath, "getOutputFilePath");
|
179527
|
-
|
179528
179606
|
// src/utils/collectKeyValues.ts
|
179529
179607
|
init_import_meta_url();
|
179530
179608
|
function collectKeyValues(array) {
|
@@ -179774,10 +179852,6 @@ Please shift to the --legacy-assets command to preserve the current functionalit
|
|
179774
179852
|
if (!args.dryRun) {
|
179775
179853
|
await standardPricingWarning(config);
|
179776
179854
|
}
|
179777
|
-
const experimentalAssetsOptions = experimentalAssets ? {
|
179778
|
-
...experimentalAssets,
|
179779
|
-
staticAssetsOnly: !(args.script || config.main)
|
179780
|
-
} : void 0;
|
179781
179855
|
const beforeUpload = Date.now();
|
179782
179856
|
const name = getScriptName(args, config);
|
179783
179857
|
const { sourceMapSize, deploymentId, workerTag } = await deploy({
|
@@ -179797,7 +179871,7 @@ Please shift to the --legacy-assets command to preserve the current functionalit
|
|
179797
179871
|
jsxFragment: args.jsxFragment,
|
179798
179872
|
tsconfig: args.tsconfig,
|
179799
179873
|
routes: args.routes,
|
179800
|
-
experimentalAssets
|
179874
|
+
experimentalAssets,
|
179801
179875
|
legacyAssetPaths,
|
179802
179876
|
legacyEnv: isLegacyEnv(config),
|
179803
179877
|
minify: args.minify,
|
@@ -181740,7 +181814,8 @@ function createWorkerBundleFormData(workerBundle, config) {
|
|
181740
181814
|
data_blobs: void 0,
|
181741
181815
|
dispatch_namespaces: void 0,
|
181742
181816
|
logfwdr: void 0,
|
181743
|
-
unsafe: void 0
|
181817
|
+
unsafe: void 0,
|
181818
|
+
experimental_assets: void 0
|
181744
181819
|
};
|
181745
181820
|
const placement = config?.placement?.mode === "smart" ? { mode: "smart" } : void 0;
|
181746
181821
|
const worker = {
|
@@ -181759,7 +181834,7 @@ function createWorkerBundleFormData(workerBundle, config) {
|
|
181759
181834
|
placement,
|
181760
181835
|
tail_consumers: void 0,
|
181761
181836
|
limits: config?.limits,
|
181762
|
-
|
181837
|
+
experimental_assets_jwt: void 0
|
181763
181838
|
};
|
181764
181839
|
return createWorkerUploadForm(worker);
|
181765
181840
|
}
|
@@ -188879,6 +188954,7 @@ async function createDraftWorker({
|
|
188879
188954
|
dispatch_namespaces: [],
|
188880
188955
|
mtls_certificates: [],
|
188881
188956
|
logfwdr: { bindings: [] },
|
188957
|
+
experimental_assets: void 0,
|
188882
188958
|
unsafe: {
|
188883
188959
|
bindings: void 0,
|
188884
188960
|
metadata: void 0,
|
@@ -188898,7 +188974,7 @@ async function createDraftWorker({
|
|
188898
188974
|
placement: void 0,
|
188899
188975
|
tail_consumers: void 0,
|
188900
188976
|
limits: void 0,
|
188901
|
-
|
188977
|
+
experimental_assets_jwt: void 0
|
188902
188978
|
})
|
188903
188979
|
}
|
188904
188980
|
);
|
@@ -199677,7 +199753,7 @@ async function listMetadataIndex(config, indexName) {
|
|
199677
199753
|
return await fetchResult(
|
199678
199754
|
`/accounts/${accountId}/vectorize/v2/indexes/${indexName}/metadata_index/list`,
|
199679
199755
|
{
|
199680
|
-
method: "
|
199756
|
+
method: "GET"
|
199681
199757
|
}
|
199682
199758
|
);
|
199683
199759
|
}
|
@@ -200212,12 +200288,12 @@ function options27(yargs) {
|
|
200212
200288
|
return yargs.positional("name", {
|
200213
200289
|
type: "string",
|
200214
200290
|
demandOption: true,
|
200215
|
-
description: "The name of the Vectorize index
|
200291
|
+
description: "The name of the Vectorize index"
|
200216
200292
|
}).options({
|
200217
200293
|
vector: {
|
200218
200294
|
type: "array",
|
200219
200295
|
demandOption: true,
|
200220
|
-
describe: "Vector to query the Vectorize Index
|
200296
|
+
describe: "Vector to query the Vectorize Index",
|
200221
200297
|
coerce: (arg) => arg.map(
|
200222
200298
|
(value) => typeof value === "string" ? parseFloat(value) : value
|
200223
200299
|
).filter(
|
@@ -200227,18 +200303,18 @@ function options27(yargs) {
|
|
200227
200303
|
"top-k": {
|
200228
200304
|
type: "number",
|
200229
200305
|
default: 5,
|
200230
|
-
describe: "The number of results (nearest neighbors) to return
|
200306
|
+
describe: "The number of results (nearest neighbors) to return"
|
200231
200307
|
},
|
200232
200308
|
"return-values": {
|
200233
200309
|
type: "boolean",
|
200234
200310
|
default: false,
|
200235
|
-
describe: "Specify if the vector values should be included in the results
|
200311
|
+
describe: "Specify if the vector values should be included in the results"
|
200236
200312
|
},
|
200237
200313
|
"return-metadata": {
|
200238
200314
|
type: "string",
|
200239
200315
|
choices: ["all", "indexed", "none"],
|
200240
200316
|
default: "none",
|
200241
|
-
describe: "Specify if the vector metadata should be included in the results
|
200317
|
+
describe: "Specify if the vector metadata should be included in the results"
|
200242
200318
|
},
|
200243
200319
|
namespace: {
|
200244
200320
|
type: "string",
|
@@ -200246,7 +200322,7 @@ function options27(yargs) {
|
|
200246
200322
|
},
|
200247
200323
|
filter: {
|
200248
200324
|
type: "string",
|
200249
|
-
describe: "Filter the query results based on this metadata filter.
|
200325
|
+
describe: "Filter the query results based on this metadata filter.",
|
200250
200326
|
coerce: (jsonStr) => {
|
200251
200327
|
try {
|
200252
200328
|
return JSON.parse(jsonStr);
|
@@ -200257,7 +200333,17 @@ function options27(yargs) {
|
|
200257
200333
|
}
|
200258
200334
|
}
|
200259
200335
|
}
|
200260
|
-
}).
|
200336
|
+
}).example([
|
200337
|
+
[
|
200338
|
+
`\u276F\u276F wrangler vectorize query --vector 1 2 3 0.5 1.25 6
|
200339
|
+
Query the Vectorize Index by vector. To read from a json file that contains data in the format [1, 2, 3], you could use a command like
|
200340
|
+
\`wrangler vectorize query --vector $(jq -r '.[]' data.json | xargs)\`
|
200341
|
+
`
|
200342
|
+
],
|
200343
|
+
[
|
200344
|
+
"\u276F\u276F wrangler vectorize query --filter '{ 'p1': 'abc', 'p2': { '$ne': true }, 'p3': 10, 'p4': false, 'nested.p5': 'abcd' }'\n Filter the query results."
|
200345
|
+
]
|
200346
|
+
]).epilogue(vectorizeBetaWarning);
|
200261
200347
|
}
|
200262
200348
|
__name(options27, "options");
|
200263
200349
|
async function handler28(args) {
|
@@ -201638,7 +201724,7 @@ async function copyWorkerVersionWithNewSecrets({
|
|
201638
201724
|
"workers/message": versionMessage,
|
201639
201725
|
"workers/tag": versionTag
|
201640
201726
|
},
|
201641
|
-
|
201727
|
+
experimental_assets_jwt: void 0
|
201642
201728
|
};
|
201643
201729
|
const body = createWorkerUploadForm(worker);
|
201644
201730
|
const result = await fetchResult(
|
@@ -201999,14 +202085,11 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
201999
202085
|
legacyEnv: props.legacyEnv,
|
202000
202086
|
env: props.env
|
202001
202087
|
}) : void 0;
|
202002
|
-
const
|
202003
|
-
|
202004
|
-
|
202005
|
-
|
202006
|
-
|
202007
|
-
),
|
202008
|
-
staticAssetsOnly: props.experimentalAssets.staticAssetsOnly
|
202009
|
-
} : void 0;
|
202088
|
+
const experimentalAssetsJwt = props.experimentalAssets && !props.dryRun ? await syncExperimentalAssets(
|
202089
|
+
accountId,
|
202090
|
+
scriptName,
|
202091
|
+
props.experimentalAssets.directory
|
202092
|
+
) : void 0;
|
202010
202093
|
const bindings = {
|
202011
202094
|
kv_namespaces: config.kv_namespaces || [],
|
202012
202095
|
send_email: config.send_email,
|
@@ -202030,6 +202113,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
202030
202113
|
dispatch_namespaces: config.dispatch_namespaces,
|
202031
202114
|
mtls_certificates: config.mtls_certificates,
|
202032
202115
|
logfwdr: config.logfwdr,
|
202116
|
+
experimental_assets: config.experimental_assets?.binding ? { binding: config.experimental_assets?.binding } : void 0,
|
202033
202117
|
unsafe: {
|
202034
202118
|
bindings: config.unsafe.bindings,
|
202035
202119
|
metadata: config.unsafe.metadata,
|
@@ -202065,7 +202149,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
202065
202149
|
"workers/message": props.message,
|
202066
202150
|
"workers/tag": props.tag
|
202067
202151
|
},
|
202068
|
-
|
202152
|
+
experimental_assets_jwt: experimentalAssetsJwt
|
202069
202153
|
};
|
202070
202154
|
await printBundleSize(
|
202071
202155
|
{ name: import_node_path56.default.basename(resolvedEntryPointPath), content },
|
@@ -202082,7 +202166,6 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
202082
202166
|
maskedVars[key] = "(hidden)";
|
202083
202167
|
}
|
202084
202168
|
}
|
202085
|
-
printBindings({ ...withoutStaticAssets, vars: maskedVars });
|
202086
202169
|
if (props.dryRun) {
|
202087
202170
|
printBindings({ ...withoutStaticAssets, vars: maskedVars });
|
202088
202171
|
} else {
|
@@ -202540,11 +202623,6 @@ async function versionsUploadHandler(args) {
|
|
202540
202623
|
"Using the latest version of the Workers runtime. To silence this warning, please choose a specific version of the runtime with --compatibility-date, or add a compatibility_date to your wrangler.toml.\n"
|
202541
202624
|
);
|
202542
202625
|
}
|
202543
|
-
const experimentalAssetsOptions = experimentalAssets ? {
|
202544
|
-
...experimentalAssets,
|
202545
|
-
// Flag use of assets without user worker
|
202546
|
-
staticAssetsOnly: !(args.script || config.main)
|
202547
|
-
} : void 0;
|
202548
202626
|
const cliVars = collectKeyValues(args.var);
|
202549
202627
|
const cliDefines = collectKeyValues(args.define);
|
202550
202628
|
const cliAlias = collectKeyValues(args.alias);
|
@@ -202567,7 +202645,7 @@ async function versionsUploadHandler(args) {
|
|
202567
202645
|
jsxFactory: args.jsxFactory,
|
202568
202646
|
jsxFragment: args.jsxFragment,
|
202569
202647
|
tsconfig: args.tsconfig,
|
202570
|
-
experimentalAssets
|
202648
|
+
experimentalAssets,
|
202571
202649
|
minify: args.minify,
|
202572
202650
|
uploadSourceMaps: args.uploadSourceMaps,
|
202573
202651
|
nodeCompat: args.nodeCompat,
|
@@ -203238,7 +203316,8 @@ function createCLIParser(argv) {
|
|
203238
203316
|
wrangler.updateStrings({
|
203239
203317
|
"Commands:": `${source_default.bold("COMMANDS")}`,
|
203240
203318
|
"Options:": `${source_default.bold("OPTIONS")}`,
|
203241
|
-
"Positionals:": `${source_default.bold("POSITIONALS")}
|
203319
|
+
"Positionals:": `${source_default.bold("POSITIONALS")}`,
|
203320
|
+
"Examples:": `${source_default.bold("EXAMPLES")}`
|
203242
203321
|
});
|
203243
203322
|
wrangler.group(
|
203244
203323
|
["experimental-json-config", "config", "env", "help", "version"],
|
@@ -205511,14 +205590,11 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
205511
205590
|
legacyEnv: props.legacyEnv,
|
205512
205591
|
env: props.env
|
205513
205592
|
}) : void 0;
|
205514
|
-
const
|
205515
|
-
|
205516
|
-
|
205517
|
-
|
205518
|
-
|
205519
|
-
),
|
205520
|
-
staticAssetsOnly: props.experimentalAssets.staticAssetsOnly
|
205521
|
-
} : void 0;
|
205593
|
+
const experimentalAssetsJwt = props.experimentalAssets && !props.dryRun ? await syncExperimentalAssets(
|
205594
|
+
accountId,
|
205595
|
+
scriptName,
|
205596
|
+
props.experimentalAssets.directory
|
205597
|
+
) : void 0;
|
205522
205598
|
const legacyAssets = await syncLegacyAssets(
|
205523
205599
|
accountId,
|
205524
205600
|
// When we're using the newer service environments, we wouldn't
|
@@ -205561,6 +205637,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
205561
205637
|
dispatch_namespaces: config.dispatch_namespaces,
|
205562
205638
|
mtls_certificates: config.mtls_certificates,
|
205563
205639
|
logfwdr: config.logfwdr,
|
205640
|
+
experimental_assets: config.experimental_assets?.binding ? { binding: config.experimental_assets.binding } : void 0,
|
205564
205641
|
unsafe: {
|
205565
205642
|
bindings: config.unsafe.bindings,
|
205566
205643
|
metadata: config.unsafe.metadata,
|
@@ -205599,7 +205676,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
205599
205676
|
placement,
|
205600
205677
|
tail_consumers: config.tail_consumers,
|
205601
205678
|
limits: config.limits,
|
205602
|
-
|
205679
|
+
experimental_assets_jwt: experimentalAssetsJwt
|
205603
205680
|
};
|
205604
205681
|
sourceMapSize = worker.sourceMaps?.reduce(
|
205605
205682
|
(acc, m2) => acc + m2.content.length,
|
@@ -206145,7 +206222,13 @@ var path63 = __toESM(require("node:path"));
|
|
206145
206222
|
var import_miniflare15 = require("miniflare");
|
206146
206223
|
var CERT_EXPIRY_DAYS = 30;
|
206147
206224
|
var ONE_DAY_IN_MS = 864e5;
|
206148
|
-
|
206225
|
+
var getHttpsKeyPathFromEnv = getEnvironmentVariableFactory({
|
206226
|
+
variableName: "WRANGLER_HTTPS_KEY_PATH"
|
206227
|
+
});
|
206228
|
+
var getHttpsCertPathFromEnv = getEnvironmentVariableFactory({
|
206229
|
+
variableName: "WRANGLER_HTTPS_CERT_PATH"
|
206230
|
+
});
|
206231
|
+
function getHttpsOptions(customHttpsKeyPath = getHttpsKeyPathFromEnv(), customHttpsCertPath = getHttpsCertPathFromEnv()) {
|
206149
206232
|
if (customHttpsKeyPath !== void 0 || customHttpsCertPath !== void 0) {
|
206150
206233
|
if (customHttpsKeyPath === void 0 || customHttpsCertPath === void 0) {
|
206151
206234
|
throw new UserError(
|
@@ -207100,7 +207183,7 @@ async function createRemoteWorkerInit(props) {
|
|
207100
207183
|
// no tail consumers in dev - TODO revisit?
|
207101
207184
|
limits: void 0,
|
207102
207185
|
// no limits in preview - not supported yet but can be added
|
207103
|
-
|
207186
|
+
experimental_assets_jwt: void 0
|
207104
207187
|
// no remote mode for assets
|
207105
207188
|
};
|
207106
207189
|
return init3;
|
@@ -209425,7 +209508,8 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
|
|
209425
209508
|
dispatch_namespaces: void 0,
|
209426
209509
|
mtls_certificates: void 0,
|
209427
209510
|
logfwdr: void 0,
|
209428
|
-
unsafe: void 0
|
209511
|
+
unsafe: void 0,
|
209512
|
+
experimental_assets: void 0
|
209429
209513
|
})
|
209430
209514
|
},
|
209431
209515
|
dev: {
|
@@ -210040,7 +210124,8 @@ function getBindings(configParam, env7, local, args) {
|
|
210040
210124
|
capnp: configParam.unsafe.capnp
|
210041
210125
|
},
|
210042
210126
|
mtls_certificates: configParam.mtls_certificates,
|
210043
|
-
send_email: configParam.send_email
|
210127
|
+
send_email: configParam.send_email,
|
210128
|
+
experimental_assets: configParam.experimental_assets?.binding ? { binding: configParam.experimental_assets?.binding } : void 0
|
210044
210129
|
};
|
210045
210130
|
return bindings;
|
210046
210131
|
}
|
@@ -210929,6 +211014,7 @@ var LocalRuntimeController = class extends RuntimeController {
|
|
210929
211014
|
await convertToConfigBundle(data),
|
210930
211015
|
this.#proxyToUserWorkerAuthenticationSecret
|
210931
211016
|
);
|
211017
|
+
options29.liveReload = false;
|
210932
211018
|
if (this.#mf === void 0) {
|
210933
211019
|
logger.log(source_default.dim("\u2394 Starting local server..."));
|
210934
211020
|
this.#mf = new import_miniflare19.Miniflare(options29);
|
@@ -211141,7 +211227,8 @@ var ProxyController = class extends Controller {
|
|
211141
211227
|
logger.loggerLevel === "debug" ? "wrangler-ProxyWorker" : "wrangler"
|
211142
211228
|
)
|
211143
211229
|
}),
|
211144
|
-
handleRuntimeStdio
|
211230
|
+
handleRuntimeStdio,
|
211231
|
+
liveReload: false
|
211145
211232
|
};
|
211146
211233
|
const proxyWorkerOptionsChanged = didMiniflareOptionsChange(
|
211147
211234
|
this.proxyWorkerOptions,
|