binary-collections 2.0.11 → 2.0.13

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 (330) hide show
  1. package/binaries/binary-executor.cjs +89 -13
  2. package/binaries/clean-nodemodule.cjs +89 -13
  3. package/binaries/clean-nodemodules.cjs +89 -13
  4. package/binaries/dev.cjs +89 -13
  5. package/binaries/empty.cjs +89 -13
  6. package/binaries/git-reduce-size.cjs +89 -13
  7. package/binaries/javakill.cjs +89 -13
  8. package/binaries/kill-process.cjs +89 -13
  9. package/binaries/nodekill.cjs +89 -13
  10. package/binaries/prod.cjs +89 -13
  11. package/binaries/py.cjs +89 -13
  12. package/binaries/rmfind.cjs +89 -13
  13. package/binaries/rmx +15 -1
  14. package/binaries/rmx.cjs +89 -13
  15. package/binaries/rmx.cmd +12 -0
  16. package/binaries/submodule-token.cjs +89 -13
  17. package/binaries/test-cjs +9 -1
  18. package/binaries/test-cjs.cjs +89 -13
  19. package/binaries/test-cjs.cmd +16 -1
  20. package/binaries/test-esm +16 -0
  21. package/binaries/test-esm.cjs +254 -0
  22. package/binaries/test-esm.cmd +23 -0
  23. package/binaries/yarn-clean +1 -1
  24. package/binaries/yarn-clean.cjs +89 -13
  25. package/binaries/yarn-clean.cmd +1 -1
  26. package/binaries/yarn-clean.py +33 -15
  27. package/binaries/yc +131 -0
  28. package/binaries/yc.cjs +254 -0
  29. package/binaries/ycw +256 -0
  30. package/binaries/ycw.cjs +254 -0
  31. package/docs-src/binary-collections.md +34 -0
  32. package/docs-src/changelog.md +26 -0
  33. package/docs-src/clean-github-actions-caches.md +91 -2
  34. package/docs-src/copy-move-file.md +59 -0
  35. package/docs-src/del-gradle.md +17 -0
  36. package/docs-src/del-ps.md +28 -0
  37. package/docs-src/downloader.md +62 -0
  38. package/docs-src/env-helpers.md +29 -0
  39. package/docs-src/find-node-modules.md +17 -0
  40. package/docs-src/git-diff.md +33 -0
  41. package/docs-src/git-fix.md +34 -0
  42. package/docs-src/git-purge.md +17 -0
  43. package/docs-src/git-reduce-size.md +17 -0
  44. package/docs-src/git-undo.md +21 -0
  45. package/docs-src/kill-night-crows.md +26 -0
  46. package/docs-src/node-cache-cleaner.md +182 -0
  47. package/docs-src/node-executor.md +50 -0
  48. package/docs-src/node-package-packer.md +48 -0
  49. package/docs-src/npm-run-series.md +43 -0
  50. package/docs-src/package-resolutions-updater.md +22 -0
  51. package/docs-src/php-cs-fixer-staged.md +19 -0
  52. package/docs-src/print-directory-tree.md +35 -0
  53. package/docs-src/print-tarball-tree.md +55 -0
  54. package/docs-src/py.md +19 -0
  55. package/docs-src/remove-module.md +32 -0
  56. package/docs-src/rmfind-rmx.md +21 -0
  57. package/docs-src/rmpath.md +38 -0
  58. package/docs-src/run-by-checksum.md +87 -0
  59. package/docs-src/submodule-install.md +31 -0
  60. package/docs-src/submodule-remove.md +22 -0
  61. package/docs-src/submodule-token.md +17 -0
  62. package/docs-src/test-runners.md +21 -0
  63. package/docs-src/yarn-install.md +31 -0
  64. package/docs-src/yarn-reinstall.md +27 -0
  65. package/lib/binary-collections/config.cjs +126 -0
  66. package/lib/binary-collections/config.mjs +7 -0
  67. package/lib/binary-collections/executeScript.cjs +19 -0
  68. package/lib/binary-collections/executeScript.d.cts +12 -0
  69. package/lib/binary-collections/executeScript.mjs +6 -0
  70. package/lib/binary-collections/findScript.cjs +309 -0
  71. package/lib/binary-collections/findScript.d.cts +12 -0
  72. package/lib/binary-collections/findScript.mjs +7 -0
  73. package/lib/binary-collections/listScript.cjs +291 -0
  74. package/lib/binary-collections/listScript.d.cts +19 -0
  75. package/lib/binary-collections/listScript.mjs +7 -0
  76. package/lib/binary-collections.cjs +264 -157
  77. package/lib/binary-collections.mjs +26 -286
  78. package/lib/changelog.cjs +9 -14
  79. package/lib/changelog.mjs +2 -2
  80. package/lib/chunk-2MN4VPV2.mjs +246 -0
  81. package/lib/chunk-6C7KTYGZ.mjs +41 -0
  82. package/lib/{chunk-Z6JLYU2J.mjs → chunk-6RK5UCTP.mjs} +7 -12
  83. package/lib/chunk-CD3HF3LK.mjs +190 -0
  84. package/lib/chunk-FLYSZFLW.mjs +61 -0
  85. package/lib/{chunk-N436BNBK.mjs → chunk-GAGABICI.mjs} +19 -13
  86. package/lib/chunk-H44UWUFY.mjs +105 -0
  87. package/lib/chunk-KLKAIFKI.mjs +40 -0
  88. package/lib/chunk-LVSPEFU2.mjs +86 -0
  89. package/lib/{chunk-RWLXRTYP.mjs → chunk-MGPYPKIE.mjs} +2 -2
  90. package/lib/chunk-NGFK3EYW.mjs +28 -0
  91. package/lib/chunk-NQXUYO67.mjs +253 -0
  92. package/lib/chunk-NVEG3LEZ.mjs +143 -0
  93. package/lib/chunk-OBXLTXFJ.mjs +34 -0
  94. package/lib/chunk-OGXVGBRI.mjs +29 -0
  95. package/lib/chunk-OXV52GD5.mjs +62 -0
  96. package/lib/chunk-PXBMHE7O.mjs +35 -0
  97. package/lib/chunk-QD4T255Z.mjs +40 -0
  98. package/lib/chunk-QII2EKCS.mjs +26 -0
  99. package/lib/chunk-R5FJOR63.mjs +47 -0
  100. package/lib/chunk-RDGDLSPD.mjs +76 -0
  101. package/lib/chunk-RDN6HF5Z.mjs +79 -0
  102. package/lib/chunk-RJKTSUAX.mjs +123 -0
  103. package/lib/{chunk-XA3SNBPA.mjs → chunk-TBWXE7ST.mjs} +97 -38
  104. package/lib/chunk-UXCFNAR6.mjs +55 -0
  105. package/lib/{chunk-M3YIYRHT.mjs → chunk-UY5VUEA3.mjs} +1 -1
  106. package/lib/chunk-WSHVPGNM.mjs +44 -0
  107. package/lib/{chunk-66PAU5PS.mjs → chunk-X2B3X7D4.mjs} +10 -6
  108. package/lib/clean-github-actions-caches-cli.cjs +507 -0
  109. package/lib/clean-github-actions-caches-cli.mjs +74 -0
  110. package/lib/clean-github-actions-caches.cjs +246 -106
  111. package/lib/clean-github-actions-caches.d.cts +53 -1
  112. package/lib/clean-github-actions-caches.mjs +5 -130
  113. package/lib/cross-env/command.cjs +63 -0
  114. package/lib/cross-env/command.d.ts +8 -0
  115. package/lib/cross-env/command.js +45 -0
  116. package/lib/{ps/isWin.mjs → cross-env/command.mjs} +4 -5
  117. package/lib/cross-env/index.cjs +178 -0
  118. package/lib/cross-env/index.d.ts +8 -0
  119. package/lib/cross-env/index.js +102 -0
  120. package/lib/cross-env/index.mjs +101 -0
  121. package/lib/cross-env/variable.cjs +60 -0
  122. package/lib/cross-env/variable.d.ts +7 -0
  123. package/lib/cross-env/variable.js +59 -0
  124. package/lib/cross-env/variable.mjs +9 -0
  125. package/lib/del-gradle.cjs +8 -13
  126. package/lib/del-gradle.js +8 -8
  127. package/lib/del-gradle.mjs +1 -1
  128. package/lib/del-node-modules.cjs +185 -3
  129. package/lib/del-node-modules.js +25 -25
  130. package/lib/del-node-modules.mjs +6 -3
  131. package/lib/{del-ps.cjs → del-ps-cli.cjs} +38 -43
  132. package/lib/del-ps-cli.d.mts +1 -0
  133. package/lib/del-ps-cli.mjs +44 -0
  134. package/lib/del-yarn-caches.cjs +8 -13
  135. package/lib/del-yarn-caches.js +2 -2
  136. package/lib/del-yarn-caches.mjs +1 -1
  137. package/lib/downloader-cli.cjs +256 -0
  138. package/lib/downloader-cli.d.cts +2 -0
  139. package/lib/downloader-cli.mjs +90 -0
  140. package/lib/file/copy-cli.cjs +273 -0
  141. package/lib/file/copy-cli.d.mts +1 -0
  142. package/lib/file/copy-cli.mjs +59 -0
  143. package/lib/file/copy.cjs +56 -0
  144. package/lib/file/copy.d.mts +1 -0
  145. package/lib/file/copy.mjs +8 -0
  146. package/lib/file/move-cli.cjs +272 -0
  147. package/lib/file/move-cli.d.mts +1 -0
  148. package/lib/file/move-cli.mjs +59 -0
  149. package/lib/file/move.cjs +55 -0
  150. package/lib/file/move.d.mts +1 -0
  151. package/lib/file/move.mjs +8 -0
  152. package/lib/find-node-modules-cli.cjs +1 -1
  153. package/lib/find-node-modules-cli.js +1 -1
  154. package/lib/find-node-modules-cli.mjs +1 -1
  155. package/lib/find-node-modules.cjs +1 -1
  156. package/lib/find-node-modules.mjs +1 -1
  157. package/lib/free-chatgpt.cjs +27 -26
  158. package/lib/free-chatgpt.js +10 -10
  159. package/lib/free-chatgpt.mjs +2 -2
  160. package/lib/git/user-config.cjs +9 -14
  161. package/lib/git/user-config.mjs +2 -2
  162. package/lib/git-diff-cli.cjs +273 -66
  163. package/lib/git-diff-cli.mjs +5 -4
  164. package/lib/git-diff.cjs +273 -66
  165. package/lib/git-diff.d.ts +2 -1
  166. package/lib/git-diff.js +153 -39
  167. package/lib/git-diff.mjs +5 -4
  168. package/lib/git-fix.cjs +9 -14
  169. package/lib/git-fix.mjs +2 -2
  170. package/lib/git-purge.cjs +9 -14
  171. package/lib/git-purge.mjs +2 -2
  172. package/lib/index.cjs +1 -1
  173. package/lib/index.d.ts +1 -1
  174. package/lib/index.mjs +1 -1
  175. package/lib/kill-night-crows.cjs +7 -7
  176. package/lib/kill-night-crows.mjs +7 -7
  177. package/lib/node-cache-cleaner/npm.cjs +65 -0
  178. package/lib/node-cache-cleaner/npm.d.ts +2 -0
  179. package/lib/node-cache-cleaner/npm.js +41 -0
  180. package/lib/node-cache-cleaner/npm.mjs +10 -0
  181. package/lib/node-cache-cleaner/npx.cjs +89 -0
  182. package/lib/node-cache-cleaner/npx.d.ts +4 -0
  183. package/lib/node-cache-cleaner/npx.js +82 -0
  184. package/lib/{ps/index.d.mjs → node-cache-cleaner/npx.mjs} +6 -5
  185. package/lib/node-cache-cleaner/yarn.cjs +73 -0
  186. package/lib/node-cache-cleaner/yarn.d.ts +2 -0
  187. package/lib/node-cache-cleaner/yarn.js +62 -0
  188. package/lib/node-cache-cleaner/yarn.mjs +10 -0
  189. package/lib/node-cache-cleaner-cli.cjs +365 -0
  190. package/lib/node-cache-cleaner-cli.d.ts +2 -0
  191. package/lib/node-cache-cleaner-cli.js +57 -0
  192. package/lib/node-cache-cleaner-cli.mjs +60 -0
  193. package/lib/node-executor.cjs +272 -0
  194. package/lib/node-executor.d.cts +2 -0
  195. package/lib/node-executor.mjs +106 -0
  196. package/lib/node-package-packer/build-readme.cjs +150 -0
  197. package/lib/node-package-packer/build-readme.d.mts +10 -0
  198. package/lib/node-package-packer/build-readme.mjs +10 -0
  199. package/lib/node-package-packer/build-tarball.cjs +495 -0
  200. package/lib/node-package-packer/build-tarball.d.mts +33 -0
  201. package/lib/node-package-packer/build-tarball.mjs +175 -0
  202. package/lib/node-package-packer-cli.cjs +525 -0
  203. package/lib/node-package-packer-cli.d.mts +1 -0
  204. package/lib/node-package-packer-cli.mjs +34 -0
  205. package/lib/npm-run-series.cjs +28 -40
  206. package/lib/npm-run-series.mjs +21 -7
  207. package/lib/package-resolutions-updater-cli.cjs +255 -173
  208. package/lib/package-resolutions-updater-cli.mjs +19 -40
  209. package/lib/package-resolutions-updater.cjs +244 -141
  210. package/lib/package-resolutions-updater.d.mts +54 -1
  211. package/lib/package-resolutions-updater.mjs +8 -5
  212. package/lib/php-cs-fixer-staged.cjs +1 -1
  213. package/lib/php-cs-fixer-staged.mjs +1 -1
  214. package/lib/print-directory-tree.cjs +18 -20
  215. package/lib/print-directory-tree.mjs +11 -8
  216. package/lib/print-tarball-tree.cjs +262 -0
  217. package/lib/print-tarball-tree.d.mts +1 -0
  218. package/lib/print-tarball-tree.mjs +68 -0
  219. package/lib/ps/connected-domain.js +10 -10
  220. package/lib/ps/index.cjs +11 -11
  221. package/lib/ps/index.mjs +180 -174
  222. package/lib/ps/table-parser.d.ts +3 -4
  223. package/lib/ps/table-parser.js +15 -22
  224. package/lib/remove-module.cjs +19 -24
  225. package/lib/remove-module.mjs +2 -2
  226. package/lib/rm-node-module-cli.cjs +389 -0
  227. package/lib/rm-node-module-cli.d.cts +1 -0
  228. package/lib/rm-node-module-cli.mjs +92 -0
  229. package/lib/rm-node-modules.cjs +127 -0
  230. package/lib/rm-node-modules.d.cts +35 -0
  231. package/lib/{binary-collections-config.mjs → rm-node-modules.mjs} +3 -3
  232. package/lib/rmpath-cli.cjs +285 -0
  233. package/lib/rmpath-cli.d.mts +1 -0
  234. package/lib/rmpath-cli.mjs +23 -0
  235. package/lib/rmpath.cjs +6 -217
  236. package/lib/rmpath.mjs +5 -101
  237. package/lib/run-by-checksum/cache.cjs +69 -0
  238. package/lib/run-by-checksum/cache.d.ts +19 -0
  239. package/lib/run-by-checksum/cache.js +50 -0
  240. package/lib/run-by-checksum/cache.mjs +12 -0
  241. package/lib/run-by-checksum/hash.cjs +72 -0
  242. package/lib/run-by-checksum/hash.d.ts +14 -0
  243. package/lib/run-by-checksum/hash.js +85 -0
  244. package/lib/run-by-checksum/hash.mjs +10 -0
  245. package/lib/run-by-checksum/run.cjs +169 -0
  246. package/lib/run-by-checksum/run.d.ts +22 -0
  247. package/lib/run-by-checksum/run.js +93 -0
  248. package/lib/run-by-checksum/run.mjs +10 -0
  249. package/lib/run-by-checksum-cli.cjs +382 -0
  250. package/lib/run-by-checksum-cli.d.ts +2 -0
  251. package/lib/run-by-checksum-cli.js +43 -0
  252. package/lib/run-by-checksum-cli.mjs +56 -0
  253. package/lib/submodule-install.cjs +55 -47
  254. package/lib/submodule-install.mjs +48 -35
  255. package/lib/submodule-remove-cli.cjs +170 -4
  256. package/lib/submodule-remove-cli.js +5 -5
  257. package/lib/submodule-remove-cli.mjs +6 -4
  258. package/lib/utils/chatgpt.cjs +19 -13
  259. package/lib/utils/chatgpt.js +94 -94
  260. package/lib/utils/chatgpt.mjs +1 -1
  261. package/lib/utils/fetchResponse.cjs +24 -0
  262. package/lib/utils/fetchResponse.d.cts +25 -0
  263. package/lib/utils/fetchResponse.mjs +6 -0
  264. package/lib/utils/findEnvFiles.cjs +28 -46
  265. package/lib/utils/findEnvFiles.d.cts +19 -0
  266. package/lib/utils/findEnvFiles.mjs +3 -5
  267. package/lib/utils/findWorkspaceRoot.js +4 -4
  268. package/lib/utils/index.cjs +7 -12
  269. package/lib/utils/index.d.cts +2 -9
  270. package/lib/utils/index.mjs +1 -1
  271. package/lib/utils/isGithubTokenValid.js +7 -7
  272. package/lib/{ps/isWin.cjs → utils/isWindows.cjs} +12 -7
  273. package/lib/utils/isWindows.d.ts +5 -0
  274. package/lib/utils/isWindows.js +10 -0
  275. package/lib/utils/isWindows.mjs +10 -0
  276. package/lib/utils/runBash.cjs +53 -0
  277. package/lib/utils/runBash.d.cts +12 -0
  278. package/lib/utils/runBash.mjs +66 -0
  279. package/lib/yarn-per-branch-lock-installer.cjs +288 -0
  280. package/lib/yarn-per-branch-lock-installer.d.cts +2 -0
  281. package/lib/yarn-per-branch-lock-installer.mjs +122 -0
  282. package/lib/yarn-reinstall.cjs +8 -13
  283. package/lib/yarn-reinstall.mjs +1 -1
  284. package/package.json +91 -57
  285. package/readme.html +784 -0
  286. package/readme.md +107 -219
  287. package/releases/readme.md +6 -3
  288. package/test/README.md +2 -2
  289. package/test-project/workspaces/workspace-a/readme.md +20 -0
  290. package/test-project/workspaces/workspace-a/release/readme.md +42 -0
  291. package/test-project/workspaces/workspace-a/test/readme.md +12 -0
  292. package/test-project/workspaces/workspace-b/readme.md +94 -0
  293. package/test-project/workspaces/workspace-b/requirements.txt +1 -0
  294. package/test-project/workspaces/workspace-b/themes/hexo-theme-flowbite/readme.md +156 -0
  295. package/tmp/test-repo/README.md +2 -35
  296. package/tmp/test-repo-runChecksum/test-complex-glob/README.md +1 -0
  297. package/tmp/test-repo-runChecksum/test-mixed-args/README.md +1 -0
  298. package/lib/binary-collections-config.cjs +0 -15
  299. package/lib/chunk-2CBJCW7E.mjs +0 -81
  300. package/lib/chunk-4UHL4WVN.mjs +0 -136
  301. package/lib/chunk-6HHJRKFB.mjs +0 -59
  302. package/lib/chunk-6S4NXESK.mjs +0 -26
  303. package/lib/chunk-7XTEJHOE.mjs +0 -193
  304. package/lib/chunk-AJDD5DZM.mjs +0 -109
  305. package/lib/chunk-FCDQGYBF.mjs +0 -136
  306. package/lib/chunk-GEYA2USY.mjs +0 -207
  307. package/lib/chunk-GJTGHXRA.mjs +0 -356
  308. package/lib/chunk-ID2WBTE2.mjs +0 -80
  309. package/lib/chunk-JXFOHKDM.mjs +0 -239
  310. package/lib/chunk-NCXAP7AA.mjs +0 -31
  311. package/lib/chunk-PDSXF5HY.mjs +0 -187
  312. package/lib/chunk-TOIVAQF7.mjs +0 -136
  313. package/lib/chunk-V5SKYJUB.mjs +0 -136
  314. package/lib/chunk-WSRETQCA.mjs +0 -59
  315. package/lib/chunk-YYLIQQKF.mjs +0 -31
  316. package/lib/del-ps.js +0 -32
  317. package/lib/del-ps.mjs +0 -43
  318. package/lib/ps/index.d.cjs +0 -17
  319. package/lib/ps/index.d.ts +0 -2
  320. package/lib/ps/index.js +0 -254
  321. package/lib/ps/isWin.d.ts +0 -2
  322. package/lib/ps/isWin.js +0 -4
  323. package/lib/utils/findEnvFiles.d.ts +0 -8
  324. package/lib/utils/findEnvFiles.js +0 -121
  325. package/test/package.json +0 -20
  326. package/test-project/package.json +0 -16
  327. package/tmp/test-repo/package.json +0 -7
  328. package/tmp/typedoc/readme.md +0 -320
  329. /package/lib/{binary-collections-config.d.cts → binary-collections/config.d.cts} +0 -0
  330. /package/lib/{del-ps.d.ts → clean-github-actions-caches-cli.d.cts} +0 -0
@@ -1,8 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
3
+ import {
4
+ require_findScript
5
+ } from "./chunk-RDN6HF5Z.mjs";
6
+ import {
7
+ require_listScript
8
+ } from "./chunk-FLYSZFLW.mjs";
9
+ import "./chunk-NQXUYO67.mjs";
10
+ import {
11
+ require_executeScript
12
+ } from "./chunk-PXBMHE7O.mjs";
3
13
  import {
4
14
  require_utils
5
- } from "./chunk-Z6JLYU2J.mjs";
15
+ } from "./chunk-6RK5UCTP.mjs";
6
16
  import {
7
17
  __commonJS,
8
18
  __dirname,
@@ -10,237 +20,24 @@ import {
10
20
  init_esm_shims
11
21
  } from "./chunk-QQ4A6DLD.mjs";
12
22
 
13
- // package.json
14
- var require_package = __commonJS({
15
- "package.json"(exports, module) {
16
- module.exports = {
17
- name: "binary-collections",
18
- version: "2.0.11",
19
- description: "Utility to clean any programming caches and more",
20
- keywords: [
21
- "cache",
22
- "cleaner",
23
- "utility"
24
- ],
25
- homepage: "https://www.webmanajemen.com/",
26
- bugs: {
27
- url: "https://github.com/dimaslanjaka/bin/issues"
28
- },
29
- license: "MIT",
30
- author: {
31
- name: "dimaslanjaka",
32
- email: "dimaslanjaka@gmail.com",
33
- url: "https://webmanajemen.com"
34
- },
35
- type: "module",
36
- main: "lib/index.js",
37
- exports: {
38
- ".": {
39
- require: {
40
- default: "./lib/index.cjs",
41
- types: "./lib/index.d.ts"
42
- },
43
- import: {
44
- default: "./lib/index.mjs",
45
- types: "./lib/index.d.mts"
46
- }
47
- },
48
- "./package.json": "./package.json"
49
- },
50
- types: "lib/index.d.ts",
51
- files: [
52
- "binaries",
53
- "lib",
54
- "package.json",
55
- "docs-src/**/*.md",
56
- "readme.md",
57
- ".puppeterrc.*",
58
- "requirements.txt"
59
- ],
60
- scripts: {
61
- build: "tsc -b tsconfig.build.json && npm run build:tsup && npm run postbuild",
62
- "build:packages": "yarn workspaces foreach --worktree --exclude=binary-collections --no-private run build",
63
- "build:rollup": "rollup -c rollup.config.js",
64
- "build:tsup": "node build.tsup.js",
65
- clean: "rimraf lib tmp/dist binaries",
66
- pack: "node packer.cjs --yarn --filename=bin",
67
- postbuild: "node -r ts-node/register -r dotenv/config build.exports.mjs && yarn run pack",
68
- prepare: "husky",
69
- test: 'npx jest --runInBand --forceExit --testTimeout=120000 --testPathIgnorePatterns="\\.mjs$"',
70
- "test:coverage": "npm test --coverage --detectOpenHandles",
71
- "test:esm": 'node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --forceExit --testTimeout=120000 --testPathIgnorePatterns="\\.(ts|js|cjs)$"',
72
- "test:nrs": "npm test -- nrs build:**",
73
- "test:watch": "npm test --watch",
74
- "update:ncu": "npx npm-check-updates -u -x jsdom,chalk,hexo,deepmerge-ts --enginesNode --root",
75
- "update:packer": "curl -L https://github.com/dimaslanjaka/nodejs-package-types/raw/main/packer.js > packer.cjs",
76
- "puppeteer:browser": "npx -y puppeteer browsers install chrome"
77
- },
78
- repository: {
79
- type: "git",
80
- url: "git+https://github.com/dimaslanjaka/bin"
81
- },
82
- dependencies: {
83
- "@yarnpkg/core": "^4.7.0",
84
- "ansi-colors": "^4.1.3",
85
- axios: "^1.15.2",
86
- dotenv: "^17.4.2",
87
- execa: "^9.6.1",
88
- "fs-extra": "^11.3.4",
89
- "git-command-helper": "https://github.com/dimaslanjaka/git-command-helper/raw/refs/heads/pre-release/release/git-command-helper.tgz",
90
- glob: "^13.0.6",
91
- minimatch: "^10.2.5",
92
- minimist: "^1.2.8",
93
- "ps-node": "^0.1.6",
94
- puppeteer: "^24.42.0",
95
- "puppeteer-extra": "^3.3.6",
96
- "puppeteer-extra-plugin-stealth": "^2.11.2",
97
- remove: "^0.1.5",
98
- "sbg-utility": "^2.0.11",
99
- upath: "^3.0.7",
100
- yaml: "^2.8.3",
101
- yarn: "^1.22.22"
102
- },
103
- devDependencies: {
104
- "@babel/core": "^7.29.0",
105
- "@babel/preset-env": "^7.29.2",
106
- "@babel/preset-typescript": "^7.28.5",
107
- "@eslint/eslintrc": "^3.3.5",
108
- "@eslint/js": "^10.0.1",
109
- "@rollup/plugin-babel": "^7.0.0",
110
- "@rollup/plugin-commonjs": "^29.0.2",
111
- "@rollup/plugin-json": "^6.1.0",
112
- "@rollup/plugin-node-resolve": "^16.0.3",
113
- "@types/babel__core": "^7",
114
- "@types/babel__preset-env": "^7",
115
- "@types/eslint": "^9",
116
- "@types/fs-extra": "^11",
117
- "@types/jest": "^30.0.0",
118
- "@types/minimist": "^1",
119
- "@types/node": "^25.6.0",
120
- "@types/prettier": "^3",
121
- "@types/ps-node": "^0",
122
- "@types/yargs": "^17",
123
- "@typescript-eslint/eslint-plugin": "^8.59.0",
124
- "@typescript-eslint/parser": "^8.59.0",
125
- "babel-jest": "^30.4.1",
126
- "browser-sync": "^3.0.4",
127
- "cross-env": "^10.1.0",
128
- "cross-spawn": "https://github.com/dimaslanjaka/node-cross-spawn/raw/80999ac7a7031a81e11ddb5fab0f8ba433041c98/release/cross-spawn.tgz",
129
- eslint: "^10.2.1",
130
- "eslint-config-prettier": "^10.1.8",
131
- "eslint-plugin-prettier": "^5.5.5",
132
- globals: "^17.5.0",
133
- gulp: "^5.0.1",
134
- husky: "^9.1.7",
135
- jest: "^30.4.2",
136
- "lint-staged": "^16.4.0",
137
- marked: "^18.0.3",
138
- prettier: "^3.8.3",
139
- rimraf: "^6.1.3",
140
- rollup: "^4.60.2",
141
- "ts-jest": "^29.4.9",
142
- "ts-node": "^10.9.2",
143
- tsup: "^8.5.1",
144
- typedoc: "^0.28.19",
145
- "typedoc-plugin-ga": "^1.1.1",
146
- typescript: "^6.0.3"
147
- },
148
- directories: {
149
- lib: "lib",
150
- bin: "binaries"
151
- },
152
- workspaces: [
153
- "packages/*"
154
- ],
155
- packageManager: "yarn@4.9.2",
156
- resolutions: {
157
- "cross-spawn": "https://github.com/dimaslanjaka/node-cross-spawn/raw/80999ac7a7031a81e11ddb5fab0f8ba433041c98/release/cross-spawn.tgz",
158
- "git-command-helper": "https://github.com/dimaslanjaka/git-command-helper/raw/0ec870a451241af4f7e16acee5474afe38918c77/release/git-command-helper.tgz",
159
- "sbg-utility": "https://github.com/dimaslanjaka/static-blog-generator/raw/1c6327117ab66a6ac7bac6df2b5c4f1cd9ef2785/packages/sbg-utility/release/sbg-utility.tgz"
160
- },
161
- bin: {
162
- "binary-collections": "lib/binary-collections.cjs",
163
- "binary-executor": "binaries/binary-executor.cjs",
164
- changelog: "lib/changelog.cjs",
165
- chatgpt: "lib/free-chatgpt.cjs",
166
- "clean-github-actions-cache": "lib/clean-github-actions-caches.cjs",
167
- "clean-github-actions-caches": "lib/clean-github-actions-caches.cjs",
168
- "clean-nodemodule": "binaries/clean-nodemodule.cjs",
169
- "clean-nodemodules": "binaries/clean-nodemodules.cjs",
170
- "clear-gh-caches": "lib/clean-github-actions-caches.cjs",
171
- "clear-github-actions-cache": "lib/clean-github-actions-caches.cjs",
172
- "clear-github-actions-caches": "lib/clean-github-actions-caches.cjs",
173
- "del-gradle": "lib/del-gradle.cjs",
174
- "del-node-modules": "lib/del-node-modules.cjs",
175
- "del-nodemodules": "lib/del-node-modules.cjs",
176
- "del-ps": "lib/del-ps.cjs",
177
- "del-yarn-caches": "lib/del-yarn-caches.cjs",
178
- "del-yarncaches": "lib/del-yarn-caches.cjs",
179
- dev: "binaries/dev.cjs",
180
- "dir-tree": "lib/print-directory-tree.cjs",
181
- empty: "binaries/empty.cjs",
182
- "find-node-modules": "lib/find-node-modules-cli.cjs",
183
- "free-chatgpt": "lib/free-chatgpt.cjs",
184
- "git-diff": "lib/git-diff-cli.cjs",
185
- "git-fix": "lib/git-fix.cjs",
186
- "git-purge": "lib/git-purge.cjs",
187
- "git-reduce-size": "binaries/git-reduce-size.cjs",
188
- "git-undo-commit": "lib/git/undo-commit.cjs",
189
- "git-undo-staged": "lib/git/undo-staged.cjs",
190
- javakill: "binaries/javakill.cjs",
191
- "kill-night-crows": "lib/kill-night-crows.cjs",
192
- "kill-process": "binaries/kill-process.cjs",
193
- nodekill: "binaries/nodekill.cjs",
194
- "npm-run-series": "lib/npm-run-series.cjs",
195
- nrs: "lib/npm-run-series.cjs",
196
- "package-resolutions-updater": "lib/package-resolutions-updater-cli.cjs",
197
- "php-cs-fixer-staged": "lib/php-cs-fixer-staged.cjs",
198
- "pkg-res-updater": "lib/package-resolutions-updater-cli.cjs",
199
- "pkg-resolutions-updater": "lib/package-resolutions-updater-cli.cjs",
200
- "print-directory-tree": "lib/print-directory-tree.cjs",
201
- "print-tree": "lib/print-directory-tree.cjs",
202
- prod: "binaries/prod.cjs",
203
- py: "binaries/py.cjs",
204
- "remove-module": "lib/remove-module.cjs",
205
- rmfind: "binaries/rmfind.cjs",
206
- rmpath: "lib/rmpath.cjs",
207
- rmx: "binaries/rmx.cjs",
208
- "run-s": "lib/npm-run-series.cjs",
209
- "run-series": "lib/npm-run-series.cjs",
210
- "submodule-install": "lib/submodule-install.cjs",
211
- "submodule-remove": "lib/submodule-remove-cli.cjs",
212
- "submodule-token": "binaries/submodule-token.cjs",
213
- "test-cjs": "binaries/test-cjs.cjs",
214
- "undo-commit": "lib/git/undo-commit.cjs",
215
- "undo-last-commit": "lib/git/undo-commit.cjs",
216
- "undo-staged": "lib/git/undo-staged.cjs",
217
- "yarn-clean": "binaries/yarn-clean.cjs",
218
- "yarn-reinstall": "lib/yarn-reinstall.cjs"
219
- }
220
- };
221
- }
222
- });
223
-
224
23
  // src/binary-collections.cjs
225
24
  var require_binary_collections = __commonJS({
226
25
  "src/binary-collections.cjs"() {
227
26
  init_esm_shims();
228
- var { spawn } = __require("child_process");
229
- var { glob } = __require("glob");
230
27
  var path = __require("upath");
231
28
  var { getArgs } = require_utils();
232
- var pkgJson = require_package();
233
- var fs = __require("fs-extra");
29
+ var findScript = require_findScript();
30
+ var executeScript = require_executeScript();
234
31
  function showHelp() {
235
32
  console.log("\u{1F680} Binary Collections - Dynamic Script Runner");
236
33
  console.log("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550");
237
34
  console.log("");
238
- console.log("\u{1F4CB} Usage: npx binary-collections <script-name> [...args]");
35
+ console.log("\u{1F4CB} Usage: npx --legacy-peer-deps -y binary-collections <script-name> [...args]");
239
36
  console.log("");
240
37
  console.log("\u2728 Examples:");
241
- console.log(" \u{1F4CA} npx binary-collections git-diff -s");
242
- console.log(" \u{1F9F9} npx binary-collections del-node-modules");
243
- console.log(" \u{1F50D} npx binary-collections find-node-modules --help");
38
+ console.log(" \u{1F4CA} npx --legacy-peer-deps -y binary-collections git-diff -s");
39
+ console.log(" \u{1F9F9} npx --legacy-peer-deps -y binary-collections del-node-modules");
40
+ console.log(" \u{1F50D} npx --legacy-peer-deps -y binary-collections find-node-modules --help");
244
41
  console.log("");
245
42
  console.log("\u2139\uFE0F This tool will search for <script-name>.{cjs,js,mjs} in the script's directory");
246
43
  console.log(" and execute it with the provided arguments.");
@@ -249,79 +46,22 @@ var require_binary_collections = __commonJS({
249
46
  console.log(" --help, -h Show this help message");
250
47
  process.exit(0);
251
48
  }
252
- function findScript(scriptName, searchDir = null) {
253
- if (!searchDir) searchDir = __dirname;
254
- let result;
255
- const ignorePatterns = [
256
- `**/*config*.{cjs,js,mjs}`,
257
- `**/utils.{cjs,js,mjs}`,
258
- `**/index.{cjs,js,mjs}`,
259
- `**/chunk-*.{cjs,js,mjs}`,
260
- `**/*.d.{ts,cts,mts}`
261
- // ignore TypeScript declaration files
262
- ];
263
- try {
264
- const pattern = `${scriptName}.{cjs,js,mjs}`;
265
- const files = glob.sync(pattern, {
266
- cwd: searchDir,
267
- ignore: ignorePatterns,
268
- absolute: true
269
- });
270
- if (files.length > 0) {
271
- result = files[0];
272
- } else {
273
- if (pkgJson.bin[scriptName]) {
274
- const find = [
275
- path.join(searchDir, pkgJson.bin[scriptName]),
276
- path.join(process.cwd(), "node_modules/binary-collections", pkgJson.bin[scriptName]),
277
- path.join(__dirname, pkgJson.bin[scriptName]),
278
- path.join(path.join(__dirname, ".."), pkgJson.bin[scriptName])
279
- ];
280
- const filtered = find.filter((file) => fs.existsSync(file));
281
- if (filtered.length > 0) {
282
- result = filtered[0];
283
- } else {
284
- console.warn(`\u26A0\uFE0F Script "${scriptName}" not found in ${searchDir}.`);
285
- console.warn(`\u{1F50D} Searched for: ${pattern} in ${searchDir}`);
286
- }
287
- }
288
- }
289
- } catch (error) {
290
- console.error(`\u{1F50D} Error searching for script: ${error.message}`);
291
- }
292
- if (result && !result.includes("-cli")) {
293
- const ext = path.extname(result);
294
- const filename = path.basename(result, ext);
295
- const cliFile = path.join(path.dirname(result), `${filename}-cli${ext}`);
296
- if (fs.existsSync(cliFile)) {
297
- result = cliFile;
298
- console.log(`\u{1F50D} Found CLI version: ${cliFile}`);
299
- }
300
- }
301
- return result;
302
- }
303
- function executeScript(scriptPath, args) {
304
- console.log(`\u{1F527} Executing script: ${scriptPath} args: ${args.join(" ")}`);
305
- const child = spawn("node", [scriptPath, ...args], {
306
- stdio: "inherit",
307
- shell: true
308
- });
309
- child.on("error", (error) => {
310
- console.error(`\u274C Error executing script: ${error.message}`);
311
- process.exit(1);
312
- });
313
- child.on("close", (code) => {
314
- process.exit(code);
315
- });
316
- }
317
49
  function main() {
318
50
  const args = getArgs();
319
51
  const positional = args._ || [];
320
- console.log(`\u{1F50D} Parsed arguments: ${JSON.stringify(args)}`);
321
52
  if (positional.length === 0) {
322
53
  return showHelp();
323
54
  }
324
55
  const scriptName = positional[0];
56
+ if (scriptName === "list") {
57
+ const listScript = require_listScript();
58
+ const scripts = listScript();
59
+ console.log("\u{1F4CB} Available scripts:");
60
+ scripts.forEach((script) => {
61
+ console.log(` - ${path.basename(script.name)} -> ${script.path}`);
62
+ });
63
+ process.exit(0);
64
+ }
325
65
  const scriptArgs = [];
326
66
  scriptArgs.push(...positional.slice(1));
327
67
  Object.keys(args).forEach((key) => {
package/lib/changelog.cjs CHANGED
@@ -19,9 +19,9 @@ var require_utils = __commonJS({
19
19
  init_cjs_shims();
20
20
  var fs2 = require("fs");
21
21
  var path2 = require("upath");
22
- var argv = require("minimist")(process.argv.slice(2));
22
+ var minimistLib = require("minimist");
23
+ var argv = minimistLib(process.argv.slice(2));
23
24
  var { exec } = require("child_process");
24
- var { URL: URL2 } = require("url");
25
25
  var { promisify } = require("util");
26
26
  var execAsync = promisify(exec);
27
27
  async function parseGitRemotes() {
@@ -34,7 +34,7 @@ var require_utils = __commonJS({
34
34
  if (name && url) {
35
35
  const [repoUrl] = url.split(" ");
36
36
  try {
37
- const parsedUrl = new URL2(repoUrl);
37
+ const parsedUrl = new URL(repoUrl);
38
38
  const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
39
39
  if (parsedUrl.hostname === "github.com" && pathParts.length === 2) {
40
40
  let repoPath = pathParts.join("/");
@@ -55,15 +55,10 @@ var require_utils = __commonJS({
55
55
  }
56
56
  }
57
57
  module2.exports.parseGitRemotes = parseGitRemotes;
58
- function joinPathPreserveDriveLetter(...segments) {
59
- let fullPath = require("path").join(...segments);
60
- if (/^[a-z]:\\/.test(fullPath)) {
61
- fullPath = fullPath.charAt(0).toUpperCase() + fullPath.slice(1);
58
+ function getArgs2(opts) {
59
+ if (opts) {
60
+ return minimistLib(process.argv.slice(2), opts);
62
61
  }
63
- return fullPath;
64
- }
65
- module2.exports.joinPathPreserveDriveLetter = joinPathPreserveDriveLetter;
66
- function getArgs2() {
67
62
  return argv;
68
63
  }
69
64
  module2.exports.getArgs = getArgs2;
@@ -88,7 +83,7 @@ var require_utils = __commonJS({
88
83
  try {
89
84
  fs2.rmdirSync(fullPath);
90
85
  console.log("deleted", fullPath);
91
- } catch (e) {
86
+ } catch (_e) {
92
87
  try {
93
88
  fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
94
89
  console.log("deleted", fullPath);
@@ -101,7 +96,7 @@ var require_utils = __commonJS({
101
96
  try {
102
97
  fs2.unlinkSync(fullPath);
103
98
  console.log("deleted", fullPath);
104
- } catch (e) {
99
+ } catch (_e) {
105
100
  try {
106
101
  fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
107
102
  console.log("deleted", fullPath);
@@ -188,7 +183,7 @@ var require_utils = __commonJS({
188
183
  // src/changelog.cjs
189
184
  init_cjs_shims();
190
185
  var fs = require("fs");
191
- var path = require("path");
186
+ var path = require("upath");
192
187
  var { EOL } = require("os");
193
188
  var { getArgs } = require_utils();
194
189
  var spawn = require("child_process").spawn;
package/lib/changelog.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  require_utils
4
- } from "./chunk-Z6JLYU2J.mjs";
4
+ } from "./chunk-6RK5UCTP.mjs";
5
5
  import {
6
6
  __commonJS,
7
7
  __dirname,
@@ -14,7 +14,7 @@ var require_changelog = __commonJS({
14
14
  "src/changelog.cjs"() {
15
15
  init_esm_shims();
16
16
  var fs = __require("fs");
17
- var path = __require("path");
17
+ var path = __require("upath");
18
18
  var { EOL } = __require("os");
19
19
  var { getArgs } = require_utils();
20
20
  var spawn = __require("child_process").spawn;
@@ -0,0 +1,246 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ require_config
4
+ } from "./chunk-X2B3X7D4.mjs";
5
+ import {
6
+ runChatGpt
7
+ } from "./chunk-GAGABICI.mjs";
8
+ import {
9
+ require_utils
10
+ } from "./chunk-6RK5UCTP.mjs";
11
+ import {
12
+ __toESM,
13
+ init_esm_shims
14
+ } from "./chunk-QQ4A6DLD.mjs";
15
+
16
+ // src/git-diff.js
17
+ init_esm_shims();
18
+ var import_config = __toESM(require_config(), 1);
19
+ import ansiColors from "ansi-colors";
20
+ import { execSync } from "child_process";
21
+ import fs from "fs-extra";
22
+ import { md5, writefile } from "sbg-utility";
23
+ import path from "upath";
24
+ import { fileURLToPath } from "url";
25
+ var import_utils = __toESM(require_utils(), 1);
26
+ var __filename = fileURLToPath(import.meta.url);
27
+ var __dirname = path.dirname(__filename);
28
+ var args = (0, import_utils.getArgs)();
29
+ var positional = args._ || [];
30
+ var FILENAME = md5((positional[0] || "default") + JSON.stringify(args));
31
+ var DIFF_OUTPUT = (0, import_config.getTempPath)(`git-diff/${FILENAME}.txt`);
32
+ var GPT_DIFF_OUTPUT = (0, import_config.getTempPath)(`git-diff/gpt-${FILENAME}.txt`);
33
+ var CACHE_DIR = path.dirname(DIFF_OUTPUT);
34
+ var DIFF_OUTPUT_RELATIVE = path.relative(process.cwd(), DIFF_OUTPUT);
35
+ var GPT_DIFF_OUTPUT_RELATIVE = path.relative(process.cwd(), GPT_DIFF_OUTPUT);
36
+ fs.ensureDirSync(CACHE_DIR, { mode: 493 });
37
+ function showHelp() {
38
+ console.log("\u{1F4CB} Git Diff Helper");
39
+ console.log("Usage:");
40
+ console.log(" git-diff FILE Show staged diff of specified file");
41
+ console.log(" git-diff --staged-only Show staged diff of all files");
42
+ console.log(" git-diff -s | -S Same as --staged-only");
43
+ console.log(" git-diff --unstaged FILE Show unstaged diff of specified file");
44
+ console.log(" git-diff --unstaged Show unstaged diff of all files");
45
+ console.log(" git-diff -u Same as --unstaged");
46
+ console.log(" git-diff --ai Run ChatGPT automation for commit message");
47
+ console.log(" git-diff --help | -h Show this help message");
48
+ console.log("");
49
+ console.log(`\u{1F4BE} Output is saved to: ${DIFF_OUTPUT_RELATIVE}`);
50
+ console.log(`\u{1F916} GPT prompt is saved to: ${GPT_DIFF_OUTPUT_RELATIVE}`);
51
+ process.exit(0);
52
+ }
53
+ function runGitDiff(command, successMessage, errorMessage) {
54
+ try {
55
+ console.log(`\u2139\uFE0F Running command: ${command}`);
56
+ const result = execSync(command, {
57
+ encoding: "utf8",
58
+ maxBuffer: 1024 * 1024 * 10
59
+ // 10MB buffer to handle large diffs
60
+ });
61
+ if (!result || result.trim() === "") {
62
+ console.log(`\u2139\uFE0F No changes found for the specified criteria`);
63
+ writefile(DIFF_OUTPUT, "# No changes found\n");
64
+ console.log(`\u2705 Empty diff saved to "${DIFF_OUTPUT_RELATIVE}"`);
65
+ return false;
66
+ }
67
+ writefile(DIFF_OUTPUT, result);
68
+ writefile(
69
+ GPT_DIFF_OUTPUT,
70
+ `Hello!
71
+ Can you create a conventional commit message by diff content below:
72
+
73
+ \`\`\`${result}
74
+ \`\`\`
75
+
76
+ Give me result as codeblock with language "text" only.
77
+
78
+ Thank you!`
79
+ );
80
+ console.log(`\u2705 ${successMessage}`);
81
+ console.log(`\u{1F4BE} GPT diff prompt saved to "${ansiColors.green(GPT_DIFF_OUTPUT_RELATIVE)}"`);
82
+ return true;
83
+ } catch (error) {
84
+ console.error(`\u274C ${errorMessage}`);
85
+ console.error(`\u274C Command: ${command}`);
86
+ console.error(`\u274C Error: ${error.message}`);
87
+ if (error.message.includes("not a git repository")) {
88
+ console.error("\u274C Make sure you are in a git repository");
89
+ }
90
+ process.exit(1);
91
+ }
92
+ }
93
+ function getUntrackedDiff() {
94
+ try {
95
+ const untrackedStr = execSync("git ls-files --others --exclude-standard", {
96
+ encoding: "utf8",
97
+ maxBuffer: 1024 * 1024 * 10
98
+ }).trim();
99
+ if (!untrackedStr) return "";
100
+ const untrackedFiles = untrackedStr.split("\n").filter(function(f) {
101
+ return f;
102
+ });
103
+ if (untrackedFiles.length === 0) return "";
104
+ var result = "\n# Untracked files:\n";
105
+ for (var i = 0; i < untrackedFiles.length; i++) {
106
+ var file = untrackedFiles[i];
107
+ if (!fs.existsSync(file)) continue;
108
+ var stat = fs.statSync(file);
109
+ if (!stat.isFile()) continue;
110
+ var content;
111
+ try {
112
+ content = fs.readFileSync(file, "utf8");
113
+ } catch (_a) {
114
+ continue;
115
+ }
116
+ var lines = content.split("\n");
117
+ if (lines.length > 0 && lines[lines.length - 1] === "") {
118
+ lines.pop();
119
+ }
120
+ result += "diff --git a/" + file + " b/" + file + "\n";
121
+ result += "new file mode 100644\n";
122
+ result += "index 0000000..0000000\n";
123
+ result += "--- /dev/null\n";
124
+ result += "+++ b/" + file + "\n";
125
+ result += "@@ -0,0 +1," + (lines.length || 0) + " @@\n";
126
+ for (var j = 0; j < lines.length; j++) {
127
+ result += "+" + lines[j] + "\n";
128
+ }
129
+ }
130
+ return result;
131
+ } catch (_b) {
132
+ return "";
133
+ }
134
+ }
135
+ function fileHasChanges(file, mode) {
136
+ const command = mode === "staged" ? `git diff --cached --quiet -- "${file}"` : `git diff --quiet -- "${file}"`;
137
+ try {
138
+ execSync(command, { stdio: "ignore" });
139
+ return false;
140
+ } catch (error) {
141
+ if (error.status === 1) {
142
+ return true;
143
+ }
144
+ throw error;
145
+ }
146
+ }
147
+ async function mainGitDiff() {
148
+ if (args.help || args.h) {
149
+ showHelp();
150
+ }
151
+ const useUnstaged = args.unstaged || args.u;
152
+ const fileFromFlag = typeof args.unstaged === "string" ? args.unstaged : typeof args.u === "string" ? args.u : null;
153
+ let hasDiff = false;
154
+ if (args["staged-only"] || args.s || args.S) {
155
+ hasDiff = runGitDiff(
156
+ "git --no-pager diff --staged",
157
+ `Full staged diff saved to "${ansiColors.green(DIFF_OUTPUT_RELATIVE)}"`,
158
+ "Failed to save staged diff"
159
+ );
160
+ } else {
161
+ const file = positional[0] || fileFromFlag;
162
+ if (!file) {
163
+ const fullDiffModeLabel = useUnstaged ? "unstaged" : "unstaged";
164
+ hasDiff = runGitDiff(
165
+ "git --no-pager diff",
166
+ `Full ${fullDiffModeLabel} diff saved to "${ansiColors.green(DIFF_OUTPUT_RELATIVE)}"`,
167
+ "Failed to save all diff's"
168
+ );
169
+ const untrackedDiff = getUntrackedDiff();
170
+ if (untrackedDiff) {
171
+ const UNTRACKED_DIFF_OUTPUT = (0, import_config.getTempPath)(`git-diff/untracked-${FILENAME}.txt`);
172
+ const UNTRACKED_GPT_DIFF_OUTPUT = (0, import_config.getTempPath)(`git-diff/gpt-untracked-${FILENAME}.txt`);
173
+ const UNTRACKED_DIFF_OUTPUT_RELATIVE = path.relative(process.cwd(), UNTRACKED_DIFF_OUTPUT);
174
+ writefile(UNTRACKED_DIFF_OUTPUT, untrackedDiff);
175
+ writefile(
176
+ UNTRACKED_GPT_DIFF_OUTPUT,
177
+ `Hello!
178
+ Can you create a conventional commit message by diff content below:
179
+
180
+ \`\`\`${untrackedDiff}
181
+ \`\`\`
182
+
183
+ Give me result as codeblock with language "text" only.
184
+
185
+ Thank you!`
186
+ );
187
+ console.log(`\u2705 Untracked file diff saved to "${ansiColors.green(UNTRACKED_DIFF_OUTPUT_RELATIVE)}"`);
188
+ console.log(
189
+ `\u{1F4BE} AI diff prompt saved to "${ansiColors.green(path.relative(process.cwd(), UNTRACKED_GPT_DIFF_OUTPUT))}"`
190
+ );
191
+ hasDiff = true;
192
+ }
193
+ } else {
194
+ let fileDiffMode = useUnstaged ? "unstaged" : "staged";
195
+ if (!useUnstaged && !fileHasChanges(file, "staged") && fileHasChanges(file, "unstaged")) {
196
+ fileDiffMode = "unstaged";
197
+ }
198
+ hasDiff = runGitDiff(
199
+ fileDiffMode === "unstaged" ? `git --no-pager diff -- "${file}"` : `git --no-pager diff --cached -- "${file}"`,
200
+ `${fileDiffMode[0].toUpperCase() + fileDiffMode.slice(1)} diff of "${file}" saved to "${ansiColors.green(
201
+ DIFF_OUTPUT_RELATIVE
202
+ )}"`,
203
+ `Failed to generate ${fileDiffMode} diff for "${file}"`
204
+ );
205
+ }
206
+ }
207
+ if (hasDiff) {
208
+ const opencodePrompt = [
209
+ "",
210
+ "\u{1F916} OpenCode Prompt Helper",
211
+ "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",
212
+ "",
213
+ "\u{1F4C4} App Prompt:",
214
+ ` Generate a conventional commit message from diff file: ${DIFF_OUTPUT}`,
215
+ "",
216
+ "\u{1F4BB} CLI Command:",
217
+ ` opencode run "Generate a conventional commit message from diff file ${DIFF_OUTPUT}"`,
218
+ ""
219
+ ];
220
+ const opencodePromptPath = (0, import_config.getTempPath)(`git-diff/opencode-${FILENAME}.txt`);
221
+ writefile(opencodePromptPath, opencodePrompt.join("\n"));
222
+ console.log(`\u2705 OpenCode prompt saved to "${ansiColors.green(path.relative(process.cwd(), opencodePromptPath))}"`);
223
+ }
224
+ if (args.ai) {
225
+ try {
226
+ await runChatGpt({ headless: true, questionFile: GPT_DIFF_OUTPUT });
227
+ } catch (error) {
228
+ console.error("\u274C Error running ChatGPT:", error.message);
229
+ console.error("\u{1F4A1} Try running with visible browser mode or check if Chrome is installed");
230
+ }
231
+ } else {
232
+ console.log("\u{1F4A1} Use --ai flag to generate commit message with ChatGPT");
233
+ }
234
+ }
235
+ var git_diff_default = runGitDiff;
236
+
237
+ export {
238
+ DIFF_OUTPUT,
239
+ GPT_DIFF_OUTPUT,
240
+ CACHE_DIR,
241
+ DIFF_OUTPUT_RELATIVE,
242
+ GPT_DIFF_OUTPUT_RELATIVE,
243
+ runGitDiff,
244
+ mainGitDiff,
245
+ git_diff_default
246
+ };