binary-collections 2.0.11 → 2.0.12

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 (225) hide show
  1. package/.opencode/package.json +5 -0
  2. package/binaries/rmx +15 -1
  3. package/binaries/rmx.cmd +12 -0
  4. package/binaries/test-cjs +9 -1
  5. package/binaries/test-cjs.cmd +16 -1
  6. package/binaries/test-esm +16 -0
  7. package/binaries/test-esm.cjs +178 -0
  8. package/binaries/test-esm.cmd +23 -0
  9. package/binaries/yarn-clean +1 -1
  10. package/binaries/yarn-clean.cmd +1 -1
  11. package/binaries/yarn-clean.py +33 -15
  12. package/binaries/yc +110 -0
  13. package/binaries/yc.cjs +178 -0
  14. package/lib/binary-collections/config.cjs +126 -0
  15. package/lib/binary-collections/config.mjs +7 -0
  16. package/lib/binary-collections/executeScript.cjs +19 -0
  17. package/lib/binary-collections/executeScript.d.cts +12 -0
  18. package/lib/binary-collections/executeScript.mjs +6 -0
  19. package/lib/binary-collections/findScript.cjs +284 -0
  20. package/lib/binary-collections/findScript.d.cts +12 -0
  21. package/lib/binary-collections/findScript.mjs +7 -0
  22. package/lib/binary-collections/listScript.cjs +266 -0
  23. package/lib/binary-collections/listScript.d.cts +19 -0
  24. package/lib/binary-collections/listScript.mjs +7 -0
  25. package/lib/binary-collections.cjs +224 -137
  26. package/lib/binary-collections.mjs +22 -282
  27. package/lib/changelog.cjs +2 -2
  28. package/lib/changelog.mjs +1 -1
  29. package/lib/{chunk-AJDD5DZM.mjs → chunk-2LSRSEXF.mjs} +1 -1
  30. package/lib/{chunk-Z6JLYU2J.mjs → chunk-5RTXZVCW.mjs} +2 -2
  31. package/lib/{chunk-XA3SNBPA.mjs → chunk-66KDU4TX.mjs} +93 -9
  32. package/lib/chunk-6PU7BAHB.mjs +61 -0
  33. package/lib/chunk-C6D2TTYU.mjs +32 -0
  34. package/lib/chunk-FB2WKVJD.mjs +158 -0
  35. package/lib/{chunk-NCXAP7AA.mjs → chunk-G5UUEWUO.mjs} +9 -5
  36. package/lib/{chunk-N436BNBK.mjs → chunk-GAGABICI.mjs} +19 -13
  37. package/lib/chunk-H44UWUFY.mjs +105 -0
  38. package/lib/chunk-NCZPTKDV.mjs +79 -0
  39. package/lib/chunk-NGFK3EYW.mjs +28 -0
  40. package/lib/chunk-NVEG3LEZ.mjs +143 -0
  41. package/lib/chunk-OGXVGBRI.mjs +29 -0
  42. package/lib/chunk-OXV52GD5.mjs +62 -0
  43. package/lib/chunk-PXBMHE7O.mjs +35 -0
  44. package/lib/chunk-R5FJOR63.mjs +47 -0
  45. package/lib/chunk-SPTECFE5.mjs +180 -0
  46. package/lib/chunk-UXCFNAR6.mjs +55 -0
  47. package/lib/chunk-V2IBPCEV.mjs +39 -0
  48. package/lib/chunk-XPJGCDOD.mjs +14 -0
  49. package/lib/chunk-ZOWVMII3.mjs +228 -0
  50. package/lib/clean-github-actions-caches-cli.cjs +465 -0
  51. package/lib/clean-github-actions-caches-cli.d.cts +1 -0
  52. package/lib/clean-github-actions-caches-cli.mjs +56 -0
  53. package/lib/clean-github-actions-caches.cjs +149 -205
  54. package/lib/clean-github-actions-caches.d.cts +15 -1
  55. package/lib/clean-github-actions-caches.mjs +4 -130
  56. package/lib/cross-env/command.cjs +63 -0
  57. package/lib/cross-env/command.d.ts +8 -0
  58. package/lib/cross-env/command.js +45 -0
  59. package/lib/cross-env/command.mjs +9 -0
  60. package/lib/cross-env/index.cjs +178 -0
  61. package/lib/cross-env/index.d.ts +8 -0
  62. package/lib/cross-env/index.js +102 -0
  63. package/lib/cross-env/index.mjs +101 -0
  64. package/lib/cross-env/variable.cjs +60 -0
  65. package/lib/cross-env/variable.d.ts +7 -0
  66. package/lib/cross-env/variable.js +59 -0
  67. package/lib/cross-env/variable.mjs +9 -0
  68. package/lib/del-gradle.cjs +2 -2
  69. package/lib/del-gradle.js +8 -8
  70. package/lib/del-gradle.mjs +1 -1
  71. package/lib/del-node-modules.js +24 -24
  72. package/lib/del-ps.cjs +2 -2
  73. package/lib/del-ps.js +8 -8
  74. package/lib/del-ps.mjs +1 -1
  75. package/lib/del-yarn-caches.cjs +2 -2
  76. package/lib/del-yarn-caches.js +2 -2
  77. package/lib/del-yarn-caches.mjs +1 -1
  78. package/lib/file/copy-cli.cjs +92 -0
  79. package/lib/file/copy-cli.d.mts +1 -0
  80. package/lib/file/copy-cli.mjs +55 -0
  81. package/lib/file/copy.cjs +56 -0
  82. package/lib/file/copy.d.mts +1 -0
  83. package/lib/file/copy.mjs +8 -0
  84. package/lib/file/move-cli.cjs +91 -0
  85. package/lib/file/move-cli.d.mts +1 -0
  86. package/lib/file/move-cli.mjs +55 -0
  87. package/lib/file/move.cjs +55 -0
  88. package/lib/file/move.d.mts +1 -0
  89. package/lib/file/move.mjs +8 -0
  90. package/lib/find-node-modules-cli.js +1 -1
  91. package/lib/free-chatgpt.cjs +21 -15
  92. package/lib/free-chatgpt.js +10 -10
  93. package/lib/free-chatgpt.mjs +2 -2
  94. package/lib/git/user-config.cjs +2 -2
  95. package/lib/git/user-config.mjs +2 -2
  96. package/lib/git-diff-cli.cjs +188 -42
  97. package/lib/git-diff-cli.mjs +5 -4
  98. package/lib/git-diff.cjs +188 -42
  99. package/lib/git-diff.d.ts +2 -1
  100. package/lib/git-diff.js +91 -34
  101. package/lib/git-diff.mjs +5 -4
  102. package/lib/git-fix.cjs +2 -2
  103. package/lib/git-fix.mjs +2 -2
  104. package/lib/git-purge.cjs +2 -2
  105. package/lib/git-purge.mjs +1 -1
  106. package/lib/index.d.ts +1 -1
  107. package/lib/kill-night-crows.cjs +7 -7
  108. package/lib/kill-night-crows.mjs +7 -7
  109. package/lib/node-cache-cleaner/npm.cjs +65 -0
  110. package/lib/node-cache-cleaner/npm.d.ts +2 -0
  111. package/lib/node-cache-cleaner/npm.js +41 -0
  112. package/lib/node-cache-cleaner/npm.mjs +10 -0
  113. package/lib/node-cache-cleaner/npx.cjs +89 -0
  114. package/lib/node-cache-cleaner/npx.d.ts +4 -0
  115. package/lib/node-cache-cleaner/npx.js +82 -0
  116. package/lib/{ps/index.d.mjs → node-cache-cleaner/npx.mjs} +6 -5
  117. package/lib/node-cache-cleaner/yarn.cjs +73 -0
  118. package/lib/node-cache-cleaner/yarn.d.ts +2 -0
  119. package/lib/node-cache-cleaner/yarn.js +62 -0
  120. package/lib/node-cache-cleaner/yarn.mjs +10 -0
  121. package/lib/node-cache-cleaner-cli.cjs +182 -0
  122. package/lib/node-cache-cleaner-cli.d.ts +2 -0
  123. package/lib/node-cache-cleaner-cli.js +60 -0
  124. package/lib/node-cache-cleaner-cli.mjs +56 -0
  125. package/lib/node-executor.cjs +91 -0
  126. package/lib/node-executor.d.cts +2 -0
  127. package/lib/node-executor.mjs +103 -0
  128. package/lib/npm-run-series.cjs +21 -28
  129. package/lib/npm-run-series.mjs +20 -6
  130. package/lib/package-resolutions-updater-cli.cjs +213 -128
  131. package/lib/package-resolutions-updater-cli.mjs +17 -39
  132. package/lib/package-resolutions-updater.cjs +204 -98
  133. package/lib/package-resolutions-updater.d.mts +20 -1
  134. package/lib/package-resolutions-updater.mjs +7 -5
  135. package/lib/print-directory-tree.cjs +2 -2
  136. package/lib/print-directory-tree.mjs +1 -1
  137. package/lib/ps/connected-domain.js +10 -10
  138. package/lib/ps/index.cjs +1 -1
  139. package/lib/ps/index.mjs +177 -171
  140. package/lib/ps/isWin.js +1 -1
  141. package/lib/ps/table-parser.js +6 -6
  142. package/lib/remove-module.cjs +2 -2
  143. package/lib/remove-module.mjs +1 -1
  144. package/lib/rm-node-module-cli.cjs +222 -0
  145. package/lib/rm-node-module-cli.d.cts +1 -0
  146. package/lib/rm-node-module-cli.mjs +89 -0
  147. package/lib/rm-node-modules.cjs +127 -0
  148. package/lib/rm-node-modules.d.cts +35 -0
  149. package/lib/{binary-collections-config.mjs → rm-node-modules.mjs} +3 -3
  150. package/lib/rmpath.cjs +2 -2
  151. package/lib/rmpath.mjs +1 -1
  152. package/lib/submodule-install.cjs +47 -34
  153. package/lib/submodule-install.mjs +46 -33
  154. package/lib/submodule-remove-cli.cjs +1 -2
  155. package/lib/submodule-remove-cli.js +3 -3
  156. package/lib/submodule-remove-cli.mjs +1 -2
  157. package/lib/utils/chatgpt.cjs +19 -13
  158. package/lib/utils/chatgpt.js +94 -94
  159. package/lib/utils/chatgpt.mjs +1 -1
  160. package/lib/utils/findEnvFiles.cjs +28 -46
  161. package/lib/utils/findEnvFiles.d.cts +19 -0
  162. package/lib/utils/findEnvFiles.mjs +3 -5
  163. package/lib/utils/findWorkspaceRoot.js +4 -4
  164. package/lib/utils/index.cjs +2 -2
  165. package/lib/utils/index.mjs +1 -1
  166. package/lib/utils/isGithubTokenValid.js +7 -7
  167. package/lib/{ps/index.d.cjs → utils/isWindows.cjs} +17 -3
  168. package/lib/utils/isWindows.d.ts +5 -0
  169. package/lib/utils/isWindows.js +10 -0
  170. package/lib/utils/isWindows.mjs +8 -0
  171. package/lib/utils/runBash.cjs +53 -0
  172. package/lib/utils/runBash.d.cts +12 -0
  173. package/lib/utils/runBash.mjs +66 -0
  174. package/lib/yarn-per-branch-lock-installer.cjs +97 -0
  175. package/lib/yarn-per-branch-lock-installer.d.cts +2 -0
  176. package/lib/yarn-per-branch-lock-installer.mjs +109 -0
  177. package/lib/yarn-reinstall.cjs +2 -2
  178. package/lib/yarn-reinstall.mjs +1 -1
  179. package/package.json +61 -52
  180. package/readme.html +784 -0
  181. package/readme.md +106 -218
  182. package/releases/readme.md +1 -1
  183. package/test/README.md +2 -2
  184. package/test-project/package.json +8 -2
  185. package/test-project/workspaces/workspace-a/package.json +135 -0
  186. package/test-project/workspaces/workspace-a/readme.md +20 -0
  187. package/test-project/workspaces/workspace-a/release/readme.md +42 -0
  188. package/test-project/workspaces/workspace-a/test/demo/package.json +25 -0
  189. package/test-project/workspaces/workspace-a/test/readme.md +12 -0
  190. package/test-project/workspaces/workspace-b/package.json +139 -0
  191. package/test-project/workspaces/workspace-b/readme.md +94 -0
  192. package/test-project/workspaces/workspace-b/requirements.txt +1 -0
  193. package/test-project/workspaces/workspace-b/test/sample-project/package.json +7 -0
  194. package/test-project/workspaces/workspace-b/themes/hexo-theme-flowbite/package.json +96 -0
  195. package/test-project/workspaces/workspace-b/themes/hexo-theme-flowbite/readme.md +156 -0
  196. package/tmp/rm-node-modules-test-project/package.json +17 -0
  197. package/tmp/rm-node-modules-test-project/packages/workspace-a/package.json +16 -0
  198. package/tmp/rm-node-modules-test-project/packages/workspace-b/package.json +16 -0
  199. package/tmp/test-repo/README.md +2 -35
  200. package/tmp/test-repo/package.json +13 -3
  201. package/docs-src/clean-github-actions-caches.md +0 -26
  202. package/docs-src/free-chatgpt.md +0 -26
  203. package/lib/binary-collections-config.cjs +0 -15
  204. package/lib/chunk-2CBJCW7E.mjs +0 -81
  205. package/lib/chunk-4UHL4WVN.mjs +0 -136
  206. package/lib/chunk-66PAU5PS.mjs +0 -31
  207. package/lib/chunk-6HHJRKFB.mjs +0 -59
  208. package/lib/chunk-7XTEJHOE.mjs +0 -193
  209. package/lib/chunk-FCDQGYBF.mjs +0 -136
  210. package/lib/chunk-GEYA2USY.mjs +0 -207
  211. package/lib/chunk-GJTGHXRA.mjs +0 -356
  212. package/lib/chunk-ID2WBTE2.mjs +0 -80
  213. package/lib/chunk-JXFOHKDM.mjs +0 -239
  214. package/lib/chunk-PDSXF5HY.mjs +0 -187
  215. package/lib/chunk-RWLXRTYP.mjs +0 -109
  216. package/lib/chunk-TOIVAQF7.mjs +0 -136
  217. package/lib/chunk-V5SKYJUB.mjs +0 -136
  218. package/lib/chunk-WSRETQCA.mjs +0 -59
  219. package/lib/chunk-YYLIQQKF.mjs +0 -31
  220. package/lib/ps/index.d.ts +0 -2
  221. package/lib/ps/index.js +0 -254
  222. package/lib/utils/findEnvFiles.d.ts +0 -8
  223. package/lib/utils/findEnvFiles.js +0 -121
  224. package/tmp/typedoc/readme.md +0 -320
  225. /package/lib/{binary-collections-config.d.cts → binary-collections/config.d.cts} +0 -0
@@ -1,136 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import {
3
- runChatGpt
4
- } from "./chunk-N436BNBK.mjs";
5
- import {
6
- require_binary_collections_config
7
- } from "./chunk-66PAU5PS.mjs";
8
- import {
9
- require_utils
10
- } from "./chunk-Z6JLYU2J.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_binary_collections_config = __toESM(require_binary_collections_config(), 1);
19
- import { execSync } from "child_process";
20
- import fs from "fs-extra";
21
- import path from "upath";
22
- import { fileURLToPath } from "url";
23
- var import_utils = __toESM(require_utils(), 1);
24
- var __filename = fileURLToPath(import.meta.url);
25
- var __dirname = path.dirname(__filename);
26
- var DIFF_OUTPUT = (0, import_binary_collections_config.getTempPath)("git-diff.txt");
27
- var GPT_DIFF_OUTPUT = (0, import_binary_collections_config.getTempPath)("gpt-question.txt");
28
- var CACHE_DIR = path.dirname(DIFF_OUTPUT);
29
- var DIFF_OUTPUT_RELATIVE = path.relative(process.cwd(), DIFF_OUTPUT);
30
- var GPT_DIFF_OUTPUT_RELATIVE = path.relative(process.cwd(), GPT_DIFF_OUTPUT);
31
- if (!fs.existsSync(CACHE_DIR)) {
32
- fs.mkdirSync(CACHE_DIR, { recursive: true });
33
- }
34
- function showHelp() {
35
- console.log("\u{1F4DD} Git Diff Helper");
36
- console.log("\u{1F4C4} Usage:");
37
- console.log(" \u{1F4C2} git-diff FILE Show staged diff of specified file");
38
- console.log(" \u{1F4C2} git-diff --staged-only Show staged diff of all files");
39
- console.log(" \u{1F4C2} git-diff -s | -S Same as --staged-only");
40
- console.log(" \u{1F4C2} git-diff --ai Run ChatGPT automation for commit message");
41
- console.log(" \u{1F4C2} git-diff --help | -h Show this help message");
42
- console.log("");
43
- console.log(`\u{1F4BE} Output is saved to: ${DIFF_OUTPUT_RELATIVE}`);
44
- console.log(`\u{1F916} GPT prompt is saved to: ${GPT_DIFF_OUTPUT_RELATIVE}`);
45
- process.exit(0);
46
- }
47
- function runGitDiff(command, successMessage, errorMessage) {
48
- try {
49
- console.log(`\u{1F50D} [i] Running command: ${command}`);
50
- const result = execSync(command, {
51
- encoding: "utf8",
52
- maxBuffer: 1024 * 1024 * 10
53
- // 10MB buffer to handle large diffs
54
- });
55
- if (!result || result.trim() === "") {
56
- console.log(`\u2139\uFE0F [i] No changes found for the specified criteria`);
57
- fs.writeFileSync(DIFF_OUTPUT, "# No changes found\n");
58
- console.log(`\u2705 Empty diff saved to "${DIFF_OUTPUT_RELATIVE}"`);
59
- return;
60
- }
61
- fs.writeFileSync(DIFF_OUTPUT, result);
62
- fs.writeFileSync(
63
- GPT_DIFF_OUTPUT,
64
- `Hello, ChatGPT!
65
- Can you create a conventional commit message by diff content below:
66
-
67
- \`\`\`${result}
68
- \`\`\`
69
-
70
- Give me result as codeblock with language "text" only.
71
-
72
- Thank you!`
73
- );
74
- console.log(`\u2705 ${successMessage}`);
75
- console.log(`\u{1F4BE} GPT diff prompt saved to "${GPT_DIFF_OUTPUT_RELATIVE}"`);
76
- } catch (error) {
77
- console.error(`\u274C ${errorMessage}`);
78
- console.error(`\u{1F4DD} Command: ${command}`);
79
- console.error(`\u26A0\uFE0F Error: ${error.message}`);
80
- if (error.message.includes("not a git repository")) {
81
- console.error("\u{1F6A7} Make sure you are in a git repository");
82
- }
83
- process.exit(1);
84
- }
85
- }
86
- async function mainGitDiff() {
87
- const args = (0, import_utils.getArgs)();
88
- const positional = args._ || [];
89
- if (args.help || args.h) {
90
- showHelp();
91
- }
92
- if (args["staged-only"] || args.s || args.S) {
93
- runGitDiff(
94
- "git --no-pager diff --staged",
95
- `Full staged diff saved to "${DIFF_OUTPUT_RELATIVE}"`,
96
- "Failed to save staged diff"
97
- );
98
- } else {
99
- const file = positional[0];
100
- if (!file) {
101
- runGitDiff(
102
- "git --no-pager diff",
103
- `Full staged diff saved to "${DIFF_OUTPUT_RELATIVE}"`,
104
- "Failed to save all diff's"
105
- );
106
- } else {
107
- runGitDiff(
108
- `git --no-pager diff --cached -- "${file}"`,
109
- `Staged diff of "${file}" saved to "${DIFF_OUTPUT_RELATIVE}"`,
110
- `Failed to generate diff for "${file}"`
111
- );
112
- }
113
- }
114
- if (args.ai) {
115
- try {
116
- await runChatGpt({ headless: true, questionFile: GPT_DIFF_OUTPUT });
117
- } catch (error) {
118
- console.error("\u274C Error running ChatGPT:", error.message);
119
- console.error("\u{1F4A1} Try running with visible browser mode or check if Chrome is installed");
120
- }
121
- } else {
122
- console.log("\u{1F4A1} Tip: Use --ai flag to generate commit message with ChatGPT");
123
- }
124
- }
125
- var git_diff_default = runGitDiff;
126
-
127
- export {
128
- DIFF_OUTPUT,
129
- GPT_DIFF_OUTPUT,
130
- CACHE_DIR,
131
- DIFF_OUTPUT_RELATIVE,
132
- GPT_DIFF_OUTPUT_RELATIVE,
133
- runGitDiff,
134
- mainGitDiff,
135
- git_diff_default
136
- };
@@ -1,136 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import {
3
- runChatGpt
4
- } from "./chunk-N436BNBK.mjs";
5
- import {
6
- require_binary_collections_config
7
- } from "./chunk-NCXAP7AA.mjs";
8
- import {
9
- require_utils
10
- } from "./chunk-Z6JLYU2J.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_binary_collections_config = __toESM(require_binary_collections_config(), 1);
19
- import { execSync } from "child_process";
20
- import fs from "fs-extra";
21
- import path from "upath";
22
- import { fileURLToPath } from "url";
23
- var import_utils = __toESM(require_utils(), 1);
24
- var __filename = fileURLToPath(import.meta.url);
25
- var __dirname = path.dirname(__filename);
26
- var DIFF_OUTPUT = (0, import_binary_collections_config.getTempPath)("git-diff.txt");
27
- var GPT_DIFF_OUTPUT = (0, import_binary_collections_config.getTempPath)("gpt-question.txt");
28
- var CACHE_DIR = path.dirname(DIFF_OUTPUT);
29
- var DIFF_OUTPUT_RELATIVE = path.relative(process.cwd(), DIFF_OUTPUT);
30
- var GPT_DIFF_OUTPUT_RELATIVE = path.relative(process.cwd(), GPT_DIFF_OUTPUT);
31
- if (!fs.existsSync(CACHE_DIR)) {
32
- fs.mkdirSync(CACHE_DIR, { recursive: true });
33
- }
34
- function showHelp() {
35
- console.log("\u{1F4DD} Git Diff Helper");
36
- console.log("\u{1F4C4} Usage:");
37
- console.log(" \u{1F4C2} git-diff FILE Show staged diff of specified file");
38
- console.log(" \u{1F4C2} git-diff --staged-only Show staged diff of all files");
39
- console.log(" \u{1F4C2} git-diff -s | -S Same as --staged-only");
40
- console.log(" \u{1F4C2} git-diff --ai Run ChatGPT automation for commit message");
41
- console.log(" \u{1F4C2} git-diff --help | -h Show this help message");
42
- console.log("");
43
- console.log(`\u{1F4BE} Output is saved to: ${DIFF_OUTPUT_RELATIVE}`);
44
- console.log(`\u{1F916} GPT prompt is saved to: ${GPT_DIFF_OUTPUT_RELATIVE}`);
45
- process.exit(0);
46
- }
47
- function runGitDiff(command, successMessage, errorMessage) {
48
- try {
49
- console.log(`\u{1F50D} [i] Running command: ${command}`);
50
- const result = execSync(command, {
51
- encoding: "utf8",
52
- maxBuffer: 1024 * 1024 * 10
53
- // 10MB buffer to handle large diffs
54
- });
55
- if (!result || result.trim() === "") {
56
- console.log(`\u2139\uFE0F [i] No changes found for the specified criteria`);
57
- fs.writeFileSync(DIFF_OUTPUT, "# No changes found\n");
58
- console.log(`\u2705 Empty diff saved to "${DIFF_OUTPUT_RELATIVE}"`);
59
- return;
60
- }
61
- fs.writeFileSync(DIFF_OUTPUT, result);
62
- fs.writeFileSync(
63
- GPT_DIFF_OUTPUT,
64
- `Hello, ChatGPT!
65
- Can you create a conventional commit message by diff content below:
66
-
67
- \`\`\`${result}
68
- \`\`\`
69
-
70
- Give me result as codeblock with language "text" only.
71
-
72
- Thank you!`
73
- );
74
- console.log(`\u2705 ${successMessage}`);
75
- console.log(`\u{1F4BE} GPT diff prompt saved to "${GPT_DIFF_OUTPUT_RELATIVE}"`);
76
- } catch (error) {
77
- console.error(`\u274C ${errorMessage}`);
78
- console.error(`\u{1F4DD} Command: ${command}`);
79
- console.error(`\u26A0\uFE0F Error: ${error.message}`);
80
- if (error.message.includes("not a git repository")) {
81
- console.error("\u{1F6A7} Make sure you are in a git repository");
82
- }
83
- process.exit(1);
84
- }
85
- }
86
- async function mainGitDiff() {
87
- const args = (0, import_utils.getArgs)();
88
- const positional = args._ || [];
89
- if (args.help || args.h) {
90
- showHelp();
91
- }
92
- if (args["staged-only"] || args.s || args.S) {
93
- runGitDiff(
94
- "git --no-pager diff --staged",
95
- `Full staged diff saved to "${DIFF_OUTPUT_RELATIVE}"`,
96
- "Failed to save staged diff"
97
- );
98
- } else {
99
- const file = positional[0];
100
- if (!file) {
101
- runGitDiff(
102
- "git --no-pager diff",
103
- `Full staged diff saved to "${DIFF_OUTPUT_RELATIVE}"`,
104
- "Failed to save all diff's"
105
- );
106
- } else {
107
- runGitDiff(
108
- `git --no-pager diff --cached -- "${file}"`,
109
- `Staged diff of "${file}" saved to "${DIFF_OUTPUT_RELATIVE}"`,
110
- `Failed to generate diff for "${file}"`
111
- );
112
- }
113
- }
114
- if (args.ai) {
115
- try {
116
- await runChatGpt({ headless: true, questionFile: GPT_DIFF_OUTPUT });
117
- } catch (error) {
118
- console.error("\u274C Error running ChatGPT:", error.message);
119
- console.error("\u{1F4A1} Try running with visible browser mode or check if Chrome is installed");
120
- }
121
- } else {
122
- console.log("\u{1F4A1} Tip: Use --ai flag to generate commit message with ChatGPT");
123
- }
124
- }
125
- var git_diff_default = runGitDiff;
126
-
127
- export {
128
- DIFF_OUTPUT,
129
- GPT_DIFF_OUTPUT,
130
- CACHE_DIR,
131
- DIFF_OUTPUT_RELATIVE,
132
- GPT_DIFF_OUTPUT_RELATIVE,
133
- runGitDiff,
134
- mainGitDiff,
135
- git_diff_default
136
- };
@@ -1,59 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import {
3
- __commonJS,
4
- __require,
5
- init_esm_shims
6
- } from "./chunk-QQ4A6DLD.mjs";
7
-
8
- // src/submodule-remove.cjs
9
- var require_submodule_remove = __commonJS({
10
- "src/submodule-remove.cjs"(exports, module) {
11
- init_esm_shims();
12
- var { spawnAsync } = __require("cross-spawn");
13
- var path = __require("upath");
14
- var fs = __require("fs-extra");
15
- var dotenv = __require("dotenv");
16
- dotenv.config({ path: path.resolve(process.cwd(), ".env"), override: true, quiet: true });
17
- async function removeSubmodule(submodulePath) {
18
- try {
19
- await spawnAsync("git", ["submodule", "deinit", "-f", submodulePath], { stdio: "inherit" });
20
- } catch (error) {
21
- console.warn(`Warning: Could not deinitialize submodule "${submodulePath}". It may not exist.`);
22
- console.warn(error.message);
23
- }
24
- try {
25
- await spawnAsync("git", ["config", "--remove-section", `submodule.${submodulePath}`], { stdio: "inherit" });
26
- } catch (error) {
27
- console.warn(`Warning: Could not remove git config section for submodule "${submodulePath}". It may not exist.`);
28
- console.warn(error.message);
29
- }
30
- const gitModulesPath = path.resolve(".git", "modules", submodulePath);
31
- if (fs.existsSync(gitModulesPath)) {
32
- fs.rmSync(gitModulesPath, { recursive: true, force: true });
33
- console.log(`Removed .git/modules entry for submodule "${submodulePath}".`);
34
- } else {
35
- console.warn(`Warning: The path "${gitModulesPath}" does not exist. Skipping removal of .git/modules entry.`);
36
- }
37
- const gitmodulesPath = path.resolve(".gitmodules");
38
- if (fs.existsSync(gitmodulesPath)) {
39
- let gitmodulesContent = fs.readFileSync(gitmodulesPath, "utf-8");
40
- const submoduleSectionRegex = new RegExp(
41
- `\\[submodule "${submodulePath.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}"]([\\s\\S]*?)(?=\\[|$)`,
42
- "g"
43
- );
44
- gitmodulesContent = gitmodulesContent.replace(submoduleSectionRegex, "").trim();
45
- fs.writeFileSync(gitmodulesPath, gitmodulesContent);
46
- console.log(`Removed submodule "${submodulePath}" from .gitmodules.`);
47
- } else {
48
- console.warn(`Warning: The .gitmodules file does not exist. Skipping removal of submodule "${submodulePath}".`);
49
- }
50
- fs.rmSync(path.resolve(submodulePath), { recursive: true, force: true });
51
- console.log(`Submodule "${submodulePath}" has been removed.`);
52
- }
53
- module.exports = removeSubmodule;
54
- }
55
- });
56
-
57
- export {
58
- require_submodule_remove
59
- };
@@ -1,31 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import {
3
- __commonJS,
4
- __require,
5
- init_esm_shims
6
- } from "./chunk-QQ4A6DLD.mjs";
7
-
8
- // src/binary-collections-config.cjs
9
- var require_binary_collections_config = __commonJS({
10
- "src/binary-collections-config.cjs"(exports, module) {
11
- init_esm_shims();
12
- var path = __require("path");
13
- __require("dotenv").config({ path: path.join(process.cwd(), ".env"), quiet: true, override: true });
14
- function getTempDir() {
15
- return process.env.TEMP_DIR || path.join(process.cwd(), "tmp");
16
- }
17
- function getTempPath(...segments) {
18
- return path.join(getTempDir(), ...segments);
19
- }
20
- var TEMP_BASE_DIR = getTempDir();
21
- module.exports = {
22
- getTempDir,
23
- getTempPath,
24
- TEMP_BASE_DIR
25
- };
26
- }
27
- });
28
-
29
- export {
30
- require_binary_collections_config
31
- };
package/lib/ps/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- declare const _exports: Function;
2
- export = _exports;
package/lib/ps/index.js DELETED
@@ -1,254 +0,0 @@
1
- "use strict";
2
- var ChildProcess = require("child_process");
3
- var IS_WIN = require("./isWin").default;
4
- var TableParser = require("./table-parser");
5
- /**
6
- * End of line.
7
- * Basically, the EOL should be:
8
- * - windows: \r\n
9
- * - *nix: \n
10
- * But i'm trying to get every possibilities covered.
11
- */
12
- var EOL = /(\r\n)|(\n\r)|\n|\r/;
13
- var SystemEOL = require("os").EOL;
14
- // ps-node
15
- /**
16
- * Execute child process
17
- * @type {Function}
18
- * @param {String[]} args
19
- * @param {Function} callback
20
- * @param {Object=null} callback.err
21
- * @param {Object[]} callback.stdout
22
- */
23
- var Exec = (module.exports =
24
- exports =
25
- function (args, callback) {
26
- var spawn = ChildProcess.spawn;
27
- // on windows, if use ChildProcess.exec(`wmic process get`), the stdout will gives you nothing
28
- // that's why I use `cmd` instead
29
- if (IS_WIN) {
30
- var CMD = spawn("cmd");
31
- var stdout = "";
32
- var stderr = null;
33
- CMD.stdout.on("data", function (data) {
34
- stdout += data.toString();
35
- });
36
- CMD.stderr.on("data", function (data) {
37
- if (stderr === null) {
38
- stderr = data.toString();
39
- }
40
- else {
41
- stderr += data.toString();
42
- }
43
- });
44
- CMD.on("exit", function () {
45
- var beginRow;
46
- stdout = stdout.split(EOL);
47
- // Find the line index for the titles
48
- stdout.forEach(function (out, index) {
49
- if (out && typeof beginRow == "undefined" && out.indexOf("CommandLine") === 0) {
50
- beginRow = index;
51
- }
52
- });
53
- // get rid of the start (copyright) and the end (current pwd)
54
- stdout.splice(stdout.length - 1, 1);
55
- stdout.splice(0, beginRow);
56
- callback(stderr, stdout.join(SystemEOL) || false);
57
- });
58
- CMD.stdin.write("wmic process get ProcessId,ParentProcessId,CommandLine \n");
59
- CMD.stdin.end();
60
- }
61
- else {
62
- if (typeof args === "string") {
63
- args = args.split(/\s+/);
64
- }
65
- const child = spawn("ps", args);
66
- stdout = "";
67
- stderr = null;
68
- child.stdout.on("data", function (data) {
69
- stdout += data.toString();
70
- });
71
- child.stderr.on("data", function (data) {
72
- if (stderr === null) {
73
- stderr = data.toString();
74
- }
75
- else {
76
- stderr += data.toString();
77
- }
78
- });
79
- child.on("exit", function () {
80
- if (stderr) {
81
- return callback(stderr.toString());
82
- }
83
- else {
84
- callback(null, stdout || false);
85
- }
86
- });
87
- }
88
- });
89
- /**
90
- * Query Process: Focus on pid & cmd
91
- * @param query
92
- * @param {String|String[]} query.pid
93
- * @param {String} query.command RegExp String
94
- * @param {String} query.arguments RegExp String
95
- * @param {String|array} query.psargs
96
- * @param {Function} callback
97
- * @param {Object=null} callback.err
98
- * @param {Object[]} callback.processList
99
- * @return {Object}
100
- */
101
- exports.lookup = function (query, callback) {
102
- /**
103
- * add 'lx' as default ps arguments, since the default ps output in linux like "ubuntu", wont include command arguments
104
- */
105
- var exeArgs = query.psargs || ["lx"];
106
- var filter = {};
107
- var idList;
108
- // Lookup by PID
109
- if (query.pid) {
110
- if (Array.isArray(query.pid)) {
111
- idList = query.pid;
112
- }
113
- else {
114
- idList = [query.pid];
115
- }
116
- // Cast all PIDs as Strings
117
- idList = idList.map(function (v) {
118
- return String(v);
119
- });
120
- }
121
- if (query.command) {
122
- filter["command"] = new RegExp(query.command, "i");
123
- }
124
- if (query.arguments) {
125
- filter["arguments"] = new RegExp(query.arguments, "i");
126
- }
127
- if (query.ppid) {
128
- filter["ppid"] = new RegExp(query.ppid);
129
- }
130
- return Exec(exeArgs, function (err, output) {
131
- if (err) {
132
- return callback(err);
133
- }
134
- else {
135
- var processList = parseGrid(output);
136
- var resultList = [];
137
- processList.forEach(function (p) {
138
- var flt;
139
- var type;
140
- var result = true;
141
- if (idList && idList.indexOf(String(p.pid)) < 0) {
142
- return;
143
- }
144
- for (type in filter) {
145
- flt = filter[type];
146
- result = flt.test(p[type]) ? result : false;
147
- }
148
- if (result) {
149
- resultList.push(p);
150
- }
151
- });
152
- callback(null, resultList);
153
- }
154
- });
155
- };
156
- /**
157
- * Kill process
158
- * @param pid
159
- * @param {Object|String} signal
160
- * @param {String} signal.signal
161
- * @param {number} signal.timeout
162
- * @param next
163
- */
164
- exports.kill = function (pid, signal, next) {
165
- //opts are optional
166
- if (arguments.length == 2 && typeof signal == "function") {
167
- next = signal;
168
- signal = undefined;
169
- }
170
- var checkTimeoutSeconds = (signal && signal.timeout) || 30;
171
- if (typeof signal === "object") {
172
- signal = signal.signal;
173
- }
174
- try {
175
- process.kill(pid, signal);
176
- }
177
- catch (e) {
178
- return next && next(e);
179
- }
180
- var checkConfident = 0;
181
- var checkTimeoutTimer = null;
182
- var checkIsTimeout = false;
183
- function checkKilled(finishCallback) {
184
- exports.lookup({ pid: pid }, function (err, list) {
185
- if (checkIsTimeout)
186
- return;
187
- if (err) {
188
- clearTimeout(checkTimeoutTimer);
189
- if (finishCallback)
190
- finishCallback(err);
191
- }
192
- else if (list.length > 0) {
193
- checkConfident = checkConfident - 1 || 0;
194
- checkKilled(finishCallback);
195
- }
196
- else {
197
- checkConfident++;
198
- if (checkConfident === 5) {
199
- clearTimeout(checkTimeoutTimer);
200
- if (finishCallback)
201
- finishCallback();
202
- }
203
- else {
204
- checkKilled(finishCallback);
205
- }
206
- }
207
- });
208
- }
209
- if (next)
210
- checkKilled(next);
211
- checkTimeoutTimer =
212
- next &&
213
- setTimeout(function () {
214
- checkIsTimeout = true;
215
- next(new Error("Kill process timeout"));
216
- }, checkTimeoutSeconds * 1000);
217
- };
218
- /**
219
- * Parse the stdout into readable object.
220
- * @param {String} output
221
- */
222
- function parseGrid(output) {
223
- if (!output) {
224
- return [];
225
- }
226
- return formatOutput(TableParser.parse(output));
227
- }
228
- /**
229
- * format the structure, extract pid, command, arguments, ppid
230
- * @param data
231
- * @return {Array}
232
- */
233
- function formatOutput(data) {
234
- var formatedData = [];
235
- data.forEach(function (d) {
236
- var pid = (d.PID && d.PID[0]) || (d.ProcessId && d.ProcessId[0]) || undefined;
237
- var cmd = d.CMD || d.CommandLine || d.COMMAND || undefined;
238
- var ppid = (d.PPID && d.PPID[0]) || (d.ParentProcessId && d.ParentProcessId[0]) || undefined;
239
- if (pid && cmd) {
240
- var command = cmd[0];
241
- var args = "";
242
- if (cmd.length > 1) {
243
- args = cmd.slice(1);
244
- }
245
- formatedData.push({
246
- pid: pid,
247
- command: command,
248
- arguments: args,
249
- ppid: ppid
250
- });
251
- }
252
- });
253
- return formatedData;
254
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Find .env files.
3
- *
4
- * @param {string} startDir
5
- * @param {(file:string)=>boolean} [filter]
6
- * @returns {string[]}
7
- */
8
- export function findEnvFiles(startDir?: string, filter?: (file: string) => boolean): string[];