vercel 48.10.14 → 48.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +723 -624
  2. package/package.json +19 -17
package/dist/index.js CHANGED
@@ -5663,14 +5663,14 @@ var require_xdg_app_paths = __commonJS2({
5663
5663
  var require_ansi_escapes = __commonJS2({
5664
5664
  "../../node_modules/.pnpm/ansi-escapes@4.3.2/node_modules/ansi-escapes/index.js"(exports2, module2) {
5665
5665
  "use strict";
5666
- var ansiEscapes6 = module2.exports;
5667
- module2.exports.default = ansiEscapes6;
5666
+ var ansiEscapes7 = module2.exports;
5667
+ module2.exports.default = ansiEscapes7;
5668
5668
  var ESC = "\x1B[";
5669
5669
  var OSC = "\x1B]";
5670
5670
  var BEL = "\x07";
5671
5671
  var SEP = ";";
5672
5672
  var isTerminalApp = process.env.TERM_PROGRAM === "Apple_Terminal";
5673
- ansiEscapes6.cursorTo = (x, y) => {
5673
+ ansiEscapes7.cursorTo = (x, y) => {
5674
5674
  if (typeof x !== "number") {
5675
5675
  throw new TypeError("The `x` argument is required");
5676
5676
  }
@@ -5679,7 +5679,7 @@ var require_ansi_escapes = __commonJS2({
5679
5679
  }
5680
5680
  return ESC + (y + 1) + ";" + (x + 1) + "H";
5681
5681
  };
5682
- ansiEscapes6.cursorMove = (x, y) => {
5682
+ ansiEscapes7.cursorMove = (x, y) => {
5683
5683
  if (typeof x !== "number") {
5684
5684
  throw new TypeError("The `x` argument is required");
5685
5685
  }
@@ -5696,46 +5696,46 @@ var require_ansi_escapes = __commonJS2({
5696
5696
  }
5697
5697
  return ret;
5698
5698
  };
5699
- ansiEscapes6.cursorUp = (count = 1) => ESC + count + "A";
5700
- ansiEscapes6.cursorDown = (count = 1) => ESC + count + "B";
5701
- ansiEscapes6.cursorForward = (count = 1) => ESC + count + "C";
5702
- ansiEscapes6.cursorBackward = (count = 1) => ESC + count + "D";
5703
- ansiEscapes6.cursorLeft = ESC + "G";
5704
- ansiEscapes6.cursorSavePosition = isTerminalApp ? "\x1B7" : ESC + "s";
5705
- ansiEscapes6.cursorRestorePosition = isTerminalApp ? "\x1B8" : ESC + "u";
5706
- ansiEscapes6.cursorGetPosition = ESC + "6n";
5707
- ansiEscapes6.cursorNextLine = ESC + "E";
5708
- ansiEscapes6.cursorPrevLine = ESC + "F";
5709
- ansiEscapes6.cursorHide = ESC + "?25l";
5710
- ansiEscapes6.cursorShow = ESC + "?25h";
5711
- ansiEscapes6.eraseLines = (count) => {
5699
+ ansiEscapes7.cursorUp = (count = 1) => ESC + count + "A";
5700
+ ansiEscapes7.cursorDown = (count = 1) => ESC + count + "B";
5701
+ ansiEscapes7.cursorForward = (count = 1) => ESC + count + "C";
5702
+ ansiEscapes7.cursorBackward = (count = 1) => ESC + count + "D";
5703
+ ansiEscapes7.cursorLeft = ESC + "G";
5704
+ ansiEscapes7.cursorSavePosition = isTerminalApp ? "\x1B7" : ESC + "s";
5705
+ ansiEscapes7.cursorRestorePosition = isTerminalApp ? "\x1B8" : ESC + "u";
5706
+ ansiEscapes7.cursorGetPosition = ESC + "6n";
5707
+ ansiEscapes7.cursorNextLine = ESC + "E";
5708
+ ansiEscapes7.cursorPrevLine = ESC + "F";
5709
+ ansiEscapes7.cursorHide = ESC + "?25l";
5710
+ ansiEscapes7.cursorShow = ESC + "?25h";
5711
+ ansiEscapes7.eraseLines = (count) => {
5712
5712
  let clear = "";
5713
5713
  for (let i = 0; i < count; i++) {
5714
- clear += ansiEscapes6.eraseLine + (i < count - 1 ? ansiEscapes6.cursorUp() : "");
5714
+ clear += ansiEscapes7.eraseLine + (i < count - 1 ? ansiEscapes7.cursorUp() : "");
5715
5715
  }
5716
5716
  if (count) {
5717
- clear += ansiEscapes6.cursorLeft;
5717
+ clear += ansiEscapes7.cursorLeft;
5718
5718
  }
5719
5719
  return clear;
5720
5720
  };
5721
- ansiEscapes6.eraseEndLine = ESC + "K";
5722
- ansiEscapes6.eraseStartLine = ESC + "1K";
5723
- ansiEscapes6.eraseLine = ESC + "2K";
5724
- ansiEscapes6.eraseDown = ESC + "J";
5725
- ansiEscapes6.eraseUp = ESC + "1J";
5726
- ansiEscapes6.eraseScreen = ESC + "2J";
5727
- ansiEscapes6.scrollUp = ESC + "S";
5728
- ansiEscapes6.scrollDown = ESC + "T";
5729
- ansiEscapes6.clearScreen = "\x1Bc";
5730
- ansiEscapes6.clearTerminal = process.platform === "win32" ? `${ansiEscapes6.eraseScreen}${ESC}0f` : (
5721
+ ansiEscapes7.eraseEndLine = ESC + "K";
5722
+ ansiEscapes7.eraseStartLine = ESC + "1K";
5723
+ ansiEscapes7.eraseLine = ESC + "2K";
5724
+ ansiEscapes7.eraseDown = ESC + "J";
5725
+ ansiEscapes7.eraseUp = ESC + "1J";
5726
+ ansiEscapes7.eraseScreen = ESC + "2J";
5727
+ ansiEscapes7.scrollUp = ESC + "S";
5728
+ ansiEscapes7.scrollDown = ESC + "T";
5729
+ ansiEscapes7.clearScreen = "\x1Bc";
5730
+ ansiEscapes7.clearTerminal = process.platform === "win32" ? `${ansiEscapes7.eraseScreen}${ESC}0f` : (
5731
5731
  // 1. Erases the screen (Only done in case `2` is not supported)
5732
5732
  // 2. Erases the whole screen including scrollback buffer
5733
5733
  // 3. Moves cursor to the top-left position
5734
5734
  // More info: https://www.real-world-systems.com/docs/ANSIcode.html
5735
- `${ansiEscapes6.eraseScreen}${ESC}3J${ESC}H`
5735
+ `${ansiEscapes7.eraseScreen}${ESC}3J${ESC}H`
5736
5736
  );
5737
- ansiEscapes6.beep = BEL;
5738
- ansiEscapes6.link = (text, url3) => {
5737
+ ansiEscapes7.beep = BEL;
5738
+ ansiEscapes7.link = (text, url3) => {
5739
5739
  return [
5740
5740
  OSC,
5741
5741
  "8",
@@ -5751,7 +5751,7 @@ var require_ansi_escapes = __commonJS2({
5751
5751
  BEL
5752
5752
  ].join("");
5753
5753
  };
5754
- ansiEscapes6.image = (buffer, options = {}) => {
5754
+ ansiEscapes7.image = (buffer, options = {}) => {
5755
5755
  let ret = `${OSC}1337;File=inline=1`;
5756
5756
  if (options.width) {
5757
5757
  ret += `;width=${options.width}`;
@@ -5764,7 +5764,7 @@ var require_ansi_escapes = __commonJS2({
5764
5764
  }
5765
5765
  return ret + ":" + buffer.toString("base64") + BEL;
5766
5766
  };
5767
- ansiEscapes6.iTerm = {
5767
+ ansiEscapes7.iTerm = {
5768
5768
  setCwd: (cwd = process.cwd()) => `${OSC}50;CurrentDir=${cwd}${BEL}`,
5769
5769
  annotation: (message2, options = {}) => {
5770
5770
  let ret = `${OSC}1337;`;
@@ -38434,22 +38434,79 @@ var init_esm7 = __esm({
38434
38434
  }
38435
38435
  });
38436
38436
 
38437
+ // ../../node_modules/.pnpm/@inquirer+password@2.1.2/node_modules/@inquirer/password/dist/esm/index.mjs
38438
+ var import_ansi_escapes4, esm_default6;
38439
+ var init_esm8 = __esm({
38440
+ "../../node_modules/.pnpm/@inquirer+password@2.1.2/node_modules/@inquirer/password/dist/esm/index.mjs"() {
38441
+ init_esm3();
38442
+ import_ansi_escapes4 = __toESM3(require_ansi_escapes(), 1);
38443
+ esm_default6 = createPrompt((config2, done) => {
38444
+ const { validate: validate2 = () => true } = config2;
38445
+ const theme = makeTheme(config2.theme);
38446
+ const [status3, setStatus] = useState("pending");
38447
+ const [errorMsg, setError] = useState(void 0);
38448
+ const [value, setValue] = useState("");
38449
+ const isLoading = status3 === "loading";
38450
+ const prefix = usePrefix({ isLoading, theme });
38451
+ useKeypress(async (key, rl) => {
38452
+ if (status3 !== "pending") {
38453
+ return;
38454
+ }
38455
+ if (isEnterKey(key)) {
38456
+ const answer = value;
38457
+ setStatus("loading");
38458
+ const isValid = await validate2(answer);
38459
+ if (isValid === true) {
38460
+ setValue(answer);
38461
+ setStatus("done");
38462
+ done(answer);
38463
+ } else {
38464
+ rl.write(value);
38465
+ setError(isValid || "You must provide a valid value");
38466
+ setStatus("pending");
38467
+ }
38468
+ } else {
38469
+ setValue(rl.line);
38470
+ setError(void 0);
38471
+ }
38472
+ });
38473
+ const message2 = theme.style.message(config2.message);
38474
+ let formattedValue = "";
38475
+ let helpTip;
38476
+ if (config2.mask) {
38477
+ const maskChar = typeof config2.mask === "string" ? config2.mask : "*";
38478
+ formattedValue = maskChar.repeat(value.length);
38479
+ } else if (status3 !== "done") {
38480
+ helpTip = `${theme.style.help("[input is masked]")}${import_ansi_escapes4.default.cursorHide}`;
38481
+ }
38482
+ if (status3 === "done") {
38483
+ formattedValue = theme.style.answer(formattedValue);
38484
+ }
38485
+ let error3 = "";
38486
+ if (errorMsg) {
38487
+ error3 = theme.style.error(errorMsg);
38488
+ }
38489
+ return [[prefix, message2, formattedValue, helpTip].filter(Boolean).join(" "), error3];
38490
+ });
38491
+ }
38492
+ });
38493
+
38437
38494
  // ../../node_modules/.pnpm/@inquirer+select@2.2.2/node_modules/@inquirer/select/dist/esm/index.mjs
38438
38495
  function isSelectable2(item) {
38439
38496
  return !Separator.isSeparator(item) && !item.disabled;
38440
38497
  }
38441
- var import_chalk13, import_figures3, import_ansi_escapes4, selectTheme, esm_default6;
38442
- var init_esm8 = __esm({
38498
+ var import_chalk13, import_figures3, import_ansi_escapes5, selectTheme, esm_default7;
38499
+ var init_esm9 = __esm({
38443
38500
  "../../node_modules/.pnpm/@inquirer+select@2.2.2/node_modules/@inquirer/select/dist/esm/index.mjs"() {
38444
38501
  init_esm3();
38445
38502
  import_chalk13 = __toESM3(require_source2(), 1);
38446
38503
  import_figures3 = __toESM3(require_figures(), 1);
38447
- import_ansi_escapes4 = __toESM3(require_ansi_escapes(), 1);
38504
+ import_ansi_escapes5 = __toESM3(require_ansi_escapes(), 1);
38448
38505
  selectTheme = {
38449
38506
  icon: { cursor: import_figures3.default.pointer },
38450
38507
  style: { disabled: (text) => import_chalk13.default.dim(`- ${text}`) }
38451
38508
  };
38452
- esm_default6 = createPrompt((config2, done) => {
38509
+ esm_default7 = createPrompt((config2, done) => {
38453
38510
  const { choices: items, loop = true, pageSize = 7 } = config2;
38454
38511
  const firstRender = useRef(true);
38455
38512
  const theme = makeTheme(selectTheme, config2.theme);
@@ -38543,7 +38600,7 @@ var init_esm8 = __esm({
38543
38600
  const choiceDescription = selectedChoice.description ? `
38544
38601
  ${selectedChoice.description}` : ``;
38545
38602
  return `${[prefix, message2, helpTip].filter(Boolean).join(" ")}
38546
- ${page}${choiceDescription}${import_ansi_escapes4.default.cursorHide}`;
38603
+ ${page}${choiceDescription}${import_ansi_escapes5.default.cursorHide}`;
38547
38604
  });
38548
38605
  }
38549
38606
  });
@@ -44894,7 +44951,7 @@ async function login(client2, telemetry2) {
44894
44951
  `,
44895
44952
  () => {
44896
44953
  open.default(verification_uri_complete);
44897
- output_manager_default.print((0, import_ansi_escapes5.eraseLines)(2));
44954
+ output_manager_default.print((0, import_ansi_escapes6.eraseLines)(2));
44898
44955
  output_manager_default.spinner("Waiting for authentication...");
44899
44956
  rl.close();
44900
44957
  rlClosed = true;
@@ -44943,7 +45000,7 @@ async function login(client2, telemetry2) {
44943
45000
  if (tokensError)
44944
45001
  return tokensError;
44945
45002
  error3 = void 0;
44946
- output_manager_default.print((0, import_ansi_escapes5.eraseLines)(2));
45003
+ output_manager_default.print((0, import_ansi_escapes6.eraseLines)(2));
44947
45004
  const isInitialLogin = !client2.authConfig.token;
44948
45005
  client2.updateAuthConfig({
44949
45006
  token: tokens.access_token,
@@ -44984,14 +45041,14 @@ async function login(client2, telemetry2) {
44984
45041
  async function wait2(intervalMs) {
44985
45042
  await new Promise((resolve13) => setTimeout(resolve13, intervalMs));
44986
45043
  }
44987
- var import_node_readline, import_chalk17, open, import_ansi_escapes5;
45044
+ var import_node_readline, import_chalk17, open, import_ansi_escapes6;
44988
45045
  var init_future = __esm({
44989
45046
  "src/commands/login/future.ts"() {
44990
45047
  "use strict";
44991
45048
  import_node_readline = __toESM3(require("readline"));
44992
45049
  import_chalk17 = __toESM3(require_source());
44993
45050
  open = __toESM3(require_open());
44994
- import_ansi_escapes5 = __toESM3(require_ansi_escapes());
45051
+ import_ansi_escapes6 = __toESM3(require_ansi_escapes());
44995
45052
  init_error2();
44996
45053
  init_update_current_team_after_login();
44997
45054
  init_global_path();
@@ -49731,7 +49788,7 @@ var require_package = __commonJS2({
49731
49788
  "../client/package.json"(exports2, module2) {
49732
49789
  module2.exports = {
49733
49790
  name: "@vercel/client",
49734
- version: "17.2.11",
49791
+ version: "17.2.12",
49735
49792
  main: "dist/index.js",
49736
49793
  typings: "dist/index.d.ts",
49737
49794
  homepage: "https://vercel.com",
@@ -49770,7 +49827,7 @@ var require_package = __commonJS2({
49770
49827
  vitest: "2.0.1"
49771
49828
  },
49772
49829
  dependencies: {
49773
- "@vercel/build-utils": "13.2.0",
49830
+ "@vercel/build-utils": "13.2.1",
49774
49831
  "@vercel/error-utils": "2.0.3",
49775
49832
  "@vercel/microfrontends": "1.2.2",
49776
49833
  "@vercel/routing-utils": "5.3.0",
@@ -63904,6 +63961,7 @@ var init_client = __esm({
63904
63961
  init_esm6();
63905
63962
  init_esm7();
63906
63963
  init_esm8();
63964
+ init_esm9();
63907
63965
  import_events = require("events");
63908
63966
  import_url5 = require("url");
63909
63967
  import_async_retry = __toESM3(require_dist5());
@@ -63963,6 +64021,10 @@ ${error3.stack}`);
63963
64021
  };
63964
64022
  this.input = {
63965
64023
  text: (opts2) => esm_default5({ theme, ...opts2 }, { input: this.stdin, output: this.stderr }),
64024
+ password: (opts2) => esm_default6(
64025
+ { theme, ...opts2 },
64026
+ { input: this.stdin, output: this.stderr }
64027
+ ),
63966
64028
  checkbox: (opts2) => esm_default2(
63967
64029
  { theme, ...opts2 },
63968
64030
  { input: this.stdin, output: this.stderr }
@@ -63972,7 +64034,7 @@ ${error3.stack}`);
63972
64034
  { theme, message: message2, default: default_value },
63973
64035
  { input: this.stdin, output: this.stderr }
63974
64036
  ),
63975
- select: (opts2) => esm_default6(
64037
+ select: (opts2) => esm_default7(
63976
64038
  { theme, ...opts2 },
63977
64039
  { input: this.stdin, output: this.stderr }
63978
64040
  )
@@ -121079,7 +121141,8 @@ var require_detect_builders = __commonJS2({
121079
121141
  { src: "api/**/*.+(js|mjs|ts|tsx)", use: `@vercel/node`, config: config2 },
121080
121142
  { src: "api/**/!(*_test).go", use: `@vercel/go`, config: config2 },
121081
121143
  { src: "api/**/*.py", use: `@vercel/python`, config: config2 },
121082
- { src: "api/**/*.rb", use: `@vercel/ruby`, config: config2 }
121144
+ { src: "api/**/*.rb", use: `@vercel/ruby`, config: config2 },
121145
+ { src: "api/**/*.rs", use: `@vercel/rust`, config: config2 }
121083
121146
  ];
121084
121147
  }
121085
121148
  function hasBuildScript(pkg) {
@@ -128741,7 +128804,7 @@ var import_strip_ansi3;
128741
128804
  var init_list4 = __esm({
128742
128805
  "src/util/input/list.ts"() {
128743
128806
  "use strict";
128744
- init_esm8();
128807
+ init_esm9();
128745
128808
  import_strip_ansi3 = __toESM3(require_strip_ansi2());
128746
128809
  init_erase_lines();
128747
128810
  }
@@ -129319,6 +129382,424 @@ var init_repo = __esm({
129319
129382
  }
129320
129383
  });
129321
129384
 
129385
+ // src/util/env/get-env-records.ts
129386
+ async function getEnvRecords(client2, projectId, source, {
129387
+ target,
129388
+ gitBranch,
129389
+ decrypt
129390
+ } = {}) {
129391
+ output_manager_default.debug(
129392
+ `Fetching Environment Variables of project ${projectId} and target ${target}`
129393
+ );
129394
+ const query = new import_url8.URLSearchParams();
129395
+ if (target) {
129396
+ let targetParam = "target";
129397
+ if (target !== "production" && target !== "preview" && target !== "development") {
129398
+ targetParam = "customEnvironmentId";
129399
+ }
129400
+ query.set(targetParam, target);
129401
+ }
129402
+ if (gitBranch) {
129403
+ query.set("gitBranch", gitBranch);
129404
+ }
129405
+ if (decrypt) {
129406
+ query.set("decrypt", decrypt.toString());
129407
+ }
129408
+ if (source) {
129409
+ query.set("source", source);
129410
+ }
129411
+ const url3 = `/v10/projects/${projectId}/env?${query}`;
129412
+ return client2.fetch(url3);
129413
+ }
129414
+ async function pullEnvRecords(client2, projectId, source, { target, gitBranch } = {}) {
129415
+ output_manager_default.debug(
129416
+ `Fetching Environment Variables of project ${projectId} and target ${target}`
129417
+ );
129418
+ const query = new import_url8.URLSearchParams();
129419
+ let url3 = `/v3/env/pull/${projectId}`;
129420
+ if (target) {
129421
+ url3 += `/${encodeURIComponent(target)}`;
129422
+ if (gitBranch) {
129423
+ url3 += `/${encodeURIComponent(gitBranch)}`;
129424
+ }
129425
+ }
129426
+ if (source) {
129427
+ query.set("source", source);
129428
+ }
129429
+ if (Array.from(query).length > 0) {
129430
+ url3 += `?${query}`;
129431
+ }
129432
+ return client2.fetch(url3);
129433
+ }
129434
+ var import_url8;
129435
+ var init_get_env_records = __esm({
129436
+ "src/util/env/get-env-records.ts"() {
129437
+ "use strict";
129438
+ import_url8 = require("url");
129439
+ init_output_manager();
129440
+ }
129441
+ });
129442
+
129443
+ // src/util/parse-env.ts
129444
+ var parseEnv;
129445
+ var init_parse_env = __esm({
129446
+ "src/util/parse-env.ts"() {
129447
+ "use strict";
129448
+ parseEnv = (env) => {
129449
+ if (!env) {
129450
+ return {};
129451
+ }
129452
+ if (typeof env === "string") {
129453
+ env = [env];
129454
+ }
129455
+ if (Array.isArray(env)) {
129456
+ const startingDict = {};
129457
+ return env.reduce((o, e2) => {
129458
+ let key;
129459
+ let value;
129460
+ const equalsSign = e2.indexOf("=");
129461
+ if (equalsSign === -1) {
129462
+ key = e2;
129463
+ } else {
129464
+ key = e2.slice(0, equalsSign);
129465
+ value = e2.slice(equalsSign + 1);
129466
+ }
129467
+ o[key] = value;
129468
+ return o;
129469
+ }, startingDict);
129470
+ }
129471
+ return env;
129472
+ };
129473
+ }
129474
+ });
129475
+
129476
+ // src/util/env/diff-env-files.ts
129477
+ async function createEnvObject(envPath) {
129478
+ const envArr = (await (0, import_fs_extra7.readFile)(envPath, "utf-8")).replace(/"/g, "").split(/\r?\n|\r/).filter((line) => /^[^#]/.test(line)).filter((line) => /=/i.test(line));
129479
+ const parsedEnv = parseEnv(envArr);
129480
+ if (Object.keys(parsedEnv).length === 0) {
129481
+ output_manager_default.debug("Failed to parse env file.");
129482
+ return;
129483
+ }
129484
+ return parsedEnv;
129485
+ }
129486
+ function findChanges(oldEnv, newEnv) {
129487
+ const added = [];
129488
+ const changed = [];
129489
+ for (const key of Object.keys(newEnv)) {
129490
+ if (oldEnv[key] === void 0) {
129491
+ added.push(key);
129492
+ } else if (oldEnv[key] !== newEnv[key]) {
129493
+ changed.push(key);
129494
+ }
129495
+ delete oldEnv[key];
129496
+ }
129497
+ const removed = Object.keys(oldEnv);
129498
+ return {
129499
+ added,
129500
+ changed,
129501
+ removed
129502
+ };
129503
+ }
129504
+ function buildDeltaString(oldEnv, newEnv) {
129505
+ const { added, changed, removed } = findChanges(oldEnv, newEnv);
129506
+ let deltaString = "";
129507
+ deltaString += import_chalk41.default.green(addDeltaSection("+", changed, true));
129508
+ deltaString += import_chalk41.default.green(addDeltaSection("+", added));
129509
+ deltaString += import_chalk41.default.red(addDeltaSection("-", removed));
129510
+ return deltaString ? import_chalk41.default.gray("Changes:\n") + deltaString + "\n" : deltaString;
129511
+ }
129512
+ function addDeltaSection(prefix, arr, changed = false) {
129513
+ if (arr.length === 0)
129514
+ return "";
129515
+ return arr.sort().map((item) => `${prefix} ${item}${changed ? " (Updated)" : ""}`).join("\n") + "\n";
129516
+ }
129517
+ var import_fs_extra7, import_chalk41;
129518
+ var init_diff_env_files = __esm({
129519
+ "src/util/env/diff-env-files.ts"() {
129520
+ "use strict";
129521
+ import_fs_extra7 = __toESM3(require_lib());
129522
+ init_parse_env();
129523
+ import_chalk41 = __toESM3(require_source());
129524
+ init_output_manager();
129525
+ }
129526
+ });
129527
+
129528
+ // src/util/projects/format-project.ts
129529
+ function formatProject(orgSlug, projectSlug, options) {
129530
+ const orgProjectSlug = `${orgSlug}/${projectSlug}`;
129531
+ const projectUrl = `https://vercel.com/${orgProjectSlug}`;
129532
+ const projectSlugLink = output_manager_default.link(import_chalk42.default.bold(orgProjectSlug), projectUrl, {
129533
+ fallback: () => import_chalk42.default.bold(orgProjectSlug),
129534
+ color: false,
129535
+ ...options
129536
+ });
129537
+ return projectSlugLink;
129538
+ }
129539
+ var import_chalk42;
129540
+ var init_format_project = __esm({
129541
+ "src/util/projects/format-project.ts"() {
129542
+ "use strict";
129543
+ import_chalk42 = __toESM3(require_source());
129544
+ init_output_manager();
129545
+ }
129546
+ });
129547
+
129548
+ // src/util/target/standard-environments.ts
129549
+ var STANDARD_ENVIRONMENTS;
129550
+ var init_standard_environments = __esm({
129551
+ "src/util/target/standard-environments.ts"() {
129552
+ "use strict";
129553
+ STANDARD_ENVIRONMENTS = [
129554
+ "production",
129555
+ "preview",
129556
+ "development"
129557
+ ];
129558
+ }
129559
+ });
129560
+
129561
+ // src/util/telemetry/commands/env/pull.ts
129562
+ var EnvPullTelemetryClient;
129563
+ var init_pull = __esm({
129564
+ "src/util/telemetry/commands/env/pull.ts"() {
129565
+ "use strict";
129566
+ init_telemetry();
129567
+ init_standard_environments();
129568
+ EnvPullTelemetryClient = class extends TelemetryClient {
129569
+ trackCliArgumentFilename(filename) {
129570
+ if (filename) {
129571
+ this.trackCliArgument({
129572
+ arg: "filename",
129573
+ value: this.redactedValue
129574
+ });
129575
+ }
129576
+ }
129577
+ trackCliOptionEnvironment(environment) {
129578
+ if (environment) {
129579
+ this.trackCliOption({
129580
+ option: "environment",
129581
+ value: STANDARD_ENVIRONMENTS.includes(
129582
+ environment
129583
+ ) ? environment : this.redactedValue
129584
+ });
129585
+ }
129586
+ }
129587
+ trackCliOptionGitBranch(gitBranch) {
129588
+ if (gitBranch) {
129589
+ this.trackCliOption({
129590
+ option: "git-branch",
129591
+ value: this.redactedValue
129592
+ });
129593
+ }
129594
+ }
129595
+ trackCliFlagYes(yes) {
129596
+ if (yes) {
129597
+ this.trackCliFlag("yes");
129598
+ }
129599
+ }
129600
+ };
129601
+ }
129602
+ });
129603
+
129604
+ // src/util/parse-target.ts
129605
+ function parseTarget({
129606
+ flagName,
129607
+ flags
129608
+ }) {
129609
+ const targetFlagName = `--${flagName}`;
129610
+ const targetFlagValue = flags[targetFlagName];
129611
+ const prodFlagValue = flags["--prod"];
129612
+ if (prodFlagValue && targetFlagValue) {
129613
+ output_manager_default.warn(
129614
+ `Both \`--prod\` and \`${targetFlagName}\` detected. Ignoring \`--prod\`.`
129615
+ );
129616
+ }
129617
+ if (typeof targetFlagValue === "string") {
129618
+ output_manager_default.debug(`Setting target to ${targetFlagValue}`);
129619
+ return targetFlagValue;
129620
+ }
129621
+ if (prodFlagValue) {
129622
+ output_manager_default.debug("Setting target to production");
129623
+ return "production";
129624
+ }
129625
+ return void 0;
129626
+ }
129627
+ var init_parse_target = __esm({
129628
+ "src/util/parse-target.ts"() {
129629
+ "use strict";
129630
+ init_output_manager();
129631
+ }
129632
+ });
129633
+
129634
+ // src/commands/env/pull.ts
129635
+ function readHeadSync(path11, length) {
129636
+ const buffer = Buffer.alloc(length);
129637
+ const fd = (0, import_fs4.openSync)(path11, "r");
129638
+ try {
129639
+ (0, import_fs4.readSync)(fd, buffer, 0, buffer.length, null);
129640
+ } finally {
129641
+ (0, import_fs4.closeSync)(fd);
129642
+ }
129643
+ return buffer.toString();
129644
+ }
129645
+ function tryReadHeadSync(path11, length) {
129646
+ try {
129647
+ return readHeadSync(path11, length);
129648
+ } catch (err) {
129649
+ if (!(0, import_error_utils12.isErrnoException)(err) || err.code !== "ENOENT") {
129650
+ throw err;
129651
+ }
129652
+ }
129653
+ }
129654
+ async function pull(client2, argv, source = "vercel-cli:env:pull") {
129655
+ const telemetryClient = new EnvPullTelemetryClient({
129656
+ opts: {
129657
+ store: client2.telemetryEventStore
129658
+ }
129659
+ });
129660
+ let parsedArgs;
129661
+ const flagsSpecification = getFlagsSpecification(pullSubcommand.options);
129662
+ try {
129663
+ parsedArgs = parseArguments(argv, flagsSpecification);
129664
+ } catch (err) {
129665
+ printError(err);
129666
+ return 1;
129667
+ }
129668
+ const { args: args2, flags: opts } = parsedArgs;
129669
+ if (args2.length > 1) {
129670
+ output_manager_default.error(
129671
+ `Invalid number of arguments. Usage: ${getCommandName(`env pull <file>`)}`
129672
+ );
129673
+ return 1;
129674
+ }
129675
+ const [rawFilename] = args2;
129676
+ const filename = rawFilename || ".env.local";
129677
+ const skipConfirmation = opts["--yes"];
129678
+ const gitBranch = opts["--git-branch"];
129679
+ telemetryClient.trackCliArgumentFilename(args2[0]);
129680
+ telemetryClient.trackCliFlagYes(skipConfirmation);
129681
+ telemetryClient.trackCliOptionGitBranch(gitBranch);
129682
+ telemetryClient.trackCliOptionEnvironment(opts["--environment"]);
129683
+ const link4 = await getLinkedProject(client2);
129684
+ if (link4.status === "error") {
129685
+ return link4.exitCode;
129686
+ } else if (link4.status === "not_linked") {
129687
+ output_manager_default.error(
129688
+ `Your codebase isn\u2019t linked to a project on Vercel. Run ${getCommandName(
129689
+ "link"
129690
+ )} to begin.`
129691
+ );
129692
+ return 1;
129693
+ }
129694
+ client2.config.currentTeam = link4.org.type === "team" ? link4.org.id : void 0;
129695
+ const environment = parseTarget({
129696
+ flagName: "environment",
129697
+ flags: opts
129698
+ }) || "development";
129699
+ await envPullCommandLogic(
129700
+ client2,
129701
+ filename,
129702
+ !!skipConfirmation,
129703
+ environment,
129704
+ link4,
129705
+ gitBranch,
129706
+ client2.cwd,
129707
+ source
129708
+ );
129709
+ return 0;
129710
+ }
129711
+ async function envPullCommandLogic(client2, filename, skipConfirmation, environment, link4, gitBranch, cwd, source) {
129712
+ const fullPath = (0, import_path15.resolve)(cwd, filename);
129713
+ const head = tryReadHeadSync(fullPath, Buffer.byteLength(CONTENTS_PREFIX));
129714
+ const exists = typeof head !== "undefined";
129715
+ if (head === CONTENTS_PREFIX) {
129716
+ output_manager_default.log(`Overwriting existing ${import_chalk43.default.bold(filename)} file`);
129717
+ } else if (exists && !skipConfirmation && !await client2.input.confirm(
129718
+ `Found existing file ${param(filename)}. Do you want to overwrite?`,
129719
+ false
129720
+ )) {
129721
+ output_manager_default.log("Canceled");
129722
+ return;
129723
+ }
129724
+ const projectSlugLink = formatProject(link4.org.slug, link4.project.name);
129725
+ output_manager_default.log(
129726
+ `Downloading \`${import_chalk43.default.cyan(
129727
+ environment
129728
+ )}\` Environment Variables for ${projectSlugLink}`
129729
+ );
129730
+ const pullStamp = stamp_default();
129731
+ output_manager_default.spinner("Downloading");
129732
+ const records = (await pullEnvRecords(client2, link4.project.id, source, {
129733
+ target: environment || "development",
129734
+ gitBranch
129735
+ })).env;
129736
+ let deltaString = "";
129737
+ let oldEnv;
129738
+ if (exists) {
129739
+ oldEnv = await createEnvObject(fullPath);
129740
+ if (oldEnv) {
129741
+ const newEnv = (0, import_json_parse_better_errors2.default)(JSON.stringify(records).replace(/\\"/g, ""));
129742
+ deltaString = buildDeltaString(oldEnv, newEnv);
129743
+ }
129744
+ }
129745
+ const contents = CONTENTS_PREFIX + Object.keys(records).sort().filter((key) => !VARIABLES_TO_IGNORE.includes(key)).map((key) => `${key}="${escapeValue(records[key])}"`).join("\n") + "\n";
129746
+ await (0, import_fs_extra8.outputFile)(fullPath, contents, "utf8");
129747
+ if (deltaString) {
129748
+ output_manager_default.print("\n" + deltaString);
129749
+ } else if (oldEnv && exists) {
129750
+ output_manager_default.log("No changes found.");
129751
+ }
129752
+ let isGitIgnoreUpdated = false;
129753
+ if (filename === ".env.local") {
129754
+ const rootPath = link4.repoRoot ?? cwd;
129755
+ isGitIgnoreUpdated = await addToGitIgnore(rootPath, ".env*.local");
129756
+ }
129757
+ output_manager_default.print(
129758
+ `${prependEmoji(
129759
+ `${exists ? "Updated" : "Created"} ${import_chalk43.default.bold(filename)} file ${isGitIgnoreUpdated ? "and added it to .gitignore" : ""} ${import_chalk43.default.gray(pullStamp())}`,
129760
+ emoji("success")
129761
+ )}
129762
+ `
129763
+ );
129764
+ }
129765
+ function escapeValue(value) {
129766
+ return value ? value.replace(new RegExp("\n", "g"), "\\n").replace(new RegExp("\r", "g"), "\\r") : "";
129767
+ }
129768
+ var import_chalk43, import_fs_extra8, import_fs4, import_path15, import_error_utils12, import_json_parse_better_errors2, CONTENTS_PREFIX, VARIABLES_TO_IGNORE;
129769
+ var init_pull2 = __esm({
129770
+ "src/commands/env/pull.ts"() {
129771
+ "use strict";
129772
+ import_chalk43 = __toESM3(require_source());
129773
+ import_fs_extra8 = __toESM3(require_lib());
129774
+ import_fs4 = require("fs");
129775
+ import_path15 = require("path");
129776
+ init_emoji();
129777
+ init_param();
129778
+ init_stamp();
129779
+ init_pkg_name();
129780
+ init_get_env_records();
129781
+ init_diff_env_files();
129782
+ import_error_utils12 = __toESM3(require_dist2());
129783
+ init_add_to_gitignore();
129784
+ import_json_parse_better_errors2 = __toESM3(require_json_parse_better_errors());
129785
+ init_format_project();
129786
+ init_output_manager();
129787
+ init_pull();
129788
+ init_command11();
129789
+ init_get_args();
129790
+ init_get_flags_specification();
129791
+ init_error2();
129792
+ init_parse_target();
129793
+ init_link2();
129794
+ CONTENTS_PREFIX = "# Created by Vercel CLI\n";
129795
+ VARIABLES_TO_IGNORE = [
129796
+ "VERCEL_ANALYTICS_ID",
129797
+ "VERCEL_SPEED_INSIGHTS_ID",
129798
+ "VERCEL_WEB_ANALYTICS_ID"
129799
+ ];
129800
+ }
129801
+ });
129802
+
129322
129803
  // src/util/projects/link.ts
129323
129804
  var link_exports = {};
129324
129805
  __export3(link_exports, {
@@ -129335,7 +129816,7 @@ __export3(link_exports, {
129335
129816
  writeReadme: () => writeReadme
129336
129817
  });
129337
129818
  function getVercelDirectory(cwd) {
129338
- const possibleDirs = [(0, import_path15.join)(cwd, VERCEL_DIR2), (0, import_path15.join)(cwd, VERCEL_DIR_FALLBACK)];
129819
+ const possibleDirs = [(0, import_path16.join)(cwd, VERCEL_DIR2), (0, import_path16.join)(cwd, VERCEL_DIR_FALLBACK)];
129339
129820
  const existingDirs = possibleDirs.filter((d) => isDirectory(d));
129340
129821
  if (existingDirs.length > 1) {
129341
129822
  throw new import_build_utils6.NowBuildError({
@@ -129356,7 +129837,7 @@ async function getProjectLinkFromRepoLink(client2, path11) {
129356
129837
  }
129357
129838
  const projects = findProjectsFromPath(
129358
129839
  repoLink.repoConfig.projects,
129359
- (0, import_path15.relative)(repoLink.rootPath, path11)
129840
+ (0, import_path16.relative)(repoLink.rootPath, path11)
129360
129841
  );
129361
129842
  let project;
129362
129843
  if (projects.length === 1) {
@@ -129383,7 +129864,7 @@ async function getProjectLinkFromRepoLink(client2, path11) {
129383
129864
  }
129384
129865
  async function getLinkFromDir(dir) {
129385
129866
  try {
129386
- const json = await readFile3((0, import_path15.join)(dir, VERCEL_DIR_PROJECT), "utf8");
129867
+ const json = await readFile4((0, import_path16.join)(dir, VERCEL_DIR_PROJECT), "utf8");
129387
129868
  const ajv2 = new import_ajv.default();
129388
129869
  const link4 = JSON.parse(json);
129389
129870
  if (!ajv2.validate(linkSchema, link4)) {
@@ -129393,10 +129874,10 @@ async function getLinkFromDir(dir) {
129393
129874
  }
129394
129875
  return link4;
129395
129876
  } catch (err) {
129396
- if ((0, import_error_utils12.isErrnoException)(err) && err.code && ["ENOENT", "ENOTDIR"].includes(err.code)) {
129877
+ if ((0, import_error_utils13.isErrnoException)(err) && err.code && ["ENOENT", "ENOTDIR"].includes(err.code)) {
129397
129878
  return null;
129398
129879
  }
129399
- if ((0, import_error_utils12.isError)(err) && err.name === "SyntaxError") {
129880
+ if ((0, import_error_utils13.isError)(err) && err.name === "SyntaxError") {
129400
129881
  throw new Error(
129401
129882
  `Project Settings could not be retrieved. To link your project again, remove the ${dir} directory.`
129402
129883
  );
@@ -129497,24 +129978,24 @@ async function getLinkedProject(client2, path11 = client2.cwd) {
129497
129978
  }
129498
129979
  async function writeReadme(path11) {
129499
129980
  await writeFile2(
129500
- (0, import_path15.join)(path11, VERCEL_DIR2, VERCEL_DIR_README),
129501
- await readFile3((0, import_path15.join)(__dirname, "VERCEL_DIR_README.txt"), "utf8")
129981
+ (0, import_path16.join)(path11, VERCEL_DIR2, VERCEL_DIR_README),
129982
+ await readFile4((0, import_path16.join)(__dirname, "VERCEL_DIR_README.txt"), "utf8")
129502
129983
  );
129503
129984
  }
129504
- async function linkFolderToProject(client2, path11, projectLink, projectName, orgSlug, successEmoji = "link") {
129985
+ async function linkFolderToProject(client2, path11, projectLink, projectName, orgSlug, successEmoji = "link", autoConfirm = false) {
129505
129986
  if (await hasProjectLink(client2, projectLink, path11)) {
129506
129987
  return;
129507
129988
  }
129508
129989
  try {
129509
- await (0, import_fs_extra7.ensureDir)((0, import_path15.join)(path11, VERCEL_DIR2));
129990
+ await (0, import_fs_extra9.ensureDir)((0, import_path16.join)(path11, VERCEL_DIR2));
129510
129991
  } catch (err) {
129511
- if ((0, import_error_utils12.isErrnoException)(err) && err.code === "ENOTDIR") {
129992
+ if ((0, import_error_utils13.isErrnoException)(err) && err.code === "ENOTDIR") {
129512
129993
  return;
129513
129994
  }
129514
129995
  throw err;
129515
129996
  }
129516
129997
  await writeFile2(
129517
- (0, import_path15.join)(path11, VERCEL_DIR2, VERCEL_DIR_PROJECT),
129998
+ (0, import_path16.join)(path11, VERCEL_DIR2, VERCEL_DIR_PROJECT),
129518
129999
  JSON.stringify({
129519
130000
  ...projectLink,
129520
130001
  projectName
@@ -129524,22 +130005,45 @@ async function linkFolderToProject(client2, path11, projectLink, projectName, or
129524
130005
  const isGitIgnoreUpdated = await addToGitIgnore(path11);
129525
130006
  output_manager_default.print(
129526
130007
  prependEmoji(
129527
- `Linked to ${import_chalk41.default.bold(
130008
+ `Linked to ${import_chalk44.default.bold(
129528
130009
  `${orgSlug}/${projectName}`
129529
130010
  )} (created ${VERCEL_DIR2}${isGitIgnoreUpdated ? " and added it to .gitignore" : ""})`,
129530
130011
  emoji(successEmoji)
129531
130012
  ) + "\n"
129532
130013
  );
130014
+ const pullEnvConfirmed = autoConfirm || await client2.input.confirm(
130015
+ "Would you like to pull environment variables now?",
130016
+ true
130017
+ );
130018
+ if (pullEnvConfirmed) {
130019
+ const originalCwd = client2.cwd;
130020
+ try {
130021
+ client2.cwd = path11;
130022
+ const args2 = autoConfirm ? ["--yes"] : [];
130023
+ const exitCode2 = await pull(client2, args2, "vercel-cli:link");
130024
+ if (exitCode2 !== 0) {
130025
+ output_manager_default.error(
130026
+ "Failed to pull environment variables. You can run `vc env pull` manually."
130027
+ );
130028
+ }
130029
+ } catch (error3) {
130030
+ output_manager_default.error(
130031
+ "Failed to pull environment variables. You can run `vc env pull` manually."
130032
+ );
130033
+ } finally {
130034
+ client2.cwd = originalCwd;
130035
+ }
130036
+ }
129533
130037
  }
129534
- var import_fs4, import_ajv, import_chalk41, import_path15, import_fs_extra7, import_util2, import_build_utils6, import_error_utils12, readFile3, writeFile2, VERCEL_DIR2, VERCEL_DIR_FALLBACK, VERCEL_DIR_README, VERCEL_DIR_PROJECT, VERCEL_DIR_REPO, linkSchema;
130038
+ var import_fs5, import_ajv, import_chalk44, import_path16, import_fs_extra9, import_util2, import_build_utils6, import_error_utils13, readFile4, writeFile2, VERCEL_DIR2, VERCEL_DIR_FALLBACK, VERCEL_DIR_README, VERCEL_DIR_PROJECT, VERCEL_DIR_REPO, linkSchema;
129535
130039
  var init_link2 = __esm({
129536
130040
  "src/util/projects/link.ts"() {
129537
130041
  "use strict";
129538
- import_fs4 = __toESM3(require("fs"));
130042
+ import_fs5 = __toESM3(require("fs"));
129539
130043
  import_ajv = __toESM3(require_ajv());
129540
- import_chalk41 = __toESM3(require_source());
129541
- import_path15 = require("path");
129542
- import_fs_extra7 = __toESM3(require_lib());
130044
+ import_chalk44 = __toESM3(require_source());
130045
+ import_path16 = require("path");
130046
+ import_fs_extra9 = __toESM3(require_lib());
129543
130047
  import_util2 = require("util");
129544
130048
  init_get_project_by_id_or_name();
129545
130049
  init_errors_ts();
@@ -129549,12 +130053,13 @@ var init_link2 = __esm({
129549
130053
  init_global_path();
129550
130054
  import_build_utils6 = require("@vercel/build-utils");
129551
130055
  init_code();
129552
- import_error_utils12 = __toESM3(require_dist2());
130056
+ import_error_utils13 = __toESM3(require_dist2());
129553
130057
  init_repo();
129554
130058
  init_add_to_gitignore();
129555
130059
  init_output_manager();
129556
- readFile3 = (0, import_util2.promisify)(import_fs4.default.readFile);
129557
- writeFile2 = (0, import_util2.promisify)(import_fs4.default.writeFile);
130060
+ init_pull2();
130061
+ readFile4 = (0, import_util2.promisify)(import_fs5.default.readFile);
130062
+ writeFile2 = (0, import_util2.promisify)(import_fs5.default.writeFile);
129558
130063
  VERCEL_DIR2 = ".vercel";
129559
130064
  VERCEL_DIR_FALLBACK = ".now";
129560
130065
  VERCEL_DIR_README = "README.txt";
@@ -129704,7 +130209,7 @@ async function addStore(client2, argv) {
129704
130209
  ]
129705
130210
  });
129706
130211
  output_manager_default.spinner(
129707
- `Connecting ${import_chalk42.default.bold(name)} to ${import_chalk42.default.bold(link4.project.name)}...`
130212
+ `Connecting ${import_chalk45.default.bold(name)} to ${import_chalk45.default.bold(link4.project.name)}...`
129708
130213
  );
129709
130214
  await connectResourceToProject(
129710
130215
  client2,
@@ -129714,7 +130219,7 @@ async function addStore(client2, argv) {
129714
130219
  link4.org.id
129715
130220
  );
129716
130221
  output_manager_default.success(
129717
- `Blob store ${import_chalk42.default.bold(name)} linked to ${import_chalk42.default.bold(
130222
+ `Blob store ${import_chalk45.default.bold(name)} linked to ${import_chalk45.default.bold(
129718
130223
  link4.project.name
129719
130224
  )}. Make sure to pull the new environment variables using ${getCommandName("env pull")}`
129720
130225
  );
@@ -129722,14 +130227,14 @@ async function addStore(client2, argv) {
129722
130227
  }
129723
130228
  return 0;
129724
130229
  }
129725
- var import_chalk42;
130230
+ var import_chalk45;
129726
130231
  var init_store_add2 = __esm({
129727
130232
  "src/commands/blob/store-add.ts"() {
129728
130233
  "use strict";
129729
130234
  init_output_manager();
129730
130235
  init_link2();
129731
130236
  init_connect_resource_to_project();
129732
- import_chalk42 = __toESM3(require_source());
130237
+ import_chalk45 = __toESM3(require_source());
129733
130238
  init_pkg_name();
129734
130239
  init_get_flags_specification();
129735
130240
  init_get_args();
@@ -132209,8 +132714,8 @@ async function getStore2(client2, argv, rwToken) {
132209
132714
  const regionInfo = store2.store.region ? `
132210
132715
  Region: ${store2.store.region}` : "";
132211
132716
  output_manager_default.print(
132212
- `Blob Store: ${import_chalk43.default.bold(store2.store.name)} (${import_chalk43.default.dim(store2.store.id)})
132213
- Billing State: ${store2.store.billingState === "active" ? import_chalk43.default.green("Active") : import_chalk43.default.red("Inactive")}
132717
+ `Blob Store: ${import_chalk46.default.bold(store2.store.name)} (${import_chalk46.default.dim(store2.store.id)})
132718
+ Billing State: ${store2.store.billingState === "active" ? import_chalk46.default.green("Active") : import_chalk46.default.red("Inactive")}
132214
132719
  Size: ${(0, import_bytes3.default)(store2.store.size)}${regionInfo}
132215
132720
  Created At: ${(0, import_date_fns.format)(new Date(store2.store.createdAt), dateTimeFormat2)}
132216
132721
  Updated At: ${(0, import_date_fns.format)(new Date(store2.store.updatedAt), dateTimeFormat2)}
@@ -132223,7 +132728,7 @@ Updated At: ${(0, import_date_fns.format)(new Date(store2.store.updatedAt), date
132223
132728
  output_manager_default.stopSpinner();
132224
132729
  return 0;
132225
132730
  }
132226
- var import_bytes3, import_date_fns, import_chalk43;
132731
+ var import_bytes3, import_date_fns, import_chalk46;
132227
132732
  var init_store_get2 = __esm({
132228
132733
  "src/commands/blob/store-get.ts"() {
132229
132734
  "use strict";
@@ -132235,7 +132740,7 @@ var init_store_get2 = __esm({
132235
132740
  init_link2();
132236
132741
  init_command39();
132237
132742
  import_date_fns = __toESM3(require_date_fns());
132238
- import_chalk43 = __toESM3(require_source());
132743
+ import_chalk46 = __toESM3(require_source());
132239
132744
  init_store_get();
132240
132745
  }
132241
132746
  });
@@ -132329,97 +132834,12 @@ var init_store2 = __esm({
132329
132834
  }
132330
132835
  });
132331
132836
 
132332
- // src/util/parse-env.ts
132333
- var parseEnv;
132334
- var init_parse_env = __esm({
132335
- "src/util/parse-env.ts"() {
132336
- "use strict";
132337
- parseEnv = (env) => {
132338
- if (!env) {
132339
- return {};
132340
- }
132341
- if (typeof env === "string") {
132342
- env = [env];
132343
- }
132344
- if (Array.isArray(env)) {
132345
- const startingDict = {};
132346
- return env.reduce((o, e2) => {
132347
- let key;
132348
- let value;
132349
- const equalsSign = e2.indexOf("=");
132350
- if (equalsSign === -1) {
132351
- key = e2;
132352
- } else {
132353
- key = e2.slice(0, equalsSign);
132354
- value = e2.slice(equalsSign + 1);
132355
- }
132356
- o[key] = value;
132357
- return o;
132358
- }, startingDict);
132359
- }
132360
- return env;
132361
- };
132362
- }
132363
- });
132364
-
132365
- // src/util/env/diff-env-files.ts
132366
- async function createEnvObject(envPath) {
132367
- const envArr = (await (0, import_fs_extra8.readFile)(envPath, "utf-8")).replace(/"/g, "").split(/\r?\n|\r/).filter((line) => /^[^#]/.test(line)).filter((line) => /=/i.test(line));
132368
- const parsedEnv = parseEnv(envArr);
132369
- if (Object.keys(parsedEnv).length === 0) {
132370
- output_manager_default.debug("Failed to parse env file.");
132371
- return;
132372
- }
132373
- return parsedEnv;
132374
- }
132375
- function findChanges(oldEnv, newEnv) {
132376
- const added = [];
132377
- const changed = [];
132378
- for (const key of Object.keys(newEnv)) {
132379
- if (oldEnv[key] === void 0) {
132380
- added.push(key);
132381
- } else if (oldEnv[key] !== newEnv[key]) {
132382
- changed.push(key);
132383
- }
132384
- delete oldEnv[key];
132385
- }
132386
- const removed = Object.keys(oldEnv);
132387
- return {
132388
- added,
132389
- changed,
132390
- removed
132391
- };
132392
- }
132393
- function buildDeltaString(oldEnv, newEnv) {
132394
- const { added, changed, removed } = findChanges(oldEnv, newEnv);
132395
- let deltaString = "";
132396
- deltaString += import_chalk44.default.green(addDeltaSection("+", changed, true));
132397
- deltaString += import_chalk44.default.green(addDeltaSection("+", added));
132398
- deltaString += import_chalk44.default.red(addDeltaSection("-", removed));
132399
- return deltaString ? import_chalk44.default.gray("Changes:\n") + deltaString + "\n" : deltaString;
132400
- }
132401
- function addDeltaSection(prefix, arr, changed = false) {
132402
- if (arr.length === 0)
132403
- return "";
132404
- return arr.sort().map((item) => `${prefix} ${item}${changed ? " (Updated)" : ""}`).join("\n") + "\n";
132405
- }
132406
- var import_fs_extra8, import_chalk44;
132407
- var init_diff_env_files = __esm({
132408
- "src/util/env/diff-env-files.ts"() {
132409
- "use strict";
132410
- import_fs_extra8 = __toESM3(require_lib());
132411
- init_parse_env();
132412
- import_chalk44 = __toESM3(require_source());
132413
- init_output_manager();
132414
- }
132415
- });
132416
-
132417
132837
  // src/util/output/list-item.ts
132418
- var import_chalk45, listItem, list_item_default;
132838
+ var import_chalk47, listItem, list_item_default;
132419
132839
  var init_list_item = __esm({
132420
132840
  "src/util/output/list-item.ts"() {
132421
132841
  "use strict";
132422
- import_chalk45 = __toESM3(require_source());
132842
+ import_chalk47 = __toESM3(require_source());
132423
132843
  listItem = (msg, n) => {
132424
132844
  if (!n) {
132425
132845
  n = "-";
@@ -132427,7 +132847,7 @@ var init_list_item = __esm({
132427
132847
  if (Number(n)) {
132428
132848
  n += ".";
132429
132849
  }
132430
- return `${(0, import_chalk45.default)(n.toString())} ${msg}`;
132850
+ return `${(0, import_chalk47.default)(n.toString())} ${msg}`;
132431
132851
  };
132432
132852
  list_item_default = listItem;
132433
132853
  }
@@ -135063,7 +135483,7 @@ async function initCorepack({
135063
135483
  return null;
135064
135484
  }
135065
135485
  const pkg = await readJSONFile(
135066
- (0, import_path16.join)(repoRootPath, "package.json")
135486
+ (0, import_path17.join)(repoRootPath, "package.json")
135067
135487
  );
135068
135488
  if (pkg instanceof CantParseJSONFile) {
135069
135489
  output_manager_default.warn(
@@ -135078,13 +135498,13 @@ async function initCorepack({
135078
135498
  output_manager_default.log(
135079
135499
  `Detected ENABLE_EXPERIMENTAL_COREPACK=1 and "${pkg.packageManager}" in package.json`
135080
135500
  );
135081
- const corepackRootDir = (0, import_path16.join)(repoRootPath, VERCEL_DIR2, "cache", "corepack");
135082
- const corepackHomeDir = (0, import_path16.join)(corepackRootDir, "home");
135083
- const corepackShimDir = (0, import_path16.join)(corepackRootDir, "shim");
135084
- await import_fs_extra9.default.mkdirp(corepackHomeDir);
135085
- await import_fs_extra9.default.mkdirp(corepackShimDir);
135501
+ const corepackRootDir = (0, import_path17.join)(repoRootPath, VERCEL_DIR2, "cache", "corepack");
135502
+ const corepackHomeDir = (0, import_path17.join)(corepackRootDir, "home");
135503
+ const corepackShimDir = (0, import_path17.join)(corepackRootDir, "shim");
135504
+ await import_fs_extra10.default.mkdirp(corepackHomeDir);
135505
+ await import_fs_extra10.default.mkdirp(corepackShimDir);
135086
135506
  process.env.COREPACK_HOME = corepackHomeDir;
135087
- process.env.PATH = `${corepackShimDir}${import_path16.delimiter}${process.env.PATH}`;
135507
+ process.env.PATH = `${corepackShimDir}${import_path17.delimiter}${process.env.PATH}`;
135088
135508
  const pkgManagerName = pkg.packageManager.split("@")[0];
135089
135509
  await (0, import_build_utils7.spawnAsync)(
135090
135510
  "corepack",
@@ -135103,18 +135523,18 @@ function cleanupCorepack(corepackShimDir) {
135103
135523
  }
135104
135524
  if (process.env.PATH) {
135105
135525
  process.env.PATH = process.env.PATH.replace(
135106
- `${corepackShimDir}${import_path16.delimiter}`,
135526
+ `${corepackShimDir}${import_path17.delimiter}`,
135107
135527
  ""
135108
135528
  );
135109
135529
  }
135110
135530
  }
135111
- var import_path16, import_build_utils7, import_fs_extra9;
135531
+ var import_path17, import_build_utils7, import_fs_extra10;
135112
135532
  var init_corepack = __esm({
135113
135533
  "src/util/build/corepack.ts"() {
135114
135534
  "use strict";
135115
- import_path16 = require("path");
135535
+ import_path17 = require("path");
135116
135536
  import_build_utils7 = require("@vercel/build-utils");
135117
- import_fs_extra9 = __toESM3(require_lib());
135537
+ import_fs_extra10 = __toESM3(require_lib());
135118
135538
  init_errors_ts();
135119
135539
  init_link2();
135120
135540
  init_read_json_file();
@@ -136032,7 +136452,7 @@ var init_static_builder = __esm({
136032
136452
 
136033
136453
  // src/util/build/import-builders.ts
136034
136454
  async function importBuilders(builderSpecs, cwd) {
136035
- const buildersDir = (0, import_path17.join)(cwd, VERCEL_DIR2, "builders");
136455
+ const buildersDir = (0, import_path18.join)(cwd, VERCEL_DIR2, "builders");
136036
136456
  let importResult = await resolveBuilders(buildersDir, builderSpecs);
136037
136457
  if ("buildersToAdd" in importResult) {
136038
136458
  const installResult = await installBuilders(
@@ -136074,10 +136494,10 @@ async function resolveBuilders(buildersDir, builderSpecs, resolvedSpecs) {
136074
136494
  let pkgPath;
136075
136495
  let builderPkg;
136076
136496
  try {
136077
- pkgPath = (0, import_path17.join)(buildersDir, "node_modules", name, "package.json");
136078
- builderPkg = await (0, import_fs_extra10.readJSON)(pkgPath);
136497
+ pkgPath = (0, import_path18.join)(buildersDir, "node_modules", name, "package.json");
136498
+ builderPkg = await (0, import_fs_extra11.readJSON)(pkgPath);
136079
136499
  } catch (error3) {
136080
- if (!(0, import_error_utils13.isErrnoException)(error3)) {
136500
+ if (!(0, import_error_utils14.isErrnoException)(error3)) {
136081
136501
  throw error3;
136082
136502
  }
136083
136503
  if (error3.code !== "ENOENT") {
@@ -136086,7 +136506,7 @@ async function resolveBuilders(buildersDir, builderSpecs, resolvedSpecs) {
136086
136506
  pkgPath = require_.resolve(`${name}/package.json`, {
136087
136507
  paths: [__dirname]
136088
136508
  });
136089
- builderPkg = await (0, import_fs_extra10.readJSON)(pkgPath);
136509
+ builderPkg = await (0, import_fs_extra11.readJSON)(pkgPath);
136090
136510
  }
136091
136511
  if (!builderPkg || !pkgPath) {
136092
136512
  throw new Error(`Failed to load \`package.json\` for "${name}"`);
@@ -136110,7 +136530,7 @@ async function resolveBuilders(buildersDir, builderSpecs, resolvedSpecs) {
136110
136530
  buildersToAdd.add(spec);
136111
136531
  continue;
136112
136532
  }
136113
- const path11 = (0, import_path17.join)((0, import_path17.dirname)(pkgPath), builderPkg.main || "index.js");
136533
+ const path11 = (0, import_path18.join)((0, import_path18.dirname)(pkgPath), builderPkg.main || "index.js");
136114
136534
  const builder = require_(path11);
136115
136535
  builders.set(spec, {
136116
136536
  builder,
@@ -136121,7 +136541,7 @@ async function resolveBuilders(buildersDir, builderSpecs, resolvedSpecs) {
136121
136541
  path: path11,
136122
136542
  pkgPath
136123
136543
  });
136124
- output_manager_default.debug(`Imported Builder "${name}" from "${(0, import_path17.dirname)(pkgPath)}"`);
136544
+ output_manager_default.debug(`Imported Builder "${name}" from "${(0, import_path18.dirname)(pkgPath)}"`);
136125
136545
  } catch (err) {
136126
136546
  if (err.code === "MODULE_NOT_FOUND" && !resolvedSpecs) {
136127
136547
  output_manager_default.debug(`Failed to import "${name}": ${err}`);
@@ -136139,13 +136559,13 @@ async function resolveBuilders(buildersDir, builderSpecs, resolvedSpecs) {
136139
136559
  }
136140
136560
  async function installBuilders(buildersDir, buildersToAdd) {
136141
136561
  const resolvedSpecs = /* @__PURE__ */ new Map();
136142
- const buildersPkgPath = (0, import_path17.join)(buildersDir, "package.json");
136562
+ const buildersPkgPath = (0, import_path18.join)(buildersDir, "package.json");
136143
136563
  try {
136144
136564
  const emptyPkgJson = {
136145
136565
  private: true,
136146
136566
  license: "UNLICENSED"
136147
136567
  };
136148
- await (0, import_fs_extra10.outputJSON)(buildersPkgPath, emptyPkgJson, {
136568
+ await (0, import_fs_extra11.outputJSON)(buildersPkgPath, emptyPkgJson, {
136149
136569
  flag: "wx"
136150
136570
  });
136151
136571
  } catch (err) {
@@ -136171,7 +136591,7 @@ async function installBuilders(buildersDir, buildersToAdd) {
136171
136591
  output_manager_default.warn(line);
136172
136592
  });
136173
136593
  } catch (err) {
136174
- if ((0, import_error_utils13.isError)(err)) {
136594
+ if ((0, import_error_utils14.isError)(err)) {
136175
136595
  const execaMessage = err.message;
136176
136596
  let message2 = getErrorMessage(err, execaMessage);
136177
136597
  if (execaMessage.startsWith("Command failed with ENOENT")) {
@@ -136179,7 +136599,7 @@ async function installBuilders(buildersDir, buildersToAdd) {
136179
136599
  } else {
136180
136600
  const notFound = /GET (.*) - Not found/.exec(message2);
136181
136601
  if (notFound) {
136182
- const url3 = new import_url8.URL(notFound[1]);
136602
+ const url3 = new import_url9.URL(notFound[1]);
136183
136603
  const packageName2 = decodeURIComponent(url3.pathname.slice(1));
136184
136604
  message2 = `The package ${code(
136185
136605
  packageName2
@@ -136191,12 +136611,12 @@ async function installBuilders(buildersDir, buildersToAdd) {
136191
136611
  }
136192
136612
  throw err;
136193
136613
  }
136194
- const nowScopePath = (0, import_path17.join)(buildersDir, "node_modules/@now");
136195
- await (0, import_fs_extra10.mkdirp)(nowScopePath);
136614
+ const nowScopePath = (0, import_path18.join)(buildersDir, "node_modules/@now");
136615
+ await (0, import_fs_extra11.mkdirp)(nowScopePath);
136196
136616
  try {
136197
- await (0, import_fs_extra10.symlink)("../@vercel/build-utils", (0, import_path17.join)(nowScopePath, "build-utils"));
136617
+ await (0, import_fs_extra11.symlink)("../@vercel/build-utils", (0, import_path18.join)(nowScopePath, "build-utils"));
136198
136618
  } catch (err) {
136199
- if (!(0, import_error_utils13.isErrnoException)(err) || err.code !== "EEXIST") {
136619
+ if (!(0, import_error_utils14.isErrnoException)(err) || err.code !== "EEXIST") {
136200
136620
  throw err;
136201
136621
  }
136202
136622
  }
@@ -136227,24 +136647,24 @@ function getErrorMessage(err, execaMessage) {
136227
136647
  }
136228
136648
  return execaMessage;
136229
136649
  }
136230
- var import_url8, import_pluralize4, import_npm_package_arg, import_semver2, import_path17, import_module2, import_fs_extra10, import_fs_detectors2, import_execa3, import_error_utils13, require_;
136650
+ var import_url9, import_pluralize4, import_npm_package_arg, import_semver2, import_path18, import_module2, import_fs_extra11, import_fs_detectors2, import_execa3, import_error_utils14, require_;
136231
136651
  var init_import_builders = __esm({
136232
136652
  "src/util/build/import-builders.ts"() {
136233
136653
  "use strict";
136234
- import_url8 = require("url");
136654
+ import_url9 = require("url");
136235
136655
  import_pluralize4 = __toESM3(require_pluralize());
136236
136656
  import_npm_package_arg = __toESM3(require_npa());
136237
136657
  import_semver2 = __toESM3(require_semver());
136238
- import_path17 = require("path");
136658
+ import_path18 = require("path");
136239
136659
  import_module2 = require("module");
136240
- import_fs_extra10 = __toESM3(require_lib());
136660
+ import_fs_extra11 = __toESM3(require_lib());
136241
136661
  import_fs_detectors2 = __toESM3(require_dist20());
136242
136662
  import_execa3 = __toESM3(require_execa());
136243
136663
  init_static_builder();
136244
136664
  init_link2();
136245
136665
  init_read_json_file();
136246
136666
  init_errors_ts();
136247
- import_error_utils13 = __toESM3(require_dist2());
136667
+ import_error_utils14 = __toESM3(require_dist2());
136248
136668
  init_cmd();
136249
136669
  init_code();
136250
136670
  init_output_manager();
@@ -136255,8 +136675,8 @@ var init_import_builders = __esm({
136255
136675
  // src/util/build/monorepo.ts
136256
136676
  async function setMonorepoDefaultSettings(cwd, workPath, projectSettings) {
136257
136677
  const localFileSystem = new import_fs_detectors3.LocalFileSystemDetector(cwd);
136258
- const projectName = (0, import_path18.basename)(workPath);
136259
- const relativeToRoot = (0, import_path18.relative)(workPath, cwd);
136678
+ const projectName = (0, import_path19.basename)(workPath);
136679
+ const relativeToRoot = (0, import_path19.relative)(workPath, cwd);
136260
136680
  const setCommand = (command, value) => {
136261
136681
  if (projectSettings[command]) {
136262
136682
  (0, import_build_utils9.debug)(
@@ -136269,7 +136689,7 @@ async function setMonorepoDefaultSettings(cwd, workPath, projectSettings) {
136269
136689
  try {
136270
136690
  const result = await (0, import_fs_detectors3.getMonorepoDefaultSettings)(
136271
136691
  projectName,
136272
- (0, import_path18.relative)(cwd, workPath),
136692
+ (0, import_path19.relative)(cwd, workPath),
136273
136693
  relativeToRoot,
136274
136694
  localFileSystem
136275
136695
  );
@@ -136300,11 +136720,11 @@ async function setMonorepoDefaultSettings(cwd, workPath, projectSettings) {
136300
136720
  throw error3;
136301
136721
  }
136302
136722
  }
136303
- var import_path18, import_fs_detectors3, import_title3, import_build_utils9;
136723
+ var import_path19, import_fs_detectors3, import_title3, import_build_utils9;
136304
136724
  var init_monorepo = __esm({
136305
136725
  "src/util/build/monorepo.ts"() {
136306
136726
  "use strict";
136307
- import_path18 = require("path");
136727
+ import_path19 = require("path");
136308
136728
  import_fs_detectors3 = __toESM3(require_dist20());
136309
136729
  import_title3 = __toESM3(require_lib4());
136310
136730
  import_build_utils9 = require("@vercel/build-utils");
@@ -144365,41 +144785,41 @@ var require_promisepipe = __commonJS2({
144365
144785
 
144366
144786
  // src/util/build/merge.ts
144367
144787
  async function merge(source, destination) {
144368
- const destStat = await (0, import_fs_extra11.stat)(destination).catch(
144788
+ const destStat = await (0, import_fs_extra12.stat)(destination).catch(
144369
144789
  (err) => err
144370
144790
  );
144371
- if ((0, import_error_utils14.isErrnoException)(destStat)) {
144791
+ if ((0, import_error_utils15.isErrnoException)(destStat)) {
144372
144792
  if (destStat.code === "ENOENT") {
144373
- await (0, import_fs_extra11.move)(source, destination);
144793
+ await (0, import_fs_extra12.move)(source, destination);
144374
144794
  return;
144375
144795
  }
144376
144796
  throw destStat;
144377
144797
  } else if (destStat.isDirectory()) {
144378
- const contents = await (0, import_fs_extra11.readdir)(
144798
+ const contents = await (0, import_fs_extra12.readdir)(
144379
144799
  source
144380
144800
  ).catch((err) => err);
144381
- if ((0, import_error_utils14.isErrnoException)(contents)) {
144801
+ if ((0, import_error_utils15.isErrnoException)(contents)) {
144382
144802
  if (contents.code !== "ENOTDIR") {
144383
144803
  throw contents;
144384
144804
  }
144385
144805
  } else {
144386
144806
  await Promise.all(
144387
- contents.map((name) => merge((0, import_path19.join)(source, name), (0, import_path19.join)(destination, name)))
144807
+ contents.map((name) => merge((0, import_path20.join)(source, name), (0, import_path20.join)(destination, name)))
144388
144808
  );
144389
- await (0, import_fs_extra11.rmdir)(source);
144809
+ await (0, import_fs_extra12.rmdir)(source);
144390
144810
  return;
144391
144811
  }
144392
144812
  }
144393
- await (0, import_fs_extra11.remove)(destination);
144394
- await (0, import_fs_extra11.move)(source, destination);
144813
+ await (0, import_fs_extra12.remove)(destination);
144814
+ await (0, import_fs_extra12.move)(source, destination);
144395
144815
  }
144396
- var import_path19, import_error_utils14, import_fs_extra11;
144816
+ var import_path20, import_error_utils15, import_fs_extra12;
144397
144817
  var init_merge = __esm({
144398
144818
  "src/util/build/merge.ts"() {
144399
144819
  "use strict";
144400
- import_path19 = require("path");
144401
- import_error_utils14 = __toESM3(require_dist2());
144402
- import_fs_extra11 = __toESM3(require_lib());
144820
+ import_path20 = require("path");
144821
+ import_error_utils15 = __toESM3(require_dist2());
144822
+ import_fs_extra12 = __toESM3(require_lib());
144403
144823
  }
144404
144824
  });
144405
144825
 
@@ -146300,11 +146720,11 @@ async function unzip(buffer, dir) {
146300
146720
  if (entry.fileName.startsWith("__MACOSX/"))
146301
146721
  continue;
146302
146722
  try {
146303
- const destDir = import_path20.default.dirname(import_path20.default.join(dir, entry.fileName));
146723
+ const destDir = import_path21.default.dirname(import_path21.default.join(dir, entry.fileName));
146304
146724
  await fs6.mkdirp(destDir);
146305
146725
  const canonicalDestDir = await fs6.realpath(destDir);
146306
- const relativeDestDir = import_path20.default.relative(dir, canonicalDestDir);
146307
- if (relativeDestDir.split(import_path20.default.sep).includes("..")) {
146726
+ const relativeDestDir = import_path21.default.relative(dir, canonicalDestDir);
146727
+ if (relativeDestDir.split(import_path21.default.sep).includes("..")) {
146308
146728
  throw new Error(
146309
146729
  `Out of bound path "${canonicalDestDir}" found while processing file ${entry.fileName}`
146310
146730
  );
@@ -146317,7 +146737,7 @@ async function unzip(buffer, dir) {
146317
146737
  }
146318
146738
  }
146319
146739
  async function extractEntry(zipFile, entry, dir) {
146320
- const dest = import_path20.default.join(dir, entry.fileName);
146740
+ const dest = import_path21.default.join(dir, entry.fileName);
146321
146741
  const mode = entry.externalFileAttributes >> 16 & 65535;
146322
146742
  const IFMT = 61440;
146323
146743
  const IFDIR = 16384;
@@ -146331,7 +146751,7 @@ async function extractEntry(zipFile, entry, dir) {
146331
146751
  if (!isDir)
146332
146752
  isDir = madeBy === 0 && entry.externalFileAttributes === 16;
146333
146753
  const procMode = getExtractedMode(mode, isDir) & 511;
146334
- const destDir = isDir ? dest : import_path20.default.dirname(dest);
146754
+ const destDir = isDir ? dest : import_path21.default.dirname(dest);
146335
146755
  const mkdirOptions = { recursive: true };
146336
146756
  if (isDir) {
146337
146757
  mkdirOptions.mode = procMode;
@@ -146358,11 +146778,11 @@ function getExtractedMode(entryMode, isDir) {
146358
146778
  }
146359
146779
  return mode;
146360
146780
  }
146361
- var import_path20, import_promisepipe, fs6, import_build_utils10, import_yauzl_promise;
146781
+ var import_path21, import_promisepipe, fs6, import_build_utils10, import_yauzl_promise;
146362
146782
  var init_unzip = __esm({
146363
146783
  "src/util/build/unzip.ts"() {
146364
146784
  "use strict";
146365
- import_path20 = __toESM3(require("path"));
146785
+ import_path21 = __toESM3(require("path"));
146366
146786
  import_promisepipe = __toESM3(require_promisepipe());
146367
146787
  fs6 = __toESM3(require_lib());
146368
146788
  import_build_utils10 = require("@vercel/build-utils");
@@ -146481,11 +146901,11 @@ async function writeBuildResultV2(args2) {
146481
146901
  if (fallback) {
146482
146902
  const ext = getFileExtension(fallback);
146483
146903
  const fallbackName = `${normalizedPath}.prerender-fallback${ext}`;
146484
- const fallbackPath = (0, import_path21.join)(outputDir, "functions", fallbackName);
146904
+ const fallbackPath = (0, import_path22.join)(outputDir, "functions", fallbackName);
146485
146905
  let usedHardLink = false;
146486
146906
  if ("fsPath" in fallback) {
146487
146907
  try {
146488
- await import_fs_extra12.default.link(fallback.fsPath, fallbackPath);
146908
+ await import_fs_extra13.default.link(fallback.fsPath, fallbackPath);
146489
146909
  usedHardLink = true;
146490
146910
  } catch (_) {
146491
146911
  }
@@ -146494,15 +146914,15 @@ async function writeBuildResultV2(args2) {
146494
146914
  const stream = fallback.toStream();
146495
146915
  await (0, import_promisepipe2.default)(
146496
146916
  stream,
146497
- import_fs_extra12.default.createWriteStream(fallbackPath, { mode: fallback.mode })
146917
+ import_fs_extra13.default.createWriteStream(fallbackPath, { mode: fallback.mode })
146498
146918
  );
146499
146919
  }
146500
146920
  fallback = new import_build_utils11.FileFsRef({
146501
146921
  ...output2.fallback,
146502
- fsPath: (0, import_path21.basename)(fallbackName)
146922
+ fsPath: (0, import_path22.basename)(fallbackName)
146503
146923
  });
146504
146924
  }
146505
- const prerenderConfigPath = (0, import_path21.join)(
146925
+ const prerenderConfigPath = (0, import_path22.join)(
146506
146926
  outputDir,
146507
146927
  "functions",
146508
146928
  `${normalizedPath}.prerender-config.json`
@@ -146512,7 +146932,7 @@ async function writeBuildResultV2(args2) {
146512
146932
  lambda: void 0,
146513
146933
  fallback
146514
146934
  };
146515
- await import_fs_extra12.default.writeJSON(prerenderConfigPath, prerenderConfig, { spaces: 2 });
146935
+ await import_fs_extra13.default.writeJSON(prerenderConfigPath, prerenderConfig, { spaces: 2 });
146516
146936
  } else if (isFile(output2)) {
146517
146937
  await writeStaticFile(
146518
146938
  outputDir,
@@ -146549,13 +146969,13 @@ async function writeBuildResultV3(args2) {
146549
146969
  workPath
146550
146970
  } = args2;
146551
146971
  const { output: output2 } = buildResult;
146552
- const routesJsonPath = (0, import_path21.join)(workPath, ".vercel", "routes.json");
146553
- if (((0, import_build_utils11.isBackendBuilder)(build2) || build2.use === "@vercel/python") && (0, import_fs_extra12.existsSync)(routesJsonPath)) {
146972
+ const routesJsonPath = (0, import_path22.join)(workPath, ".vercel", "routes.json");
146973
+ if (((0, import_build_utils11.isBackendBuilder)(build2) || build2.use === "@vercel/python") && (0, import_fs_extra13.existsSync)(routesJsonPath)) {
146554
146974
  try {
146555
146975
  const newOutput = {
146556
146976
  index: output2
146557
146977
  };
146558
- const routesJson = await import_fs_extra12.default.readJSON(routesJsonPath);
146978
+ const routesJson = await import_fs_extra13.default.readJSON(routesJsonPath);
146559
146979
  if (routesJson && typeof routesJson === "object" && "routes" in routesJson && Array.isArray(routesJson.routes)) {
146560
146980
  for (const route of routesJson.routes) {
146561
146981
  if (route.source === "/") {
@@ -146587,7 +147007,7 @@ async function writeBuildResultV3(args2) {
146587
147007
  sourceFile: src,
146588
147008
  config: vercelConfig
146589
147009
  }) : {};
146590
- const ext = (0, import_path21.extname)(src);
147010
+ const ext = (0, import_path22.extname)(src);
146591
147011
  const path11 = stripDuplicateSlashes(
146592
147012
  build2.config?.zeroConfig ? src.substring(0, src.length - ext.length) : src
146593
147013
  );
@@ -146620,7 +147040,7 @@ async function writeStaticFile(outputDir, file, path11, overrides, cleanUrls = f
146620
147040
  let fsPath = path11;
146621
147041
  let override = null;
146622
147042
  const ext = getFileExtension(file);
146623
- if (ext && (0, import_path21.extname)(path11) !== ext) {
147043
+ if (ext && (0, import_path22.extname)(path11) !== ext) {
146624
147044
  fsPath += ext;
146625
147045
  if (!override)
146626
147046
  override = {};
@@ -146639,11 +147059,11 @@ async function writeStaticFile(outputDir, file, path11, overrides, cleanUrls = f
146639
147059
  if (override) {
146640
147060
  overrides[fsPath] = override;
146641
147061
  }
146642
- const dest = (0, import_path21.join)(outputDir, "static", fsPath);
146643
- await import_fs_extra12.default.mkdirp((0, import_path21.dirname)(dest));
147062
+ const dest = (0, import_path22.join)(outputDir, "static", fsPath);
147063
+ await import_fs_extra13.default.mkdirp((0, import_path22.dirname)(dest));
146644
147064
  if ("fsPath" in file) {
146645
147065
  try {
146646
- return await import_fs_extra12.default.link(file.fsPath, dest);
147066
+ return await import_fs_extra13.default.link(file.fsPath, dest);
146647
147067
  } catch (_) {
146648
147068
  }
146649
147069
  }
@@ -146653,15 +147073,15 @@ async function writeFunctionSymlink(outputDir, dest, fn2, existingFunctions) {
146653
147073
  const existingPath = existingFunctions.get(fn2);
146654
147074
  if (!existingPath)
146655
147075
  return false;
146656
- const destDir = (0, import_path21.dirname)(dest);
146657
- const targetDest = (0, import_path21.join)(outputDir, "functions", `${existingPath}.func`);
146658
- const target = (0, import_path21.relative)(destDir, targetDest);
146659
- await import_fs_extra12.default.mkdirp(destDir);
146660
- await import_fs_extra12.default.symlink(target, dest);
147076
+ const destDir = (0, import_path22.dirname)(dest);
147077
+ const targetDest = (0, import_path22.join)(outputDir, "functions", `${existingPath}.func`);
147078
+ const target = (0, import_path22.relative)(destDir, targetDest);
147079
+ await import_fs_extra13.default.mkdirp(destDir);
147080
+ await import_fs_extra13.default.symlink(target, dest);
146661
147081
  return true;
146662
147082
  }
146663
147083
  async function writeEdgeFunction(repoRootPath, outputDir, edgeFunction, path11, existingFunctions, standalone = false) {
146664
- const dest = (0, import_path21.join)(outputDir, "functions", `${path11}.func`);
147084
+ const dest = (0, import_path22.join)(outputDir, "functions", `${path11}.func`);
146665
147085
  if (existingFunctions) {
146666
147086
  if (await writeFunctionSymlink(
146667
147087
  outputDir,
@@ -146673,9 +147093,9 @@ async function writeEdgeFunction(repoRootPath, outputDir, edgeFunction, path11,
146673
147093
  }
146674
147094
  existingFunctions.set(edgeFunction, path11);
146675
147095
  }
146676
- await import_fs_extra12.default.mkdirp(dest);
147096
+ await import_fs_extra13.default.mkdirp(dest);
146677
147097
  const ops = [];
146678
- const sharedDest = (0, import_path21.join)(outputDir, "shared");
147098
+ const sharedDest = (0, import_path22.join)(outputDir, "shared");
146679
147099
  const { files, filePathMap, shared } = filesWithoutFsRefs(
146680
147100
  edgeFunction.files,
146681
147101
  repoRootPath,
@@ -146694,27 +147114,27 @@ async function writeEdgeFunction(repoRootPath, outputDir, edgeFunction, path11,
146694
147114
  files: void 0,
146695
147115
  type: void 0
146696
147116
  };
146697
- const configPath = (0, import_path21.join)(dest, ".vc-config.json");
147117
+ const configPath = (0, import_path22.join)(dest, ".vc-config.json");
146698
147118
  ops.push(
146699
- import_fs_extra12.default.writeJSON(configPath, config2, {
147119
+ import_fs_extra13.default.writeJSON(configPath, config2, {
146700
147120
  spaces: 2
146701
147121
  })
146702
147122
  );
146703
147123
  await Promise.all(ops);
146704
147124
  }
146705
147125
  async function writeLambda(repoRootPath, outputDir, lambda, path11, functionConfiguration, existingFunctions, standalone = false) {
146706
- const dest = (0, import_path21.join)(outputDir, "functions", `${path11}.func`);
147126
+ const dest = (0, import_path22.join)(outputDir, "functions", `${path11}.func`);
146707
147127
  if (existingFunctions) {
146708
147128
  if (await writeFunctionSymlink(outputDir, dest, lambda, existingFunctions)) {
146709
147129
  return;
146710
147130
  }
146711
147131
  existingFunctions.set(lambda, path11);
146712
147132
  }
146713
- await import_fs_extra12.default.mkdirp(dest);
147133
+ await import_fs_extra13.default.mkdirp(dest);
146714
147134
  const ops = [];
146715
147135
  let filePathMap;
146716
147136
  if (lambda.files) {
146717
- const sharedDest = (0, import_path21.join)(outputDir, "shared");
147137
+ const sharedDest = (0, import_path22.join)(outputDir, "shared");
146718
147138
  const f = filesWithoutFsRefs(
146719
147139
  lambda.files,
146720
147140
  repoRootPath,
@@ -146749,27 +147169,27 @@ async function writeLambda(repoRootPath, outputDir, lambda, path11, functionConf
146749
147169
  files: void 0,
146750
147170
  zipBuffer: void 0
146751
147171
  };
146752
- const configPath = (0, import_path21.join)(dest, ".vc-config.json");
147172
+ const configPath = (0, import_path22.join)(dest, ".vc-config.json");
146753
147173
  ops.push(
146754
- import_fs_extra12.default.writeJSON(configPath, config2, {
147174
+ import_fs_extra13.default.writeJSON(configPath, config2, {
146755
147175
  spaces: 2
146756
147176
  })
146757
147177
  );
146758
147178
  await Promise.all(ops);
146759
147179
  for await (const dir of findDirs(".vercel", dest)) {
146760
- const absDir = (0, import_path21.join)(dest, dir);
146761
- const entries = await import_fs_extra12.default.readdir(absDir);
147180
+ const absDir = (0, import_path22.join)(dest, dir);
147181
+ const entries = await import_fs_extra13.default.readdir(absDir);
146762
147182
  if (entries.includes("cache")) {
146763
147183
  await Promise.all(
146764
- entries.filter((e2) => e2 !== "cache").map((entry) => import_fs_extra12.default.remove((0, import_path21.join)(absDir, entry)))
147184
+ entries.filter((e2) => e2 !== "cache").map((entry) => import_fs_extra13.default.remove((0, import_path22.join)(absDir, entry)))
146765
147185
  );
146766
147186
  } else {
146767
- await import_fs_extra12.default.remove(absDir);
147187
+ await import_fs_extra13.default.remove(absDir);
146768
147188
  }
146769
147189
  }
146770
147190
  }
146771
147191
  async function mergeBuilderOutput(outputDir, buildResult) {
146772
- const absOutputDir = (0, import_path21.resolve)(outputDir);
147192
+ const absOutputDir = (0, import_path22.resolve)(outputDir);
146773
147193
  if (absOutputDir === buildResult.buildOutputPath) {
146774
147194
  return;
146775
147195
  }
@@ -146778,7 +147198,7 @@ async function mergeBuilderOutput(outputDir, buildResult) {
146778
147198
  function getFileExtension(file) {
146779
147199
  let ext = "";
146780
147200
  if (file.type === "FileFsRef") {
146781
- ext = (0, import_path21.extname)(file.fsPath);
147201
+ ext = (0, import_path22.extname)(file.fsPath);
146782
147202
  }
146783
147203
  if (!ext && file.contentType) {
146784
147204
  const e2 = import_mime_types.default.extension(file.contentType);
@@ -146791,7 +147211,7 @@ function getFileExtension(file) {
146791
147211
  async function* findDirs(name, dir, root = dir) {
146792
147212
  let paths;
146793
147213
  try {
146794
- paths = await import_fs_extra12.default.readdir(dir);
147214
+ paths = await import_fs_extra13.default.readdir(dir);
146795
147215
  } catch (err) {
146796
147216
  if (err.code !== "ENOENT") {
146797
147217
  throw err;
@@ -146799,10 +147219,10 @@ async function* findDirs(name, dir, root = dir) {
146799
147219
  paths = [];
146800
147220
  }
146801
147221
  for (const path11 of paths) {
146802
- const abs = (0, import_path21.join)(dir, path11);
147222
+ const abs = (0, import_path22.join)(dir, path11);
146803
147223
  let stat2;
146804
147224
  try {
146805
- stat2 = await import_fs_extra12.default.lstat(abs);
147225
+ stat2 = await import_fs_extra13.default.lstat(abs);
146806
147226
  } catch (err) {
146807
147227
  if (err.code === "ENOENT")
146808
147228
  continue;
@@ -146810,7 +147230,7 @@ async function* findDirs(name, dir, root = dir) {
146810
147230
  }
146811
147231
  if (stat2.isDirectory()) {
146812
147232
  if (path11 === name) {
146813
- yield (0, import_path21.relative)(root, abs);
147233
+ yield (0, import_path22.relative)(root, abs);
146814
147234
  } else {
146815
147235
  yield* findDirs(name, abs, root);
146816
147236
  }
@@ -146828,11 +147248,11 @@ function filesWithoutFsRefs(files, repoRootPath, sharedDest, standalone) {
146828
147248
  if (standalone && sharedDest) {
146829
147249
  shared[path11] = file;
146830
147250
  filePathMap[(0, import_build_utils11.normalizePath)(path11)] = (0, import_build_utils11.normalizePath)(
146831
- (0, import_path21.relative)(repoRootPath, (0, import_path21.join)(sharedDest, path11))
147251
+ (0, import_path22.relative)(repoRootPath, (0, import_path22.join)(sharedDest, path11))
146832
147252
  );
146833
147253
  } else {
146834
147254
  filePathMap[(0, import_build_utils11.normalizePath)(path11)] = (0, import_build_utils11.normalizePath)(
146835
- (0, import_path21.relative)(repoRootPath, file.fsPath)
147255
+ (0, import_path22.relative)(repoRootPath, file.fsPath)
146836
147256
  );
146837
147257
  }
146838
147258
  } else {
@@ -146841,13 +147261,13 @@ function filesWithoutFsRefs(files, repoRootPath, sharedDest, standalone) {
146841
147261
  }
146842
147262
  return { files: out, filePathMap, shared };
146843
147263
  }
146844
- var import_fs_extra12, import_mime_types, import_path21, import_build_utils11, import_promisepipe2, import_client3, normalize2, OUTPUT_DIR;
147264
+ var import_fs_extra13, import_mime_types, import_path22, import_build_utils11, import_promisepipe2, import_client3, normalize2, OUTPUT_DIR;
146845
147265
  var init_write_build_result = __esm({
146846
147266
  "src/util/build/write-build-result.ts"() {
146847
147267
  "use strict";
146848
- import_fs_extra12 = __toESM3(require_lib());
147268
+ import_fs_extra13 = __toESM3(require_lib());
146849
147269
  import_mime_types = __toESM3(require_mime_types());
146850
- import_path21 = require("path");
147270
+ import_path22 = require("path");
146851
147271
  import_build_utils11 = require("@vercel/build-utils");
146852
147272
  import_promisepipe2 = __toESM3(require_promisepipe());
146853
147273
  init_merge();
@@ -146855,8 +147275,8 @@ var init_write_build_result = __esm({
146855
147275
  init_link2();
146856
147276
  import_client3 = __toESM3(require_dist7());
146857
147277
  init_output_manager();
146858
- ({ normalize: normalize2 } = import_path21.posix);
146859
- OUTPUT_DIR = (0, import_path21.join)(VERCEL_DIR2, "output");
147278
+ ({ normalize: normalize2 } = import_path22.posix);
147279
+ OUTPUT_DIR = (0, import_path22.join)(VERCEL_DIR2, "output");
146860
147280
  }
146861
147281
  });
146862
147282
 
@@ -146893,7 +147313,7 @@ async function staticFiles(path11, { src }) {
146893
147313
  const { debug: debug2, time } = output_manager_default;
146894
147314
  let files = [];
146895
147315
  const source = src || ".";
146896
- const search = (0, import_path22.resolve)(path11, source);
147316
+ const search = (0, import_path23.resolve)(path11, source);
146897
147317
  const { ig } = await (0, import_client4.getVercelIgnore)(path11);
146898
147318
  const filter = ig.createFilter();
146899
147319
  const prefixLength = path11.length + 1;
@@ -146925,18 +147345,18 @@ async function explode(paths, { accepts }) {
146925
147345
  return null;
146926
147346
  }
146927
147347
  try {
146928
- s = await import_fs_extra13.default.stat(path11);
147348
+ s = await import_fs_extra14.default.stat(path11);
146929
147349
  } catch (e2) {
146930
147350
  path11 = `${file}.js`;
146931
147351
  try {
146932
- s = await import_fs_extra13.default.stat(path11);
147352
+ s = await import_fs_extra14.default.stat(path11);
146933
147353
  } catch (e22) {
146934
147354
  debug2(`Ignoring invalid file ${file}`);
146935
147355
  return null;
146936
147356
  }
146937
147357
  }
146938
147358
  if (s.isDirectory()) {
146939
- const all = await import_fs_extra13.default.readdir(file);
147359
+ const all = await import_fs_extra14.default.readdir(file);
146940
147360
  const recursive = many(all.map((subdir) => asAbsolute(subdir, file)));
146941
147361
  return recursive;
146942
147362
  }
@@ -146953,12 +147373,12 @@ async function explode(paths, { accepts }) {
146953
147373
  function notNull(value) {
146954
147374
  return value !== null;
146955
147375
  }
146956
- var import_fs_extra13, import_path22, import_client4, asAbsolute;
147376
+ var import_fs_extra14, import_path23, import_client4, asAbsolute;
146957
147377
  var init_get_files = __esm({
146958
147378
  "src/util/get-files.ts"() {
146959
147379
  "use strict";
146960
- import_fs_extra13 = __toESM3(require_lib());
146961
- import_path22 = require("path");
147380
+ import_fs_extra14 = __toESM3(require_lib());
147381
+ import_path23 = require("path");
146962
147382
  import_client4 = __toESM3(require_dist7());
146963
147383
  init_unique_strings();
146964
147384
  init_output_manager();
@@ -146966,41 +147386,11 @@ var init_get_files = __esm({
146966
147386
  if (path11[0] === "/") {
146967
147387
  return path11;
146968
147388
  }
146969
- return (0, import_path22.resolve)(parent, path11);
147389
+ return (0, import_path23.resolve)(parent, path11);
146970
147390
  };
146971
147391
  }
146972
147392
  });
146973
147393
 
146974
- // src/util/parse-target.ts
146975
- function parseTarget({
146976
- flagName,
146977
- flags
146978
- }) {
146979
- const targetFlagName = `--${flagName}`;
146980
- const targetFlagValue = flags[targetFlagName];
146981
- const prodFlagValue = flags["--prod"];
146982
- if (prodFlagValue && targetFlagValue) {
146983
- output_manager_default.warn(
146984
- `Both \`--prod\` and \`${targetFlagName}\` detected. Ignoring \`--prod\`.`
146985
- );
146986
- }
146987
- if (typeof targetFlagValue === "string") {
146988
- output_manager_default.debug(`Setting target to ${targetFlagValue}`);
146989
- return targetFlagValue;
146990
- }
146991
- if (prodFlagValue) {
146992
- output_manager_default.debug("Setting target to production");
146993
- return "production";
146994
- }
146995
- return void 0;
146996
- }
146997
- var init_parse_target = __esm({
146998
- "src/util/parse-target.ts"() {
146999
- "use strict";
147000
- init_output_manager();
147001
- }
147002
- });
147003
-
147004
147394
  // src/util/projects/project-settings.ts
147005
147395
  async function writeProjectSettings(cwd, project, org, isRepoLinked) {
147006
147396
  let analyticsId;
@@ -147024,21 +147414,21 @@ async function writeProjectSettings(cwd, project, org, isRepoLinked) {
147024
147414
  analyticsId
147025
147415
  }
147026
147416
  };
147027
- const path11 = (0, import_path23.join)(cwd, VERCEL_DIR2, VERCEL_DIR_PROJECT);
147028
- return await (0, import_fs_extra14.outputJSON)(path11, projectLinkAndSettings, {
147417
+ const path11 = (0, import_path24.join)(cwd, VERCEL_DIR2, VERCEL_DIR_PROJECT);
147418
+ return await (0, import_fs_extra15.outputJSON)(path11, projectLinkAndSettings, {
147029
147419
  spaces: 2
147030
147420
  });
147031
147421
  }
147032
147422
  async function readProjectSettings(vercelDir) {
147033
147423
  try {
147034
147424
  return JSON.parse(
147035
- await (0, import_fs_extra14.readFile)((0, import_path23.join)(vercelDir, VERCEL_DIR_PROJECT), "utf8")
147425
+ await (0, import_fs_extra15.readFile)((0, import_path24.join)(vercelDir, VERCEL_DIR_PROJECT), "utf8")
147036
147426
  );
147037
147427
  } catch (err) {
147038
- if ((0, import_error_utils15.isErrnoException)(err) && err.code && ["ENOENT", "ENOTDIR"].includes(err.code)) {
147428
+ if ((0, import_error_utils16.isErrnoException)(err) && err.code && ["ENOENT", "ENOTDIR"].includes(err.code)) {
147039
147429
  return null;
147040
147430
  }
147041
- if ((0, import_error_utils15.isError)(err) && err.name === "SyntaxError") {
147431
+ if ((0, import_error_utils16.isError)(err) && err.name === "SyntaxError") {
147042
147432
  return null;
147043
147433
  }
147044
147434
  throw err;
@@ -147064,14 +147454,14 @@ function pickOverrides(vercelConfig) {
147064
147454
  }
147065
147455
  return overrides;
147066
147456
  }
147067
- var import_path23, import_fs_extra14, import_error_utils15;
147457
+ var import_path24, import_fs_extra15, import_error_utils16;
147068
147458
  var init_project_settings = __esm({
147069
147459
  "src/util/projects/project-settings.ts"() {
147070
147460
  "use strict";
147071
- import_path23 = require("path");
147072
- import_fs_extra14 = __toESM3(require_lib());
147461
+ import_path24 = require("path");
147462
+ import_fs_extra15 = __toESM3(require_lib());
147073
147463
  init_link2();
147074
- import_error_utils15 = __toESM3(require_dist2());
147464
+ import_error_utils16 = __toESM3(require_dist2());
147075
147465
  }
147076
147466
  });
147077
147467
 
@@ -147306,309 +147696,6 @@ var init_validate_config = __esm({
147306
147696
  }
147307
147697
  });
147308
147698
 
147309
- // src/util/env/get-env-records.ts
147310
- async function getEnvRecords(client2, projectId, source, {
147311
- target,
147312
- gitBranch,
147313
- decrypt
147314
- } = {}) {
147315
- output_manager_default.debug(
147316
- `Fetching Environment Variables of project ${projectId} and target ${target}`
147317
- );
147318
- const query = new import_url9.URLSearchParams();
147319
- if (target) {
147320
- let targetParam = "target";
147321
- if (target !== "production" && target !== "preview" && target !== "development") {
147322
- targetParam = "customEnvironmentId";
147323
- }
147324
- query.set(targetParam, target);
147325
- }
147326
- if (gitBranch) {
147327
- query.set("gitBranch", gitBranch);
147328
- }
147329
- if (decrypt) {
147330
- query.set("decrypt", decrypt.toString());
147331
- }
147332
- if (source) {
147333
- query.set("source", source);
147334
- }
147335
- const url3 = `/v10/projects/${projectId}/env?${query}`;
147336
- return client2.fetch(url3);
147337
- }
147338
- async function pullEnvRecords(client2, projectId, source, { target, gitBranch } = {}) {
147339
- output_manager_default.debug(
147340
- `Fetching Environment Variables of project ${projectId} and target ${target}`
147341
- );
147342
- const query = new import_url9.URLSearchParams();
147343
- let url3 = `/v3/env/pull/${projectId}`;
147344
- if (target) {
147345
- url3 += `/${encodeURIComponent(target)}`;
147346
- if (gitBranch) {
147347
- url3 += `/${encodeURIComponent(gitBranch)}`;
147348
- }
147349
- }
147350
- if (source) {
147351
- query.set("source", source);
147352
- }
147353
- if (Array.from(query).length > 0) {
147354
- url3 += `?${query}`;
147355
- }
147356
- return client2.fetch(url3);
147357
- }
147358
- var import_url9;
147359
- var init_get_env_records = __esm({
147360
- "src/util/env/get-env-records.ts"() {
147361
- "use strict";
147362
- import_url9 = require("url");
147363
- init_output_manager();
147364
- }
147365
- });
147366
-
147367
- // src/util/projects/format-project.ts
147368
- function formatProject(orgSlug, projectSlug, options) {
147369
- const orgProjectSlug = `${orgSlug}/${projectSlug}`;
147370
- const projectUrl = `https://vercel.com/${orgProjectSlug}`;
147371
- const projectSlugLink = output_manager_default.link(import_chalk46.default.bold(orgProjectSlug), projectUrl, {
147372
- fallback: () => import_chalk46.default.bold(orgProjectSlug),
147373
- color: false,
147374
- ...options
147375
- });
147376
- return projectSlugLink;
147377
- }
147378
- var import_chalk46;
147379
- var init_format_project = __esm({
147380
- "src/util/projects/format-project.ts"() {
147381
- "use strict";
147382
- import_chalk46 = __toESM3(require_source());
147383
- init_output_manager();
147384
- }
147385
- });
147386
-
147387
- // src/util/target/standard-environments.ts
147388
- var STANDARD_ENVIRONMENTS;
147389
- var init_standard_environments = __esm({
147390
- "src/util/target/standard-environments.ts"() {
147391
- "use strict";
147392
- STANDARD_ENVIRONMENTS = [
147393
- "production",
147394
- "preview",
147395
- "development"
147396
- ];
147397
- }
147398
- });
147399
-
147400
- // src/util/telemetry/commands/env/pull.ts
147401
- var EnvPullTelemetryClient;
147402
- var init_pull = __esm({
147403
- "src/util/telemetry/commands/env/pull.ts"() {
147404
- "use strict";
147405
- init_telemetry();
147406
- init_standard_environments();
147407
- EnvPullTelemetryClient = class extends TelemetryClient {
147408
- trackCliArgumentFilename(filename) {
147409
- if (filename) {
147410
- this.trackCliArgument({
147411
- arg: "filename",
147412
- value: this.redactedValue
147413
- });
147414
- }
147415
- }
147416
- trackCliOptionEnvironment(environment) {
147417
- if (environment) {
147418
- this.trackCliOption({
147419
- option: "environment",
147420
- value: STANDARD_ENVIRONMENTS.includes(
147421
- environment
147422
- ) ? environment : this.redactedValue
147423
- });
147424
- }
147425
- }
147426
- trackCliOptionGitBranch(gitBranch) {
147427
- if (gitBranch) {
147428
- this.trackCliOption({
147429
- option: "git-branch",
147430
- value: this.redactedValue
147431
- });
147432
- }
147433
- }
147434
- trackCliFlagYes(yes) {
147435
- if (yes) {
147436
- this.trackCliFlag("yes");
147437
- }
147438
- }
147439
- };
147440
- }
147441
- });
147442
-
147443
- // src/commands/env/pull.ts
147444
- function readHeadSync(path11, length) {
147445
- const buffer = Buffer.alloc(length);
147446
- const fd = (0, import_fs5.openSync)(path11, "r");
147447
- try {
147448
- (0, import_fs5.readSync)(fd, buffer, 0, buffer.length, null);
147449
- } finally {
147450
- (0, import_fs5.closeSync)(fd);
147451
- }
147452
- return buffer.toString();
147453
- }
147454
- function tryReadHeadSync(path11, length) {
147455
- try {
147456
- return readHeadSync(path11, length);
147457
- } catch (err) {
147458
- if (!(0, import_error_utils16.isErrnoException)(err) || err.code !== "ENOENT") {
147459
- throw err;
147460
- }
147461
- }
147462
- }
147463
- async function pull(client2, argv) {
147464
- const telemetryClient = new EnvPullTelemetryClient({
147465
- opts: {
147466
- store: client2.telemetryEventStore
147467
- }
147468
- });
147469
- let parsedArgs;
147470
- const flagsSpecification = getFlagsSpecification(pullSubcommand.options);
147471
- try {
147472
- parsedArgs = parseArguments(argv, flagsSpecification);
147473
- } catch (err) {
147474
- printError(err);
147475
- return 1;
147476
- }
147477
- const { args: args2, flags: opts } = parsedArgs;
147478
- if (args2.length > 1) {
147479
- output_manager_default.error(
147480
- `Invalid number of arguments. Usage: ${getCommandName(`env pull <file>`)}`
147481
- );
147482
- return 1;
147483
- }
147484
- const [rawFilename] = args2;
147485
- const filename = rawFilename || ".env.local";
147486
- const skipConfirmation = opts["--yes"];
147487
- const gitBranch = opts["--git-branch"];
147488
- telemetryClient.trackCliArgumentFilename(args2[0]);
147489
- telemetryClient.trackCliFlagYes(skipConfirmation);
147490
- telemetryClient.trackCliOptionGitBranch(gitBranch);
147491
- telemetryClient.trackCliOptionEnvironment(opts["--environment"]);
147492
- const link4 = await getLinkedProject(client2);
147493
- if (link4.status === "error") {
147494
- return link4.exitCode;
147495
- } else if (link4.status === "not_linked") {
147496
- output_manager_default.error(
147497
- `Your codebase isn\u2019t linked to a project on Vercel. Run ${getCommandName(
147498
- "link"
147499
- )} to begin.`
147500
- );
147501
- return 1;
147502
- }
147503
- client2.config.currentTeam = link4.org.type === "team" ? link4.org.id : void 0;
147504
- const environment = parseTarget({
147505
- flagName: "environment",
147506
- flags: opts
147507
- }) || "development";
147508
- await envPullCommandLogic(
147509
- client2,
147510
- filename,
147511
- !!skipConfirmation,
147512
- environment,
147513
- link4,
147514
- gitBranch,
147515
- client2.cwd,
147516
- "vercel-cli:env:pull"
147517
- );
147518
- return 0;
147519
- }
147520
- async function envPullCommandLogic(client2, filename, skipConfirmation, environment, link4, gitBranch, cwd, source) {
147521
- const fullPath = (0, import_path24.resolve)(cwd, filename);
147522
- const head = tryReadHeadSync(fullPath, Buffer.byteLength(CONTENTS_PREFIX));
147523
- const exists = typeof head !== "undefined";
147524
- if (head === CONTENTS_PREFIX) {
147525
- output_manager_default.log(`Overwriting existing ${import_chalk47.default.bold(filename)} file`);
147526
- } else if (exists && !skipConfirmation && !await client2.input.confirm(
147527
- `Found existing file ${param(filename)}. Do you want to overwrite?`,
147528
- false
147529
- )) {
147530
- output_manager_default.log("Canceled");
147531
- return;
147532
- }
147533
- const projectSlugLink = formatProject(link4.org.slug, link4.project.name);
147534
- output_manager_default.log(
147535
- `Downloading \`${import_chalk47.default.cyan(
147536
- environment
147537
- )}\` Environment Variables for ${projectSlugLink}`
147538
- );
147539
- const pullStamp = stamp_default();
147540
- output_manager_default.spinner("Downloading");
147541
- const records = (await pullEnvRecords(client2, link4.project.id, source, {
147542
- target: environment || "development",
147543
- gitBranch
147544
- })).env;
147545
- let deltaString = "";
147546
- let oldEnv;
147547
- if (exists) {
147548
- oldEnv = await createEnvObject(fullPath);
147549
- if (oldEnv) {
147550
- const newEnv = (0, import_json_parse_better_errors2.default)(JSON.stringify(records).replace(/\\"/g, ""));
147551
- deltaString = buildDeltaString(oldEnv, newEnv);
147552
- }
147553
- }
147554
- const contents = CONTENTS_PREFIX + Object.keys(records).sort().filter((key) => !VARIABLES_TO_IGNORE.includes(key)).map((key) => `${key}="${escapeValue(records[key])}"`).join("\n") + "\n";
147555
- await (0, import_fs_extra15.outputFile)(fullPath, contents, "utf8");
147556
- if (deltaString) {
147557
- output_manager_default.print("\n" + deltaString);
147558
- } else if (oldEnv && exists) {
147559
- output_manager_default.log("No changes found.");
147560
- }
147561
- let isGitIgnoreUpdated = false;
147562
- if (filename === ".env.local") {
147563
- const rootPath = link4.repoRoot ?? cwd;
147564
- isGitIgnoreUpdated = await addToGitIgnore(rootPath, ".env*.local");
147565
- }
147566
- output_manager_default.print(
147567
- `${prependEmoji(
147568
- `${exists ? "Updated" : "Created"} ${import_chalk47.default.bold(filename)} file ${isGitIgnoreUpdated ? "and added it to .gitignore" : ""} ${import_chalk47.default.gray(pullStamp())}`,
147569
- emoji("success")
147570
- )}
147571
- `
147572
- );
147573
- }
147574
- function escapeValue(value) {
147575
- return value ? value.replace(new RegExp("\n", "g"), "\\n").replace(new RegExp("\r", "g"), "\\r") : "";
147576
- }
147577
- var import_chalk47, import_fs_extra15, import_fs5, import_path24, import_error_utils16, import_json_parse_better_errors2, CONTENTS_PREFIX, VARIABLES_TO_IGNORE;
147578
- var init_pull2 = __esm({
147579
- "src/commands/env/pull.ts"() {
147580
- "use strict";
147581
- import_chalk47 = __toESM3(require_source());
147582
- import_fs_extra15 = __toESM3(require_lib());
147583
- import_fs5 = require("fs");
147584
- import_path24 = require("path");
147585
- init_emoji();
147586
- init_param();
147587
- init_stamp();
147588
- init_pkg_name();
147589
- init_get_env_records();
147590
- init_diff_env_files();
147591
- import_error_utils16 = __toESM3(require_dist2());
147592
- init_add_to_gitignore();
147593
- import_json_parse_better_errors2 = __toESM3(require_json_parse_better_errors());
147594
- init_format_project();
147595
- init_output_manager();
147596
- init_pull();
147597
- init_command11();
147598
- init_get_args();
147599
- init_get_flags_specification();
147600
- init_error2();
147601
- init_parse_target();
147602
- init_link2();
147603
- CONTENTS_PREFIX = "# Created by Vercel CLI\n";
147604
- VARIABLES_TO_IGNORE = [
147605
- "VERCEL_ANALYTICS_ID",
147606
- "VERCEL_SPEED_INSIGHTS_ID",
147607
- "VERCEL_WEB_ANALYTICS_ID"
147608
- ];
147609
- }
147610
- });
147611
-
147612
147699
  // src/util/input/input-project.ts
147613
147700
  async function inputProject(client2, org, detectedProjectName, autoConfirm = false) {
147614
147701
  const slugifiedName = (0, import_slugify2.default)(detectedProjectName);
@@ -148097,7 +148184,8 @@ async function setupAndLink(client2, path11, {
148097
148184
  },
148098
148185
  project.name,
148099
148186
  org.slug,
148100
- successEmoji
148187
+ successEmoji,
148188
+ autoConfirm
148101
148189
  );
148102
148190
  return { status: "linked", org, project };
148103
148191
  }
@@ -148166,7 +148254,8 @@ async function setupAndLink(client2, path11, {
148166
148254
  },
148167
148255
  project.name,
148168
148256
  org.slug,
148169
- successEmoji
148257
+ successEmoji,
148258
+ autoConfirm
148170
148259
  );
148171
148260
  await connectGitRepository(client2, path11, project, autoConfirm, org);
148172
148261
  return { status: "linked", org, project };
@@ -151508,7 +151597,7 @@ async function printEvents(client2, urlOrDeploymentId, { mode, onEvent, quiet, f
151508
151597
  retries: 4,
151509
151598
  onRetry: (err) => {
151510
151599
  if (!quiet && o) {
151511
- process.stdout.write((0, import_ansi_escapes6.eraseLines)(o + 1));
151600
+ process.stdout.write((0, import_ansi_escapes7.eraseLines)(o + 1));
151512
151601
  o = 0;
151513
151602
  }
151514
151603
  log2(`Deployment events polling error: ${err.message}`);
@@ -151516,14 +151605,14 @@ async function printEvents(client2, urlOrDeploymentId, { mode, onEvent, quiet, f
151516
151605
  }
151517
151606
  );
151518
151607
  }
151519
- var import_url10, import_async_retry4, import_jsonlines, import_ansi_escapes6, events_default;
151608
+ var import_url10, import_async_retry4, import_jsonlines, import_ansi_escapes7, events_default;
151520
151609
  var init_events = __esm({
151521
151610
  "src/util/events.ts"() {
151522
151611
  "use strict";
151523
151612
  import_url10 = require("url");
151524
151613
  import_async_retry4 = __toESM3(require_dist5());
151525
151614
  import_jsonlines = __toESM3(require_jsonlines());
151526
- import_ansi_escapes6 = __toESM3(require_ansi_escapes());
151615
+ import_ansi_escapes7 = __toESM3(require_ansi_escapes());
151527
151616
  init_get_deployment();
151528
151617
  init_get_scope();
151529
151618
  init_output_manager();
@@ -176687,12 +176776,23 @@ async function add4(client2, argv) {
176687
176776
  );
176688
176777
  return 1;
176689
176778
  }
176779
+ let type = opts["--sensitive"] ? "sensitive" : "encrypted";
176690
176780
  let envValue;
176691
176781
  if (stdInput) {
176692
176782
  envValue = stdInput;
176693
176783
  } else {
176694
- envValue = await client2.input.text({
176695
- message: `What's the value of ${envName}?`
176784
+ if (type === "encrypted") {
176785
+ const isSensitive = await client2.input.confirm(
176786
+ `Your value will be encrypted. Mark as sensitive?`,
176787
+ false
176788
+ );
176789
+ if (isSensitive) {
176790
+ type = "sensitive";
176791
+ }
176792
+ }
176793
+ envValue = await client2.input.password({
176794
+ message: `What's the value of ${envName}?`,
176795
+ mask: true
176696
176796
  });
176697
176797
  }
176698
176798
  while (envTargets.length === 0) {
@@ -176709,7 +176809,6 @@ async function add4(client2, argv) {
176709
176809
  message: `Add ${envName} to which Git branch? (leave empty for all Preview branches)?`
176710
176810
  });
176711
176811
  }
176712
- const type = opts["--sensitive"] ? "sensitive" : "encrypted";
176713
176812
  const upsert = opts["--force"] ? "true" : "";
176714
176813
  const addStamp = stamp_default();
176715
176814
  try {