binary-collections 2.0.10 → 2.0.11

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 (165) hide show
  1. package/.puppeterrc.cjs +25 -0
  2. package/binaries/binary-executor.cjs +138 -3
  3. package/binaries/clean-nodemodule.cjs +138 -3
  4. package/binaries/clean-nodemodules.cjs +138 -3
  5. package/binaries/dev.cjs +138 -3
  6. package/binaries/empty.cjs +138 -3
  7. package/binaries/git-reduce-size.cjs +138 -3
  8. package/binaries/javakill.cjs +138 -3
  9. package/binaries/kill-night-crows.bat +7 -0
  10. package/binaries/kill-night-crows.ps1 +172 -0
  11. package/binaries/kill-process.cjs +138 -3
  12. package/binaries/nodekill.cjs +138 -3
  13. package/binaries/prod.cjs +138 -3
  14. package/binaries/py +111 -0
  15. package/binaries/py.cjs +178 -0
  16. package/binaries/py.cmd +49 -0
  17. package/binaries/rmfind.cjs +138 -3
  18. package/binaries/rmx.cjs +138 -3
  19. package/binaries/submodule-token.cjs +138 -3
  20. package/binaries/test-cjs +10 -0
  21. package/binaries/test-cjs.cjs +178 -0
  22. package/binaries/test-cjs.cmd +11 -0
  23. package/binaries/yarn-clean +32 -0
  24. package/binaries/yarn-clean.cjs +178 -0
  25. package/binaries/yarn-clean.cmd +30 -0
  26. package/binaries/yarn-clean.py +148 -0
  27. package/lib/binary-collections-config.cjs +1 -1
  28. package/lib/binary-collections-config.mjs +1 -1
  29. package/lib/binary-collections.cjs +167 -106
  30. package/lib/binary-collections.mjs +108 -94
  31. package/lib/changelog.cjs +61 -13
  32. package/lib/changelog.mjs +1 -1
  33. package/lib/{chunk-AI4CVPJ7.mjs → chunk-2CBJCW7E.mjs} +4 -4
  34. package/lib/chunk-34IQDTLZ.mjs +27 -0
  35. package/lib/chunk-3HFFECCI.mjs +27 -0
  36. package/lib/{chunk-SBNDSKG5.mjs → chunk-4UHL4WVN.mjs} +1 -1
  37. package/lib/chunk-7XTEJHOE.mjs +193 -0
  38. package/lib/chunk-AJDD5DZM.mjs +109 -0
  39. package/lib/chunk-BZWVHODJ.mjs +62 -0
  40. package/lib/{chunk-BEZKJ25G.mjs → chunk-FCDQGYBF.mjs} +5 -9
  41. package/lib/chunk-GEYA2USY.mjs +207 -0
  42. package/lib/chunk-ID2WBTE2.mjs +80 -0
  43. package/lib/chunk-JXFOHKDM.mjs +239 -0
  44. package/lib/{chunk-DI5MDPSN.mjs → chunk-N436BNBK.mjs} +192 -64
  45. package/lib/chunk-NCXAP7AA.mjs +31 -0
  46. package/lib/chunk-PDN26I7O.mjs +188 -0
  47. package/lib/{chunk-E6FDDAOO.mjs → chunk-RWLXRTYP.mjs} +1 -1
  48. package/lib/{chunk-BDCHCWHD.mjs → chunk-TOIVAQF7.mjs} +4 -4
  49. package/lib/chunk-V5SKYJUB.mjs +136 -0
  50. package/lib/{chunk-HMRMTYZM.mjs → chunk-WSRETQCA.mjs} +21 -2
  51. package/lib/chunk-XA3SNBPA.mjs +184 -0
  52. package/lib/chunk-YYLIQQKF.mjs +31 -0
  53. package/lib/{chunk-V3N3JEUF.mjs → chunk-Z6JLYU2J.mjs} +60 -13
  54. package/lib/{chunk-O6SWBEOQ.mjs → chunk-ZDMWBSYF.mjs} +2 -2
  55. package/lib/clean-github-actions-caches.cjs +63 -15
  56. package/lib/clean-github-actions-caches.mjs +3 -3
  57. package/lib/del-gradle.cjs +61 -13
  58. package/lib/del-gradle.js +1 -0
  59. package/lib/del-gradle.mjs +1 -1
  60. package/lib/del-node-modules.cjs +143 -148
  61. package/lib/del-node-modules.js +210 -14
  62. package/lib/del-node-modules.mjs +148 -17
  63. package/lib/del-ps.cjs +61 -13
  64. package/lib/del-ps.js +1 -0
  65. package/lib/del-ps.mjs +1 -1
  66. package/lib/del-yarn-caches.cjs +61 -13
  67. package/lib/del-yarn-caches.mjs +1 -1
  68. package/lib/find-node-modules-cli.js +1 -0
  69. package/lib/free-chatgpt.cjs +253 -47
  70. package/lib/free-chatgpt.mjs +2 -2
  71. package/lib/git/gitattributes.cjs +1 -0
  72. package/lib/git/gitattributes.d.cts +7 -2
  73. package/lib/git/gitattributes.mjs +1 -1
  74. package/lib/git/line-endings.cjs +2 -1
  75. package/lib/git/line-endings.mjs +2 -2
  76. package/lib/git/undo-commit-cli.cjs +110 -0
  77. package/lib/git/undo-commit-cli.d.ts +1 -0
  78. package/lib/git/undo-commit-cli.js +4 -0
  79. package/lib/git/undo-commit-cli.mjs +14 -0
  80. package/lib/git/undo-commit.cjs +81 -0
  81. package/lib/git/undo-commit.d.cts +1 -0
  82. package/lib/git/undo-commit.mjs +7 -0
  83. package/lib/git/undo-staged-cli.cjs +110 -0
  84. package/lib/git/undo-staged-cli.d.ts +1 -0
  85. package/lib/git/undo-staged-cli.js +4 -0
  86. package/lib/git/undo-staged-cli.mjs +14 -0
  87. package/lib/git/undo-staged.cjs +81 -0
  88. package/lib/git/undo-staged.d.cts +1 -0
  89. package/lib/git/undo-staged.mjs +7 -0
  90. package/lib/git/user-config.cjs +61 -14
  91. package/lib/git/user-config.mjs +2 -2
  92. package/lib/git-diff-cli.cjs +255 -49
  93. package/lib/git-diff-cli.d.ts +1 -0
  94. package/lib/git-diff-cli.js +1 -0
  95. package/lib/git-diff-cli.mjs +5 -4
  96. package/lib/git-diff.cjs +254 -49
  97. package/lib/git-diff.mjs +4 -4
  98. package/lib/git-fix.cjs +64 -16
  99. package/lib/git-fix.mjs +10 -10
  100. package/lib/git-purge.cjs +61 -13
  101. package/lib/git-purge.mjs +1 -1
  102. package/lib/kill-night-crows.cjs +87 -0
  103. package/lib/kill-night-crows.d.mts +1 -0
  104. package/lib/kill-night-crows.mjs +65 -0
  105. package/lib/npm-run-series.cjs +60 -13
  106. package/lib/npm-run-series.mjs +1 -1
  107. package/lib/package-resolutions-updater-cli.cjs +560 -0
  108. package/lib/package-resolutions-updater-cli.d.mts +1 -0
  109. package/lib/package-resolutions-updater-cli.mjs +124 -0
  110. package/lib/package-resolutions-updater.cjs +174 -154
  111. package/lib/package-resolutions-updater.d.mts +32 -1
  112. package/lib/package-resolutions-updater.mjs +16 -294
  113. package/lib/php-cs-fixer-staged.cjs +105 -0
  114. package/lib/php-cs-fixer-staged.d.cts +2 -0
  115. package/lib/php-cs-fixer-staged.mjs +117 -0
  116. package/lib/print-directory-tree.cjs +62 -14
  117. package/lib/print-directory-tree.mjs +2 -2
  118. package/lib/ps/connected-domain.d.ts +1 -1
  119. package/lib/ps/index.js +1 -0
  120. package/lib/remove-module.cjs +61 -13
  121. package/lib/remove-module.mjs +1 -1
  122. package/lib/rmpath.cjs +63 -15
  123. package/lib/rmpath.mjs +2 -2
  124. package/lib/submodule-install.cjs +62 -15
  125. package/lib/submodule-install.mjs +3 -3
  126. package/lib/submodule-remove-cli.cjs +5 -1
  127. package/lib/submodule-remove-cli.mjs +1 -1
  128. package/lib/submodule-remove.cjs +4 -1
  129. package/lib/submodule-remove.mjs +1 -1
  130. package/lib/utils/chatgpt.cjs +192 -34
  131. package/lib/utils/chatgpt.js +210 -43
  132. package/lib/utils/chatgpt.mjs +1 -1
  133. package/lib/utils/findEnvFiles.cjs +107 -0
  134. package/lib/utils/findEnvFiles.d.ts +8 -0
  135. package/lib/utils/findEnvFiles.js +121 -0
  136. package/lib/utils/findEnvFiles.mjs +8 -0
  137. package/lib/utils/findWorkspaceRoot.cjs +70 -0
  138. package/lib/utils/findWorkspaceRoot.d.ts +9 -0
  139. package/lib/utils/findWorkspaceRoot.js +57 -0
  140. package/lib/utils/findWorkspaceRoot.mjs +40 -0
  141. package/lib/utils/index.cjs +60 -13
  142. package/lib/utils/index.mjs +1 -1
  143. package/lib/utils/isGithubTokenValid.cjs +64 -0
  144. package/lib/utils/isGithubTokenValid.d.ts +7 -0
  145. package/lib/utils/isGithubTokenValid.js +48 -0
  146. package/lib/utils/isGithubTokenValid.mjs +36 -0
  147. package/lib/yarn-reinstall.cjs +61 -13
  148. package/lib/yarn-reinstall.mjs +1 -1
  149. package/package.json +107 -93
  150. package/readme.md +33 -34
  151. package/releases/readme.md +1 -1
  152. package/requirements.txt +1 -0
  153. package/lib/chunk-4EWQC6GZ.mjs +0 -382
  154. package/lib/chunk-4ZI7BQKQ.mjs +0 -381
  155. package/lib/chunk-5J2BEPY5.mjs +0 -83
  156. package/lib/chunk-AGZYRDC2.mjs +0 -323
  157. package/lib/chunk-HN52G2YL.mjs +0 -305
  158. package/lib/chunk-HO6GHCOB.mjs +0 -385
  159. package/lib/chunk-LEM5OMRP.mjs +0 -384
  160. package/lib/chunk-RCP7DHVY.mjs +0 -190
  161. package/lib/chunk-U6SO4QEV.mjs +0 -320
  162. package/lib/chunk-XD6BJK6Q.mjs +0 -351
  163. package/lib/chunk-YXSFGA2D.mjs +0 -383
  164. package/lib/git/gitattributes.d.ts +0 -33
  165. package/lib/git/gitattributes.js +0 -223
@@ -0,0 +1,188 @@
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/git/gitattributes.cjs
9
+ var require_gitattributes = __commonJS({
10
+ "src/git/gitattributes.cjs"(exports, module) {
11
+ init_esm_shims();
12
+ var fs = __require("fs");
13
+ function parseGitAttributes(gitattributesPath) {
14
+ const rules = [];
15
+ if (!fs.existsSync(gitattributesPath)) {
16
+ return rules;
17
+ }
18
+ const content = fs.readFileSync(gitattributesPath, "utf8");
19
+ const lines = content.split("\n");
20
+ lines.forEach((line, index) => {
21
+ const trimmedLine = line.trim();
22
+ if (!trimmedLine || trimmedLine.startsWith("#")) {
23
+ rules.push({
24
+ type: trimmedLine.startsWith("#") ? "comment" : "empty",
25
+ content: line,
26
+ lineNumber: index + 1
27
+ });
28
+ return;
29
+ }
30
+ const parts = trimmedLine.split(/\s+/);
31
+ if (parts.length >= 2) {
32
+ const pattern = parts[0];
33
+ const attributes = parts.slice(1).join(" ");
34
+ rules.push({
35
+ type: "rule",
36
+ pattern,
37
+ attributes,
38
+ content: line,
39
+ lineNumber: index + 1
40
+ });
41
+ } else {
42
+ rules.push({
43
+ type: "invalid",
44
+ content: line,
45
+ lineNumber: index + 1
46
+ });
47
+ }
48
+ });
49
+ return rules;
50
+ }
51
+ function patternsConflict(pattern1, pattern2) {
52
+ if (pattern1 === pattern2) {
53
+ return true;
54
+ }
55
+ if (pattern1 === "*" || pattern2 === "*") {
56
+ return pattern1 !== pattern2;
57
+ }
58
+ const normalize = (p) => p.replace(/\{[^}]+\}/g, "*").replace(/\*+/g, "*");
59
+ const norm1 = normalize(pattern1);
60
+ const norm2 = normalize(pattern2);
61
+ return norm1 === norm2;
62
+ }
63
+ function mergeGitAttributeRules(existingRules, desiredRules) {
64
+ let mergedRules;
65
+ if (existingRules.length === 0) {
66
+ mergedRules = desiredRules.map((desired, idx) => ({
67
+ type: "rule",
68
+ pattern: desired.pattern,
69
+ attributes: desired.attributes,
70
+ content: `${desired.pattern} ${desired.attributes}`,
71
+ lineNumber: idx + 1,
72
+ added: true
73
+ }));
74
+ return {
75
+ mergedRules,
76
+ conflicts: [],
77
+ changes: desiredRules.map((rule) => ({ action: "added", pattern: rule.pattern, attributes: rule.attributes }))
78
+ };
79
+ } else {
80
+ mergedRules = [...existingRules];
81
+ }
82
+ const conflicts = [];
83
+ const changes = [];
84
+ desiredRules.forEach((desired) => {
85
+ const existingIdx = mergedRules.findIndex((r) => r.type === "rule" && r.pattern === desired.pattern);
86
+ if (existingIdx !== -1) {
87
+ const existing = mergedRules[existingIdx];
88
+ if (existing.attributes === desired.attributes) {
89
+ conflicts.push({
90
+ pattern: desired.pattern,
91
+ existing: existing.attributes,
92
+ proposed: desired.attributes,
93
+ action: "kept existing (identical)"
94
+ });
95
+ } else if (desired.priority > (existing.priority || 0)) {
96
+ mergedRules[existingIdx] = {
97
+ type: "rule",
98
+ pattern: desired.pattern,
99
+ attributes: desired.attributes,
100
+ content: `${desired.pattern} ${desired.attributes}`,
101
+ lineNumber: existing.lineNumber,
102
+ replaced: true
103
+ };
104
+ conflicts.push({
105
+ pattern: desired.pattern,
106
+ existing: existing.attributes,
107
+ proposed: desired.attributes,
108
+ action: "replaced (higher priority)"
109
+ });
110
+ changes.push({
111
+ action: "replaced",
112
+ pattern: desired.pattern,
113
+ attributes: desired.attributes,
114
+ oldAttributes: existing.attributes
115
+ });
116
+ } else {
117
+ conflicts.push({
118
+ pattern: desired.pattern,
119
+ existing: existing.attributes,
120
+ proposed: desired.attributes,
121
+ action: "kept existing (lower priority)"
122
+ });
123
+ }
124
+ } else {
125
+ mergedRules.push({
126
+ type: "rule",
127
+ pattern: desired.pattern,
128
+ attributes: desired.attributes,
129
+ content: `${desired.pattern} ${desired.attributes}`,
130
+ lineNumber: mergedRules.length + 1,
131
+ added: true
132
+ });
133
+ changes.push({
134
+ action: "added",
135
+ pattern: desired.pattern,
136
+ attributes: desired.attributes
137
+ });
138
+ }
139
+ });
140
+ return { mergedRules, conflicts, changes };
141
+ }
142
+ function formatGitAttributes(rules) {
143
+ return rules.map((rule) => {
144
+ if (rule.type === "rule") {
145
+ return `${rule.pattern} ${rule.attributes}`;
146
+ }
147
+ return rule.content;
148
+ }).join("\n") + "\n";
149
+ }
150
+ function updateGitAttributes(gitattributesPath, desiredRules) {
151
+ try {
152
+ const existingRules = parseGitAttributes(gitattributesPath);
153
+ const { mergedRules, conflicts, changes } = mergeGitAttributeRules(existingRules, desiredRules);
154
+ let success = false;
155
+ if (changes.length > 0) {
156
+ const newContent = formatGitAttributes(mergedRules);
157
+ fs.writeFileSync(gitattributesPath, newContent);
158
+ success = true;
159
+ }
160
+ return {
161
+ success,
162
+ conflicts,
163
+ changes,
164
+ message: success ? `Updated .gitattributes with ${changes.length} changes` : "No changes needed - all rules already present"
165
+ };
166
+ } catch (error) {
167
+ return {
168
+ success: false,
169
+ error: error.message,
170
+ conflicts: [],
171
+ changes: []
172
+ };
173
+ }
174
+ }
175
+ module.exports = {
176
+ parseGitAttributes,
177
+ patternsConflict,
178
+ mergeGitAttributeRules,
179
+ formatGitAttributes,
180
+ updateGitAttributes
181
+ };
182
+ module.exports.default = module.exports;
183
+ }
184
+ });
185
+
186
+ export {
187
+ require_gitattributes
188
+ };
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-A3VUZEJK.mjs";
5
5
  import {
6
6
  require_utils
7
- } from "./chunk-V3N3JEUF.mjs";
7
+ } from "./chunk-Z6JLYU2J.mjs";
8
8
  import {
9
9
  __commonJS,
10
10
  __require,
@@ -1,13 +1,13 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  runChatGpt
4
- } from "./chunk-GJTGHXRA.mjs";
4
+ } from "./chunk-N436BNBK.mjs";
5
5
  import {
6
6
  require_binary_collections_config
7
7
  } from "./chunk-66PAU5PS.mjs";
8
8
  import {
9
9
  require_utils
10
- } from "./chunk-V3N3JEUF.mjs";
10
+ } from "./chunk-Z6JLYU2J.mjs";
11
11
  import {
12
12
  __toESM,
13
13
  init_esm_shims
@@ -17,8 +17,8 @@ import {
17
17
  init_esm_shims();
18
18
  var import_binary_collections_config = __toESM(require_binary_collections_config(), 1);
19
19
  import { execSync } from "child_process";
20
- import fs from "fs";
21
- import path from "path";
20
+ import fs from "fs-extra";
21
+ import path from "upath";
22
22
  import { fileURLToPath } from "url";
23
23
  var import_utils = __toESM(require_utils(), 1);
24
24
  var __filename = fileURLToPath(import.meta.url);
@@ -0,0 +1,136 @@
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
+ };
@@ -13,9 +13,14 @@ var require_submodule_remove = __commonJS({
13
13
  var path = __require("upath");
14
14
  var fs = __require("fs-extra");
15
15
  var dotenv = __require("dotenv");
16
- dotenv.config({ path: path.resolve(process.cwd(), ".env") });
16
+ dotenv.config({ path: path.resolve(process.cwd(), ".env"), override: true, quiet: true });
17
17
  async function removeSubmodule(submodulePath) {
18
- await spawnAsync("git", ["submodule", "deinit", "-f", submodulePath], { stdio: "inherit" });
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
+ }
19
24
  try {
20
25
  await spawnAsync("git", ["config", "--remove-section", `submodule.${submodulePath}`], { stdio: "inherit" });
21
26
  } catch (error) {
@@ -25,9 +30,23 @@ var require_submodule_remove = __commonJS({
25
30
  const gitModulesPath = path.resolve(".git", "modules", submodulePath);
26
31
  if (fs.existsSync(gitModulesPath)) {
27
32
  fs.rmSync(gitModulesPath, { recursive: true, force: true });
33
+ console.log(`Removed .git/modules entry for submodule "${submodulePath}".`);
28
34
  } else {
29
35
  console.warn(`Warning: The path "${gitModulesPath}" does not exist. Skipping removal of .git/modules entry.`);
30
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
+ }
31
50
  fs.rmSync(path.resolve(submodulePath), { recursive: true, force: true });
32
51
  console.log(`Submodule "${submodulePath}" has been removed.`);
33
52
  }
@@ -0,0 +1,184 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ findEnvFiles
4
+ } from "./chunk-ID2WBTE2.mjs";
5
+ import {
6
+ require_utils
7
+ } from "./chunk-Z6JLYU2J.mjs";
8
+ import {
9
+ __toESM,
10
+ init_esm_shims
11
+ } from "./chunk-QQ4A6DLD.mjs";
12
+
13
+ // src/package-resolutions-updater.mjs
14
+ init_esm_shims();
15
+ var utils = __toESM(require_utils(), 1);
16
+ import * as dotenv from "dotenv";
17
+ import fs from "fs";
18
+ import https from "https";
19
+ import os from "os";
20
+ import path from "path";
21
+ import { parseGitHubUrl } from "git-command-helper";
22
+ var projectDir = process.cwd();
23
+ var envPath = path.join(projectDir, ".env");
24
+ var args = utils.getArgs();
25
+ if (!fs.existsSync(envPath)) {
26
+ const envFiles = findEnvFiles(projectDir, (file) => {
27
+ const content = fs.readFileSync(file, "utf-8");
28
+ return /GITHUB_TOKEN|ACCESS_TOKEN/.test(content);
29
+ });
30
+ if (envFiles.length > 0) {
31
+ envPath = envFiles[0];
32
+ }
33
+ }
34
+ if (fs.existsSync(envPath)) {
35
+ dotenv.config({ path: envPath, quiet: true, override: true });
36
+ }
37
+ var ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
38
+ if (args.help || args.h) {
39
+ showHelp();
40
+ }
41
+ function showHelp() {
42
+ const helpText = `
43
+ GitHub Package Resolutions Updater
44
+ Usage:
45
+ node src/package-resolutions-updater.mjs [options]
46
+ Options:
47
+ --help, -h Show this help message
48
+ Description:
49
+ Updates the commit hashes in package.json's 'resolutions' field for GitHub tarball URLs to point to the latest commit SHA of the corresponding repository and branch.
50
+ Features:
51
+ - Parses GitHub URLs to extract repository owner, name, and branch.
52
+ - Fetches the latest commit SHA across all branches using GitHub's API.
53
+ - Replaces the old branch or commit in the URL with the latest SHA.
54
+ - Overwrites package.json with the updated URLs.
55
+ Requirements:
56
+ - GitHub Personal Access Token (GITHUB_TOKEN) via .env
57
+ - ESM support (type: "module" in package.json)
58
+ - Node.js v18+ recommended
59
+ Dependencies:
60
+ - ansi-colors \u2013 for styled terminal output
61
+ - dotenv \u2013 to load GitHub token from .env
62
+ Examples:
63
+ node src/package-resolutions-updater.mjs
64
+ node src/package-resolutions-updater.mjs --help
65
+
66
+ `;
67
+ console.log(helpText);
68
+ process.exit(0);
69
+ }
70
+ var GITHUB_USER_AGENTS = [
71
+ "octokit-rest.js/19.0.7",
72
+ "GitHub CLI/2.40.0",
73
+ "Mozilla/5.0 (compatible; GitHubCopilot/1.0)",
74
+ "PostmanRuntime/7.32.3",
75
+ "binary-collections-resolver/1.0 (+https://github.com/dimaslanjaka/bin)"
76
+ ];
77
+ var userAgentDir = path.join(os.tmpdir(), "nodejs");
78
+ var userAgentFile = path.join(userAgentDir, "useragent.txt");
79
+ var selectedUserAgent;
80
+ try {
81
+ if (!fs.existsSync(userAgentDir)) fs.mkdirSync(userAgentDir, { recursive: true });
82
+ if (fs.existsSync(userAgentFile)) {
83
+ const fileAgent = fs.readFileSync(userAgentFile, "utf-8").trim();
84
+ if (GITHUB_USER_AGENTS.includes(fileAgent)) {
85
+ selectedUserAgent = fileAgent;
86
+ }
87
+ }
88
+ if (!selectedUserAgent) {
89
+ selectedUserAgent = GITHUB_USER_AGENTS[Math.floor(Math.random() * GITHUB_USER_AGENTS.length)];
90
+ fs.writeFileSync(userAgentFile, selectedUserAgent, "utf-8");
91
+ }
92
+ } catch (_e) {
93
+ selectedUserAgent = GITHUB_USER_AGENTS[Math.floor(Math.random() * GITHUB_USER_AGENTS.length)];
94
+ }
95
+ function fetchJson(url) {
96
+ const headers = {
97
+ "User-Agent": selectedUserAgent,
98
+ Accept: "application/vnd.github.v3+json",
99
+ "X-GitHub-Api-Version": "2022-11-28",
100
+ ...ACCESS_TOKEN ? { Authorization: `token ${ACCESS_TOKEN}` } : {}
101
+ };
102
+ return new Promise((resolve, reject) => {
103
+ https.get(url, { headers }, (res) => {
104
+ let data = "";
105
+ res.on("data", (chunk) => data += chunk);
106
+ res.on("end", () => {
107
+ try {
108
+ const json = JSON.parse(data);
109
+ if (res.statusCode < 200 || res.statusCode >= 300) {
110
+ return reject(
111
+ new Error(`GitHub API Error ${res.statusCode}: ${json.message || "Unknown error"}
112
+ URL: ${url}`)
113
+ );
114
+ }
115
+ resolve(json);
116
+ } catch {
117
+ reject(new Error(`Invalid JSON from: ${url}`));
118
+ }
119
+ });
120
+ }).on("error", reject);
121
+ });
122
+ }
123
+ async function getLatestCommit(owner, repo, branch = "main") {
124
+ var _a, _b, _c, _d;
125
+ const url = `https://api.github.com/repos/${owner}/${repo}/commits/${branch}`;
126
+ const json = await fetchJson(url);
127
+ const sha = json.sha;
128
+ const dateStr = ((_b = (_a = json.commit) == null ? void 0 : _a.committer) == null ? void 0 : _b.date) || ((_d = (_c = json.commit) == null ? void 0 : _c.author) == null ? void 0 : _d.date);
129
+ if (!sha || !dateStr) {
130
+ console.log(json);
131
+ throw new Error(`Missing SHA or date for ${owner}/${repo}@${branch}`);
132
+ }
133
+ return {
134
+ owner,
135
+ repo,
136
+ branch,
137
+ sha,
138
+ date: new Date(dateStr).toISOString()
139
+ };
140
+ }
141
+ async function getLatestCommitAcrossBranches(owner, repo) {
142
+ const branches = await fetchJson(`https://api.github.com/repos/${owner}/${repo}/branches`);
143
+ const commits = await Promise.all(
144
+ branches.map(async ({ name, commit }) => {
145
+ var _a, _b, _c, _d;
146
+ const commitSha = commit == null ? void 0 : commit.sha;
147
+ if (!commitSha) {
148
+ console.warn(`No commit SHA for '${owner}/${repo}' branch: ${name}`);
149
+ return { branch: name, sha: "", date: /* @__PURE__ */ new Date(0) };
150
+ }
151
+ try {
152
+ const commitData = await fetchJson(`https://api.github.com/repos/${owner}/${repo}/commits/${commitSha}`);
153
+ const dateStr = ((_b = (_a = commitData.commit) == null ? void 0 : _a.committer) == null ? void 0 : _b.date) || ((_d = (_c = commitData.commit) == null ? void 0 : _c.author) == null ? void 0 : _d.date);
154
+ const date = dateStr ? new Date(dateStr) : /* @__PURE__ */ new Date(0);
155
+ return { branch: name, sha: commitData.sha, date };
156
+ } catch (e) {
157
+ console.warn(`Failed to fetch commit for ${name}: ${e.message}`);
158
+ return { branch: name, sha: commitSha, date: /* @__PURE__ */ new Date(0) };
159
+ }
160
+ })
161
+ );
162
+ const latest = commits.reduce((a, b) => a.date > b.date ? a : b, { date: /* @__PURE__ */ new Date(0) });
163
+ return {
164
+ owner,
165
+ repo,
166
+ branch: latest.branch,
167
+ sha: latest.sha,
168
+ date: latest.date.toISOString()
169
+ };
170
+ }
171
+ function replaceRawWithLatestHash(url, latestHash) {
172
+ const match = url.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+)\/raw\/([^/]+)\/(.+)$/);
173
+ if (!match) throw new Error("Invalid GitHub raw URL");
174
+ const [, owner, repo, _oldHash, path2] = match;
175
+ return `https://github.com/${owner}/${repo}/raw/${latestHash}/${path2}`;
176
+ }
177
+
178
+ export {
179
+ parseGitHubUrl,
180
+ fetchJson,
181
+ getLatestCommit,
182
+ getLatestCommitAcrossBranches,
183
+ replaceRawWithLatestHash
184
+ };
@@ -0,0 +1,31 @@
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
+ };