wrangler 3.78.6 → 3.78.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "3.78.6",
3
+ "version": "3.78.7",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "wrangler",
@@ -62,7 +62,7 @@
62
62
  "resolve.exports": "^2.0.2",
63
63
  "selfsigned": "^2.0.1",
64
64
  "source-map": "^0.6.1",
65
- "unenv": "npm:unenv-nightly@2.0.0-1726478054.1e87097",
65
+ "unenv": "npm:unenv-nightly@2.0.0-20240919-125358-9a64854",
66
66
  "workerd": "1.20240909.0",
67
67
  "xxhash-wasm": "^1.0.1",
68
68
  "@cloudflare/kv-asset-handler": "0.3.4",
@@ -72329,7 +72329,7 @@ var init_execa = __esm({
72329
72329
  var require_depd = __commonJS({
72330
72330
  "../../node_modules/.pnpm/depd@2.0.0/node_modules/depd/index.js"(exports2, module3) {
72331
72331
  init_import_meta_url();
72332
- var relative16 = require("path").relative;
72332
+ var relative15 = require("path").relative;
72333
72333
  module3.exports = depd;
72334
72334
  var basePath = process.cwd();
72335
72335
  function containsNamespace(str, namespace) {
@@ -72535,7 +72535,7 @@ var require_depd = __commonJS({
72535
72535
  }
72536
72536
  __name(formatColor, "formatColor");
72537
72537
  function formatLocation(callSite) {
72538
- return relative16(basePath, callSite[0]) + ":" + callSite[1] + ":" + callSite[2];
72538
+ return relative15(basePath, callSite[0]) + ":" + callSite[1] + ":" + callSite[2];
72539
72539
  }
72540
72540
  __name(formatLocation, "formatLocation");
72541
72541
  function getStack() {
@@ -95511,51 +95511,51 @@ var require_uri_all = __commonJS({
95511
95511
  return uriTokens.join("");
95512
95512
  }
95513
95513
  __name(serialize, "serialize");
95514
- function resolveComponents(base2, relative16) {
95514
+ function resolveComponents(base2, relative15) {
95515
95515
  var options29 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
95516
95516
  var skipNormalization = arguments[3];
95517
95517
  var target = {};
95518
95518
  if (!skipNormalization) {
95519
95519
  base2 = parse7(serialize(base2, options29), options29);
95520
- relative16 = parse7(serialize(relative16, options29), options29);
95520
+ relative15 = parse7(serialize(relative15, options29), options29);
95521
95521
  }
95522
95522
  options29 = options29 || {};
95523
- if (!options29.tolerant && relative16.scheme) {
95524
- target.scheme = relative16.scheme;
95525
- target.userinfo = relative16.userinfo;
95526
- target.host = relative16.host;
95527
- target.port = relative16.port;
95528
- target.path = removeDotSegments(relative16.path || "");
95529
- target.query = relative16.query;
95523
+ if (!options29.tolerant && relative15.scheme) {
95524
+ target.scheme = relative15.scheme;
95525
+ target.userinfo = relative15.userinfo;
95526
+ target.host = relative15.host;
95527
+ target.port = relative15.port;
95528
+ target.path = removeDotSegments(relative15.path || "");
95529
+ target.query = relative15.query;
95530
95530
  } else {
95531
- if (relative16.userinfo !== void 0 || relative16.host !== void 0 || relative16.port !== void 0) {
95532
- target.userinfo = relative16.userinfo;
95533
- target.host = relative16.host;
95534
- target.port = relative16.port;
95535
- target.path = removeDotSegments(relative16.path || "");
95536
- target.query = relative16.query;
95531
+ if (relative15.userinfo !== void 0 || relative15.host !== void 0 || relative15.port !== void 0) {
95532
+ target.userinfo = relative15.userinfo;
95533
+ target.host = relative15.host;
95534
+ target.port = relative15.port;
95535
+ target.path = removeDotSegments(relative15.path || "");
95536
+ target.query = relative15.query;
95537
95537
  } else {
95538
- if (!relative16.path) {
95538
+ if (!relative15.path) {
95539
95539
  target.path = base2.path;
95540
- if (relative16.query !== void 0) {
95541
- target.query = relative16.query;
95540
+ if (relative15.query !== void 0) {
95541
+ target.query = relative15.query;
95542
95542
  } else {
95543
95543
  target.query = base2.query;
95544
95544
  }
95545
95545
  } else {
95546
- if (relative16.path.charAt(0) === "/") {
95547
- target.path = removeDotSegments(relative16.path);
95546
+ if (relative15.path.charAt(0) === "/") {
95547
+ target.path = removeDotSegments(relative15.path);
95548
95548
  } else {
95549
95549
  if ((base2.userinfo !== void 0 || base2.host !== void 0 || base2.port !== void 0) && !base2.path) {
95550
- target.path = "/" + relative16.path;
95550
+ target.path = "/" + relative15.path;
95551
95551
  } else if (!base2.path) {
95552
- target.path = relative16.path;
95552
+ target.path = relative15.path;
95553
95553
  } else {
95554
- target.path = base2.path.slice(0, base2.path.lastIndexOf("/") + 1) + relative16.path;
95554
+ target.path = base2.path.slice(0, base2.path.lastIndexOf("/") + 1) + relative15.path;
95555
95555
  }
95556
95556
  target.path = removeDotSegments(target.path);
95557
95557
  }
95558
- target.query = relative16.query;
95558
+ target.query = relative15.query;
95559
95559
  }
95560
95560
  target.userinfo = base2.userinfo;
95561
95561
  target.host = base2.host;
@@ -95563,7 +95563,7 @@ var require_uri_all = __commonJS({
95563
95563
  }
95564
95564
  target.scheme = base2.scheme;
95565
95565
  }
95566
- target.fragment = relative16.fragment;
95566
+ target.fragment = relative15.fragment;
95567
95567
  return target;
95568
95568
  }
95569
95569
  __name(resolveComponents, "resolveComponents");
@@ -152882,7 +152882,7 @@ init_import_meta_url();
152882
152882
  init_import_meta_url();
152883
152883
 
152884
152884
  // package.json
152885
- var version = "3.78.6";
152885
+ var version = "3.78.7";
152886
152886
  var package_default = {
152887
152887
  name: "wrangler",
152888
152888
  version,
@@ -152969,7 +152969,7 @@ var package_default = {
152969
152969
  "resolve.exports": "^2.0.2",
152970
152970
  selfsigned: "^2.0.1",
152971
152971
  "source-map": "^0.6.1",
152972
- unenv: "npm:unenv-nightly@2.0.0-1726478054.1e87097",
152972
+ unenv: "npm:unenv-nightly@2.0.0-20240919-125358-9a64854",
152973
152973
  workerd: "1.20240909.0",
152974
152974
  "xxhash-wasm": "^1.0.1"
152975
152975
  },
@@ -166909,17 +166909,17 @@ var buildAssetManifest = /* @__PURE__ */ __name(async (dir) => {
166909
166909
  let counter = 0;
166910
166910
  const ignoreFn = await createAssetIgnoreFunction(dir);
166911
166911
  await Promise.all(
166912
- files.map(async (file) => {
166913
- const filepath = path16.join(dir, file);
166914
- const relativeFilepath = path16.relative(dir, filepath);
166912
+ files.map(async (relativeFilepath) => {
166915
166913
  if (ignoreFn?.(relativeFilepath)) {
166916
166914
  logger.debug("Ignoring asset:", relativeFilepath);
166917
166915
  return;
166918
166916
  }
166917
+ const filepath = path16.join(dir, relativeFilepath);
166919
166918
  const filestat = await (0, import_promises8.stat)(filepath);
166920
166919
  if (filestat.isSymbolicLink() || filestat.isDirectory()) {
166921
166920
  return;
166922
166921
  } else {
166922
+ errorOnLegacyPagesWorkerJSAsset(relativeFilepath, !!ignoreFn);
166923
166923
  if (counter >= MAX_ASSET_COUNT2) {
166924
166924
  throw new UserError(
166925
166925
  `Maximum number of assets exceeded.
@@ -166974,38 +166974,37 @@ function getExperimentalAssetsBasePath(config, experimentalAssetsCommandLineArg)
166974
166974
  __name(getExperimentalAssetsBasePath, "getExperimentalAssetsBasePath");
166975
166975
  function processExperimentalAssetsArg(args, config) {
166976
166976
  const experimentalAssets = args.experimentalAssets ? { directory: args.experimentalAssets } : config.experimental_assets;
166977
- let experimentalAssetsOptions;
166978
- if (experimentalAssets) {
166979
- const experimentalAssetsBasePath = getExperimentalAssetsBasePath(
166980
- config,
166981
- args.experimentalAssets
166982
- );
166983
- const resolvedExperimentalAssetsPath = path16.resolve(
166984
- experimentalAssetsBasePath,
166985
- experimentalAssets.directory
166986
- );
166987
- if (!(0, import_node_fs11.existsSync)(resolvedExperimentalAssetsPath)) {
166988
- const sourceOfTruthMessage = args.experimentalAssets ? '"--experimental-assets" command line argument' : '"experimental_assets.directory" field in your configuration file';
166989
- throw new UserError(
166990
- `The directory specified by the ${sourceOfTruthMessage} does not exist:
166977
+ if (!experimentalAssets) {
166978
+ return;
166979
+ }
166980
+ const experimentalAssetsBasePath = getExperimentalAssetsBasePath(
166981
+ config,
166982
+ args.experimentalAssets
166983
+ );
166984
+ const resolvedExperimentalAssetsPath = path16.resolve(
166985
+ experimentalAssetsBasePath,
166986
+ experimentalAssets.directory
166987
+ );
166988
+ if (!(0, import_node_fs11.existsSync)(resolvedExperimentalAssetsPath)) {
166989
+ const sourceOfTruthMessage = args.experimentalAssets ? '"--experimental-assets" command line argument' : '"experimental_assets.directory" field in your configuration file';
166990
+ throw new UserError(
166991
+ `The directory specified by the ${sourceOfTruthMessage} does not exist:
166991
166992
  ${resolvedExperimentalAssetsPath}`
166992
- );
166993
- }
166994
- experimentalAssets.directory = resolvedExperimentalAssetsPath;
166995
- const routingConfig = {
166996
- has_user_worker: Boolean(args.script || config.main)
166997
- };
166998
- const assetConfig = {
166999
- html_handling: config.experimental_assets?.html_handling,
167000
- not_found_handling: config.experimental_assets?.not_found_handling
167001
- };
167002
- experimentalAssetsOptions = {
167003
- ...experimentalAssets,
167004
- routingConfig,
167005
- assetConfig
167006
- };
166993
+ );
167007
166994
  }
167008
- return experimentalAssetsOptions;
166995
+ experimentalAssets.directory = resolvedExperimentalAssetsPath;
166996
+ const routingConfig = {
166997
+ has_user_worker: Boolean(args.script || config.main)
166998
+ };
166999
+ const assetConfig = {
167000
+ html_handling: config.experimental_assets?.html_handling,
167001
+ not_found_handling: config.experimental_assets?.not_found_handling
167002
+ };
167003
+ return {
167004
+ ...experimentalAssets,
167005
+ routingConfig,
167006
+ assetConfig
167007
+ };
167009
167008
  }
167010
167009
  __name(processExperimentalAssetsArg, "processExperimentalAssetsArg");
167011
167010
  function verifyMutuallyExclusiveAssetsArgsOrConfig(args, config) {
@@ -167026,8 +167025,8 @@ function verifyMutuallyExclusiveAssetsArgsOrConfig(args, config) {
167026
167025
  }
167027
167026
  }
167028
167027
  __name(verifyMutuallyExclusiveAssetsArgsOrConfig, "verifyMutuallyExclusiveAssetsArgsOrConfig");
167028
+ var CF_ASSETS_IGNORE_FILENAME = ".assetsignore";
167029
167029
  async function createAssetIgnoreFunction(dir) {
167030
- const CF_ASSETS_IGNORE_FILENAME = ".assetsignore";
167031
167030
  const cfAssetIgnorePath = path16.resolve(dir, CF_ASSETS_IGNORE_FILENAME);
167032
167031
  if (!(0, import_node_fs11.existsSync)(cfAssetIgnorePath)) {
167033
167032
  return null;
@@ -167037,6 +167036,20 @@ async function createAssetIgnoreFunction(dir) {
167037
167036
  return createPatternMatcher(ignorePatterns, true);
167038
167037
  }
167039
167038
  __name(createAssetIgnoreFunction, "createAssetIgnoreFunction");
167039
+ function errorOnLegacyPagesWorkerJSAsset(file, hasAssetsIgnoreFile) {
167040
+ if (!hasAssetsIgnoreFile) {
167041
+ const workerJsType = file === "_worker.js" ? "file" : file.startsWith("_worker.js") ? "directory" : null;
167042
+ if (workerJsType !== null) {
167043
+ throw new UserError(dedent2`
167044
+ Uploading a Pages _worker.js ${workerJsType} as an asset.
167045
+ This could expose your private server-side code to the public Internet. Is this intended?
167046
+ If you do not want to upload this ${workerJsType}, either remove it or add an "${CF_ASSETS_IGNORE_FILENAME}" file, to the root of your asset directory, containing "_worker.js" to avoid uploading.
167047
+ If you do want to upload this ${workerJsType}, you can add an empty "${CF_ASSETS_IGNORE_FILENAME}" file, to the root of your asset directory, to hide this error.
167048
+ `);
167049
+ }
167050
+ }
167051
+ }
167052
+ __name(errorOnLegacyPagesWorkerJSAsset, "errorOnLegacyPagesWorkerJSAsset");
167040
167053
 
167041
167054
  // src/metrics/index.ts
167042
167055
  init_import_meta_url();
@@ -189332,26 +189345,39 @@ var import_node_path39 = __toESM(require("node:path"));
189332
189345
 
189333
189346
  // src/match-tag.ts
189334
189347
  init_import_meta_url();
189335
- async function verifyWorkerMatchesCITag(accountId, workerName) {
189348
+ async function verifyWorkerMatchesCITag(accountId, workerName, configPath) {
189336
189349
  const matchTag = getCIMatchTag();
189350
+ logger.debug(
189351
+ `Starting verifyWorkerMatchesCITag() with tag: ${matchTag}, name: ${workerName}`
189352
+ );
189337
189353
  if (!matchTag) {
189354
+ logger.debug(
189355
+ "No WRANGLER_CI_MATCH_TAG variable provided, aborting verifyWorkerMatchesCITag()"
189356
+ );
189338
189357
  return;
189339
189358
  }
189359
+ const envAccountID = getCloudflareAccountIdFromEnv();
189360
+ if (accountId !== envAccountID) {
189361
+ throw new FatalError(
189362
+ `The \`account_id\` in \`${configPath ?? "wrangler.toml"}\` must match the \`account_id\` for this account. Please update your wrangler.toml with \`account_id = "${envAccountID}"\``
189363
+ );
189364
+ }
189340
189365
  let tag;
189341
189366
  try {
189342
189367
  const worker = await fetchResult(
189343
189368
  `/accounts/${accountId}/workers/services/${workerName}`
189344
189369
  );
189345
189370
  tag = worker.default_environment.script.tag;
189371
+ logger.debug(`API returned with tag: ${tag} for worker: ${workerName}`);
189346
189372
  } catch (e3) {
189347
189373
  logger.debug(e3);
189348
189374
  if (e3.code === 10090) {
189349
189375
  throw new FatalError(
189350
- `Your Worker's name (${workerName}) does not match what is expected by the CI system`
189376
+ `The name in \`${configPath ?? "wrangler.toml"}\` (${workerName}) must match the name of your Worker. Please update the name field in your wrangler.toml.`
189351
189377
  );
189352
189378
  } else {
189353
189379
  throw new FatalError(
189354
- "Wrangler cannot validate that your Worker name matches what is expected by the CI system"
189380
+ "Wrangler cannot validate that your Worker name matches what is expected by the build system. Please retry the build."
189355
189381
  );
189356
189382
  }
189357
189383
  }
@@ -189360,7 +189386,7 @@ async function verifyWorkerMatchesCITag(accountId, workerName) {
189360
189386
  `Failed to match Worker tag. The API returned "${tag}", but the CI system expected "${matchTag}"`
189361
189387
  );
189362
189388
  throw new FatalError(
189363
- `Your Worker's name (${workerName}) does not match what is expected by the CI system`
189389
+ `The name in \`${configPath ?? "wrangler.toml"}\` (${workerName}) must match the name of your Worker. Please update the name field in your wrangler.toml.`
189364
189390
  );
189365
189391
  }
189366
189392
  }
@@ -189597,7 +189623,11 @@ Please shift to the --legacy-assets command to preserve the current functionalit
189597
189623
  );
189598
189624
  if (!args.dryRun) {
189599
189625
  (0, import_node_assert21.default)(accountId, "Missing account ID");
189600
- await verifyWorkerMatchesCITag(accountId, name);
189626
+ await verifyWorkerMatchesCITag(
189627
+ accountId,
189628
+ name,
189629
+ import_node_path39.default.relative(entry.directory, config.configPath ?? "wrangler.toml")
189630
+ );
189601
189631
  }
189602
189632
  const { sourceMapSize, versionId, workerTag, targets } = await deploy({
189603
189633
  config,
@@ -210238,7 +210268,8 @@ async function typesHandler(args) {
210238
210268
  browser: config.browser,
210239
210269
  ai: config.ai,
210240
210270
  version_metadata: config.version_metadata,
210241
- secrets
210271
+ secrets,
210272
+ experimental_assets: config.experimental_assets
210242
210273
  };
210243
210274
  await generateTypes(
210244
210275
  configBindingsWithSecrets,
@@ -210430,6 +210461,11 @@ async function generateTypes(configToDTS, config, envInterface, outputPath) {
210430
210461
  `${configToDTS.version_metadata.binding}: { id: string; tag: string };`
210431
210462
  );
210432
210463
  }
210464
+ if (configToDTS.experimental_assets?.binding) {
210465
+ envTypeStructure.push(
210466
+ constructType(configToDTS.experimental_assets.binding, "Fetcher")
210467
+ );
210468
+ }
210433
210469
  const modulesTypeStructure = [];
210434
210470
  if (configToDTS.rules) {
210435
210471
  const moduleTypeMap = {
@@ -212917,7 +212953,11 @@ async function versionsUploadHandler(args) {
212917
212953
  );
212918
212954
  if (!args.dryRun) {
212919
212955
  (0, import_node_assert23.default)(accountId, "Missing account ID");
212920
- await verifyWorkerMatchesCITag(accountId, name);
212956
+ await verifyWorkerMatchesCITag(
212957
+ accountId,
212958
+ name,
212959
+ import_node_path62.default.relative(entry.directory, config.configPath ?? "wrangler.toml")
212960
+ );
212921
212961
  }
212922
212962
  if (!args.dryRun) {
212923
212963
  await standardPricingWarning2(config);
@@ -214509,6 +214549,11 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
214509
214549
  "Cannot use Legacy Assets and Workers Sites in the same Worker."
214510
214550
  );
214511
214551
  }
214552
+ if ((args.experimentalAssets || config.experimental_assets) && args.remote) {
214553
+ throw new UserError(
214554
+ "Cannot use Experimental Assets in remote mode. Workers with assets are only supported in local mode. Please use `wrangler dev`."
214555
+ );
214556
+ }
214512
214557
  verifyMutuallyExclusiveAssetsArgsOrConfig(args, config);
214513
214558
  let experimentalAssetsOptions = processExperimentalAssetsArg(args, config);
214514
214559
  if (experimentalAssetsOptions) {
@@ -214703,12 +214748,22 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
214703
214748
  return;
214704
214749
  }
214705
214750
  logger.log(`${import_node_path63.default.basename(config.configPath)} changed...`);
214751
+ entry = await getEntry(
214752
+ {
214753
+ legacyAssets: args.legacyAssets,
214754
+ script: args.script,
214755
+ moduleRoot: args.moduleRoot,
214756
+ experimentalAssets: args.experimentalAssets
214757
+ },
214758
+ config,
214759
+ "dev"
214760
+ );
214761
+ experimentalAssetsOptions = processExperimentalAssetsArg(
214762
+ args,
214763
+ config
214764
+ );
214706
214765
  if (experimentalAssetsOptions && !args.experimentalAssets) {
214707
214766
  await assetsWatcher?.close();
214708
- experimentalAssetsOptions = processExperimentalAssetsArg(
214709
- args,
214710
- config
214711
- );
214712
214767
  if (experimentalAssetsOptions) {
214713
214768
  assetsWatcher = (0, import_chokidar6.watch)(experimentalAssetsOptions.directory, {
214714
214769
  persistent: true,
@@ -214726,8 +214781,9 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
214726
214781
  }
214727
214782
  });
214728
214783
  }
214784
+ const devServerSettings = await validateDevServerSettings(args, config);
214785
+ let { entry } = devServerSettings;
214729
214786
  const {
214730
- entry,
214731
214787
  upstreamProtocol,
214732
214788
  host,
214733
214789
  routes,
@@ -214739,7 +214795,7 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
214739
214795
  localPersistencePath,
214740
214796
  processEntrypoint,
214741
214797
  additionalModules
214742
- } = await validateDevServerSettings(args, config);
214798
+ } = devServerSettings;
214743
214799
  const nodejsCompatMode = getNodeCompatMode(
214744
214800
  args.compatibilityFlags ?? config.compatibility_flags ?? [],
214745
214801
  {
@@ -217436,15 +217492,19 @@ function unstable_getMiniflareWorkerOptions(configPath, env7) {
217436
217492
  );
217437
217493
  }
217438
217494
  if (bindings.durable_objects !== void 0) {
217495
+ const classNameToUseSQLite = getClassNamesWhichUseSQLite(config.migrations);
217439
217496
  bindingOptions.durableObjects = Object.fromEntries(
217440
- bindings.durable_objects.bindings.map((binding) => [
217441
- binding.name,
217442
- {
217443
- className: binding.class_name,
217444
- scriptName: binding.script_name,
217445
- binding
217446
- }
217447
- ])
217497
+ bindings.durable_objects.bindings.map((binding) => {
217498
+ const useSQLite = classNameToUseSQLite.get(binding.class_name);
217499
+ return [
217500
+ binding.name,
217501
+ {
217502
+ className: binding.class_name,
217503
+ scriptName: binding.script_name,
217504
+ useSQLite
217505
+ }
217506
+ ];
217507
+ })
217448
217508
  );
217449
217509
  }
217450
217510
  const legacyAssetPaths = config.legacy_assets ? getLegacyAssetPaths(config, void 0) : getSiteAssetPaths(config);
@@ -218130,4 +218190,3 @@ yargs-parser/build/lib/index.js:
218130
218190
  * SPDX-License-Identifier: ISC
218131
218191
  *)
218132
218192
  */
218133
- //# sourceMappingURL=cli.js.map