@socketsecurity/lib 6.0.3 → 6.0.5

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 (542) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/_virtual/_rolldown/runtime.js +45 -0
  3. package/dist/abort/signal.js +53 -59
  4. package/dist/ai/discover.js +110 -110
  5. package/dist/ai/profiles.js +94 -65
  6. package/dist/ai/spawn.js +172 -194
  7. package/dist/ai/types.js +1 -17
  8. package/dist/ai/worktree.js +160 -183
  9. package/dist/ansi/constants.js +16 -38
  10. package/dist/ansi/strip.js +44 -41
  11. package/dist/archives/_internal.js +64 -73
  12. package/dist/archives/detect.js +30 -43
  13. package/dist/archives/extract.js +43 -50
  14. package/dist/archives/tar.js +197 -228
  15. package/dist/archives/types.js +1 -17
  16. package/dist/archives/zip.js +85 -121
  17. package/dist/argv/flag-predicates.js +203 -101
  18. package/dist/argv/flag-types.js +96 -113
  19. package/dist/argv/parse-args-string.d.ts +16 -14
  20. package/dist/argv/parse-args-string.js +42 -39
  21. package/dist/argv/parse.js +145 -163
  22. package/dist/arrays/_internal.js +65 -48
  23. package/dist/arrays/chunk.js +51 -40
  24. package/dist/arrays/join.js +87 -35
  25. package/dist/arrays/predicates.js +46 -28
  26. package/dist/arrays/unique.js +45 -31
  27. package/dist/bin/_internal.js +34 -42
  28. package/dist/bin/check-primordials.js +175 -233
  29. package/dist/bin/check.js +51 -72
  30. package/dist/bin/exec.js +70 -74
  31. package/dist/bin/find.js +151 -134
  32. package/dist/bin/resolve.js +180 -246
  33. package/dist/bin/shadow.js +24 -33
  34. package/dist/bin/socket-lib.js +51 -73
  35. package/dist/bin/types.js +1 -17
  36. package/dist/bin/which.js +211 -146
  37. package/dist/cacache/_internal.js +25 -40
  38. package/dist/cacache/clear.js +79 -72
  39. package/dist/cacache/read.js +48 -46
  40. package/dist/cacache/tmp.js +29 -36
  41. package/dist/cacache/types.js +1 -17
  42. package/dist/cacache/write.js +43 -48
  43. package/dist/cache/ttl/store.js +232 -288
  44. package/dist/cache/ttl/types.js +1 -17
  45. package/dist/checks/primordials-defaults.js +83 -89
  46. package/dist/checks/primordials.js +225 -277
  47. package/dist/colors/convert.js +45 -37
  48. package/dist/colors/palette.js +88 -45
  49. package/dist/colors/socket-palette.js +74 -84
  50. package/dist/colors/types.js +1 -17
  51. package/dist/compression/_internal.js +57 -72
  52. package/dist/compression/brotli.js +94 -127
  53. package/dist/compression/gzip.js +95 -121
  54. package/dist/compression/types.js +1 -17
  55. package/dist/constants/agents.js +61 -113
  56. package/dist/constants/encoding.js +19 -42
  57. package/dist/constants/github.js +12 -30
  58. package/dist/constants/licenses.js +48 -63
  59. package/dist/constants/lifecycle-script-names.js +31 -45
  60. package/dist/constants/maintained-node-versions.js +22 -37
  61. package/dist/constants/node.js +226 -167
  62. package/dist/constants/package-default-node-range.js +16 -41
  63. package/dist/constants/package-default-socket-categories.js +12 -30
  64. package/dist/constants/packages.js +77 -126
  65. package/dist/constants/platform.js +27 -49
  66. package/dist/constants/sentinels.js +23 -48
  67. package/dist/constants/socket.js +42 -87
  68. package/dist/constants/testing.js +15 -34
  69. package/dist/constants/time.js +16 -36
  70. package/dist/constants/typescript.js +32 -52
  71. package/dist/cover/code.js +111 -142
  72. package/dist/cover/formatters.js +118 -101
  73. package/dist/cover/type.js +50 -76
  74. package/dist/cover/types.js +1 -17
  75. package/dist/crypto/hash.js +54 -46
  76. package/dist/debug/_internal.js +62 -71
  77. package/dist/debug/caller-info.js +53 -64
  78. package/dist/debug/namespace.js +80 -90
  79. package/dist/debug/output.js +172 -188
  80. package/dist/debug/types.js +1 -17
  81. package/dist/dlx/_internal.js +24 -43
  82. package/dist/dlx/arborist.js +162 -160
  83. package/dist/dlx/binary-cache.js +228 -200
  84. package/dist/dlx/binary-download.js +172 -211
  85. package/dist/dlx/binary-resolution.js +165 -157
  86. package/dist/dlx/binary-types.js +1 -17
  87. package/dist/dlx/binary.js +149 -189
  88. package/dist/dlx/cache.js +45 -30
  89. package/dist/dlx/detect.js +245 -159
  90. package/dist/dlx/dir.js +67 -51
  91. package/dist/dlx/firewall.js +62 -100
  92. package/dist/dlx/lockfile.js +122 -127
  93. package/dist/dlx/manifest.js +264 -274
  94. package/dist/dlx/package.js +241 -244
  95. package/dist/dlx/packages.js +99 -96
  96. package/dist/dlx/paths.js +73 -59
  97. package/dist/dlx/spec.js +52 -60
  98. package/dist/dlx/types.js +1 -17
  99. package/dist/eco/cargo/lockfile-format.js +19 -36
  100. package/dist/eco/cargo/manifest-format.js +17 -35
  101. package/dist/eco/cargo/parse-lockfile.js +210 -237
  102. package/dist/eco/manifest/analyze-lockfile.js +46 -63
  103. package/dist/eco/manifest/detect-format.js +66 -90
  104. package/dist/eco/manifest/find-packages.js +39 -64
  105. package/dist/eco/manifest/get-package-versions.js +27 -48
  106. package/dist/eco/manifest/get-package.js +21 -40
  107. package/dist/eco/manifest/manifest-error.js +14 -35
  108. package/dist/eco/manifest/parse-lockfile.js +40 -86
  109. package/dist/eco/manifest/parse-manifest.js +26 -43
  110. package/dist/eco/manifest/parse.js +26 -47
  111. package/dist/eco/manifest/types.js +1 -17
  112. package/dist/eco/npm/bun/exec.js +23 -32
  113. package/dist/eco/npm/manifest-format.js +21 -35
  114. package/dist/eco/npm/npm/exec.js +51 -61
  115. package/dist/eco/npm/npm/extract-package-name-from-path.js +28 -50
  116. package/dist/eco/npm/npm/flags.js +80 -52
  117. package/dist/eco/npm/npm/lockfile-format.js +21 -40
  118. package/dist/eco/npm/npm/parse-git-url.js +26 -40
  119. package/dist/eco/npm/npm/parse-lockfile.js +184 -210
  120. package/dist/eco/npm/parse-package-json.js +71 -102
  121. package/dist/eco/npm/pnpm/detect-pnpm-version.js +22 -43
  122. package/dist/eco/npm/pnpm/exec.js +51 -62
  123. package/dist/eco/npm/pnpm/flags.js +75 -68
  124. package/dist/eco/npm/pnpm/lockfile-format.js +19 -36
  125. package/dist/eco/npm/pnpm/parse-lockfile.js +235 -259
  126. package/dist/eco/npm/pnpm/parse-pnpm-package-id-v5.js +37 -47
  127. package/dist/eco/npm/pnpm/parse-pnpm-package-id-v6-v9.js +36 -49
  128. package/dist/eco/npm/script.js +82 -90
  129. package/dist/eco/npm/vlt/exec.js +24 -32
  130. package/dist/eco/npm/yarnpkg/yarn/exec.js +60 -59
  131. package/dist/eco/npm/yarnpkg/yarn/lockfile-format.js +20 -36
  132. package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.js +194 -242
  133. package/dist/eco/npm/yarnpkg/yarn/parse-yarn-descriptor.js +37 -61
  134. package/dist/eco/purl.js +50 -60
  135. package/dist/eco/types.js +1 -17
  136. package/dist/effects/pulse-frames.js +64 -65
  137. package/dist/effects/shimmer-keyframes.js +71 -52
  138. package/dist/effects/shimmer-terminal.js +81 -50
  139. package/dist/effects/shimmer.js +290 -153
  140. package/dist/env/boolean.js +42 -43
  141. package/dist/env/case-insensitive.js +54 -39
  142. package/dist/env/ci.js +29 -31
  143. package/dist/env/debug.js +28 -31
  144. package/dist/env/github.js +144 -59
  145. package/dist/env/home.js +38 -31
  146. package/dist/env/locale.js +59 -39
  147. package/dist/env/node-auth-token.js +28 -31
  148. package/dist/env/node-env.js +28 -31
  149. package/dist/env/npm.js +94 -47
  150. package/dist/env/number.js +50 -51
  151. package/dist/env/package-manager.js +95 -83
  152. package/dist/env/path.js +28 -31
  153. package/dist/env/pre-commit.js +30 -32
  154. package/dist/env/proxy.js +121 -122
  155. package/dist/env/rewire.js +204 -96
  156. package/dist/env/shell.js +28 -31
  157. package/dist/env/socket-cli.js +233 -81
  158. package/dist/env/socket.js +521 -156
  159. package/dist/env/string.js +43 -44
  160. package/dist/env/temp-dir.js +59 -39
  161. package/dist/env/term.js +28 -31
  162. package/dist/env/test.js +65 -43
  163. package/dist/env/types.js +1 -17
  164. package/dist/env/windows.js +78 -43
  165. package/dist/env/xdg.js +62 -39
  166. package/dist/errors/message.js +40 -46
  167. package/dist/errors/predicates.js +61 -49
  168. package/dist/errors/stack.js +24 -36
  169. package/dist/events/exit/_internal.js +86 -103
  170. package/dist/events/exit/handler.js +48 -55
  171. package/dist/events/exit/intercept.js +49 -70
  172. package/dist/events/exit/lifecycle.js +92 -101
  173. package/dist/events/exit/signals.js +25 -31
  174. package/dist/events/exit/types.js +1 -17
  175. package/dist/events/warning/handler.js +43 -40
  176. package/dist/events/warning/suppress.js +111 -90
  177. package/dist/external/@npmcli/package-json/lib/read-package.js +132 -153
  178. package/dist/external/@npmcli/package-json/lib/sort.js +73 -105
  179. package/dist/external/@npmcli/package-json.js +12705 -15140
  180. package/dist/external/@npmcli/promise-spawn.js +451 -472
  181. package/dist/external/@sinclair/typebox/value.js +7443 -9002
  182. package/dist/external/@sinclair/typebox.js +7516 -7885
  183. package/dist/external/@socketregistry/is-unicode-supported.js +31 -39
  184. package/dist/external/@socketregistry/packageurl-js.js +6127 -7369
  185. package/dist/external/@socketregistry/yocto-spinner.js +394 -455
  186. package/dist/external/@yarnpkg/extensions.js +435 -1022
  187. package/dist/external/adm-zip.js +2313 -2673
  188. package/dist/external/debug.js +700 -687
  189. package/dist/external/external-pack.js +2658 -3171
  190. package/dist/external/fast-sort.js +124 -138
  191. package/dist/external/get-east-asian-width.js +70 -64
  192. package/dist/external/libnpmexec.js +28 -31
  193. package/dist/external/npm-pack.js +43617 -50137
  194. package/dist/external/p-map.js +198 -222
  195. package/dist/external/pico-pack.js +6735 -7304
  196. package/dist/external/pony-cause.js +143 -139
  197. package/dist/external/shell-quote.js +226 -0
  198. package/dist/external/spdx-pack.js +1283 -1403
  199. package/dist/external/streaming-iterables.js +835 -1052
  200. package/dist/external/tar-fs.js +2769 -3048
  201. package/dist/external/which.js +267 -251
  202. package/dist/external/yargs-parser.js +851 -1074
  203. package/dist/external-tools/bazel/asset-names.js +98 -90
  204. package/dist/external-tools/bazel/from-download.js +52 -46
  205. package/dist/external-tools/bazel/from-path.js +27 -38
  206. package/dist/external-tools/bazel/read-bazel-version-file.js +35 -57
  207. package/dist/external-tools/bazel/resolve-asset-url.js +24 -39
  208. package/dist/external-tools/bazel/resolve-bazel-version.js +34 -56
  209. package/dist/external-tools/bazel/resolve.js +44 -58
  210. package/dist/external-tools/bazel/types.js +1 -17
  211. package/dist/external-tools/cdxgen/asset-names.js +59 -66
  212. package/dist/external-tools/cdxgen/from-download.js +52 -80
  213. package/dist/external-tools/cdxgen/from-path.js +19 -37
  214. package/dist/external-tools/cdxgen/from-vfs.js +22 -43
  215. package/dist/external-tools/cdxgen/resolve.js +48 -63
  216. package/dist/external-tools/cdxgen/types.js +1 -17
  217. package/dist/external-tools/from-download.js +107 -67
  218. package/dist/external-tools/janus/asset-names.js +44 -51
  219. package/dist/external-tools/janus/from-download.js +45 -70
  220. package/dist/external-tools/janus/from-path.js +19 -37
  221. package/dist/external-tools/janus/from-vfs.js +22 -43
  222. package/dist/external-tools/janus/resolve.js +45 -63
  223. package/dist/external-tools/janus/types.js +1 -17
  224. package/dist/external-tools/jre/asset-names.js +109 -82
  225. package/dist/external-tools/jre/detect-platform-arch.js +25 -49
  226. package/dist/external-tools/jre/from-download.js +71 -67
  227. package/dist/external-tools/jre/from-java-home.js +27 -54
  228. package/dist/external-tools/jre/from-path.js +27 -49
  229. package/dist/external-tools/jre/from-vfs.js +39 -60
  230. package/dist/external-tools/jre/resolve.js +55 -68
  231. package/dist/external-tools/jre/types.js +1 -17
  232. package/dist/external-tools/manifest.js +130 -150
  233. package/dist/external-tools/opengrep/asset-names.js +60 -72
  234. package/dist/external-tools/opengrep/from-download.js +58 -80
  235. package/dist/external-tools/opengrep/from-path.js +19 -37
  236. package/dist/external-tools/opengrep/from-vfs.js +23 -43
  237. package/dist/external-tools/opengrep/resolve.js +43 -63
  238. package/dist/external-tools/opengrep/types.js +1 -17
  239. package/dist/external-tools/sbt/asset-names.js +21 -30
  240. package/dist/external-tools/sbt/from-download.js +50 -61
  241. package/dist/external-tools/sbt/from-path.js +23 -38
  242. package/dist/external-tools/sbt/from-vfs.js +30 -44
  243. package/dist/external-tools/sbt/resolve.js +45 -63
  244. package/dist/external-tools/sbt/types.js +1 -17
  245. package/dist/external-tools/synp/asset-names.js +11 -29
  246. package/dist/external-tools/synp/from-download.js +24 -41
  247. package/dist/external-tools/synp/from-path.js +19 -37
  248. package/dist/external-tools/synp/from-vfs.js +22 -43
  249. package/dist/external-tools/synp/resolve.js +43 -62
  250. package/dist/external-tools/synp/types.js +1 -17
  251. package/dist/external-tools/trivy/asset-names.js +51 -62
  252. package/dist/external-tools/trivy/from-download.js +42 -64
  253. package/dist/external-tools/trivy/from-path.js +19 -37
  254. package/dist/external-tools/trivy/from-vfs.js +22 -43
  255. package/dist/external-tools/trivy/resolve.js +43 -63
  256. package/dist/external-tools/trivy/types.js +1 -17
  257. package/dist/external-tools/trufflehog/asset-names.js +54 -66
  258. package/dist/external-tools/trufflehog/from-download.js +44 -62
  259. package/dist/external-tools/trufflehog/from-path.js +21 -37
  260. package/dist/external-tools/trufflehog/from-vfs.js +26 -43
  261. package/dist/external-tools/trufflehog/resolve.js +43 -63
  262. package/dist/external-tools/trufflehog/types.js +1 -17
  263. package/dist/external-tools/uv/asset-names.js +64 -74
  264. package/dist/external-tools/uv/from-download.js +44 -65
  265. package/dist/external-tools/uv/from-path.js +19 -37
  266. package/dist/external-tools/uv/from-vfs.js +22 -43
  267. package/dist/external-tools/uv/resolve.js +42 -63
  268. package/dist/external-tools/uv/types.js +1 -17
  269. package/dist/fs/_internal.js +40 -42
  270. package/dist/fs/access.js +57 -54
  271. package/dist/fs/encoding.js +80 -97
  272. package/dist/fs/find-up.js +126 -125
  273. package/dist/fs/inspect.js +168 -99
  274. package/dist/fs/path-cache.js +31 -32
  275. package/dist/fs/read-dir.js +102 -79
  276. package/dist/fs/read-file.js +177 -118
  277. package/dist/fs/read-json-cache.js +150 -134
  278. package/dist/fs/read-json.js +172 -187
  279. package/dist/fs/resolve-module.js +35 -58
  280. package/dist/fs/safe.js +278 -169
  281. package/dist/fs/types.js +1 -17
  282. package/dist/fs/unique.js +52 -48
  283. package/dist/fs/validate.js +56 -40
  284. package/dist/fs/write-json.js +109 -75
  285. package/dist/git/_internal.js +251 -216
  286. package/dist/git/changed.js +191 -74
  287. package/dist/git/repo.js +118 -104
  288. package/dist/git/staged.js +172 -62
  289. package/dist/git/types.js +1 -17
  290. package/dist/git/unstaged.js +175 -62
  291. package/dist/github/constants.js +25 -33
  292. package/dist/github/errors.js +46 -38
  293. package/dist/github/fetch.js +137 -82
  294. package/dist/github/ghsa.js +217 -151
  295. package/dist/github/refs-cache.js +54 -43
  296. package/dist/github/refs-graphql.js +97 -89
  297. package/dist/github/refs-rest.js +70 -101
  298. package/dist/github/refs.js +105 -64
  299. package/dist/github/token.js +96 -48
  300. package/dist/github/types.js +1 -17
  301. package/dist/globs/_internal.js +73 -82
  302. package/dist/globs/defaults.js +40 -59
  303. package/dist/globs/match.js +93 -77
  304. package/dist/globs/matcher.js +104 -92
  305. package/dist/globs/stream.js +43 -55
  306. package/dist/globs/types.js +1 -17
  307. package/dist/http-request/_internal.js +11 -38
  308. package/dist/http-request/browser-fetch.js +19 -29
  309. package/dist/http-request/browser.js +188 -206
  310. package/dist/http-request/checksums.js +101 -65
  311. package/dist/http-request/download-types.js +1 -17
  312. package/dist/http-request/download.js +195 -196
  313. package/dist/http-request/errors.js +39 -47
  314. package/dist/http-request/headers.js +95 -80
  315. package/dist/http-request/http-request.js +10 -35
  316. package/dist/http-request/node.js +71 -97
  317. package/dist/http-request/request-attempt.js +232 -285
  318. package/dist/http-request/request-types.js +1 -17
  319. package/dist/http-request/request.js +106 -108
  320. package/dist/http-request/response-reader.js +47 -51
  321. package/dist/http-request/response-types.js +22 -38
  322. package/dist/http-request/user-agent.js +73 -55
  323. package/dist/integrity.js +105 -106
  324. package/dist/ipc/_internal.js +34 -48
  325. package/dist/ipc/directory.js +55 -63
  326. package/dist/ipc/paths.js +52 -45
  327. package/dist/ipc/types.js +1 -17
  328. package/dist/ipc/write.js +81 -74
  329. package/dist/ipc-cli/get.js +29 -56
  330. package/dist/ipc-cli/types.js +1 -17
  331. package/dist/json/edit.js +182 -242
  332. package/dist/json/format.js +202 -103
  333. package/dist/json/parse.js +206 -109
  334. package/dist/json/types.js +1 -17
  335. package/dist/links/create.js +93 -60
  336. package/dist/links/types.js +1 -17
  337. package/dist/logger/_internal.js +109 -73
  338. package/dist/logger/browser.js +45 -56
  339. package/dist/logger/colors.js +31 -49
  340. package/dist/logger/console.js +89 -112
  341. package/dist/logger/default.js +19 -33
  342. package/dist/logger/logger.js +5 -29
  343. package/dist/logger/node.js +793 -854
  344. package/dist/logger/symbols-builder.js +54 -56
  345. package/dist/logger/symbols.js +135 -118
  346. package/dist/logger/types.js +1 -17
  347. package/dist/memo/_internal.js +39 -49
  348. package/dist/memo/async.js +133 -117
  349. package/dist/memo/clear.js +25 -34
  350. package/dist/memo/decorator.js +43 -37
  351. package/dist/memo/memoize.js +97 -88
  352. package/dist/memo/once.js +42 -41
  353. package/dist/memo/types.js +1 -17
  354. package/dist/memo/weak.js +45 -41
  355. package/dist/node/async-hooks.js +9 -30
  356. package/dist/node/child-process.js +9 -30
  357. package/dist/node/crypto.js +9 -30
  358. package/dist/node/events.js +9 -30
  359. package/dist/node/fs-promises.js +9 -30
  360. package/dist/node/fs.js +9 -30
  361. package/dist/node/http.js +9 -30
  362. package/dist/node/https.js +9 -30
  363. package/dist/node/module.js +20 -34
  364. package/dist/node/os.js +9 -30
  365. package/dist/node/path.js +9 -30
  366. package/dist/node/timers-promises.js +9 -30
  367. package/dist/node/url.js +9 -30
  368. package/dist/node/util.js +9 -30
  369. package/dist/objects/getters.js +185 -126
  370. package/dist/objects/inspect.js +85 -52
  371. package/dist/objects/mutate.js +96 -76
  372. package/dist/objects/predicates.js +112 -59
  373. package/dist/objects/sort.js +120 -76
  374. package/dist/objects/types.js +1 -17
  375. package/dist/packages/edit-class.js +198 -265
  376. package/dist/packages/edit.js +79 -86
  377. package/dist/packages/exports.js +146 -157
  378. package/dist/packages/isolation.js +159 -209
  379. package/dist/packages/licenses.js +207 -189
  380. package/dist/packages/manifest.js +134 -172
  381. package/dist/packages/normalize.js +91 -102
  382. package/dist/packages/operations.d.ts +2 -0
  383. package/dist/packages/operations.js +283 -254
  384. package/dist/packages/provenance.js +195 -245
  385. package/dist/packages/specs.js +94 -84
  386. package/dist/packages/types.js +1 -17
  387. package/dist/packages/validation.js +49 -50
  388. package/dist/paths/_internal.js +82 -86
  389. package/dist/paths/conversion.js +112 -65
  390. package/dist/paths/dirnames.js +17 -42
  391. package/dist/paths/exts.js +23 -54
  392. package/dist/paths/filenames.js +21 -50
  393. package/dist/paths/globs.js +15 -38
  394. package/dist/paths/normalize.js +215 -236
  395. package/dist/paths/packages.js +34 -49
  396. package/dist/paths/predicates.js +184 -106
  397. package/dist/paths/resolve.js +146 -128
  398. package/dist/paths/rewire.js +108 -72
  399. package/dist/paths/socket.js +252 -132
  400. package/dist/paths/walk.js +55 -60
  401. package/dist/perf/_internal.js +10 -28
  402. package/dist/perf/enabled.js +21 -30
  403. package/dist/perf/metrics.js +81 -67
  404. package/dist/perf/report.js +79 -80
  405. package/dist/perf/timer.js +180 -126
  406. package/dist/perf/types.js +1 -17
  407. package/dist/pkg-ext/data.js +29 -82
  408. package/dist/pkg-ext/types.js +1 -17
  409. package/dist/primordials/array.js +120 -198
  410. package/dist/primordials/buffer.js +28 -51
  411. package/dist/primordials/date.js +26 -51
  412. package/dist/primordials/error.js +33 -59
  413. package/dist/primordials/function.js +21 -41
  414. package/dist/primordials/globals.js +25 -48
  415. package/dist/primordials/json.js +14 -30
  416. package/dist/primordials/map-set.js +88 -152
  417. package/dist/primordials/math.js +59 -116
  418. package/dist/primordials/number.js +41 -76
  419. package/dist/primordials/object.js +56 -116
  420. package/dist/primordials/promise.js +28 -52
  421. package/dist/primordials/reflect.js +24 -52
  422. package/dist/primordials/regexp.js +25 -47
  423. package/dist/primordials/string.js +114 -167
  424. package/dist/primordials/symbol.js +40 -72
  425. package/dist/primordials/uncurry.js +38 -55
  426. package/dist/primordials/url.js +27 -66
  427. package/dist/process/_internal.js +7 -32
  428. package/dist/process/abort.js +29 -35
  429. package/dist/process/lock-instance.js +26 -30
  430. package/dist/process/lock-manager.js +279 -307
  431. package/dist/process/lock-types.js +1 -17
  432. package/dist/process/spawn/_internal.js +43 -55
  433. package/dist/process/spawn/child.js +172 -211
  434. package/dist/process/spawn/errors.js +116 -113
  435. package/dist/process/spawn/stdio.js +51 -35
  436. package/dist/process/spawn/types.js +1 -17
  437. package/dist/process/transient.js +49 -66
  438. package/dist/promises/_internal.js +31 -34
  439. package/dist/promises/iterate.js +238 -102
  440. package/dist/promises/options.js +123 -101
  441. package/dist/promises/queue.js +115 -136
  442. package/dist/promises/resolvers.js +77 -46
  443. package/dist/promises/retry.js +156 -101
  444. package/dist/promises/types.js +1 -17
  445. package/dist/regexps/escape.js +32 -30
  446. package/dist/regexps/hex.js +16 -33
  447. package/dist/regexps/spec.js +53 -81
  448. package/dist/releases/github-archives.js +127 -118
  449. package/dist/releases/github-asset-url.js +162 -146
  450. package/dist/releases/github-assets.js +37 -49
  451. package/dist/releases/github-auth.js +32 -48
  452. package/dist/releases/github-downloads.js +118 -138
  453. package/dist/releases/github-listing.js +175 -145
  454. package/dist/releases/github-retry-config.js +41 -47
  455. package/dist/releases/github-types.js +1 -17
  456. package/dist/releases/socket-btm.js +273 -192
  457. package/dist/schema/parse.js +35 -36
  458. package/dist/schema/types.js +1 -17
  459. package/dist/schema/validate.js +118 -99
  460. package/dist/sea/detect.js +57 -52
  461. package/dist/secrets/_internal.js +86 -67
  462. package/dist/secrets/find.js +96 -77
  463. package/dist/secrets/keychain.js +315 -309
  464. package/dist/secrets/linux.js +133 -135
  465. package/dist/secrets/macos.js +151 -147
  466. package/dist/secrets/rc.js +182 -181
  467. package/dist/secrets/socket-api-token.js +28 -43
  468. package/dist/secrets/types.js +1 -17
  469. package/dist/secrets/windows.js +184 -242
  470. package/dist/shadow/skip.js +51 -70
  471. package/dist/shadow/types.js +1 -17
  472. package/dist/shell/parse.d.ts +26 -0
  473. package/dist/shell/parse.js +35 -0
  474. package/dist/shell/quote.d.ts +19 -0
  475. package/dist/shell/quote.js +30 -0
  476. package/dist/smol/detect.js +67 -43
  477. package/dist/smol/http.js +33 -37
  478. package/dist/smol/https.js +31 -37
  479. package/dist/smol/manifest.js +33 -37
  480. package/dist/smol/path.js +33 -37
  481. package/dist/smol/primordial.js +35 -37
  482. package/dist/smol/purl.js +34 -37
  483. package/dist/smol/versions.js +31 -37
  484. package/dist/smol/vfs.js +46 -38
  485. package/dist/sorts/_internal.js +14 -40
  486. package/dist/sorts/natural.js +57 -64
  487. package/dist/sorts/semver.js +33 -43
  488. package/dist/sorts/strings.js +24 -30
  489. package/dist/sorts/types.js +1 -17
  490. package/dist/spinner/default.js +72 -63
  491. package/dist/spinner/format.js +86 -71
  492. package/dist/spinner/spinner.js +749 -797
  493. package/dist/spinner/types.js +1 -17
  494. package/dist/spinner/with.js +193 -137
  495. package/dist/ssri/convert.js +64 -47
  496. package/dist/ssri/parse.js +38 -37
  497. package/dist/ssri/validate.js +51 -34
  498. package/dist/stdio/_internal.js +50 -46
  499. package/dist/stdio/clear.js +208 -86
  500. package/dist/stdio/divider.js +170 -97
  501. package/dist/stdio/footer.js +116 -110
  502. package/dist/stdio/header.js +117 -90
  503. package/dist/stdio/progress.js +189 -218
  504. package/dist/stdio/prompts.js +244 -168
  505. package/dist/stdio/stderr.js +173 -78
  506. package/dist/stdio/stdout.js +177 -94
  507. package/dist/streams/parallel.js +58 -50
  508. package/dist/streams/transform.js +36 -45
  509. package/dist/strings/format.js +145 -63
  510. package/dist/strings/predicates.js +56 -34
  511. package/dist/strings/search.js +52 -42
  512. package/dist/strings/transform.js +113 -72
  513. package/dist/strings/types.js +1 -17
  514. package/dist/strings/width.js +89 -82
  515. package/dist/tables/bordered.js +81 -81
  516. package/dist/tables/padding.js +36 -46
  517. package/dist/tables/simple.js +62 -70
  518. package/dist/tables/types.js +1 -17
  519. package/dist/temporal/instant.js +72 -81
  520. package/dist/temporal/now.js +40 -31
  521. package/dist/temporal/slots.js +42 -36
  522. package/dist/temporal/system.js +36 -36
  523. package/dist/temporal/temporal.js +11 -41
  524. package/dist/themes/context.js +131 -69
  525. package/dist/themes/resolve.js +207 -132
  526. package/dist/themes/themes.js +225 -194
  527. package/dist/themes/types.js +1 -17
  528. package/dist/url/parse.js +48 -51
  529. package/dist/url/predicates.js +24 -31
  530. package/dist/url/search-params.js +133 -101
  531. package/dist/url/types.js +1 -17
  532. package/dist/versions/_internal.js +31 -33
  533. package/dist/versions/compare.js +80 -58
  534. package/dist/versions/modify.js +41 -39
  535. package/dist/versions/parse.js +88 -64
  536. package/dist/versions/range.js +58 -41
  537. package/dist/versions/types.js +1 -17
  538. package/dist/words/article.js +22 -30
  539. package/dist/words/capitalize.js +25 -34
  540. package/dist/words/pluralize.js +23 -31
  541. package/dist/words/types.js +1 -17
  542. package/package.json +17 -5
@@ -1,4 +1,57 @@
1
+ "use strict";
2
+ /**
3
+ * Bundled from yargs-parser
4
+ * This is a zero-dependency bundle created by rolldown.
5
+ */
6
+ 'use strict';
7
+
8
+ //#region \0rolldown/runtime.js
9
+ var __defProp = Object.defineProperty;
10
+ var __name = (target, value) => __defProp(target, "name", {
11
+ value,
12
+ configurable: true
13
+ });
14
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
15
+ var __getOwnPropNames = Object.getOwnPropertyNames;
16
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
17
+ var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
18
+ var __exportAll = (all, no_symbols) => {
19
+ let target = {};
20
+ for (var name in all) {
21
+ __defProp(target, name, {
22
+ get: all[name],
23
+ enumerable: true
24
+ });
25
+ }
26
+ if (!no_symbols) {
27
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
28
+ }
29
+ return target;
30
+ };
31
+ var __copyProps = (to, from, except, desc) => {
32
+ if (from && typeof from === "object" || typeof from === "function") {
33
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
34
+ key = keys[i];
35
+ if (!__hasOwnProp.call(to, key) && key !== except) {
36
+ __defProp(to, key, {
37
+ get: ((k) => from[k]).bind(null, key),
38
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
39
+ });
40
+ }
41
+ }
42
+ }
43
+ return to;
44
+ };
45
+ var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
+
47
+ //#endregion
48
+ let util = require("util");
49
+ let path = require("path");
50
+ let fs = require("fs");
51
+ let node_module = require("node:module");
52
+
1
53
  const { ArrayIsArray: _p_ArrayIsArray } = require('../primordials/array.js')
54
+
2
55
  const { JSONParse: _p_JSONParse } = require('../primordials/json.js')
3
56
 
4
57
  const { SetCtor: _p_SetCtor } = require('../primordials/map-set.js')
@@ -13,1104 +66,828 @@ const { RegExpCtor: _p_RegExpCtor } = require('../primordials/regexp.js')
13
66
 
14
67
  const { StringPrototypeCharAt: _p_StringPrototypeCharAt, StringPrototypeSubstring: _p_StringPrototypeSubstring } = require('../primordials/string.js')
15
68
 
16
- "use strict";
69
+ //#region node_modules/.pnpm/yargs-parser@22.0.0/node_modules/yargs-parser/build/lib/string-utils.js
17
70
  /**
18
- * Bundled from yargs-parser
19
- * This is a zero-dependency bundle created by esbuild.
20
- */
21
- "use strict";
22
- var __defProp = Object.defineProperty;
23
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
24
- var __getOwnPropNames = Object.getOwnPropertyNames;
25
- var __hasOwnProp = Object.prototype.hasOwnProperty;
26
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
27
- var __esm = (fn, res) => function __init() {
28
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
29
- };
30
- var __export = (target, all) => {
31
- for (var name in all)
32
- __defProp(target, name, { get: all[name], enumerable: true });
33
- };
34
- var __copyProps = (to, from, except, desc) => {
35
- if (from && typeof from === "object" || typeof from === "function") {
36
- for (let key of __getOwnPropNames(from))
37
- if (!__hasOwnProp.call(to, key) && key !== except)
38
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
39
- }
40
- return to;
41
- };
42
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
43
-
44
- // node_modules/.pnpm/yargs-parser@22.0.0/node_modules/yargs-parser/build/lib/string-utils.js
71
+ * @license
72
+ * Copyright (c) 2016, Contributors
73
+ * SPDX-License-Identifier: ISC
74
+ */
45
75
  function camelCase(str) {
46
- const isCamelCase = str !== str.toLowerCase() && str !== str.toUpperCase();
47
- if (!isCamelCase) {
48
- str = str.toLowerCase();
49
- }
50
- if (str.indexOf("-") === -1 && str.indexOf("_") === -1) {
51
- return str;
52
- } else {
53
- let camelcase = "";
54
- let nextChrUpper = false;
55
- const leadingHyphens = str.match(/^-+/);
56
- for (let i = leadingHyphens ? leadingHyphens[0].length : 0; i < str.length; i++) {
57
- let chr = _p_StringPrototypeCharAt(str, i);
58
- if (nextChrUpper) {
59
- nextChrUpper = false;
60
- chr = chr.toUpperCase();
61
- }
62
- if (i !== 0 && (chr === "-" || chr === "_")) {
63
- nextChrUpper = true;
64
- } else if (chr !== "-" && chr !== "_") {
65
- camelcase += chr;
66
- }
67
- }
68
- return camelcase;
69
- }
76
+ if (!(str !== str.toLowerCase() && str !== str.toUpperCase())) str = str.toLowerCase();
77
+ if (str.indexOf("-") === -1 && str.indexOf("_") === -1) return str;
78
+ else {
79
+ let camelcase = "";
80
+ let nextChrUpper = false;
81
+ const leadingHyphens = str.match(/^-+/);
82
+ for (let i = leadingHyphens ? leadingHyphens[0].length : 0; i < str.length; i++) {
83
+ let chr = _p_StringPrototypeCharAt(str, i);
84
+ if (nextChrUpper) {
85
+ nextChrUpper = false;
86
+ chr = chr.toUpperCase();
87
+ }
88
+ if (i !== 0 && (chr === "-" || chr === "_")) nextChrUpper = true;
89
+ else if (chr !== "-" && chr !== "_") camelcase += chr;
90
+ }
91
+ return camelcase;
92
+ }
70
93
  }
71
94
  function decamelize(str, joinString) {
72
- const lowercase = str.toLowerCase();
73
- joinString = joinString || "-";
74
- let notCamelcase = "";
75
- for (let i = 0; i < str.length; i++) {
76
- const chrLower = _p_StringPrototypeCharAt(lowercase, i);
77
- const chrString = _p_StringPrototypeCharAt(str, i);
78
- if (chrLower !== chrString && i > 0) {
79
- notCamelcase += `${joinString}${_p_StringPrototypeCharAt(lowercase, i)}`;
80
- } else {
81
- notCamelcase += chrString;
82
- }
83
- }
84
- return notCamelcase;
95
+ const lowercase = str.toLowerCase();
96
+ joinString = joinString || "-";
97
+ let notCamelcase = "";
98
+ for (let i = 0; i < str.length; i++) {
99
+ const chrLower = _p_StringPrototypeCharAt(lowercase, i);
100
+ const chrString = _p_StringPrototypeCharAt(str, i);
101
+ if (chrLower !== chrString && i > 0) notCamelcase += `${joinString}${_p_StringPrototypeCharAt(lowercase, i)}`;
102
+ else notCamelcase += chrString;
103
+ }
104
+ return notCamelcase;
85
105
  }
86
106
  function looksLikeNumber(x) {
87
- if (x === null || x === void 0)
88
- return false;
89
- if (typeof x === "number")
90
- return true;
91
- if (/^0x[0-9a-f]+$/i.test(x))
92
- return true;
93
- if (/^0[^.]/.test(x))
94
- return false;
95
- return /^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
107
+ if (x === null || x === void 0) return false;
108
+ if (typeof x === "number") return true;
109
+ if (/^0x[0-9a-f]+$/i.test(x)) return true;
110
+ if (/^0[^.]/.test(x)) return false;
111
+ return /^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
96
112
  }
97
- var init_string_utils = __esm({
98
- "node_modules/.pnpm/yargs-parser@22.0.0/node_modules/yargs-parser/build/lib/string-utils.js"() {
99
- __name(camelCase, "camelCase");
100
- __name(decamelize, "decamelize");
101
- __name(looksLikeNumber, "looksLikeNumber");
102
- }
103
- });
113
+ var init_string_utils = __esmMin((() => {}));
104
114
 
105
- // node_modules/.pnpm/yargs-parser@22.0.0/node_modules/yargs-parser/build/lib/tokenize-arg-string.js
115
+ //#endregion
116
+ //#region node_modules/.pnpm/yargs-parser@22.0.0/node_modules/yargs-parser/build/lib/tokenize-arg-string.js
117
+ /**
118
+ * @license
119
+ * Copyright (c) 2016, Contributors
120
+ * SPDX-License-Identifier: ISC
121
+ */
106
122
  function tokenizeArgString(argString) {
107
- if (_p_ArrayIsArray(argString)) {
108
- return argString.map((e) => typeof e !== "string" ? e + "" : e);
109
- }
110
- argString = argString.trim();
111
- let i = 0;
112
- let prevC = null;
113
- let c = null;
114
- let opening = null;
115
- const args = [];
116
- for (let ii = 0; ii < argString.length; ii++) {
117
- prevC = c;
118
- c = _p_StringPrototypeCharAt(argString, ii);
119
- if (c === " " && !opening) {
120
- if (!(prevC === " ")) {
121
- i++;
122
- }
123
- continue;
124
- }
125
- if (c === opening) {
126
- opening = null;
127
- } else if ((c === "'" || c === '"') && !opening) {
128
- opening = c;
129
- }
130
- if (!args[i])
131
- args[i] = "";
132
- args[i] += c;
133
- }
134
- return args;
123
+ if (_p_ArrayIsArray(argString)) return argString.map((e) => typeof e !== "string" ? e + "" : e);
124
+ argString = argString.trim();
125
+ let i = 0;
126
+ let prevC = null;
127
+ let c = null;
128
+ let opening = null;
129
+ const args = [];
130
+ for (let ii = 0; ii < argString.length; ii++) {
131
+ prevC = c;
132
+ c = _p_StringPrototypeCharAt(argString, ii);
133
+ if (c === " " && !opening) {
134
+ if (!(prevC === " ")) i++;
135
+ continue;
136
+ }
137
+ if (c === opening) opening = null;
138
+ else if ((c === "'" || c === "\"") && !opening) opening = c;
139
+ if (!args[i]) args[i] = "";
140
+ args[i] += c;
141
+ }
142
+ return args;
135
143
  }
136
- var init_tokenize_arg_string = __esm({
137
- "node_modules/.pnpm/yargs-parser@22.0.0/node_modules/yargs-parser/build/lib/tokenize-arg-string.js"() {
138
- __name(tokenizeArgString, "tokenizeArgString");
139
- }
140
- });
144
+ var init_tokenize_arg_string = __esmMin((() => {}));
141
145
 
142
- // node_modules/.pnpm/yargs-parser@22.0.0/node_modules/yargs-parser/build/lib/yargs-parser-types.js
146
+ //#endregion
147
+ //#region node_modules/.pnpm/yargs-parser@22.0.0/node_modules/yargs-parser/build/lib/yargs-parser-types.js
143
148
  var DefaultValuesForTypeKey;
144
- var init_yargs_parser_types = __esm({
145
- "node_modules/.pnpm/yargs-parser@22.0.0/node_modules/yargs-parser/build/lib/yargs-parser-types.js"() {
146
- (function(DefaultValuesForTypeKey2) {
147
- DefaultValuesForTypeKey2["BOOLEAN"] = "boolean";
148
- DefaultValuesForTypeKey2["STRING"] = "string";
149
- DefaultValuesForTypeKey2["NUMBER"] = "number";
150
- DefaultValuesForTypeKey2["ARRAY"] = "array";
151
- })(DefaultValuesForTypeKey || (DefaultValuesForTypeKey = {}));
152
- }
153
- });
149
+ var init_yargs_parser_types = __esmMin((() => {
150
+ ;
151
+ /**
152
+ * @license
153
+ * Copyright (c) 2016, Contributors
154
+ * SPDX-License-Identifier: ISC
155
+ */
156
+ (function(DefaultValuesForTypeKey) {
157
+ DefaultValuesForTypeKey["BOOLEAN"] = "boolean";
158
+ DefaultValuesForTypeKey["STRING"] = "string";
159
+ DefaultValuesForTypeKey["NUMBER"] = "number";
160
+ DefaultValuesForTypeKey["ARRAY"] = "array";
161
+ })(DefaultValuesForTypeKey || (DefaultValuesForTypeKey = {}));
162
+ }));
154
163
 
155
- // node_modules/.pnpm/yargs-parser@22.0.0/node_modules/yargs-parser/build/lib/yargs-parser.js
164
+ //#endregion
165
+ //#region node_modules/.pnpm/yargs-parser@22.0.0/node_modules/yargs-parser/build/lib/yargs-parser.js
166
+ /**
167
+ * @license
168
+ * Copyright (c) 2016, Contributors
169
+ * SPDX-License-Identifier: ISC
170
+ */
156
171
  function combineAliases(aliases) {
157
- const aliasArrays = [];
158
- const combined = /* @__PURE__ */ _p_ObjectCreate(null);
159
- let change = true;
160
- _p_ObjectKeys(aliases).forEach(function(key) {
161
- aliasArrays.push([].concat(aliases[key], key));
162
- });
163
- while (change) {
164
- change = false;
165
- for (let i = 0; i < aliasArrays.length; i++) {
166
- for (let ii = i + 1; ii < aliasArrays.length; ii++) {
167
- const intersect = aliasArrays[i].filter(function(v) {
168
- return aliasArrays[ii].indexOf(v) !== -1;
169
- });
170
- if (intersect.length) {
171
- aliasArrays[i] = aliasArrays[i].concat(aliasArrays[ii]);
172
- aliasArrays.splice(ii, 1);
173
- change = true;
174
- break;
175
- }
176
- }
177
- }
178
- }
179
- aliasArrays.forEach(function(aliasArray) {
180
- aliasArray = aliasArray.filter(function(v, i, self) {
181
- return self.indexOf(v) === i;
182
- });
183
- const lastAlias = aliasArray.pop();
184
- if (lastAlias !== void 0 && typeof lastAlias === "string") {
185
- combined[lastAlias] = aliasArray;
186
- }
187
- });
188
- return combined;
172
+ const aliasArrays = [];
173
+ const combined = _p_ObjectCreate(null);
174
+ let change = true;
175
+ _p_ObjectKeys(aliases).forEach(function(key) {
176
+ aliasArrays.push([].concat(aliases[key], key));
177
+ });
178
+ while (change) {
179
+ change = false;
180
+ for (let i = 0; i < aliasArrays.length; i++) for (let ii = i + 1; ii < aliasArrays.length; ii++) if (aliasArrays[i].filter(function(v) {
181
+ return aliasArrays[ii].indexOf(v) !== -1;
182
+ }).length) {
183
+ aliasArrays[i] = aliasArrays[i].concat(aliasArrays[ii]);
184
+ aliasArrays.splice(ii, 1);
185
+ change = true;
186
+ break;
187
+ }
188
+ }
189
+ aliasArrays.forEach(function(aliasArray) {
190
+ aliasArray = aliasArray.filter(function(v, i, self) {
191
+ return self.indexOf(v) === i;
192
+ });
193
+ const lastAlias = aliasArray.pop();
194
+ if (lastAlias !== void 0 && typeof lastAlias === "string") combined[lastAlias] = aliasArray;
195
+ });
196
+ return combined;
189
197
  }
190
198
  function increment(orig) {
191
- return orig !== void 0 ? orig + 1 : 1;
199
+ return orig !== void 0 ? orig + 1 : 1;
192
200
  }
193
201
  function sanitizeKey(key) {
194
- if (key === "__proto__")
195
- return "___proto___";
196
- return key;
202
+ if (key === "__proto__") return "___proto___";
203
+ return key;
197
204
  }
198
205
  function stripQuotes(val) {
199
- return typeof val === "string" && (val[0] === "'" || val[0] === '"') && val[val.length - 1] === val[0] ? val.substring(1, val.length - 1) : val;
206
+ return typeof val === "string" && (val[0] === "'" || val[0] === "\"") && val[val.length - 1] === val[0] ? val.substring(1, val.length - 1) : val;
200
207
  }
201
208
  var mixin, YargsParser;
202
- var init_yargs_parser = __esm({
203
- "node_modules/.pnpm/yargs-parser@22.0.0/node_modules/yargs-parser/build/lib/yargs-parser.js"() {
204
- init_tokenize_arg_string();
205
- init_yargs_parser_types();
206
- init_string_utils();
207
- YargsParser = class {
208
- static {
209
- __name(this, "YargsParser");
210
- }
211
- constructor(_mixin) {
212
- mixin = _mixin;
213
- }
214
- parse(argsInput, options) {
215
- const opts = _p_ObjectAssign({
216
- alias: void 0,
217
- array: void 0,
218
- boolean: void 0,
219
- config: void 0,
220
- configObjects: void 0,
221
- configuration: void 0,
222
- coerce: void 0,
223
- count: void 0,
224
- default: void 0,
225
- envPrefix: void 0,
226
- narg: void 0,
227
- normalize: void 0,
228
- string: void 0,
229
- number: void 0,
230
- __: void 0,
231
- key: void 0
232
- }, options);
233
- const args = tokenizeArgString(argsInput);
234
- const inputIsString = typeof argsInput === "string";
235
- const aliases = combineAliases(_p_ObjectAssign(/* @__PURE__ */ _p_ObjectCreate(null), opts.alias));
236
- const configuration = _p_ObjectAssign({
237
- "boolean-negation": true,
238
- "camel-case-expansion": true,
239
- "combine-arrays": false,
240
- "dot-notation": true,
241
- "duplicate-arguments-array": true,
242
- "flatten-duplicate-arrays": true,
243
- "greedy-arrays": true,
244
- "halt-at-non-option": false,
245
- "nargs-eats-options": false,
246
- "negation-prefix": "no-",
247
- "parse-numbers": true,
248
- "parse-positional-numbers": true,
249
- "populate--": false,
250
- "set-placeholder-key": false,
251
- "short-option-groups": true,
252
- "strip-aliased": false,
253
- "strip-dashed": false,
254
- "unknown-options-as-args": false
255
- }, opts.configuration);
256
- const defaults = _p_ObjectAssign(/* @__PURE__ */ _p_ObjectCreate(null), opts.default);
257
- const configObjects = opts.configObjects || [];
258
- const envPrefix = opts.envPrefix;
259
- const notFlagsOption = configuration["populate--"];
260
- const notFlagsArgv = notFlagsOption ? "--" : "_";
261
- const newAliases = /* @__PURE__ */ _p_ObjectCreate(null);
262
- const defaulted = /* @__PURE__ */ _p_ObjectCreate(null);
263
- const __ = opts.__ || mixin.format;
264
- const flags = {
265
- aliases: /* @__PURE__ */ _p_ObjectCreate(null),
266
- arrays: /* @__PURE__ */ _p_ObjectCreate(null),
267
- bools: /* @__PURE__ */ _p_ObjectCreate(null),
268
- strings: /* @__PURE__ */ _p_ObjectCreate(null),
269
- numbers: /* @__PURE__ */ _p_ObjectCreate(null),
270
- counts: /* @__PURE__ */ _p_ObjectCreate(null),
271
- normalize: /* @__PURE__ */ _p_ObjectCreate(null),
272
- configs: /* @__PURE__ */ _p_ObjectCreate(null),
273
- nargs: /* @__PURE__ */ _p_ObjectCreate(null),
274
- coercions: /* @__PURE__ */ _p_ObjectCreate(null),
275
- keys: []
276
- };
277
- const negative = /^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/;
278
- const negatedBoolean = new _p_RegExpCtor("^--" + configuration["negation-prefix"] + "(.+)");
279
- [].concat(opts.array || []).filter(Boolean).forEach(function(opt) {
280
- const key = typeof opt === "object" ? opt.key : opt;
281
- const assignment = _p_ObjectKeys(opt).map(function(key2) {
282
- const arrayFlagKeys = {
283
- boolean: "bools",
284
- string: "strings",
285
- number: "numbers"
286
- };
287
- return arrayFlagKeys[key2];
288
- }).filter(Boolean).pop();
289
- if (assignment) {
290
- flags[assignment][key] = true;
291
- }
292
- flags.arrays[key] = true;
293
- flags.keys.push(key);
294
- });
295
- [].concat(opts.boolean || []).filter(Boolean).forEach(function(key) {
296
- flags.bools[key] = true;
297
- flags.keys.push(key);
298
- });
299
- [].concat(opts.string || []).filter(Boolean).forEach(function(key) {
300
- flags.strings[key] = true;
301
- flags.keys.push(key);
302
- });
303
- [].concat(opts.number || []).filter(Boolean).forEach(function(key) {
304
- flags.numbers[key] = true;
305
- flags.keys.push(key);
306
- });
307
- [].concat(opts.count || []).filter(Boolean).forEach(function(key) {
308
- flags.counts[key] = true;
309
- flags.keys.push(key);
310
- });
311
- [].concat(opts.normalize || []).filter(Boolean).forEach(function(key) {
312
- flags.normalize[key] = true;
313
- flags.keys.push(key);
314
- });
315
- if (typeof opts.narg === "object") {
316
- _p_ObjectEntries(opts.narg).forEach(([key, value]) => {
317
- if (typeof value === "number") {
318
- flags.nargs[key] = value;
319
- flags.keys.push(key);
320
- }
321
- });
322
- }
323
- if (typeof opts.coerce === "object") {
324
- _p_ObjectEntries(opts.coerce).forEach(([key, value]) => {
325
- if (typeof value === "function") {
326
- flags.coercions[key] = value;
327
- flags.keys.push(key);
328
- }
329
- });
330
- }
331
- if (typeof opts.config !== "undefined") {
332
- if (_p_ArrayIsArray(opts.config) || typeof opts.config === "string") {
333
- ;
334
- [].concat(opts.config).filter(Boolean).forEach(function(key) {
335
- flags.configs[key] = true;
336
- });
337
- } else if (typeof opts.config === "object") {
338
- _p_ObjectEntries(opts.config).forEach(([key, value]) => {
339
- if (typeof value === "boolean" || typeof value === "function") {
340
- flags.configs[key] = value;
341
- }
342
- });
343
- }
344
- }
345
- extendAliases(opts.key, aliases, opts.default, flags.arrays);
346
- _p_ObjectKeys(defaults).forEach(function(key) {
347
- (flags.aliases[key] || []).forEach(function(alias) {
348
- defaults[alias] = defaults[key];
349
- });
350
- });
351
- let error = null;
352
- checkConfiguration();
353
- let notFlags = [];
354
- const argv = _p_ObjectAssign(/* @__PURE__ */ _p_ObjectCreate(null), { _: [] });
355
- const argvReturn = {};
356
- for (let i = 0; i < args.length; i++) {
357
- const arg = args[i];
358
- const truncatedArg = arg.replace(/^-{3,}/, "---");
359
- let broken;
360
- let key;
361
- let letters;
362
- let m;
363
- let next;
364
- let value;
365
- if (arg !== "--" && /^-/.test(arg) && isUnknownOptionAsArg(arg)) {
366
- pushPositional(arg);
367
- } else if (truncatedArg.match(/^---+(=|$)/)) {
368
- pushPositional(arg);
369
- continue;
370
- } else if (arg.match(/^--.+=/) || !configuration["short-option-groups"] && arg.match(/^-.+=/)) {
371
- m = arg.match(/^--?([^=]+)=([\s\S]*)$/);
372
- if (m !== null && _p_ArrayIsArray(m) && m.length >= 3) {
373
- if (checkAllAliases(m[1], flags.arrays)) {
374
- i = eatArray(i, m[1], args, m[2]);
375
- } else if (checkAllAliases(m[1], flags.nargs) !== false) {
376
- i = eatNargs(i, m[1], args, m[2]);
377
- } else {
378
- setArg(m[1], m[2], true);
379
- }
380
- }
381
- } else if (arg.match(negatedBoolean) && configuration["boolean-negation"]) {
382
- m = arg.match(negatedBoolean);
383
- if (m !== null && _p_ArrayIsArray(m) && m.length >= 2) {
384
- key = m[1];
385
- setArg(key, checkAllAliases(key, flags.arrays) ? [false] : false);
386
- }
387
- } else if (arg.match(/^--.+/) || !configuration["short-option-groups"] && arg.match(/^-[^-]+/)) {
388
- m = arg.match(/^--?(.+)/);
389
- if (m !== null && _p_ArrayIsArray(m) && m.length >= 2) {
390
- key = m[1];
391
- if (checkAllAliases(key, flags.arrays)) {
392
- i = eatArray(i, key, args);
393
- } else if (checkAllAliases(key, flags.nargs) !== false) {
394
- i = eatNargs(i, key, args);
395
- } else {
396
- next = args[i + 1];
397
- if (next !== void 0 && (!next.match(/^-/) || next.match(negative)) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) {
398
- setArg(key, next);
399
- i++;
400
- } else if (/^(true|false)$/.test(next)) {
401
- setArg(key, next);
402
- i++;
403
- } else {
404
- setArg(key, defaultValue(key));
405
- }
406
- }
407
- }
408
- } else if (arg.match(/^-.\..+=/)) {
409
- m = arg.match(/^-([^=]+)=([\s\S]*)$/);
410
- if (m !== null && _p_ArrayIsArray(m) && m.length >= 3) {
411
- setArg(m[1], m[2]);
412
- }
413
- } else if (arg.match(/^-.\..+/) && !arg.match(negative)) {
414
- next = args[i + 1];
415
- m = arg.match(/^-(.\..+)/);
416
- if (m !== null && _p_ArrayIsArray(m) && m.length >= 2) {
417
- key = m[1];
418
- if (next !== void 0 && !next.match(/^-/) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) {
419
- setArg(key, next);
420
- i++;
421
- } else {
422
- setArg(key, defaultValue(key));
423
- }
424
- }
425
- } else if (arg.match(/^-[^-]+/) && !arg.match(negative)) {
426
- letters = arg.slice(1, -1).split("");
427
- broken = false;
428
- for (let j = 0; j < letters.length; j++) {
429
- next = arg.slice(j + 2);
430
- if (letters[j + 1] && letters[j + 1] === "=") {
431
- value = arg.slice(j + 3);
432
- key = letters[j];
433
- if (checkAllAliases(key, flags.arrays)) {
434
- i = eatArray(i, key, args, value);
435
- } else if (checkAllAliases(key, flags.nargs) !== false) {
436
- i = eatNargs(i, key, args, value);
437
- } else {
438
- setArg(key, value);
439
- }
440
- broken = true;
441
- break;
442
- }
443
- if (next === "-") {
444
- setArg(letters[j], next);
445
- continue;
446
- }
447
- if (/[A-Za-z]/.test(letters[j]) && /^-?\d+(\.\d*)?(e-?\d+)?$/.test(next) && checkAllAliases(next, flags.bools) === false) {
448
- setArg(letters[j], next);
449
- broken = true;
450
- break;
451
- }
452
- if (letters[j + 1] && letters[j + 1].match(/\W/)) {
453
- setArg(letters[j], next);
454
- broken = true;
455
- break;
456
- } else {
457
- setArg(letters[j], defaultValue(letters[j]));
458
- }
459
- }
460
- key = arg.slice(-1)[0];
461
- if (!broken && key !== "-") {
462
- if (checkAllAliases(key, flags.arrays)) {
463
- i = eatArray(i, key, args);
464
- } else if (checkAllAliases(key, flags.nargs) !== false) {
465
- i = eatNargs(i, key, args);
466
- } else {
467
- next = args[i + 1];
468
- if (next !== void 0 && (!/^(-|--)[^-]/.test(next) || next.match(negative)) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) {
469
- setArg(key, next);
470
- i++;
471
- } else if (/^(true|false)$/.test(next)) {
472
- setArg(key, next);
473
- i++;
474
- } else {
475
- setArg(key, defaultValue(key));
476
- }
477
- }
478
- }
479
- } else if (arg.match(/^-[0-9]$/) && arg.match(negative) && checkAllAliases(arg.slice(1), flags.bools)) {
480
- key = arg.slice(1);
481
- setArg(key, defaultValue(key));
482
- } else if (arg === "--") {
483
- notFlags = args.slice(i + 1);
484
- break;
485
- } else if (configuration["halt-at-non-option"]) {
486
- notFlags = args.slice(i);
487
- break;
488
- } else {
489
- pushPositional(arg);
490
- }
491
- }
492
- applyEnvVars(argv, true);
493
- applyEnvVars(argv, false);
494
- setConfig(argv);
495
- setConfigObjects();
496
- applyDefaultsAndAliases(argv, flags.aliases, defaults, true);
497
- applyCoercions(argv);
498
- if (configuration["set-placeholder-key"])
499
- setPlaceholderKeys(argv);
500
- _p_ObjectKeys(flags.counts).forEach(function(key) {
501
- if (!hasKey(argv, key.split(".")))
502
- setArg(key, 0);
503
- });
504
- if (notFlagsOption && notFlags.length)
505
- argv[notFlagsArgv] = [];
506
- notFlags.forEach(function(key) {
507
- argv[notFlagsArgv].push(key);
508
- });
509
- if (configuration["camel-case-expansion"] && configuration["strip-dashed"]) {
510
- _p_ObjectKeys(argv).filter((key) => key !== "--" && key.includes("-")).forEach((key) => {
511
- delete argv[key];
512
- });
513
- }
514
- if (configuration["strip-aliased"]) {
515
- ;
516
- [].concat(..._p_ObjectKeys(aliases).map((k) => aliases[k])).forEach((alias) => {
517
- if (configuration["camel-case-expansion"] && alias.includes("-")) {
518
- delete argv[alias.split(".").map((prop) => camelCase(prop)).join(".")];
519
- }
520
- delete argv[alias];
521
- });
522
- }
523
- function pushPositional(arg) {
524
- const maybeCoercedNumber = maybeCoerceNumber("_", arg);
525
- if (typeof maybeCoercedNumber === "string" || typeof maybeCoercedNumber === "number") {
526
- argv._.push(maybeCoercedNumber);
527
- }
528
- }
529
- __name(pushPositional, "pushPositional");
530
- function eatNargs(i, key, args2, argAfterEqualSign) {
531
- let ii;
532
- let toEat = checkAllAliases(key, flags.nargs);
533
- toEat = typeof toEat !== "number" || isNaN(toEat) ? 1 : toEat;
534
- if (toEat === 0) {
535
- if (!isUndefined(argAfterEqualSign)) {
536
- error = Error(__("Argument unexpected for: %s", key));
537
- }
538
- setArg(key, defaultValue(key));
539
- return i;
540
- }
541
- let available = isUndefined(argAfterEqualSign) ? 0 : 1;
542
- if (configuration["nargs-eats-options"]) {
543
- if (args2.length - (i + 1) + available < toEat) {
544
- error = Error(__("Not enough arguments following: %s", key));
545
- }
546
- available = toEat;
547
- } else {
548
- for (ii = i + 1; ii < args2.length; ii++) {
549
- if (!args2[ii].match(/^-[^0-9]/) || args2[ii].match(negative) || isUnknownOptionAsArg(args2[ii]))
550
- available++;
551
- else
552
- break;
553
- }
554
- if (available < toEat)
555
- error = Error(__("Not enough arguments following: %s", key));
556
- }
557
- let consumed = _p_MathMin(available, toEat);
558
- if (!isUndefined(argAfterEqualSign) && consumed > 0) {
559
- setArg(key, argAfterEqualSign);
560
- consumed--;
561
- }
562
- for (ii = i + 1; ii < consumed + i + 1; ii++) {
563
- setArg(key, args2[ii]);
564
- }
565
- return i + consumed;
566
- }
567
- __name(eatNargs, "eatNargs");
568
- function eatArray(i, key, args2, argAfterEqualSign) {
569
- let argsToSet = [];
570
- let next = argAfterEqualSign || args2[i + 1];
571
- const nargsCount = checkAllAliases(key, flags.nargs);
572
- if (checkAllAliases(key, flags.bools) && !/^(true|false)$/.test(next)) {
573
- argsToSet.push(true);
574
- } else if (isUndefined(next) || isUndefined(argAfterEqualSign) && /^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next)) {
575
- if (defaults[key] !== void 0) {
576
- const defVal = defaults[key];
577
- argsToSet = _p_ArrayIsArray(defVal) ? defVal : [defVal];
578
- }
579
- } else {
580
- if (!isUndefined(argAfterEqualSign)) {
581
- argsToSet.push(processValue(key, argAfterEqualSign, true));
582
- }
583
- for (let ii = i + 1; ii < args2.length; ii++) {
584
- if (!configuration["greedy-arrays"] && argsToSet.length > 0 || nargsCount && typeof nargsCount === "number" && argsToSet.length >= nargsCount)
585
- break;
586
- next = args2[ii];
587
- if (/^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next))
588
- break;
589
- i = ii;
590
- argsToSet.push(processValue(key, next, inputIsString));
591
- }
592
- }
593
- if (typeof nargsCount === "number" && (nargsCount && argsToSet.length < nargsCount || isNaN(nargsCount) && argsToSet.length === 0)) {
594
- error = Error(__("Not enough arguments following: %s", key));
595
- }
596
- setArg(key, argsToSet);
597
- return i;
598
- }
599
- __name(eatArray, "eatArray");
600
- function setArg(key, val, shouldStripQuotes = inputIsString) {
601
- if (/-/.test(key) && configuration["camel-case-expansion"]) {
602
- const alias = key.split(".").map(function(prop) {
603
- return camelCase(prop);
604
- }).join(".");
605
- addNewAlias(key, alias);
606
- }
607
- const value = processValue(key, val, shouldStripQuotes);
608
- const splitKey = key.split(".");
609
- setKey(argv, splitKey, value);
610
- if (flags.aliases[key]) {
611
- flags.aliases[key].forEach(function(x) {
612
- const keyProperties = x.split(".");
613
- setKey(argv, keyProperties, value);
614
- });
615
- }
616
- if (splitKey.length > 1 && configuration["dot-notation"]) {
617
- ;
618
- (flags.aliases[splitKey[0]] || []).forEach(function(x) {
619
- let keyProperties = x.split(".");
620
- const a = [].concat(splitKey);
621
- a.shift();
622
- keyProperties = keyProperties.concat(a);
623
- if (!(flags.aliases[key] || []).includes(keyProperties.join("."))) {
624
- setKey(argv, keyProperties, value);
625
- }
626
- });
627
- }
628
- if (checkAllAliases(key, flags.normalize) && !checkAllAliases(key, flags.arrays)) {
629
- const keys = [key].concat(flags.aliases[key] || []);
630
- keys.forEach(function(key2) {
631
- _p_ObjectDefineProperty(argvReturn, key2, {
632
- enumerable: true,
633
- get() {
634
- return val;
635
- },
636
- set(value2) {
637
- val = typeof value2 === "string" ? mixin.normalize(value2) : value2;
638
- }
639
- });
640
- });
641
- }
642
- }
643
- __name(setArg, "setArg");
644
- function addNewAlias(key, alias) {
645
- if (!(flags.aliases[key] && flags.aliases[key].length)) {
646
- flags.aliases[key] = [alias];
647
- newAliases[alias] = true;
648
- }
649
- if (!(flags.aliases[alias] && flags.aliases[alias].length)) {
650
- addNewAlias(alias, key);
651
- }
652
- }
653
- __name(addNewAlias, "addNewAlias");
654
- function processValue(key, val, shouldStripQuotes) {
655
- if (shouldStripQuotes) {
656
- val = stripQuotes(val);
657
- }
658
- if (checkAllAliases(key, flags.bools) || checkAllAliases(key, flags.counts)) {
659
- if (typeof val === "string")
660
- val = val === "true";
661
- }
662
- let value = _p_ArrayIsArray(val) ? val.map(function(v) {
663
- return maybeCoerceNumber(key, v);
664
- }) : maybeCoerceNumber(key, val);
665
- if (checkAllAliases(key, flags.counts) && (isUndefined(value) || typeof value === "boolean")) {
666
- value = increment();
667
- }
668
- if (checkAllAliases(key, flags.normalize) && checkAllAliases(key, flags.arrays)) {
669
- if (_p_ArrayIsArray(val))
670
- value = val.map((val2) => {
671
- return mixin.normalize(val2);
672
- });
673
- else
674
- value = mixin.normalize(val);
675
- }
676
- return value;
677
- }
678
- __name(processValue, "processValue");
679
- function maybeCoerceNumber(key, value) {
680
- if (!configuration["parse-positional-numbers"] && key === "_")
681
- return value;
682
- if (!checkAllAliases(key, flags.strings) && !checkAllAliases(key, flags.bools) && !_p_ArrayIsArray(value)) {
683
- const shouldCoerceNumber = looksLikeNumber(value) && configuration["parse-numbers"] && _p_NumberIsSafeInteger(_p_MathFloor(parseFloat(`${value}`)));
684
- if (shouldCoerceNumber || !isUndefined(value) && checkAllAliases(key, flags.numbers)) {
685
- value = Number(value);
686
- }
687
- }
688
- return value;
689
- }
690
- __name(maybeCoerceNumber, "maybeCoerceNumber");
691
- function setConfig(argv2) {
692
- const configLookup = /* @__PURE__ */ _p_ObjectCreate(null);
693
- applyDefaultsAndAliases(configLookup, flags.aliases, defaults);
694
- _p_ObjectKeys(flags.configs).forEach(function(configKey) {
695
- const configPath = argv2[configKey] || configLookup[configKey];
696
- if (configPath) {
697
- try {
698
- let config = null;
699
- const resolvedConfigPath = mixin.resolve(mixin.cwd(), configPath);
700
- const resolveConfig = flags.configs[configKey];
701
- if (typeof resolveConfig === "function") {
702
- try {
703
- config = resolveConfig(resolvedConfigPath);
704
- } catch (e) {
705
- config = e;
706
- }
707
- if (config instanceof Error) {
708
- error = config;
709
- return;
710
- }
711
- } else {
712
- config = mixin.require(resolvedConfigPath);
713
- }
714
- setConfigObject(config);
715
- } catch (ex) {
716
- if (ex.name === "PermissionDenied")
717
- error = ex;
718
- else if (argv2[configKey])
719
- error = Error(__("Invalid JSON config file: %s", configPath));
720
- }
721
- }
722
- });
723
- }
724
- __name(setConfig, "setConfig");
725
- function setConfigObject(config, prev) {
726
- _p_ObjectKeys(config).forEach(function(key) {
727
- const value = config[key];
728
- const fullKey = prev ? prev + "." + key : key;
729
- if (typeof value === "object" && value !== null && !_p_ArrayIsArray(value) && configuration["dot-notation"]) {
730
- setConfigObject(value, fullKey);
731
- } else {
732
- if (!hasKey(argv, fullKey.split(".")) || checkAllAliases(fullKey, flags.arrays) && configuration["combine-arrays"]) {
733
- setArg(fullKey, value);
734
- }
735
- }
736
- });
737
- }
738
- __name(setConfigObject, "setConfigObject");
739
- function setConfigObjects() {
740
- if (typeof configObjects !== "undefined") {
741
- configObjects.forEach(function(configObject) {
742
- setConfigObject(configObject);
743
- });
744
- }
745
- }
746
- __name(setConfigObjects, "setConfigObjects");
747
- function applyEnvVars(argv2, configOnly) {
748
- if (typeof envPrefix === "undefined")
749
- return;
750
- const prefix = typeof envPrefix === "string" ? envPrefix : "";
751
- const env2 = mixin.env();
752
- _p_ObjectKeys(env2).forEach(function(envVar) {
753
- if (prefix === "" || envVar.lastIndexOf(prefix, 0) === 0) {
754
- const keys = envVar.split("__").map(function(key, i) {
755
- if (i === 0) {
756
- key = _p_StringPrototypeSubstring(key, prefix.length);
757
- }
758
- return camelCase(key);
759
- });
760
- if ((configOnly && flags.configs[keys.join(".")] || !configOnly) && !hasKey(argv2, keys)) {
761
- setArg(keys.join("."), env2[envVar]);
762
- }
763
- }
764
- });
765
- }
766
- __name(applyEnvVars, "applyEnvVars");
767
- function applyCoercions(argv2) {
768
- let coerce;
769
- const applied = /* @__PURE__ */ new _p_SetCtor();
770
- _p_ObjectKeys(argv2).forEach(function(key) {
771
- if (!applied.has(key)) {
772
- coerce = checkAllAliases(key, flags.coercions);
773
- if (typeof coerce === "function") {
774
- try {
775
- const value = maybeCoerceNumber(key, coerce(argv2[key]));
776
- [].concat(flags.aliases[key] || [], key).forEach((ali) => {
777
- applied.add(ali);
778
- argv2[ali] = value;
779
- });
780
- } catch (err) {
781
- error = err;
782
- }
783
- }
784
- }
785
- });
786
- }
787
- __name(applyCoercions, "applyCoercions");
788
- function setPlaceholderKeys(argv2) {
789
- flags.keys.forEach((key) => {
790
- if (~key.indexOf("."))
791
- return;
792
- if (typeof argv2[key] === "undefined")
793
- argv2[key] = void 0;
794
- });
795
- return argv2;
796
- }
797
- __name(setPlaceholderKeys, "setPlaceholderKeys");
798
- function applyDefaultsAndAliases(obj, aliases2, defaults2, canLog = false) {
799
- _p_ObjectKeys(defaults2).forEach(function(key) {
800
- if (!hasKey(obj, key.split("."))) {
801
- setKey(obj, key.split("."), defaults2[key]);
802
- if (canLog)
803
- defaulted[key] = true;
804
- (aliases2[key] || []).forEach(function(x) {
805
- if (hasKey(obj, x.split(".")))
806
- return;
807
- setKey(obj, x.split("."), defaults2[key]);
808
- });
809
- }
810
- });
811
- }
812
- __name(applyDefaultsAndAliases, "applyDefaultsAndAliases");
813
- function hasKey(obj, keys) {
814
- let o = obj;
815
- if (!configuration["dot-notation"])
816
- keys = [keys.join(".")];
817
- keys.slice(0, -1).forEach(function(key2) {
818
- o = o[key2] || {};
819
- });
820
- const key = keys[keys.length - 1];
821
- if (typeof o !== "object")
822
- return false;
823
- else
824
- return key in o;
825
- }
826
- __name(hasKey, "hasKey");
827
- function setKey(obj, keys, value) {
828
- let o = obj;
829
- if (!configuration["dot-notation"])
830
- keys = [keys.join(".")];
831
- keys.slice(0, -1).forEach(function(key2) {
832
- key2 = sanitizeKey(key2);
833
- if (typeof o === "object" && o[key2] === void 0) {
834
- o[key2] = {};
835
- }
836
- if (typeof o[key2] !== "object" || _p_ArrayIsArray(o[key2])) {
837
- if (_p_ArrayIsArray(o[key2])) {
838
- o[key2].push({});
839
- } else {
840
- o[key2] = [o[key2], {}];
841
- }
842
- o = o[key2][o[key2].length - 1];
843
- } else {
844
- o = o[key2];
845
- }
846
- });
847
- const key = sanitizeKey(keys[keys.length - 1]);
848
- const isTypeArray = checkAllAliases(keys.join("."), flags.arrays);
849
- const isValueArray = _p_ArrayIsArray(value);
850
- let duplicate = configuration["duplicate-arguments-array"];
851
- if (!duplicate && checkAllAliases(key, flags.nargs)) {
852
- duplicate = true;
853
- if (!isUndefined(o[key]) && flags.nargs[key] === 1 || _p_ArrayIsArray(o[key]) && o[key].length === flags.nargs[key]) {
854
- o[key] = void 0;
855
- }
856
- }
857
- if (value === increment()) {
858
- o[key] = increment(o[key]);
859
- } else if (_p_ArrayIsArray(o[key])) {
860
- if (duplicate && isTypeArray && isValueArray) {
861
- o[key] = configuration["flatten-duplicate-arrays"] ? o[key].concat(value) : (_p_ArrayIsArray(o[key][0]) ? o[key] : [o[key]]).concat([value]);
862
- } else if (!duplicate && Boolean(isTypeArray) === Boolean(isValueArray)) {
863
- o[key] = value;
864
- } else {
865
- o[key] = o[key].concat([value]);
866
- }
867
- } else if (o[key] === void 0 && isTypeArray) {
868
- o[key] = isValueArray ? value : [value];
869
- } else if (duplicate && !(o[key] === void 0 || checkAllAliases(key, flags.counts) || checkAllAliases(key, flags.bools))) {
870
- o[key] = [o[key], value];
871
- } else {
872
- o[key] = value;
873
- }
874
- }
875
- __name(setKey, "setKey");
876
- function extendAliases(...args2) {
877
- args2.forEach(function(obj) {
878
- _p_ObjectKeys(obj || {}).forEach(function(key) {
879
- if (flags.aliases[key])
880
- return;
881
- flags.aliases[key] = [].concat(aliases[key] || []);
882
- flags.aliases[key].concat(key).forEach(function(x) {
883
- if (/-/.test(x) && configuration["camel-case-expansion"]) {
884
- const c = camelCase(x);
885
- if (c !== key && flags.aliases[key].indexOf(c) === -1) {
886
- flags.aliases[key].push(c);
887
- newAliases[c] = true;
888
- }
889
- }
890
- });
891
- flags.aliases[key].concat(key).forEach(function(x) {
892
- if (x.length > 1 && /[A-Z]/.test(x) && configuration["camel-case-expansion"]) {
893
- const c = decamelize(x, "-");
894
- if (c !== key && flags.aliases[key].indexOf(c) === -1) {
895
- flags.aliases[key].push(c);
896
- newAliases[c] = true;
897
- }
898
- }
899
- });
900
- flags.aliases[key].forEach(function(x) {
901
- flags.aliases[x] = [key].concat(flags.aliases[key].filter(function(y) {
902
- return x !== y;
903
- }));
904
- });
905
- });
906
- });
907
- }
908
- __name(extendAliases, "extendAliases");
909
- function checkAllAliases(key, flag) {
910
- const toCheck = [].concat(flags.aliases[key] || [], key);
911
- const keys = _p_ObjectKeys(flag);
912
- const setAlias = toCheck.find((key2) => keys.includes(key2));
913
- return setAlias ? flag[setAlias] : false;
914
- }
915
- __name(checkAllAliases, "checkAllAliases");
916
- function hasAnyFlag(key) {
917
- const flagsKeys = _p_ObjectKeys(flags);
918
- const toCheck = [].concat(flagsKeys.map((k) => flags[k]));
919
- return toCheck.some(function(flag) {
920
- return _p_ArrayIsArray(flag) ? flag.includes(key) : flag[key];
921
- });
922
- }
923
- __name(hasAnyFlag, "hasAnyFlag");
924
- function hasFlagsMatching(arg, ...patterns) {
925
- const toCheck = [].concat(...patterns);
926
- return toCheck.some(function(pattern) {
927
- const match = arg.match(pattern);
928
- return match && hasAnyFlag(match[1]);
929
- });
930
- }
931
- __name(hasFlagsMatching, "hasFlagsMatching");
932
- function hasAllShortFlags(arg) {
933
- if (arg.match(negative) || !arg.match(/^-[^-]+/)) {
934
- return false;
935
- }
936
- let hasAllFlags = true;
937
- let next;
938
- const letters = arg.slice(1).split("");
939
- for (let j = 0; j < letters.length; j++) {
940
- next = arg.slice(j + 2);
941
- if (!hasAnyFlag(letters[j])) {
942
- hasAllFlags = false;
943
- break;
944
- }
945
- if (letters[j + 1] && letters[j + 1] === "=" || next === "-" || /[A-Za-z]/.test(letters[j]) && /^-?\d+(\.\d*)?(e-?\d+)?$/.test(next) || letters[j + 1] && letters[j + 1].match(/\W/)) {
946
- break;
947
- }
948
- }
949
- return hasAllFlags;
950
- }
951
- __name(hasAllShortFlags, "hasAllShortFlags");
952
- function isUnknownOptionAsArg(arg) {
953
- return configuration["unknown-options-as-args"] && isUnknownOption(arg);
954
- }
955
- __name(isUnknownOptionAsArg, "isUnknownOptionAsArg");
956
- function isUnknownOption(arg) {
957
- arg = arg.replace(/^-{3,}/, "--");
958
- if (arg.match(negative)) {
959
- return false;
960
- }
961
- if (hasAllShortFlags(arg)) {
962
- return false;
963
- }
964
- const flagWithEquals = /^-+([^=]+?)=[\s\S]*$/;
965
- const normalFlag = /^-+([^=]+?)$/;
966
- const flagEndingInHyphen = /^-+([^=]+?)-$/;
967
- const flagEndingInDigits = /^-+([^=]+?\d+)$/;
968
- const flagEndingInNonWordCharacters = /^-+([^=]+?)\W+.*$/;
969
- return !hasFlagsMatching(arg, flagWithEquals, negatedBoolean, normalFlag, flagEndingInHyphen, flagEndingInDigits, flagEndingInNonWordCharacters);
970
- }
971
- __name(isUnknownOption, "isUnknownOption");
972
- function defaultValue(key) {
973
- if (!checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts) && `${key}` in defaults) {
974
- return defaults[key];
975
- } else {
976
- return defaultForType(guessType(key));
977
- }
978
- }
979
- __name(defaultValue, "defaultValue");
980
- function defaultForType(type) {
981
- const def = {
982
- [DefaultValuesForTypeKey.BOOLEAN]: true,
983
- [DefaultValuesForTypeKey.STRING]: "",
984
- [DefaultValuesForTypeKey.NUMBER]: void 0,
985
- [DefaultValuesForTypeKey.ARRAY]: []
986
- };
987
- return def[type];
988
- }
989
- __name(defaultForType, "defaultForType");
990
- function guessType(key) {
991
- let type = DefaultValuesForTypeKey.BOOLEAN;
992
- if (checkAllAliases(key, flags.strings))
993
- type = DefaultValuesForTypeKey.STRING;
994
- else if (checkAllAliases(key, flags.numbers))
995
- type = DefaultValuesForTypeKey.NUMBER;
996
- else if (checkAllAliases(key, flags.bools))
997
- type = DefaultValuesForTypeKey.BOOLEAN;
998
- else if (checkAllAliases(key, flags.arrays))
999
- type = DefaultValuesForTypeKey.ARRAY;
1000
- return type;
1001
- }
1002
- __name(guessType, "guessType");
1003
- function isUndefined(num) {
1004
- return num === void 0;
1005
- }
1006
- __name(isUndefined, "isUndefined");
1007
- function checkConfiguration() {
1008
- _p_ObjectKeys(flags.counts).find((key) => {
1009
- if (checkAllAliases(key, flags.arrays)) {
1010
- error = Error(__("Invalid configuration: %s, opts.count excludes opts.array.", key));
1011
- return true;
1012
- } else if (checkAllAliases(key, flags.nargs)) {
1013
- error = Error(__("Invalid configuration: %s, opts.count excludes opts.narg.", key));
1014
- return true;
1015
- }
1016
- return false;
1017
- });
1018
- }
1019
- __name(checkConfiguration, "checkConfiguration");
1020
- return {
1021
- aliases: _p_ObjectAssign({}, flags.aliases),
1022
- argv: _p_ObjectAssign(argvReturn, argv),
1023
- configuration,
1024
- defaulted: _p_ObjectAssign({}, defaulted),
1025
- error,
1026
- newAliases: _p_ObjectAssign({}, newAliases)
1027
- };
1028
- }
1029
- };
1030
- __name(combineAliases, "combineAliases");
1031
- __name(increment, "increment");
1032
- __name(sanitizeKey, "sanitizeKey");
1033
- __name(stripQuotes, "stripQuotes");
1034
- }
1035
- });
209
+ var init_yargs_parser = __esmMin((() => {
210
+ init_tokenize_arg_string();
211
+ init_yargs_parser_types();
212
+ init_string_utils();
213
+ ;
214
+ YargsParser = class {
215
+ constructor(_mixin) {
216
+ mixin = _mixin;
217
+ }
218
+ parse(argsInput, options) {
219
+ const opts = _p_ObjectAssign({
220
+ alias: void 0,
221
+ array: void 0,
222
+ boolean: void 0,
223
+ config: void 0,
224
+ configObjects: void 0,
225
+ configuration: void 0,
226
+ coerce: void 0,
227
+ count: void 0,
228
+ default: void 0,
229
+ envPrefix: void 0,
230
+ narg: void 0,
231
+ normalize: void 0,
232
+ string: void 0,
233
+ number: void 0,
234
+ __: void 0,
235
+ key: void 0
236
+ }, options);
237
+ const args = tokenizeArgString(argsInput);
238
+ const inputIsString = typeof argsInput === "string";
239
+ const aliases = combineAliases(_p_ObjectAssign(_p_ObjectCreate(null), opts.alias));
240
+ const configuration = _p_ObjectAssign({
241
+ "boolean-negation": true,
242
+ "camel-case-expansion": true,
243
+ "combine-arrays": false,
244
+ "dot-notation": true,
245
+ "duplicate-arguments-array": true,
246
+ "flatten-duplicate-arrays": true,
247
+ "greedy-arrays": true,
248
+ "halt-at-non-option": false,
249
+ "nargs-eats-options": false,
250
+ "negation-prefix": "no-",
251
+ "parse-numbers": true,
252
+ "parse-positional-numbers": true,
253
+ "populate--": false,
254
+ "set-placeholder-key": false,
255
+ "short-option-groups": true,
256
+ "strip-aliased": false,
257
+ "strip-dashed": false,
258
+ "unknown-options-as-args": false
259
+ }, opts.configuration);
260
+ const defaults = _p_ObjectAssign(_p_ObjectCreate(null), opts.default);
261
+ const configObjects = opts.configObjects || [];
262
+ const envPrefix = opts.envPrefix;
263
+ const notFlagsOption = configuration["populate--"];
264
+ const notFlagsArgv = notFlagsOption ? "--" : "_";
265
+ const newAliases = _p_ObjectCreate(null);
266
+ const defaulted = _p_ObjectCreate(null);
267
+ const __ = opts.__ || mixin.format;
268
+ const flags = {
269
+ aliases: _p_ObjectCreate(null),
270
+ arrays: _p_ObjectCreate(null),
271
+ bools: _p_ObjectCreate(null),
272
+ strings: _p_ObjectCreate(null),
273
+ numbers: _p_ObjectCreate(null),
274
+ counts: _p_ObjectCreate(null),
275
+ normalize: _p_ObjectCreate(null),
276
+ configs: _p_ObjectCreate(null),
277
+ nargs: _p_ObjectCreate(null),
278
+ coercions: _p_ObjectCreate(null),
279
+ keys: []
280
+ };
281
+ const negative = /^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/;
282
+ const negatedBoolean = new _p_RegExpCtor("^--" + configuration["negation-prefix"] + "(.+)");
283
+ [].concat(opts.array || []).filter(Boolean).forEach(function(opt) {
284
+ const key = typeof opt === "object" ? opt.key : opt;
285
+ const assignment = _p_ObjectKeys(opt).map(function(key) {
286
+ return {
287
+ boolean: "bools",
288
+ string: "strings",
289
+ number: "numbers"
290
+ }[key];
291
+ }).filter(Boolean).pop();
292
+ if (assignment) flags[assignment][key] = true;
293
+ flags.arrays[key] = true;
294
+ flags.keys.push(key);
295
+ });
296
+ [].concat(opts.boolean || []).filter(Boolean).forEach(function(key) {
297
+ flags.bools[key] = true;
298
+ flags.keys.push(key);
299
+ });
300
+ [].concat(opts.string || []).filter(Boolean).forEach(function(key) {
301
+ flags.strings[key] = true;
302
+ flags.keys.push(key);
303
+ });
304
+ [].concat(opts.number || []).filter(Boolean).forEach(function(key) {
305
+ flags.numbers[key] = true;
306
+ flags.keys.push(key);
307
+ });
308
+ [].concat(opts.count || []).filter(Boolean).forEach(function(key) {
309
+ flags.counts[key] = true;
310
+ flags.keys.push(key);
311
+ });
312
+ [].concat(opts.normalize || []).filter(Boolean).forEach(function(key) {
313
+ flags.normalize[key] = true;
314
+ flags.keys.push(key);
315
+ });
316
+ if (typeof opts.narg === "object") _p_ObjectEntries(opts.narg).forEach(([key, value]) => {
317
+ if (typeof value === "number") {
318
+ flags.nargs[key] = value;
319
+ flags.keys.push(key);
320
+ }
321
+ });
322
+ if (typeof opts.coerce === "object") _p_ObjectEntries(opts.coerce).forEach(([key, value]) => {
323
+ if (typeof value === "function") {
324
+ flags.coercions[key] = value;
325
+ flags.keys.push(key);
326
+ }
327
+ });
328
+ if (typeof opts.config !== "undefined") {
329
+ if (_p_ArrayIsArray(opts.config) || typeof opts.config === "string") [].concat(opts.config).filter(Boolean).forEach(function(key) {
330
+ flags.configs[key] = true;
331
+ });
332
+ else if (typeof opts.config === "object") _p_ObjectEntries(opts.config).forEach(([key, value]) => {
333
+ if (typeof value === "boolean" || typeof value === "function") flags.configs[key] = value;
334
+ });
335
+ }
336
+ extendAliases(opts.key, aliases, opts.default, flags.arrays);
337
+ _p_ObjectKeys(defaults).forEach(function(key) {
338
+ (flags.aliases[key] || []).forEach(function(alias) {
339
+ defaults[alias] = defaults[key];
340
+ });
341
+ });
342
+ let error = null;
343
+ checkConfiguration();
344
+ let notFlags = [];
345
+ const argv = _p_ObjectAssign(_p_ObjectCreate(null), { _: [] });
346
+ const argvReturn = {};
347
+ for (let i = 0; i < args.length; i++) {
348
+ const arg = args[i];
349
+ const truncatedArg = arg.replace(/^-{3,}/, "---");
350
+ let broken;
351
+ let key;
352
+ let letters;
353
+ let m;
354
+ let next;
355
+ let value;
356
+ if (arg !== "--" && /^-/.test(arg) && isUnknownOptionAsArg(arg)) pushPositional(arg);
357
+ else if (truncatedArg.match(/^---+(=|$)/)) {
358
+ pushPositional(arg);
359
+ continue;
360
+ } else if (arg.match(/^--.+=/) || !configuration["short-option-groups"] && arg.match(/^-.+=/)) {
361
+ m = arg.match(/^--?([^=]+)=([\s\S]*)$/);
362
+ if (m !== null && _p_ArrayIsArray(m) && m.length >= 3) if (checkAllAliases(m[1], flags.arrays)) i = eatArray(i, m[1], args, m[2]);
363
+ else if (checkAllAliases(m[1], flags.nargs) !== false) i = eatNargs(i, m[1], args, m[2]);
364
+ else setArg(m[1], m[2], true);
365
+ } else if (arg.match(negatedBoolean) && configuration["boolean-negation"]) {
366
+ m = arg.match(negatedBoolean);
367
+ if (m !== null && _p_ArrayIsArray(m) && m.length >= 2) {
368
+ key = m[1];
369
+ setArg(key, checkAllAliases(key, flags.arrays) ? [false] : false);
370
+ }
371
+ } else if (arg.match(/^--.+/) || !configuration["short-option-groups"] && arg.match(/^-[^-]+/)) {
372
+ m = arg.match(/^--?(.+)/);
373
+ if (m !== null && _p_ArrayIsArray(m) && m.length >= 2) {
374
+ key = m[1];
375
+ if (checkAllAliases(key, flags.arrays)) i = eatArray(i, key, args);
376
+ else if (checkAllAliases(key, flags.nargs) !== false) i = eatNargs(i, key, args);
377
+ else {
378
+ next = args[i + 1];
379
+ if (next !== void 0 && (!next.match(/^-/) || next.match(negative)) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) {
380
+ setArg(key, next);
381
+ i++;
382
+ } else if (/^(true|false)$/.test(next)) {
383
+ setArg(key, next);
384
+ i++;
385
+ } else setArg(key, defaultValue(key));
386
+ }
387
+ }
388
+ } else if (arg.match(/^-.\..+=/)) {
389
+ m = arg.match(/^-([^=]+)=([\s\S]*)$/);
390
+ if (m !== null && _p_ArrayIsArray(m) && m.length >= 3) setArg(m[1], m[2]);
391
+ } else if (arg.match(/^-.\..+/) && !arg.match(negative)) {
392
+ next = args[i + 1];
393
+ m = arg.match(/^-(.\..+)/);
394
+ if (m !== null && _p_ArrayIsArray(m) && m.length >= 2) {
395
+ key = m[1];
396
+ if (next !== void 0 && !next.match(/^-/) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) {
397
+ setArg(key, next);
398
+ i++;
399
+ } else setArg(key, defaultValue(key));
400
+ }
401
+ } else if (arg.match(/^-[^-]+/) && !arg.match(negative)) {
402
+ letters = arg.slice(1, -1).split("");
403
+ broken = false;
404
+ for (let j = 0; j < letters.length; j++) {
405
+ next = arg.slice(j + 2);
406
+ if (letters[j + 1] && letters[j + 1] === "=") {
407
+ value = arg.slice(j + 3);
408
+ key = letters[j];
409
+ if (checkAllAliases(key, flags.arrays)) i = eatArray(i, key, args, value);
410
+ else if (checkAllAliases(key, flags.nargs) !== false) i = eatNargs(i, key, args, value);
411
+ else setArg(key, value);
412
+ broken = true;
413
+ break;
414
+ }
415
+ if (next === "-") {
416
+ setArg(letters[j], next);
417
+ continue;
418
+ }
419
+ if (/[A-Za-z]/.test(letters[j]) && /^-?\d+(\.\d*)?(e-?\d+)?$/.test(next) && checkAllAliases(next, flags.bools) === false) {
420
+ setArg(letters[j], next);
421
+ broken = true;
422
+ break;
423
+ }
424
+ if (letters[j + 1] && letters[j + 1].match(/\W/)) {
425
+ setArg(letters[j], next);
426
+ broken = true;
427
+ break;
428
+ } else setArg(letters[j], defaultValue(letters[j]));
429
+ }
430
+ key = arg.slice(-1)[0];
431
+ if (!broken && key !== "-") if (checkAllAliases(key, flags.arrays)) i = eatArray(i, key, args);
432
+ else if (checkAllAliases(key, flags.nargs) !== false) i = eatNargs(i, key, args);
433
+ else {
434
+ next = args[i + 1];
435
+ if (next !== void 0 && (!/^(-|--)[^-]/.test(next) || next.match(negative)) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) {
436
+ setArg(key, next);
437
+ i++;
438
+ } else if (/^(true|false)$/.test(next)) {
439
+ setArg(key, next);
440
+ i++;
441
+ } else setArg(key, defaultValue(key));
442
+ }
443
+ } else if (arg.match(/^-[0-9]$/) && arg.match(negative) && checkAllAliases(arg.slice(1), flags.bools)) {
444
+ key = arg.slice(1);
445
+ setArg(key, defaultValue(key));
446
+ } else if (arg === "--") {
447
+ notFlags = args.slice(i + 1);
448
+ break;
449
+ } else if (configuration["halt-at-non-option"]) {
450
+ notFlags = args.slice(i);
451
+ break;
452
+ } else pushPositional(arg);
453
+ }
454
+ applyEnvVars(argv, true);
455
+ applyEnvVars(argv, false);
456
+ setConfig(argv);
457
+ setConfigObjects();
458
+ applyDefaultsAndAliases(argv, flags.aliases, defaults, true);
459
+ applyCoercions(argv);
460
+ if (configuration["set-placeholder-key"]) setPlaceholderKeys(argv);
461
+ _p_ObjectKeys(flags.counts).forEach(function(key) {
462
+ if (!hasKey(argv, key.split("."))) setArg(key, 0);
463
+ });
464
+ if (notFlagsOption && notFlags.length) argv[notFlagsArgv] = [];
465
+ notFlags.forEach(function(key) {
466
+ argv[notFlagsArgv].push(key);
467
+ });
468
+ if (configuration["camel-case-expansion"] && configuration["strip-dashed"]) _p_ObjectKeys(argv).filter((key) => key !== "--" && key.includes("-")).forEach((key) => {
469
+ delete argv[key];
470
+ });
471
+ if (configuration["strip-aliased"]) [].concat(..._p_ObjectKeys(aliases).map((k) => aliases[k])).forEach((alias) => {
472
+ if (configuration["camel-case-expansion"] && alias.includes("-")) delete argv[alias.split(".").map((prop) => camelCase(prop)).join(".")];
473
+ delete argv[alias];
474
+ });
475
+ function pushPositional(arg) {
476
+ const maybeCoercedNumber = maybeCoerceNumber("_", arg);
477
+ if (typeof maybeCoercedNumber === "string" || typeof maybeCoercedNumber === "number") argv._.push(maybeCoercedNumber);
478
+ }
479
+ function eatNargs(i, key, args, argAfterEqualSign) {
480
+ let ii;
481
+ let toEat = checkAllAliases(key, flags.nargs);
482
+ toEat = typeof toEat !== "number" || isNaN(toEat) ? 1 : toEat;
483
+ if (toEat === 0) {
484
+ if (!isUndefined(argAfterEqualSign)) error = Error(__("Argument unexpected for: %s", key));
485
+ setArg(key, defaultValue(key));
486
+ return i;
487
+ }
488
+ let available = isUndefined(argAfterEqualSign) ? 0 : 1;
489
+ if (configuration["nargs-eats-options"]) {
490
+ if (args.length - (i + 1) + available < toEat) error = Error(__("Not enough arguments following: %s", key));
491
+ available = toEat;
492
+ } else {
493
+ for (ii = i + 1; ii < args.length; ii++) if (!args[ii].match(/^-[^0-9]/) || args[ii].match(negative) || isUnknownOptionAsArg(args[ii])) available++;
494
+ else break;
495
+ if (available < toEat) error = Error(__("Not enough arguments following: %s", key));
496
+ }
497
+ let consumed = _p_MathMin(available, toEat);
498
+ if (!isUndefined(argAfterEqualSign) && consumed > 0) {
499
+ setArg(key, argAfterEqualSign);
500
+ consumed--;
501
+ }
502
+ for (ii = i + 1; ii < consumed + i + 1; ii++) setArg(key, args[ii]);
503
+ return i + consumed;
504
+ }
505
+ function eatArray(i, key, args, argAfterEqualSign) {
506
+ let argsToSet = [];
507
+ let next = argAfterEqualSign || args[i + 1];
508
+ const nargsCount = checkAllAliases(key, flags.nargs);
509
+ if (checkAllAliases(key, flags.bools) && !/^(true|false)$/.test(next)) argsToSet.push(true);
510
+ else if (isUndefined(next) || isUndefined(argAfterEqualSign) && /^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next)) {
511
+ if (defaults[key] !== void 0) {
512
+ const defVal = defaults[key];
513
+ argsToSet = _p_ArrayIsArray(defVal) ? defVal : [defVal];
514
+ }
515
+ } else {
516
+ if (!isUndefined(argAfterEqualSign)) argsToSet.push(processValue(key, argAfterEqualSign, true));
517
+ for (let ii = i + 1; ii < args.length; ii++) {
518
+ if (!configuration["greedy-arrays"] && argsToSet.length > 0 || nargsCount && typeof nargsCount === "number" && argsToSet.length >= nargsCount) break;
519
+ next = args[ii];
520
+ if (/^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next)) break;
521
+ i = ii;
522
+ argsToSet.push(processValue(key, next, inputIsString));
523
+ }
524
+ }
525
+ if (typeof nargsCount === "number" && (nargsCount && argsToSet.length < nargsCount || isNaN(nargsCount) && argsToSet.length === 0)) error = Error(__("Not enough arguments following: %s", key));
526
+ setArg(key, argsToSet);
527
+ return i;
528
+ }
529
+ function setArg(key, val, shouldStripQuotes = inputIsString) {
530
+ if (/-/.test(key) && configuration["camel-case-expansion"]) addNewAlias(key, key.split(".").map(function(prop) {
531
+ return camelCase(prop);
532
+ }).join("."));
533
+ const value = processValue(key, val, shouldStripQuotes);
534
+ const splitKey = key.split(".");
535
+ setKey(argv, splitKey, value);
536
+ if (flags.aliases[key]) flags.aliases[key].forEach(function(x) {
537
+ setKey(argv, x.split("."), value);
538
+ });
539
+ if (splitKey.length > 1 && configuration["dot-notation"]) (flags.aliases[splitKey[0]] || []).forEach(function(x) {
540
+ let keyProperties = x.split(".");
541
+ const a = [].concat(splitKey);
542
+ a.shift();
543
+ keyProperties = keyProperties.concat(a);
544
+ if (!(flags.aliases[key] || []).includes(keyProperties.join("."))) setKey(argv, keyProperties, value);
545
+ });
546
+ if (checkAllAliases(key, flags.normalize) && !checkAllAliases(key, flags.arrays)) [key].concat(flags.aliases[key] || []).forEach(function(key) {
547
+ _p_ObjectDefineProperty(argvReturn, key, {
548
+ enumerable: true,
549
+ get() {
550
+ return val;
551
+ },
552
+ set(value) {
553
+ val = typeof value === "string" ? mixin.normalize(value) : value;
554
+ }
555
+ });
556
+ });
557
+ }
558
+ function addNewAlias(key, alias) {
559
+ if (!(flags.aliases[key] && flags.aliases[key].length)) {
560
+ flags.aliases[key] = [alias];
561
+ newAliases[alias] = true;
562
+ }
563
+ if (!(flags.aliases[alias] && flags.aliases[alias].length)) addNewAlias(alias, key);
564
+ }
565
+ function processValue(key, val, shouldStripQuotes) {
566
+ if (shouldStripQuotes) val = stripQuotes(val);
567
+ if (checkAllAliases(key, flags.bools) || checkAllAliases(key, flags.counts)) {
568
+ if (typeof val === "string") val = val === "true";
569
+ }
570
+ let value = _p_ArrayIsArray(val) ? val.map(function(v) {
571
+ return maybeCoerceNumber(key, v);
572
+ }) : maybeCoerceNumber(key, val);
573
+ if (checkAllAliases(key, flags.counts) && (isUndefined(value) || typeof value === "boolean")) value = increment();
574
+ if (checkAllAliases(key, flags.normalize) && checkAllAliases(key, flags.arrays)) if (_p_ArrayIsArray(val)) value = val.map((val) => {
575
+ return mixin.normalize(val);
576
+ });
577
+ else value = mixin.normalize(val);
578
+ return value;
579
+ }
580
+ function maybeCoerceNumber(key, value) {
581
+ if (!configuration["parse-positional-numbers"] && key === "_") return value;
582
+ if (!checkAllAliases(key, flags.strings) && !checkAllAliases(key, flags.bools) && !_p_ArrayIsArray(value)) {
583
+ if (looksLikeNumber(value) && configuration["parse-numbers"] && _p_NumberIsSafeInteger(_p_MathFloor(parseFloat(`${value}`))) || !isUndefined(value) && checkAllAliases(key, flags.numbers)) value = Number(value);
584
+ }
585
+ return value;
586
+ }
587
+ function setConfig(argv) {
588
+ const configLookup = _p_ObjectCreate(null);
589
+ applyDefaultsAndAliases(configLookup, flags.aliases, defaults);
590
+ _p_ObjectKeys(flags.configs).forEach(function(configKey) {
591
+ const configPath = argv[configKey] || configLookup[configKey];
592
+ if (configPath) try {
593
+ let config = null;
594
+ const resolvedConfigPath = mixin.resolve(mixin.cwd(), configPath);
595
+ const resolveConfig = flags.configs[configKey];
596
+ if (typeof resolveConfig === "function") {
597
+ try {
598
+ config = resolveConfig(resolvedConfigPath);
599
+ } catch (e) {
600
+ config = e;
601
+ }
602
+ if (config instanceof Error) {
603
+ error = config;
604
+ return;
605
+ }
606
+ } else config = mixin.require(resolvedConfigPath);
607
+ setConfigObject(config);
608
+ } catch (ex) {
609
+ if (ex.name === "PermissionDenied") error = ex;
610
+ else if (argv[configKey]) error = Error(__("Invalid JSON config file: %s", configPath));
611
+ }
612
+ });
613
+ }
614
+ function setConfigObject(config, prev) {
615
+ _p_ObjectKeys(config).forEach(function(key) {
616
+ const value = config[key];
617
+ const fullKey = prev ? prev + "." + key : key;
618
+ if (typeof value === "object" && value !== null && !_p_ArrayIsArray(value) && configuration["dot-notation"]) setConfigObject(value, fullKey);
619
+ else if (!hasKey(argv, fullKey.split(".")) || checkAllAliases(fullKey, flags.arrays) && configuration["combine-arrays"]) setArg(fullKey, value);
620
+ });
621
+ }
622
+ function setConfigObjects() {
623
+ if (typeof configObjects !== "undefined") configObjects.forEach(function(configObject) {
624
+ setConfigObject(configObject);
625
+ });
626
+ }
627
+ function applyEnvVars(argv, configOnly) {
628
+ if (typeof envPrefix === "undefined") return;
629
+ const prefix = typeof envPrefix === "string" ? envPrefix : "";
630
+ const env = mixin.env();
631
+ _p_ObjectKeys(env).forEach(function(envVar) {
632
+ if (prefix === "" || envVar.lastIndexOf(prefix, 0) === 0) {
633
+ const keys = envVar.split("__").map(function(key, i) {
634
+ if (i === 0) key = _p_StringPrototypeSubstring(key, prefix.length);
635
+ return camelCase(key);
636
+ });
637
+ if ((configOnly && flags.configs[keys.join(".")] || !configOnly) && !hasKey(argv, keys)) setArg(keys.join("."), env[envVar]);
638
+ }
639
+ });
640
+ }
641
+ function applyCoercions(argv) {
642
+ let coerce;
643
+ const applied = /* @__PURE__ */ new _p_SetCtor();
644
+ _p_ObjectKeys(argv).forEach(function(key) {
645
+ if (!applied.has(key)) {
646
+ coerce = checkAllAliases(key, flags.coercions);
647
+ if (typeof coerce === "function") try {
648
+ const value = maybeCoerceNumber(key, coerce(argv[key]));
649
+ [].concat(flags.aliases[key] || [], key).forEach((ali) => {
650
+ applied.add(ali);
651
+ argv[ali] = value;
652
+ });
653
+ } catch (err) {
654
+ error = err;
655
+ }
656
+ }
657
+ });
658
+ }
659
+ function setPlaceholderKeys(argv) {
660
+ flags.keys.forEach((key) => {
661
+ if (~key.indexOf(".")) return;
662
+ if (typeof argv[key] === "undefined") argv[key] = void 0;
663
+ });
664
+ return argv;
665
+ }
666
+ function applyDefaultsAndAliases(obj, aliases, defaults, canLog = false) {
667
+ _p_ObjectKeys(defaults).forEach(function(key) {
668
+ if (!hasKey(obj, key.split("."))) {
669
+ setKey(obj, key.split("."), defaults[key]);
670
+ if (canLog) defaulted[key] = true;
671
+ (aliases[key] || []).forEach(function(x) {
672
+ if (hasKey(obj, x.split("."))) return;
673
+ setKey(obj, x.split("."), defaults[key]);
674
+ });
675
+ }
676
+ });
677
+ }
678
+ function hasKey(obj, keys) {
679
+ let o = obj;
680
+ if (!configuration["dot-notation"]) keys = [keys.join(".")];
681
+ keys.slice(0, -1).forEach(function(key) {
682
+ o = o[key] || {};
683
+ });
684
+ const key = keys[keys.length - 1];
685
+ if (typeof o !== "object") return false;
686
+ else return key in o;
687
+ }
688
+ function setKey(obj, keys, value) {
689
+ let o = obj;
690
+ if (!configuration["dot-notation"]) keys = [keys.join(".")];
691
+ keys.slice(0, -1).forEach(function(key) {
692
+ key = sanitizeKey(key);
693
+ if (typeof o === "object" && o[key] === void 0) o[key] = {};
694
+ if (typeof o[key] !== "object" || _p_ArrayIsArray(o[key])) {
695
+ if (_p_ArrayIsArray(o[key])) o[key].push({});
696
+ else o[key] = [o[key], {}];
697
+ o = o[key][o[key].length - 1];
698
+ } else o = o[key];
699
+ });
700
+ const key = sanitizeKey(keys[keys.length - 1]);
701
+ const isTypeArray = checkAllAliases(keys.join("."), flags.arrays);
702
+ const isValueArray = _p_ArrayIsArray(value);
703
+ let duplicate = configuration["duplicate-arguments-array"];
704
+ if (!duplicate && checkAllAliases(key, flags.nargs)) {
705
+ duplicate = true;
706
+ if (!isUndefined(o[key]) && flags.nargs[key] === 1 || _p_ArrayIsArray(o[key]) && o[key].length === flags.nargs[key]) o[key] = void 0;
707
+ }
708
+ if (value === increment()) o[key] = increment(o[key]);
709
+ else if (_p_ArrayIsArray(o[key])) if (duplicate && isTypeArray && isValueArray) o[key] = configuration["flatten-duplicate-arrays"] ? o[key].concat(value) : (_p_ArrayIsArray(o[key][0]) ? o[key] : [o[key]]).concat([value]);
710
+ else if (!duplicate && Boolean(isTypeArray) === Boolean(isValueArray)) o[key] = value;
711
+ else o[key] = o[key].concat([value]);
712
+ else if (o[key] === void 0 && isTypeArray) o[key] = isValueArray ? value : [value];
713
+ else if (duplicate && !(o[key] === void 0 || checkAllAliases(key, flags.counts) || checkAllAliases(key, flags.bools))) o[key] = [o[key], value];
714
+ else o[key] = value;
715
+ }
716
+ function extendAliases(...args) {
717
+ args.forEach(function(obj) {
718
+ _p_ObjectKeys(obj || {}).forEach(function(key) {
719
+ if (flags.aliases[key]) return;
720
+ flags.aliases[key] = [].concat(aliases[key] || []);
721
+ flags.aliases[key].concat(key).forEach(function(x) {
722
+ if (/-/.test(x) && configuration["camel-case-expansion"]) {
723
+ const c = camelCase(x);
724
+ if (c !== key && flags.aliases[key].indexOf(c) === -1) {
725
+ flags.aliases[key].push(c);
726
+ newAliases[c] = true;
727
+ }
728
+ }
729
+ });
730
+ flags.aliases[key].concat(key).forEach(function(x) {
731
+ if (x.length > 1 && /[A-Z]/.test(x) && configuration["camel-case-expansion"]) {
732
+ const c = decamelize(x, "-");
733
+ if (c !== key && flags.aliases[key].indexOf(c) === -1) {
734
+ flags.aliases[key].push(c);
735
+ newAliases[c] = true;
736
+ }
737
+ }
738
+ });
739
+ flags.aliases[key].forEach(function(x) {
740
+ flags.aliases[x] = [key].concat(flags.aliases[key].filter(function(y) {
741
+ return x !== y;
742
+ }));
743
+ });
744
+ });
745
+ });
746
+ }
747
+ function checkAllAliases(key, flag) {
748
+ const toCheck = [].concat(flags.aliases[key] || [], key);
749
+ const keys = _p_ObjectKeys(flag);
750
+ const setAlias = toCheck.find((key) => keys.includes(key));
751
+ return setAlias ? flag[setAlias] : false;
752
+ }
753
+ function hasAnyFlag(key) {
754
+ const flagsKeys = _p_ObjectKeys(flags);
755
+ return [].concat(flagsKeys.map((k) => flags[k])).some(function(flag) {
756
+ return _p_ArrayIsArray(flag) ? flag.includes(key) : flag[key];
757
+ });
758
+ }
759
+ function hasFlagsMatching(arg, ...patterns) {
760
+ return [].concat(...patterns).some(function(pattern) {
761
+ const match = arg.match(pattern);
762
+ return match && hasAnyFlag(match[1]);
763
+ });
764
+ }
765
+ function hasAllShortFlags(arg) {
766
+ if (arg.match(negative) || !arg.match(/^-[^-]+/)) return false;
767
+ let hasAllFlags = true;
768
+ let next;
769
+ const letters = arg.slice(1).split("");
770
+ for (let j = 0; j < letters.length; j++) {
771
+ next = arg.slice(j + 2);
772
+ if (!hasAnyFlag(letters[j])) {
773
+ hasAllFlags = false;
774
+ break;
775
+ }
776
+ if (letters[j + 1] && letters[j + 1] === "=" || next === "-" || /[A-Za-z]/.test(letters[j]) && /^-?\d+(\.\d*)?(e-?\d+)?$/.test(next) || letters[j + 1] && letters[j + 1].match(/\W/)) break;
777
+ }
778
+ return hasAllFlags;
779
+ }
780
+ function isUnknownOptionAsArg(arg) {
781
+ return configuration["unknown-options-as-args"] && isUnknownOption(arg);
782
+ }
783
+ function isUnknownOption(arg) {
784
+ arg = arg.replace(/^-{3,}/, "--");
785
+ if (arg.match(negative)) return false;
786
+ if (hasAllShortFlags(arg)) return false;
787
+ return !hasFlagsMatching(arg, /^-+([^=]+?)=[\s\S]*$/, negatedBoolean, /^-+([^=]+?)$/, /^-+([^=]+?)-$/, /^-+([^=]+?\d+)$/, /^-+([^=]+?)\W+.*$/);
788
+ }
789
+ function defaultValue(key) {
790
+ if (!checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts) && `${key}` in defaults) return defaults[key];
791
+ else return defaultForType(guessType(key));
792
+ }
793
+ function defaultForType(type) {
794
+ return {
795
+ [DefaultValuesForTypeKey.BOOLEAN]: true,
796
+ [DefaultValuesForTypeKey.STRING]: "",
797
+ [DefaultValuesForTypeKey.NUMBER]: void 0,
798
+ [DefaultValuesForTypeKey.ARRAY]: []
799
+ }[type];
800
+ }
801
+ function guessType(key) {
802
+ let type = DefaultValuesForTypeKey.BOOLEAN;
803
+ if (checkAllAliases(key, flags.strings)) type = DefaultValuesForTypeKey.STRING;
804
+ else if (checkAllAliases(key, flags.numbers)) type = DefaultValuesForTypeKey.NUMBER;
805
+ else if (checkAllAliases(key, flags.bools)) type = DefaultValuesForTypeKey.BOOLEAN;
806
+ else if (checkAllAliases(key, flags.arrays)) type = DefaultValuesForTypeKey.ARRAY;
807
+ return type;
808
+ }
809
+ function isUndefined(num) {
810
+ return num === void 0;
811
+ }
812
+ function checkConfiguration() {
813
+ _p_ObjectKeys(flags.counts).find((key) => {
814
+ if (checkAllAliases(key, flags.arrays)) {
815
+ error = Error(__("Invalid configuration: %s, opts.count excludes opts.array.", key));
816
+ return true;
817
+ } else if (checkAllAliases(key, flags.nargs)) {
818
+ error = Error(__("Invalid configuration: %s, opts.count excludes opts.narg.", key));
819
+ return true;
820
+ }
821
+ return false;
822
+ });
823
+ }
824
+ return {
825
+ aliases: _p_ObjectAssign({}, flags.aliases),
826
+ argv: _p_ObjectAssign(argvReturn, argv),
827
+ configuration,
828
+ defaulted: _p_ObjectAssign({}, defaulted),
829
+ error,
830
+ newAliases: _p_ObjectAssign({}, newAliases)
831
+ };
832
+ }
833
+ };
834
+ }));
1036
835
 
1037
- // node_modules/.pnpm/yargs-parser@22.0.0/node_modules/yargs-parser/build/lib/index.js
1038
- var lib_exports = {};
1039
- __export(lib_exports, {
1040
- default: () => lib_default,
1041
- "module.exports": () => yargsParser
1042
- });
1043
- var import_util, import_path, import_fs, import_node_module, _a, _b, _c, minNodeVersion, nodeVersion, env, require2, parser, yargsParser, lib_default;
1044
- var init_lib = __esm({
1045
- "node_modules/.pnpm/yargs-parser@22.0.0/node_modules/yargs-parser/build/lib/index.js"() {
1046
- import_util = require("util");
1047
- import_path = require("path");
1048
- init_string_utils();
1049
- init_yargs_parser();
1050
- import_fs = require("fs");
1051
- import_node_module = require("node:module");
1052
- minNodeVersion = process && process.env && process.env.YARGS_MIN_NODE_VERSION ? Number(process.env.YARGS_MIN_NODE_VERSION) : 20;
1053
- nodeVersion = (_b = (_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node) !== null && _b !== void 0 ? _b : (_c = process === null || process === void 0 ? void 0 : process.version) === null || _c === void 0 ? void 0 : _c.slice(1);
1054
- if (nodeVersion) {
1055
- const major = Number(nodeVersion.match(/^([^.]+)/)[1]);
1056
- if (major < minNodeVersion) {
1057
- throw Error(`yargs parser supports a minimum Node.js version of ${minNodeVersion}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);
1058
- }
1059
- }
1060
- env = process ? process.env : {};
1061
- require2 = import_node_module.createRequire ? (0, import_node_module.createRequire)(__filename) : void 0;
1062
- parser = new YargsParser({
1063
- cwd: process.cwd,
1064
- env: /* @__PURE__ */ __name(() => {
1065
- return env;
1066
- }, "env"),
1067
- format: import_util.format,
1068
- normalize: import_path.normalize,
1069
- resolve: import_path.resolve,
1070
- require: /* @__PURE__ */ __name((path) => {
1071
- if (typeof require2 !== "undefined") {
1072
- return require2(path);
1073
- } else if (path.match(/\.json$/)) {
1074
- return _p_JSONParse((0, import_fs.readFileSync)(path, "utf8"));
1075
- } else {
1076
- throw Error("only .json config files are supported in ESM");
1077
- }
1078
- }, "require")
1079
- });
1080
- yargsParser = /* @__PURE__ */ __name(function Parser(args, opts) {
1081
- const result = parser.parse(args.slice(), opts);
1082
- return result.argv;
1083
- }, "Parser");
1084
- yargsParser.detailed = function(args, opts) {
1085
- return parser.parse(args.slice(), opts);
1086
- };
1087
- yargsParser.camelCase = camelCase;
1088
- yargsParser.decamelize = decamelize;
1089
- yargsParser.looksLikeNumber = looksLikeNumber;
1090
- lib_default = yargsParser;
1091
- }
836
+ //#endregion
837
+ //#region node_modules/.pnpm/yargs-parser@22.0.0/node_modules/yargs-parser/build/lib/index.js
838
+ var lib_exports = /* @__PURE__ */ __exportAll({
839
+ default: () => yargsParser,
840
+ "module.exports": () => yargsParser
1092
841
  });
842
+ var _a, _b, _c, minNodeVersion, nodeVersion, env, require$1, parser, yargsParser;
843
+ var init_lib = __esmMin((() => {
844
+ init_string_utils();
845
+ init_yargs_parser();
846
+ ;
847
+ ;
848
+ ;
849
+ minNodeVersion = process && process.env && process.env.YARGS_MIN_NODE_VERSION ? Number(process.env.YARGS_MIN_NODE_VERSION) : 20;
850
+ nodeVersion = (_b = (_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node) !== null && _b !== void 0 ? _b : (_c = process === null || process === void 0 ? void 0 : process.version) === null || _c === void 0 ? void 0 : _c.slice(1);
851
+ /**
852
+ * @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
853
+ *
854
+ * @license
855
+ * Copyright (c) 2016, Contributors
856
+ * SPDX-License-Identifier: ISC
857
+ */
858
+ if (nodeVersion) {
859
+ if (Number(nodeVersion.match(/^([^.]+)/)[1]) < minNodeVersion) throw Error(`yargs parser supports a minimum Node.js version of ${minNodeVersion}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);
860
+ }
861
+ env = process ? process.env : {};
862
+ require$1 = node_module.createRequire ? (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href) : void 0;
863
+ parser = new YargsParser({
864
+ cwd: process.cwd,
865
+ env: () => {
866
+ return env;
867
+ },
868
+ format: util.format,
869
+ normalize: path.normalize,
870
+ resolve: path.resolve,
871
+ require: (path$1) => {
872
+ if (typeof require$1 !== "undefined") return require$1(path$1);
873
+ else if (path$1.match(/\.json$/)) return _p_JSONParse((0, fs.readFileSync)(path$1, "utf8"));
874
+ else throw Error("only .json config files are supported in ESM");
875
+ }
876
+ });
877
+ yargsParser = function Parser(args, opts) {
878
+ return parser.parse(args.slice(), opts).argv;
879
+ };
880
+ yargsParser.detailed = function(args, opts) {
881
+ return parser.parse(args.slice(), opts);
882
+ };
883
+ yargsParser.camelCase = camelCase;
884
+ yargsParser.decamelize = decamelize;
885
+ yargsParser.looksLikeNumber = looksLikeNumber;
886
+ }));
1093
887
 
1094
- // src/external/yargs-parser.js
888
+ //#endregion
889
+ //#region src/external/yargs-parser.js
1095
890
  module.exports = (init_lib(), __toCommonJS(lib_exports));
1096
- /*! Bundled license information:
1097
891
 
1098
- yargs-parser/build/lib/string-utils.js:
1099
- yargs-parser/build/lib/tokenize-arg-string.js:
1100
- yargs-parser/build/lib/yargs-parser-types.js:
1101
- yargs-parser/build/lib/yargs-parser.js:
1102
- (**
1103
- * @license
1104
- * Copyright (c) 2016, Contributors
1105
- * SPDX-License-Identifier: ISC
1106
- *)
1107
-
1108
- yargs-parser/build/lib/index.js:
1109
- (**
1110
- * @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
1111
- *
1112
- * @license
1113
- * Copyright (c) 2016, Contributors
1114
- * SPDX-License-Identifier: ISC
1115
- *)
1116
- */
892
+ //#endregion
893
+ exports["module.exports"] = yargsParser;