vercel 59.4.0 → 59.6.2

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 (137) hide show
  1. package/dist/chunks/{add-FQMB3XPM.js → add-4GQZ22ZN.js} +20 -16
  2. package/dist/chunks/{add-73X2SKBH.js → add-HJSEM4YJ.js} +17 -13
  3. package/dist/chunks/{add-QJ3WT4FW.js → add-SIGUSM3Y.js} +21 -17
  4. package/dist/chunks/{build-YUYCLCXD.js → build-XOMJDX4M.js} +18 -15
  5. package/dist/chunks/{chunk-F7OXZLY2.js → chunk-26XDDLXM.js} +2 -2
  6. package/dist/chunks/{chunk-VCE6QKFE.js → chunk-2O5J3KMT.js} +4 -4
  7. package/dist/chunks/{chunk-XI6NJLI4.js → chunk-2YRAWYGE.js} +3 -3
  8. package/dist/chunks/{chunk-X6O6XJEA.js → chunk-37V5P4VO.js} +16 -14
  9. package/dist/chunks/{chunk-EB7NJKPL.js → chunk-3F5EGINT.js} +3 -3
  10. package/dist/chunks/{chunk-RIB4S2IB.js → chunk-3HZLXCVL.js} +1 -1
  11. package/dist/chunks/{chunk-KQRVZWJU.js → chunk-3T7WSWZH.js} +1 -1
  12. package/dist/chunks/{chunk-3KNPVXJ3.js → chunk-4KD5BYHB.js} +1 -1
  13. package/dist/chunks/{chunk-XLKFJPMT.js → chunk-57RHXXXG.js} +1 -1
  14. package/dist/chunks/chunk-5GGUB4EO.js +31 -0
  15. package/dist/chunks/{chunk-R6IGDGX3.js → chunk-5XECIWME.js} +1 -1
  16. package/dist/chunks/{chunk-KAYSW4CJ.js → chunk-6JPVTPTU.js} +3 -3
  17. package/dist/chunks/{chunk-ZFWNMVNR.js → chunk-6M2KZUED.js} +19 -8
  18. package/dist/chunks/{chunk-HT2XWSAJ.js → chunk-7AEEQOD4.js} +2 -29
  19. package/dist/chunks/{chunk-HURL5EBN.js → chunk-7HE63HCR.js} +124 -161
  20. package/dist/chunks/chunk-7Q45OKWR.js +149 -0
  21. package/dist/chunks/{chunk-RI7KKKII.js → chunk-7R6M3BHM.js} +4 -18
  22. package/dist/chunks/{chunk-XBN2O34P.js → chunk-7ST552E3.js} +17 -4
  23. package/dist/chunks/{chunk-JKQWQA2T.js → chunk-AINIBIP4.js} +1 -1
  24. package/dist/chunks/{chunk-CV4S27SS.js → chunk-ASBP32T6.js} +1 -1
  25. package/dist/chunks/chunk-AYLY3ZVL.js +104 -0
  26. package/dist/chunks/{chunk-SOFC4MLS.js → chunk-BMKU5KEL.js} +9 -569
  27. package/dist/chunks/{chunk-KDYRLN6H.js → chunk-C5HKWXRR.js} +1 -1
  28. package/dist/chunks/{chunk-2MF3ZAVW.js → chunk-CJV7J7B5.js} +6 -6
  29. package/dist/chunks/{chunk-HJVTLJHO.js → chunk-DE7MBNHQ.js} +6 -6
  30. package/dist/chunks/{chunk-3L2YLLHC.js → chunk-DWIC7MRV.js} +2 -2
  31. package/dist/chunks/{chunk-GFCTRJI5.js → chunk-EZKW5YJ2.js} +1 -1
  32. package/dist/chunks/{chunk-MWYQ24FO.js → chunk-FRAXI2WT.js} +3 -3
  33. package/dist/chunks/{chunk-DDIZGOCK.js → chunk-FRZULOVH.js} +8 -6
  34. package/dist/chunks/{chunk-Y3J4VU2H.js → chunk-FWKSJYDV.js} +2 -2
  35. package/dist/chunks/chunk-FXD67VN5.js +467 -0
  36. package/dist/chunks/{chunk-EB5NBVTV.js → chunk-GISTGGBO.js} +8 -8
  37. package/dist/chunks/chunk-GY5I4AYD.js +122 -0
  38. package/dist/chunks/{chunk-PD4DYNSB.js → chunk-GZQQNLF5.js} +5 -5
  39. package/dist/chunks/{chunk-PIMIKY4X.js → chunk-IJ4X426J.js} +1 -1
  40. package/dist/chunks/{chunk-KSZ4MNHO.js → chunk-JH4WQRIU.js} +2 -2
  41. package/dist/chunks/{chunk-TVXCXIRO.js → chunk-L3UXB2CW.js} +1 -1
  42. package/dist/chunks/{chunk-O5DLWLT7.js → chunk-LXZVOR6F.js} +9 -9
  43. package/dist/chunks/{chunk-EG5BSAXD.js → chunk-MTWHQEXI.js} +1 -1
  44. package/dist/chunks/{chunk-WC7IINFV.js → chunk-NFU4XJIR.js} +1 -1
  45. package/dist/chunks/{chunk-TH2XUVDP.js → chunk-NGGLYKNU.js} +30 -6
  46. package/dist/chunks/{chunk-2PX6N4FE.js → chunk-NGNN6WF2.js} +10 -10
  47. package/dist/chunks/{chunk-GGPE5377.js → chunk-O26N2UPI.js} +1 -1
  48. package/dist/chunks/chunk-O75LSD3C.js +34 -0
  49. package/dist/chunks/{chunk-BBSS3XIW.js → chunk-OQ3C5VXZ.js} +1 -1
  50. package/dist/chunks/{chunk-M22O6CYY.js → chunk-POOO7W47.js} +1 -1
  51. package/dist/chunks/{chunk-LKTQR5JE.js → chunk-PRH6KRUT.js} +2 -2
  52. package/dist/chunks/chunk-Q2DGFCO7.js +579 -0
  53. package/dist/chunks/{chunk-OX7KI3LF.js → chunk-QFAS4OVW.js} +18 -0
  54. package/dist/chunks/{chunk-CHEZBD7H.js → chunk-R5PULMHT.js} +3 -3
  55. package/dist/chunks/{chunk-VAFU7DXZ.js → chunk-RKDCNQ4S.js} +1 -91
  56. package/dist/chunks/{chunk-BLYBHFIE.js → chunk-SF3AYAIF.js} +61 -24
  57. package/dist/chunks/{chunk-GMWRTZVZ.js → chunk-SLPSPYVR.js} +1 -1
  58. package/dist/chunks/{chunk-J5Y2QGGU.js → chunk-SWI6F4X3.js} +2 -2
  59. package/dist/chunks/chunk-V3MDDR2X.js +249 -0
  60. package/dist/chunks/{chunk-HMJVUXE6.js → chunk-VJ5NAOWB.js} +867 -625
  61. package/dist/chunks/{chunk-O5GNPPTU.js → chunk-VP5Y3SZG.js} +1 -1
  62. package/dist/chunks/{chunk-G75NFPIT.js → chunk-WNAKOXGK.js} +1 -1
  63. package/dist/chunks/{chunk-NP6BQPCN.js → chunk-WZ2S3A2A.js} +8 -6
  64. package/dist/chunks/{chunk-7QVJTI5H.js → chunk-XDGOOW3K.js} +1 -1
  65. package/dist/chunks/{chunk-UMA66MKW.js → chunk-XM3LOQIX.js} +1 -1
  66. package/dist/chunks/{chunk-CYNB6LL4.js → chunk-XNFHNTS2.js} +1 -1
  67. package/dist/chunks/{chunk-VDJN4WKH.js → chunk-XRWOTCDO.js} +1 -1
  68. package/dist/chunks/{chunk-UV2ZMFVG.js → chunk-YJKZQEHS.js} +2 -2
  69. package/dist/chunks/{chunk-STPH4Y62.js → chunk-YJUO3EKH.js} +1 -1
  70. package/dist/chunks/{chunk-Y42SPI2H.js → chunk-ZNMTDLYH.js} +6 -6
  71. package/dist/chunks/{chunk-VLPLCJZC.js → chunk-ZSFEACZU.js} +1 -1
  72. package/dist/chunks/{clear-USQM5VW5.js → clear-BWT2FJY4.js} +17 -13
  73. package/dist/chunks/{compile-vercel-config-2JNYMI6W.js → compile-vercel-config-DGM4NISW.js} +10 -7
  74. package/dist/chunks/{config-VTRIDLY4.js → config-NJAN3RMU.js} +20 -16
  75. package/dist/chunks/config-RSE6Z4LB.js +122 -0
  76. package/dist/chunks/{constants-YMCRE6IG.js → constants-WEQVJSYS.js} +1 -1
  77. package/dist/chunks/{delete-ILLSBCVQ.js → delete-LROBRBAH.js} +15 -11
  78. package/dist/chunks/{delete-VTPHK3EB.js → delete-SSL2PK2F.js} +12 -9
  79. package/dist/chunks/{disable-VTOMO64V.js → disable-ASG5JDZR.js} +12 -9
  80. package/dist/chunks/{discard-ZIOZ34ZI.js → discard-PV47B6IL.js} +12 -9
  81. package/dist/chunks/{edit-E3AMR4KM.js → edit-5ATYIOLX.js} +14 -11
  82. package/dist/chunks/{edit-JMZ5XWVW.js → edit-REI7HXGG.js} +16 -12
  83. package/dist/chunks/{enable-A4PMZ7QZ.js → enable-LZXL7XAG.js} +12 -9
  84. package/dist/chunks/{exec-CNBOV577.js → exec-XH4K34JM.js} +3 -3
  85. package/dist/chunks/{export-Y6AJ3WRZ.js → export-ZAZFQU2E.js} +12 -9
  86. package/dist/chunks/{image-26BKPAUB.js → image-QPHN5V7L.js} +7 -6
  87. package/dist/chunks/{import-builders-3H7J2SEK.js → import-builders-W3YE2V6A.js} +12 -9
  88. package/dist/chunks/{inspect-7DGKYHKW.js → inspect-BFGK72WY.js} +18 -14
  89. package/dist/chunks/{inspect-OEY4DJRI.js → inspect-FRXJRM6T.js} +18 -14
  90. package/dist/chunks/{inspect-ZW5N6O5P.js → inspect-RDMC2Z3Q.js} +17 -13
  91. package/dist/chunks/{inspect-GJFVAZIJ.js → inspect-SJEZVGPK.js} +20 -16
  92. package/dist/chunks/{inspect-N3E2PO6K.js → inspect-SSOM3FXS.js} +17 -13
  93. package/dist/chunks/{list-MIQ5D6PM.js → list-2HTR7Q3J.js} +18 -14
  94. package/dist/chunks/{list-2VTCNQEB.js → list-PHDUZVMR.js} +15 -11
  95. package/dist/chunks/{list-DTJBW7OQ.js → list-W33GXKDA.js} +18 -14
  96. package/dist/chunks/{login-L34UHAU5.js → login-JWAFHVDG.js} +30 -17
  97. package/dist/chunks/{ls-OBUDC4SB.js → ls-3AN2DZHN.js} +20 -15
  98. package/dist/chunks/{ls-SXJFBLUT.js → ls-3MH2OCP3.js} +20 -15
  99. package/dist/chunks/ls-D2POUHI7.js +176 -0
  100. package/dist/chunks/{ls-VDYUFSSC.js → ls-KDFU224B.js} +20 -15
  101. package/dist/chunks/{ls-OKO4IHWB.js → ls-KX2VBOGV.js} +18 -14
  102. package/dist/chunks/{ls-NCPQY4FV.js → ls-RWKNJQNT.js} +23 -18
  103. package/dist/chunks/{open-V5JDGXUP.js → open-IEYRB6RL.js} +15 -11
  104. package/dist/chunks/{permissions-6CPRPPBY.js → permissions-ZWZUMEHR.js} +10 -9
  105. package/dist/chunks/{publish-R27DPHFO.js → publish-UWZYBDHK.js} +12 -9
  106. package/dist/chunks/{push-VLVTBS42.js → push-IAEQ3FBF.js} +18 -15
  107. package/dist/chunks/{query-IVVRYMJN.js → query-NNOZYSED.js} +18 -14
  108. package/dist/chunks/{reorder-LJ2RBZM2.js → reorder-TKBM244W.js} +12 -9
  109. package/dist/chunks/{reply-USAISZYC.js → reply-FLBSBMTW.js} +16 -12
  110. package/dist/chunks/{resolve-CRCJYVS5.js → resolve-GJYPMWUE.js} +15 -11
  111. package/dist/chunks/{restore-6PBPEAMU.js → restore-PNI3TM3U.js} +12 -9
  112. package/dist/chunks/{rm-HHELZB7R.js → rm-76CSSSSV.js} +17 -13
  113. package/dist/chunks/{rm-TWU3JR6Z.js → rm-FN7LTIIL.js} +17 -13
  114. package/dist/chunks/{rm-KGOEOWVK.js → rm-FTE33UHE.js} +16 -12
  115. package/dist/chunks/rm-FXA5DLXQ.js +315 -0
  116. package/dist/chunks/{rm-EOD7RDSO.js → rm-PGJ4KR6U.js} +20 -16
  117. package/dist/chunks/{routes-SZI2G4SE.js → routes-2OLIBRYX.js} +3 -3
  118. package/dist/chunks/{rule-inspect-WFTVRK6B.js → rule-inspect-LJIGPTWS.js} +18 -14
  119. package/dist/chunks/{rules-AQYTFJI6.js → rules-6BMNO6M5.js} +11 -10
  120. package/dist/chunks/{schema-LUVFYPWN.js → schema-45SJNY5L.js} +9 -7
  121. package/dist/chunks/{schema-ZCDCJC7E.js → schema-HATXEQDP.js} +14 -11
  122. package/dist/chunks/set-C3UQUQ42.js +243 -0
  123. package/dist/chunks/{tags-RCNRFX7U.js → tags-BTVDROFG.js} +6 -5
  124. package/dist/chunks/{types-AJHILHO5.js → types-JGANJ5EQ.js} +12 -8
  125. package/dist/chunks/{update-I7QGAOYF.js → update-B6PSOHUW.js} +19 -15
  126. package/dist/commands/build/builder-worker.cjs +281 -0
  127. package/dist/commands/build/index.js +695 -236
  128. package/dist/commands/deploy/index.js +131 -50
  129. package/dist/commands/dev/index.js +677 -144
  130. package/dist/commands/env/index.js +1199 -565
  131. package/dist/commands/link/index.js +27 -22
  132. package/dist/commands/list/index.js +21 -14
  133. package/dist/commands-bulk.js +2051 -1019
  134. package/dist/help.js +1 -1
  135. package/dist/index.js +39 -33
  136. package/dist/version.mjs +1 -1
  137. package/package.json +48 -48
@@ -4,17 +4,6 @@ import { dirname as __dirname_ } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  const __filename = __fileURLToPath(import.meta.url);
6
6
  const __dirname = __dirname_(__filename);
7
- import {
8
- getCommandName,
9
- parseRetryAfterHeaderAsMillis,
10
- require_bytes
11
- } from "./chunk-SOFC4MLS.js";
12
- import {
13
- output_manager_default
14
- } from "./chunk-OX7KI3LF.js";
15
- import {
16
- require_source
17
- } from "./chunk-S7KYDPEM.js";
18
7
  import {
19
8
  __commonJS,
20
9
  __require,
@@ -1876,89 +1865,10 @@ function table(rows, opts) {
1876
1865
  return table2.toString();
1877
1866
  }
1878
1867
 
1879
- // src/util/output/error.ts
1880
- var import_chalk = __toESM(require_source(), 1);
1881
-
1882
- // src/util/error.ts
1883
- var import_bytes = __toESM(require_bytes(), 1);
1884
- async function responseError(res, fallbackMessage = null, parsedBody = {}) {
1885
- let message = "";
1886
- let bodyError;
1887
- if (res.status >= 400 && res.status < 500) {
1888
- let body;
1889
- try {
1890
- body = await res.json();
1891
- } catch (_err) {
1892
- body = parsedBody;
1893
- }
1894
- bodyError = body.error || body.err || {};
1895
- message = bodyError.message;
1896
- }
1897
- if (!message) {
1898
- message = fallbackMessage === null ? "Response Error" : fallbackMessage;
1899
- }
1900
- const err = new Error(`${message} (${res.status})`);
1901
- err.status = res.status;
1902
- err.serverMessage = message;
1903
- if (bodyError) {
1904
- for (const field of Object.keys(bodyError)) {
1905
- if (field !== "message") {
1906
- err[field] = bodyError[field];
1907
- }
1908
- }
1909
- }
1910
- if (res.status === 429 || res.status === 503) {
1911
- const parsed = parseRetryAfterHeaderAsMillis(
1912
- res.headers.get("Retry-After")
1913
- );
1914
- err.retryAfterMs = parsed ?? (res.status === 429 ? 0 : void 0);
1915
- }
1916
- return err;
1917
- }
1918
- function toEnumerableError(err) {
1919
- const enumerable = {};
1920
- enumerable.name = err.name;
1921
- for (const key of Object.getOwnPropertyNames(err)) {
1922
- enumerable[key] = err[key];
1923
- }
1924
- return enumerable;
1925
- }
1926
- function printError(error2) {
1927
- if (typeof error2 === "string") {
1928
- error2 = new Error(error2);
1929
- }
1930
- const apiError = error2;
1931
- const { message, stack, status, code, sizeLimit } = apiError;
1932
- output_manager_default.debug(`handling error: ${stack}`);
1933
- if (message === "User force closed the prompt with 0 null") {
1934
- return;
1935
- }
1936
- if (status === 403) {
1937
- output_manager_default.error(
1938
- message || `Authentication error. Run ${getCommandName("login")} to log-in again.`
1939
- );
1940
- } else if (status === 429) {
1941
- output_manager_default.error(message);
1942
- } else if (code === "size_limit_exceeded") {
1943
- output_manager_default.error(`File size limit exceeded (${(0, import_bytes.default)(sizeLimit)})`);
1944
- } else if (message) {
1945
- output_manager_default.prettyError(apiError);
1946
- } else if (status === 500) {
1947
- output_manager_default.error("Unexpected server error. Please retry.");
1948
- } else if (code === "USER_ABORT") {
1949
- output_manager_default.log("Canceled");
1950
- } else {
1951
- output_manager_default.error(`Unexpected error. Please try again later. (${message})`);
1952
- }
1953
- }
1954
-
1955
1868
  export {
1956
1869
  require_strip_ansi,
1957
1870
  require_string_width,
1958
1871
  require_cli_table3,
1959
1872
  noBorderChars,
1960
- table,
1961
- responseError,
1962
- toEnumerableError,
1963
- printError
1873
+ table
1964
1874
  };
@@ -9,22 +9,19 @@ import {
9
9
  } from "./chunk-PRWJUY5U.js";
10
10
  import {
11
11
  progress
12
- } from "./chunk-EB5NBVTV.js";
12
+ } from "./chunk-GISTGGBO.js";
13
13
  import {
14
14
  isJSONObject,
15
15
  printIndications,
16
16
  require_dist as require_dist2,
17
17
  sleep
18
- } from "./chunk-O5DLWLT7.js";
18
+ } from "./chunk-LXZVOR6F.js";
19
19
  import {
20
20
  suggestNextCommands
21
- } from "./chunk-XBN2O34P.js";
21
+ } from "./chunk-7ST552E3.js";
22
22
  import {
23
23
  CommandTimeout
24
- } from "./chunk-HURL5EBN.js";
25
- import {
26
- showPluginTipIfNeeded
27
- } from "./chunk-HT2XWSAJ.js";
24
+ } from "./chunk-7HE63HCR.js";
28
25
  import {
29
26
  stamp_default
30
27
  } from "./chunk-64IF634X.js";
@@ -38,14 +35,19 @@ import {
38
35
  require_dist as require_dist3,
39
36
  require_pluralize,
40
37
  ua_default
41
- } from "./chunk-HMJVUXE6.js";
38
+ } from "./chunk-VJ5NAOWB.js";
39
+ import {
40
+ withGlobalFlags
41
+ } from "./chunk-NGGLYKNU.js";
42
42
  import {
43
43
  require_ms
44
44
  } from "./chunk-GGP5R3FU.js";
45
45
  import {
46
- require_strip_ansi,
47
46
  responseError
48
- } from "./chunk-VAFU7DXZ.js";
47
+ } from "./chunk-AYLY3ZVL.js";
48
+ import {
49
+ require_strip_ansi
50
+ } from "./chunk-RKDCNQ4S.js";
49
51
  import {
50
52
  APIError,
51
53
  BuildError,
@@ -60,10 +62,9 @@ import {
60
62
  UnexpectedDomainPurchaseError,
61
63
  UnsupportedTLD,
62
64
  UserAborted,
63
- getCommandName,
64
65
  isAPIError,
65
66
  require_bytes
66
- } from "./chunk-SOFC4MLS.js";
67
+ } from "./chunk-BMKU5KEL.js";
67
68
  import {
68
69
  Headers,
69
70
  fetch,
@@ -78,7 +79,7 @@ import {
78
79
  prependEmoji,
79
80
  require_ansi_escapes,
80
81
  require_dist
81
- } from "./chunk-OX7KI3LF.js";
82
+ } from "./chunk-QFAS4OVW.js";
82
83
  import {
83
84
  require_source
84
85
  } from "./chunk-S7KYDPEM.js";
@@ -2076,7 +2077,7 @@ async function printDeploymentStatus(client, {
2076
2077
  aliasWarning,
2077
2078
  url,
2078
2079
  target
2079
- }, deployStamp, noWait, guidanceMode, isInit) {
2080
+ }, deployStamp, noWait, guidanceMode, isInit, gitConnectCommand) {
2080
2081
  indications = indications || [];
2081
2082
  let isStillBuilding = false;
2082
2083
  if (noWait) {
@@ -2123,18 +2124,54 @@ ${import_chalk6.default.green("\u2713")} ${import_chalk6.default.bold("Ready")}
2123
2124
  ) + newline;
2124
2125
  output_manager_default.print(message + link);
2125
2126
  }
2126
- if (guidanceMode) {
2127
+ if (gitConnectCommand || guidanceMode) {
2127
2128
  output_manager_default.print("\n");
2128
- suggestNextCommands(
2129
- [
2130
- readyState === "READY" ? getCommandName(`curl https://${url}`) : false,
2131
- getCommandName(`inspect ${url} --logs`),
2132
- getCommandName(`redeploy ${url}`),
2133
- target !== "production" ? getCommandName(`deploy --prod`) : false
2134
- ].filter(Boolean)
2135
- );
2129
+ const nextCommands = [];
2130
+ if (gitConnectCommand) {
2131
+ nextCommands.push({
2132
+ description: "Automatically deploy changes on every push by connecting Git",
2133
+ command: gitConnectCommand
2134
+ });
2135
+ }
2136
+ if (readyState === "READY") {
2137
+ nextCommands.push({
2138
+ description: "Check the deployment response",
2139
+ command: withGlobalFlags(client, `curl https://${url}`, {
2140
+ preserveProject: true
2141
+ })
2142
+ });
2143
+ nextCommands.push(
2144
+ {
2145
+ description: "View build logs",
2146
+ command: withGlobalFlags(client, `inspect ${url} --logs`, {
2147
+ preserveProject: true
2148
+ })
2149
+ },
2150
+ {
2151
+ description: "Create a new deployment from the same source",
2152
+ command: withGlobalFlags(client, `redeploy ${url}`, {
2153
+ preserveProject: true
2154
+ })
2155
+ }
2156
+ );
2157
+ if (target !== "production") {
2158
+ nextCommands.push({
2159
+ description: "Deploy the current project to production",
2160
+ command: withGlobalFlags(client, "deploy --prod", {
2161
+ preserveProject: true
2162
+ })
2163
+ });
2164
+ }
2165
+ } else {
2166
+ nextCommands.push({
2167
+ description: "Check deployment status",
2168
+ command: withGlobalFlags(client, `inspect ${url}`, {
2169
+ preserveProject: true
2170
+ })
2171
+ });
2172
+ }
2173
+ suggestNextCommands(nextCommands);
2136
2174
  }
2137
- await showPluginTipIfNeeded(client);
2138
2175
  return 0;
2139
2176
  }
2140
2177
 
@@ -11,7 +11,7 @@ import {
11
11
  packageName,
12
12
  projectOption,
13
13
  yesOption
14
- } from "./chunk-SOFC4MLS.js";
14
+ } from "./chunk-Q2DGFCO7.js";
15
15
 
16
16
  // src/commands/comments/command.ts
17
17
  var commentsProjectOption = {
@@ -9,11 +9,11 @@ import {
9
9
  require_dist2 as require_dist3,
10
10
  require_dist4,
11
11
  require_lib
12
- } from "./chunk-HMJVUXE6.js";
12
+ } from "./chunk-VJ5NAOWB.js";
13
13
  import {
14
14
  output_manager_default,
15
15
  require_dist
16
- } from "./chunk-OX7KI3LF.js";
16
+ } from "./chunk-QFAS4OVW.js";
17
17
  import {
18
18
  __commonJS,
19
19
  __require,
@@ -0,0 +1,249 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __dirname_ } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ const __filename = __fileURLToPath(import.meta.url);
6
+ const __dirname = __dirname_(__filename);
7
+ import {
8
+ MISSING_BOTH_MESSAGE
9
+ } from "./chunk-5GGUB4EO.js";
10
+ import {
11
+ RULE_ENVIRONMENTS
12
+ } from "./chunk-GY5I4AYD.js";
13
+ import {
14
+ detectExplicitScope,
15
+ resolveProjectContext
16
+ } from "./chunk-VJ5NAOWB.js";
17
+ import {
18
+ AGENT_REASON,
19
+ AGENT_STATUS,
20
+ outputAgentError
21
+ } from "./chunk-NGGLYKNU.js";
22
+ import {
23
+ printError
24
+ } from "./chunk-AYLY3ZVL.js";
25
+ import {
26
+ isAPIError
27
+ } from "./chunk-BMKU5KEL.js";
28
+ import {
29
+ output_manager_default
30
+ } from "./chunk-QFAS4OVW.js";
31
+
32
+ // src/commands/traces/config/errors.ts
33
+ function messageFor(err) {
34
+ if (isAPIError(err)) {
35
+ return err.serverMessage || err.message;
36
+ }
37
+ return err instanceof Error ? err.message : String(err);
38
+ }
39
+ function handleTracingApiError(client, err) {
40
+ if (client.nonInteractive) {
41
+ const status = isAPIError(err) ? err.status : void 0;
42
+ outputAgentError(client, {
43
+ status: AGENT_STATUS.ERROR,
44
+ reason: status === 403 ? AGENT_REASON.PERMISSION_DENIED : status === 404 ? AGENT_REASON.NOT_FOUND : AGENT_REASON.API_ERROR,
45
+ message: messageFor(err)
46
+ });
47
+ }
48
+ if (isAPIError(err) && err.status === 403) {
49
+ output_manager_default.error(messageFor(err));
50
+ return 1;
51
+ }
52
+ printError(err);
53
+ return 1;
54
+ }
55
+ function configError(client, reason, message) {
56
+ if (client.nonInteractive) {
57
+ outputAgentError(client, {
58
+ status: AGENT_STATUS.ERROR,
59
+ reason,
60
+ message
61
+ });
62
+ }
63
+ output_manager_default.error(message);
64
+ return 1;
65
+ }
66
+ function invalidArguments(client, message) {
67
+ return configError(client, AGENT_REASON.INVALID_ARGUMENTS, message);
68
+ }
69
+ function ruleNotFound(client, message) {
70
+ return configError(client, AGENT_REASON.NOT_FOUND, message);
71
+ }
72
+ function confirmationRequired(client, message, next) {
73
+ outputAgentError(client, {
74
+ status: AGENT_STATUS.ERROR,
75
+ reason: AGENT_REASON.CONFIRMATION_REQUIRED,
76
+ message,
77
+ userActionRequired: true,
78
+ next
79
+ });
80
+ output_manager_default.error(message);
81
+ return 1;
82
+ }
83
+
84
+ // src/commands/traces/config/json-output.ts
85
+ function writeConfigJson(client, {
86
+ project,
87
+ bare,
88
+ envelope,
89
+ message,
90
+ next
91
+ }) {
92
+ if (!client.nonInteractive) {
93
+ client.stdout.write(`${JSON.stringify(bare, null, 2)}
94
+ `);
95
+ return;
96
+ }
97
+ client.stdout.write(
98
+ `${JSON.stringify(
99
+ {
100
+ status: AGENT_STATUS.OK,
101
+ projectId: project.id,
102
+ projectName: project.name,
103
+ ...envelope,
104
+ message,
105
+ next
106
+ },
107
+ null,
108
+ 2
109
+ )}
110
+ `
111
+ );
112
+ }
113
+
114
+ // src/commands/traces/config/rules.ts
115
+ var RULE_LIMIT = 10;
116
+ var MIN_SAMPLE_RATE = 1;
117
+ var MAX_SAMPLE_RATE = 100;
118
+ function isRuleEnvironment(value) {
119
+ return RULE_ENVIRONMENTS.includes(value);
120
+ }
121
+ var ENVIRONMENT_ERROR = `\`environment\` must be one of: ${RULE_ENVIRONMENTS.join(", ")}.`;
122
+ var RATE_ERROR = `\`rate\` must be a whole number from ${MIN_SAMPLE_RATE} to ${MAX_SAMPLE_RATE}.`;
123
+ var EMPTY_PATH_ERROR = "`requestPath` cannot be empty.";
124
+ function parseSampleRate(value) {
125
+ if (!/^\d+$/.test(value.trim())) {
126
+ return void 0;
127
+ }
128
+ const rate = Number(value);
129
+ return rate >= MIN_SAMPLE_RATE && rate <= MAX_SAMPLE_RATE ? rate : void 0;
130
+ }
131
+ function toRow(rule) {
132
+ return {
133
+ environment: rule.env ?? "any",
134
+ requestPath: rule.requestPath ?? null,
135
+ sampleRate: Math.round(rule.rate * 100)
136
+ };
137
+ }
138
+ function toApiRate(sampleRate) {
139
+ return sampleRate / 100;
140
+ }
141
+ function toRule(row) {
142
+ return {
143
+ rate: toApiRate(row.sampleRate),
144
+ ...row.environment === "any" ? {} : { env: row.environment },
145
+ ...row.requestPath === null ? {} : { requestPath: row.requestPath }
146
+ };
147
+ }
148
+ var ALL_PATHS_LABEL = "(all paths)";
149
+ function formatPath(requestPath) {
150
+ return requestPath ?? ALL_PATHS_LABEL;
151
+ }
152
+ function formatRate(sampleRate) {
153
+ return `${sampleRate}%`;
154
+ }
155
+ function formatRuleTarget(environment, requestPath) {
156
+ return `${environment} ${formatPath(requestPath)}`;
157
+ }
158
+ function formatRuleLine(row) {
159
+ return `${formatRuleTarget(row.environment, row.requestPath)} ${formatRate(row.sampleRate)}`;
160
+ }
161
+ var COMMAND_WORD_COUNT = 3;
162
+ function subcommandArguments(positional) {
163
+ return positional.slice(COMMAND_WORD_COUNT);
164
+ }
165
+ function hasSameKey(a, b) {
166
+ return a.environment === b.environment && a.requestPath === b.requestPath;
167
+ }
168
+ async function readProjectTracing({
169
+ client,
170
+ teamId,
171
+ projectId
172
+ }) {
173
+ const project = await client.fetch(
174
+ `/v9/projects/${encodeURIComponent(projectId)}`,
175
+ { accountId: teamId }
176
+ );
177
+ const tracing = project.tracing ?? null;
178
+ return {
179
+ project,
180
+ tracing,
181
+ entries: (tracing?.samplingRules ?? []).map((rule) => ({
182
+ rule,
183
+ row: toRow(rule)
184
+ }))
185
+ };
186
+ }
187
+ async function writeSamplingRules({
188
+ client,
189
+ teamId,
190
+ projectId,
191
+ tracing,
192
+ rules
193
+ }) {
194
+ const body = {
195
+ tracing: { ...tracing ?? {}, samplingRules: rules }
196
+ };
197
+ await client.fetch(`/v9/projects/${encodeURIComponent(projectId)}`, {
198
+ accountId: teamId,
199
+ method: "PATCH",
200
+ body
201
+ });
202
+ }
203
+
204
+ // src/commands/traces/config/scope.ts
205
+ async function resolveConfigScope(client, flags) {
206
+ const link = await resolveProjectContext({
207
+ client,
208
+ projectNameOrId: flags.project
209
+ });
210
+ if (link.status === "error") {
211
+ return { exitCode: link.exitCode };
212
+ }
213
+ if (link.status === "not_linked") {
214
+ output_manager_default.error(MISSING_BOTH_MESSAGE);
215
+ return { exitCode: 1 };
216
+ }
217
+ if (flags.project === void 0 && detectExplicitScope(client) && link.org.id !== client.config.currentTeam) {
218
+ output_manager_default.error(
219
+ `The linked project ${link.project.name} belongs to ${link.org.slug || link.org.id}, which is not the scope that was passed. Pass --project <name> to act on a project in that scope.`
220
+ );
221
+ return { exitCode: 1 };
222
+ }
223
+ return { teamId: link.org.id, projectId: link.project.id };
224
+ }
225
+
226
+ export {
227
+ handleTracingApiError,
228
+ invalidArguments,
229
+ ruleNotFound,
230
+ confirmationRequired,
231
+ writeConfigJson,
232
+ RULE_LIMIT,
233
+ isRuleEnvironment,
234
+ ENVIRONMENT_ERROR,
235
+ RATE_ERROR,
236
+ EMPTY_PATH_ERROR,
237
+ parseSampleRate,
238
+ toApiRate,
239
+ toRule,
240
+ formatPath,
241
+ formatRate,
242
+ formatRuleTarget,
243
+ formatRuleLine,
244
+ subcommandArguments,
245
+ hasSameKey,
246
+ readProjectTracing,
247
+ writeSamplingRules,
248
+ resolveConfigScope
249
+ };