ccjk 14.2.2 → 15.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (532) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +75 -338
  3. package/dist/cli.js +89 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/commands/detect.js +15 -0
  6. package/dist/commands/detect.js.map +1 -0
  7. package/dist/commands/doctor.js +68 -0
  8. package/dist/commands/doctor.js.map +1 -0
  9. package/dist/commands/git-install.js +50 -0
  10. package/dist/commands/git-install.js.map +1 -0
  11. package/dist/commands/init.js +165 -0
  12. package/dist/commands/init.js.map +1 -0
  13. package/dist/commands/mcp.js +66 -0
  14. package/dist/commands/mcp.js.map +1 -0
  15. package/dist/commands/menu.js +42 -0
  16. package/dist/commands/menu.js.map +1 -0
  17. package/dist/commands/profile.js +138 -0
  18. package/dist/commands/profile.js.map +1 -0
  19. package/dist/core/detect.js +24 -0
  20. package/dist/core/detect.js.map +1 -0
  21. package/dist/core/lint.js +49 -0
  22. package/dist/core/lint.js.map +1 -0
  23. package/dist/core/mcp.js +41 -0
  24. package/dist/core/mcp.js.map +1 -0
  25. package/dist/core/paths.js +9 -0
  26. package/dist/core/paths.js.map +1 -0
  27. package/dist/core/profiles.js +104 -0
  28. package/dist/core/profiles.js.map +1 -0
  29. package/dist/core/providers.js +53 -0
  30. package/dist/core/providers.js.map +1 -0
  31. package/dist/core/settings.js +31 -0
  32. package/dist/core/settings.js.map +1 -0
  33. package/dist/core/slash-templates.js +56 -0
  34. package/dist/core/slash-templates.js.map +1 -0
  35. package/dist/core/tools.js +27 -0
  36. package/dist/core/tools.js.map +1 -0
  37. package/package.json +43 -164
  38. package/README.HONEST.md +0 -176
  39. package/README.en.md +0 -67
  40. package/README.ja.md +0 -67
  41. package/README.ko.md +0 -67
  42. package/README.zh-CN.md +0 -86
  43. package/bin/ccjk.mjs +0 -5
  44. package/bin/ccjk.ts +0 -222
  45. package/dist/chunks/agent-teams.mjs +0 -145
  46. package/dist/chunks/agent.mjs +0 -1439
  47. package/dist/chunks/agents.mjs +0 -3783
  48. package/dist/chunks/api-cli.mjs +0 -135
  49. package/dist/chunks/api-config-selector.mjs +0 -159
  50. package/dist/chunks/api-providers.mjs +0 -144
  51. package/dist/chunks/api.mjs +0 -115
  52. package/dist/chunks/auto-bootstrap.mjs +0 -358
  53. package/dist/chunks/auto-fixer.mjs +0 -95
  54. package/dist/chunks/auto-updater.mjs +0 -507
  55. package/dist/chunks/banner.mjs +0 -173
  56. package/dist/chunks/bash.mjs +0 -187
  57. package/dist/chunks/boost.mjs +0 -474
  58. package/dist/chunks/brain-config.mjs +0 -75
  59. package/dist/chunks/brain-status.mjs +0 -89
  60. package/dist/chunks/ccjk-agents.mjs +0 -416
  61. package/dist/chunks/ccjk-all.mjs +0 -1046
  62. package/dist/chunks/ccjk-config.mjs +0 -445
  63. package/dist/chunks/ccjk-hooks.mjs +0 -1074
  64. package/dist/chunks/ccjk-mcp.mjs +0 -763
  65. package/dist/chunks/ccjk-setup.mjs +0 -765
  66. package/dist/chunks/ccjk-skills.mjs +0 -518
  67. package/dist/chunks/ccr.mjs +0 -109
  68. package/dist/chunks/ccu.mjs +0 -40
  69. package/dist/chunks/check-updates.mjs +0 -117
  70. package/dist/chunks/claude-code-incremental-manager.mjs +0 -761
  71. package/dist/chunks/claude-config.mjs +0 -606
  72. package/dist/chunks/claude-config2.mjs +0 -62
  73. package/dist/chunks/claude-wrapper.mjs +0 -85
  74. package/dist/chunks/clavue-config.mjs +0 -1454
  75. package/dist/chunks/cleanup-migration.mjs +0 -20
  76. package/dist/chunks/cli-hook.mjs +0 -4096
  77. package/dist/chunks/cloud-sync.mjs +0 -29
  78. package/dist/chunks/code-type-resolver.mjs +0 -880
  79. package/dist/chunks/codex-config-switch.mjs +0 -452
  80. package/dist/chunks/codex-provider-manager.mjs +0 -238
  81. package/dist/chunks/codex-uninstaller.mjs +0 -404
  82. package/dist/chunks/codex.mjs +0 -2141
  83. package/dist/chunks/commands.mjs +0 -108
  84. package/dist/chunks/commands2.mjs +0 -421
  85. package/dist/chunks/commit.mjs +0 -140
  86. package/dist/chunks/completion.mjs +0 -517
  87. package/dist/chunks/config-consolidator.mjs +0 -172
  88. package/dist/chunks/config-switch.mjs +0 -334
  89. package/dist/chunks/config.mjs +0 -558
  90. package/dist/chunks/config2.mjs +0 -484
  91. package/dist/chunks/config3.mjs +0 -486
  92. package/dist/chunks/constants.mjs +0 -323
  93. package/dist/chunks/context-opt.mjs +0 -444
  94. package/dist/chunks/context.mjs +0 -974
  95. package/dist/chunks/dashboard.mjs +0 -481
  96. package/dist/chunks/doctor.mjs +0 -1301
  97. package/dist/chunks/eval.mjs +0 -502
  98. package/dist/chunks/evolution.mjs +0 -322
  99. package/dist/chunks/features.mjs +0 -715
  100. package/dist/chunks/fish.mjs +0 -181
  101. package/dist/chunks/fs-operations.mjs +0 -180
  102. package/dist/chunks/health-alerts.mjs +0 -830
  103. package/dist/chunks/help.mjs +0 -341
  104. package/dist/chunks/hook-installer.mjs +0 -48
  105. package/dist/chunks/impact.mjs +0 -651
  106. package/dist/chunks/index.mjs +0 -23
  107. package/dist/chunks/index10.mjs +0 -19
  108. package/dist/chunks/index11.mjs +0 -1171
  109. package/dist/chunks/index12.mjs +0 -218
  110. package/dist/chunks/index13.mjs +0 -679
  111. package/dist/chunks/index14.mjs +0 -1009
  112. package/dist/chunks/index15.mjs +0 -194
  113. package/dist/chunks/index2.mjs +0 -7637
  114. package/dist/chunks/index3.mjs +0 -171
  115. package/dist/chunks/index4.mjs +0 -26
  116. package/dist/chunks/index5.mjs +0 -19
  117. package/dist/chunks/index6.mjs +0 -19092
  118. package/dist/chunks/index7.mjs +0 -616
  119. package/dist/chunks/index8.mjs +0 -1602
  120. package/dist/chunks/index9.mjs +0 -5384
  121. package/dist/chunks/init.mjs +0 -1911
  122. package/dist/chunks/installer.mjs +0 -757
  123. package/dist/chunks/installer2.mjs +0 -103
  124. package/dist/chunks/interview.mjs +0 -2927
  125. package/dist/chunks/json-config.mjs +0 -60
  126. package/dist/chunks/linux.mjs +0 -3863
  127. package/dist/chunks/macos.mjs +0 -69
  128. package/dist/chunks/main.mjs +0 -635
  129. package/dist/chunks/manager.mjs +0 -1048
  130. package/dist/chunks/marketplace.mjs +0 -265
  131. package/dist/chunks/mcp-cli.mjs +0 -205
  132. package/dist/chunks/mcp-performance.mjs +0 -187
  133. package/dist/chunks/mcp.mjs +0 -667
  134. package/dist/chunks/memory-check.mjs +0 -2973
  135. package/dist/chunks/memory-paths.mjs +0 -259
  136. package/dist/chunks/memory-sync.mjs +0 -209
  137. package/dist/chunks/memory.mjs +0 -354
  138. package/dist/chunks/metrics-display.mjs +0 -153
  139. package/dist/chunks/monitor.mjs +0 -1856
  140. package/dist/chunks/notification.mjs +0 -1864
  141. package/dist/chunks/onboarding.mjs +0 -386
  142. package/dist/chunks/package.mjs +0 -3
  143. package/dist/chunks/paradigm.mjs +0 -74
  144. package/dist/chunks/permission-manager.mjs +0 -250
  145. package/dist/chunks/permissions.mjs +0 -265
  146. package/dist/chunks/persistence-manager.mjs +0 -801
  147. package/dist/chunks/persistence.mjs +0 -707
  148. package/dist/chunks/platform.mjs +0 -395
  149. package/dist/chunks/plugin.mjs +0 -1936
  150. package/dist/chunks/powershell.mjs +0 -213
  151. package/dist/chunks/prompts.mjs +0 -244
  152. package/dist/chunks/providers.mjs +0 -263
  153. package/dist/chunks/quick-actions.mjs +0 -335
  154. package/dist/chunks/quick-provider.mjs +0 -755
  155. package/dist/chunks/quick-setup.mjs +0 -421
  156. package/dist/chunks/remote.mjs +0 -497
  157. package/dist/chunks/research.mjs +0 -1904
  158. package/dist/chunks/rollback.mjs +0 -38
  159. package/dist/chunks/session-manager.mjs +0 -1371
  160. package/dist/chunks/session.mjs +0 -878
  161. package/dist/chunks/sessions.mjs +0 -106
  162. package/dist/chunks/silent-updater.mjs +0 -396
  163. package/dist/chunks/simple-config.mjs +0 -122
  164. package/dist/chunks/skill.mjs +0 -117
  165. package/dist/chunks/skill2.mjs +0 -9052
  166. package/dist/chunks/skills-sync.mjs +0 -1343
  167. package/dist/chunks/skills.mjs +0 -577
  168. package/dist/chunks/slash-commands.mjs +0 -208
  169. package/dist/chunks/smart-guide.mjs +0 -247
  170. package/dist/chunks/snapshot.mjs +0 -58
  171. package/dist/chunks/startup.mjs +0 -487
  172. package/dist/chunks/stats.mjs +0 -191
  173. package/dist/chunks/status.mjs +0 -471
  174. package/dist/chunks/team.mjs +0 -63
  175. package/dist/chunks/thinking.mjs +0 -626
  176. package/dist/chunks/trace.mjs +0 -57
  177. package/dist/chunks/uninstall.mjs +0 -852
  178. package/dist/chunks/update.mjs +0 -174
  179. package/dist/chunks/upgrade-manager.mjs +0 -204
  180. package/dist/chunks/upgrade.mjs +0 -133
  181. package/dist/chunks/version-checker.mjs +0 -891
  182. package/dist/chunks/vim.mjs +0 -903
  183. package/dist/chunks/windows.mjs +0 -14
  184. package/dist/chunks/workflows.mjs +0 -633
  185. package/dist/chunks/wsl.mjs +0 -129
  186. package/dist/chunks/zero-config.mjs +0 -871
  187. package/dist/chunks/zsh.mjs +0 -182
  188. package/dist/cli.d.mts +0 -1
  189. package/dist/cli.d.ts +0 -1
  190. package/dist/cli.mjs +0 -2684
  191. package/dist/i18n/locales/en/agent-teams.json +0 -18
  192. package/dist/i18n/locales/en/agentBrowser.json +0 -80
  193. package/dist/i18n/locales/en/agents.json +0 -135
  194. package/dist/i18n/locales/en/api.json +0 -63
  195. package/dist/i18n/locales/en/ccjk-agents.json +0 -33
  196. package/dist/i18n/locales/en/ccjk-all.json +0 -23
  197. package/dist/i18n/locales/en/ccjk-skills.json +0 -22
  198. package/dist/i18n/locales/en/ccjk.json +0 -276
  199. package/dist/i18n/locales/en/ccr.json +0 -65
  200. package/dist/i18n/locales/en/claude-md.json +0 -73
  201. package/dist/i18n/locales/en/cli.json +0 -148
  202. package/dist/i18n/locales/en/cloud-setup.json +0 -31
  203. package/dist/i18n/locales/en/cloud-sync.json +0 -147
  204. package/dist/i18n/locales/en/cloud.json +0 -40
  205. package/dist/i18n/locales/en/cloudPlugins.json +0 -118
  206. package/dist/i18n/locales/en/codex.json +0 -184
  207. package/dist/i18n/locales/en/cometix.json +0 -29
  208. package/dist/i18n/locales/en/common.json +0 -68
  209. package/dist/i18n/locales/en/config.json +0 -108
  210. package/dist/i18n/locales/en/configuration.json +0 -236
  211. package/dist/i18n/locales/en/context.json +0 -85
  212. package/dist/i18n/locales/en/dashboard.json +0 -78
  213. package/dist/i18n/locales/en/errors.json +0 -26
  214. package/dist/i18n/locales/en/evolution.json +0 -54
  215. package/dist/i18n/locales/en/hooks.json +0 -74
  216. package/dist/i18n/locales/en/hooksSync.json +0 -133
  217. package/dist/i18n/locales/en/installation.json +0 -83
  218. package/dist/i18n/locales/en/interview.json +0 -104
  219. package/dist/i18n/locales/en/language.json +0 -19
  220. package/dist/i18n/locales/en/lsp.json +0 -78
  221. package/dist/i18n/locales/en/marketplace.json +0 -116
  222. package/dist/i18n/locales/en/mcp.json +0 -180
  223. package/dist/i18n/locales/en/memory.json +0 -23
  224. package/dist/i18n/locales/en/menu.json +0 -299
  225. package/dist/i18n/locales/en/multi-config.json +0 -79
  226. package/dist/i18n/locales/en/notification.json +0 -307
  227. package/dist/i18n/locales/en/permissions.json +0 -95
  228. package/dist/i18n/locales/en/persistence.json +0 -127
  229. package/dist/i18n/locales/en/plugins.json +0 -146
  230. package/dist/i18n/locales/en/quick-actions.json +0 -78
  231. package/dist/i18n/locales/en/registry.json +0 -54
  232. package/dist/i18n/locales/en/remote.json +0 -93
  233. package/dist/i18n/locales/en/sandbox.json +0 -44
  234. package/dist/i18n/locales/en/setup.json +0 -44
  235. package/dist/i18n/locales/en/shencha.json +0 -14
  236. package/dist/i18n/locales/en/skills.json +0 -100
  237. package/dist/i18n/locales/en/skillsSync.json +0 -74
  238. package/dist/i18n/locales/en/smartGuide.json +0 -49
  239. package/dist/i18n/locales/en/stats.json +0 -20
  240. package/dist/i18n/locales/en/subagent.json +0 -69
  241. package/dist/i18n/locales/en/superpowers.json +0 -117
  242. package/dist/i18n/locales/en/team.json +0 -7
  243. package/dist/i18n/locales/en/thinking.json +0 -65
  244. package/dist/i18n/locales/en/tools.json +0 -42
  245. package/dist/i18n/locales/en/uninstall.json +0 -56
  246. package/dist/i18n/locales/en/updater.json +0 -29
  247. package/dist/i18n/locales/en/vim.json +0 -169
  248. package/dist/i18n/locales/en/workflow.json +0 -55
  249. package/dist/i18n/locales/en/workspace.json +0 -108
  250. package/dist/i18n/locales/zh-CN/agent-teams.json +0 -18
  251. package/dist/i18n/locales/zh-CN/agentBrowser.json +0 -80
  252. package/dist/i18n/locales/zh-CN/agents.json +0 -135
  253. package/dist/i18n/locales/zh-CN/api.json +0 -63
  254. package/dist/i18n/locales/zh-CN/ccjk-agents.json +0 -33
  255. package/dist/i18n/locales/zh-CN/ccjk-all.json +0 -23
  256. package/dist/i18n/locales/zh-CN/ccjk-skills.json +0 -22
  257. package/dist/i18n/locales/zh-CN/ccjk.json +0 -276
  258. package/dist/i18n/locales/zh-CN/ccr.json +0 -65
  259. package/dist/i18n/locales/zh-CN/claude-md.json +0 -73
  260. package/dist/i18n/locales/zh-CN/cli.json +0 -148
  261. package/dist/i18n/locales/zh-CN/cloud-setup.json +0 -31
  262. package/dist/i18n/locales/zh-CN/cloud-sync.json +0 -147
  263. package/dist/i18n/locales/zh-CN/cloud.json +0 -40
  264. package/dist/i18n/locales/zh-CN/cloudPlugins.json +0 -118
  265. package/dist/i18n/locales/zh-CN/codex.json +0 -184
  266. package/dist/i18n/locales/zh-CN/cometix.json +0 -29
  267. package/dist/i18n/locales/zh-CN/common.json +0 -68
  268. package/dist/i18n/locales/zh-CN/config.json +0 -108
  269. package/dist/i18n/locales/zh-CN/configuration.json +0 -234
  270. package/dist/i18n/locales/zh-CN/context.json +0 -85
  271. package/dist/i18n/locales/zh-CN/dashboard.json +0 -78
  272. package/dist/i18n/locales/zh-CN/errors.json +0 -26
  273. package/dist/i18n/locales/zh-CN/evolution.json +0 -54
  274. package/dist/i18n/locales/zh-CN/hooks.json +0 -74
  275. package/dist/i18n/locales/zh-CN/hooksSync.json +0 -133
  276. package/dist/i18n/locales/zh-CN/installation.json +0 -83
  277. package/dist/i18n/locales/zh-CN/interview.json +0 -104
  278. package/dist/i18n/locales/zh-CN/language.json +0 -19
  279. package/dist/i18n/locales/zh-CN/lsp.json +0 -78
  280. package/dist/i18n/locales/zh-CN/marketplace.json +0 -116
  281. package/dist/i18n/locales/zh-CN/mcp.json +0 -180
  282. package/dist/i18n/locales/zh-CN/memory.json +0 -23
  283. package/dist/i18n/locales/zh-CN/menu.json +0 -299
  284. package/dist/i18n/locales/zh-CN/multi-config.json +0 -79
  285. package/dist/i18n/locales/zh-CN/notification.json +0 -307
  286. package/dist/i18n/locales/zh-CN/permissions.json +0 -95
  287. package/dist/i18n/locales/zh-CN/persistence.json +0 -127
  288. package/dist/i18n/locales/zh-CN/plugins.json +0 -146
  289. package/dist/i18n/locales/zh-CN/quick-actions.json +0 -78
  290. package/dist/i18n/locales/zh-CN/registry.json +0 -54
  291. package/dist/i18n/locales/zh-CN/remote.json +0 -93
  292. package/dist/i18n/locales/zh-CN/sandbox.json +0 -44
  293. package/dist/i18n/locales/zh-CN/setup.json +0 -44
  294. package/dist/i18n/locales/zh-CN/shencha.json +0 -14
  295. package/dist/i18n/locales/zh-CN/skills.json +0 -100
  296. package/dist/i18n/locales/zh-CN/skillsSync.json +0 -74
  297. package/dist/i18n/locales/zh-CN/smartGuide.json +0 -49
  298. package/dist/i18n/locales/zh-CN/stats.json +0 -20
  299. package/dist/i18n/locales/zh-CN/subagent.json +0 -69
  300. package/dist/i18n/locales/zh-CN/superpowers.json +0 -117
  301. package/dist/i18n/locales/zh-CN/team.json +0 -7
  302. package/dist/i18n/locales/zh-CN/thinking.json +0 -65
  303. package/dist/i18n/locales/zh-CN/tools.json +0 -42
  304. package/dist/i18n/locales/zh-CN/uninstall.json +0 -56
  305. package/dist/i18n/locales/zh-CN/updater.json +0 -29
  306. package/dist/i18n/locales/zh-CN/vim.json +0 -169
  307. package/dist/i18n/locales/zh-CN/workflow.json +0 -55
  308. package/dist/i18n/locales/zh-CN/workspace.json +0 -108
  309. package/dist/index.d.mts +0 -5658
  310. package/dist/index.d.ts +0 -5658
  311. package/dist/index.mjs +0 -3732
  312. package/dist/shared/ccjk.5bEolFrk.mjs +0 -254
  313. package/dist/shared/ccjk.8oaxX4iR.mjs +0 -90
  314. package/dist/shared/ccjk.B2U7DsPy.mjs +0 -31
  315. package/dist/shared/ccjk.B2f-cwUP.mjs +0 -468
  316. package/dist/shared/ccjk.BAGoDD49.mjs +0 -36
  317. package/dist/shared/ccjk.BBtCGd_g.mjs +0 -899
  318. package/dist/shared/ccjk.BFQ7yr5S.mjs +0 -16
  319. package/dist/shared/ccjk.BLsIiTqO.mjs +0 -449
  320. package/dist/shared/ccjk.BXv8aYs1.mjs +0 -170
  321. package/dist/shared/ccjk.BnsY5WxD.mjs +0 -171
  322. package/dist/shared/ccjk.BoApaI4j.mjs +0 -28
  323. package/dist/shared/ccjk.Bq8TqZG_.mjs +0 -189
  324. package/dist/shared/ccjk.BtrioX1Z.mjs +0 -25
  325. package/dist/shared/ccjk.Bx_rmYfN.mjs +0 -69
  326. package/dist/shared/ccjk.BzPbSEP2.mjs +0 -115
  327. package/dist/shared/ccjk.C0WLUnFV.mjs +0 -293
  328. package/dist/shared/ccjk.C1hANZTu.mjs +0 -19
  329. package/dist/shared/ccjk.C2jHOZVP.mjs +0 -52
  330. package/dist/shared/ccjk.CNhnT6uQ.mjs +0 -636
  331. package/dist/shared/ccjk.COweQ1RR.mjs +0 -5
  332. package/dist/shared/ccjk.CfKKcvWy.mjs +0 -126
  333. package/dist/shared/ccjk.Cjgrln_h.mjs +0 -297
  334. package/dist/shared/ccjk.CoCHVXl3.mjs +0 -3951
  335. package/dist/shared/ccjk.CwGZSTAK.mjs +0 -319
  336. package/dist/shared/ccjk.CxpGa6MC.mjs +0 -2724
  337. package/dist/shared/ccjk.D-magaEx.mjs +0 -763
  338. package/dist/shared/ccjk.D0g2ABGg.mjs +0 -171
  339. package/dist/shared/ccjk.D6ycHbak.mjs +0 -270
  340. package/dist/shared/ccjk.D75wivnp.mjs +0 -142
  341. package/dist/shared/ccjk.DDL-4C-k.mjs +0 -100
  342. package/dist/shared/ccjk.DFRPtmK_.mjs +0 -75
  343. package/dist/shared/ccjk.DMV3x5Sd.mjs +0 -299
  344. package/dist/shared/ccjk.DZ2LLOa-.mjs +0 -2195
  345. package/dist/shared/ccjk.DbigonEQ.mjs +0 -698
  346. package/dist/shared/ccjk.DcMvE7lf.mjs +0 -618
  347. package/dist/shared/ccjk.DeWpAShp.mjs +0 -1828
  348. package/dist/shared/ccjk.DhJ1kyDR.mjs +0 -30
  349. package/dist/shared/ccjk.DlTXS9rP.mjs +0 -224
  350. package/dist/shared/ccjk.DopKzo3z.mjs +0 -305
  351. package/dist/shared/ccjk.DsZsc4LR.mjs +0 -1280
  352. package/dist/shared/ccjk.DuzJZlgj.mjs +0 -418
  353. package/dist/shared/ccjk.Dxgd2vjc.mjs +0 -444
  354. package/dist/shared/ccjk.J8YiPsOw.mjs +0 -259
  355. package/dist/shared/ccjk.KfSWcGlE.mjs +0 -38
  356. package/dist/shared/ccjk.L7yC58_i.mjs +0 -225
  357. package/dist/shared/ccjk.MwtjAULc.mjs +0 -1447
  358. package/dist/shared/ccjk.OJKHVSOb.mjs +0 -2005
  359. package/dist/shared/ccjk.OTnevPNE.mjs +0 -225
  360. package/dist/shared/ccjk.RyizuzOI.mjs +0 -21
  361. package/dist/shared/ccjk.T_cX87dY.mjs +0 -15
  362. package/dist/shared/ccjk.bQ7Dh1g4.mjs +0 -249
  363. package/dist/shared/ccjk.gDEDGD_t.mjs +0 -38
  364. package/dist/shared/ccjk.hoqrwWdN.mjs +0 -333
  365. package/dist/shared/ccjk.i_vn-9C3.mjs +0 -317
  366. package/dist/shared/ccjk.lG3ccFjm.mjs +0 -885
  367. package/dist/shared/ccjk.wLJHO0Af.mjs +0 -244
  368. package/dist/shared/ccjk.y-a_1vK4.mjs +0 -5127
  369. package/dist/templates/agents/README.md +0 -78
  370. package/dist/templates/agents/fullstack-developer.json +0 -70
  371. package/dist/templates/agents/go-expert.json +0 -69
  372. package/dist/templates/agents/index.json +0 -64
  373. package/dist/templates/agents/python-expert.json +0 -69
  374. package/dist/templates/agents/react-specialist.json +0 -69
  375. package/dist/templates/agents/testing-automation-expert.json +0 -70
  376. package/dist/templates/agents/typescript-architect.json +0 -69
  377. package/dist/templates/claude-code/common/settings.json +0 -109
  378. package/dist/templates/common/error-prevention.md +0 -267
  379. package/dist/templates/common/karpathy-baseline.md +0 -83
  380. package/dist/templates/common/output-styles/zh-CN/carmack-mode.md +0 -381
  381. package/dist/templates/common/output-styles/zh-CN/codex-rigor-mode.md +0 -114
  382. package/dist/templates/common/output-styles/zh-CN/dhh-mode.md +0 -265
  383. package/dist/templates/common/output-styles/zh-CN/evan-you-mode.md +0 -539
  384. package/dist/templates/common/output-styles/zh-CN/jobs-mode.md +0 -369
  385. package/dist/templates/common/output-styles/zh-CN/linus-mode.md +0 -135
  386. package/dist/templates/common/output-styles/zh-CN/uncle-bob-mode.md +0 -221
  387. package/dist/templates/common/workflow/continuousDelivery/en/continuous-delivery.md +0 -628
  388. package/dist/templates/common/workflow/continuousDelivery/zh-CN/continuous-delivery.md +0 -628
  389. package/dist/templates/common/workflow/essential/en/agents/ccjk-config-agent.md +0 -187
  390. package/dist/templates/common/workflow/essential/en/agents/ccjk-mcp-agent.md +0 -191
  391. package/dist/templates/common/workflow/essential/en/agents/ccjk-skill-agent.md +0 -249
  392. package/dist/templates/common/workflow/essential/en/agents/ccjk-workflow-agent.md +0 -277
  393. package/dist/templates/common/workflow/essential/en/agents/get-current-datetime.md +0 -29
  394. package/dist/templates/common/workflow/essential/en/agents/init-architect.md +0 -115
  395. package/dist/templates/common/workflow/essential/en/agents/ui-ux-designer.md +0 -91
  396. package/dist/templates/common/workflow/essential/en/feat.md +0 -92
  397. package/dist/templates/common/workflow/essential/en/goal.md +0 -147
  398. package/dist/templates/common/workflow/essential/en/init-project.md +0 -53
  399. package/dist/templates/common/workflow/essential/zh-CN/agents/get-current-datetime.md +0 -29
  400. package/dist/templates/common/workflow/essential/zh-CN/agents/init-architect.md +0 -115
  401. package/dist/templates/common/workflow/essential/zh-CN/agents/ui-ux-designer.md +0 -91
  402. package/dist/templates/common/workflow/essential/zh-CN/feat.md +0 -315
  403. package/dist/templates/common/workflow/essential/zh-CN/goal.md +0 -146
  404. package/dist/templates/common/workflow/essential/zh-CN/init-project.md +0 -53
  405. package/dist/templates/common/workflow/git/en/git-cleanBranches.md +0 -102
  406. package/dist/templates/common/workflow/git/en/git-commit.md +0 -205
  407. package/dist/templates/common/workflow/git/en/git-rollback.md +0 -90
  408. package/dist/templates/common/workflow/git/en/git-worktree.md +0 -276
  409. package/dist/templates/common/workflow/git/zh-CN/git-cleanBranches.md +0 -102
  410. package/dist/templates/common/workflow/git/zh-CN/git-commit.md +0 -205
  411. package/dist/templates/common/workflow/git/zh-CN/git-rollback.md +0 -90
  412. package/dist/templates/common/workflow/git/zh-CN/git-worktree.md +0 -276
  413. package/dist/templates/common/workflow/interview/en/interview.md +0 -67
  414. package/dist/templates/common/workflow/interview/zh-CN/interview.md +0 -67
  415. package/dist/templates/common/workflow/linearMethod/en/linear-method.md +0 -651
  416. package/dist/templates/common/workflow/linearMethod/zh-CN/linear-method.md +0 -752
  417. package/dist/templates/common/workflow/refactoringMaster/en/refactoring-master.md +0 -516
  418. package/dist/templates/common/workflow/refactoringMaster/zh-CN/refactoring-master.md +0 -812
  419. package/dist/templates/common/workflow/sixStep/en/workflow.md +0 -83
  420. package/dist/templates/common/workflow/sixStep/zh-CN/workflow.md +0 -359
  421. package/dist/templates/common/workflow/specFirstTDD/en/spec-first-tdd.md +0 -364
  422. package/dist/templates/common/workflow/specFirstTDD/zh-CN/spec-first-tdd.md +0 -366
  423. package/dist/templates/hooks/README.md +0 -212
  424. package/dist/templates/hooks/git-workflow-hooks.md +0 -551
  425. package/dist/templates/hooks/post-test/coverage.json +0 -21
  426. package/dist/templates/hooks/post-test/summary.json +0 -21
  427. package/dist/templates/hooks/post-test-coverage.md +0 -434
  428. package/dist/templates/hooks/pre-commit/eslint.json +0 -22
  429. package/dist/templates/hooks/pre-commit/prettier.json +0 -22
  430. package/dist/templates/hooks/pre-commit-black.md +0 -274
  431. package/dist/templates/hooks/pre-commit-eslint.md +0 -153
  432. package/dist/templates/hooks/pre-commit-gofmt.md +0 -284
  433. package/dist/templates/hooks/pre-commit-prettier.md +0 -212
  434. package/dist/templates/hooks/pre-commit-type-check.md +0 -377
  435. package/dist/templates/skills/ccjk-init.md +0 -154
  436. package/dist/templates/skills/ccjk-mcp-setup.md +0 -205
  437. package/dist/templates/skills/ccjk-troubleshoot.md +0 -228
  438. package/dist/templates/skills/django-patterns.md +0 -1016
  439. package/dist/templates/skills/git-workflow.md +0 -748
  440. package/dist/templates/skills/go-idioms.md +0 -963
  441. package/dist/templates/skills/index.json +0 -132
  442. package/dist/templates/skills/nextjs-optimization.md +0 -694
  443. package/dist/templates/skills/python-pep8.md +0 -852
  444. package/dist/templates/skills/react-patterns.md +0 -686
  445. package/dist/templates/skills/rust-patterns.md +0 -1057
  446. package/dist/templates/skills/security-best-practices.md +0 -1413
  447. package/dist/templates/skills/testing-best-practices.md +0 -1315
  448. package/dist/templates/skills/ts-best-practices.md +0 -354
  449. package/templates/agents/README.md +0 -78
  450. package/templates/agents/fullstack-developer.json +0 -70
  451. package/templates/agents/go-expert.json +0 -69
  452. package/templates/agents/index.json +0 -64
  453. package/templates/agents/python-expert.json +0 -69
  454. package/templates/agents/react-specialist.json +0 -69
  455. package/templates/agents/testing-automation-expert.json +0 -70
  456. package/templates/agents/typescript-architect.json +0 -69
  457. package/templates/claude-code/common/settings.json +0 -109
  458. package/templates/common/error-prevention.md +0 -267
  459. package/templates/common/karpathy-baseline.md +0 -83
  460. package/templates/common/output-styles/zh-CN/carmack-mode.md +0 -381
  461. package/templates/common/output-styles/zh-CN/codex-rigor-mode.md +0 -114
  462. package/templates/common/output-styles/zh-CN/dhh-mode.md +0 -265
  463. package/templates/common/output-styles/zh-CN/evan-you-mode.md +0 -539
  464. package/templates/common/output-styles/zh-CN/jobs-mode.md +0 -369
  465. package/templates/common/output-styles/zh-CN/linus-mode.md +0 -135
  466. package/templates/common/output-styles/zh-CN/uncle-bob-mode.md +0 -221
  467. package/templates/common/workflow/continuousDelivery/en/continuous-delivery.md +0 -628
  468. package/templates/common/workflow/continuousDelivery/zh-CN/continuous-delivery.md +0 -628
  469. package/templates/common/workflow/essential/en/agents/ccjk-config-agent.md +0 -187
  470. package/templates/common/workflow/essential/en/agents/ccjk-mcp-agent.md +0 -191
  471. package/templates/common/workflow/essential/en/agents/ccjk-skill-agent.md +0 -249
  472. package/templates/common/workflow/essential/en/agents/ccjk-workflow-agent.md +0 -277
  473. package/templates/common/workflow/essential/en/agents/get-current-datetime.md +0 -29
  474. package/templates/common/workflow/essential/en/agents/init-architect.md +0 -115
  475. package/templates/common/workflow/essential/en/agents/ui-ux-designer.md +0 -91
  476. package/templates/common/workflow/essential/en/feat.md +0 -92
  477. package/templates/common/workflow/essential/en/goal.md +0 -147
  478. package/templates/common/workflow/essential/en/init-project.md +0 -53
  479. package/templates/common/workflow/essential/zh-CN/agents/get-current-datetime.md +0 -29
  480. package/templates/common/workflow/essential/zh-CN/agents/init-architect.md +0 -115
  481. package/templates/common/workflow/essential/zh-CN/agents/ui-ux-designer.md +0 -91
  482. package/templates/common/workflow/essential/zh-CN/feat.md +0 -315
  483. package/templates/common/workflow/essential/zh-CN/goal.md +0 -146
  484. package/templates/common/workflow/essential/zh-CN/init-project.md +0 -53
  485. package/templates/common/workflow/git/en/git-cleanBranches.md +0 -102
  486. package/templates/common/workflow/git/en/git-commit.md +0 -205
  487. package/templates/common/workflow/git/en/git-rollback.md +0 -90
  488. package/templates/common/workflow/git/en/git-worktree.md +0 -276
  489. package/templates/common/workflow/git/zh-CN/git-cleanBranches.md +0 -102
  490. package/templates/common/workflow/git/zh-CN/git-commit.md +0 -205
  491. package/templates/common/workflow/git/zh-CN/git-rollback.md +0 -90
  492. package/templates/common/workflow/git/zh-CN/git-worktree.md +0 -276
  493. package/templates/common/workflow/interview/en/interview.md +0 -67
  494. package/templates/common/workflow/interview/zh-CN/interview.md +0 -67
  495. package/templates/common/workflow/linearMethod/en/linear-method.md +0 -651
  496. package/templates/common/workflow/linearMethod/zh-CN/linear-method.md +0 -752
  497. package/templates/common/workflow/refactoringMaster/en/refactoring-master.md +0 -516
  498. package/templates/common/workflow/refactoringMaster/zh-CN/refactoring-master.md +0 -812
  499. package/templates/common/workflow/sixStep/en/workflow.md +0 -83
  500. package/templates/common/workflow/sixStep/zh-CN/workflow.md +0 -359
  501. package/templates/common/workflow/specFirstTDD/en/spec-first-tdd.md +0 -364
  502. package/templates/common/workflow/specFirstTDD/zh-CN/spec-first-tdd.md +0 -366
  503. package/templates/hooks/README.md +0 -212
  504. package/templates/hooks/git-workflow-hooks.md +0 -551
  505. package/templates/hooks/post-test/coverage.json +0 -21
  506. package/templates/hooks/post-test/summary.json +0 -21
  507. package/templates/hooks/post-test-coverage.md +0 -434
  508. package/templates/hooks/pre-commit/eslint.json +0 -22
  509. package/templates/hooks/pre-commit/prettier.json +0 -22
  510. package/templates/hooks/pre-commit-black.md +0 -274
  511. package/templates/hooks/pre-commit-eslint.md +0 -153
  512. package/templates/hooks/pre-commit-gofmt.md +0 -284
  513. package/templates/hooks/pre-commit-prettier.md +0 -212
  514. package/templates/hooks/pre-commit-type-check.md +0 -377
  515. package/templates/skills/basic.hbs +0 -72
  516. package/templates/skills/ccjk-init.md +0 -154
  517. package/templates/skills/ccjk-mcp-setup.md +0 -205
  518. package/templates/skills/ccjk-troubleshoot.md +0 -228
  519. package/templates/skills/code-refactor.hbs +0 -133
  520. package/templates/skills/code-review.hbs +0 -141
  521. package/templates/skills/django-patterns.md +0 -1016
  522. package/templates/skills/git-workflow.md +0 -748
  523. package/templates/skills/go-idioms.md +0 -963
  524. package/templates/skills/index.json +0 -132
  525. package/templates/skills/nextjs-optimization.md +0 -694
  526. package/templates/skills/python-pep8.md +0 -852
  527. package/templates/skills/react-patterns.md +0 -686
  528. package/templates/skills/rust-patterns.md +0 -1057
  529. package/templates/skills/security-best-practices.md +0 -1413
  530. package/templates/skills/testing-best-practices.md +0 -1315
  531. package/templates/skills/ts-best-practices.md +0 -354
  532. package/templates/skills/type-fix.hbs +0 -132
@@ -1,3863 +0,0 @@
1
- import os__default from 'node:os';
2
- import path__default from 'node:path';
3
- import fs__default from 'node:fs';
4
- import { randomUUID } from 'node:crypto';
5
- import { c as commonjsGlobal, g as getDefaultExportFromCjs } from '../shared/ccjk.BAGoDD49.mjs';
6
- import require$$0 from 'fs';
7
- import sysPath from 'path';
8
- import require$$0$1 from 'child_process';
9
- import require$$0$2 from 'os';
10
- import require$$4 from 'util';
11
- import require$$5 from 'assert';
12
- import require$$2 from 'events';
13
- import require$$0$4 from 'buffer';
14
- import require$$0$3 from 'stream';
15
- import { m as moveFile } from '../shared/ccjk.Bx_rmYfN.mjs';
16
- import { c as commonjsRequire } from '../shared/ccjk.COweQ1RR.mjs';
17
- import 'node:process';
18
-
19
- var xdgTrashdir$1 = {exports: {}};
20
-
21
- var df$1 = {exports: {}};
22
-
23
- var execa = {exports: {}};
24
-
25
- var crossSpawn = {exports: {}};
26
-
27
- var windows;
28
- var hasRequiredWindows;
29
-
30
- function requireWindows () {
31
- if (hasRequiredWindows) return windows;
32
- hasRequiredWindows = 1;
33
- windows = isexe;
34
- isexe.sync = sync;
35
-
36
- var fs = require$$0;
37
-
38
- function checkPathExt (path, options) {
39
- var pathext = options.pathExt !== undefined ?
40
- options.pathExt : process.env.PATHEXT;
41
-
42
- if (!pathext) {
43
- return true
44
- }
45
-
46
- pathext = pathext.split(';');
47
- if (pathext.indexOf('') !== -1) {
48
- return true
49
- }
50
- for (var i = 0; i < pathext.length; i++) {
51
- var p = pathext[i].toLowerCase();
52
- if (p && path.substr(-p.length).toLowerCase() === p) {
53
- return true
54
- }
55
- }
56
- return false
57
- }
58
-
59
- function checkStat (stat, path, options) {
60
- if (!stat.isSymbolicLink() && !stat.isFile()) {
61
- return false
62
- }
63
- return checkPathExt(path, options)
64
- }
65
-
66
- function isexe (path, options, cb) {
67
- fs.stat(path, function (er, stat) {
68
- cb(er, er ? false : checkStat(stat, path, options));
69
- });
70
- }
71
-
72
- function sync (path, options) {
73
- return checkStat(fs.statSync(path), path, options)
74
- }
75
- return windows;
76
- }
77
-
78
- var mode;
79
- var hasRequiredMode;
80
-
81
- function requireMode () {
82
- if (hasRequiredMode) return mode;
83
- hasRequiredMode = 1;
84
- mode = isexe;
85
- isexe.sync = sync;
86
-
87
- var fs = require$$0;
88
-
89
- function isexe (path, options, cb) {
90
- fs.stat(path, function (er, stat) {
91
- cb(er, er ? false : checkStat(stat, options));
92
- });
93
- }
94
-
95
- function sync (path, options) {
96
- return checkStat(fs.statSync(path), options)
97
- }
98
-
99
- function checkStat (stat, options) {
100
- return stat.isFile() && checkMode(stat, options)
101
- }
102
-
103
- function checkMode (stat, options) {
104
- var mod = stat.mode;
105
- var uid = stat.uid;
106
- var gid = stat.gid;
107
-
108
- var myUid = options.uid !== undefined ?
109
- options.uid : process.getuid && process.getuid();
110
- var myGid = options.gid !== undefined ?
111
- options.gid : process.getgid && process.getgid();
112
-
113
- var u = parseInt('100', 8);
114
- var g = parseInt('010', 8);
115
- var o = parseInt('001', 8);
116
- var ug = u | g;
117
-
118
- var ret = (mod & o) ||
119
- (mod & g) && gid === myGid ||
120
- (mod & u) && uid === myUid ||
121
- (mod & ug) && myUid === 0;
122
-
123
- return ret
124
- }
125
- return mode;
126
- }
127
-
128
- var isexe_1;
129
- var hasRequiredIsexe;
130
-
131
- function requireIsexe () {
132
- if (hasRequiredIsexe) return isexe_1;
133
- hasRequiredIsexe = 1;
134
- var core;
135
- if (process.platform === 'win32' || commonjsGlobal.TESTING_WINDOWS) {
136
- core = requireWindows();
137
- } else {
138
- core = requireMode();
139
- }
140
-
141
- isexe_1 = isexe;
142
- isexe.sync = sync;
143
-
144
- function isexe (path, options, cb) {
145
- if (typeof options === 'function') {
146
- cb = options;
147
- options = {};
148
- }
149
-
150
- if (!cb) {
151
- if (typeof Promise !== 'function') {
152
- throw new TypeError('callback not provided')
153
- }
154
-
155
- return new Promise(function (resolve, reject) {
156
- isexe(path, options || {}, function (er, is) {
157
- if (er) {
158
- reject(er);
159
- } else {
160
- resolve(is);
161
- }
162
- });
163
- })
164
- }
165
-
166
- core(path, options || {}, function (er, is) {
167
- // ignore EACCES because that just means we aren't allowed to run it
168
- if (er) {
169
- if (er.code === 'EACCES' || options && options.ignoreErrors) {
170
- er = null;
171
- is = false;
172
- }
173
- }
174
- cb(er, is);
175
- });
176
- }
177
-
178
- function sync (path, options) {
179
- // my kingdom for a filtered catch
180
- try {
181
- return core.sync(path, options || {})
182
- } catch (er) {
183
- if (options && options.ignoreErrors || er.code === 'EACCES') {
184
- return false
185
- } else {
186
- throw er
187
- }
188
- }
189
- }
190
- return isexe_1;
191
- }
192
-
193
- var which_1;
194
- var hasRequiredWhich;
195
-
196
- function requireWhich () {
197
- if (hasRequiredWhich) return which_1;
198
- hasRequiredWhich = 1;
199
- const isWindows = process.platform === 'win32' ||
200
- process.env.OSTYPE === 'cygwin' ||
201
- process.env.OSTYPE === 'msys';
202
-
203
- const path = sysPath;
204
- const COLON = isWindows ? ';' : ':';
205
- const isexe = requireIsexe();
206
-
207
- const getNotFoundError = (cmd) =>
208
- Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' });
209
-
210
- const getPathInfo = (cmd, opt) => {
211
- const colon = opt.colon || COLON;
212
-
213
- // If it has a slash, then we don't bother searching the pathenv.
214
- // just check the file itself, and that's it.
215
- const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? ['']
216
- : (
217
- [
218
- // windows always checks the cwd first
219
- ...(isWindows ? [process.cwd()] : []),
220
- ...(opt.path || process.env.PATH ||
221
- /* istanbul ignore next: very unusual */ '').split(colon),
222
- ]
223
- );
224
- const pathExtExe = isWindows
225
- ? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM'
226
- : '';
227
- const pathExt = isWindows ? pathExtExe.split(colon) : [''];
228
-
229
- if (isWindows) {
230
- if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
231
- pathExt.unshift('');
232
- }
233
-
234
- return {
235
- pathEnv,
236
- pathExt,
237
- pathExtExe,
238
- }
239
- };
240
-
241
- const which = (cmd, opt, cb) => {
242
- if (typeof opt === 'function') {
243
- cb = opt;
244
- opt = {};
245
- }
246
- if (!opt)
247
- opt = {};
248
-
249
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
250
- const found = [];
251
-
252
- const step = i => new Promise((resolve, reject) => {
253
- if (i === pathEnv.length)
254
- return opt.all && found.length ? resolve(found)
255
- : reject(getNotFoundError(cmd))
256
-
257
- const ppRaw = pathEnv[i];
258
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
259
-
260
- const pCmd = path.join(pathPart, cmd);
261
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
262
- : pCmd;
263
-
264
- resolve(subStep(p, i, 0));
265
- });
266
-
267
- const subStep = (p, i, ii) => new Promise((resolve, reject) => {
268
- if (ii === pathExt.length)
269
- return resolve(step(i + 1))
270
- const ext = pathExt[ii];
271
- isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
272
- if (!er && is) {
273
- if (opt.all)
274
- found.push(p + ext);
275
- else
276
- return resolve(p + ext)
277
- }
278
- return resolve(subStep(p, i, ii + 1))
279
- });
280
- });
281
-
282
- return cb ? step(0).then(res => cb(null, res), cb) : step(0)
283
- };
284
-
285
- const whichSync = (cmd, opt) => {
286
- opt = opt || {};
287
-
288
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
289
- const found = [];
290
-
291
- for (let i = 0; i < pathEnv.length; i ++) {
292
- const ppRaw = pathEnv[i];
293
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
294
-
295
- const pCmd = path.join(pathPart, cmd);
296
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
297
- : pCmd;
298
-
299
- for (let j = 0; j < pathExt.length; j ++) {
300
- const cur = p + pathExt[j];
301
- try {
302
- const is = isexe.sync(cur, { pathExt: pathExtExe });
303
- if (is) {
304
- if (opt.all)
305
- found.push(cur);
306
- else
307
- return cur
308
- }
309
- } catch (ex) {}
310
- }
311
- }
312
-
313
- if (opt.all && found.length)
314
- return found
315
-
316
- if (opt.nothrow)
317
- return null
318
-
319
- throw getNotFoundError(cmd)
320
- };
321
-
322
- which_1 = which;
323
- which.sync = whichSync;
324
- return which_1;
325
- }
326
-
327
- var pathKey = {exports: {}};
328
-
329
- var hasRequiredPathKey;
330
-
331
- function requirePathKey () {
332
- if (hasRequiredPathKey) return pathKey.exports;
333
- hasRequiredPathKey = 1;
334
-
335
- const pathKey$1 = (options = {}) => {
336
- const environment = options.env || process.env;
337
- const platform = options.platform || process.platform;
338
-
339
- if (platform !== 'win32') {
340
- return 'PATH';
341
- }
342
-
343
- return Object.keys(environment).reverse().find(key => key.toUpperCase() === 'PATH') || 'Path';
344
- };
345
-
346
- pathKey.exports = pathKey$1;
347
- // TODO: Remove this for the next major release
348
- pathKey.exports.default = pathKey$1;
349
- return pathKey.exports;
350
- }
351
-
352
- var resolveCommand_1;
353
- var hasRequiredResolveCommand;
354
-
355
- function requireResolveCommand () {
356
- if (hasRequiredResolveCommand) return resolveCommand_1;
357
- hasRequiredResolveCommand = 1;
358
-
359
- const path = sysPath;
360
- const which = requireWhich();
361
- const getPathKey = requirePathKey();
362
-
363
- function resolveCommandAttempt(parsed, withoutPathExt) {
364
- const env = parsed.options.env || process.env;
365
- const cwd = process.cwd();
366
- const hasCustomCwd = parsed.options.cwd != null;
367
- // Worker threads do not have process.chdir()
368
- const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled;
369
-
370
- // If a custom `cwd` was specified, we need to change the process cwd
371
- // because `which` will do stat calls but does not support a custom cwd
372
- if (shouldSwitchCwd) {
373
- try {
374
- process.chdir(parsed.options.cwd);
375
- } catch (err) {
376
- /* Empty */
377
- }
378
- }
379
-
380
- let resolved;
381
-
382
- try {
383
- resolved = which.sync(parsed.command, {
384
- path: env[getPathKey({ env })],
385
- pathExt: withoutPathExt ? path.delimiter : undefined,
386
- });
387
- } catch (e) {
388
- /* Empty */
389
- } finally {
390
- if (shouldSwitchCwd) {
391
- process.chdir(cwd);
392
- }
393
- }
394
-
395
- // If we successfully resolved, ensure that an absolute path is returned
396
- // Note that when a custom `cwd` was used, we need to resolve to an absolute path based on it
397
- if (resolved) {
398
- resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : '', resolved);
399
- }
400
-
401
- return resolved;
402
- }
403
-
404
- function resolveCommand(parsed) {
405
- return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
406
- }
407
-
408
- resolveCommand_1 = resolveCommand;
409
- return resolveCommand_1;
410
- }
411
-
412
- var _escape = {};
413
-
414
- var hasRequired_escape;
415
-
416
- function require_escape () {
417
- if (hasRequired_escape) return _escape;
418
- hasRequired_escape = 1;
419
-
420
- // See http://www.robvanderwoude.com/escapechars.php
421
- const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
422
-
423
- function escapeCommand(arg) {
424
- // Escape meta chars
425
- arg = arg.replace(metaCharsRegExp, '^$1');
426
-
427
- return arg;
428
- }
429
-
430
- function escapeArgument(arg, doubleEscapeMetaChars) {
431
- // Convert to string
432
- arg = `${arg}`;
433
-
434
- // Algorithm below is based on https://qntm.org/cmd
435
- // It's slightly altered to disable JS backtracking to avoid hanging on specially crafted input
436
- // Please see https://github.com/moxystudio/node-cross-spawn/pull/160 for more information
437
-
438
- // Sequence of backslashes followed by a double quote:
439
- // double up all the backslashes and escape the double quote
440
- arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
441
-
442
- // Sequence of backslashes followed by the end of the string
443
- // (which will become a double quote later):
444
- // double up all the backslashes
445
- arg = arg.replace(/(?=(\\+?)?)\1$/, '$1$1');
446
-
447
- // All other backslashes occur literally
448
-
449
- // Quote the whole thing:
450
- arg = `"${arg}"`;
451
-
452
- // Escape meta chars
453
- arg = arg.replace(metaCharsRegExp, '^$1');
454
-
455
- // Double escape meta chars if necessary
456
- if (doubleEscapeMetaChars) {
457
- arg = arg.replace(metaCharsRegExp, '^$1');
458
- }
459
-
460
- return arg;
461
- }
462
-
463
- _escape.command = escapeCommand;
464
- _escape.argument = escapeArgument;
465
- return _escape;
466
- }
467
-
468
- var shebangRegex;
469
- var hasRequiredShebangRegex;
470
-
471
- function requireShebangRegex () {
472
- if (hasRequiredShebangRegex) return shebangRegex;
473
- hasRequiredShebangRegex = 1;
474
- shebangRegex = /^#!(.*)/;
475
- return shebangRegex;
476
- }
477
-
478
- var shebangCommand;
479
- var hasRequiredShebangCommand;
480
-
481
- function requireShebangCommand () {
482
- if (hasRequiredShebangCommand) return shebangCommand;
483
- hasRequiredShebangCommand = 1;
484
- const shebangRegex = requireShebangRegex();
485
-
486
- shebangCommand = (string = '') => {
487
- const match = string.match(shebangRegex);
488
-
489
- if (!match) {
490
- return null;
491
- }
492
-
493
- const [path, argument] = match[0].replace(/#! ?/, '').split(' ');
494
- const binary = path.split('/').pop();
495
-
496
- if (binary === 'env') {
497
- return argument;
498
- }
499
-
500
- return argument ? `${binary} ${argument}` : binary;
501
- };
502
- return shebangCommand;
503
- }
504
-
505
- var readShebang_1;
506
- var hasRequiredReadShebang;
507
-
508
- function requireReadShebang () {
509
- if (hasRequiredReadShebang) return readShebang_1;
510
- hasRequiredReadShebang = 1;
511
-
512
- const fs = require$$0;
513
- const shebangCommand = requireShebangCommand();
514
-
515
- function readShebang(command) {
516
- // Read the first 150 bytes from the file
517
- const size = 150;
518
- const buffer = Buffer.alloc(size);
519
-
520
- let fd;
521
-
522
- try {
523
- fd = fs.openSync(command, 'r');
524
- fs.readSync(fd, buffer, 0, size, 0);
525
- fs.closeSync(fd);
526
- } catch (e) { /* Empty */ }
527
-
528
- // Attempt to extract shebang (null is returned if not a shebang)
529
- return shebangCommand(buffer.toString());
530
- }
531
-
532
- readShebang_1 = readShebang;
533
- return readShebang_1;
534
- }
535
-
536
- var parse_1;
537
- var hasRequiredParse;
538
-
539
- function requireParse () {
540
- if (hasRequiredParse) return parse_1;
541
- hasRequiredParse = 1;
542
-
543
- const path = sysPath;
544
- const resolveCommand = requireResolveCommand();
545
- const escape = require_escape();
546
- const readShebang = requireReadShebang();
547
-
548
- const isWin = process.platform === 'win32';
549
- const isExecutableRegExp = /\.(?:com|exe)$/i;
550
- const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
551
-
552
- function detectShebang(parsed) {
553
- parsed.file = resolveCommand(parsed);
554
-
555
- const shebang = parsed.file && readShebang(parsed.file);
556
-
557
- if (shebang) {
558
- parsed.args.unshift(parsed.file);
559
- parsed.command = shebang;
560
-
561
- return resolveCommand(parsed);
562
- }
563
-
564
- return parsed.file;
565
- }
566
-
567
- function parseNonShell(parsed) {
568
- if (!isWin) {
569
- return parsed;
570
- }
571
-
572
- // Detect & add support for shebangs
573
- const commandFile = detectShebang(parsed);
574
-
575
- // We don't need a shell if the command filename is an executable
576
- const needsShell = !isExecutableRegExp.test(commandFile);
577
-
578
- // If a shell is required, use cmd.exe and take care of escaping everything correctly
579
- // Note that `forceShell` is an hidden option used only in tests
580
- if (parsed.options.forceShell || needsShell) {
581
- // Need to double escape meta chars if the command is a cmd-shim located in `node_modules/.bin/`
582
- // The cmd-shim simply calls execute the package bin file with NodeJS, proxying any argument
583
- // Because the escape of metachars with ^ gets interpreted when the cmd.exe is first called,
584
- // we need to double escape them
585
- const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
586
-
587
- // Normalize posix paths into OS compatible paths (e.g.: foo/bar -> foo\bar)
588
- // This is necessary otherwise it will always fail with ENOENT in those cases
589
- parsed.command = path.normalize(parsed.command);
590
-
591
- // Escape command & arguments
592
- parsed.command = escape.command(parsed.command);
593
- parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
594
-
595
- const shellCommand = [parsed.command].concat(parsed.args).join(' ');
596
-
597
- parsed.args = ['/d', '/s', '/c', `"${shellCommand}"`];
598
- parsed.command = process.env.comspec || 'cmd.exe';
599
- parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped
600
- }
601
-
602
- return parsed;
603
- }
604
-
605
- function parse(command, args, options) {
606
- // Normalize arguments, similar to nodejs
607
- if (args && !Array.isArray(args)) {
608
- options = args;
609
- args = null;
610
- }
611
-
612
- args = args ? args.slice(0) : []; // Clone array to avoid changing the original
613
- options = Object.assign({}, options); // Clone object to avoid changing the original
614
-
615
- // Build our parsed object
616
- const parsed = {
617
- command,
618
- args,
619
- options,
620
- file: undefined,
621
- original: {
622
- command,
623
- args,
624
- },
625
- };
626
-
627
- // Delegate further parsing to shell or non-shell
628
- return options.shell ? parsed : parseNonShell(parsed);
629
- }
630
-
631
- parse_1 = parse;
632
- return parse_1;
633
- }
634
-
635
- var enoent;
636
- var hasRequiredEnoent;
637
-
638
- function requireEnoent () {
639
- if (hasRequiredEnoent) return enoent;
640
- hasRequiredEnoent = 1;
641
-
642
- const isWin = process.platform === 'win32';
643
-
644
- function notFoundError(original, syscall) {
645
- return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
646
- code: 'ENOENT',
647
- errno: 'ENOENT',
648
- syscall: `${syscall} ${original.command}`,
649
- path: original.command,
650
- spawnargs: original.args,
651
- });
652
- }
653
-
654
- function hookChildProcess(cp, parsed) {
655
- if (!isWin) {
656
- return;
657
- }
658
-
659
- const originalEmit = cp.emit;
660
-
661
- cp.emit = function (name, arg1) {
662
- // If emitting "exit" event and exit code is 1, we need to check if
663
- // the command exists and emit an "error" instead
664
- // See https://github.com/IndigoUnited/node-cross-spawn/issues/16
665
- if (name === 'exit') {
666
- const err = verifyENOENT(arg1, parsed);
667
-
668
- if (err) {
669
- return originalEmit.call(cp, 'error', err);
670
- }
671
- }
672
-
673
- return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params
674
- };
675
- }
676
-
677
- function verifyENOENT(status, parsed) {
678
- if (isWin && status === 1 && !parsed.file) {
679
- return notFoundError(parsed.original, 'spawn');
680
- }
681
-
682
- return null;
683
- }
684
-
685
- function verifyENOENTSync(status, parsed) {
686
- if (isWin && status === 1 && !parsed.file) {
687
- return notFoundError(parsed.original, 'spawnSync');
688
- }
689
-
690
- return null;
691
- }
692
-
693
- enoent = {
694
- hookChildProcess,
695
- verifyENOENT,
696
- verifyENOENTSync,
697
- notFoundError,
698
- };
699
- return enoent;
700
- }
701
-
702
- var hasRequiredCrossSpawn;
703
-
704
- function requireCrossSpawn () {
705
- if (hasRequiredCrossSpawn) return crossSpawn.exports;
706
- hasRequiredCrossSpawn = 1;
707
-
708
- const cp = require$$0$1;
709
- const parse = requireParse();
710
- const enoent = requireEnoent();
711
-
712
- function spawn(command, args, options) {
713
- // Parse the arguments
714
- const parsed = parse(command, args, options);
715
-
716
- // Spawn the child process
717
- const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
718
-
719
- // Hook into child process "exit" event to emit an error if the command
720
- // does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
721
- enoent.hookChildProcess(spawned, parsed);
722
-
723
- return spawned;
724
- }
725
-
726
- function spawnSync(command, args, options) {
727
- // Parse the arguments
728
- const parsed = parse(command, args, options);
729
-
730
- // Spawn the child process
731
- const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
732
-
733
- // Analyze if the command does not exist, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
734
- result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
735
-
736
- return result;
737
- }
738
-
739
- crossSpawn.exports = spawn;
740
- crossSpawn.exports.spawn = spawn;
741
- crossSpawn.exports.sync = spawnSync;
742
-
743
- crossSpawn.exports._parse = parse;
744
- crossSpawn.exports._enoent = enoent;
745
- return crossSpawn.exports;
746
- }
747
-
748
- var stripFinalNewline;
749
- var hasRequiredStripFinalNewline;
750
-
751
- function requireStripFinalNewline () {
752
- if (hasRequiredStripFinalNewline) return stripFinalNewline;
753
- hasRequiredStripFinalNewline = 1;
754
-
755
- stripFinalNewline = input => {
756
- const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
757
- const CR = typeof input === 'string' ? '\r' : '\r'.charCodeAt();
758
-
759
- if (input[input.length - 1] === LF) {
760
- input = input.slice(0, input.length - 1);
761
- }
762
-
763
- if (input[input.length - 1] === CR) {
764
- input = input.slice(0, input.length - 1);
765
- }
766
-
767
- return input;
768
- };
769
- return stripFinalNewline;
770
- }
771
-
772
- var npmRunPath = {exports: {}};
773
-
774
- npmRunPath.exports;
775
-
776
- var hasRequiredNpmRunPath;
777
-
778
- function requireNpmRunPath () {
779
- if (hasRequiredNpmRunPath) return npmRunPath.exports;
780
- hasRequiredNpmRunPath = 1;
781
- (function (module) {
782
- const path = sysPath;
783
- const pathKey = requirePathKey();
784
-
785
- const npmRunPath = options => {
786
- options = {
787
- cwd: process.cwd(),
788
- path: process.env[pathKey()],
789
- ...options
790
- };
791
-
792
- let previous;
793
- let cwdPath = path.resolve(options.cwd);
794
- const result = [];
795
-
796
- while (previous !== cwdPath) {
797
- result.push(path.join(cwdPath, 'node_modules/.bin'));
798
- previous = cwdPath;
799
- cwdPath = path.resolve(cwdPath, '..');
800
- }
801
-
802
- // Ensure the running `node` binary is used
803
- result.push(path.dirname(process.execPath));
804
-
805
- return result.concat(options.path).join(path.delimiter);
806
- };
807
-
808
- module.exports = npmRunPath;
809
- // TODO: Remove this for the next major release
810
- module.exports.default = npmRunPath;
811
-
812
- module.exports.env = options => {
813
- options = {
814
- env: process.env,
815
- ...options
816
- };
817
-
818
- const env = {...options.env};
819
- const path = pathKey({env});
820
-
821
- options.path = env[path];
822
- env[path] = module.exports(options);
823
-
824
- return env;
825
- };
826
- } (npmRunPath));
827
- return npmRunPath.exports;
828
- }
829
-
830
- var onetime = {exports: {}};
831
-
832
- var mimicFn = {exports: {}};
833
-
834
- var hasRequiredMimicFn;
835
-
836
- function requireMimicFn () {
837
- if (hasRequiredMimicFn) return mimicFn.exports;
838
- hasRequiredMimicFn = 1;
839
-
840
- const mimicFn$1 = (to, from) => {
841
- for (const prop of Reflect.ownKeys(from)) {
842
- Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop));
843
- }
844
-
845
- return to;
846
- };
847
-
848
- mimicFn.exports = mimicFn$1;
849
- // TODO: Remove this for the next major release
850
- mimicFn.exports.default = mimicFn$1;
851
- return mimicFn.exports;
852
- }
853
-
854
- var hasRequiredOnetime;
855
-
856
- function requireOnetime () {
857
- if (hasRequiredOnetime) return onetime.exports;
858
- hasRequiredOnetime = 1;
859
- const mimicFn = requireMimicFn();
860
-
861
- const calledFunctions = new WeakMap();
862
-
863
- const onetime$1 = (function_, options = {}) => {
864
- if (typeof function_ !== 'function') {
865
- throw new TypeError('Expected a function');
866
- }
867
-
868
- let returnValue;
869
- let callCount = 0;
870
- const functionName = function_.displayName || function_.name || '<anonymous>';
871
-
872
- const onetime = function (...arguments_) {
873
- calledFunctions.set(onetime, ++callCount);
874
-
875
- if (callCount === 1) {
876
- returnValue = function_.apply(this, arguments_);
877
- function_ = null;
878
- } else if (options.throw === true) {
879
- throw new Error(`Function \`${functionName}\` can only be called once`);
880
- }
881
-
882
- return returnValue;
883
- };
884
-
885
- mimicFn(onetime, function_);
886
- calledFunctions.set(onetime, callCount);
887
-
888
- return onetime;
889
- };
890
-
891
- onetime.exports = onetime$1;
892
- // TODO: Remove this for the next major release
893
- onetime.exports.default = onetime$1;
894
-
895
- onetime.exports.callCount = function_ => {
896
- if (!calledFunctions.has(function_)) {
897
- throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
898
- }
899
-
900
- return calledFunctions.get(function_);
901
- };
902
- return onetime.exports;
903
- }
904
-
905
- var error;
906
- var hasRequiredError;
907
-
908
- function requireError () {
909
- if (hasRequiredError) return error;
910
- hasRequiredError = 1;
911
- const os = require$$0$2;
912
- const util = require$$4;
913
-
914
- const getCode = (error, code) => {
915
- if (error && error.code) {
916
- return [error.code, os.constants.errno[error.code]];
917
- }
918
-
919
- if (Number.isInteger(code)) {
920
- return [util.getSystemErrorName(-code), code];
921
- }
922
-
923
- return [];
924
- };
925
-
926
- const getErrorPrefix = ({timedOut, timeout, signal, exitCodeName, exitCode, isCanceled}) => {
927
- if (timedOut) {
928
- return `timed out after ${timeout} milliseconds`;
929
- }
930
-
931
- if (isCanceled) {
932
- return 'was canceled';
933
- }
934
-
935
- if (signal) {
936
- return `was killed with ${signal}`;
937
- }
938
-
939
- if (exitCode !== undefined) {
940
- return `failed with exit code ${exitCode} (${exitCodeName})`;
941
- }
942
-
943
- return 'failed';
944
- };
945
-
946
- const makeError = ({
947
- stdout,
948
- stderr,
949
- all,
950
- error,
951
- signal,
952
- code,
953
- command,
954
- timedOut,
955
- isCanceled,
956
- killed,
957
- parsed: {options: {timeout}}
958
- }) => {
959
- const [exitCodeName, exitCode] = getCode(error, code);
960
-
961
- const prefix = getErrorPrefix({timedOut, timeout, signal, exitCodeName, exitCode, isCanceled});
962
- const message = `Command ${prefix}: ${command}`;
963
-
964
- if (error instanceof Error) {
965
- error.originalMessage = error.message;
966
- error.message = `${message}\n${error.message}`;
967
- } else {
968
- error = new Error(message);
969
- }
970
-
971
- error.command = command;
972
- delete error.code;
973
- error.exitCode = exitCode;
974
- error.exitCodeName = exitCodeName;
975
- error.stdout = stdout;
976
- error.stderr = stderr;
977
-
978
- if (all !== undefined) {
979
- error.all = all;
980
- }
981
-
982
- if ('bufferedData' in error) {
983
- delete error.bufferedData;
984
- }
985
-
986
- error.failed = true;
987
- error.timedOut = Boolean(timedOut);
988
- error.isCanceled = isCanceled;
989
- error.killed = killed && !timedOut;
990
- // `signal` emitted on `spawned.on('exit')` event can be `null`. We normalize
991
- // it to `undefined`
992
- error.signal = signal || undefined;
993
-
994
- return error;
995
- };
996
-
997
- error = makeError;
998
- return error;
999
- }
1000
-
1001
- var stdio = {exports: {}};
1002
-
1003
- var hasRequiredStdio;
1004
-
1005
- function requireStdio () {
1006
- if (hasRequiredStdio) return stdio.exports;
1007
- hasRequiredStdio = 1;
1008
- const aliases = ['stdin', 'stdout', 'stderr'];
1009
-
1010
- const hasAlias = opts => aliases.some(alias => opts[alias] !== undefined);
1011
-
1012
- const normalizeStdio = opts => {
1013
- if (!opts) {
1014
- return;
1015
- }
1016
-
1017
- const {stdio} = opts;
1018
-
1019
- if (stdio === undefined) {
1020
- return aliases.map(alias => opts[alias]);
1021
- }
1022
-
1023
- if (hasAlias(opts)) {
1024
- throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias => `\`${alias}\``).join(', ')}`);
1025
- }
1026
-
1027
- if (typeof stdio === 'string') {
1028
- return stdio;
1029
- }
1030
-
1031
- if (!Array.isArray(stdio)) {
1032
- throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
1033
- }
1034
-
1035
- const length = Math.max(stdio.length, aliases.length);
1036
- return Array.from({length}, (value, index) => stdio[index]);
1037
- };
1038
-
1039
- stdio.exports = normalizeStdio;
1040
-
1041
- // `ipc` is pushed unless it is already present
1042
- stdio.exports.node = opts => {
1043
- const stdio = normalizeStdio(opts);
1044
-
1045
- if (stdio === 'ipc') {
1046
- return 'ipc';
1047
- }
1048
-
1049
- if (stdio === undefined || typeof stdio === 'string') {
1050
- return [stdio, stdio, stdio, 'ipc'];
1051
- }
1052
-
1053
- if (stdio.includes('ipc')) {
1054
- return stdio;
1055
- }
1056
-
1057
- return [...stdio, 'ipc'];
1058
- };
1059
- return stdio.exports;
1060
- }
1061
-
1062
- var signalExit = {exports: {}};
1063
-
1064
- var signals = {exports: {}};
1065
-
1066
- var hasRequiredSignals;
1067
-
1068
- function requireSignals () {
1069
- if (hasRequiredSignals) return signals.exports;
1070
- hasRequiredSignals = 1;
1071
- (function (module) {
1072
- // This is not the set of all possible signals.
1073
- //
1074
- // It IS, however, the set of all signals that trigger
1075
- // an exit on either Linux or BSD systems. Linux is a
1076
- // superset of the signal names supported on BSD, and
1077
- // the unknown signals just fail to register, so we can
1078
- // catch that easily enough.
1079
- //
1080
- // Don't bother with SIGKILL. It's uncatchable, which
1081
- // means that we can't fire any callbacks anyway.
1082
- //
1083
- // If a user does happen to register a handler on a non-
1084
- // fatal signal like SIGWINCH or something, and then
1085
- // exit, it'll end up firing `process.emit('exit')`, so
1086
- // the handler will be fired anyway.
1087
- //
1088
- // SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
1089
- // artificially, inherently leave the process in a
1090
- // state from which it is not safe to try and enter JS
1091
- // listeners.
1092
- module.exports = [
1093
- 'SIGABRT',
1094
- 'SIGALRM',
1095
- 'SIGHUP',
1096
- 'SIGINT',
1097
- 'SIGTERM'
1098
- ];
1099
-
1100
- if (process.platform !== 'win32') {
1101
- module.exports.push(
1102
- 'SIGVTALRM',
1103
- 'SIGXCPU',
1104
- 'SIGXFSZ',
1105
- 'SIGUSR2',
1106
- 'SIGTRAP',
1107
- 'SIGSYS',
1108
- 'SIGQUIT',
1109
- 'SIGIOT'
1110
- // should detect profiler and enable/disable accordingly.
1111
- // see #21
1112
- // 'SIGPROF'
1113
- );
1114
- }
1115
-
1116
- if (process.platform === 'linux') {
1117
- module.exports.push(
1118
- 'SIGIO',
1119
- 'SIGPOLL',
1120
- 'SIGPWR',
1121
- 'SIGSTKFLT',
1122
- 'SIGUNUSED'
1123
- );
1124
- }
1125
- } (signals));
1126
- return signals.exports;
1127
- }
1128
-
1129
- var hasRequiredSignalExit;
1130
-
1131
- function requireSignalExit () {
1132
- if (hasRequiredSignalExit) return signalExit.exports;
1133
- hasRequiredSignalExit = 1;
1134
- // Note: since nyc uses this module to output coverage, any lines
1135
- // that are in the direct sync flow of nyc's outputCoverage are
1136
- // ignored, since we can never get coverage for them.
1137
- // grab a reference to node's real process object right away
1138
- var process = commonjsGlobal.process;
1139
-
1140
- const processOk = function (process) {
1141
- return process &&
1142
- typeof process === 'object' &&
1143
- typeof process.removeListener === 'function' &&
1144
- typeof process.emit === 'function' &&
1145
- typeof process.reallyExit === 'function' &&
1146
- typeof process.listeners === 'function' &&
1147
- typeof process.kill === 'function' &&
1148
- typeof process.pid === 'number' &&
1149
- typeof process.on === 'function'
1150
- };
1151
-
1152
- // some kind of non-node environment, just no-op
1153
- /* istanbul ignore if */
1154
- if (!processOk(process)) {
1155
- signalExit.exports = function () {
1156
- return function () {}
1157
- };
1158
- } else {
1159
- var assert = require$$5;
1160
- var signals = requireSignals();
1161
- var isWin = /^win/i.test(process.platform);
1162
-
1163
- var EE = require$$2;
1164
- /* istanbul ignore if */
1165
- if (typeof EE !== 'function') {
1166
- EE = EE.EventEmitter;
1167
- }
1168
-
1169
- var emitter;
1170
- if (process.__signal_exit_emitter__) {
1171
- emitter = process.__signal_exit_emitter__;
1172
- } else {
1173
- emitter = process.__signal_exit_emitter__ = new EE();
1174
- emitter.count = 0;
1175
- emitter.emitted = {};
1176
- }
1177
-
1178
- // Because this emitter is a global, we have to check to see if a
1179
- // previous version of this library failed to enable infinite listeners.
1180
- // I know what you're about to say. But literally everything about
1181
- // signal-exit is a compromise with evil. Get used to it.
1182
- if (!emitter.infinite) {
1183
- emitter.setMaxListeners(Infinity);
1184
- emitter.infinite = true;
1185
- }
1186
-
1187
- signalExit.exports = function (cb, opts) {
1188
- /* istanbul ignore if */
1189
- if (!processOk(commonjsGlobal.process)) {
1190
- return function () {}
1191
- }
1192
- assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler');
1193
-
1194
- if (loaded === false) {
1195
- load();
1196
- }
1197
-
1198
- var ev = 'exit';
1199
- if (opts && opts.alwaysLast) {
1200
- ev = 'afterexit';
1201
- }
1202
-
1203
- var remove = function () {
1204
- emitter.removeListener(ev, cb);
1205
- if (emitter.listeners('exit').length === 0 &&
1206
- emitter.listeners('afterexit').length === 0) {
1207
- unload();
1208
- }
1209
- };
1210
- emitter.on(ev, cb);
1211
-
1212
- return remove
1213
- };
1214
-
1215
- var unload = function unload () {
1216
- if (!loaded || !processOk(commonjsGlobal.process)) {
1217
- return
1218
- }
1219
- loaded = false;
1220
-
1221
- signals.forEach(function (sig) {
1222
- try {
1223
- process.removeListener(sig, sigListeners[sig]);
1224
- } catch (er) {}
1225
- });
1226
- process.emit = originalProcessEmit;
1227
- process.reallyExit = originalProcessReallyExit;
1228
- emitter.count -= 1;
1229
- };
1230
- signalExit.exports.unload = unload;
1231
-
1232
- var emit = function emit (event, code, signal) {
1233
- /* istanbul ignore if */
1234
- if (emitter.emitted[event]) {
1235
- return
1236
- }
1237
- emitter.emitted[event] = true;
1238
- emitter.emit(event, code, signal);
1239
- };
1240
-
1241
- // { <signal>: <listener fn>, ... }
1242
- var sigListeners = {};
1243
- signals.forEach(function (sig) {
1244
- sigListeners[sig] = function listener () {
1245
- /* istanbul ignore if */
1246
- if (!processOk(commonjsGlobal.process)) {
1247
- return
1248
- }
1249
- // If there are no other listeners, an exit is coming!
1250
- // Simplest way: remove us and then re-send the signal.
1251
- // We know that this will kill the process, so we can
1252
- // safely emit now.
1253
- var listeners = process.listeners(sig);
1254
- if (listeners.length === emitter.count) {
1255
- unload();
1256
- emit('exit', null, sig);
1257
- /* istanbul ignore next */
1258
- emit('afterexit', null, sig);
1259
- /* istanbul ignore next */
1260
- if (isWin && sig === 'SIGHUP') {
1261
- // "SIGHUP" throws an `ENOSYS` error on Windows,
1262
- // so use a supported signal instead
1263
- sig = 'SIGINT';
1264
- }
1265
- /* istanbul ignore next */
1266
- process.kill(process.pid, sig);
1267
- }
1268
- };
1269
- });
1270
-
1271
- signalExit.exports.signals = function () {
1272
- return signals
1273
- };
1274
-
1275
- var loaded = false;
1276
-
1277
- var load = function load () {
1278
- if (loaded || !processOk(commonjsGlobal.process)) {
1279
- return
1280
- }
1281
- loaded = true;
1282
-
1283
- // This is the number of onSignalExit's that are in play.
1284
- // It's important so that we can count the correct number of
1285
- // listeners on signals, and don't wait for the other one to
1286
- // handle it instead of us.
1287
- emitter.count += 1;
1288
-
1289
- signals = signals.filter(function (sig) {
1290
- try {
1291
- process.on(sig, sigListeners[sig]);
1292
- return true
1293
- } catch (er) {
1294
- return false
1295
- }
1296
- });
1297
-
1298
- process.emit = processEmit;
1299
- process.reallyExit = processReallyExit;
1300
- };
1301
- signalExit.exports.load = load;
1302
-
1303
- var originalProcessReallyExit = process.reallyExit;
1304
- var processReallyExit = function processReallyExit (code) {
1305
- /* istanbul ignore if */
1306
- if (!processOk(commonjsGlobal.process)) {
1307
- return
1308
- }
1309
- process.exitCode = code || /* istanbul ignore next */ 0;
1310
- emit('exit', process.exitCode, null);
1311
- /* istanbul ignore next */
1312
- emit('afterexit', process.exitCode, null);
1313
- /* istanbul ignore next */
1314
- originalProcessReallyExit.call(process, process.exitCode);
1315
- };
1316
-
1317
- var originalProcessEmit = process.emit;
1318
- var processEmit = function processEmit (ev, arg) {
1319
- if (ev === 'exit' && processOk(commonjsGlobal.process)) {
1320
- /* istanbul ignore else */
1321
- if (arg !== undefined) {
1322
- process.exitCode = arg;
1323
- }
1324
- var ret = originalProcessEmit.apply(this, arguments);
1325
- /* istanbul ignore next */
1326
- emit('exit', process.exitCode, null);
1327
- /* istanbul ignore next */
1328
- emit('afterexit', process.exitCode, null);
1329
- /* istanbul ignore next */
1330
- return ret
1331
- } else {
1332
- return originalProcessEmit.apply(this, arguments)
1333
- }
1334
- };
1335
- }
1336
- return signalExit.exports;
1337
- }
1338
-
1339
- var pFinally;
1340
- var hasRequiredPFinally;
1341
-
1342
- function requirePFinally () {
1343
- if (hasRequiredPFinally) return pFinally;
1344
- hasRequiredPFinally = 1;
1345
-
1346
- pFinally = async (
1347
- promise,
1348
- onFinally = (() => {})
1349
- ) => {
1350
- let value;
1351
- try {
1352
- value = await promise;
1353
- } catch (error) {
1354
- await onFinally();
1355
- throw error;
1356
- }
1357
-
1358
- await onFinally();
1359
- return value;
1360
- };
1361
- return pFinally;
1362
- }
1363
-
1364
- var kill;
1365
- var hasRequiredKill;
1366
-
1367
- function requireKill () {
1368
- if (hasRequiredKill) return kill;
1369
- hasRequiredKill = 1;
1370
- const os = require$$0$2;
1371
- const onExit = requireSignalExit();
1372
- const pFinally = requirePFinally();
1373
-
1374
- const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;
1375
-
1376
- // Monkey-patches `childProcess.kill()` to add `forceKillAfterTimeout` behavior
1377
- const spawnedKill = (kill, signal = 'SIGTERM', options = {}) => {
1378
- const killResult = kill(signal);
1379
- setKillTimeout(kill, signal, options, killResult);
1380
- return killResult;
1381
- };
1382
-
1383
- const setKillTimeout = (kill, signal, options, killResult) => {
1384
- if (!shouldForceKill(signal, options, killResult)) {
1385
- return;
1386
- }
1387
-
1388
- const timeout = getForceKillAfterTimeout(options);
1389
- setTimeout(() => {
1390
- kill('SIGKILL');
1391
- }, timeout).unref();
1392
- };
1393
-
1394
- const shouldForceKill = (signal, {forceKillAfterTimeout}, killResult) => {
1395
- return isSigterm(signal) && forceKillAfterTimeout !== false && killResult;
1396
- };
1397
-
1398
- const isSigterm = signal => {
1399
- return signal === os.constants.signals.SIGTERM ||
1400
- (typeof signal === 'string' && signal.toUpperCase() === 'SIGTERM');
1401
- };
1402
-
1403
- const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => {
1404
- if (forceKillAfterTimeout === true) {
1405
- return DEFAULT_FORCE_KILL_TIMEOUT;
1406
- }
1407
-
1408
- if (!Number.isInteger(forceKillAfterTimeout) || forceKillAfterTimeout < 0) {
1409
- throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`);
1410
- }
1411
-
1412
- return forceKillAfterTimeout;
1413
- };
1414
-
1415
- // `childProcess.cancel()`
1416
- const spawnedCancel = (spawned, context) => {
1417
- const killResult = spawned.kill();
1418
-
1419
- if (killResult) {
1420
- context.isCanceled = true;
1421
- }
1422
- };
1423
-
1424
- const timeoutKill = (spawned, signal, reject) => {
1425
- spawned.kill(signal);
1426
- reject(Object.assign(new Error('Timed out'), {timedOut: true, signal}));
1427
- };
1428
-
1429
- // `timeout` option handling
1430
- const setupTimeout = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise) => {
1431
- if (timeout === 0 || timeout === undefined) {
1432
- return spawnedPromise;
1433
- }
1434
-
1435
- if (!Number.isInteger(timeout) || timeout < 0) {
1436
- throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
1437
- }
1438
-
1439
- let timeoutId;
1440
- const timeoutPromise = new Promise((resolve, reject) => {
1441
- timeoutId = setTimeout(() => {
1442
- timeoutKill(spawned, killSignal, reject);
1443
- }, timeout);
1444
- });
1445
-
1446
- const safeSpawnedPromise = pFinally(spawnedPromise, () => {
1447
- clearTimeout(timeoutId);
1448
- });
1449
-
1450
- return Promise.race([timeoutPromise, safeSpawnedPromise]);
1451
- };
1452
-
1453
- // `cleanup` option handling
1454
- const setExitHandler = (spawned, {cleanup, detached}, timedPromise) => {
1455
- if (!cleanup || detached) {
1456
- return timedPromise;
1457
- }
1458
-
1459
- const removeExitHandler = onExit(() => {
1460
- spawned.kill();
1461
- });
1462
-
1463
- // TODO: Use native "finally" syntax when targeting Node.js 10
1464
- return pFinally(timedPromise, removeExitHandler);
1465
- };
1466
-
1467
- kill = {
1468
- spawnedKill,
1469
- spawnedCancel,
1470
- setupTimeout,
1471
- setExitHandler
1472
- };
1473
- return kill;
1474
- }
1475
-
1476
- var isStream_1;
1477
- var hasRequiredIsStream;
1478
-
1479
- function requireIsStream () {
1480
- if (hasRequiredIsStream) return isStream_1;
1481
- hasRequiredIsStream = 1;
1482
-
1483
- const isStream = stream =>
1484
- stream !== null &&
1485
- typeof stream === 'object' &&
1486
- typeof stream.pipe === 'function';
1487
-
1488
- isStream.writable = stream =>
1489
- isStream(stream) &&
1490
- stream.writable !== false &&
1491
- typeof stream._write === 'function' &&
1492
- typeof stream._writableState === 'object';
1493
-
1494
- isStream.readable = stream =>
1495
- isStream(stream) &&
1496
- stream.readable !== false &&
1497
- typeof stream._read === 'function' &&
1498
- typeof stream._readableState === 'object';
1499
-
1500
- isStream.duplex = stream =>
1501
- isStream.writable(stream) &&
1502
- isStream.readable(stream);
1503
-
1504
- isStream.transform = stream =>
1505
- isStream.duplex(stream) &&
1506
- typeof stream._transform === 'function';
1507
-
1508
- isStream_1 = isStream;
1509
- return isStream_1;
1510
- }
1511
-
1512
- var getStream = {exports: {}};
1513
-
1514
- var once = {exports: {}};
1515
-
1516
- var wrappy_1;
1517
- var hasRequiredWrappy;
1518
-
1519
- function requireWrappy () {
1520
- if (hasRequiredWrappy) return wrappy_1;
1521
- hasRequiredWrappy = 1;
1522
- // Returns a wrapper function that returns a wrapped callback
1523
- // The wrapper function should do some stuff, and return a
1524
- // presumably different callback function.
1525
- // This makes sure that own properties are retained, so that
1526
- // decorations and such are not lost along the way.
1527
- wrappy_1 = wrappy;
1528
- function wrappy (fn, cb) {
1529
- if (fn && cb) return wrappy(fn)(cb)
1530
-
1531
- if (typeof fn !== 'function')
1532
- throw new TypeError('need wrapper function')
1533
-
1534
- Object.keys(fn).forEach(function (k) {
1535
- wrapper[k] = fn[k];
1536
- });
1537
-
1538
- return wrapper
1539
-
1540
- function wrapper() {
1541
- var args = new Array(arguments.length);
1542
- for (var i = 0; i < args.length; i++) {
1543
- args[i] = arguments[i];
1544
- }
1545
- var ret = fn.apply(this, args);
1546
- var cb = args[args.length-1];
1547
- if (typeof ret === 'function' && ret !== cb) {
1548
- Object.keys(cb).forEach(function (k) {
1549
- ret[k] = cb[k];
1550
- });
1551
- }
1552
- return ret
1553
- }
1554
- }
1555
- return wrappy_1;
1556
- }
1557
-
1558
- var hasRequiredOnce;
1559
-
1560
- function requireOnce () {
1561
- if (hasRequiredOnce) return once.exports;
1562
- hasRequiredOnce = 1;
1563
- var wrappy = requireWrappy();
1564
- once.exports = wrappy(once$1);
1565
- once.exports.strict = wrappy(onceStrict);
1566
-
1567
- once$1.proto = once$1(function () {
1568
- Object.defineProperty(Function.prototype, 'once', {
1569
- value: function () {
1570
- return once$1(this)
1571
- },
1572
- configurable: true
1573
- });
1574
-
1575
- Object.defineProperty(Function.prototype, 'onceStrict', {
1576
- value: function () {
1577
- return onceStrict(this)
1578
- },
1579
- configurable: true
1580
- });
1581
- });
1582
-
1583
- function once$1 (fn) {
1584
- var f = function () {
1585
- if (f.called) return f.value
1586
- f.called = true;
1587
- return f.value = fn.apply(this, arguments)
1588
- };
1589
- f.called = false;
1590
- return f
1591
- }
1592
-
1593
- function onceStrict (fn) {
1594
- var f = function () {
1595
- if (f.called)
1596
- throw new Error(f.onceError)
1597
- f.called = true;
1598
- return f.value = fn.apply(this, arguments)
1599
- };
1600
- var name = fn.name || 'Function wrapped with `once`';
1601
- f.onceError = name + " shouldn't be called more than once";
1602
- f.called = false;
1603
- return f
1604
- }
1605
- return once.exports;
1606
- }
1607
-
1608
- var endOfStream;
1609
- var hasRequiredEndOfStream;
1610
-
1611
- function requireEndOfStream () {
1612
- if (hasRequiredEndOfStream) return endOfStream;
1613
- hasRequiredEndOfStream = 1;
1614
- var once = requireOnce();
1615
-
1616
- var noop = function() {};
1617
-
1618
- var qnt = commonjsGlobal.Bare ? queueMicrotask : process.nextTick.bind(process);
1619
-
1620
- var isRequest = function(stream) {
1621
- return stream.setHeader && typeof stream.abort === 'function';
1622
- };
1623
-
1624
- var isChildProcess = function(stream) {
1625
- return stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3
1626
- };
1627
-
1628
- var eos = function(stream, opts, callback) {
1629
- if (typeof opts === 'function') return eos(stream, null, opts);
1630
- if (!opts) opts = {};
1631
-
1632
- callback = once(callback || noop);
1633
-
1634
- var ws = stream._writableState;
1635
- var rs = stream._readableState;
1636
- var readable = opts.readable || (opts.readable !== false && stream.readable);
1637
- var writable = opts.writable || (opts.writable !== false && stream.writable);
1638
- var cancelled = false;
1639
-
1640
- var onlegacyfinish = function() {
1641
- if (!stream.writable) onfinish();
1642
- };
1643
-
1644
- var onfinish = function() {
1645
- writable = false;
1646
- if (!readable) callback.call(stream);
1647
- };
1648
-
1649
- var onend = function() {
1650
- readable = false;
1651
- if (!writable) callback.call(stream);
1652
- };
1653
-
1654
- var onexit = function(exitCode) {
1655
- callback.call(stream, exitCode ? new Error('exited with error code: ' + exitCode) : null);
1656
- };
1657
-
1658
- var onerror = function(err) {
1659
- callback.call(stream, err);
1660
- };
1661
-
1662
- var onclose = function() {
1663
- qnt(onclosenexttick);
1664
- };
1665
-
1666
- var onclosenexttick = function() {
1667
- if (cancelled) return;
1668
- if (readable && !(rs && (rs.ended && !rs.destroyed))) return callback.call(stream, new Error('premature close'));
1669
- if (writable && !(ws && (ws.ended && !ws.destroyed))) return callback.call(stream, new Error('premature close'));
1670
- };
1671
-
1672
- var onrequest = function() {
1673
- stream.req.on('finish', onfinish);
1674
- };
1675
-
1676
- if (isRequest(stream)) {
1677
- stream.on('complete', onfinish);
1678
- stream.on('abort', onclose);
1679
- if (stream.req) onrequest();
1680
- else stream.on('request', onrequest);
1681
- } else if (writable && !ws) { // legacy streams
1682
- stream.on('end', onlegacyfinish);
1683
- stream.on('close', onlegacyfinish);
1684
- }
1685
-
1686
- if (isChildProcess(stream)) stream.on('exit', onexit);
1687
-
1688
- stream.on('end', onend);
1689
- stream.on('finish', onfinish);
1690
- if (opts.error !== false) stream.on('error', onerror);
1691
- stream.on('close', onclose);
1692
-
1693
- return function() {
1694
- cancelled = true;
1695
- stream.removeListener('complete', onfinish);
1696
- stream.removeListener('abort', onclose);
1697
- stream.removeListener('request', onrequest);
1698
- if (stream.req) stream.req.removeListener('finish', onfinish);
1699
- stream.removeListener('end', onlegacyfinish);
1700
- stream.removeListener('close', onlegacyfinish);
1701
- stream.removeListener('finish', onfinish);
1702
- stream.removeListener('exit', onexit);
1703
- stream.removeListener('end', onend);
1704
- stream.removeListener('error', onerror);
1705
- stream.removeListener('close', onclose);
1706
- };
1707
- };
1708
-
1709
- endOfStream = eos;
1710
- return endOfStream;
1711
- }
1712
-
1713
- var pump_1;
1714
- var hasRequiredPump;
1715
-
1716
- function requirePump () {
1717
- if (hasRequiredPump) return pump_1;
1718
- hasRequiredPump = 1;
1719
- var once = requireOnce();
1720
- var eos = requireEndOfStream();
1721
- var fs;
1722
-
1723
- try {
1724
- fs = require('fs'); // we only need fs to get the ReadStream and WriteStream prototypes
1725
- } catch (e) {}
1726
-
1727
- var noop = function () {};
1728
- var ancient = typeof process === 'undefined' ? false : /^v?\.0/.test(process.version);
1729
-
1730
- var isFn = function (fn) {
1731
- return typeof fn === 'function'
1732
- };
1733
-
1734
- var isFS = function (stream) {
1735
- if (!ancient) return false // newer node version do not need to care about fs is a special way
1736
- if (!fs) return false // browser
1737
- return (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close)
1738
- };
1739
-
1740
- var isRequest = function (stream) {
1741
- return stream.setHeader && isFn(stream.abort)
1742
- };
1743
-
1744
- var destroyer = function (stream, reading, writing, callback) {
1745
- callback = once(callback);
1746
-
1747
- var closed = false;
1748
- stream.on('close', function () {
1749
- closed = true;
1750
- });
1751
-
1752
- eos(stream, {readable: reading, writable: writing}, function (err) {
1753
- if (err) return callback(err)
1754
- closed = true;
1755
- callback();
1756
- });
1757
-
1758
- var destroyed = false;
1759
- return function (err) {
1760
- if (closed) return
1761
- if (destroyed) return
1762
- destroyed = true;
1763
-
1764
- if (isFS(stream)) return stream.close(noop) // use close for fs streams to avoid fd leaks
1765
- if (isRequest(stream)) return stream.abort() // request.destroy just do .end - .abort is what we want
1766
-
1767
- if (isFn(stream.destroy)) return stream.destroy()
1768
-
1769
- callback(err || new Error('stream was destroyed'));
1770
- }
1771
- };
1772
-
1773
- var call = function (fn) {
1774
- fn();
1775
- };
1776
-
1777
- var pipe = function (from, to) {
1778
- return from.pipe(to)
1779
- };
1780
-
1781
- var pump = function () {
1782
- var streams = Array.prototype.slice.call(arguments);
1783
- var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop;
1784
-
1785
- if (Array.isArray(streams[0])) streams = streams[0];
1786
- if (streams.length < 2) throw new Error('pump requires two streams per minimum')
1787
-
1788
- var error;
1789
- var destroys = streams.map(function (stream, i) {
1790
- var reading = i < streams.length - 1;
1791
- var writing = i > 0;
1792
- return destroyer(stream, reading, writing, function (err) {
1793
- if (!error) error = err;
1794
- if (err) destroys.forEach(call);
1795
- if (reading) return
1796
- destroys.forEach(call);
1797
- callback(error);
1798
- })
1799
- });
1800
-
1801
- return streams.reduce(pipe)
1802
- };
1803
-
1804
- pump_1 = pump;
1805
- return pump_1;
1806
- }
1807
-
1808
- var bufferStream;
1809
- var hasRequiredBufferStream;
1810
-
1811
- function requireBufferStream () {
1812
- if (hasRequiredBufferStream) return bufferStream;
1813
- hasRequiredBufferStream = 1;
1814
- const {PassThrough: PassThroughStream} = require$$0$3;
1815
-
1816
- bufferStream = options => {
1817
- options = {...options};
1818
-
1819
- const {array} = options;
1820
- let {encoding} = options;
1821
- const isBuffer = encoding === 'buffer';
1822
- let objectMode = false;
1823
-
1824
- if (array) {
1825
- objectMode = !(encoding || isBuffer);
1826
- } else {
1827
- encoding = encoding || 'utf8';
1828
- }
1829
-
1830
- if (isBuffer) {
1831
- encoding = null;
1832
- }
1833
-
1834
- const stream = new PassThroughStream({objectMode});
1835
-
1836
- if (encoding) {
1837
- stream.setEncoding(encoding);
1838
- }
1839
-
1840
- let length = 0;
1841
- const chunks = [];
1842
-
1843
- stream.on('data', chunk => {
1844
- chunks.push(chunk);
1845
-
1846
- if (objectMode) {
1847
- length = chunks.length;
1848
- } else {
1849
- length += chunk.length;
1850
- }
1851
- });
1852
-
1853
- stream.getBufferedValue = () => {
1854
- if (array) {
1855
- return chunks;
1856
- }
1857
-
1858
- return isBuffer ? Buffer.concat(chunks, length) : chunks.join('');
1859
- };
1860
-
1861
- stream.getBufferedLength = () => length;
1862
-
1863
- return stream;
1864
- };
1865
- return bufferStream;
1866
- }
1867
-
1868
- var hasRequiredGetStream;
1869
-
1870
- function requireGetStream () {
1871
- if (hasRequiredGetStream) return getStream.exports;
1872
- hasRequiredGetStream = 1;
1873
- const {constants: BufferConstants} = require$$0$4;
1874
- const pump = requirePump();
1875
- const bufferStream = requireBufferStream();
1876
-
1877
- class MaxBufferError extends Error {
1878
- constructor() {
1879
- super('maxBuffer exceeded');
1880
- this.name = 'MaxBufferError';
1881
- }
1882
- }
1883
-
1884
- async function getStream$1(inputStream, options) {
1885
- if (!inputStream) {
1886
- return Promise.reject(new Error('Expected a stream'));
1887
- }
1888
-
1889
- options = {
1890
- maxBuffer: Infinity,
1891
- ...options
1892
- };
1893
-
1894
- const {maxBuffer} = options;
1895
-
1896
- let stream;
1897
- await new Promise((resolve, reject) => {
1898
- const rejectPromise = error => {
1899
- // Don't retrieve an oversized buffer.
1900
- if (error && stream.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
1901
- error.bufferedData = stream.getBufferedValue();
1902
- }
1903
-
1904
- reject(error);
1905
- };
1906
-
1907
- stream = pump(inputStream, bufferStream(options), error => {
1908
- if (error) {
1909
- rejectPromise(error);
1910
- return;
1911
- }
1912
-
1913
- resolve();
1914
- });
1915
-
1916
- stream.on('data', () => {
1917
- if (stream.getBufferedLength() > maxBuffer) {
1918
- rejectPromise(new MaxBufferError());
1919
- }
1920
- });
1921
- });
1922
-
1923
- return stream.getBufferedValue();
1924
- }
1925
-
1926
- getStream.exports = getStream$1;
1927
- // TODO: Remove this for the next major release
1928
- getStream.exports.default = getStream$1;
1929
- getStream.exports.buffer = (stream, options) => getStream$1(stream, {...options, encoding: 'buffer'});
1930
- getStream.exports.array = (stream, options) => getStream$1(stream, {...options, array: true});
1931
- getStream.exports.MaxBufferError = MaxBufferError;
1932
- return getStream.exports;
1933
- }
1934
-
1935
- var mergeStream;
1936
- var hasRequiredMergeStream;
1937
-
1938
- function requireMergeStream () {
1939
- if (hasRequiredMergeStream) return mergeStream;
1940
- hasRequiredMergeStream = 1;
1941
-
1942
- const { PassThrough } = require$$0$3;
1943
-
1944
- mergeStream = function (/*streams...*/) {
1945
- var sources = [];
1946
- var output = new PassThrough({objectMode: true});
1947
-
1948
- output.setMaxListeners(0);
1949
-
1950
- output.add = add;
1951
- output.isEmpty = isEmpty;
1952
-
1953
- output.on('unpipe', remove);
1954
-
1955
- Array.prototype.slice.call(arguments).forEach(add);
1956
-
1957
- return output
1958
-
1959
- function add (source) {
1960
- if (Array.isArray(source)) {
1961
- source.forEach(add);
1962
- return this
1963
- }
1964
-
1965
- sources.push(source);
1966
- source.once('end', remove.bind(null, source));
1967
- source.once('error', output.emit.bind(output, 'error'));
1968
- source.pipe(output, {end: false});
1969
- return this
1970
- }
1971
-
1972
- function isEmpty () {
1973
- return sources.length == 0;
1974
- }
1975
-
1976
- function remove (source) {
1977
- sources = sources.filter(function (it) { return it !== source });
1978
- if (!sources.length && output.readable) { output.end(); }
1979
- }
1980
- };
1981
- return mergeStream;
1982
- }
1983
-
1984
- var stream;
1985
- var hasRequiredStream;
1986
-
1987
- function requireStream () {
1988
- if (hasRequiredStream) return stream;
1989
- hasRequiredStream = 1;
1990
- const isStream = requireIsStream();
1991
- const getStream = requireGetStream();
1992
- const mergeStream = requireMergeStream();
1993
-
1994
- // `input` option
1995
- const handleInput = (spawned, input) => {
1996
- // Checking for stdin is workaround for https://github.com/nodejs/node/issues/26852
1997
- // TODO: Remove `|| spawned.stdin === undefined` once we drop support for Node.js <=12.2.0
1998
- if (input === undefined || spawned.stdin === undefined) {
1999
- return;
2000
- }
2001
-
2002
- if (isStream(input)) {
2003
- input.pipe(spawned.stdin);
2004
- } else {
2005
- spawned.stdin.end(input);
2006
- }
2007
- };
2008
-
2009
- // `all` interleaves `stdout` and `stderr`
2010
- const makeAllStream = spawned => {
2011
- if (!spawned.stdout && !spawned.stderr) {
2012
- return;
2013
- }
2014
-
2015
- const mixed = mergeStream();
2016
-
2017
- if (spawned.stdout) {
2018
- mixed.add(spawned.stdout);
2019
- }
2020
-
2021
- if (spawned.stderr) {
2022
- mixed.add(spawned.stderr);
2023
- }
2024
-
2025
- return mixed;
2026
- };
2027
-
2028
- // On failure, `result.stdout|stderr|all` should contain the currently buffered stream
2029
- const getBufferedData = async (stream, streamPromise) => {
2030
- if (!stream) {
2031
- return;
2032
- }
2033
-
2034
- stream.destroy();
2035
-
2036
- try {
2037
- return await streamPromise;
2038
- } catch (error) {
2039
- return error.bufferedData;
2040
- }
2041
- };
2042
-
2043
- const getStreamPromise = (stream, {encoding, buffer, maxBuffer}) => {
2044
- if (!stream) {
2045
- return;
2046
- }
2047
-
2048
- if (!buffer) {
2049
- // TODO: Use `ret = util.promisify(stream.finished)(stream);` when targeting Node.js 10
2050
- return new Promise((resolve, reject) => {
2051
- stream
2052
- .once('end', resolve)
2053
- .once('error', reject);
2054
- });
2055
- }
2056
-
2057
- if (encoding) {
2058
- return getStream(stream, {encoding, maxBuffer});
2059
- }
2060
-
2061
- return getStream.buffer(stream, {maxBuffer});
2062
- };
2063
-
2064
- // Retrieve result of child process: exit code, signal, error, streams (stdout/stderr/all)
2065
- const getSpawnedResult = async ({stdout, stderr, all}, {encoding, buffer, maxBuffer}, processDone) => {
2066
- const stdoutPromise = getStreamPromise(stdout, {encoding, buffer, maxBuffer});
2067
- const stderrPromise = getStreamPromise(stderr, {encoding, buffer, maxBuffer});
2068
- const allPromise = getStreamPromise(all, {encoding, buffer, maxBuffer: maxBuffer * 2});
2069
-
2070
- try {
2071
- return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]);
2072
- } catch (error) {
2073
- return Promise.all([
2074
- {error, code: error.code, signal: error.signal, timedOut: error.timedOut},
2075
- getBufferedData(stdout, stdoutPromise),
2076
- getBufferedData(stderr, stderrPromise),
2077
- getBufferedData(all, allPromise)
2078
- ]);
2079
- }
2080
- };
2081
-
2082
- const validateInputSync = ({input}) => {
2083
- if (isStream(input)) {
2084
- throw new TypeError('The `input` option cannot be a stream in sync mode');
2085
- }
2086
- };
2087
-
2088
- stream = {
2089
- handleInput,
2090
- makeAllStream,
2091
- getSpawnedResult,
2092
- validateInputSync
2093
- };
2094
- return stream;
2095
- }
2096
-
2097
- var promise;
2098
- var hasRequiredPromise;
2099
-
2100
- function requirePromise () {
2101
- if (hasRequiredPromise) return promise;
2102
- hasRequiredPromise = 1;
2103
- const mergePromiseProperty = (spawned, promise, property) => {
2104
- // Starting the main `promise` is deferred to avoid consuming streams
2105
- const value = typeof promise === 'function' ?
2106
- (...args) => promise()[property](...args) :
2107
- promise[property].bind(promise);
2108
-
2109
- Object.defineProperty(spawned, property, {
2110
- value,
2111
- writable: true,
2112
- enumerable: false,
2113
- configurable: true
2114
- });
2115
- };
2116
-
2117
- // The return value is a mixin of `childProcess` and `Promise`
2118
- const mergePromise = (spawned, promise) => {
2119
- mergePromiseProperty(spawned, promise, 'then');
2120
- mergePromiseProperty(spawned, promise, 'catch');
2121
-
2122
- // TODO: Remove the `if`-guard when targeting Node.js 10
2123
- if (Promise.prototype.finally) {
2124
- mergePromiseProperty(spawned, promise, 'finally');
2125
- }
2126
-
2127
- return spawned;
2128
- };
2129
-
2130
- // Use promises instead of `child_process` events
2131
- const getSpawnedPromise = spawned => {
2132
- return new Promise((resolve, reject) => {
2133
- spawned.on('exit', (code, signal) => {
2134
- resolve({code, signal});
2135
- });
2136
-
2137
- spawned.on('error', error => {
2138
- reject(error);
2139
- });
2140
-
2141
- if (spawned.stdin) {
2142
- spawned.stdin.on('error', error => {
2143
- reject(error);
2144
- });
2145
- }
2146
- });
2147
- };
2148
-
2149
- promise = {
2150
- mergePromise,
2151
- getSpawnedPromise
2152
- };
2153
- return promise;
2154
- }
2155
-
2156
- var command;
2157
- var hasRequiredCommand;
2158
-
2159
- function requireCommand () {
2160
- if (hasRequiredCommand) return command;
2161
- hasRequiredCommand = 1;
2162
- const SPACES_REGEXP = / +/g;
2163
-
2164
- const joinCommand = (file, args = []) => {
2165
- if (!Array.isArray(args)) {
2166
- return file;
2167
- }
2168
-
2169
- return [file, ...args].join(' ');
2170
- };
2171
-
2172
- // Allow spaces to be escaped by a backslash if not meant as a delimiter
2173
- const handleEscaping = (tokens, token, index) => {
2174
- if (index === 0) {
2175
- return [token];
2176
- }
2177
-
2178
- const previousToken = tokens[tokens.length - 1];
2179
-
2180
- if (previousToken.endsWith('\\')) {
2181
- return [...tokens.slice(0, -1), `${previousToken.slice(0, -1)} ${token}`];
2182
- }
2183
-
2184
- return [...tokens, token];
2185
- };
2186
-
2187
- // Handle `execa.command()`
2188
- const parseCommand = command => {
2189
- return command
2190
- .trim()
2191
- .split(SPACES_REGEXP)
2192
- .reduce(handleEscaping, []);
2193
- };
2194
-
2195
- command = {
2196
- joinCommand,
2197
- parseCommand
2198
- };
2199
- return command;
2200
- }
2201
-
2202
- var hasRequiredExeca;
2203
-
2204
- function requireExeca () {
2205
- if (hasRequiredExeca) return execa.exports;
2206
- hasRequiredExeca = 1;
2207
- const path = sysPath;
2208
- const childProcess = require$$0$1;
2209
- const crossSpawn = requireCrossSpawn();
2210
- const stripFinalNewline = requireStripFinalNewline();
2211
- const npmRunPath = requireNpmRunPath();
2212
- const onetime = requireOnetime();
2213
- const makeError = requireError();
2214
- const normalizeStdio = requireStdio();
2215
- const {spawnedKill, spawnedCancel, setupTimeout, setExitHandler} = requireKill();
2216
- const {handleInput, getSpawnedResult, makeAllStream, validateInputSync} = requireStream();
2217
- const {mergePromise, getSpawnedPromise} = requirePromise();
2218
- const {joinCommand, parseCommand} = requireCommand();
2219
-
2220
- const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100;
2221
-
2222
- const getEnv = ({env: envOption, extendEnv, preferLocal, localDir}) => {
2223
- const env = extendEnv ? {...process.env, ...envOption} : envOption;
2224
-
2225
- if (preferLocal) {
2226
- return npmRunPath.env({env, cwd: localDir});
2227
- }
2228
-
2229
- return env;
2230
- };
2231
-
2232
- const handleArgs = (file, args, options = {}) => {
2233
- const parsed = crossSpawn._parse(file, args, options);
2234
- file = parsed.command;
2235
- args = parsed.args;
2236
- options = parsed.options;
2237
-
2238
- options = {
2239
- maxBuffer: DEFAULT_MAX_BUFFER,
2240
- buffer: true,
2241
- stripFinalNewline: true,
2242
- extendEnv: true,
2243
- preferLocal: false,
2244
- localDir: options.cwd || process.cwd(),
2245
- encoding: 'utf8',
2246
- reject: true,
2247
- cleanup: true,
2248
- ...options,
2249
- windowsHide: true
2250
- };
2251
-
2252
- options.env = getEnv(options);
2253
-
2254
- options.stdio = normalizeStdio(options);
2255
-
2256
- if (process.platform === 'win32' && path.basename(file, '.exe') === 'cmd') {
2257
- // #116
2258
- args.unshift('/q');
2259
- }
2260
-
2261
- return {file, args, options, parsed};
2262
- };
2263
-
2264
- const handleOutput = (options, value, error) => {
2265
- if (typeof value !== 'string' && !Buffer.isBuffer(value)) {
2266
- // When `execa.sync()` errors, we normalize it to '' to mimic `execa()`
2267
- return error === undefined ? undefined : '';
2268
- }
2269
-
2270
- if (options.stripFinalNewline) {
2271
- return stripFinalNewline(value);
2272
- }
2273
-
2274
- return value;
2275
- };
2276
-
2277
- const execa$1 = (file, args, options) => {
2278
- const parsed = handleArgs(file, args, options);
2279
- const command = joinCommand(file, args);
2280
-
2281
- let spawned;
2282
- try {
2283
- spawned = childProcess.spawn(parsed.file, parsed.args, parsed.options);
2284
- } catch (error) {
2285
- // Ensure the returned error is always both a promise and a child process
2286
- const dummySpawned = new childProcess.ChildProcess();
2287
- const errorPromise = Promise.reject(makeError({
2288
- error,
2289
- stdout: '',
2290
- stderr: '',
2291
- all: '',
2292
- command,
2293
- parsed,
2294
- timedOut: false,
2295
- isCanceled: false,
2296
- killed: false
2297
- }));
2298
- return mergePromise(dummySpawned, errorPromise);
2299
- }
2300
-
2301
- const spawnedPromise = getSpawnedPromise(spawned);
2302
- const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise);
2303
- const processDone = setExitHandler(spawned, parsed.options, timedPromise);
2304
-
2305
- const context = {isCanceled: false};
2306
-
2307
- spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned));
2308
- spawned.cancel = spawnedCancel.bind(null, spawned, context);
2309
-
2310
- const handlePromise = async () => {
2311
- const [{error, code, signal, timedOut}, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone);
2312
- const stdout = handleOutput(parsed.options, stdoutResult);
2313
- const stderr = handleOutput(parsed.options, stderrResult);
2314
- const all = handleOutput(parsed.options, allResult);
2315
-
2316
- if (error || code !== 0 || signal !== null) {
2317
- const returnedError = makeError({
2318
- error,
2319
- code,
2320
- signal,
2321
- stdout,
2322
- stderr,
2323
- all,
2324
- command,
2325
- parsed,
2326
- timedOut,
2327
- isCanceled: context.isCanceled,
2328
- killed: spawned.killed
2329
- });
2330
-
2331
- if (!parsed.options.reject) {
2332
- return returnedError;
2333
- }
2334
-
2335
- throw returnedError;
2336
- }
2337
-
2338
- return {
2339
- command,
2340
- exitCode: 0,
2341
- exitCodeName: 'SUCCESS',
2342
- stdout,
2343
- stderr,
2344
- all,
2345
- failed: false,
2346
- timedOut: false,
2347
- isCanceled: false,
2348
- killed: false
2349
- };
2350
- };
2351
-
2352
- const handlePromiseOnce = onetime(handlePromise);
2353
-
2354
- crossSpawn._enoent.hookChildProcess(spawned, parsed.parsed);
2355
-
2356
- handleInput(spawned, parsed.options.input);
2357
-
2358
- spawned.all = makeAllStream(spawned);
2359
-
2360
- return mergePromise(spawned, handlePromiseOnce);
2361
- };
2362
-
2363
- execa.exports = execa$1;
2364
-
2365
- execa.exports.sync = (file, args, options) => {
2366
- const parsed = handleArgs(file, args, options);
2367
- const command = joinCommand(file, args);
2368
-
2369
- validateInputSync(parsed.options);
2370
-
2371
- let result;
2372
- try {
2373
- result = childProcess.spawnSync(parsed.file, parsed.args, parsed.options);
2374
- } catch (error) {
2375
- throw makeError({
2376
- error,
2377
- stdout: '',
2378
- stderr: '',
2379
- all: '',
2380
- command,
2381
- parsed,
2382
- timedOut: false,
2383
- isCanceled: false,
2384
- killed: false
2385
- });
2386
- }
2387
-
2388
- result.stdout = handleOutput(parsed.options, result.stdout, result.error);
2389
- result.stderr = handleOutput(parsed.options, result.stderr, result.error);
2390
-
2391
- if (result.error || result.status !== 0 || result.signal !== null) {
2392
- const error = makeError({
2393
- ...result,
2394
- code: result.status,
2395
- command,
2396
- parsed,
2397
- timedOut: result.error && result.error.code === 'ETIMEDOUT',
2398
- isCanceled: false,
2399
- killed: result.signal !== null
2400
- });
2401
-
2402
- if (!parsed.options.reject) {
2403
- return error;
2404
- }
2405
-
2406
- throw error;
2407
- }
2408
-
2409
- return {
2410
- command,
2411
- exitCode: 0,
2412
- exitCodeName: 'SUCCESS',
2413
- stdout: result.stdout,
2414
- stderr: result.stderr,
2415
- failed: false,
2416
- timedOut: false,
2417
- isCanceled: false,
2418
- killed: false
2419
- };
2420
- };
2421
-
2422
- execa.exports.command = (command, options) => {
2423
- const [file, ...args] = parseCommand(command);
2424
- return execa$1(file, args, options);
2425
- };
2426
-
2427
- execa.exports.commandSync = (command, options) => {
2428
- const [file, ...args] = parseCommand(command);
2429
- return execa$1.sync(file, args, options);
2430
- };
2431
-
2432
- execa.exports.node = (scriptPath, args, options = {}) => {
2433
- if (args && !Array.isArray(args) && typeof args === 'object') {
2434
- options = args;
2435
- args = [];
2436
- }
2437
-
2438
- const stdio = normalizeStdio.node(options);
2439
-
2440
- const {nodePath = process.execPath, nodeOptions = process.execArgv} = options;
2441
-
2442
- return execa$1(
2443
- nodePath,
2444
- [
2445
- ...nodeOptions,
2446
- scriptPath,
2447
- ...(Array.isArray(args) ? args : [])
2448
- ],
2449
- {
2450
- ...options,
2451
- stdin: undefined,
2452
- stdout: undefined,
2453
- stderr: undefined,
2454
- stdio,
2455
- shell: false
2456
- }
2457
- );
2458
- };
2459
- return execa.exports;
2460
- }
2461
-
2462
- var hasRequiredDf$1;
2463
-
2464
- function requireDf$1 () {
2465
- if (hasRequiredDf$1) return df$1.exports;
2466
- hasRequiredDf$1 = 1;
2467
- const execa = requireExeca();
2468
-
2469
- const getColumnBoundaries = async header => {
2470
- // Regex captures each individual column
2471
- // ^\S+\s+ -> First column
2472
- // \s*\S+\s*\S+$ -> Last column (combined)
2473
- // \s*\S+ -> Regular columns
2474
- const regex = /^\S+\s+|\s*\S+\s*\S+$|\s*\S+/g;
2475
- const boundaries = [];
2476
- let match;
2477
-
2478
- while ((match = regex.exec(header))) {
2479
- boundaries.push(match[0].length);
2480
- }
2481
-
2482
- // Extend last column boundary
2483
- boundaries[boundaries.length - 1] = -1;
2484
-
2485
- return boundaries;
2486
- };
2487
-
2488
- const parseOutput = async output => {
2489
- const lines = output.trim().split('\n');
2490
- const boundaries = await getColumnBoundaries(lines[0]);
2491
-
2492
- return lines.slice(1).map(line => {
2493
- const cl = boundaries.map(boundary => {
2494
- // Handle extra-long last column
2495
- const column = boundary > 0 ? line.slice(0, boundary) : line;
2496
- line = line.slice(boundary);
2497
- return column.trim();
2498
- });
2499
-
2500
- return {
2501
- filesystem: cl[0],
2502
- size: parseInt(cl[1], 10) * 1024,
2503
- used: parseInt(cl[2], 10) * 1024,
2504
- available: parseInt(cl[3], 10) * 1024,
2505
- capacity: parseInt(cl[4], 10) / 100,
2506
- mountpoint: cl[5]
2507
- };
2508
- });
2509
- };
2510
-
2511
- const run = async args => {
2512
- const {stdout} = await execa('df', args);
2513
- return parseOutput(stdout);
2514
- };
2515
-
2516
- const df = async () => run(['-kP']);
2517
-
2518
- df.fs = async name => {
2519
- if (typeof name !== 'string') {
2520
- throw new TypeError('The `name` parameter required');
2521
- }
2522
-
2523
- const data = await run(['-kP']);
2524
-
2525
- for (const item of data) {
2526
- if (item.filesystem === name) {
2527
- return item;
2528
- }
2529
- }
2530
-
2531
- throw new Error(`The specified filesystem \`${name}\` doesn't exist`);
2532
- };
2533
-
2534
- df.file = async file => {
2535
- if (typeof file !== 'string') {
2536
- throw new TypeError('The `file` parameter is required');
2537
- }
2538
-
2539
- let data;
2540
- try {
2541
- data = await run(['-kP', file]);
2542
- } catch (error) {
2543
- if (/No such file or directory/.test(error.stderr)) {
2544
- throw new Error(`The specified file \`${file}\` doesn't exist`);
2545
- }
2546
-
2547
- throw error;
2548
- }
2549
-
2550
- return data[0];
2551
- };
2552
-
2553
- df$1.exports = df;
2554
- // TODO: remove this in the next major version
2555
- df$1.exports.default = df;
2556
-
2557
- if (process.env.NODE_ENV === 'test') {
2558
- df$1.exports._parseOutput = parseOutput;
2559
- }
2560
- return df$1.exports;
2561
- }
2562
-
2563
- var df = {exports: {}};
2564
-
2565
- var hasRequiredDf;
2566
-
2567
- function requireDf () {
2568
- if (hasRequiredDf) return df.exports;
2569
- hasRequiredDf = 1;
2570
- var childProcess = require$$0$1;
2571
-
2572
- function run(args, cb) {
2573
- childProcess.execFile('df', args, function (err, stdout) {
2574
- if (err) {
2575
- cb(err);
2576
- return;
2577
- }
2578
-
2579
- cb(null, stdout.trim().split('\n').slice(1).map(function (el) {
2580
- var cl = el.split(/\s+(?=[\d\/])/);
2581
-
2582
- return {
2583
- filesystem: cl[0],
2584
- size: parseInt(cl[1], 10) * 1024,
2585
- used: parseInt(cl[2], 10) * 1024,
2586
- available: parseInt(cl[3], 10) * 1024,
2587
- capacity: parseInt(cl[4], 10) / 100,
2588
- mountpoint: cl[5]
2589
- };
2590
- }));
2591
- });
2592
- }
2593
- var df$1 = df.exports = function (cb) {
2594
- run(['-kP'], cb);
2595
- };
2596
-
2597
- df$1.fs = function (name, cb) {
2598
- if (typeof name !== 'string') {
2599
- throw new Error('name required');
2600
- }
2601
-
2602
- run(['-kP'], function (err, data) {
2603
- if (err) {
2604
- cb(err);
2605
- return;
2606
- }
2607
-
2608
- var ret;
2609
-
2610
- data.forEach(function (el) {
2611
- if (el.filesystem === name) {
2612
- ret = el;
2613
- }
2614
- });
2615
-
2616
- cb(null, ret);
2617
- });
2618
- };
2619
-
2620
- df$1.file = function (file, cb) {
2621
- if (typeof file !== 'string') {
2622
- throw new Error('file required');
2623
- }
2624
-
2625
- run(['-kP', file], function (err, data) {
2626
- if (err) {
2627
- cb(err);
2628
- return;
2629
- }
2630
-
2631
- cb(null, data[0]);
2632
- });
2633
- };
2634
- return df.exports;
2635
- }
2636
-
2637
- var pify = {exports: {}};
2638
-
2639
- var hasRequiredPify;
2640
-
2641
- function requirePify () {
2642
- if (hasRequiredPify) return pify.exports;
2643
- hasRequiredPify = 1;
2644
-
2645
- var processFn = function (fn, P, opts) {
2646
- return function () {
2647
- var that = this;
2648
- var args = new Array(arguments.length);
2649
-
2650
- for (var i = 0; i < arguments.length; i++) {
2651
- args[i] = arguments[i];
2652
- }
2653
-
2654
- return new P(function (resolve, reject) {
2655
- args.push(function (err, result) {
2656
- if (err) {
2657
- reject(err);
2658
- } else if (opts.multiArgs) {
2659
- var results = new Array(arguments.length - 1);
2660
-
2661
- for (var i = 1; i < arguments.length; i++) {
2662
- results[i - 1] = arguments[i];
2663
- }
2664
-
2665
- resolve(results);
2666
- } else {
2667
- resolve(result);
2668
- }
2669
- });
2670
-
2671
- fn.apply(that, args);
2672
- });
2673
- };
2674
- };
2675
-
2676
- var pify$1 = pify.exports = function (obj, P, opts) {
2677
- if (typeof P !== 'function') {
2678
- opts = P;
2679
- P = Promise;
2680
- }
2681
-
2682
- opts = opts || {};
2683
- opts.exclude = opts.exclude || [/.+Sync$/];
2684
-
2685
- var filter = function (key) {
2686
- var match = function (pattern) {
2687
- return typeof pattern === 'string' ? key === pattern : pattern.test(key);
2688
- };
2689
-
2690
- return opts.include ? opts.include.some(match) : !opts.exclude.some(match);
2691
- };
2692
-
2693
- var ret = typeof obj === 'function' ? function () {
2694
- if (opts.excludeMain) {
2695
- return obj.apply(this, arguments);
2696
- }
2697
-
2698
- return processFn(obj, P, opts).apply(this, arguments);
2699
- } : {};
2700
-
2701
- return Object.keys(obj).reduce(function (ret, key) {
2702
- var x = obj[key];
2703
-
2704
- ret[key] = typeof x === 'function' && filter(key) ? processFn(x, P, opts) : x;
2705
-
2706
- return ret;
2707
- }, ret);
2708
- };
2709
-
2710
- pify$1.all = pify$1;
2711
- return pify.exports;
2712
- }
2713
-
2714
- var pinkie;
2715
- var hasRequiredPinkie;
2716
-
2717
- function requirePinkie () {
2718
- if (hasRequiredPinkie) return pinkie;
2719
- hasRequiredPinkie = 1;
2720
-
2721
- var PENDING = 'pending';
2722
- var SETTLED = 'settled';
2723
- var FULFILLED = 'fulfilled';
2724
- var REJECTED = 'rejected';
2725
- var NOOP = function () {};
2726
- var isNode = typeof commonjsGlobal !== 'undefined' && typeof commonjsGlobal.process !== 'undefined' && typeof commonjsGlobal.process.emit === 'function';
2727
-
2728
- var asyncSetTimer = typeof setImmediate === 'undefined' ? setTimeout : setImmediate;
2729
- var asyncQueue = [];
2730
- var asyncTimer;
2731
-
2732
- function asyncFlush() {
2733
- // run promise callbacks
2734
- for (var i = 0; i < asyncQueue.length; i++) {
2735
- asyncQueue[i][0](asyncQueue[i][1]);
2736
- }
2737
-
2738
- // reset async asyncQueue
2739
- asyncQueue = [];
2740
- asyncTimer = false;
2741
- }
2742
-
2743
- function asyncCall(callback, arg) {
2744
- asyncQueue.push([callback, arg]);
2745
-
2746
- if (!asyncTimer) {
2747
- asyncTimer = true;
2748
- asyncSetTimer(asyncFlush, 0);
2749
- }
2750
- }
2751
-
2752
- function invokeResolver(resolver, promise) {
2753
- function resolvePromise(value) {
2754
- resolve(promise, value);
2755
- }
2756
-
2757
- function rejectPromise(reason) {
2758
- reject(promise, reason);
2759
- }
2760
-
2761
- try {
2762
- resolver(resolvePromise, rejectPromise);
2763
- } catch (e) {
2764
- rejectPromise(e);
2765
- }
2766
- }
2767
-
2768
- function invokeCallback(subscriber) {
2769
- var owner = subscriber.owner;
2770
- var settled = owner._state;
2771
- var value = owner._data;
2772
- var callback = subscriber[settled];
2773
- var promise = subscriber.then;
2774
-
2775
- if (typeof callback === 'function') {
2776
- settled = FULFILLED;
2777
- try {
2778
- value = callback(value);
2779
- } catch (e) {
2780
- reject(promise, e);
2781
- }
2782
- }
2783
-
2784
- if (!handleThenable(promise, value)) {
2785
- if (settled === FULFILLED) {
2786
- resolve(promise, value);
2787
- }
2788
-
2789
- if (settled === REJECTED) {
2790
- reject(promise, value);
2791
- }
2792
- }
2793
- }
2794
-
2795
- function handleThenable(promise, value) {
2796
- var resolved;
2797
-
2798
- try {
2799
- if (promise === value) {
2800
- throw new TypeError('A promises callback cannot return that same promise.');
2801
- }
2802
-
2803
- if (value && (typeof value === 'function' || typeof value === 'object')) {
2804
- // then should be retrieved only once
2805
- var then = value.then;
2806
-
2807
- if (typeof then === 'function') {
2808
- then.call(value, function (val) {
2809
- if (!resolved) {
2810
- resolved = true;
2811
-
2812
- if (value === val) {
2813
- fulfill(promise, val);
2814
- } else {
2815
- resolve(promise, val);
2816
- }
2817
- }
2818
- }, function (reason) {
2819
- if (!resolved) {
2820
- resolved = true;
2821
-
2822
- reject(promise, reason);
2823
- }
2824
- });
2825
-
2826
- return true;
2827
- }
2828
- }
2829
- } catch (e) {
2830
- if (!resolved) {
2831
- reject(promise, e);
2832
- }
2833
-
2834
- return true;
2835
- }
2836
-
2837
- return false;
2838
- }
2839
-
2840
- function resolve(promise, value) {
2841
- if (promise === value || !handleThenable(promise, value)) {
2842
- fulfill(promise, value);
2843
- }
2844
- }
2845
-
2846
- function fulfill(promise, value) {
2847
- if (promise._state === PENDING) {
2848
- promise._state = SETTLED;
2849
- promise._data = value;
2850
-
2851
- asyncCall(publishFulfillment, promise);
2852
- }
2853
- }
2854
-
2855
- function reject(promise, reason) {
2856
- if (promise._state === PENDING) {
2857
- promise._state = SETTLED;
2858
- promise._data = reason;
2859
-
2860
- asyncCall(publishRejection, promise);
2861
- }
2862
- }
2863
-
2864
- function publish(promise) {
2865
- promise._then = promise._then.forEach(invokeCallback);
2866
- }
2867
-
2868
- function publishFulfillment(promise) {
2869
- promise._state = FULFILLED;
2870
- publish(promise);
2871
- }
2872
-
2873
- function publishRejection(promise) {
2874
- promise._state = REJECTED;
2875
- publish(promise);
2876
- if (!promise._handled && isNode) {
2877
- commonjsGlobal.process.emit('unhandledRejection', promise._data, promise);
2878
- }
2879
- }
2880
-
2881
- function notifyRejectionHandled(promise) {
2882
- commonjsGlobal.process.emit('rejectionHandled', promise);
2883
- }
2884
-
2885
- /**
2886
- * @class
2887
- */
2888
- function Promise(resolver) {
2889
- if (typeof resolver !== 'function') {
2890
- throw new TypeError('Promise resolver ' + resolver + ' is not a function');
2891
- }
2892
-
2893
- if (this instanceof Promise === false) {
2894
- throw new TypeError('Failed to construct \'Promise\': Please use the \'new\' operator, this object constructor cannot be called as a function.');
2895
- }
2896
-
2897
- this._then = [];
2898
-
2899
- invokeResolver(resolver, this);
2900
- }
2901
-
2902
- Promise.prototype = {
2903
- constructor: Promise,
2904
-
2905
- _state: PENDING,
2906
- _then: null,
2907
- _data: undefined,
2908
- _handled: false,
2909
-
2910
- then: function (onFulfillment, onRejection) {
2911
- var subscriber = {
2912
- owner: this,
2913
- then: new this.constructor(NOOP),
2914
- fulfilled: onFulfillment,
2915
- rejected: onRejection
2916
- };
2917
-
2918
- if ((onRejection || onFulfillment) && !this._handled) {
2919
- this._handled = true;
2920
- if (this._state === REJECTED && isNode) {
2921
- asyncCall(notifyRejectionHandled, this);
2922
- }
2923
- }
2924
-
2925
- if (this._state === FULFILLED || this._state === REJECTED) {
2926
- // already resolved, call callback async
2927
- asyncCall(invokeCallback, subscriber);
2928
- } else {
2929
- // subscribe
2930
- this._then.push(subscriber);
2931
- }
2932
-
2933
- return subscriber.then;
2934
- },
2935
-
2936
- catch: function (onRejection) {
2937
- return this.then(null, onRejection);
2938
- }
2939
- };
2940
-
2941
- Promise.all = function (promises) {
2942
- if (!Array.isArray(promises)) {
2943
- throw new TypeError('You must pass an array to Promise.all().');
2944
- }
2945
-
2946
- return new Promise(function (resolve, reject) {
2947
- var results = [];
2948
- var remaining = 0;
2949
-
2950
- function resolver(index) {
2951
- remaining++;
2952
- return function (value) {
2953
- results[index] = value;
2954
- if (!--remaining) {
2955
- resolve(results);
2956
- }
2957
- };
2958
- }
2959
-
2960
- for (var i = 0, promise; i < promises.length; i++) {
2961
- promise = promises[i];
2962
-
2963
- if (promise && typeof promise.then === 'function') {
2964
- promise.then(resolver(i), reject);
2965
- } else {
2966
- results[i] = promise;
2967
- }
2968
- }
2969
-
2970
- if (!remaining) {
2971
- resolve(results);
2972
- }
2973
- });
2974
- };
2975
-
2976
- Promise.race = function (promises) {
2977
- if (!Array.isArray(promises)) {
2978
- throw new TypeError('You must pass an array to Promise.race().');
2979
- }
2980
-
2981
- return new Promise(function (resolve, reject) {
2982
- for (var i = 0, promise; i < promises.length; i++) {
2983
- promise = promises[i];
2984
-
2985
- if (promise && typeof promise.then === 'function') {
2986
- promise.then(resolve, reject);
2987
- } else {
2988
- resolve(promise);
2989
- }
2990
- }
2991
- });
2992
- };
2993
-
2994
- Promise.resolve = function (value) {
2995
- if (value && typeof value === 'object' && value.constructor === Promise) {
2996
- return value;
2997
- }
2998
-
2999
- return new Promise(function (resolve) {
3000
- resolve(value);
3001
- });
3002
- };
3003
-
3004
- Promise.reject = function (reason) {
3005
- return new Promise(function (resolve, reject) {
3006
- reject(reason);
3007
- });
3008
- };
3009
-
3010
- pinkie = Promise;
3011
- return pinkie;
3012
- }
3013
-
3014
- var pinkiePromise;
3015
- var hasRequiredPinkiePromise;
3016
-
3017
- function requirePinkiePromise () {
3018
- if (hasRequiredPinkiePromise) return pinkiePromise;
3019
- hasRequiredPinkiePromise = 1;
3020
-
3021
- pinkiePromise = typeof Promise === 'function' ? Promise : requirePinkie();
3022
- return pinkiePromise;
3023
- }
3024
-
3025
- var mountPoint;
3026
- var hasRequiredMountPoint;
3027
-
3028
- function requireMountPoint () {
3029
- if (hasRequiredMountPoint) return mountPoint;
3030
- hasRequiredMountPoint = 1;
3031
- var df = requireDf();
3032
- var pify = requirePify();
3033
- var Promise = requirePinkiePromise();
3034
-
3035
- mountPoint = function (file) {
3036
- return pify(df.file, Promise)(file).then(function (data) {
3037
- return data.mountpoint;
3038
- });
3039
- };
3040
- return mountPoint;
3041
- }
3042
-
3043
- var osHomedir;
3044
- var hasRequiredOsHomedir;
3045
-
3046
- function requireOsHomedir () {
3047
- if (hasRequiredOsHomedir) return osHomedir;
3048
- hasRequiredOsHomedir = 1;
3049
- var os = require$$0$2;
3050
-
3051
- function homedir() {
3052
- var env = process.env;
3053
- var home = env.HOME;
3054
- var user = env.LOGNAME || env.USER || env.LNAME || env.USERNAME;
3055
-
3056
- if (process.platform === 'win32') {
3057
- return env.USERPROFILE || env.HOMEDRIVE + env.HOMEPATH || home || null;
3058
- }
3059
-
3060
- if (process.platform === 'darwin') {
3061
- return home || (user ? '/Users/' + user : null);
3062
- }
3063
-
3064
- if (process.platform === 'linux') {
3065
- return home || (process.getuid() === 0 ? '/root' : (user ? '/home/' + user : null));
3066
- }
3067
-
3068
- return home || null;
3069
- }
3070
-
3071
- osHomedir = typeof os.homedir === 'function' ? os.homedir : homedir;
3072
- return osHomedir;
3073
- }
3074
-
3075
- var userHome;
3076
- var hasRequiredUserHome;
3077
-
3078
- function requireUserHome () {
3079
- if (hasRequiredUserHome) return userHome;
3080
- hasRequiredUserHome = 1;
3081
- userHome = requireOsHomedir()();
3082
- return userHome;
3083
- }
3084
-
3085
- var xdgBasedir = {};
3086
-
3087
- var hasRequiredXdgBasedir;
3088
-
3089
- function requireXdgBasedir () {
3090
- if (hasRequiredXdgBasedir) return xdgBasedir;
3091
- hasRequiredXdgBasedir = 1;
3092
- (function (exports) {
3093
- const os = require$$0$2;
3094
- const path = sysPath;
3095
-
3096
- const homeDirectory = os.homedir();
3097
- const {env} = process;
3098
-
3099
- exports.data = env.XDG_DATA_HOME ||
3100
- (homeDirectory ? path.join(homeDirectory, '.local', 'share') : undefined);
3101
-
3102
- exports.config = env.XDG_CONFIG_HOME ||
3103
- (homeDirectory ? path.join(homeDirectory, '.config') : undefined);
3104
-
3105
- exports.cache = env.XDG_CACHE_HOME || (homeDirectory ? path.join(homeDirectory, '.cache') : undefined);
3106
-
3107
- exports.runtime = env.XDG_RUNTIME_DIR || undefined;
3108
-
3109
- exports.dataDirs = (env.XDG_DATA_DIRS || '/usr/local/share/:/usr/share/').split(':');
3110
-
3111
- if (exports.data) {
3112
- exports.dataDirs.unshift(exports.data);
3113
- }
3114
-
3115
- exports.configDirs = (env.XDG_CONFIG_DIRS || '/etc/xdg').split(':');
3116
-
3117
- if (exports.config) {
3118
- exports.configDirs.unshift(exports.config);
3119
- }
3120
- } (xdgBasedir));
3121
- return xdgBasedir;
3122
- }
3123
-
3124
- var hasRequiredXdgTrashdir;
3125
-
3126
- function requireXdgTrashdir () {
3127
- if (hasRequiredXdgTrashdir) return xdgTrashdir$1.exports;
3128
- hasRequiredXdgTrashdir = 1;
3129
- const fs = require$$0.promises;
3130
- const path = sysPath;
3131
- const df = requireDf$1();
3132
- const mountPoint = requireMountPoint();
3133
- const userHome = requireUserHome();
3134
- const xdgBasedir = requireXdgBasedir();
3135
-
3136
- const check = async filePath => {
3137
- const topuid = `${filePath}-${process.getuid()}`;
3138
- const stickyBitMode = 17407;
3139
-
3140
- try {
3141
- const stats = await fs.lstat(filePath);
3142
-
3143
- if (stats.isSymbolicLink() || stats.mode !== stickyBitMode) {
3144
- return topuid;
3145
- }
3146
-
3147
- return path.join(filePath, String(process.getuid()));
3148
- } catch (error) {
3149
- if (error.code === 'ENOENT') {
3150
- return topuid;
3151
- }
3152
-
3153
- return path.join(xdgBasedir.data, 'Trash');
3154
- }
3155
- };
3156
-
3157
- xdgTrashdir$1.exports = async filePath => {
3158
- if (process.platform !== 'linux') {
3159
- return Promise.reject(new Error('Only Linux systems are supported'));
3160
- }
3161
-
3162
- if (!filePath) {
3163
- return Promise.resolve(path.join(xdgBasedir.data, 'Trash'));
3164
- }
3165
-
3166
- const [homeMountPoint, fileMountPoint] = await Promise.all([
3167
- mountPoint(userHome),
3168
- // Ignore errors in case `file` is a dangling symlink
3169
- mountPoint(filePath).catch(() => {})
3170
- ]);
3171
-
3172
- if (!fileMountPoint || fileMountPoint === homeMountPoint) {
3173
- return path.join(xdgBasedir.data, 'Trash');
3174
- }
3175
-
3176
- return check(path.join(fileMountPoint, '.Trash'));
3177
- };
3178
-
3179
- xdgTrashdir$1.exports.all = async () => {
3180
- if (process.platform !== 'linux') {
3181
- return Promise.reject(new Error('Only Linux systems are supported'));
3182
- }
3183
-
3184
- return Promise.all((await df()).map(fileSystem => {
3185
- if (fileSystem.mountpoint === '/') {
3186
- return path.join(xdgBasedir.data, 'Trash');
3187
- }
3188
-
3189
- return check(path.join(fileSystem.mountpoint, '.Trash'));
3190
- }));
3191
- };
3192
- return xdgTrashdir$1.exports;
3193
- }
3194
-
3195
- var xdgTrashdirExports = requireXdgTrashdir();
3196
- const xdgTrashdir = /*@__PURE__*/getDefaultExportFromCjs(xdgTrashdirExports);
3197
-
3198
- async function pMap(
3199
- iterable,
3200
- mapper,
3201
- {
3202
- concurrency = Number.POSITIVE_INFINITY,
3203
- stopOnError = true,
3204
- signal,
3205
- } = {},
3206
- ) {
3207
- return new Promise((resolve_, reject_) => {
3208
- if (iterable[Symbol.iterator] === undefined && iterable[Symbol.asyncIterator] === undefined) {
3209
- throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
3210
- }
3211
-
3212
- if (typeof mapper !== 'function') {
3213
- throw new TypeError('Mapper function is required');
3214
- }
3215
-
3216
- if (!((Number.isSafeInteger(concurrency) && concurrency >= 1) || concurrency === Number.POSITIVE_INFINITY)) {
3217
- throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
3218
- }
3219
-
3220
- const result = [];
3221
- const errors = [];
3222
- const skippedIndexesMap = new Map();
3223
- let isRejected = false;
3224
- let isResolved = false;
3225
- let isIterableDone = false;
3226
- let resolvingCount = 0;
3227
- let currentIndex = 0;
3228
- const iterator = iterable[Symbol.iterator] === undefined ? iterable[Symbol.asyncIterator]() : iterable[Symbol.iterator]();
3229
-
3230
- const signalListener = () => {
3231
- reject(signal.reason);
3232
- };
3233
-
3234
- const cleanup = () => {
3235
- signal?.removeEventListener('abort', signalListener);
3236
- };
3237
-
3238
- const resolve = value => {
3239
- resolve_(value);
3240
- cleanup();
3241
- };
3242
-
3243
- const reject = reason => {
3244
- isRejected = true;
3245
- isResolved = true;
3246
- reject_(reason);
3247
- cleanup();
3248
- };
3249
-
3250
- if (signal) {
3251
- if (signal.aborted) {
3252
- reject(signal.reason);
3253
- }
3254
-
3255
- signal.addEventListener('abort', signalListener, {once: true});
3256
- }
3257
-
3258
- const next = async () => {
3259
- if (isResolved) {
3260
- return;
3261
- }
3262
-
3263
- const nextItem = await iterator.next();
3264
-
3265
- const index = currentIndex;
3266
- currentIndex++;
3267
-
3268
- // Note: `iterator.next()` can be called many times in parallel.
3269
- // This can cause multiple calls to this `next()` function to
3270
- // receive a `nextItem` with `done === true`.
3271
- // The shutdown logic that rejects/resolves must be protected
3272
- // so it runs only one time as the `skippedIndex` logic is
3273
- // non-idempotent.
3274
- if (nextItem.done) {
3275
- isIterableDone = true;
3276
-
3277
- if (resolvingCount === 0 && !isResolved) {
3278
- if (!stopOnError && errors.length > 0) {
3279
- reject(new AggregateError(errors)); // eslint-disable-line unicorn/error-message
3280
- return;
3281
- }
3282
-
3283
- isResolved = true;
3284
-
3285
- if (skippedIndexesMap.size === 0) {
3286
- resolve(result);
3287
- return;
3288
- }
3289
-
3290
- const pureResult = [];
3291
-
3292
- // Support multiple `pMapSkip`'s.
3293
- for (const [index, value] of result.entries()) {
3294
- if (skippedIndexesMap.get(index) === pMapSkip) {
3295
- continue;
3296
- }
3297
-
3298
- pureResult.push(value);
3299
- }
3300
-
3301
- resolve(pureResult);
3302
- }
3303
-
3304
- return;
3305
- }
3306
-
3307
- resolvingCount++;
3308
-
3309
- // Intentionally detached
3310
- (async () => {
3311
- try {
3312
- const element = await nextItem.value;
3313
-
3314
- if (isResolved) {
3315
- return;
3316
- }
3317
-
3318
- const value = await mapper(element, index);
3319
-
3320
- // Use Map to stage the index of the element.
3321
- if (value === pMapSkip) {
3322
- skippedIndexesMap.set(index, value);
3323
- }
3324
-
3325
- result[index] = value;
3326
-
3327
- resolvingCount--;
3328
- await next();
3329
- } catch (error) {
3330
- if (stopOnError) {
3331
- reject(error);
3332
- } else {
3333
- errors.push(error);
3334
- resolvingCount--;
3335
-
3336
- // In that case we can't really continue regardless of `stopOnError` state
3337
- // since an iterable is likely to continue throwing after it throws once.
3338
- // If we continue calling `next()` indefinitely we will likely end up
3339
- // in an infinite loop of failed iteration.
3340
- try {
3341
- await next();
3342
- } catch (error) {
3343
- reject(error);
3344
- }
3345
- }
3346
- }
3347
- })();
3348
- };
3349
-
3350
- // Create the concurrent runners in a detached (non-awaited)
3351
- // promise. We need this so we can await the `next()` calls
3352
- // to stop creating runners before hitting the concurrency limit
3353
- // if the iterable has already been marked as done.
3354
- // NOTE: We *must* do this for async iterators otherwise we'll spin up
3355
- // infinite `next()` calls by default and never start the event loop.
3356
- (async () => {
3357
- for (let index = 0; index < concurrency; index++) {
3358
- try {
3359
- // eslint-disable-next-line no-await-in-loop
3360
- await next();
3361
- } catch (error) {
3362
- reject(error);
3363
- break;
3364
- }
3365
-
3366
- if (isIterableDone || isRejected) {
3367
- break;
3368
- }
3369
- }
3370
- })();
3371
- });
3372
- }
3373
-
3374
- const pMapSkip = Symbol('skip');
3375
-
3376
- var procfsError;
3377
- var hasRequiredProcfsError;
3378
-
3379
- function requireProcfsError () {
3380
- if (hasRequiredProcfsError) return procfsError;
3381
- hasRequiredProcfsError = 1;
3382
- class ProcfsError extends Error {
3383
- constructor(code, message, sourceError) {
3384
- super(message);
3385
- this.name = 'ProcfsError';
3386
- this.code = code;
3387
- if (sourceError !== undefined) {
3388
- this.sourceError = sourceError;
3389
- }
3390
- }
3391
- }
3392
-
3393
- ProcfsError.ERR_PARSING_FAILED = 'EPARSE';
3394
- ProcfsError.ERR_UNKNOWN = 'EUNKNOWN';
3395
- ProcfsError.ERR_NOT_FOUND = 'ENOENT';
3396
-
3397
- ProcfsError.parsingError = (src, msg) => {
3398
- let e = new ProcfsError(ProcfsError.ERR_PARSING_FAILED, `Parsing failed: ${msg}`);
3399
- e.sourceText = src;
3400
- return e;
3401
- };
3402
-
3403
- ProcfsError.generic = err => {
3404
- /* istanbul ignore next should not ever happen */
3405
- if (err instanceof ProcfsError) {
3406
- return err;
3407
- }
3408
-
3409
- switch (err.code) {
3410
- case 'ENOENT':
3411
- return new ProcfsError(ProcfsError.ERR_NOT_FOUND, 'File not found', err);
3412
- /* istanbul ignore next should not ever happen*/
3413
- default:
3414
- return new ProcfsError(ProcfsError.ERR_UNKNOWN, `Unknown error: ${err.message}`, err);
3415
- }
3416
- };
3417
-
3418
- procfsError = ProcfsError;
3419
- return procfsError;
3420
- }
3421
-
3422
- var parsers_1;
3423
- var hasRequiredParsers;
3424
-
3425
- function requireParsers () {
3426
- if (hasRequiredParsers) return parsers_1;
3427
- hasRequiredParsers = 1;
3428
- const trim = str => str.trim();
3429
-
3430
- class Parsers {}
3431
-
3432
- const parsers = new Parsers();
3433
-
3434
- for (let name of [
3435
- 'cgroups',
3436
- 'config',
3437
- 'cpuinfo',
3438
- 'devices',
3439
- 'diskstats',
3440
- 'filesystems',
3441
- 'loadavg',
3442
- 'meminfo',
3443
- 'partitions',
3444
- 'processAutogroup',
3445
- 'processCgroups',
3446
- 'processCmdline',
3447
- 'processEnviron',
3448
- 'processes',
3449
- 'processExe',
3450
- 'processFd',
3451
- 'processFdinfo',
3452
- 'processFds',
3453
- 'processGidMap',
3454
- 'processIo',
3455
- 'processLimits',
3456
- 'processMountinfo',
3457
- 'processNetDev',
3458
- 'processNetTcp4',
3459
- 'processNetTcp6',
3460
- 'processNetUdp4',
3461
- 'processNetUdp6',
3462
- 'processNetUnix',
3463
- 'processNetWireless',
3464
- 'processStat',
3465
- 'processStatm',
3466
- 'processStatus',
3467
- 'processThreads',
3468
- 'processUidMap',
3469
- 'stat',
3470
- 'swaps',
3471
- 'uptime',
3472
- ]) {
3473
- Object.defineProperty(Parsers.prototype, name, {
3474
- get: function () { // eslint-disable-line object-shorthand
3475
- let value = commonjsRequire(`./parsers/${name}`);
3476
- Object.defineProperty(this, name, {value});
3477
- return value;
3478
- },
3479
- });
3480
- }
3481
-
3482
- parsers.cmdline = trim;
3483
- parsers.processComm = trim;
3484
- parsers.processCpuset = trim;
3485
- parsers.processOomScore = src => parseInt(src);
3486
- parsers.processTimerslackNs = src => parseInt(src);
3487
- parsers.version = trim;
3488
- parsers.processCwd = src => src;
3489
- parsers.processPersonality = src => parseInt(src, 16);
3490
-
3491
- parsers_1 = parsers;
3492
- return parsers_1;
3493
- }
3494
-
3495
- var utils;
3496
- var hasRequiredUtils;
3497
-
3498
- function requireUtils () {
3499
- if (hasRequiredUtils) return utils;
3500
- hasRequiredUtils = 1;
3501
- const {
3502
- readlinkSync,
3503
- readdirSync,
3504
- openSync,
3505
- readSync,
3506
- closeSync,
3507
- readFileSync,
3508
- existsSync,
3509
- } = require$$0;
3510
-
3511
- const tmpBufMinLen = 4096 * 2;
3512
- const tmpBufMaxLen = 4096 * 8;
3513
-
3514
- let tmpBuf = Buffer.allocUnsafeSlow(tmpBufMinLen);
3515
-
3516
- const read = path => {
3517
- const fd = openSync(path, 'r', 0o666);
3518
- let pos = 0;
3519
- let bytesRead;
3520
- let buf = tmpBuf;
3521
- let length = buf.length;
3522
- do {
3523
- bytesRead = readSync(fd, buf, pos, buf.length - pos, null);
3524
- pos += bytesRead;
3525
- if (pos === tmpBuf.length) {
3526
- length = length << 1;
3527
- let newBuf = Buffer.allocUnsafeSlow(length);
3528
-
3529
- if (length <= tmpBufMaxLen) {
3530
- tmpBuf = newBuf;
3531
- }
3532
-
3533
- buf.copy(newBuf);
3534
- buf = newBuf;
3535
- }
3536
- } while (bytesRead !== 0);
3537
- closeSync(fd);
3538
- return buf.toString('utf8', 0, pos);
3539
- };
3540
-
3541
- const readIdList = path => {
3542
- let ls = readdirSync(path);
3543
- for (let i = 0; i < ls.length; i++) {
3544
- ls[i] = parseInt(ls[i]);
3545
- }
3546
- return ls;
3547
- };
3548
-
3549
- const readBuffer = readFileSync;
3550
- const exists = existsSync;
3551
- const readdir = readdirSync;
3552
-
3553
- const devIdGetMinor = devId => (((devId >> 20) << 8) | (devId & 0xFF));
3554
- const devIdGetMajor = devId => ((devId >> 8) & 0xFF);
3555
- const devIdFromMajorMinor = (major, minor) => (((minor >> 8) << 20) | ((major & 0xFF) << 8) | (minor & 0xFF));
3556
-
3557
- utils = {
3558
- read,
3559
- readLink: readlinkSync,
3560
- readIdList,
3561
- readBuffer,
3562
- exists,
3563
- readdir,
3564
-
3565
- devIdGetMinor,
3566
- devIdGetMajor,
3567
- devIdFromMajorMinor,
3568
- };
3569
- return utils;
3570
- }
3571
-
3572
- var procfs_1;
3573
- var hasRequiredProcfs;
3574
-
3575
- function requireProcfs () {
3576
- if (hasRequiredProcfs) return procfs_1;
3577
- hasRequiredProcfs = 1;
3578
- const ProcfsError = requireProcfsError();
3579
- const parsers = requireParsers();
3580
- const {
3581
- read,
3582
- readLink,
3583
- readBuffer,
3584
- readdir,
3585
- devIdGetMinor,
3586
- devIdGetMajor,
3587
- devIdFromMajorMinor,
3588
- } = requireUtils();
3589
-
3590
- class Procfs {
3591
- constructor(root) {
3592
- if (root === undefined) {
3593
- root = '/proc';
3594
- }
3595
- this.root = root;
3596
- this.rootSlash = `${root}/`;
3597
- }
3598
-
3599
- processes() {
3600
- try {
3601
- return parsers.processes(readdir(this.root));
3602
- } catch (error) {
3603
- /* istanbul ignore next should not ever happen when procfs exists */
3604
- throw ProcfsError.generic(error);
3605
- }
3606
- }
3607
-
3608
- processFds(pid) {
3609
- if (pid !== undefined && (!Number.isInteger(pid) || pid <= 0)) {
3610
- throw new TypeError('pid');
3611
- }
3612
- try {
3613
- return parsers.processFds(readdir(`${this.rootSlash}${pid === undefined ? 'self' : pid}/fd`));
3614
- } catch (error) {
3615
- throw ProcfsError.generic(error);
3616
- }
3617
- }
3618
-
3619
- processThreads(pid) {
3620
- if (pid !== undefined && (!Number.isInteger(pid) || pid <= 0)) {
3621
- throw new TypeError('pid');
3622
- }
3623
- try {
3624
- return parsers.processThreads(readdir(`${this.rootSlash}${pid === undefined ? 'self' : pid}/task`));
3625
- } catch (error) {
3626
- throw ProcfsError.generic(error);
3627
- }
3628
- }
3629
-
3630
- processFdinfo(fd, pid) {
3631
- if (pid !== undefined && !(Number.isInteger(pid) && pid >= 0)) {
3632
- throw new TypeError('pid');
3633
- }
3634
- if (!Number.isInteger(fd) || fd <= 0) {
3635
- throw new TypeError('fd');
3636
- }
3637
- try {
3638
- return parsers.processFdinfo(read(`${this.rootSlash}${pid === undefined ? 'self' : pid}/fdinfo/${fd}`));
3639
- } catch (error) {
3640
- throw ProcfsError.generic(error);
3641
- }
3642
- }
3643
-
3644
- processFd(fd, pid) {
3645
- if (pid !== undefined && !(Number.isInteger(pid) && pid >= 0)) {
3646
- throw new TypeError('pid');
3647
- }
3648
- if (!Number.isInteger(fd) || fd <= 0) {
3649
- throw new TypeError('fd');
3650
- }
3651
- try {
3652
- return parsers.processFd(readLink(`${this.rootSlash}${pid === undefined ? 'self' : pid}/fd/${fd}`));
3653
- } catch (error) {
3654
- throw ProcfsError.generic(error);
3655
- }
3656
- }
3657
-
3658
- config() {
3659
- try {
3660
- return parsers.config(readBuffer(`${this.rootSlash}config.gz`));
3661
- } catch (error) {
3662
- /* istanbul ignore next should not ever happen when procfs exists and kernel properly configured */
3663
- throw ProcfsError.generic(error);
3664
- }
3665
- }
3666
- }
3667
-
3668
- Procfs.prototype.devIdGetMinor = devIdGetMinor;
3669
- Procfs.prototype.devIdGetMajor = devIdGetMajor;
3670
- Procfs.prototype.devIdFromMajorMinor = devIdFromMajorMinor;
3671
-
3672
- for (let [name, path] of [
3673
- ['processExe', '/exe'],
3674
- ['processCwd', '/cwd'],
3675
- ]) {
3676
- Procfs.prototype[name] = function (pid) {
3677
- if (pid !== undefined && !(Number.isInteger(pid) && pid >= 0)) {
3678
- throw new TypeError('pid');
3679
- }
3680
- try {
3681
- return parsers[name](readLink(`${this.rootSlash}${pid === undefined ? 'self' : pid}${path}`));
3682
- } catch (error) {
3683
- throw ProcfsError.generic(error);
3684
- }
3685
- };
3686
- }
3687
-
3688
- for (let [name, path] of [
3689
- ['processMountinfo', '/mountinfo'],
3690
- ['processIo', '/io'],
3691
- ['processUidMap', '/uid_map'],
3692
- ['processGidMap', '/gid_map'],
3693
- ['processEnviron', '/environ'],
3694
- ['processOomScore', '/oom_score'],
3695
- ['processTimerslackNs', '/timerslack_ns'],
3696
- ['processCmdline', '/cmdline'],
3697
- ['processAutogroup', '/autogroup'],
3698
- ['processStatm', '/statm'],
3699
- ['processComm', '/comm'],
3700
- ['processPersonality', '/personality'],
3701
- ['processCgroups', '/cgroup'],
3702
- ['processCpuset', '/cpuset'],
3703
- ['processLimits', '/limits'],
3704
- ['processStat', '/stat'],
3705
- ['processStatus', '/status'],
3706
- ['processNetDev', '/net/dev'],
3707
- ['processNetWireless', '/net/wireless'],
3708
- ['processNetUnix', '/net/unix'],
3709
- ['processNetTcp4', '/net/tcp'],
3710
- ['processNetTcp6', '/net/tcp6'],
3711
- ['processNetUdp4', '/net/udp'],
3712
- ['processNetUdp6', '/net/udp6'],
3713
- ]) {
3714
- Procfs.prototype[name] = function (pid) {
3715
- if (pid !== undefined && !(Number.isInteger(pid) && pid >= 0)) {
3716
- throw new TypeError('pid');
3717
- }
3718
- try {
3719
- return parsers[name](read(`${this.rootSlash}${pid === undefined ? 'self' : pid}${path}`));
3720
- } catch (error) {
3721
- throw ProcfsError.generic(error);
3722
- }
3723
- };
3724
- }
3725
-
3726
- for (let name of [
3727
- 'cpuinfo',
3728
- 'loadavg',
3729
- 'uptime',
3730
- 'version',
3731
- 'cmdline',
3732
- 'swaps',
3733
- 'stat',
3734
- 'devices',
3735
- 'filesystems',
3736
- 'diskstats',
3737
- 'partitions',
3738
- 'meminfo',
3739
- 'cgroups',
3740
- ]) {
3741
- Procfs.prototype[name] = function () {
3742
- try {
3743
- return parsers[name](read(this.rootSlash + name));
3744
- } catch (error) {
3745
- /* istanbul ignore next should not ever happen when procfs exists */
3746
- throw ProcfsError.generic(error);
3747
- }
3748
- };
3749
- }
3750
-
3751
- for (let [name, parser, path] of [
3752
- ['netDev', 'processNetDev', 'net/dev'],
3753
- ['netWireless', 'processNetWireless', 'net/wireless'],
3754
- ['netUnix', 'processNetUnix', 'net/unix'],
3755
- ['netTcp4', 'processNetTcp4', 'net/tcp'],
3756
- ['netTcp6', 'processNetTcp6', 'net/tcp6'],
3757
- ['netUdp4', 'processNetUdp4', 'net/udp'],
3758
- ['netUdp6', 'processNetUdp6', 'net/udp6'],
3759
- ]) {
3760
- Procfs.prototype[name] = function () {
3761
- try {
3762
- return parsers[parser](read(this.rootSlash + path));
3763
- } catch (error) {
3764
- /* istanbul ignore next should not ever happen when procfs exists */
3765
- throw ProcfsError.generic(error);
3766
- }
3767
- };
3768
- }
3769
-
3770
- const procfs = new Procfs();
3771
- procfs_1 = {
3772
- procfs,
3773
- Procfs,
3774
- ProcfsError,
3775
- };
3776
- return procfs_1;
3777
- }
3778
-
3779
- var procfsExports = requireProcfs();
3780
-
3781
- // Educated guess, values of 16 to 64 seem to be optimal for modern SSD, 8-16 and 64-128 can be a bit slower.
3782
- // We should be ok as long as ssdCount <= cpuCount <= ssdCount*16.
3783
- // For slower media this is not as important and we rely on OS handling it for us.
3784
- const concurrency = os__default.availableParallelism() * 8;
3785
-
3786
- const formatDate = date => {
3787
- const pad = n => String(n).padStart(2, '0');
3788
- return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
3789
- };
3790
-
3791
- const trash = async (filePath, {filesPath, infoPath}) => {
3792
- const name = randomUUID();
3793
- const destination = path__default.join(filesPath, name);
3794
- const trashInfoPath = path__default.join(infoPath, `${name}.trashinfo`);
3795
-
3796
- const trashInfo = [
3797
- '[Trash Info]',
3798
- `Path=${encodeURI(filePath)}`,
3799
- `DeletionDate=${formatDate(new Date())}`,
3800
- ].join('\n');
3801
-
3802
- await fs__default.promises.writeFile(trashInfoPath, trashInfo);
3803
- await moveFile(filePath, destination);
3804
-
3805
- return {
3806
- path: destination,
3807
- info: trashInfoPath,
3808
- };
3809
- };
3810
-
3811
- async function linux(paths) {
3812
- const mountPointMap = new Map();
3813
-
3814
- for (const mountInfo of Object.values(procfsExports.procfs.processMountinfo())) {
3815
- // Filter out irrelevant drives
3816
- if (/^\/(snap|var\/snap|run|sys|proc|dev)($|\/)/.test(mountInfo.mountPoint)) {
3817
- continue;
3818
- }
3819
-
3820
- // Keep the first one if there are multiple `devId`.
3821
- if (!mountPointMap.has(mountInfo.devId)) {
3822
- mountPointMap.set(mountInfo.devId, mountInfo.mountPoint);
3823
- }
3824
- }
3825
-
3826
- // Get the home directory's device ID to handle systems like NixOS where
3827
- // multiple mount points (e.g., /nix/store and /home) share the same device ID.
3828
- // Per XDG spec, files on the same device as home should use ~/.local/share/Trash.
3829
- const homeStats = await fs__default.promises.lstat(os__default.homedir());
3830
- const homeDevId = homeStats.dev;
3831
-
3832
- const trashPathsCache = new Map();
3833
-
3834
- const getDeviceTrashPaths = async deviceId => {
3835
- let trashPathsPromise = trashPathsCache.get(deviceId);
3836
- if (!trashPathsPromise) {
3837
- trashPathsPromise = (async () => {
3838
- // For files on the same device as home, always use home trash.
3839
- // When xdgTrashdir is called without argument, it returns ~/.local/share/Trash.
3840
- const mountPoint = deviceId === homeDevId ? undefined : mountPointMap.get(deviceId);
3841
- const trashPath = await xdgTrashdir(mountPoint);
3842
- const paths = {
3843
- filesPath: path__default.join(trashPath, 'files'),
3844
- infoPath: path__default.join(trashPath, 'info'),
3845
- };
3846
- await fs__default.promises.mkdir(paths.filesPath, {mode: 0o700, recursive: true});
3847
- await fs__default.promises.mkdir(paths.infoPath, {mode: 0o700, recursive: true});
3848
- return paths;
3849
- })();
3850
- trashPathsCache.set(deviceId, trashPathsPromise);
3851
- }
3852
-
3853
- return trashPathsPromise;
3854
- };
3855
-
3856
- return pMap(paths, async filePath => {
3857
- const stats = await fs__default.promises.lstat(filePath);
3858
- const trashPaths = await getDeviceTrashPaths(stats.dev);
3859
- return trash(filePath, trashPaths);
3860
- }, {concurrency});
3861
- }
3862
-
3863
- export { linux as default };