nitro 3.0.1-alpha.2 → 3.0.260415-beta

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 (297) hide show
  1. package/LICENSE +6 -0
  2. package/README.md +2 -2
  3. package/dist/THIRD-PARTY-LICENSES.md +1646 -0
  4. package/dist/_build/common.mjs +7261 -3812
  5. package/dist/_build/rolldown.mjs +32 -42
  6. package/dist/_build/rollup.mjs +28 -48
  7. package/dist/_build/vite.build.mjs +10 -10
  8. package/dist/_chunks/nitro.mjs +102 -327
  9. package/dist/_chunks/nitro2.mjs +8 -9
  10. package/dist/_chunks/nitro3.mjs +136 -0
  11. package/dist/_chunks/nitro4.mjs +127 -0
  12. package/dist/_chunks/utils.mjs +40 -29
  13. package/dist/_common.mjs +13 -25
  14. package/dist/_dev.d.mts +0 -3
  15. package/dist/{_chunks/dev.mjs → _dev.mjs} +132 -330
  16. package/dist/_libs/_.mjs +2 -0
  17. package/dist/_libs/_2.mjs +2 -0
  18. package/dist/_libs/_3.mjs +2 -0
  19. package/dist/_libs/_4.mjs +2 -0
  20. package/dist/_libs/_5.mjs +2 -0
  21. package/dist/_libs/_6.mjs +2 -0
  22. package/dist/_libs/_7.mjs +2 -0
  23. package/dist/_libs/c12+rc9.mjs +814 -0
  24. package/dist/_libs/{c12+giget+readdirp+chokidar.d.mts → c12+readdirp+chokidar.d.mts} +49 -40
  25. package/dist/_libs/citty.mjs +142 -41
  26. package/dist/_libs/commondir+is-reference.mjs +60 -56
  27. package/dist/_libs/compatx.d.mts +0 -2
  28. package/dist/_libs/compatx.mjs +1 -4
  29. package/dist/_libs/esbuild.d.mts +0 -1
  30. package/dist/_libs/escape-string-regexp.mjs +1 -4
  31. package/dist/_libs/{pluginutils+plugin-commonjs.d.mts → estree+pluginutils.d.mts} +0 -5
  32. package/dist/_libs/estree-walker.mjs +4 -92
  33. package/dist/_libs/exsolve.d.mts +1 -0
  34. package/dist/_libs/hasown+resolve+deepmerge.mjs +160 -246
  35. package/dist/_libs/httpxy.d.mts +20 -13
  36. package/dist/_libs/httpxy.mjs +519 -95
  37. package/dist/_libs/js-tokens.d.mts +1 -0
  38. package/dist/_libs/klona.mjs +1 -4
  39. package/dist/_libs/magic-string.d.mts +0 -2
  40. package/dist/_libs/mlly.d.mts +0 -2
  41. package/dist/_libs/nypm+tinyexec.mjs +822 -0
  42. package/dist/_libs/perfect-debounce.mjs +68 -0
  43. package/dist/_libs/pkg-types.d.mts +0 -3
  44. package/dist/_libs/plugin-alias.mjs +1 -5
  45. package/dist/_libs/plugin-inject.mjs +1 -7
  46. package/dist/_libs/plugin-json.mjs +1 -5
  47. package/dist/_libs/pluginutils.mjs +3 -35
  48. package/dist/_libs/readdirp+chokidar.mjs +187 -365
  49. package/dist/_libs/remapping.mjs +1 -5
  50. package/dist/_libs/resolve-uri+gen-mapping.mjs +15 -53
  51. package/dist/_libs/rou3.d.mts +1 -4
  52. package/dist/_libs/rou3.mjs +223 -78
  53. package/dist/_libs/std-env.d.mts +8 -2
  54. package/dist/_libs/strip-literal.d.mts +1 -0
  55. package/dist/_libs/tsconfck.mjs +21 -334
  56. package/dist/_libs/ultrahtml.mjs +3 -16
  57. package/dist/_libs/unimport+unplugin.mjs +244 -388
  58. package/dist/_libs/unplugin+unimport.d.mts +5 -15
  59. package/dist/_libs/unwasm.d.mts +0 -3
  60. package/dist/_presets.mjs +576 -488
  61. package/dist/builder.d.mts +5 -25
  62. package/dist/builder.mjs +3 -8
  63. package/dist/cli/_chunks/build.mjs +22 -25
  64. package/dist/cli/_chunks/common.mjs +1 -4
  65. package/dist/cli/_chunks/deploy.mjs +37 -0
  66. package/dist/cli/_chunks/dev.mjs +6 -11
  67. package/dist/cli/_chunks/docs.mjs +28 -0
  68. package/dist/cli/_chunks/list.mjs +4 -8
  69. package/dist/cli/_chunks/prepare.mjs +2 -6
  70. package/dist/cli/_chunks/preview.mjs +48 -0
  71. package/dist/cli/_chunks/run.mjs +7 -11
  72. package/dist/cli/_chunks/task.mjs +1 -5
  73. package/dist/cli/index.mjs +5 -6
  74. package/dist/docs/0.docs/0.index/index.md +56 -0
  75. package/dist/docs/0.docs/1.quick-start.md +110 -0
  76. package/dist/docs/0.docs/10.lifecycle.md +204 -0
  77. package/dist/docs/0.docs/11.openapi.md +291 -0
  78. package/dist/docs/0.docs/12.plugins.md +164 -0
  79. package/dist/docs/0.docs/13.tasks.md +277 -0
  80. package/dist/docs/0.docs/14.websocket.md +386 -0
  81. package/dist/docs/0.docs/15.migration.md +213 -0
  82. package/dist/docs/0.docs/16.nightly.md +31 -0
  83. package/dist/docs/0.docs/2.renderer.md +322 -0
  84. package/dist/docs/0.docs/3.routing.md +711 -0
  85. package/dist/docs/0.docs/4.server-entry.md +239 -0
  86. package/dist/docs/0.docs/5.cache.md +408 -0
  87. package/dist/docs/0.docs/6.storage.md +261 -0
  88. package/dist/docs/0.docs/7.assets.md +166 -0
  89. package/dist/docs/0.docs/8.configuration.md +256 -0
  90. package/dist/docs/0.docs/9.database.md +185 -0
  91. package/dist/docs/1.deploy/0.index/index.md +64 -0
  92. package/dist/docs/1.deploy/1.runtimes/0.node.md +63 -0
  93. package/dist/docs/1.deploy/1.runtimes/1.bun.md +15 -0
  94. package/dist/docs/1.deploy/1.runtimes/2.deno.md +19 -0
  95. package/dist/docs/1.deploy/2.providers/0.alwaysdata.md +50 -0
  96. package/dist/docs/1.deploy/2.providers/1.aws.md +47 -0
  97. package/dist/docs/1.deploy/2.providers/10.flightcontrol.md +67 -0
  98. package/dist/docs/1.deploy/2.providers/11.genezio.md +67 -0
  99. package/dist/docs/1.deploy/2.providers/12.github-pages.md +68 -0
  100. package/dist/docs/1.deploy/2.providers/13.gitlab-pages.md +37 -0
  101. package/dist/docs/1.deploy/2.providers/14.heroku.md +84 -0
  102. package/dist/docs/1.deploy/2.providers/15.iis.md +38 -0
  103. package/dist/docs/1.deploy/2.providers/16.koyeb.md +109 -0
  104. package/dist/docs/1.deploy/2.providers/17.netlify.md +47 -0
  105. package/dist/docs/1.deploy/2.providers/18.platform-sh.md +37 -0
  106. package/dist/docs/1.deploy/2.providers/19.render.md +37 -0
  107. package/dist/docs/1.deploy/2.providers/2.aws-amplify.md +81 -0
  108. package/dist/docs/1.deploy/2.providers/20.stormkit.md +24 -0
  109. package/dist/docs/1.deploy/2.providers/21.vercel.md +270 -0
  110. package/dist/docs/1.deploy/2.providers/22.zeabur.md +19 -0
  111. package/dist/docs/1.deploy/2.providers/23.zephyr.md +99 -0
  112. package/dist/docs/1.deploy/2.providers/24.zerops.md +102 -0
  113. package/dist/docs/1.deploy/2.providers/3.azure.md +72 -0
  114. package/dist/docs/1.deploy/2.providers/4.cleavr.md +33 -0
  115. package/dist/docs/1.deploy/2.providers/5.cloudflare.md +369 -0
  116. package/dist/docs/1.deploy/2.providers/6.deno-deploy.md +66 -0
  117. package/dist/docs/1.deploy/2.providers/7.digitalocean.md +46 -0
  118. package/dist/docs/1.deploy/2.providers/8.edgeone.md +20 -0
  119. package/dist/docs/1.deploy/2.providers/9.firebase.md +32 -0
  120. package/dist/docs/2.config/0.index/index.md +1221 -0
  121. package/dist/docs/3.examples/0.index/index.md +3 -0
  122. package/dist/docs/3.examples/1.api-routes.md +145 -0
  123. package/dist/docs/3.examples/10.hono.md +74 -0
  124. package/dist/docs/3.examples/11.import-alias.md +97 -0
  125. package/dist/docs/3.examples/12.middleware.md +91 -0
  126. package/dist/docs/3.examples/13.mono-jsx.md +68 -0
  127. package/dist/docs/3.examples/14.nano-jsx.md +70 -0
  128. package/dist/docs/3.examples/15.plugins.md +91 -0
  129. package/dist/docs/3.examples/16.renderer.md +113 -0
  130. package/dist/docs/3.examples/17.runtime-config.md +97 -0
  131. package/dist/docs/3.examples/18.server-fetch.md +87 -0
  132. package/dist/docs/3.examples/19.shiki.md +198 -0
  133. package/dist/docs/3.examples/2.auto-imports.md +92 -0
  134. package/dist/docs/3.examples/20.virtual-routes.md +74 -0
  135. package/dist/docs/3.examples/21.vite-nitro-plugin.md +79 -0
  136. package/dist/docs/3.examples/22.vite-rsc.md +1041 -0
  137. package/dist/docs/3.examples/23.vite-ssr-html.md +217 -0
  138. package/dist/docs/3.examples/24.vite-ssr-preact.md +247 -0
  139. package/dist/docs/3.examples/25.vite-ssr-react.md +226 -0
  140. package/dist/docs/3.examples/26.vite-ssr-solid.md +256 -0
  141. package/dist/docs/3.examples/27.vite-ssr-tsr-react.md +442 -0
  142. package/dist/docs/3.examples/28.vite-ssr-tss-react.md +444 -0
  143. package/dist/docs/3.examples/29.vite-ssr-vue-router.md +617 -0
  144. package/dist/docs/3.examples/3.cached-handler.md +81 -0
  145. package/dist/docs/3.examples/30.vite-trpc.md +335 -0
  146. package/dist/docs/3.examples/31.websocket.md +282 -0
  147. package/dist/docs/3.examples/4.custom-error-handler.md +98 -0
  148. package/dist/docs/3.examples/5.database.md +157 -0
  149. package/dist/docs/3.examples/6.elysia.md +70 -0
  150. package/dist/docs/3.examples/7.express.md +78 -0
  151. package/dist/docs/3.examples/8.fastify.md +79 -0
  152. package/dist/docs/3.examples/9.hello-world.md +68 -0
  153. package/dist/docs/README.md +86 -0
  154. package/dist/docs/index.md +121 -0
  155. package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +8 -0
  156. package/dist/node_modules/@poppinss/dumper/package.json +1 -1
  157. package/dist/node_modules/@speed-highlight/core/dist/index.js +4 -4
  158. package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -2
  159. package/dist/node_modules/@speed-highlight/core/package.json +1 -1
  160. package/dist/node_modules/cookie-es/dist/index.mjs +299 -250
  161. package/dist/node_modules/cookie-es/package.json +26 -23
  162. package/dist/node_modules/croner/dist/croner.js +1 -1
  163. package/dist/node_modules/croner/package.json +11 -1
  164. package/dist/node_modules/defu/dist/defu.mjs +2 -2
  165. package/dist/node_modules/defu/package.json +33 -28
  166. package/dist/node_modules/rendu/dist/_chunks/libs/cookie-es.mjs +151 -0
  167. package/dist/node_modules/rendu/dist/index.mjs +5 -112
  168. package/dist/node_modules/rendu/package.json +25 -24
  169. package/dist/node_modules/youch/build/helpers-B9BQYaS6.js +23 -0
  170. package/dist/node_modules/youch/build/index.js +204 -351
  171. package/dist/node_modules/youch/build/public/error_info/script.js +1 -1
  172. package/dist/node_modules/youch/build/public_dir-C5bujZKB.js +25 -0
  173. package/dist/node_modules/youch/build/src/templates/error_cause/main.js +44 -0
  174. package/dist/node_modules/youch/build/src/templates/error_info/main.js +72 -0
  175. package/dist/node_modules/youch/build/src/templates/error_metadata/main.js +65 -0
  176. package/dist/node_modules/youch/build/src/templates/error_stack/main.js +152 -0
  177. package/dist/node_modules/youch/build/src/templates/error_stack_source/main.js +46 -0
  178. package/dist/node_modules/youch/build/src/templates/header/main.js +24 -0
  179. package/dist/node_modules/youch/build/src/templates/layout/main.js +27 -0
  180. package/dist/node_modules/youch/package.json +35 -32
  181. package/dist/presets/_nitro/runtime/nitro-dev.mjs +12 -57
  182. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +1 -0
  183. package/dist/presets/_nitro/runtime/service-worker.mjs +1 -2
  184. package/dist/presets/aws-lambda/runtime/_utils.mjs +6 -6
  185. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +3 -1
  186. package/dist/presets/azure/runtime/_utils.mjs +5 -5
  187. package/dist/presets/azure/runtime/azure-swa.mjs +5 -5
  188. package/dist/presets/bun/runtime/bun.mjs +9 -6
  189. package/dist/presets/cloudflare/runtime/_module-handler.mjs +1 -1
  190. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +4 -4
  191. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +3 -3
  192. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +2 -2
  193. package/dist/presets/cloudflare/runtime/plugin.dev.mjs +10 -21
  194. package/dist/presets/deno/runtime/deno-deploy.mjs +4 -4
  195. package/dist/presets/deno/runtime/deno-server.mjs +9 -6
  196. package/dist/presets/edgeone/runtime/edgeone.mjs +10 -0
  197. package/dist/presets/netlify/runtime/netlify-edge.mjs +2 -3
  198. package/dist/presets/netlify/runtime/netlify.mjs +1 -1
  199. package/dist/presets/node/runtime/node-cluster.mjs +5 -4
  200. package/dist/presets/node/runtime/node-middleware.mjs +1 -1
  201. package/dist/presets/node/runtime/node-server.mjs +8 -5
  202. package/dist/presets/stormkit/runtime/stormkit.mjs +1 -2
  203. package/dist/presets/vercel/runtime/cron-handler.mjs +25 -0
  204. package/dist/presets/vercel/runtime/queue-handler.mjs +21 -0
  205. package/dist/presets/vercel/runtime/vercel.node.mjs +3 -3
  206. package/dist/presets/vercel/runtime/vercel.web.mjs +3 -5
  207. package/dist/presets/winterjs/runtime/winterjs.mjs +10 -10
  208. package/dist/presets/zephyr/runtime/server.mjs +3 -0
  209. package/dist/runtime/internal/app.mjs +12 -11
  210. package/dist/runtime/internal/cache.d.mts +0 -4
  211. package/dist/runtime/internal/cache.mjs +32 -256
  212. package/dist/runtime/internal/context.d.mts +3 -1
  213. package/dist/runtime/internal/context.mjs +1 -9
  214. package/dist/runtime/internal/error/dev.d.mts +5 -4
  215. package/dist/runtime/internal/error/dev.mjs +47 -49
  216. package/dist/runtime/internal/error/hooks.d.mts +1 -1
  217. package/dist/runtime/internal/error/prod.d.mts +2 -5
  218. package/dist/runtime/internal/error/prod.mjs +19 -33
  219. package/dist/runtime/internal/error/utils.d.mts +4 -4
  220. package/dist/runtime/internal/meta.d.mts +1 -1
  221. package/dist/runtime/internal/plugin.d.mts +2 -2
  222. package/dist/runtime/internal/route-rules.d.mts +11 -4
  223. package/dist/runtime/internal/route-rules.mjs +15 -5
  224. package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -2
  225. package/dist/runtime/internal/routes/dev-tasks.mjs +15 -10
  226. package/dist/runtime/internal/routes/openapi.mjs +2 -2
  227. package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
  228. package/dist/runtime/internal/routes/renderer-template.dev.d.mts +2 -1
  229. package/dist/runtime/internal/routes/scalar.mjs +3 -3
  230. package/dist/runtime/internal/routes/swagger.mjs +7 -4
  231. package/dist/runtime/internal/runtime-config.d.mts +1 -1
  232. package/dist/runtime/internal/runtime-config.mjs +2 -2
  233. package/dist/runtime/internal/static.mjs +5 -4
  234. package/dist/runtime/internal/task.d.mts +3 -1
  235. package/dist/runtime/internal/task.mjs +7 -7
  236. package/dist/runtime/internal/vite/dev-entry.mjs +6 -3
  237. package/dist/runtime/internal/vite/dev-worker.mjs +264 -0
  238. package/dist/runtime/meta.d.mts +1 -0
  239. package/dist/runtime/meta.mjs +2 -0
  240. package/dist/runtime/nitro.d.mts +2 -0
  241. package/dist/runtime/nitro.mjs +4 -2
  242. package/dist/runtime/virtual/error-handler.mjs +1 -1
  243. package/dist/runtime/virtual/renderer-template.mjs +1 -1
  244. package/dist/runtime/virtual/server-assets.d.mts +2 -1
  245. package/dist/runtime/virtual/tracing.d.mts +5 -0
  246. package/dist/runtime/virtual/tracing.mjs +1 -0
  247. package/dist/runtime/vite.d.mts +1 -1
  248. package/dist/types/index.d.mts +215 -195
  249. package/dist/types/index.mjs +1 -11
  250. package/dist/vite.d.mts +3 -8
  251. package/dist/vite.mjs +285 -253
  252. package/lib/tsconfig.json +3 -5
  253. package/package.json +97 -80
  254. package/dist/_libs/confbox.mjs +0 -2509
  255. package/dist/_libs/nypm+giget+tinyexec.mjs +0 -3603
  256. package/dist/_libs/rc9+c12+dotenv.mjs +0 -972
  257. package/dist/node_modules/hookable/dist/index.mjs +0 -266
  258. package/dist/node_modules/hookable/package.json +0 -52
  259. package/dist/node_modules/youch/build/chunk-4L7RY2JA.js +0 -42
  260. package/dist/node_modules/youch/build/chunk-7QV3D5YX.js +0 -83
  261. package/dist/node_modules/youch/build/chunk-AUGPHE32.js +0 -39
  262. package/dist/node_modules/youch/build/chunk-CM7DWJNZ.js +0 -44
  263. package/dist/node_modules/youch/build/chunk-EJH674NB.js +0 -223
  264. package/dist/node_modules/youch/build/chunk-OIJ3WD7L.js +0 -81
  265. package/dist/node_modules/youch/build/chunk-P36L72PL.js +0 -87
  266. package/dist/node_modules/youch/build/chunk-PE3GG3TN.js +0 -65
  267. package/dist/node_modules/youch/build/chunk-X53OIOJH.js +0 -70
  268. package/dist/presets/_nitro/runtime/nitro-dev.d.mts +0 -2
  269. package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +0 -3
  270. package/dist/presets/_nitro/runtime/service-worker.d.mts +0 -2
  271. package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +0 -2
  272. package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -8
  273. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +0 -2
  274. package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +0 -3
  275. package/dist/presets/azure/runtime/_utils.d.mts +0 -2
  276. package/dist/presets/azure/runtime/azure-swa.d.mts +0 -5
  277. package/dist/presets/bun/runtime/bun.d.mts +0 -3
  278. package/dist/presets/cloudflare/runtime/_module-handler.d.mts +0 -16
  279. package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +0 -11
  280. package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +0 -3
  281. package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +0 -20
  282. package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +0 -3
  283. package/dist/presets/deno/runtime/deno-deploy.d.mts +0 -5
  284. package/dist/presets/deno/runtime/deno-server.d.mts +0 -3
  285. package/dist/presets/netlify/runtime/netlify-edge.d.mts +0 -3
  286. package/dist/presets/netlify/runtime/netlify.d.mts +0 -4
  287. package/dist/presets/node/runtime/node-cluster.d.mts +0 -3
  288. package/dist/presets/node/runtime/node-middleware.d.mts +0 -3
  289. package/dist/presets/node/runtime/node-server.d.mts +0 -3
  290. package/dist/presets/standard/runtime/server.d.mts +0 -3
  291. package/dist/presets/stormkit/runtime/stormkit.d.mts +0 -21
  292. package/dist/presets/vercel/runtime/isr.d.mts +0 -2
  293. package/dist/presets/vercel/runtime/vercel.node.d.mts +0 -3
  294. package/dist/presets/vercel/runtime/vercel.web.d.mts +0 -8
  295. package/dist/presets/winterjs/runtime/winterjs.d.mts +0 -2
  296. package/dist/presets/zeabur/runtime/zeabur.d.mts +0 -3
  297. package/dist/runtime/internal/vite/node-runner.mjs +0 -359
@@ -0,0 +1,822 @@
1
+ import { ct as join$1, dt as resolve$1, lt as normalize$1 } from "../_build/common.mjs";
2
+ import { createRequire } from "node:module";
3
+ import { existsSync } from "node:fs";
4
+ import { readFile } from "node:fs/promises";
5
+ import { delimiter, dirname, join, normalize, resolve } from "node:path";
6
+ import { cwd } from "node:process";
7
+ import { PassThrough } from "node:stream";
8
+ import { spawn } from "node:child_process";
9
+ import c from "node:readline";
10
+ var l = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports);
11
+ var u = /* @__PURE__ */ createRequire(import.meta.url);
12
+ const d = /^path$/i;
13
+ const f = {
14
+ key: "PATH",
15
+ value: ""
16
+ };
17
+ function p(e) {
18
+ for (const t in e) {
19
+ if (!Object.prototype.hasOwnProperty.call(e, t) || !d.test(t)) continue;
20
+ const n = e[t];
21
+ if (!n) return f;
22
+ return {
23
+ key: t,
24
+ value: n
25
+ };
26
+ }
27
+ return f;
28
+ }
29
+ function m(e, t) {
30
+ const i = t.value.split(delimiter);
31
+ const o = [];
32
+ let s = e;
33
+ let c;
34
+ do {
35
+ o.push(resolve(s, "node_modules", ".bin"));
36
+ c = s;
37
+ s = dirname(s);
38
+ } while (s !== c);
39
+ const l = o.concat(i).join(delimiter);
40
+ return {
41
+ key: t.key,
42
+ value: l
43
+ };
44
+ }
45
+ function h(e, t) {
46
+ const n = {
47
+ ...process.env,
48
+ ...t
49
+ };
50
+ const r = m(e, p(n));
51
+ n[r.key] = r.value;
52
+ return n;
53
+ }
54
+ const g = (e) => {
55
+ let t = e.length;
56
+ const n = new PassThrough();
57
+ const r = () => {
58
+ if (--t === 0) n.emit("end");
59
+ };
60
+ for (const t of e) {
61
+ t.pipe(n, { end: false });
62
+ t.on("end", r);
63
+ }
64
+ return n;
65
+ };
66
+ var _ = /* @__PURE__ */ l(((e, t) => {
67
+ t.exports = a;
68
+ a.sync = o;
69
+ var n = u("fs");
70
+ function r(e, t) {
71
+ var n = t.pathExt !== void 0 ? t.pathExt : process.env.PATHEXT;
72
+ if (!n) return true;
73
+ n = n.split(";");
74
+ if (n.indexOf("") !== -1) return true;
75
+ for (var r = 0; r < n.length; r++) {
76
+ var i = n[r].toLowerCase();
77
+ if (i && e.substr(-i.length).toLowerCase() === i) return true;
78
+ }
79
+ return false;
80
+ }
81
+ function i(e, t, n) {
82
+ if (!e.isSymbolicLink() && !e.isFile()) return false;
83
+ return r(t, n);
84
+ }
85
+ function a(e, t, r) {
86
+ n.stat(e, function(n, a) {
87
+ r(n, n ? false : i(a, e, t));
88
+ });
89
+ }
90
+ function o(e, t) {
91
+ return i(n.statSync(e), e, t);
92
+ }
93
+ }));
94
+ var v = /* @__PURE__ */ l(((e, t) => {
95
+ t.exports = r;
96
+ r.sync = i;
97
+ var n = u("fs");
98
+ function r(e, t, r) {
99
+ n.stat(e, function(e, n) {
100
+ r(e, e ? false : a(n, t));
101
+ });
102
+ }
103
+ function i(e, t) {
104
+ return a(n.statSync(e), t);
105
+ }
106
+ function a(e, t) {
107
+ return e.isFile() && o(e, t);
108
+ }
109
+ function o(e, t) {
110
+ var n = e.mode;
111
+ var r = e.uid;
112
+ var i = e.gid;
113
+ var a = t.uid !== void 0 ? t.uid : process.getuid && process.getuid();
114
+ var o = t.gid !== void 0 ? t.gid : process.getgid && process.getgid();
115
+ var s = parseInt("100", 8);
116
+ var c = parseInt("010", 8);
117
+ var l = parseInt("001", 8);
118
+ var u = s | c;
119
+ return n & l || n & c && i === o || n & s && r === a || n & u && a === 0;
120
+ }
121
+ }));
122
+ var y = /* @__PURE__ */ l(((e, t) => {
123
+ u("fs");
124
+ var n;
125
+ if (process.platform === "win32" || global.TESTING_WINDOWS) n = _();
126
+ else n = v();
127
+ t.exports = r;
128
+ r.sync = i;
129
+ function r(e, t, i) {
130
+ if (typeof t === "function") {
131
+ i = t;
132
+ t = {};
133
+ }
134
+ if (!i) {
135
+ if (typeof Promise !== "function") throw new TypeError("callback not provided");
136
+ return new Promise(function(n, i) {
137
+ r(e, t || {}, function(e, t) {
138
+ if (e) i(e);
139
+ else n(t);
140
+ });
141
+ });
142
+ }
143
+ n(e, t || {}, function(e, n) {
144
+ if (e) {
145
+ if (e.code === "EACCES" || t && t.ignoreErrors) {
146
+ e = null;
147
+ n = false;
148
+ }
149
+ }
150
+ i(e, n);
151
+ });
152
+ }
153
+ function i(e, t) {
154
+ try {
155
+ return n.sync(e, t || {});
156
+ } catch (e) {
157
+ if (t && t.ignoreErrors || e.code === "EACCES") return false;
158
+ else throw e;
159
+ }
160
+ }
161
+ }));
162
+ var b = /* @__PURE__ */ l(((e, t) => {
163
+ const n = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
164
+ const r = u("path");
165
+ const i = n ? ";" : ":";
166
+ const a = y();
167
+ const o = (e) => Object.assign(/* @__PURE__ */ new Error(`not found: ${e}`), { code: "ENOENT" });
168
+ const s = (e, t) => {
169
+ const r = t.colon || i;
170
+ const a = e.match(/\//) || n && e.match(/\\/) ? [""] : [...n ? [process.cwd()] : [], ...(t.path || process.env.PATH || "").split(r)];
171
+ const o = n ? t.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
172
+ const s = n ? o.split(r) : [""];
173
+ if (n) {
174
+ if (e.indexOf(".") !== -1 && s[0] !== "") s.unshift("");
175
+ }
176
+ return {
177
+ pathEnv: a,
178
+ pathExt: s,
179
+ pathExtExe: o
180
+ };
181
+ };
182
+ const c = (e, t, n) => {
183
+ if (typeof t === "function") {
184
+ n = t;
185
+ t = {};
186
+ }
187
+ if (!t) t = {};
188
+ const { pathEnv: i, pathExt: c, pathExtExe: l } = s(e, t);
189
+ const u = [];
190
+ const d = (n) => new Promise((a, s) => {
191
+ if (n === i.length) return t.all && u.length ? a(u) : s(o(e));
192
+ const c = i[n];
193
+ const l = /^".*"$/.test(c) ? c.slice(1, -1) : c;
194
+ const d = r.join(l, e);
195
+ a(f(!l && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d, n, 0));
196
+ });
197
+ const f = (e, n, r) => new Promise((i, o) => {
198
+ if (r === c.length) return i(d(n + 1));
199
+ const s = c[r];
200
+ a(e + s, { pathExt: l }, (a, o) => {
201
+ if (!a && o) if (t.all) u.push(e + s);
202
+ else return i(e + s);
203
+ return i(f(e, n, r + 1));
204
+ });
205
+ });
206
+ return n ? d(0).then((e) => n(null, e), n) : d(0);
207
+ };
208
+ const l = (e, t) => {
209
+ t = t || {};
210
+ const { pathEnv: n, pathExt: i, pathExtExe: c } = s(e, t);
211
+ const l = [];
212
+ for (let o = 0; o < n.length; o++) {
213
+ const s = n[o];
214
+ const u = /^".*"$/.test(s) ? s.slice(1, -1) : s;
215
+ const d = r.join(u, e);
216
+ const f = !u && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d;
217
+ for (let e = 0; e < i.length; e++) {
218
+ const n = f + i[e];
219
+ try {
220
+ if (a.sync(n, { pathExt: c })) if (t.all) l.push(n);
221
+ else return n;
222
+ } catch (e) {}
223
+ }
224
+ }
225
+ if (t.all && l.length) return l;
226
+ if (t.nothrow) return null;
227
+ throw o(e);
228
+ };
229
+ t.exports = c;
230
+ c.sync = l;
231
+ }));
232
+ var x = /* @__PURE__ */ l(((e, t) => {
233
+ const n = (e = {}) => {
234
+ const t = e.env || process.env;
235
+ if ((e.platform || process.platform) !== "win32") return "PATH";
236
+ return Object.keys(t).reverse().find((e) => e.toUpperCase() === "PATH") || "Path";
237
+ };
238
+ t.exports = n;
239
+ t.exports.default = n;
240
+ }));
241
+ var S = /* @__PURE__ */ l(((e, t) => {
242
+ const n = u("path");
243
+ const r = b();
244
+ const i = x();
245
+ function a(e, t) {
246
+ const a = e.options.env || process.env;
247
+ const o = process.cwd();
248
+ const s = e.options.cwd != null;
249
+ const c = s && process.chdir !== void 0 && !process.chdir.disabled;
250
+ if (c) try {
251
+ process.chdir(e.options.cwd);
252
+ } catch (e) {}
253
+ let l;
254
+ try {
255
+ l = r.sync(e.command, {
256
+ path: a[i({ env: a })],
257
+ pathExt: t ? n.delimiter : void 0
258
+ });
259
+ } catch (e) {} finally {
260
+ if (c) process.chdir(o);
261
+ }
262
+ if (l) l = n.resolve(s ? e.options.cwd : "", l);
263
+ return l;
264
+ }
265
+ function o(e) {
266
+ return a(e) || a(e, true);
267
+ }
268
+ t.exports = o;
269
+ }));
270
+ var C = /* @__PURE__ */ l(((e, t) => {
271
+ const n = /([()\][%!^"`<>&|;, *?])/g;
272
+ function r(e) {
273
+ e = e.replace(n, "^$1");
274
+ return e;
275
+ }
276
+ function i(e, t) {
277
+ e = `${e}`;
278
+ e = e.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
279
+ e = e.replace(/(?=(\\+?)?)\1$/, "$1$1");
280
+ e = `"${e}"`;
281
+ e = e.replace(n, "^$1");
282
+ if (t) e = e.replace(n, "^$1");
283
+ return e;
284
+ }
285
+ t.exports.command = r;
286
+ t.exports.argument = i;
287
+ }));
288
+ var w = /* @__PURE__ */ l(((e, t) => {
289
+ t.exports = /^#!(.*)/;
290
+ }));
291
+ var T = /* @__PURE__ */ l(((e, t) => {
292
+ const n = w();
293
+ t.exports = (e = "") => {
294
+ const t = e.match(n);
295
+ if (!t) return null;
296
+ const [r, i] = t[0].replace(/#! ?/, "").split(" ");
297
+ const a = r.split("/").pop();
298
+ if (a === "env") return i;
299
+ return i ? `${a} ${i}` : a;
300
+ };
301
+ }));
302
+ var E = /* @__PURE__ */ l(((e, t) => {
303
+ const n = u("fs");
304
+ const r = T();
305
+ function i(e) {
306
+ const t = 150;
307
+ const i = Buffer.alloc(t);
308
+ let a;
309
+ try {
310
+ a = n.openSync(e, "r");
311
+ n.readSync(a, i, 0, t, 0);
312
+ n.closeSync(a);
313
+ } catch (e) {}
314
+ return r(i.toString());
315
+ }
316
+ t.exports = i;
317
+ }));
318
+ var D = /* @__PURE__ */ l(((e, t) => {
319
+ const n = u("path");
320
+ const r = S();
321
+ const i = C();
322
+ const a = E();
323
+ const o = process.platform === "win32";
324
+ const s = /\.(?:com|exe)$/i;
325
+ const c = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
326
+ function l(e) {
327
+ e.file = r(e);
328
+ const t = e.file && a(e.file);
329
+ if (t) {
330
+ e.args.unshift(e.file);
331
+ e.command = t;
332
+ return r(e);
333
+ }
334
+ return e.file;
335
+ }
336
+ function d(e) {
337
+ if (!o) return e;
338
+ const t = l(e);
339
+ const r = !s.test(t);
340
+ if (e.options.forceShell || r) {
341
+ const r = c.test(t);
342
+ e.command = n.normalize(e.command);
343
+ e.command = i.command(e.command);
344
+ e.args = e.args.map((e) => i.argument(e, r));
345
+ e.args = [
346
+ "/d",
347
+ "/s",
348
+ "/c",
349
+ `"${[e.command].concat(e.args).join(" ")}"`
350
+ ];
351
+ e.command = process.env.comspec || "cmd.exe";
352
+ e.options.windowsVerbatimArguments = true;
353
+ }
354
+ return e;
355
+ }
356
+ function f(e, t, n) {
357
+ if (t && !Array.isArray(t)) {
358
+ n = t;
359
+ t = null;
360
+ }
361
+ t = t ? t.slice(0) : [];
362
+ n = Object.assign({}, n);
363
+ const r = {
364
+ command: e,
365
+ args: t,
366
+ options: n,
367
+ file: void 0,
368
+ original: {
369
+ command: e,
370
+ args: t
371
+ }
372
+ };
373
+ return n.shell ? r : d(r);
374
+ }
375
+ t.exports = f;
376
+ }));
377
+ var O = /* @__PURE__ */ l(((e, t) => {
378
+ const n = process.platform === "win32";
379
+ function r(e, t) {
380
+ return Object.assign(/* @__PURE__ */ new Error(`${t} ${e.command} ENOENT`), {
381
+ code: "ENOENT",
382
+ errno: "ENOENT",
383
+ syscall: `${t} ${e.command}`,
384
+ path: e.command,
385
+ spawnargs: e.args
386
+ });
387
+ }
388
+ function i(e, t) {
389
+ if (!n) return;
390
+ const r = e.emit;
391
+ e.emit = function(n, i) {
392
+ if (n === "exit") {
393
+ const n = a(i, t);
394
+ if (n) return r.call(e, "error", n);
395
+ }
396
+ return r.apply(e, arguments);
397
+ };
398
+ }
399
+ function a(e, t) {
400
+ if (n && e === 1 && !t.file) return r(t.original, "spawn");
401
+ return null;
402
+ }
403
+ function o(e, t) {
404
+ if (n && e === 1 && !t.file) return r(t.original, "spawnSync");
405
+ return null;
406
+ }
407
+ t.exports = {
408
+ hookChildProcess: i,
409
+ verifyENOENT: a,
410
+ verifyENOENTSync: o,
411
+ notFoundError: r
412
+ };
413
+ }));
414
+ var A = (/* @__PURE__ */ l(((e, t) => {
415
+ const n = u("child_process");
416
+ const r = D();
417
+ const i = O();
418
+ function a(e, t, a) {
419
+ const o = r(e, t, a);
420
+ const s = n.spawn(o.command, o.args, o.options);
421
+ i.hookChildProcess(s, o);
422
+ return s;
423
+ }
424
+ function o(e, t, a) {
425
+ const o = r(e, t, a);
426
+ const s = n.spawnSync(o.command, o.args, o.options);
427
+ s.error = s.error || i.verifyENOENTSync(s.status, o);
428
+ return s;
429
+ }
430
+ t.exports = a;
431
+ t.exports.spawn = a;
432
+ t.exports.sync = o;
433
+ t.exports._parse = r;
434
+ t.exports._enoent = i;
435
+ })))();
436
+ var j = class extends Error {
437
+ result;
438
+ output;
439
+ get exitCode() {
440
+ if (this.result.exitCode !== null) return this.result.exitCode;
441
+ }
442
+ constructor(e, t) {
443
+ super(`Process exited with non-zero status (${e.exitCode})`);
444
+ this.result = e;
445
+ this.output = t;
446
+ }
447
+ };
448
+ const M = {
449
+ timeout: void 0,
450
+ persist: false
451
+ };
452
+ const N = { windowsHide: true };
453
+ function P(e, t) {
454
+ return {
455
+ command: normalize(e),
456
+ args: t ?? []
457
+ };
458
+ }
459
+ function F(e) {
460
+ const t = new AbortController();
461
+ for (const n of e) {
462
+ if (n.aborted) {
463
+ t.abort();
464
+ return n;
465
+ }
466
+ const e = () => {
467
+ t.abort(n.reason);
468
+ };
469
+ n.addEventListener("abort", e, { signal: t.signal });
470
+ }
471
+ return t.signal;
472
+ }
473
+ async function I(e) {
474
+ let t = "";
475
+ for await (const n of e) t += n.toString();
476
+ return t;
477
+ }
478
+ var L = class {
479
+ _process;
480
+ _aborted = false;
481
+ _options;
482
+ _command;
483
+ _args;
484
+ _resolveClose;
485
+ _processClosed;
486
+ _thrownError;
487
+ get process() {
488
+ return this._process;
489
+ }
490
+ get pid() {
491
+ return this._process?.pid;
492
+ }
493
+ get exitCode() {
494
+ if (this._process && this._process.exitCode !== null) return this._process.exitCode;
495
+ }
496
+ constructor(e, t, n) {
497
+ this._options = {
498
+ ...M,
499
+ ...n
500
+ };
501
+ this._command = e;
502
+ this._args = t ?? [];
503
+ this._processClosed = new Promise((e) => {
504
+ this._resolveClose = e;
505
+ });
506
+ }
507
+ kill(e) {
508
+ return this._process?.kill(e) === true;
509
+ }
510
+ get aborted() {
511
+ return this._aborted;
512
+ }
513
+ get killed() {
514
+ return this._process?.killed === true;
515
+ }
516
+ pipe(e, t, n) {
517
+ return z(e, t, {
518
+ ...n,
519
+ stdin: this
520
+ });
521
+ }
522
+ async *[Symbol.asyncIterator]() {
523
+ const e = this._process;
524
+ if (!e) return;
525
+ const t = [];
526
+ if (this._streamErr) t.push(this._streamErr);
527
+ if (this._streamOut) t.push(this._streamOut);
528
+ const n = g(t);
529
+ const r = c.createInterface({ input: n });
530
+ for await (const e of r) yield e.toString();
531
+ await this._processClosed;
532
+ e.removeAllListeners();
533
+ if (this._thrownError) throw this._thrownError;
534
+ if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new j(this);
535
+ }
536
+ async _waitForOutput() {
537
+ const e = this._process;
538
+ if (!e) throw new Error("No process was started");
539
+ const [t, n] = await Promise.all([this._streamOut ? I(this._streamOut) : "", this._streamErr ? I(this._streamErr) : ""]);
540
+ await this._processClosed;
541
+ if (this._options?.stdin) await this._options.stdin;
542
+ e.removeAllListeners();
543
+ if (this._thrownError) throw this._thrownError;
544
+ const r = {
545
+ stderr: n,
546
+ stdout: t,
547
+ exitCode: this.exitCode
548
+ };
549
+ if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new j(this, r);
550
+ return r;
551
+ }
552
+ then(e, t) {
553
+ return this._waitForOutput().then(e, t);
554
+ }
555
+ _streamOut;
556
+ _streamErr;
557
+ spawn() {
558
+ const e = cwd();
559
+ const n = this._options;
560
+ const r = {
561
+ ...N,
562
+ ...n.nodeOptions
563
+ };
564
+ const i = [];
565
+ this._resetState();
566
+ if (n.timeout !== void 0) i.push(AbortSignal.timeout(n.timeout));
567
+ if (n.signal !== void 0) i.push(n.signal);
568
+ if (n.persist === true) r.detached = true;
569
+ if (i.length > 0) r.signal = F(i);
570
+ r.env = h(e, r.env);
571
+ const { command: a, args: s } = P(this._command, this._args);
572
+ const c = (0, A._parse)(a, s, r);
573
+ const l = spawn(c.command, c.args, c.options);
574
+ if (l.stderr) this._streamErr = l.stderr;
575
+ if (l.stdout) this._streamOut = l.stdout;
576
+ this._process = l;
577
+ l.once("error", this._onError);
578
+ l.once("close", this._onClose);
579
+ if (n.stdin !== void 0 && l.stdin && n.stdin.process) {
580
+ const { stdout: e } = n.stdin.process;
581
+ if (e) e.pipe(l.stdin);
582
+ }
583
+ }
584
+ _resetState() {
585
+ this._aborted = false;
586
+ this._processClosed = new Promise((e) => {
587
+ this._resolveClose = e;
588
+ });
589
+ this._thrownError = void 0;
590
+ }
591
+ _onError = (e) => {
592
+ if (e.name === "AbortError" && (!(e.cause instanceof Error) || e.cause.name !== "TimeoutError")) {
593
+ this._aborted = true;
594
+ return;
595
+ }
596
+ this._thrownError = e;
597
+ };
598
+ _onClose = () => {
599
+ if (this._resolveClose) this._resolveClose();
600
+ };
601
+ };
602
+ const R = (e, t, n) => {
603
+ const r = new L(e, t, n);
604
+ r.spawn();
605
+ return r;
606
+ };
607
+ const z = R;
608
+ async function findup(cwd, match, options = {}) {
609
+ const segments = normalize$1(cwd).split("/");
610
+ while (segments.length > 0) {
611
+ const result = await match(segments.join("/") || "/");
612
+ if (result || !options.includeParentDirs) return result;
613
+ segments.pop();
614
+ }
615
+ }
616
+ async function readPackageJSON(cwd) {
617
+ return findup(cwd, (p) => {
618
+ const pkgPath = join(p, "package.json");
619
+ if (existsSync(pkgPath)) return readFile(pkgPath, "utf8").then((data) => JSON.parse(data));
620
+ });
621
+ }
622
+ function cached(fn) {
623
+ let v;
624
+ return () => {
625
+ if (v === void 0) v = fn().then((r) => {
626
+ v = r;
627
+ return v;
628
+ });
629
+ return v;
630
+ };
631
+ }
632
+ const hasCorepack = cached(async () => {
633
+ if (globalThis.process?.versions?.webcontainer) return false;
634
+ try {
635
+ const { exitCode } = await R("corepack", ["--version"]);
636
+ return exitCode === 0;
637
+ } catch {
638
+ return false;
639
+ }
640
+ });
641
+ async function executeCommand(command, args, options = {}) {
642
+ const xArgs = command !== "npm" && command !== "bun" && command !== "deno" && options.corepack !== false && await hasCorepack() ? ["corepack", [command, ...args]] : [command, args];
643
+ const { exitCode, stdout, stderr } = await R(xArgs[0], xArgs[1], { nodeOptions: {
644
+ cwd: resolve$1(options.cwd || process.cwd()),
645
+ env: options.env,
646
+ stdio: options.silent ? "pipe" : "inherit"
647
+ } });
648
+ if (exitCode !== 0) throw new Error(`\`${xArgs.flat().join(" ")}\` failed.${options.silent ? [
649
+ "",
650
+ stdout,
651
+ stderr
652
+ ].join("\n") : ""}`);
653
+ }
654
+ const NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG = "No package manager auto-detected.";
655
+ async function resolveOperationOptions(options = {}) {
656
+ const cwd = options.cwd || process.cwd();
657
+ const env = {
658
+ ...process.env,
659
+ ...options.env
660
+ };
661
+ const packageManager = (typeof options.packageManager === "string" ? packageManagers.find((pm) => pm.name === options.packageManager) : options.packageManager) || await detectPackageManager(options.cwd || process.cwd());
662
+ if (!packageManager) throw new Error(NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG);
663
+ return {
664
+ cwd,
665
+ env,
666
+ silent: options.silent ?? false,
667
+ packageManager,
668
+ dev: options.dev ?? false,
669
+ workspace: options.workspace,
670
+ global: options.global ?? false,
671
+ dry: options.dry ?? false,
672
+ corepack: options.corepack ?? true
673
+ };
674
+ }
675
+ function getWorkspaceArgs(options) {
676
+ if (!options.workspace) return [];
677
+ const workspacePkg = typeof options.workspace === "string" && options.workspace !== "" ? options.workspace : void 0;
678
+ if (options.packageManager.name === "pnpm") return workspacePkg ? ["--filter", workspacePkg] : ["--workspace-root"];
679
+ if (options.packageManager.name === "npm") return workspacePkg ? ["-w", workspacePkg] : ["--workspaces"];
680
+ if (options.packageManager.name === "yarn") if (!options.packageManager.majorVersion || options.packageManager.majorVersion === "1") return workspacePkg ? ["--cwd", workspacePkg] : ["-W"];
681
+ else return workspacePkg ? ["workspace", workspacePkg] : [];
682
+ return [];
683
+ }
684
+ function parsePackageManagerField(packageManager) {
685
+ const [name, _version] = (packageManager || "").split("@");
686
+ const [version, buildMeta] = _version?.split("+") || [];
687
+ if (name && name !== "-" && /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(name)) return {
688
+ name,
689
+ version,
690
+ buildMeta
691
+ };
692
+ const sanitized = (name || "").replace(/\W+/g, "");
693
+ return {
694
+ name: sanitized,
695
+ version,
696
+ buildMeta,
697
+ warnings: [`Abnormal characters found in \`packageManager\` field, sanitizing from \`${name}\` to \`${sanitized}\``]
698
+ };
699
+ }
700
+ const packageManagers = [
701
+ {
702
+ name: "npm",
703
+ command: "npm",
704
+ lockFile: "package-lock.json"
705
+ },
706
+ {
707
+ name: "pnpm",
708
+ command: "pnpm",
709
+ lockFile: "pnpm-lock.yaml",
710
+ files: ["pnpm-workspace.yaml"]
711
+ },
712
+ {
713
+ name: "bun",
714
+ command: "bun",
715
+ lockFile: ["bun.lockb", "bun.lock"]
716
+ },
717
+ {
718
+ name: "yarn",
719
+ command: "yarn",
720
+ lockFile: "yarn.lock",
721
+ files: [".yarnrc.yml"]
722
+ },
723
+ {
724
+ name: "deno",
725
+ command: "deno",
726
+ lockFile: "deno.lock",
727
+ files: ["deno.json"]
728
+ }
729
+ ];
730
+ async function detectPackageManager(cwd, options = {}) {
731
+ const detected = await findup(resolve$1(cwd || "."), async (path) => {
732
+ if (!options.ignorePackageJSON) {
733
+ const packageJSONPath = join$1(path, "package.json");
734
+ if (existsSync(packageJSONPath)) {
735
+ const packageJSON = JSON.parse(await readFile(packageJSONPath, "utf8"));
736
+ if (packageJSON?.packageManager) {
737
+ const { name, version = "0.0.0", buildMeta, warnings } = parsePackageManagerField(packageJSON.packageManager);
738
+ if (name) {
739
+ const majorVersion = version.split(".")[0];
740
+ const packageManager = packageManagers.find((pm) => pm.name === name && pm.majorVersion === majorVersion) || packageManagers.find((pm) => pm.name === name);
741
+ return {
742
+ name,
743
+ command: name,
744
+ version,
745
+ majorVersion,
746
+ buildMeta,
747
+ warnings,
748
+ files: packageManager?.files,
749
+ lockFile: packageManager?.lockFile
750
+ };
751
+ }
752
+ }
753
+ }
754
+ if (existsSync(join$1(path, "deno.json"))) return packageManagers.find((pm) => pm.name === "deno");
755
+ }
756
+ if (!options.ignoreLockFile) {
757
+ for (const packageManager of packageManagers) if ([packageManager.lockFile, packageManager.files].flat().filter(Boolean).some((file) => existsSync(resolve$1(path, file)))) return { ...packageManager };
758
+ }
759
+ }, { includeParentDirs: options.includeParentDirs ?? true });
760
+ if (!detected && !options.ignoreArgv) {
761
+ const scriptArg = process.argv[1];
762
+ if (scriptArg) {
763
+ for (const packageManager of packageManagers) if (new RegExp(`[/\\\\]\\.?${packageManager.command}`).test(scriptArg)) return packageManager;
764
+ }
765
+ }
766
+ return detected;
767
+ }
768
+ async function addDependency(name, options = {}) {
769
+ const resolvedOptions = await resolveOperationOptions(options);
770
+ const names = Array.isArray(name) ? name : [name];
771
+ if (resolvedOptions.packageManager.name === "deno") {
772
+ for (let i = 0; i < names.length; i++) if (!/^(npm|jsr|file):.+$/.test(names[i] || "")) names[i] = `npm:${names[i]}`;
773
+ }
774
+ if (names.length === 0) return {};
775
+ const args = (resolvedOptions.packageManager.name === "yarn" ? [
776
+ ...getWorkspaceArgs(resolvedOptions),
777
+ resolvedOptions.global && resolvedOptions.packageManager.majorVersion === "1" ? "global" : "",
778
+ "add",
779
+ resolvedOptions.dev ? "-D" : "",
780
+ ...names
781
+ ] : [
782
+ resolvedOptions.packageManager.name === "npm" ? "install" : "add",
783
+ ...getWorkspaceArgs(resolvedOptions),
784
+ resolvedOptions.dev ? "-D" : "",
785
+ resolvedOptions.global ? "-g" : "",
786
+ ...names
787
+ ]).filter(Boolean);
788
+ if (!resolvedOptions.dry) await executeCommand(resolvedOptions.packageManager.command, args, {
789
+ cwd: resolvedOptions.cwd,
790
+ silent: resolvedOptions.silent,
791
+ corepack: resolvedOptions.corepack
792
+ });
793
+ if (!resolvedOptions.dry && options.installPeerDependencies) {
794
+ const existingPkg = await readPackageJSON(resolvedOptions.cwd);
795
+ const peerDeps = [];
796
+ const peerDevDeps = [];
797
+ const _require = createRequire(join(resolvedOptions.cwd, "/_.js"));
798
+ for (const _name of names) {
799
+ const pkgName = _name.match(/^(.[^@]+)/)?.[0];
800
+ const pkg = await readPackageJSON(_require.resolve(pkgName));
801
+ if (!pkg?.peerDependencies || pkg?.name !== pkgName) continue;
802
+ for (const [peerDependency, version] of Object.entries(pkg.peerDependencies)) {
803
+ if (pkg.peerDependenciesMeta?.[peerDependency]?.optional) continue;
804
+ if (existingPkg?.dependencies?.[peerDependency] || existingPkg?.devDependencies?.[peerDependency]) continue;
805
+ (pkg.peerDependenciesMeta?.[peerDependency]?.dev ? peerDevDeps : peerDeps).push(`${peerDependency}@${version}`);
806
+ }
807
+ }
808
+ if (peerDeps.length > 0) await addDependency(peerDeps, { ...resolvedOptions });
809
+ if (peerDevDeps.length > 0) await addDevDependency(peerDevDeps, { ...resolvedOptions });
810
+ }
811
+ return { exec: {
812
+ command: resolvedOptions.packageManager.command,
813
+ args
814
+ } };
815
+ }
816
+ async function addDevDependency(name, options = {}) {
817
+ return await addDependency(name, {
818
+ ...options,
819
+ dev: true
820
+ });
821
+ }
822
+ export { packageManagers as i, addDevDependency as n, detectPackageManager as r, addDependency as t };