wrangler 3.73.0 → 3.75.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/README.md +4 -0
- package/config-schema.json +24 -3
- package/package.json +4 -4
- package/wrangler-dist/cli.d.ts +13 -4
- package/wrangler-dist/cli.js +355 -252
- package/templates/no-op-assets-worker.ts +0 -33
- package/wrangler-dist/cli.js.map +0 -7
package/wrangler-dist/cli.js
CHANGED
@@ -80045,7 +80045,7 @@ var require_view = __commonJS({
|
|
80045
80045
|
var debug = require_src2()("express:view");
|
80046
80046
|
var path74 = require("path");
|
80047
80047
|
var fs26 = require("fs");
|
80048
|
-
var
|
80048
|
+
var dirname16 = path74.dirname;
|
80049
80049
|
var basename5 = path74.basename;
|
80050
80050
|
var extname5 = path74.extname;
|
80051
80051
|
var join18 = path74.join;
|
@@ -80085,7 +80085,7 @@ var require_view = __commonJS({
|
|
80085
80085
|
for (var i = 0; i < roots.length && !path75; i++) {
|
80086
80086
|
var root = roots[i];
|
80087
80087
|
var loc = resolve22(root, name);
|
80088
|
-
var dir =
|
80088
|
+
var dir = dirname16(loc);
|
80089
80089
|
var file = basename5(loc);
|
80090
80090
|
path75 = this.resolve(dir, file);
|
80091
80091
|
}
|
@@ -97445,9 +97445,9 @@ var require_command_exists = __commonJS({
|
|
97445
97445
|
cleanInput = /* @__PURE__ */ __name(function(s) {
|
97446
97446
|
var isPathName = /[\\]/.test(s);
|
97447
97447
|
if (isPathName) {
|
97448
|
-
var
|
97448
|
+
var dirname16 = '"' + path74.dirname(s) + '"';
|
97449
97449
|
var basename5 = '"' + path74.basename(s) + '"';
|
97450
|
-
return
|
97450
|
+
return dirname16 + ":" + basename5;
|
97451
97451
|
}
|
97452
97452
|
return '"' + s + '"';
|
97453
97453
|
}, "cleanInput");
|
@@ -152394,7 +152394,7 @@ __name(getEnvironmentVariableFactory, "getEnvironmentVariableFactory");
|
|
152394
152394
|
init_import_meta_url();
|
152395
152395
|
var getC3CommandFromEnv = getEnvironmentVariableFactory({
|
152396
152396
|
variableName: "WRANGLER_C3_COMMAND",
|
152397
|
-
defaultValue: () => "create cloudflare
|
152397
|
+
defaultValue: () => "create cloudflare@^2.5.0"
|
152398
152398
|
});
|
152399
152399
|
var getWranglerSendMetricsFromEnv = getEnvironmentVariableFactory({
|
152400
152400
|
variableName: "WRANGLER_SEND_METRICS"
|
@@ -152693,7 +152693,7 @@ init_import_meta_url();
|
|
152693
152693
|
init_import_meta_url();
|
152694
152694
|
|
152695
152695
|
// package.json
|
152696
|
-
var version = "3.
|
152696
|
+
var version = "3.75.0";
|
152697
152697
|
var package_default = {
|
152698
152698
|
name: "wrangler",
|
152699
152699
|
version,
|
@@ -157058,7 +157058,14 @@ var validateMigrations = /* @__PURE__ */ __name((diagnostics, field, value) => {
|
|
157058
157058
|
}
|
157059
157059
|
let valid = true;
|
157060
157060
|
for (let i = 0; i < rawMigrations.length; i++) {
|
157061
|
-
const {
|
157061
|
+
const {
|
157062
|
+
tag,
|
157063
|
+
new_classes,
|
157064
|
+
new_sqlite_classes,
|
157065
|
+
renamed_classes,
|
157066
|
+
deleted_classes,
|
157067
|
+
...rest
|
157068
|
+
} = rawMigrations[i];
|
157062
157069
|
valid = validateAdditionalProperties(
|
157063
157070
|
diagnostics,
|
157064
157071
|
"migrations",
|
@@ -157078,6 +157085,12 @@ var validateMigrations = /* @__PURE__ */ __name((diagnostics, field, value) => {
|
|
157078
157085
|
new_classes,
|
157079
157086
|
"string"
|
157080
157087
|
) && valid;
|
157088
|
+
valid = validateOptionalTypedArray(
|
157089
|
+
diagnostics,
|
157090
|
+
`migrations[${i}].new_sqlite_classes`,
|
157091
|
+
new_sqlite_classes,
|
157092
|
+
"string"
|
157093
|
+
) && valid;
|
157081
157094
|
if (renamed_classes !== void 0) {
|
157082
157095
|
if (!Array.isArray(renamed_classes)) {
|
157083
157096
|
diagnostics.errors.push(
|
@@ -159430,10 +159443,8 @@ async function getEntry(args, config, command2) {
|
|
159430
159443
|
// site.entry-point could be a directory
|
159431
159444
|
import_node_path16.default.resolve(config.site?.["entry-point"], "index.js")
|
159432
159445
|
);
|
159433
|
-
} else if (args.legacyAssets || config.legacy_assets) {
|
159446
|
+
} else if (args.legacyAssets || config.legacy_assets || args.experimentalAssets || config.experimental_assets) {
|
159434
159447
|
file = import_node_path16.default.resolve(getBasePath(), "templates/no-op-worker.js");
|
159435
|
-
} else if (args.experimentalAssets || config.experimental_assets) {
|
159436
|
-
file = import_node_path16.default.resolve(getBasePath(), "templates/no-op-assets-worker.ts");
|
159437
159448
|
} else {
|
159438
159449
|
throw new UserError(
|
159439
159450
|
`Missing entry-point: The entry-point should be specified via the command line (e.g. \`wrangler ${command2} path/to/script\`) or the \`main\` config field.`
|
@@ -159476,7 +159487,6 @@ ${migrateUrl}`
|
|
159476
159487
|
directory,
|
159477
159488
|
format: format10,
|
159478
159489
|
moduleRoot: args.moduleRoot ?? config.base_dir ?? import_node_path16.default.dirname(file),
|
159479
|
-
staticAssetsOnly: !!(args.experimentalAssets || config.experimental_assets) && !(args.script && config.main),
|
159480
159490
|
name: config.name ?? "worker"
|
159481
159491
|
};
|
159482
159492
|
}
|
@@ -162639,8 +162649,7 @@ function buildMiniflareBindingOptions(config) {
|
|
162639
162649
|
}
|
162640
162650
|
}
|
162641
162651
|
const serviceBindings = {
|
162642
|
-
...config.serviceBindings
|
162643
|
-
...config.experimentalAssets ? { ASSET_WORKER: "asset-worker" } : {}
|
162652
|
+
...config.serviceBindings
|
162644
162653
|
};
|
162645
162654
|
const notFoundServices = /* @__PURE__ */ new Set();
|
162646
162655
|
for (const service of config.services ?? []) {
|
@@ -162842,6 +162851,19 @@ function buildPersistOptions(localPersistencePath) {
|
|
162842
162851
|
}
|
162843
162852
|
}
|
162844
162853
|
__name(buildPersistOptions, "buildPersistOptions");
|
162854
|
+
function buildAssetOptions(config) {
|
162855
|
+
if (config.experimentalAssets) {
|
162856
|
+
return {
|
162857
|
+
assets: {
|
162858
|
+
workerName: config.name,
|
162859
|
+
path: config.experimentalAssets.directory,
|
162860
|
+
bindingName: config.experimentalAssets.binding,
|
162861
|
+
routingConfig: config.experimentalAssets.routingConfig
|
162862
|
+
}
|
162863
|
+
};
|
162864
|
+
}
|
162865
|
+
}
|
162866
|
+
__name(buildAssetOptions, "buildAssetOptions");
|
162845
162867
|
function buildSitesOptions({
|
162846
162868
|
legacyAssetPaths
|
162847
162869
|
}) {
|
@@ -162955,6 +162977,7 @@ async function buildMiniflareOptions(log2, config, proxyToUserWorkerAuthenticati
|
|
162955
162977
|
const { bindingOptions, internalObjects, externalWorkers } = buildMiniflareBindingOptions(config);
|
162956
162978
|
const sitesOptions = buildSitesOptions(config);
|
162957
162979
|
const persistOptions = buildPersistOptions(config.localPersistencePath);
|
162980
|
+
const assetOptions = buildAssetOptions(config);
|
162958
162981
|
const options29 = {
|
162959
162982
|
host: config.initialIp,
|
162960
162983
|
port: config.initialPort,
|
@@ -162974,6 +162997,7 @@ async function buildMiniflareOptions(log2, config, proxyToUserWorkerAuthenticati
|
|
162974
162997
|
...sourceOptions,
|
162975
162998
|
...bindingOptions,
|
162976
162999
|
...sitesOptions,
|
163000
|
+
...assetOptions,
|
162977
163001
|
// Allow each entrypoint to be accessed directly over `127.0.0.1:0`
|
162978
163002
|
unsafeDirectSockets: entrypointNames.map((name) => ({
|
162979
163003
|
host: "127.0.0.1",
|
@@ -162982,53 +163006,12 @@ async function buildMiniflareOptions(log2, config, proxyToUserWorkerAuthenticati
|
|
162982
163006
|
proxy: true
|
162983
163007
|
}))
|
162984
163008
|
},
|
162985
|
-
...getAssetServerWorker(config),
|
162986
163009
|
...externalWorkers
|
162987
163010
|
]
|
162988
163011
|
};
|
162989
163012
|
return { options: options29, internalObjects, entrypointNames };
|
162990
163013
|
}
|
162991
163014
|
__name(buildMiniflareOptions, "buildMiniflareOptions");
|
162992
|
-
function getAssetServerWorker(config) {
|
162993
|
-
if (!config.experimentalAssets) {
|
162994
|
-
return [];
|
162995
|
-
}
|
162996
|
-
const assetServerModulePath = require.resolve("@cloudflare/workers-shared/dist/asset-worker.mjs");
|
162997
|
-
const assetServerConfigPath = require.resolve("@cloudflare/workers-shared/dist/asset-worker.toml");
|
162998
|
-
let assetServerConfig;
|
162999
|
-
try {
|
163000
|
-
assetServerConfig = readConfig(assetServerConfigPath, {});
|
163001
|
-
} catch (err) {
|
163002
|
-
throw new UserError(
|
163003
|
-
`Failed to read the Asset Worker configuration file.
|
163004
|
-
${err}`
|
163005
|
-
);
|
163006
|
-
}
|
163007
|
-
return [
|
163008
|
-
{
|
163009
|
-
name: assetServerConfig?.name,
|
163010
|
-
compatibilityDate: assetServerConfig?.compatibility_date,
|
163011
|
-
compatibilityFlags: assetServerConfig?.compatibility_flags,
|
163012
|
-
modulesRoot: (0, import_node_path22.dirname)(assetServerModulePath),
|
163013
|
-
modules: [
|
163014
|
-
{
|
163015
|
-
type: "ESModule",
|
163016
|
-
path: assetServerModulePath
|
163017
|
-
}
|
163018
|
-
],
|
163019
|
-
unsafeDirectSockets: [
|
163020
|
-
{
|
163021
|
-
host: "127.0.0.1",
|
163022
|
-
port: 0
|
163023
|
-
}
|
163024
|
-
],
|
163025
|
-
assetsPath: config.experimentalAssets.directory,
|
163026
|
-
assetsKVBindingName: "ASSETS_KV_NAMESPACE",
|
163027
|
-
assetsManifestBindingName: "ASSETS_MANIFEST"
|
163028
|
-
}
|
163029
|
-
];
|
163030
|
-
}
|
163031
|
-
__name(getAssetServerWorker, "getAssetServerWorker");
|
163032
163015
|
var ReloadedEvent = class extends Event {
|
163033
163016
|
url;
|
163034
163017
|
internalDurableObjects;
|
@@ -163620,12 +163603,12 @@ function createWorkerUploadForm(worker) {
|
|
163620
163603
|
tail_consumers,
|
163621
163604
|
limits,
|
163622
163605
|
annotations,
|
163623
|
-
|
163606
|
+
experimental_assets
|
163624
163607
|
} = worker;
|
163625
|
-
if (
|
163608
|
+
if (experimental_assets && !experimental_assets.routingConfig.hasUserWorker) {
|
163626
163609
|
formData.set(
|
163627
163610
|
"metadata",
|
163628
|
-
JSON.stringify({ assets:
|
163611
|
+
JSON.stringify({ assets: experimental_assets.jwt })
|
163629
163612
|
);
|
163630
163613
|
return formData;
|
163631
163614
|
}
|
@@ -163918,7 +163901,7 @@ function createWorkerUploadForm(worker) {
|
|
163918
163901
|
...tail_consumers && { tail_consumers },
|
163919
163902
|
...limits && { limits },
|
163920
163903
|
...annotations && { annotations },
|
163921
|
-
...
|
163904
|
+
...experimental_assets && { assets: experimental_assets.jwt }
|
163922
163905
|
};
|
163923
163906
|
if (bindings.unsafe?.metadata !== void 0) {
|
163924
163907
|
for (const key of Object.keys(bindings.unsafe.metadata)) {
|
@@ -165067,7 +165050,10 @@ var syncExperimentalAssets = /* @__PURE__ */ __name(async (accountId, scriptName
|
|
165067
165050
|
1
|
165068
165051
|
);
|
165069
165052
|
}
|
165070
|
-
assetLogCount = logAssetUpload(
|
165053
|
+
assetLogCount = logAssetUpload(
|
165054
|
+
`+ ${decodeFilepath(manifestEntry[0])}`,
|
165055
|
+
assetLogCount
|
165056
|
+
);
|
165071
165057
|
return manifestEntry;
|
165072
165058
|
});
|
165073
165059
|
});
|
@@ -165081,7 +165067,8 @@ var syncExperimentalAssets = /* @__PURE__ */ __name(async (accountId, scriptName
|
|
165081
165067
|
const doUpload = /* @__PURE__ */ __name(async () => {
|
165082
165068
|
const payload = await Promise.all(
|
165083
165069
|
bucket.map(async (manifestEntry) => {
|
165084
|
-
const
|
165070
|
+
const decodedFilePath = decodeFilepath(manifestEntry[0]);
|
165071
|
+
const absFilePath = path28.join(assetDirectory, decodedFilePath);
|
165085
165072
|
return {
|
165086
165073
|
base64: true,
|
165087
165074
|
key: manifestEntry[1].hash,
|
@@ -165236,6 +165223,7 @@ function getExperimentalAssetsBasePath(config, experimentalAssetsCommandLineArg)
|
|
165236
165223
|
__name(getExperimentalAssetsBasePath, "getExperimentalAssetsBasePath");
|
165237
165224
|
function processExperimentalAssetsArg(args, config) {
|
165238
165225
|
const experimentalAssets = args.experimentalAssets ? { directory: args.experimentalAssets } : config.experimental_assets;
|
165226
|
+
let experimentalAssetsOptions;
|
165239
165227
|
if (experimentalAssets) {
|
165240
165228
|
const experimentalAssetsBasePath = getExperimentalAssetsBasePath(
|
165241
165229
|
config,
|
@@ -165253,14 +165241,24 @@ ${resolvedExperimentalAssetsPath}`
|
|
165253
165241
|
);
|
165254
165242
|
}
|
165255
165243
|
experimentalAssets.directory = resolvedExperimentalAssetsPath;
|
165244
|
+
const routingConfig = {
|
165245
|
+
hasUserWorker: Boolean(args.script || config.main)
|
165246
|
+
};
|
165247
|
+
experimentalAssetsOptions = {
|
165248
|
+
...experimentalAssets,
|
165249
|
+
routingConfig
|
165250
|
+
};
|
165256
165251
|
}
|
165257
|
-
return
|
165252
|
+
return experimentalAssetsOptions;
|
165258
165253
|
}
|
165259
165254
|
__name(processExperimentalAssetsArg, "processExperimentalAssetsArg");
|
165260
165255
|
var encodeFilePath = /* @__PURE__ */ __name((filePath) => {
|
165261
165256
|
const encodedPath = filePath.split(path28.sep).map((segment) => encodeURIComponent(segment)).join("/");
|
165262
165257
|
return "/" + encodedPath;
|
165263
165258
|
}, "encodeFilePath");
|
165259
|
+
var decodeFilepath = /* @__PURE__ */ __name((filePath) => {
|
165260
|
+
return filePath.split("/").map((segment) => decodeURIComponent(segment)).join(path28.sep);
|
165261
|
+
}, "decodeFilepath");
|
165264
165262
|
|
165265
165263
|
// src/metrics/index.ts
|
165266
165264
|
init_import_meta_url();
|
@@ -166799,6 +166797,96 @@ ${dashLink}`);
|
|
166799
166797
|
}
|
166800
166798
|
__name(triggersDeploy, "triggersDeploy");
|
166801
166799
|
|
166800
|
+
// src/versions/api.ts
|
166801
|
+
init_import_meta_url();
|
166802
|
+
async function fetchVersion(accountId, workerName, versionId, versionCache) {
|
166803
|
+
const cachedVersion = versionCache?.get(versionId);
|
166804
|
+
if (cachedVersion) {
|
166805
|
+
return cachedVersion;
|
166806
|
+
}
|
166807
|
+
const version3 = await fetchResult(
|
166808
|
+
`/accounts/${accountId}/workers/scripts/${workerName}/versions/${versionId}`
|
166809
|
+
);
|
166810
|
+
versionCache?.set(version3.id, version3);
|
166811
|
+
return version3;
|
166812
|
+
}
|
166813
|
+
__name(fetchVersion, "fetchVersion");
|
166814
|
+
async function fetchVersions(accountId, workerName, versionCache, ...versionIds) {
|
166815
|
+
return Promise.all(
|
166816
|
+
versionIds.map(
|
166817
|
+
(versionId) => fetchVersion(accountId, workerName, versionId, versionCache)
|
166818
|
+
)
|
166819
|
+
);
|
166820
|
+
}
|
166821
|
+
__name(fetchVersions, "fetchVersions");
|
166822
|
+
async function fetchLatestDeployments(accountId, workerName) {
|
166823
|
+
const { deployments: deployments2 } = await fetchResult(`/accounts/${accountId}/workers/scripts/${workerName}/deployments`);
|
166824
|
+
return deployments2;
|
166825
|
+
}
|
166826
|
+
__name(fetchLatestDeployments, "fetchLatestDeployments");
|
166827
|
+
async function fetchLatestDeployment(accountId, workerName) {
|
166828
|
+
const deployments2 = await fetchLatestDeployments(accountId, workerName);
|
166829
|
+
return deployments2.at(0);
|
166830
|
+
}
|
166831
|
+
__name(fetchLatestDeployment, "fetchLatestDeployment");
|
166832
|
+
async function fetchDeploymentVersions(accountId, workerName, deployment, versionCache) {
|
166833
|
+
if (!deployment) {
|
166834
|
+
return [[], /* @__PURE__ */ new Map()];
|
166835
|
+
}
|
166836
|
+
const versionTraffic = new Map(
|
166837
|
+
deployment.versions.map((v2) => [v2.version_id, v2.percentage])
|
166838
|
+
);
|
166839
|
+
const versions = await fetchVersions(
|
166840
|
+
accountId,
|
166841
|
+
workerName,
|
166842
|
+
versionCache,
|
166843
|
+
...versionTraffic.keys()
|
166844
|
+
);
|
166845
|
+
return [versions, versionTraffic];
|
166846
|
+
}
|
166847
|
+
__name(fetchDeploymentVersions, "fetchDeploymentVersions");
|
166848
|
+
async function fetchDeployableVersions(accountId, workerName, versionCache) {
|
166849
|
+
const { items: versions } = await fetchResult(
|
166850
|
+
`/accounts/${accountId}/workers/scripts/${workerName}/versions?deployable=true`
|
166851
|
+
);
|
166852
|
+
for (const version3 of versions) {
|
166853
|
+
versionCache.set(version3.id, version3);
|
166854
|
+
}
|
166855
|
+
return versions;
|
166856
|
+
}
|
166857
|
+
__name(fetchDeployableVersions, "fetchDeployableVersions");
|
166858
|
+
async function createDeployment(accountId, workerName, versionTraffic, message, force) {
|
166859
|
+
return await fetchResult(
|
166860
|
+
`/accounts/${accountId}/workers/scripts/${workerName}/deployments${force ? "?force=true" : ""}`,
|
166861
|
+
{
|
166862
|
+
method: "POST",
|
166863
|
+
headers: { "Content-Type": "application/json" },
|
166864
|
+
body: JSON.stringify({
|
166865
|
+
strategy: "percentage",
|
166866
|
+
versions: Array.from(versionTraffic).map(
|
166867
|
+
([version_id, percentage]) => ({ version_id, percentage })
|
166868
|
+
),
|
166869
|
+
annotations: {
|
166870
|
+
"workers/message": message
|
166871
|
+
}
|
166872
|
+
})
|
166873
|
+
}
|
166874
|
+
);
|
166875
|
+
}
|
166876
|
+
__name(createDeployment, "createDeployment");
|
166877
|
+
async function patchNonVersionedScriptSettings(accountId, workerName, settings) {
|
166878
|
+
const res = await fetchResult(
|
166879
|
+
`/accounts/${accountId}/workers/scripts/${workerName}/script-settings`,
|
166880
|
+
{
|
166881
|
+
method: "PATCH",
|
166882
|
+
headers: { "Content-Type": "application/json" },
|
166883
|
+
body: JSON.stringify(settings)
|
166884
|
+
}
|
166885
|
+
);
|
166886
|
+
return res;
|
166887
|
+
}
|
166888
|
+
__name(patchNonVersionedScriptSettings, "patchNonVersionedScriptSettings");
|
166889
|
+
|
166802
166890
|
// src/versions/deploy.ts
|
166803
166891
|
init_import_meta_url();
|
166804
166892
|
var import_assert2 = __toESM(require("assert"));
|
@@ -168554,96 +168642,6 @@ function collapseWhiteSpaceLines(input) {
|
|
168554
168642
|
}
|
168555
168643
|
__name(collapseWhiteSpaceLines, "collapseWhiteSpaceLines");
|
168556
168644
|
|
168557
|
-
// src/versions/api.ts
|
168558
|
-
init_import_meta_url();
|
168559
|
-
async function fetchVersion(accountId, workerName, versionId, versionCache) {
|
168560
|
-
const cachedVersion = versionCache?.get(versionId);
|
168561
|
-
if (cachedVersion) {
|
168562
|
-
return cachedVersion;
|
168563
|
-
}
|
168564
|
-
const version3 = await fetchResult(
|
168565
|
-
`/accounts/${accountId}/workers/scripts/${workerName}/versions/${versionId}`
|
168566
|
-
);
|
168567
|
-
versionCache?.set(version3.id, version3);
|
168568
|
-
return version3;
|
168569
|
-
}
|
168570
|
-
__name(fetchVersion, "fetchVersion");
|
168571
|
-
async function fetchVersions(accountId, workerName, versionCache, ...versionIds) {
|
168572
|
-
return Promise.all(
|
168573
|
-
versionIds.map(
|
168574
|
-
(versionId) => fetchVersion(accountId, workerName, versionId, versionCache)
|
168575
|
-
)
|
168576
|
-
);
|
168577
|
-
}
|
168578
|
-
__name(fetchVersions, "fetchVersions");
|
168579
|
-
async function fetchLatestDeployments(accountId, workerName) {
|
168580
|
-
const { deployments: deployments2 } = await fetchResult(`/accounts/${accountId}/workers/scripts/${workerName}/deployments`);
|
168581
|
-
return deployments2;
|
168582
|
-
}
|
168583
|
-
__name(fetchLatestDeployments, "fetchLatestDeployments");
|
168584
|
-
async function fetchLatestDeployment(accountId, workerName) {
|
168585
|
-
const deployments2 = await fetchLatestDeployments(accountId, workerName);
|
168586
|
-
return deployments2.at(0);
|
168587
|
-
}
|
168588
|
-
__name(fetchLatestDeployment, "fetchLatestDeployment");
|
168589
|
-
async function fetchDeploymentVersions(accountId, workerName, deployment, versionCache) {
|
168590
|
-
if (!deployment) {
|
168591
|
-
return [[], /* @__PURE__ */ new Map()];
|
168592
|
-
}
|
168593
|
-
const versionTraffic = new Map(
|
168594
|
-
deployment.versions.map((v2) => [v2.version_id, v2.percentage])
|
168595
|
-
);
|
168596
|
-
const versions = await fetchVersions(
|
168597
|
-
accountId,
|
168598
|
-
workerName,
|
168599
|
-
versionCache,
|
168600
|
-
...versionTraffic.keys()
|
168601
|
-
);
|
168602
|
-
return [versions, versionTraffic];
|
168603
|
-
}
|
168604
|
-
__name(fetchDeploymentVersions, "fetchDeploymentVersions");
|
168605
|
-
async function fetchDeployableVersions(accountId, workerName, versionCache) {
|
168606
|
-
const { items: versions } = await fetchResult(
|
168607
|
-
`/accounts/${accountId}/workers/scripts/${workerName}/versions?deployable=true`
|
168608
|
-
);
|
168609
|
-
for (const version3 of versions) {
|
168610
|
-
versionCache.set(version3.id, version3);
|
168611
|
-
}
|
168612
|
-
return versions;
|
168613
|
-
}
|
168614
|
-
__name(fetchDeployableVersions, "fetchDeployableVersions");
|
168615
|
-
async function createDeployment(accountId, workerName, versionTraffic, message, force) {
|
168616
|
-
return await fetchResult(
|
168617
|
-
`/accounts/${accountId}/workers/scripts/${workerName}/deployments${force ? "?force=true" : ""}`,
|
168618
|
-
{
|
168619
|
-
method: "POST",
|
168620
|
-
headers: { "Content-Type": "application/json" },
|
168621
|
-
body: JSON.stringify({
|
168622
|
-
strategy: "percentage",
|
168623
|
-
versions: Array.from(versionTraffic).map(
|
168624
|
-
([version_id, percentage]) => ({ version_id, percentage })
|
168625
|
-
),
|
168626
|
-
annotations: {
|
168627
|
-
"workers/message": message
|
168628
|
-
}
|
168629
|
-
})
|
168630
|
-
}
|
168631
|
-
);
|
168632
|
-
}
|
168633
|
-
__name(createDeployment, "createDeployment");
|
168634
|
-
async function patchNonVersionedScriptSettings(accountId, workerName, settings) {
|
168635
|
-
const res = await fetchResult(
|
168636
|
-
`/accounts/${accountId}/workers/scripts/${workerName}/script-settings`,
|
168637
|
-
{
|
168638
|
-
method: "PATCH",
|
168639
|
-
headers: { "Content-Type": "application/json" },
|
168640
|
-
body: JSON.stringify(settings)
|
168641
|
-
}
|
168642
|
-
);
|
168643
|
-
return res;
|
168644
|
-
}
|
168645
|
-
__name(patchNonVersionedScriptSettings, "patchNonVersionedScriptSettings");
|
168646
|
-
|
168647
168645
|
// src/versions/deploy.ts
|
168648
168646
|
var EPSILON = 1e-3;
|
168649
168647
|
var BLANK_INPUT = "-";
|
@@ -169478,11 +169476,14 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
169478
169476
|
legacyEnv: props.legacyEnv,
|
169479
169477
|
env: props.env
|
169480
169478
|
}) : void 0;
|
169481
|
-
const
|
169482
|
-
|
169483
|
-
|
169484
|
-
|
169485
|
-
|
169479
|
+
const experimentalAssetsOptions = props.experimentalAssetsOptions && !props.dryRun ? {
|
169480
|
+
routingConfig: props.experimentalAssetsOptions?.routingConfig,
|
169481
|
+
jwt: await syncExperimentalAssets(
|
169482
|
+
accountId,
|
169483
|
+
scriptName,
|
169484
|
+
props.experimentalAssetsOptions.directory
|
169485
|
+
)
|
169486
|
+
} : void 0;
|
169486
169487
|
const legacyAssets = await syncLegacyAssets(
|
169487
169488
|
accountId,
|
169488
169489
|
// When we're using the newer service environments, we wouldn't
|
@@ -169564,7 +169565,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
169564
169565
|
placement,
|
169565
169566
|
tail_consumers: config.tail_consumers,
|
169566
169567
|
limits: config.limits,
|
169567
|
-
|
169568
|
+
experimental_assets: experimentalAssetsOptions
|
169568
169569
|
};
|
169569
169570
|
sourceMapSize = worker.sourceMaps?.reduce(
|
169570
169571
|
(acc, m2) => acc + m2.content.length,
|
@@ -169589,6 +169590,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
169589
169590
|
if (props.dryRun) {
|
169590
169591
|
printBindings({ ...withoutStaticAssets, vars: maskedVars });
|
169591
169592
|
} else {
|
169593
|
+
(0, import_node_assert16.default)(accountId, "Missing accountId");
|
169592
169594
|
await ensureQueuesExistByConfig(config);
|
169593
169595
|
let bindingsPrinted = false;
|
169594
169596
|
try {
|
@@ -169602,22 +169604,13 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
169602
169604
|
headers: await getMetricsUsageHeaders(config.send_metrics)
|
169603
169605
|
}
|
169604
169606
|
);
|
169605
|
-
|
169606
|
-
|
169607
|
-
|
169608
|
-
|
169609
|
-
|
169610
|
-
|
169611
|
-
|
169612
|
-
{
|
169613
|
-
percentage: 100,
|
169614
|
-
version_id: versionResult.id
|
169615
|
-
}
|
169616
|
-
]
|
169617
|
-
}),
|
169618
|
-
headers: await getMetricsUsageHeaders(config.send_metrics)
|
169619
|
-
}
|
169620
|
-
);
|
169607
|
+
const versionMap = /* @__PURE__ */ new Map();
|
169608
|
+
versionMap.set(versionResult.id, 100);
|
169609
|
+
await createDeployment(accountId, scriptName, versionMap, void 0);
|
169610
|
+
await patchNonVersionedScriptSettings(accountId, scriptName, {
|
169611
|
+
tail_consumers: worker.tail_consumers,
|
169612
|
+
logpush: worker.logpush
|
169613
|
+
});
|
169621
169614
|
const { available_on_subdomain } = await fetchResult(`/accounts/${accountId}/workers/scripts/${scriptName}/subdomain`);
|
169622
169615
|
result = {
|
169623
169616
|
available_on_subdomain,
|
@@ -169714,7 +169707,6 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
169714
169707
|
logger.log(`--dry-run: exiting now.`);
|
169715
169708
|
return { versionId, workerTag };
|
169716
169709
|
}
|
169717
|
-
(0, import_node_assert16.default)(accountId, "Missing accountId");
|
169718
169710
|
const uploadMs = Date.now() - start;
|
169719
169711
|
logger.log("Uploaded", workerName, formatTime2(uploadMs));
|
169720
169712
|
if (props.dispatchNamespace !== void 0) {
|
@@ -171117,7 +171109,7 @@ async function createRemoteWorkerInit(props) {
|
|
171117
171109
|
// no tail consumers in dev - TODO revisit?
|
171118
171110
|
limits: void 0,
|
171119
171111
|
// no limits in preview - not supported yet but can be added
|
171120
|
-
|
171112
|
+
experimental_assets: void 0
|
171121
171113
|
// no remote mode for assets
|
171122
171114
|
};
|
171123
171115
|
return init3;
|
@@ -185080,7 +185072,7 @@ Please shift to the --legacy-assets command to preserve the current functionalit
|
|
185080
185072
|
"The --assets argument is experimental and may change or break at any time"
|
185081
185073
|
);
|
185082
185074
|
}
|
185083
|
-
const
|
185075
|
+
const experimentalAssetsOptions = processExperimentalAssetsArg(args, config);
|
185084
185076
|
if (args.latest) {
|
185085
185077
|
logger.warn(
|
185086
185078
|
"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"
|
@@ -185118,7 +185110,7 @@ Please shift to the --legacy-assets command to preserve the current functionalit
|
|
185118
185110
|
jsxFragment: args.jsxFragment,
|
185119
185111
|
tsconfig: args.tsconfig,
|
185120
185112
|
routes: args.routes,
|
185121
|
-
|
185113
|
+
experimentalAssetsOptions,
|
185122
185114
|
legacyAssetPaths,
|
185123
185115
|
legacyEnv: isLegacyEnv(config),
|
185124
185116
|
minify: args.minify,
|
@@ -188435,7 +188427,7 @@ function createWorkerBundleFormData(workerBundle, config) {
|
|
188435
188427
|
placement,
|
188436
188428
|
tail_consumers: void 0,
|
188437
188429
|
limits: config?.limits,
|
188438
|
-
|
188430
|
+
experimental_assets: void 0
|
188439
188431
|
};
|
188440
188432
|
return createWorkerUploadForm(worker);
|
188441
188433
|
}
|
@@ -195328,7 +195320,7 @@ async function createDraftWorker({
|
|
195328
195320
|
placement: void 0,
|
195329
195321
|
tail_consumers: void 0,
|
195330
195322
|
limits: void 0,
|
195331
|
-
|
195323
|
+
experimental_assets: void 0
|
195332
195324
|
})
|
195333
195325
|
}
|
195334
195326
|
);
|
@@ -195384,7 +195376,7 @@ var secret2 = /* @__PURE__ */ __name((secretYargs) => {
|
|
195384
195376
|
} catch (e3) {
|
195385
195377
|
if (e3 instanceof APIError && e3.code === VERSION_NOT_DEPLOYED_ERR_CODE) {
|
195386
195378
|
throw new UserError(
|
195387
|
-
"Secret edit failed. You attempted to modify a secret, but the latest version of your Worker isn't currently deployed. Please ensure that the latest version of your Worker is fully deployed (wrangler versions deploy
|
195379
|
+
"Secret edit failed. You attempted to modify a secret, but the latest version of your Worker isn't currently deployed. Please ensure that the latest version of your Worker is fully deployed (wrangler versions deploy) before modifying secrets. Alternatively, you can use the Cloudflare dashboard to modify secrets and deploy the version.\n\nNote: This limitation will be addressed in an upcoming release."
|
195388
195380
|
);
|
195389
195381
|
} else {
|
195390
195382
|
throw e3;
|
@@ -205331,7 +205323,11 @@ async function generateTypes(configToDTS, config, envInterface, outputPath) {
|
|
205331
205323
|
}
|
205332
205324
|
if (configToDTS.unsafe?.bindings) {
|
205333
205325
|
for (const unsafe of configToDTS.unsafe.bindings) {
|
205334
|
-
|
205326
|
+
if (unsafe.type === "ratelimit") {
|
205327
|
+
envTypeStructure.push(constructType(unsafe.name, "RateLimit"));
|
205328
|
+
} else {
|
205329
|
+
envTypeStructure.push(constructType(unsafe.name, "any"));
|
205330
|
+
}
|
205335
205331
|
}
|
205336
205332
|
}
|
205337
205333
|
if (configToDTS.queues) {
|
@@ -206692,7 +206688,7 @@ async function versionsSecretPutBulkHandler(args) {
|
|
206692
206688
|
}
|
206693
206689
|
logger.log(
|
206694
206690
|
`\u2728 Success! Created version ${newVersion.id} with ${secrets.length} secrets.
|
206695
|
-
\u27A1\uFE0F To deploy this version to production traffic use the command "wrangler versions deploy
|
206691
|
+
\u27A1\uFE0F To deploy this version to production traffic use the command "wrangler versions deploy".`
|
206696
206692
|
);
|
206697
206693
|
}
|
206698
206694
|
__name(versionsSecretPutBulkHandler, "versionsSecretPutBulkHandler");
|
@@ -206770,7 +206766,7 @@ async function versionsSecretDeleteHandler(args) {
|
|
206770
206766
|
});
|
206771
206767
|
logger.log(
|
206772
206768
|
`\u2728 Success! Created version ${newVersion.id} with deleted secret ${args.key}.
|
206773
|
-
\u27A1\uFE0F To deploy this version without the secret ${args.key} to production traffic use the command "wrangler versions deploy
|
206769
|
+
\u27A1\uFE0F To deploy this version without the secret ${args.key} to production traffic use the command "wrangler versions deploy".`
|
206774
206770
|
);
|
206775
206771
|
}
|
206776
206772
|
}
|
@@ -206906,7 +206902,7 @@ async function versionsSecretPutHandler(args) {
|
|
206906
206902
|
});
|
206907
206903
|
logger.log(
|
206908
206904
|
`\u2728 Success! Created version ${newVersion.id} with secret ${args.key}.
|
206909
|
-
\u27A1\uFE0F To deploy this version with secret ${args.key} to production traffic use the command "wrangler versions deploy
|
206905
|
+
\u27A1\uFE0F To deploy this version with secret ${args.key} to production traffic use the command "wrangler versions deploy".`
|
206910
206906
|
);
|
206911
206907
|
}
|
206912
206908
|
__name(versionsSecretPutHandler, "versionsSecretPutHandler");
|
@@ -207007,7 +207003,7 @@ async function copyWorkerVersionWithNewSecrets({
|
|
207007
207003
|
"workers/message": versionMessage,
|
207008
207004
|
"workers/tag": versionTag
|
207009
207005
|
},
|
207010
|
-
|
207006
|
+
experimental_assets: void 0
|
207011
207007
|
};
|
207012
207008
|
const body = createWorkerUploadForm(worker);
|
207013
207009
|
const result = await fetchResult(
|
@@ -207096,7 +207092,6 @@ __name(parseModules, "parseModules");
|
|
207096
207092
|
init_import_meta_url();
|
207097
207093
|
var import_node_fs36 = require("node:fs");
|
207098
207094
|
var import_node_path61 = __toESM(require("node:path"));
|
207099
|
-
var import_node_url16 = require("node:url");
|
207100
207095
|
var scriptStartupErrorRegex2 = /startup/i;
|
207101
207096
|
function errIsScriptSize2(err) {
|
207102
207097
|
if (!err) {
|
@@ -207207,7 +207202,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
207207
207202
|
const destination = props.outDir ?? getWranglerTmpDir(props.projectRoot, "deploy");
|
207208
207203
|
const start = Date.now();
|
207209
207204
|
const workerName = scriptName;
|
207210
|
-
const workerUrl = `/accounts/${accountId}/workers/scripts/${scriptName}
|
207205
|
+
const workerUrl = `/accounts/${accountId}/workers/scripts/${scriptName}`;
|
207211
207206
|
const { format: format10 } = props.entry;
|
207212
207207
|
if (config.wasm_modules && format10 === "modules") {
|
207213
207208
|
throw new UserError(
|
@@ -207224,6 +207219,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
207224
207219
|
"You cannot configure [data_blobs] with an ES module worker. Instead, import the file directly in your code, and optionally configure `[rules]` in your wrangler.toml"
|
207225
207220
|
);
|
207226
207221
|
}
|
207222
|
+
let hasPreview = false;
|
207227
207223
|
try {
|
207228
207224
|
if (props.noBundle) {
|
207229
207225
|
const destinationDir = typeof destination === "string" ? destination : destination.path;
|
@@ -207298,11 +207294,14 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
207298
207294
|
legacyEnv: props.legacyEnv,
|
207299
207295
|
env: props.env
|
207300
207296
|
}) : void 0;
|
207301
|
-
const
|
207302
|
-
|
207303
|
-
|
207304
|
-
|
207305
|
-
|
207297
|
+
const experimentalAssetsOptions = props.experimentalAssetsOptions && !props.dryRun ? {
|
207298
|
+
routingConfig: props.experimentalAssetsOptions?.routingConfig,
|
207299
|
+
jwt: await syncExperimentalAssets(
|
207300
|
+
accountId,
|
207301
|
+
scriptName,
|
207302
|
+
props.experimentalAssetsOptions.directory
|
207303
|
+
)
|
207304
|
+
} : void 0;
|
207306
207305
|
const bindings = {
|
207307
207306
|
kv_namespaces: config.kv_namespaces || [],
|
207308
207307
|
send_email: config.send_email,
|
@@ -207362,7 +207361,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
207362
207361
|
"workers/message": props.message,
|
207363
207362
|
"workers/tag": props.tag
|
207364
207363
|
},
|
207365
|
-
|
207364
|
+
experimental_assets: experimentalAssetsOptions
|
207366
207365
|
};
|
207367
207366
|
await printBundleSize(
|
207368
207367
|
{ name: import_node_path61.default.basename(resolvedEntryPointPath), content },
|
@@ -207386,25 +207385,16 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
207386
207385
|
let bindingsPrinted = false;
|
207387
207386
|
try {
|
207388
207387
|
const body = createWorkerUploadForm(worker);
|
207389
|
-
const result = await fetchResult(
|
207390
|
-
|
207391
|
-
|
207392
|
-
|
207393
|
-
|
207394
|
-
headers: await getMetricsUsageHeaders(config.send_metrics)
|
207395
|
-
},
|
207396
|
-
new import_node_url16.URLSearchParams({
|
207397
|
-
include_subdomain_availability: "true",
|
207398
|
-
// pass excludeScript so the whole body of the
|
207399
|
-
// script doesn't get included in the response
|
207400
|
-
excludeScript: "true"
|
207401
|
-
})
|
207402
|
-
);
|
207388
|
+
const result = await fetchResult(`${workerUrl}/versions`, {
|
207389
|
+
method: "POST",
|
207390
|
+
body,
|
207391
|
+
headers: await getMetricsUsageHeaders(config.send_metrics)
|
207392
|
+
});
|
207403
207393
|
logger.log("Worker Startup Time:", result.startup_time_ms, "ms");
|
207404
207394
|
bindingsPrinted = true;
|
207405
207395
|
printBindings({ ...withoutStaticAssets, vars: maskedVars });
|
207406
|
-
logger.log("Worker Version ID:", result.id);
|
207407
207396
|
versionId = result.id;
|
207397
|
+
hasPreview = result.metadata.has_preview;
|
207408
207398
|
} catch (err) {
|
207409
207399
|
if (!bindingsPrinted) {
|
207410
207400
|
printBindings({ ...withoutStaticAssets, vars: maskedVars });
|
@@ -207447,12 +207437,19 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
207447
207437
|
}
|
207448
207438
|
const uploadMs = Date.now() - start;
|
207449
207439
|
logger.log("Uploaded", workerName, formatTime3(uploadMs));
|
207450
|
-
|
207451
|
-
|
207452
|
-
|
207453
|
-
|
207454
|
-
|
207455
|
-
|
207440
|
+
logger.log("Worker Version ID:", versionId);
|
207441
|
+
if (versionId && hasPreview) {
|
207442
|
+
const { enabled: available_on_subdomain } = await fetchResult(`${workerUrl}/subdomain`);
|
207443
|
+
if (available_on_subdomain) {
|
207444
|
+
const userSubdomain = await getWorkersDevSubdomain(accountId);
|
207445
|
+
const shortVersion = versionId.slice(0, 8);
|
207446
|
+
logger.log(
|
207447
|
+
`Version Preview URL: https://${shortVersion}-${workerName}.${userSubdomain}.workers.dev`
|
207448
|
+
);
|
207449
|
+
}
|
207450
|
+
}
|
207451
|
+
const cmdVersionsDeploy = blue("wrangler versions deploy");
|
207452
|
+
const cmdTriggersDeploy = blue("wrangler triggers deploy");
|
207456
207453
|
logger.info(
|
207457
207454
|
gray(`
|
207458
207455
|
To deploy this version to production traffic use the command ${cmdVersionsDeploy}
|
@@ -207830,7 +207827,7 @@ async function versionsUploadHandler(args) {
|
|
207830
207827
|
"Legacy Assets does not support uploading versions through `wrangler versions upload`. You must use `wrangler deploy` instead."
|
207831
207828
|
);
|
207832
207829
|
}
|
207833
|
-
const
|
207830
|
+
const experimentalAssetsOptions = processExperimentalAssetsArg(args, config);
|
207834
207831
|
if (args.latest) {
|
207835
207832
|
logger.warn(
|
207836
207833
|
"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"
|
@@ -207858,7 +207855,7 @@ async function versionsUploadHandler(args) {
|
|
207858
207855
|
jsxFactory: args.jsxFactory,
|
207859
207856
|
jsxFragment: args.jsxFragment,
|
207860
207857
|
tsconfig: args.tsconfig,
|
207861
|
-
|
207858
|
+
experimentalAssetsOptions,
|
207862
207859
|
minify: args.minify,
|
207863
207860
|
uploadSourceMaps: args.uploadSourceMaps,
|
207864
207861
|
nodeCompat: args.nodeCompat,
|
@@ -208096,11 +208093,11 @@ async function versionsDeploymentsViewHandler(args) {
|
|
208096
208093
|
await printWranglerBanner();
|
208097
208094
|
if (args.deploymentId === void 0) {
|
208098
208095
|
throw new UserError(
|
208099
|
-
"`wrangler deployments view` has been renamed `wrangler deployments status
|
208096
|
+
"`wrangler deployments view` has been renamed `wrangler deployments status`. Please use that command instead."
|
208100
208097
|
);
|
208101
208098
|
} else {
|
208102
208099
|
throw new UserError(
|
208103
|
-
"`wrangler deployments view <deployment-id>` has been renamed `wrangler versions view [version-id]
|
208100
|
+
"`wrangler deployments view <deployment-id>` has been renamed `wrangler versions view [version-id]`. Please use that command instead."
|
208104
208101
|
);
|
208105
208102
|
}
|
208106
208103
|
}
|
@@ -209303,7 +209300,8 @@ Please shift to the --legacy-assets command to preserve the current functionalit
|
|
209303
209300
|
throw new UserError("Cannot use both --assets and --legacy-assets.");
|
209304
209301
|
}
|
209305
209302
|
args.legacyAssets = args.legacyAssets ?? args.assets;
|
209306
|
-
let
|
209303
|
+
let configFileWatcher;
|
209304
|
+
let assetsWatcher;
|
209307
209305
|
try {
|
209308
209306
|
const devInstance = await run(
|
209309
209307
|
{
|
@@ -209318,12 +209316,16 @@ Please shift to the --legacy-assets command to preserve the current functionalit
|
|
209318
209316
|
await import_node_events3.default.once(devInstance, "teardown");
|
209319
209317
|
} else {
|
209320
209318
|
(0, import_node_assert22.default)(!(devInstance instanceof DevEnv));
|
209321
|
-
|
209319
|
+
configFileWatcher = devInstance.configFileWatcher;
|
209320
|
+
assetsWatcher = devInstance.assetsWatcher;
|
209322
209321
|
const { waitUntilExit } = devInstance.devReactElement;
|
209323
209322
|
await waitUntilExit();
|
209324
209323
|
}
|
209325
209324
|
} finally {
|
209326
|
-
await
|
209325
|
+
await Promise.allSettled([
|
209326
|
+
configFileWatcher?.close(),
|
209327
|
+
assetsWatcher?.close()
|
209328
|
+
]);
|
209327
209329
|
}
|
209328
209330
|
}
|
209329
209331
|
__name(devHandler, "devHandler");
|
@@ -209380,7 +209382,8 @@ async function getPagesAssetsFetcher(options29) {
|
|
209380
209382
|
}
|
209381
209383
|
__name(getPagesAssetsFetcher, "getPagesAssetsFetcher");
|
209382
209384
|
async function startDev(args) {
|
209383
|
-
let
|
209385
|
+
let configFileWatcher;
|
209386
|
+
let assetsWatcher;
|
209384
209387
|
let rerender;
|
209385
209388
|
try {
|
209386
209389
|
const configPath = args.config || args.script && findWranglerToml(import_node_path63.default.dirname(args.script));
|
@@ -209415,11 +209418,11 @@ Move any existing data to .wrangler/state and use --persist, or
|
|
209415
209418
|
use --persist-to=./wrangler-local-state to keep using the old path.`
|
209416
209419
|
);
|
209417
209420
|
}
|
209418
|
-
|
209419
|
-
if (
|
209421
|
+
let experimentalAssetsOptions = processExperimentalAssetsArg(args, config);
|
209422
|
+
if (experimentalAssetsOptions) {
|
209420
209423
|
args.forceLocal = true;
|
209421
209424
|
}
|
209422
|
-
if ((args.legacyAssets || config.legacy_assets) &&
|
209425
|
+
if ((args.legacyAssets || config.legacy_assets) && experimentalAssetsOptions) {
|
209423
209426
|
throw new UserError(
|
209424
209427
|
"Cannot use Legacy Assets and Experimental Assets in the same Worker."
|
209425
209428
|
);
|
@@ -209581,7 +209584,10 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
|
|
209581
209584
|
enableServiceEnvironments: !(args.legacyEnv ?? true)
|
209582
209585
|
},
|
209583
209586
|
experimental: {
|
209584
|
-
|
209587
|
+
// only pass `experimentalAssetsOptions` if it came from args not from config
|
209588
|
+
// otherwise config at startup ends up overriding future config changes in the
|
209589
|
+
// ConfigController
|
209590
|
+
assets: args.experimentalAssets ? experimentalAssetsOptions : void 0
|
209585
209591
|
}
|
209586
209592
|
});
|
209587
209593
|
void sendMetricsEvent(
|
@@ -209600,13 +209606,35 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
|
|
209600
209606
|
return devEnv;
|
209601
209607
|
}
|
209602
209608
|
if (config.configPath && !args.experimentalDevEnv) {
|
209603
|
-
|
209609
|
+
configFileWatcher = (0, import_chokidar6.watch)(config.configPath, {
|
209604
209610
|
persistent: true
|
209605
209611
|
}).on("change", async (_event) => {
|
209606
|
-
|
209607
|
-
|
209612
|
+
try {
|
209613
|
+
config = readConfig(configPath, args);
|
209614
|
+
if (!config.configPath) {
|
209615
|
+
return;
|
209616
|
+
}
|
209608
209617
|
logger.log(`${import_node_path63.default.basename(config.configPath)} changed...`);
|
209618
|
+
if (experimentalAssetsOptions && !args.experimentalAssets) {
|
209619
|
+
await assetsWatcher?.close();
|
209620
|
+
experimentalAssetsOptions = processExperimentalAssetsArg(
|
209621
|
+
args,
|
209622
|
+
config
|
209623
|
+
);
|
209624
|
+
if (experimentalAssetsOptions) {
|
209625
|
+
assetsWatcher = (0, import_chokidar6.watch)(experimentalAssetsOptions.directory, {
|
209626
|
+
persistent: true,
|
209627
|
+
ignoreInitial: true
|
209628
|
+
}).on("all", async (eventName, changedPath) => {
|
209629
|
+
const message = getAssetChangeMessage(eventName, changedPath);
|
209630
|
+
logger.log(`\u{1F300} ${message}...`);
|
209631
|
+
rerender(await getDevReactElement(config));
|
209632
|
+
});
|
209633
|
+
}
|
209634
|
+
}
|
209609
209635
|
rerender(await getDevReactElement(config));
|
209636
|
+
} catch (err) {
|
209637
|
+
logger.error(err);
|
209610
209638
|
}
|
209611
209639
|
});
|
209612
209640
|
}
|
@@ -209677,7 +209705,7 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
|
|
209677
209705
|
accountId: args.accountId ?? configParam.account_id ?? getAccountFromCache()?.id,
|
209678
209706
|
legacyAssetPaths,
|
209679
209707
|
legacyAssetsConfig: configParam.legacy_assets,
|
209680
|
-
experimentalAssets,
|
209708
|
+
experimentalAssets: experimentalAssetsOptions,
|
209681
209709
|
initialPort: args.port ?? configParam.dev.port ?? await getLocalPort2(),
|
209682
209710
|
initialIp: args.ip || configParam.dev.ip,
|
209683
209711
|
inspectorPort: args.inspectorPort ?? configParam.dev.inspector_port ?? await getInspectorPort2(),
|
@@ -209710,16 +209738,33 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
|
|
209710
209738
|
__name(getDevReactElement, "getDevReactElement");
|
209711
209739
|
const devReactElement = (0, import_ink13.render)(await getDevReactElement(config));
|
209712
209740
|
rerender = devReactElement.rerender;
|
209741
|
+
if (experimentalAssetsOptions && !args.experimentalDevEnv) {
|
209742
|
+
assetsWatcher = (0, import_chokidar6.watch)(experimentalAssetsOptions.directory, {
|
209743
|
+
persistent: true,
|
209744
|
+
ignoreInitial: true
|
209745
|
+
}).on("all", async (eventName, filePath) => {
|
209746
|
+
const message = getAssetChangeMessage(eventName, filePath);
|
209747
|
+
logger.log(`\u{1F300} ${message}...`);
|
209748
|
+
rerender(await getDevReactElement(config));
|
209749
|
+
});
|
209750
|
+
}
|
209713
209751
|
return {
|
209714
209752
|
devReactElement,
|
209715
|
-
|
209753
|
+
configFileWatcher,
|
209754
|
+
assetsWatcher,
|
209716
209755
|
stop: async () => {
|
209717
209756
|
devReactElement.unmount();
|
209718
|
-
await
|
209757
|
+
await Promise.allSettled([
|
209758
|
+
configFileWatcher?.close(),
|
209759
|
+
assetsWatcher?.close()
|
209760
|
+
]);
|
209719
209761
|
}
|
209720
209762
|
};
|
209721
209763
|
} catch (e3) {
|
209722
|
-
await
|
209764
|
+
await Promise.allSettled([
|
209765
|
+
configFileWatcher?.close(),
|
209766
|
+
assetsWatcher?.close()
|
209767
|
+
]);
|
209723
209768
|
throw e3;
|
209724
209769
|
}
|
209725
209770
|
}
|
@@ -210150,6 +210195,25 @@ function getBindings(configParam, env7, local, args) {
|
|
210150
210195
|
return bindings;
|
210151
210196
|
}
|
210152
210197
|
__name(getBindings, "getBindings");
|
210198
|
+
function getAssetChangeMessage(eventName, assetPath) {
|
210199
|
+
let message = `${assetPath} changed`;
|
210200
|
+
switch (eventName) {
|
210201
|
+
case "add":
|
210202
|
+
message = `File ${assetPath} was added`;
|
210203
|
+
break;
|
210204
|
+
case "addDir":
|
210205
|
+
message = `Directory ${assetPath} was added`;
|
210206
|
+
break;
|
210207
|
+
case "unlink":
|
210208
|
+
message = `File ${assetPath} was removed`;
|
210209
|
+
break;
|
210210
|
+
case "unlinkDir":
|
210211
|
+
message = `Directory ${assetPath} was removed`;
|
210212
|
+
break;
|
210213
|
+
}
|
210214
|
+
return message;
|
210215
|
+
}
|
210216
|
+
__name(getAssetChangeMessage, "getAssetChangeMessage");
|
210153
210217
|
|
210154
210218
|
// src/api/dev.ts
|
210155
210219
|
async function unstable_dev(script, options29, apiOptions) {
|
@@ -210764,6 +210828,13 @@ async function resolveConfig(config, input) {
|
|
210764
210828
|
);
|
210765
210829
|
const nodejsCompatMode = unwrapHook(input.build?.nodejsCompatMode, config);
|
210766
210830
|
const { bindings, unsafe } = await resolveBindings(config, input);
|
210831
|
+
const experimentalAssetsOptions = processExperimentalAssetsArg(
|
210832
|
+
{
|
210833
|
+
experimentalAssets: input?.experimental?.assets?.directory,
|
210834
|
+
script: input.entrypoint
|
210835
|
+
},
|
210836
|
+
config
|
210837
|
+
);
|
210767
210838
|
const resolved = {
|
210768
210839
|
name: getScriptName({ name: input.name, env: input.env }, config),
|
210769
210840
|
compatibilityDate: getDevCompatibilityDate(config, input.compatibilityDate),
|
@@ -210805,7 +210876,7 @@ async function resolveConfig(config, input) {
|
|
210805
210876
|
metadata: input.unsafe?.metadata ?? unsafe?.metadata
|
210806
210877
|
},
|
210807
210878
|
experimental: {
|
210808
|
-
assets:
|
210879
|
+
assets: experimentalAssetsOptions
|
210809
210880
|
}
|
210810
210881
|
};
|
210811
210882
|
if (resolved.legacy.legacyAssets && resolved.legacy.site) {
|
@@ -210839,12 +210910,14 @@ var ConfigController = class extends Controller {
|
|
210839
210910
|
latestInput;
|
210840
210911
|
latestConfig;
|
210841
210912
|
#configWatcher;
|
210913
|
+
#assetsWatcher;
|
210842
210914
|
#abortController;
|
210843
210915
|
async #ensureWatchingConfig(configPath) {
|
210844
210916
|
await this.#configWatcher?.close();
|
210845
210917
|
if (configPath) {
|
210846
210918
|
this.#configWatcher = (0, import_chokidar8.watch)(configPath, {
|
210847
|
-
persistent: true
|
210919
|
+
persistent: true,
|
210920
|
+
ignoreInitial: true
|
210848
210921
|
}).on("change", async (_event) => {
|
210849
210922
|
logger.log(`${import_node_path64.default.basename(configPath)} changed...`);
|
210850
210923
|
(0, import_node_assert23.default)(
|
@@ -210855,6 +210928,23 @@ var ConfigController = class extends Controller {
|
|
210855
210928
|
});
|
210856
210929
|
}
|
210857
210930
|
}
|
210931
|
+
async #ensureWatchingAssets(assetsPath) {
|
210932
|
+
await this.#assetsWatcher?.close();
|
210933
|
+
if (assetsPath) {
|
210934
|
+
this.#assetsWatcher = (0, import_chokidar8.watch)(assetsPath, {
|
210935
|
+
persistent: true,
|
210936
|
+
ignoreInitial: true
|
210937
|
+
}).on("all", async (eventName, filePath) => {
|
210938
|
+
const message = getAssetChangeMessage(eventName, filePath);
|
210939
|
+
logger.log(`\u{1F300} ${message}...`);
|
210940
|
+
(0, import_node_assert23.default)(
|
210941
|
+
this.latestInput,
|
210942
|
+
"Cannot be watching config without having first set an input"
|
210943
|
+
);
|
210944
|
+
void this.#updateConfig(this.latestInput);
|
210945
|
+
});
|
210946
|
+
}
|
210947
|
+
}
|
210858
210948
|
set(input) {
|
210859
210949
|
return this.#updateConfig(input);
|
210860
210950
|
}
|
@@ -210874,29 +210964,43 @@ var ConfigController = class extends Controller {
|
|
210874
210964
|
this.#abortController = new AbortController();
|
210875
210965
|
const signal = this.#abortController.signal;
|
210876
210966
|
this.latestInput = input;
|
210877
|
-
|
210878
|
-
|
210879
|
-
|
210880
|
-
|
210881
|
-
|
210882
|
-
|
210883
|
-
|
210884
|
-
|
210885
|
-
|
210886
|
-
|
210887
|
-
|
210888
|
-
|
210967
|
+
try {
|
210968
|
+
const fileConfig = readConfig(input.config, {
|
210969
|
+
env: input.env,
|
210970
|
+
"dispatch-namespace": void 0,
|
210971
|
+
"legacy-env": !input.legacy?.enableServiceEnvironments,
|
210972
|
+
remote: input.dev?.remote,
|
210973
|
+
upstreamProtocol: input.dev?.origin?.secure === void 0 ? void 0 : input.dev?.origin?.secure ? "https" : "http",
|
210974
|
+
localProtocol: input.dev?.server?.secure === void 0 ? void 0 : input.dev?.server?.secure ? "https" : "http"
|
210975
|
+
});
|
210976
|
+
void this.#ensureWatchingConfig(fileConfig.configPath);
|
210977
|
+
const experimentalAssets = processExperimentalAssetsArg(
|
210978
|
+
{ experimentalAssets: input.experimental?.assets?.directory },
|
210979
|
+
fileConfig
|
210980
|
+
);
|
210981
|
+
if (experimentalAssets) {
|
210982
|
+
void this.#ensureWatchingAssets(experimentalAssets.directory);
|
210983
|
+
}
|
210984
|
+
const resolvedConfig = await resolveConfig(fileConfig, input);
|
210985
|
+
if (signal.aborted) {
|
210986
|
+
return;
|
210987
|
+
}
|
210988
|
+
this.latestConfig = resolvedConfig;
|
210989
|
+
this.emitConfigUpdateEvent(resolvedConfig);
|
210990
|
+
return this.latestConfig;
|
210991
|
+
} catch (err) {
|
210992
|
+
logger.error(err);
|
210889
210993
|
}
|
210890
|
-
this.latestConfig = resolvedConfig;
|
210891
|
-
this.emitConfigUpdateEvent(resolvedConfig);
|
210892
|
-
return this.latestConfig;
|
210893
210994
|
}
|
210894
210995
|
// ******************
|
210895
210996
|
// Event Handlers
|
210896
210997
|
// ******************
|
210897
210998
|
async teardown() {
|
210898
210999
|
logger.debug("ConfigController teardown beginning...");
|
210899
|
-
await
|
211000
|
+
await Promise.allSettled([
|
211001
|
+
this.#configWatcher?.close(),
|
211002
|
+
this.#assetsWatcher?.close()
|
211003
|
+
]);
|
210900
211004
|
logger.debug("ConfigController teardown complete");
|
210901
211005
|
}
|
210902
211006
|
// *********************
|
@@ -212921,4 +213025,3 @@ yargs-parser/build/lib/index.js:
|
|
212921
213025
|
* SPDX-License-Identifier: ISC
|
212922
213026
|
*)
|
212923
213027
|
*/
|
212924
|
-
//# sourceMappingURL=cli.js.map
|