vercel 36.0.0 → 37.1.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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +445 -337
  3. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -62540,7 +62540,7 @@ var require_package = __commonJS2({
62540
62540
  "../client/package.json"(exports2, module2) {
62541
62541
  module2.exports = {
62542
62542
  name: "@vercel/client",
62543
- version: "13.3.4",
62543
+ version: "13.4.0",
62544
62544
  main: "dist/index.js",
62545
62545
  typings: "dist/index.d.ts",
62546
62546
  homepage: "https://vercel.com",
@@ -63539,7 +63539,7 @@ var require_utils8 = __commonJS2({
63539
63539
  module2.exports = __toCommonJS4(utils_exports);
63540
63540
  var import_fetch2 = require_fetch2();
63541
63541
  var import_path44 = require("path");
63542
- var import_url24 = require("url");
63542
+ var import_url23 = require("url");
63543
63543
  var import_ignore = __toESM4(require_ignore());
63544
63544
  var import_pkg5 = require_pkg();
63545
63545
  var import_build_utils19 = require("@vercel/build-utils");
@@ -63731,7 +63731,7 @@ ${clearRelative(ignoreFile)}`);
63731
63731
  url3 += `${url3.includes("?") ? "&" : "?"}teamId=${VERCEL_TEAM_ID}`;
63732
63732
  }
63733
63733
  if (opts.teamId) {
63734
- const parsedUrl = new import_url24.URL(url3);
63734
+ const parsedUrl = new import_url23.URL(url3);
63735
63735
  parsedUrl.searchParams.set("teamId", opts.teamId);
63736
63736
  url3 = parsedUrl.toString();
63737
63737
  delete opts.teamId;
@@ -63849,9 +63849,9 @@ var require_query_string = __commonJS2({
63849
63849
  generateQueryString: () => generateQueryString
63850
63850
  });
63851
63851
  module2.exports = __toCommonJS4(query_string_exports);
63852
- var import_url24 = require("url");
63852
+ var import_url23 = require("url");
63853
63853
  function generateQueryString(clientOptions) {
63854
- const options = new import_url24.URLSearchParams();
63854
+ const options = new import_url23.URLSearchParams();
63855
63855
  if (clientOptions.teamId) {
63856
63856
  options.set("teamId", clientOptions.teamId);
63857
63857
  }
@@ -96679,9 +96679,10 @@ var require_esprima = __commonJS2({
96679
96679
  }
96680
96680
  });
96681
96681
 
96682
- // ../../node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.es6.js
96682
+ // ../../node_modules/.pnpm/tslib@2.6.3/node_modules/tslib/tslib.es6.mjs
96683
96683
  var tslib_es6_exports2 = {};
96684
96684
  __export3(tslib_es6_exports2, {
96685
+ __addDisposableResource: () => __addDisposableResource,
96685
96686
  __assign: () => __assign2,
96686
96687
  __asyncDelegator: () => __asyncDelegator2,
96687
96688
  __asyncGenerator: () => __asyncGenerator2,
@@ -96693,6 +96694,7 @@ __export3(tslib_es6_exports2, {
96693
96694
  __classPrivateFieldSet: () => __classPrivateFieldSet2,
96694
96695
  __createBinding: () => __createBinding2,
96695
96696
  __decorate: () => __decorate2,
96697
+ __disposeResources: () => __disposeResources,
96696
96698
  __esDecorate: () => __esDecorate,
96697
96699
  __exportStar: () => __exportStar2,
96698
96700
  __extends: () => __extends2,
@@ -96710,7 +96712,8 @@ __export3(tslib_es6_exports2, {
96710
96712
  __spread: () => __spread2,
96711
96713
  __spreadArray: () => __spreadArray,
96712
96714
  __spreadArrays: () => __spreadArrays2,
96713
- __values: () => __values2
96715
+ __values: () => __values2,
96716
+ default: () => tslib_es6_default
96714
96717
  });
96715
96718
  function __extends2(d, b) {
96716
96719
  if (typeof b !== "function" && b !== null)
@@ -96780,10 +96783,10 @@ function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, e
96780
96783
  if (_ = accept(result.set))
96781
96784
  descriptor2.set = _;
96782
96785
  if (_ = accept(result.init))
96783
- initializers.push(_);
96786
+ initializers.unshift(_);
96784
96787
  } else if (_ = accept(result)) {
96785
96788
  if (kind === "field")
96786
- initializers.push(_);
96789
+ initializers.unshift(_);
96787
96790
  else
96788
96791
  descriptor2[key] = _;
96789
96792
  }
@@ -96985,16 +96988,24 @@ function __asyncGenerator2(thisArg, _arguments, generator) {
96985
96988
  if (!Symbol.asyncIterator)
96986
96989
  throw new TypeError("Symbol.asyncIterator is not defined.");
96987
96990
  var g = generator.apply(thisArg, _arguments || []), i, q2 = [];
96988
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
96991
+ return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function() {
96989
96992
  return this;
96990
96993
  }, i;
96991
- function verb(n) {
96992
- if (g[n])
96994
+ function awaitReturn(f) {
96995
+ return function(v) {
96996
+ return Promise.resolve(v).then(f, reject);
96997
+ };
96998
+ }
96999
+ function verb(n, f) {
97000
+ if (g[n]) {
96993
97001
  i[n] = function(v) {
96994
97002
  return new Promise(function(a, b) {
96995
97003
  q2.push([n, v, a, b]) > 1 || resume(n, v);
96996
97004
  });
96997
97005
  };
97006
+ if (f)
97007
+ i[n] = f(i[n]);
97008
+ }
96998
97009
  }
96999
97010
  function resume(n, v) {
97000
97011
  try {
@@ -97094,9 +97105,66 @@ function __classPrivateFieldIn(state, receiver) {
97094
97105
  throw new TypeError("Cannot use 'in' operator on non-object");
97095
97106
  return typeof state === "function" ? receiver === state : state.has(receiver);
97096
97107
  }
97097
- var extendStatics2, __assign2, __createBinding2, __setModuleDefault;
97108
+ function __addDisposableResource(env, value, async) {
97109
+ if (value !== null && value !== void 0) {
97110
+ if (typeof value !== "object" && typeof value !== "function")
97111
+ throw new TypeError("Object expected.");
97112
+ var dispose, inner;
97113
+ if (async) {
97114
+ if (!Symbol.asyncDispose)
97115
+ throw new TypeError("Symbol.asyncDispose is not defined.");
97116
+ dispose = value[Symbol.asyncDispose];
97117
+ }
97118
+ if (dispose === void 0) {
97119
+ if (!Symbol.dispose)
97120
+ throw new TypeError("Symbol.dispose is not defined.");
97121
+ dispose = value[Symbol.dispose];
97122
+ if (async)
97123
+ inner = dispose;
97124
+ }
97125
+ if (typeof dispose !== "function")
97126
+ throw new TypeError("Object not disposable.");
97127
+ if (inner)
97128
+ dispose = function() {
97129
+ try {
97130
+ inner.call(this);
97131
+ } catch (e2) {
97132
+ return Promise.reject(e2);
97133
+ }
97134
+ };
97135
+ env.stack.push({ value, dispose, async });
97136
+ } else if (async) {
97137
+ env.stack.push({ async: true });
97138
+ }
97139
+ return value;
97140
+ }
97141
+ function __disposeResources(env) {
97142
+ function fail(e2) {
97143
+ env.error = env.hasError ? new _SuppressedError(e2, env.error, "An error was suppressed during disposal.") : e2;
97144
+ env.hasError = true;
97145
+ }
97146
+ function next() {
97147
+ while (env.stack.length) {
97148
+ var rec = env.stack.pop();
97149
+ try {
97150
+ var result = rec.dispose && rec.dispose.call(rec.value);
97151
+ if (rec.async)
97152
+ return Promise.resolve(result).then(next, function(e2) {
97153
+ fail(e2);
97154
+ return next();
97155
+ });
97156
+ } catch (e2) {
97157
+ fail(e2);
97158
+ }
97159
+ }
97160
+ if (env.hasError)
97161
+ throw env.error;
97162
+ }
97163
+ return next();
97164
+ }
97165
+ var extendStatics2, __assign2, __createBinding2, __setModuleDefault, _SuppressedError, tslib_es6_default;
97098
97166
  var init_tslib_es62 = __esm({
97099
- "../../node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.es6.js"() {
97167
+ "../../node_modules/.pnpm/tslib@2.6.3/node_modules/tslib/tslib.es6.mjs"() {
97100
97168
  extendStatics2 = function(d, b) {
97101
97169
  extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
97102
97170
  d2.__proto__ = b2;
@@ -97139,6 +97207,39 @@ var init_tslib_es62 = __esm({
97139
97207
  } : function(o, v) {
97140
97208
  o["default"] = v;
97141
97209
  };
97210
+ _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error3, suppressed, message2) {
97211
+ var e2 = new Error(message2);
97212
+ return e2.name = "SuppressedError", e2.error = error3, e2.suppressed = suppressed, e2;
97213
+ };
97214
+ tslib_es6_default = {
97215
+ __extends: __extends2,
97216
+ __assign: __assign2,
97217
+ __rest: __rest2,
97218
+ __decorate: __decorate2,
97219
+ __param: __param2,
97220
+ __metadata: __metadata2,
97221
+ __awaiter: __awaiter2,
97222
+ __generator: __generator2,
97223
+ __createBinding: __createBinding2,
97224
+ __exportStar: __exportStar2,
97225
+ __values: __values2,
97226
+ __read: __read2,
97227
+ __spread: __spread2,
97228
+ __spreadArrays: __spreadArrays2,
97229
+ __spreadArray,
97230
+ __await: __await2,
97231
+ __asyncGenerator: __asyncGenerator2,
97232
+ __asyncDelegator: __asyncDelegator2,
97233
+ __asyncValues: __asyncValues2,
97234
+ __makeTemplateObject: __makeTemplateObject2,
97235
+ __importStar: __importStar2,
97236
+ __importDefault: __importDefault2,
97237
+ __classPrivateFieldGet: __classPrivateFieldGet2,
97238
+ __classPrivateFieldSet: __classPrivateFieldSet2,
97239
+ __classPrivateFieldIn,
97240
+ __addDisposableResource,
97241
+ __disposeResources
97242
+ };
97142
97243
  }
97143
97244
  });
97144
97245
 
@@ -121961,6 +122062,9 @@ var require_detect_builders = __commonJS2({
121961
122062
  var __toCommonJS4 = (mod) => __copyProps4(__defProp4({}, "__esModule", { value: true }), mod);
121962
122063
  var detect_builders_exports = {};
121963
122064
  __export4(detect_builders_exports, {
122065
+ REGEX_MIDDLEWARE_FILES: () => REGEX_MIDDLEWARE_FILES,
122066
+ REGEX_NON_VERCEL_PLATFORM_FILES: () => REGEX_NON_VERCEL_PLATFORM_FILES2,
122067
+ REGEX_VERCEL_PLATFORM_FILES: () => REGEX_VERCEL_PLATFORM_FILES,
121964
122068
  detectApiDirectory: () => detectApiDirectory3,
121965
122069
  detectApiExtensions: () => detectApiExtensions3,
121966
122070
  detectBuilders: () => detectBuilders4,
@@ -121973,6 +122077,9 @@ var require_detect_builders = __commonJS2({
121973
122077
  var import_path44 = require("path");
121974
122078
  var import_frameworks6 = __toESM4(require_frameworks());
121975
122079
  var import_is_official_runtime = require_is_official_runtime();
122080
+ var REGEX_MIDDLEWARE_FILES = "middleware.[jt]s";
122081
+ var REGEX_VERCEL_PLATFORM_FILES = `api/**,package.json,${REGEX_MIDDLEWARE_FILES}`;
122082
+ var REGEX_NON_VERCEL_PLATFORM_FILES2 = `!{${REGEX_VERCEL_PLATFORM_FILES}}`;
121976
122083
  var slugToFramework = new Map(
121977
122084
  import_frameworks6.default.map((f) => [f.slug, f])
121978
122085
  );
@@ -122129,7 +122236,7 @@ var require_detect_builders = __commonJS2({
122129
122236
  } else if (apiBuilders.length && hasNoneApiFiles) {
122130
122237
  frontendBuilder = {
122131
122238
  use: "@vercel/static",
122132
- src: "!{api/**,package.json,middleware.[jt]s}",
122239
+ src: REGEX_NON_VERCEL_PLATFORM_FILES2,
122133
122240
  config: {
122134
122241
  zeroConfig: true
122135
122242
  }
@@ -122251,7 +122358,7 @@ var require_detect_builders = __commonJS2({
122251
122358
  const config3 = { zeroConfig: true };
122252
122359
  return [
122253
122360
  {
122254
- src: "middleware.[jt]s",
122361
+ src: REGEX_MIDDLEWARE_FILES,
122255
122362
  use: `@vercel/node`,
122256
122363
  config: { ...config3, middleware: true }
122257
122364
  },
@@ -130185,6 +130292,7 @@ var require_dist27 = __commonJS2({
130185
130292
  GetWorkspaceOptions: () => import_get_workspaces.GetWorkspaceOptions,
130186
130293
  GetWorkspacePackagePathsOptions: () => import_get_workspace_package_paths.GetWorkspacePackagePathsOptions,
130187
130294
  LocalFileSystemDetector: () => import_local_file_system_detector.LocalFileSystemDetector,
130295
+ REGEX_NON_VERCEL_PLATFORM_FILES: () => import_detect_builders2.REGEX_NON_VERCEL_PLATFORM_FILES,
130188
130296
  Workspace: () => import_get_workspaces.Workspace,
130189
130297
  WorkspaceType: () => import_get_workspaces.WorkspaceType,
130190
130298
  detectApiDirectory: () => import_detect_builders.detectApiDirectory,
@@ -130219,6 +130327,7 @@ var require_dist27 = __commonJS2({
130219
130327
  var import_is_official_runtime = require_is_official_runtime();
130220
130328
  var import_package_managers = require_package_managers();
130221
130329
  __reExport(src_exports2, require_get_monorepo_default_settings(), module2.exports);
130330
+ var import_detect_builders2 = require_detect_builders();
130222
130331
  }
130223
130332
  });
130224
130333
 
@@ -130625,7 +130734,7 @@ var require_superstatic = __commonJS2({
130625
130734
  sourceToRegex: () => sourceToRegex
130626
130735
  });
130627
130736
  module2.exports = __toCommonJS4(superstatic_exports);
130628
- var import_url24 = require("url");
130737
+ var import_url23 = require("url");
130629
130738
  var import_path_to_regexp = require_dist28();
130630
130739
  var UN_NAMED_SEGMENT = "__UN_NAMED_SEGMENT__";
130631
130740
  function getCleanUrls2(filePaths) {
@@ -130841,7 +130950,7 @@ var require_superstatic = __commonJS2({
130841
130950
  indexes[name] = "$" + name;
130842
130951
  escapedDestination = escapeSegment(escapedDestination, name);
130843
130952
  });
130844
- const parsedDestination = (0, import_url24.parse)(escapedDestination, true);
130953
+ const parsedDestination = (0, import_url23.parse)(escapedDestination, true);
130845
130954
  delete parsedDestination.href;
130846
130955
  delete parsedDestination.path;
130847
130956
  delete parsedDestination.search;
@@ -130893,7 +131002,7 @@ var require_superstatic = __commonJS2({
130893
131002
  }
130894
131003
  }
130895
131004
  }
130896
- destination = (0, import_url24.format)({
131005
+ destination = (0, import_url23.format)({
130897
131006
  ...rest,
130898
131007
  hostname: hostname2,
130899
131008
  pathname,
@@ -131507,7 +131616,7 @@ var require_dist29 = __commonJS2({
131507
131616
  normalizeRoutes: () => normalizeRoutes2
131508
131617
  });
131509
131618
  module2.exports = __toCommonJS4(src_exports2);
131510
- var import_url24 = require("url");
131619
+ var import_url23 = require("url");
131511
131620
  var import_superstatic = require_superstatic();
131512
131621
  var import_append = require_append();
131513
131622
  var import_merge2 = require_merge3();
@@ -131638,7 +131747,7 @@ var require_dist29 = __commonJS2({
131638
131747
  }
131639
131748
  if (destination) {
131640
131749
  try {
131641
- const { hostname: hostname2, pathname, query } = (0, import_url24.parse)(destination, true);
131750
+ const { hostname: hostname2, pathname, query } = (0, import_url23.parse)(destination, true);
131642
131751
  (0, import_superstatic.sourceToRegex)(hostname2 || "").segments.forEach(
131643
131752
  (name) => destinationSegments.add(name)
131644
131753
  );
@@ -139465,7 +139574,11 @@ async function getEnvRecords(output2, client2, projectId, source, {
139465
139574
  );
139466
139575
  const query = new import_url11.URLSearchParams();
139467
139576
  if (target) {
139468
- query.set("target", target);
139577
+ let targetParam = "target";
139578
+ if (target !== "production" && target !== "preview" && target !== "development") {
139579
+ targetParam = "customEnvironmentId";
139580
+ }
139581
+ query.set(targetParam, target);
139469
139582
  }
139470
139583
  if (gitBranch) {
139471
139584
  query.set("gitBranch", gitBranch);
@@ -143366,7 +143479,7 @@ var init_process_deployment = __esm({
143366
143479
  });
143367
143480
 
143368
143481
  // src/util/index.ts
143369
- var import_events3, import_querystring3, import_url14, import_async_retry5, import_ms8, import_node_fetch3, import_url15, import_bytes4, import_chalk46, Now;
143482
+ var import_events3, import_querystring3, import_url14, import_async_retry5, import_ms8, import_node_fetch3, import_bytes4, import_chalk46, Now;
143370
143483
  var init_util = __esm({
143371
143484
  "src/util/index.ts"() {
143372
143485
  "use strict";
@@ -143376,7 +143489,6 @@ var init_util = __esm({
143376
143489
  import_async_retry5 = __toESM3(require_dist11());
143377
143490
  import_ms8 = __toESM3(require_ms2());
143378
143491
  import_node_fetch3 = __toESM3(require_lib14());
143379
- import_url15 = require("url");
143380
143492
  import_bytes4 = __toESM3(require_bytes());
143381
143493
  import_chalk46 = __toESM3(require_source());
143382
143494
  init_ua();
@@ -143575,62 +143687,6 @@ var init_util = __esm({
143575
143687
  }
143576
143688
  return new Error(error3.message || error3.errorMessage);
143577
143689
  }
143578
- async list(app, { version: version2 = 4, meta = {}, nextTimestamp, target } = {}, prod) {
143579
- const fetchRetry = async (url3, options = {}) => {
143580
- return this.retry(
143581
- async (bail) => {
143582
- const res = await this._fetch(url3, options);
143583
- if (res.status === 200) {
143584
- return res.json();
143585
- }
143586
- if (res.status > 200 && res.status < 500) {
143587
- return bail(await responseError2(res, "Failed to list deployments"));
143588
- }
143589
- throw await responseError2(res, "Failed to list deployments");
143590
- },
143591
- {
143592
- retries: 3,
143593
- minTimeout: 2500,
143594
- onRetry: this._onRetry
143595
- }
143596
- );
143597
- };
143598
- if (!app && !Object.keys(meta).length) {
143599
- const query2 = new import_url15.URLSearchParams({ limit: 20 .toString() });
143600
- if (nextTimestamp) {
143601
- query2.set("until", String(nextTimestamp));
143602
- }
143603
- const { projects, pagination } = await fetchRetry(
143604
- `/v4/projects/?${query2}`
143605
- );
143606
- const deployments = await Promise.all(
143607
- projects.map(async ({ id: projectId }) => {
143608
- const query3 = new import_url15.URLSearchParams({ limit: "1", projectId });
143609
- const { deployments: deployments2 } = await fetchRetry(
143610
- `/v${version2}/now/deployments?${query3}`
143611
- );
143612
- return deployments2[0];
143613
- })
143614
- );
143615
- return { deployments: deployments.filter((x) => x), pagination };
143616
- }
143617
- const query = new import_url15.URLSearchParams();
143618
- if (app) {
143619
- query.set("app", app);
143620
- }
143621
- Object.keys(meta).map((key) => query.set(`meta-${key}`, meta[key]));
143622
- query.set("limit", "20");
143623
- if (nextTimestamp) {
143624
- query.set("until", String(nextTimestamp));
143625
- }
143626
- if (prod) {
143627
- query.set("target", "production");
143628
- } else if (target) {
143629
- query.set("target", target);
143630
- }
143631
- const response = await fetchRetry(`/v${version2}/now/deployments?${query}`);
143632
- return response;
143633
- }
143634
143690
  async findDeployment(hostOrId) {
143635
143691
  const { debug: debug3 } = this._output;
143636
143692
  let id = hostOrId && !hostOrId.includes(".");
@@ -144089,16 +144145,18 @@ var init_command4 = __esm({
144089
144145
  // src/util/parse-target.ts
144090
144146
  function parseTarget({
144091
144147
  output: output2,
144092
- targetFlagName,
144093
- targetFlagValue,
144094
- prodFlagValue
144148
+ flagName,
144149
+ flags
144095
144150
  }) {
144151
+ const targetFlagName = `--${flagName}`;
144152
+ const targetFlagValue = flags[targetFlagName];
144153
+ const prodFlagValue = flags["--prod"];
144096
144154
  if (prodFlagValue && targetFlagValue) {
144097
144155
  output2.warn(
144098
- `Both \`--prod\` and \`--${targetFlagName}\` detected. Ignoring \`--prod\`.`
144156
+ `Both \`--prod\` and \`${targetFlagName}\` detected. Ignoring \`--prod\`.`
144099
144157
  );
144100
144158
  }
144101
- if (targetFlagValue) {
144159
+ if (typeof targetFlagValue === "string") {
144102
144160
  const lowerCaseTarget = targetFlagValue.toLowerCase();
144103
144161
  output2.debug(`Setting target to ${lowerCaseTarget}`);
144104
144162
  return lowerCaseTarget;
@@ -144161,8 +144219,8 @@ async function main(client2) {
144161
144219
  const autoConfirm = Boolean(parsedArgs.flags["--yes"]);
144162
144220
  const environment = parseTarget({
144163
144221
  output: client2.output,
144164
- targetFlagName: "environment",
144165
- targetFlagValue: parsedArgs.flags["--environment"]
144222
+ flagName: "environment",
144223
+ flags: parsedArgs.flags
144166
144224
  }) || "development";
144167
144225
  const link4 = await ensureLink("pull", client2, cwd, { autoConfirm });
144168
144226
  if (typeof link4 === "number") {
@@ -147852,7 +147910,7 @@ async function installBuilders(buildersDir, buildersToAdd, output2) {
147852
147910
  } else {
147853
147911
  const notFound = /GET (.*) - Not found/.exec(message2);
147854
147912
  if (notFound) {
147855
- const url3 = new import_url16.URL(notFound[1]);
147913
+ const url3 = new import_url15.URL(notFound[1]);
147856
147914
  const packageName2 = decodeURIComponent(url3.pathname.slice(1));
147857
147915
  message2 = `The package ${code(
147858
147916
  packageName2
@@ -147900,11 +147958,11 @@ function getErrorMessage(err, execaMessage) {
147900
147958
  }
147901
147959
  return execaMessage;
147902
147960
  }
147903
- var import_url16, import_pluralize4, import_npm_package_arg, import_semver2, import_path25, import_module2, import_fs_extra16, import_fs_detectors2, import_execa3, import_error_utils16, require_;
147961
+ var import_url15, import_pluralize4, import_npm_package_arg, import_semver2, import_path25, import_module2, import_fs_extra16, import_fs_detectors2, import_execa3, import_error_utils16, require_;
147904
147962
  var init_import_builders = __esm({
147905
147963
  "src/util/build/import-builders.ts"() {
147906
147964
  "use strict";
147907
- import_url16 = require("url");
147965
+ import_url15 = require("url");
147908
147966
  import_pluralize4 = __toESM3(require_pluralize());
147909
147967
  import_npm_package_arg = __toESM3(require_npa());
147910
147968
  import_semver2 = __toESM3(require_semver());
@@ -148330,9 +148388,8 @@ async function main2(client2) {
148330
148388
  }
148331
148389
  const target = parseTarget({
148332
148390
  output: output2,
148333
- targetFlagName: "target",
148334
- targetFlagValue: parsedArgs.flags["--target"],
148335
- prodFlagValue: parsedArgs.flags["--prod"]
148391
+ flagName: "target",
148392
+ flags: parsedArgs.flags
148336
148393
  }) || "preview";
148337
148394
  const yes = Boolean(parsedArgs.flags["--yes"]);
148338
148395
  try {
@@ -150298,9 +150355,8 @@ var init_deploy = __esm({
150298
150355
  }
150299
150356
  const target = parseTarget({
150300
150357
  output: output2,
150301
- targetFlagName: "target",
150302
- targetFlagValue: parsedArguments.flags["--target"],
150303
- prodFlagValue: parsedArguments.flags["--prod"]
150358
+ flagName: "target",
150359
+ flags: parsedArguments.flags
150304
150360
  });
150305
150361
  const archive = parsedArguments.flags["--archive"];
150306
150362
  if (typeof archive === "string" && !isValidArchive(archive)) {
@@ -166595,7 +166651,7 @@ function getRoutesTypes(routes2 = []) {
166595
166651
  }
166596
166652
  async function devRouter(reqUrl = "/", reqMethod, routes2, devServer, vercelConfig, previousHeaders, missRoutes, phase) {
166597
166653
  let result;
166598
- let { pathname: reqPathname, search: reqSearch } = import_url17.default.parse(reqUrl);
166654
+ let { pathname: reqPathname, search: reqSearch } = import_url16.default.parse(reqUrl);
166599
166655
  reqPathname = reqPathname || "/";
166600
166656
  const reqQuery = parseQueryString(reqSearch);
166601
166657
  const combinedHeaders = { ...previousHeaders };
@@ -166643,7 +166699,7 @@ async function devRouter(reqUrl = "/", reqMethod, routes2, devServer, vercelConf
166643
166699
  }
166644
166700
  const isDestUrl = isURL(destPath);
166645
166701
  if (routeConfig.check && devServer && vercelConfig && phase !== "hit" && !isDestUrl) {
166646
- let { pathname } = import_url17.default.parse(destPath);
166702
+ let { pathname } = import_url16.default.parse(destPath);
166647
166703
  pathname = pathname || "/";
166648
166704
  const hasDestFile = await devServer.hasFilesystem(
166649
166705
  pathname,
@@ -166696,7 +166752,7 @@ async function devRouter(reqUrl = "/", reqMethod, routes2, devServer, vercelConf
166696
166752
  if (!destPath.startsWith("/")) {
166697
166753
  destPath = `/${destPath}`;
166698
166754
  }
166699
- let { pathname: destPathname, search: destSearch } = import_url17.default.parse(destPath);
166755
+ let { pathname: destPathname, search: destSearch } = import_url16.default.parse(destPath);
166700
166756
  destPathname = destPathname || "/";
166701
166757
  const destQuery = parseQueryString(destSearch);
166702
166758
  Object.assign(destQuery, reqQuery);
@@ -166732,11 +166788,11 @@ async function devRouter(reqUrl = "/", reqMethod, routes2, devServer, vercelConf
166732
166788
  }
166733
166789
  return result;
166734
166790
  }
166735
- var import_url17, import_pcre_to_regexp, import_routing_utils3;
166791
+ var import_url16, import_pcre_to_regexp, import_routing_utils3;
166736
166792
  var init_router = __esm({
166737
166793
  "src/util/dev/router.ts"() {
166738
166794
  "use strict";
166739
- import_url17 = __toESM3(require("url"));
166795
+ import_url16 = __toESM3(require("url"));
166740
166796
  import_pcre_to_regexp = __toESM3(require_dist31());
166741
166797
  init_is_url();
166742
166798
  import_routing_utils3 = __toESM3(require_dist29());
@@ -167517,7 +167573,7 @@ function parseListen(str, defaultPort = 3e3) {
167517
167573
  if (!isNaN(port)) {
167518
167574
  return [port];
167519
167575
  }
167520
- const url3 = (0, import_url18.parse)(str);
167576
+ const url3 = (0, import_url17.parse)(str);
167521
167577
  switch (url3.protocol) {
167522
167578
  case "pipe:": {
167523
167579
  const cutStr = str.replace(/^pipe:/, "");
@@ -167552,11 +167608,11 @@ function parseListen(str, defaultPort = 3e3) {
167552
167608
  function replaceLocalhost(address) {
167553
167609
  return address.replace("[::]", "localhost").replace("0.0.0.0", "localhost");
167554
167610
  }
167555
- var import_url18;
167611
+ var import_url17;
167556
167612
  var init_parse_listen = __esm({
167557
167613
  "src/util/dev/parse-listen.ts"() {
167558
167614
  "use strict";
167559
- import_url18 = require("url");
167615
+ import_url17 = require("url");
167560
167616
  }
167561
167617
  });
167562
167618
 
@@ -167784,11 +167840,11 @@ function buildMatchEquals(a, b) {
167784
167840
  return false;
167785
167841
  return true;
167786
167842
  }
167787
- var import_url19, import_http3, import_fs_extra21, import_chalk58, import_node_fetch5, import_pluralize7, import_raw_body, import_async_listen3, import_minimatch4, import_http_proxy, import_crypto3, import_serve_handler, import_chokidar, import_dotenv2, import_path36, import_once, import_directory, import_get_port, import_is_port_reachable, import_fast_deep_equal, import_npm_package_arg2, import_json_parse_better_errors3, import_client11, import_routing_utils5, import_build_utils17, import_fs_detectors6, import_frameworks5, import_error_utils19, frontendRuntimeSet, DevServer;
167843
+ var import_url18, import_http3, import_fs_extra21, import_chalk58, import_node_fetch5, import_pluralize7, import_raw_body, import_async_listen3, import_minimatch4, import_http_proxy, import_crypto3, import_serve_handler, import_chokidar, import_dotenv2, import_path36, import_once, import_directory, import_get_port, import_is_port_reachable, import_fast_deep_equal, import_npm_package_arg2, import_json_parse_better_errors3, import_client11, import_routing_utils5, import_build_utils17, import_fs_detectors6, import_frameworks5, import_error_utils19, frontendRuntimeSet, DevServer;
167788
167844
  var init_server = __esm({
167789
167845
  "src/util/dev/server.ts"() {
167790
167846
  "use strict";
167791
- import_url19 = __toESM3(require("url"));
167847
+ import_url18 = __toESM3(require("url"));
167792
167848
  import_http3 = __toESM3(require("http"));
167793
167849
  import_fs_extra21 = __toESM3(require_lib());
167794
167850
  import_chalk58 = __toESM3(require_source());
@@ -167908,7 +167964,7 @@ var init_server = __esm({
167908
167964
  */
167909
167965
  this.serveProjectAsNowV2 = async (req, res, requestId, vercelConfig, routes2 = vercelConfig.routes, callLevel = 0) => {
167910
167966
  const { debug: debug3 } = this.output;
167911
- const parsed = import_url19.default.parse(req.url || "/");
167967
+ const parsed = import_url18.default.parse(req.url || "/");
167912
167968
  if (typeof parsed.pathname === "string" && parsed.pathname.includes("//")) {
167913
167969
  let location = parsed.pathname.replace(/\/+/g, "/");
167914
167970
  if (parsed.search) {
@@ -167931,11 +167987,11 @@ var init_server = __esm({
167931
167987
  const getReqUrl = (rr) => {
167932
167988
  if (rr.dest) {
167933
167989
  if (rr.query) {
167934
- const destParsed = import_url19.default.parse(rr.dest);
167990
+ const destParsed = import_url18.default.parse(rr.dest);
167935
167991
  const destQuery = parseQueryString(destParsed.search);
167936
167992
  Object.assign(destQuery, rr.query);
167937
167993
  destParsed.search = formatQueryString(destQuery);
167938
- return import_url19.default.format(destParsed);
167994
+ return import_url18.default.format(destParsed);
167939
167995
  }
167940
167996
  return rr.dest;
167941
167997
  }
@@ -168047,7 +168103,7 @@ var init_server = __esm({
168047
168103
  prevUrl = rewritePath;
168048
168104
  const beforeRewriteUrl = req.url || "/";
168049
168105
  if (isURL(rewritePath)) {
168050
- const rewriteUrlParsed = new import_url19.URL(rewritePath);
168106
+ const rewriteUrlParsed = new import_url18.URL(rewritePath);
168051
168107
  if (this.address.origin === rewriteUrlParsed.origin) {
168052
168108
  req.url = rewritePath.slice(rewriteUrlParsed.origin.length) || "/";
168053
168109
  prevUrl = req.url;
@@ -168058,9 +168114,9 @@ var init_server = __esm({
168058
168114
  return;
168059
168115
  }
168060
168116
  } else {
168061
- const rewriteUrlParsed = import_url19.default.parse(beforeRewriteUrl);
168062
- rewriteUrlParsed.search = import_url19.default.parse(rewritePath).search;
168063
- req.url = import_url19.default.format(rewriteUrlParsed);
168117
+ const rewriteUrlParsed = import_url18.default.parse(beforeRewriteUrl);
168118
+ rewriteUrlParsed.search = import_url18.default.parse(rewritePath).search;
168119
+ req.url = import_url18.default.format(rewriteUrlParsed);
168064
168120
  }
168065
168121
  debug3(
168066
168122
  `Rewrote incoming HTTP URL from "${beforeRewriteUrl}" to "${req.url}"`
@@ -168113,11 +168169,11 @@ Please ensure that ${cmd(err.path)} is properly installed`;
168113
168169
  }
168114
168170
  }
168115
168171
  if (routeResult.isDestUrl) {
168116
- const destParsed = import_url19.default.parse(routeResult.dest);
168172
+ const destParsed = import_url18.default.parse(routeResult.dest);
168117
168173
  const destQuery = parseQueryString(destParsed.search);
168118
168174
  Object.assign(destQuery, routeResult.query);
168119
168175
  destParsed.search = formatQueryString(destQuery);
168120
- const destUrl = import_url19.default.format(destParsed);
168176
+ const destUrl = import_url18.default.format(destParsed);
168121
168177
  debug3(`ProxyPass: ${destUrl}`);
168122
168178
  this.setResponseHeaders(res, requestId);
168123
168179
  return proxyPass(req, res, destUrl, this, requestId);
@@ -168256,12 +168312,12 @@ Please ensure that ${cmd(err.path)} is properly installed`;
168256
168312
  req.headers[name] = value;
168257
168313
  }
168258
168314
  this.setResponseHeaders(res, requestId);
168259
- const origUrl = import_url19.default.parse(req.url || "/");
168315
+ const origUrl = import_url18.default.parse(req.url || "/");
168260
168316
  const origQuery = parseQueryString(origUrl.search);
168261
168317
  origUrl.pathname = dest;
168262
168318
  Object.assign(origQuery, query);
168263
168319
  origUrl.search = formatQueryString(origQuery);
168264
- req.url = import_url19.default.format(origUrl);
168320
+ req.url = import_url18.default.format(origUrl);
168265
168321
  return proxyPass(req, res, upstream, this, requestId, false);
168266
168322
  }
168267
168323
  if (statusCode === 404 && routeResult.phase === "miss" || !this.renderDirectoryListing(req, res, requestPath, requestId)) {
@@ -168272,12 +168328,12 @@ Please ensure that ${cmd(err.path)} is properly installed`;
168272
168328
  const buildRequestPath = match.buildResults.has(null) ? null : requestPath;
168273
168329
  const buildResult = match.buildResults.get(buildRequestPath);
168274
168330
  if (buildResult && Array.isArray(buildResult.routes) && buildResult.routes.length > 0) {
168275
- const origUrl = import_url19.default.parse(req.url || "/");
168331
+ const origUrl = import_url18.default.parse(req.url || "/");
168276
168332
  const origQuery = parseQueryString(origUrl.search);
168277
168333
  origUrl.pathname = dest;
168278
168334
  Object.assign(origQuery, query);
168279
168335
  origUrl.search = formatQueryString(origQuery);
168280
- const newUrl = import_url19.default.format(origUrl);
168336
+ const newUrl = import_url18.default.format(origUrl);
168281
168337
  debug3(
168282
168338
  `Checking build result's ${buildResult.routes.length} \`routes\` to match ${newUrl}`
168283
168339
  );
@@ -168353,11 +168409,11 @@ Please ensure that ${cmd(err.path)} is properly installed`;
168353
168409
  debug3(
168354
168410
  `Proxying to "${builderPkg.name}" dev server (port=${port}, pid=${pid})`
168355
168411
  );
168356
- const origUrl = import_url19.default.parse(req.url || "/");
168412
+ const origUrl = import_url18.default.parse(req.url || "/");
168357
168413
  const origQuery = parseQueryString(origUrl.search);
168358
168414
  Object.assign(origQuery, query);
168359
168415
  origUrl.search = formatQueryString(origQuery);
168360
- req.url = import_url19.default.format({
168416
+ req.url = import_url18.default.format({
168361
168417
  pathname: origUrl.pathname,
168362
168418
  search: origUrl.search
168363
168419
  });
@@ -168436,11 +168492,11 @@ Please ensure that ${cmd(err.path)} is properly installed`;
168436
168492
  return;
168437
168493
  }
168438
168494
  requestId = generateRequestId(this.podId, true);
168439
- const origUrl = import_url19.default.parse(req.url || "/");
168495
+ const origUrl = import_url18.default.parse(req.url || "/");
168440
168496
  const origQuery = parseQueryString(origUrl.search);
168441
168497
  Object.assign(origQuery, query);
168442
168498
  origUrl.search = formatQueryString(origQuery);
168443
- const path11 = import_url19.default.format({
168499
+ const path11 = import_url18.default.format({
168444
168500
  pathname: origUrl.pathname,
168445
168501
  search: origUrl.search
168446
168502
  });
@@ -169061,7 +169117,7 @@ Please ensure that ${cmd(err.path)} is properly installed`;
169061
169117
  }
169062
169118
  }
169063
169119
  }
169064
- this._address = new import_url19.URL(replaceLocalhost(address));
169120
+ this._address = new import_url18.URL(replaceLocalhost(address));
169065
169121
  const vercelConfig = await this.getVercelConfig();
169066
169122
  const devCommandPromise = this.runDevCommand();
169067
169123
  const files = await staticFiles(this.cwd, { output: this.output });
@@ -172688,11 +172744,18 @@ async function addEnvRecord(output2, client2, projectId, upsert, type, key, valu
172688
172744
  output2.debug(
172689
172745
  `${actionWord} ${type} Environment Variable ${key} to ${targets.length} targets`
172690
172746
  );
172747
+ const target = [];
172748
+ const customEnvironmentIds = [];
172749
+ for (const t of targets) {
172750
+ const arr = import_constants4.PROJECT_ENV_TARGET.includes(t) ? target : customEnvironmentIds;
172751
+ arr.push(t);
172752
+ }
172691
172753
  const body = {
172692
172754
  type,
172693
172755
  key,
172694
172756
  value,
172695
- target: targets,
172757
+ target,
172758
+ customEnvironmentIds: customEnvironmentIds.length > 0 ? customEnvironmentIds : void 0,
172696
172759
  gitBranch: gitBranch || void 0
172697
172760
  };
172698
172761
  const args2 = upsert ? `?upsert=${upsert}` : "";
@@ -172702,9 +172765,11 @@ async function addEnvRecord(output2, client2, projectId, upsert, type, key, valu
172702
172765
  body
172703
172766
  });
172704
172767
  }
172768
+ var import_constants4;
172705
172769
  var init_add_env_record = __esm({
172706
172770
  "src/util/env/add-env-record.ts"() {
172707
172771
  "use strict";
172772
+ import_constants4 = __toESM3(require_dist26());
172708
172773
  }
172709
172774
  });
172710
172775
 
@@ -172769,6 +172834,29 @@ var init_known_error = __esm({
172769
172834
  }
172770
172835
  });
172771
172836
 
172837
+ // src/util/target/get-custom-environments.ts
172838
+ async function getCustomEnvironments(client2, projectId) {
172839
+ try {
172840
+ const res = await client2.fetch(
172841
+ `/projects/${encodeURIComponent(projectId)}/custom-environments`,
172842
+ { method: "GET" }
172843
+ );
172844
+ return res.environments;
172845
+ } catch (error3) {
172846
+ if ((0, import_error_utils23.isObject)(error3) && error3.status === 404) {
172847
+ return [];
172848
+ }
172849
+ throw error3;
172850
+ }
172851
+ }
172852
+ var import_error_utils23;
172853
+ var init_get_custom_environments = __esm({
172854
+ "src/util/target/get-custom-environments.ts"() {
172855
+ "use strict";
172856
+ import_error_utils23 = __toESM3(require_dist2());
172857
+ }
172858
+ });
172859
+
172772
172860
  // src/commands/env/add.ts
172773
172861
  async function add5(client2, project, opts, args2, output2) {
172774
172862
  const stdInput = await readStandardInput(client2.stdin);
@@ -172791,32 +172879,42 @@ async function add5(client2, project, opts, args2, output2) {
172791
172879
  }
172792
172880
  let envTargets = [];
172793
172881
  if (envTargetArg) {
172794
- if (!isValidEnvTarget(envTargetArg)) {
172795
- output2.error(
172796
- `The Environment ${param(
172797
- envTargetArg
172798
- )} is invalid. It must be one of: ${getEnvTargetPlaceholder()}.`
172799
- );
172800
- return 1;
172801
- }
172802
172882
  envTargets.push(envTargetArg);
172803
172883
  }
172804
172884
  if (!envName) {
172805
172885
  envName = await client2.input.text({
172806
- message: `What\u2019s the name of the variable?`,
172886
+ message: `What's the name of the variable?`,
172807
172887
  validate: (val) => val ? true : "Name cannot be empty"
172808
172888
  });
172809
172889
  }
172810
- const { envs } = await getEnvRecords(
172811
- output2,
172812
- client2,
172813
- project.id,
172814
- "vercel-cli:env:add"
172815
- );
172816
- const existing = new Set(
172817
- envs.filter((r) => r.key === envName).map((r) => r.target)
172818
- );
172819
- const choices = envTargetChoices.filter((c) => !existing.has(c.value));
172890
+ const [{ envs }, customEnvironments] = await Promise.all([
172891
+ getEnvRecords(output2, client2, project.id, "vercel-cli:env:add"),
172892
+ getCustomEnvironments(client2, project.id)
172893
+ ]);
172894
+ const matchingEnvs = envs.filter((r) => r.key === envName);
172895
+ const existingTargets = /* @__PURE__ */ new Set();
172896
+ const existingCustomEnvs = /* @__PURE__ */ new Set();
172897
+ for (const env of matchingEnvs) {
172898
+ if (typeof env.target === "string") {
172899
+ existingTargets.add(env.target);
172900
+ } else if (Array.isArray(env.target)) {
172901
+ for (const target of env.target) {
172902
+ existingTargets.add(target);
172903
+ }
172904
+ }
172905
+ if (env.customEnvironmentIds) {
172906
+ for (const customEnvId of env.customEnvironmentIds) {
172907
+ existingCustomEnvs.add(customEnvId);
172908
+ }
172909
+ }
172910
+ }
172911
+ const choices = [
172912
+ ...envTargetChoices.filter((c) => !existingTargets.has(c.value)),
172913
+ ...customEnvironments.filter((c) => !existingCustomEnvs.has(c.id)).map((c) => ({
172914
+ name: c.name,
172915
+ value: c.id
172916
+ }))
172917
+ ];
172820
172918
  if (choices.length === 0 && !opts["--force"]) {
172821
172919
  output2.error(
172822
172920
  `The variable ${param(
@@ -172832,7 +172930,7 @@ async function add5(client2, project, opts, args2, output2) {
172832
172930
  envValue = stdInput;
172833
172931
  } else {
172834
172932
  envValue = await client2.input.text({
172835
- message: `What\u2019s the value of ${envName}?`
172933
+ message: `What's the value of ${envName}?`
172836
172934
  });
172837
172935
  }
172838
172936
  while (envTargets.length === 0) {
@@ -172898,6 +172996,7 @@ var init_add4 = __esm({
172898
172996
  init_known_error();
172899
172997
  init_pkg_name();
172900
172998
  init_errors_ts();
172999
+ init_get_custom_environments();
172901
173000
  }
172902
173001
  });
172903
173002
 
@@ -172922,14 +173021,6 @@ async function ls5(client2, project, opts, args2, output2) {
172922
173021
  return 1;
172923
173022
  }
172924
173023
  const [envTarget, envGitBranch] = args2;
172925
- if (!isValidEnvTarget(envTarget)) {
172926
- output2.error(
172927
- `The Environment ${param(
172928
- envTarget
172929
- )} is invalid. It must be one of: ${getEnvTargetPlaceholder()}.`
172930
- );
172931
- return 1;
172932
- }
172933
173024
  const lsStamp = stamp_default();
172934
173025
  const [envsResult, customEnvs] = await Promise.all([
172935
173026
  getEnvRecords(output2, client2, project.id, "vercel-cli:env:ls", {
@@ -172956,20 +173047,6 @@ async function ls5(client2, project, opts, args2, output2) {
172956
173047
  }
172957
173048
  return 0;
172958
173049
  }
172959
- async function getCustomEnvironments(client2, projectId) {
172960
- try {
172961
- const res = await client2.fetch(
172962
- `/projects/${encodeURIComponent(projectId)}/custom-environments`,
172963
- { method: "GET" }
172964
- );
172965
- return res.environments;
172966
- } catch (error3) {
172967
- if ((0, import_error_utils23.isObject)(error3) && error3.status === 404) {
172968
- return [];
172969
- }
172970
- throw error3;
172971
- }
172972
- }
172973
173050
  function getTable(records, customEnvironments) {
172974
173051
  const label = records.some((env) => env.gitBranch) ? "environments (git branch)" : "environments";
172975
173052
  return formatTable(
@@ -173007,7 +173084,7 @@ function formatEnvTarget(env, customEnvironments) {
173007
173084
  const targetsString = [...defaultTargets, ...customTargets].join(", ");
173008
173085
  return env.gitBranch ? `${targetsString} (${env.gitBranch})` : targetsString;
173009
173086
  }
173010
- var import_chalk81, import_ms16, import_title4, import_error_utils23;
173087
+ var import_chalk81, import_ms16, import_title4;
173011
173088
  var init_ls5 = __esm({
173012
173089
  "src/commands/env/ls.ts"() {
173013
173090
  "use strict";
@@ -173018,10 +173095,9 @@ var init_ls5 = __esm({
173018
173095
  init_get_env_records();
173019
173096
  init_env_target();
173020
173097
  init_stamp();
173021
- init_param();
173022
173098
  init_pkg_name();
173023
173099
  init_ellipsis();
173024
- import_error_utils23 = __toESM3(require_dist2());
173100
+ init_get_custom_environments();
173025
173101
  }
173026
173102
  });
173027
173103
 
@@ -173181,7 +173257,12 @@ var init_command11 = __esm({
173181
173257
  {
173182
173258
  name: "ls",
173183
173259
  description: "List all variables for the specified Environment",
173184
- arguments: [],
173260
+ arguments: [
173261
+ {
173262
+ name: "environment",
173263
+ required: false
173264
+ }
173265
+ ],
173185
173266
  options: [],
173186
173267
  examples: []
173187
173268
  },
@@ -173360,8 +173441,8 @@ async function main6(client2) {
173360
173441
  const { cwd, config: config3 } = client2;
173361
173442
  const target = parseTarget({
173362
173443
  output: output2,
173363
- targetFlagName: "environment",
173364
- targetFlagValue: parsedArgs.flags["--environment"]
173444
+ flagName: "environment",
173445
+ flags: parsedArgs.flags
173365
173446
  }) || "development";
173366
173447
  const link4 = await getLinkedProject(client2, cwd);
173367
173448
  if (link4.status === "error") {
@@ -174775,7 +174856,7 @@ async function inspect3(client2) {
174775
174856
  const withLogs = parsedArguments.flags["--logs"];
174776
174857
  const startTimestamp = Date.now();
174777
174858
  try {
174778
- deploymentIdOrHost = new import_url20.URL(deploymentIdOrHost).hostname;
174859
+ deploymentIdOrHost = new import_url19.URL(deploymentIdOrHost).hostname;
174779
174860
  } catch {
174780
174861
  }
174781
174862
  client2.output.spinner(
@@ -174920,7 +175001,7 @@ function exitCode(state) {
174920
175001
  }
174921
175002
  return 0;
174922
175003
  }
174923
- var import_error_utils25, import_chalk89, import_ms17, import_title6, import_url20;
175004
+ var import_error_utils25, import_chalk89, import_ms17, import_title6, import_url19;
174924
175005
  var init_inspect2 = __esm({
174925
175006
  "src/commands/inspect/index.ts"() {
174926
175007
  "use strict";
@@ -174928,7 +175009,7 @@ var init_inspect2 = __esm({
174928
175009
  import_chalk89 = __toESM3(require_source());
174929
175010
  import_ms17 = __toESM3(require_ms2());
174930
175011
  import_title6 = __toESM3(require_lib17());
174931
- import_url20 = require("url");
175012
+ import_url19 = require("url");
174932
175013
  init_is_deploying();
174933
175014
  init_logs();
174934
175015
  init_error2();
@@ -175069,6 +175150,27 @@ var init_link3 = __esm({
175069
175150
  }
175070
175151
  });
175071
175152
 
175153
+ // src/util/parse-policy.ts
175154
+ function parsePolicy(policy) {
175155
+ if (!policy) {
175156
+ return {};
175157
+ }
175158
+ if (typeof policy === "string") {
175159
+ policy = [policy];
175160
+ }
175161
+ const parsed = {};
175162
+ for (const item of policy) {
175163
+ const [key, ...rest] = item.split("=");
175164
+ parsed[key] = rest.join("=");
175165
+ }
175166
+ return parsed;
175167
+ }
175168
+ var init_parse_policy = __esm({
175169
+ "src/util/parse-policy.ts"() {
175170
+ "use strict";
175171
+ }
175172
+ });
175173
+
175072
175174
  // src/commands/list/command.ts
175073
175175
  var listCommand;
175074
175176
  var init_command16 = __esm({
@@ -175094,6 +175196,14 @@ var init_command16 = __esm({
175094
175196
  type: [String],
175095
175197
  deprecated: false
175096
175198
  },
175199
+ {
175200
+ name: "policy",
175201
+ description: "See deployments with provided Deployment Retention policies (e.g.: `-p KEY=value`). Can appear many times.",
175202
+ argument: "KEY=value",
175203
+ shorthand: "p",
175204
+ type: [String],
175205
+ deprecated: false
175206
+ },
175097
175207
  {
175098
175208
  name: "environment",
175099
175209
  description: "",
@@ -175141,8 +175251,17 @@ __export3(list_exports, {
175141
175251
  getDeploymentDuration: () => getDeploymentDuration,
175142
175252
  stateString: () => stateString2
175143
175253
  });
175254
+ function toDate(timestamp) {
175255
+ const date = new Date(timestamp);
175256
+ const options = {
175257
+ year: "2-digit",
175258
+ month: "2-digit",
175259
+ day: "2-digit"
175260
+ };
175261
+ return date.toLocaleDateString("en-US", options);
175262
+ }
175144
175263
  async function list2(client2) {
175145
- const { cwd, output: output2, config: config3 } = client2;
175264
+ const { print, log: log2, warn, error: error3, note, debug: debug3, spinner } = client2.output;
175146
175265
  let parsedArgs = null;
175147
175266
  const flagsSpecification = getFlagsSpecification(listCommand.options);
175148
175267
  try {
@@ -175152,191 +175271,181 @@ async function list2(client2) {
175152
175271
  return 1;
175153
175272
  }
175154
175273
  if (parsedArgs.flags["--help"]) {
175155
- output2.print(help2(listCommand, { columns: client2.stderr.columns }));
175274
+ print(help2(listCommand, { columns: client2.stderr.columns }));
175156
175275
  return 2;
175157
175276
  }
175158
175277
  if ("--confirm" in parsedArgs.flags) {
175159
- output2.warn("`--confirm` is deprecated, please use `--yes` instead");
175278
+ warn("`--confirm` is deprecated, please use `--yes` instead");
175160
175279
  parsedArgs.flags["--yes"] = parsedArgs.flags["--confirm"];
175161
175280
  }
175162
- const { print, log: log2, error: error3, note, debug: debug3, spinner } = output2;
175163
175281
  if (parsedArgs.args.length > 2) {
175164
175282
  error3(`${getCommandName("ls [app]")} accepts at most one argument`);
175165
175283
  return 1;
175166
175284
  }
175167
175285
  const autoConfirm = !!parsedArgs.flags["--yes"];
175168
175286
  const meta = parseMeta(parsedArgs.flags["--meta"]);
175287
+ const policy = parsePolicy(parsedArgs.flags["--policy"]);
175169
175288
  const target = parseTarget({
175170
- output: output2,
175171
- targetFlagName: "environment",
175172
- targetFlagValue: parsedArgs.flags["--environment"],
175173
- prodFlagValue: parsedArgs.flags["--prod"]
175289
+ output: client2.output,
175290
+ flagName: "environment",
175291
+ flags: parsedArgs.flags
175174
175292
  });
175175
- let link4 = await getLinkedProject(client2, cwd);
175176
- if (link4.status === "error") {
175177
- return link4.exitCode;
175178
- }
175179
- let { org, project, status } = link4;
175180
- const appArg = parsedArgs.args[1];
175181
- let app = appArg || project?.name;
175182
- let host = void 0;
175183
- if (app && !isValidName(app)) {
175184
- error3(`The provided argument "${app}" is not a valid project name`);
175185
- return 1;
175186
- }
175187
- if (status === "not_linked" && !app) {
175188
- const linkedProject = await ensureLink("list", client2, cwd, {
175189
- autoConfirm,
175190
- link: link4
175191
- });
175192
- if (typeof linkedProject === "number") {
175193
- return linkedProject;
175194
- }
175195
- org = linkedProject.org;
175196
- project = linkedProject.project;
175197
- app = project.name;
175198
- }
175293
+ let project;
175294
+ let pagination;
175199
175295
  let contextName;
175200
- let team;
175201
- try {
175202
- ({ contextName, team } = await getScope(client2));
175203
- } catch (err) {
175204
- if ((0, import_error_utils26.isErrnoException)(err) && (err.code === "NOT_AUTHORIZED" || err.code === "TEAM_DELETED")) {
175205
- error3(err.message);
175296
+ let app = parsedArgs.args[1];
175297
+ let deployments = [];
175298
+ let singleDeployment = false;
175299
+ if (app) {
175300
+ if (!isValidName(app)) {
175301
+ error3(`The provided argument "${app}" is not a valid project name`);
175302
+ return 1;
175303
+ }
175304
+ if (app.includes(".")) {
175305
+ try {
175306
+ ({ contextName } = await getScope(client2));
175307
+ } catch (err) {
175308
+ if ((0, import_error_utils26.isErrnoException)(err) && (err.code === "NOT_AUTHORIZED" || err.code === "TEAM_DELETED")) {
175309
+ error3(err.message);
175310
+ return 1;
175311
+ }
175312
+ }
175313
+ if (!contextName) {
175314
+ error3("No context name found");
175315
+ return 1;
175316
+ }
175317
+ const host = toHost(app);
175318
+ const deployment = await getDeployment(client2, contextName, host);
175319
+ if (!deployment.projectId) {
175320
+ error3(`Could not find a deployment for "${host}"`);
175321
+ return 1;
175322
+ }
175323
+ app = deployment.projectId;
175324
+ note(
175325
+ `We suggest using ${getCommandName(
175326
+ "inspect <deployment>"
175327
+ )} for retrieving details about a single deployment`
175328
+ );
175329
+ deployments.push(deployment);
175330
+ singleDeployment = true;
175331
+ }
175332
+ project = await getProjectByNameOrId(client2, app);
175333
+ if (project instanceof ProjectNotFound) {
175334
+ error3(`The provided argument "${app}" is not a valid project name`);
175206
175335
  return 1;
175207
175336
  }
175208
- }
175209
- if (parsedArgs.flags["--scope"]) {
175210
- client2.config.currentTeam = team?.id || void 0;
175211
- if (team?.slug)
175212
- contextName = team.slug;
175213
175337
  } else {
175214
- client2.config.currentTeam = org?.type === "team" ? org.id : void 0;
175215
- if (org?.slug)
175216
- contextName = org.slug;
175338
+ const link4 = await ensureLink("list", client2, client2.cwd, {
175339
+ autoConfirm
175340
+ });
175341
+ if (typeof link4 === "number")
175342
+ return link4;
175343
+ project = link4.project;
175344
+ client2.config.currentTeam = link4.org.id;
175345
+ }
175346
+ if (!contextName) {
175347
+ try {
175348
+ ({ contextName } = await getScope(client2));
175349
+ } catch (err) {
175350
+ if ((0, import_error_utils26.isErrnoException)(err) && (err.code === "NOT_AUTHORIZED" || err.code === "TEAM_DELETED")) {
175351
+ error3(err.message);
175352
+ return 1;
175353
+ }
175354
+ }
175217
175355
  }
175218
- const { currentTeam } = config3;
175219
- ({ contextName } = await getScope(client2));
175220
175356
  const nextTimestamp = parsedArgs.flags["--next"];
175221
- if (typeof nextTimestamp !== void 0 && Number.isNaN(nextTimestamp)) {
175357
+ if (Number.isNaN(nextTimestamp)) {
175222
175358
  error3("Please provide a number for flag `--next`");
175223
175359
  return 1;
175224
175360
  }
175225
- spinner(`Fetching deployments in ${import_chalk90.default.bold(contextName)}`);
175226
- const now = new Now({
175227
- client: client2,
175228
- currentTeam
175361
+ const projectUrl = `https://vercel.com/${contextName}/${project.name}`;
175362
+ const projectSlugBold = import_chalk90.default.bold(`${contextName}/${project.name}`);
175363
+ const projectSlugLink = client2.output.link(projectSlugBold, projectUrl, {
175364
+ fallback: () => projectSlugBold,
175365
+ color: false
175229
175366
  });
175230
- const start = Date.now();
175231
- if (app && !isValidName(app)) {
175232
- error3(`The provided argument "${app}" is not a valid project name`);
175233
- return 1;
175234
- }
175235
- const asHost = app ? toHost(app) : "";
175236
- if (asHost.endsWith(".now.sh") || asHost.endsWith(".vercel.app")) {
175237
- note(
175238
- `We suggest using ${getCommandName(
175239
- "inspect <deployment>"
175240
- )} for retrieving details about a single deployment`
175241
- );
175242
- const hostParts = asHost.split("-");
175243
- if (hostParts.length < 2) {
175244
- error3("Only deployment hostnames are allowed, no aliases");
175245
- return 1;
175367
+ if (!singleDeployment) {
175368
+ spinner(`Fetching deployments in ${import_chalk90.default.bold(contextName)}`);
175369
+ const start = Date.now();
175370
+ debug3("Fetching deployments");
175371
+ const query = new URLSearchParams({ limit: "20", projectId: project.id });
175372
+ for (const [k, v] of Object.entries(meta)) {
175373
+ query.set(`meta-${k}`, v);
175246
175374
  }
175247
- app = void 0;
175248
- host = asHost;
175249
- }
175250
- debug3("Fetching deployments");
175251
- const response = await now.list(app, {
175252
- version: 6,
175253
- meta,
175254
- nextTimestamp,
175255
- target
175256
- });
175257
- let {
175258
- deployments,
175259
- pagination
175260
- } = response;
175261
- let showUsername = false;
175262
- for (const deployment of deployments) {
175263
- const username = deployment.creator?.username;
175264
- if (username !== contextName) {
175265
- showUsername = true;
175375
+ for (const [k, v] of Object.entries(policy)) {
175376
+ query.set(`policy-${k}`, v);
175266
175377
  }
175267
- }
175268
- if (app && !deployments.length) {
175269
- debug3(
175270
- "No deployments: attempting to find deployment that matches supplied app name"
175271
- );
175272
- let match;
175273
- try {
175274
- await now.findDeployment(app);
175275
- } catch (err) {
175276
- if (isAPIError(err) && err.status === 404) {
175277
- debug3("Ignore findDeployment 404");
175278
- } else {
175279
- throw err;
175378
+ if (nextTimestamp) {
175379
+ query.set("until", String(nextTimestamp));
175380
+ }
175381
+ if (target) {
175382
+ query.set("target", target);
175383
+ }
175384
+ for await (const chunk of client2.fetchPaginated(`/v6/deployments?${query}`)) {
175385
+ deployments.push(...chunk.deployments);
175386
+ pagination = chunk.pagination;
175387
+ if (deployments.length >= 20) {
175388
+ break;
175280
175389
  }
175281
175390
  }
175282
- if (match !== null && typeof match !== "undefined") {
175283
- debug3("Found deployment that matches app name");
175284
- deployments = Array.of(match);
175391
+ if (!deployments.length) {
175392
+ log2(`No deployments found.`);
175393
+ return 0;
175285
175394
  }
175395
+ log2(
175396
+ `${target === "production" ? `Production deployments` : `Deployments`} for ${projectSlugLink} ${elapsed(Date.now() - start)}`
175397
+ );
175286
175398
  }
175287
- now.close();
175288
- if (host) {
175289
- deployments = deployments.filter((deployment) => deployment.url === host);
175290
- }
175291
- if (!deployments.length) {
175292
- log2(`No deployments found.`);
175293
- return 0;
175294
- }
175295
- log2(
175296
- `${target === "production" ? `Production deployments` : `Deployments`} for ${import_chalk90.default.bold(app)} under ${import_chalk90.default.bold(contextName)} ${elapsed(
175297
- Date.now() - start
175298
- )}`
175299
- );
175300
- log2(
175301
- `To list deployments for a project, run ${getCommandName("ls [project]")}.`
175302
- );
175303
- print("\n");
175304
- const headers = ["Age", "Deployment", "Status", "Environment", "Duration"];
175305
- if (showUsername)
175306
- headers.push("Username");
175399
+ const headers = ["Age", "Deployment", "Status", "Environment"];
175400
+ const showPolicy = Object.keys(policy).length > 0;
175401
+ if (!showPolicy)
175402
+ headers.push("Duration", "Username");
175403
+ if (showPolicy)
175404
+ headers.push("Proposed Expiration");
175307
175405
  const urls = [];
175308
- client2.output.print(
175309
- `${table(
175310
- [
175311
- headers.map((header) => import_chalk90.default.bold(import_chalk90.default.cyan(header))),
175312
- ...deployments.sort(sortRecent()).map((dep) => {
175313
- urls.push(`https://${dep.url}`);
175314
- return [
175315
- import_chalk90.default.gray((0, import_ms18.default)(Date.now() - dep.createdAt)),
175316
- `https://${dep.url}`,
175317
- stateString2(dep.state || ""),
175318
- dep.target === "production" ? "Production" : "Preview",
175319
- import_chalk90.default.gray(getDeploymentDuration(dep)),
175320
- showUsername ? import_chalk90.default.gray(dep.creator?.username) : ""
175321
- ];
175322
- }).filter(
175323
- (app2) => (
175324
- // if an app wasn't supplied to filter by,
175325
- // we only want to render one deployment per app
175326
- app2 === null ? filterUniqueApps() : () => true
175327
- )
175406
+ const tablePrint = table(
175407
+ [
175408
+ headers.map((header) => import_chalk90.default.bold(import_chalk90.default.cyan(header))),
175409
+ ...deployments.sort(sortByCreatedAt).map((dep) => {
175410
+ urls.push(`https://${dep.url}`);
175411
+ const proposedExp = dep.proposedExpiration ? toDate(Math.min(Date.now(), dep.proposedExpiration)) : "No expiration";
175412
+ const createdAt = (0, import_ms18.default)(
175413
+ Date.now() - (dep?.undeletedAt ?? dep.createdAt)
175414
+ );
175415
+ const targetName = dep.customEnvironment?.name || (dep.target === "production" ? "Production" : "Preview");
175416
+ const targetSlug = dep.customEnvironment?.id || dep.target || "preview";
175417
+ return [
175418
+ import_chalk90.default.gray(createdAt),
175419
+ `https://${dep.url}`,
175420
+ stateString2(dep.readyState || ""),
175421
+ client2.output.link(
175422
+ targetName,
175423
+ `${projectUrl}/settings/environments/${targetSlug}`,
175424
+ { fallback: () => targetName, color: false }
175425
+ ),
175426
+ ...!showPolicy ? [import_chalk90.default.gray(getDeploymentDuration(dep))] : [],
175427
+ ...!showPolicy ? [import_chalk90.default.gray(dep.creator?.username)] : [],
175428
+ ...showPolicy ? [import_chalk90.default.gray(proposedExp)] : []
175429
+ ];
175430
+ }).filter(
175431
+ (app2) => (
175432
+ // if an app wasn't supplied to filter by,
175433
+ // we only want to render one deployment per app
175434
+ app2 === null ? filterUniqueApps() : () => true
175328
175435
  )
175329
- ],
175330
- { hsep: 5 }
175331
- ).replace(/^/gm, " ")}
175436
+ )
175437
+ ],
175438
+ { hsep: 5 }
175439
+ ).replace(/^/gm, " ");
175440
+ print(`
175441
+ ${tablePrint}
175332
175442
 
175333
- `
175334
- );
175443
+ `);
175335
175444
  if (!client2.stdout.isTTY) {
175336
175445
  client2.stdout.write(urls.join("\n"));
175337
175446
  client2.stdout.write("\n");
175338
175447
  }
175339
- if (pagination && pagination.count === 20) {
175448
+ if (pagination?.next) {
175340
175449
  const flags = getCommandFlags(parsedArgs.flags, ["--next"]);
175341
175450
  log2(
175342
175451
  `To display the next page, run ${getCommandName(
@@ -175376,10 +175485,8 @@ function stateString2(s) {
175376
175485
  return import_chalk90.default.gray("UNKNOWN");
175377
175486
  }
175378
175487
  }
175379
- function sortRecent() {
175380
- return function recencySort(a, b) {
175381
- return b.createdAt - a.createdAt;
175382
- };
175488
+ function sortByCreatedAt(a, b) {
175489
+ return b.createdAt - a.createdAt;
175383
175490
  }
175384
175491
  function filterUniqueApps() {
175385
175492
  const uniqueApps = /* @__PURE__ */ new Set();
@@ -175399,16 +175506,15 @@ var init_list2 = __esm({
175399
175506
  import_ms18 = __toESM3(require_ms2());
175400
175507
  init_table();
175401
175508
  import_title7 = __toESM3(require_lib17());
175402
- init_util();
175403
175509
  init_get_args();
175404
175510
  init_error2();
175405
175511
  init_elapsed();
175406
175512
  init_to_host();
175407
175513
  init_parse_meta();
175514
+ init_parse_policy();
175408
175515
  init_is_valid_name();
175409
175516
  init_get_command_flags();
175410
175517
  init_pkg_name();
175411
- init_link2();
175412
175518
  init_ensure_link();
175413
175519
  init_get_scope();
175414
175520
  init_errors_ts();
@@ -175417,6 +175523,8 @@ var init_list2 = __esm({
175417
175523
  init_command16();
175418
175524
  init_parse_target();
175419
175525
  init_get_flags_specification();
175526
+ init_get_deployment();
175527
+ init_get_project_by_id_or_name();
175420
175528
  }
175421
175529
  });
175422
175530
 
@@ -177001,7 +177109,7 @@ var init_remove_project = __esm({
177001
177109
  // src/util/deploy/get-deployments-by-project-id.ts
177002
177110
  async function getDeploymentsByProjectId(client2, projectId, options = { from: null, limit: 100, continue: false }, total = 0) {
177003
177111
  const limit = options.limit || 100;
177004
- const query = new import_url21.URLSearchParams();
177112
+ const query = new import_url20.URLSearchParams();
177005
177113
  query.set("projectId", projectId);
177006
177114
  query.set("limit", limit.toString());
177007
177115
  if (options.from) {
@@ -177056,11 +177164,11 @@ async function getDeploymentsByProjectId(client2, projectId, options = { from: n
177056
177164
  }
177057
177165
  return deployments;
177058
177166
  }
177059
- var import_url21;
177167
+ var import_url20;
177060
177168
  var init_get_deployments_by_project_id = __esm({
177061
177169
  "src/util/deploy/get-deployments-by-project-id.ts"() {
177062
177170
  "use strict";
177063
- import_url21 = require("url");
177171
+ import_url20 = require("url");
177064
177172
  }
177065
177173
  });
177066
177174
 
@@ -178788,7 +178896,7 @@ function spawnWorker(payload, output2) {
178788
178896
  }
178789
178897
 
178790
178898
  // src/index.ts
178791
- var import_url23 = require("url");
178899
+ var import_url22 = require("url");
178792
178900
  var Sentry = __toESM3(require_dist8());
178793
178901
  init_humanize_path();
178794
178902
 
@@ -179569,7 +179677,7 @@ var main13 = async () => {
179569
179677
  apiUrl = config3.api;
179570
179678
  }
179571
179679
  try {
179572
- new import_url23.URL(apiUrl);
179680
+ new import_url22.URL(apiUrl);
179573
179681
  } catch (err) {
179574
179682
  output.error(`Please provide a valid URL instead of ${highlight(apiUrl)}.`);
179575
179683
  return 1;