binary-collections 2.0.9 → 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 (306) hide show
  1. package/.puppeterrc.cjs +25 -0
  2. package/binaries/binary-executor.cjs +178 -0
  3. package/{bin → binaries}/clean-nodemodule +0 -0
  4. package/binaries/clean-nodemodule.cjs +178 -0
  5. package/binaries/clean-nodemodule.cmd +4 -0
  6. package/{bin → binaries}/clean-nodemodules +0 -0
  7. package/binaries/clean-nodemodules.cjs +178 -0
  8. package/binaries/clean-nodemodules.cmd +5 -0
  9. package/{bin → binaries}/dev +0 -0
  10. package/binaries/dev.cjs +178 -0
  11. package/{bin → binaries}/empty +0 -0
  12. package/binaries/empty.cjs +178 -0
  13. package/{bin → binaries}/git-reduce-size +0 -0
  14. package/binaries/git-reduce-size.cjs +178 -0
  15. package/binaries/javakill.cjs +178 -0
  16. package/{bin → binaries}/javakill.cmd +0 -0
  17. package/binaries/kill-night-crows.bat +7 -0
  18. package/binaries/kill-night-crows.ps1 +172 -0
  19. package/{bin → binaries}/kill-process +0 -0
  20. package/binaries/kill-process.cjs +178 -0
  21. package/binaries/nodekill.cjs +178 -0
  22. package/{bin → binaries}/nodekill.ps1 +0 -0
  23. package/{bin → binaries}/prod +0 -0
  24. package/binaries/prod.cjs +178 -0
  25. package/binaries/py +111 -0
  26. package/binaries/py.cjs +178 -0
  27. package/binaries/py.cmd +49 -0
  28. package/{bin → binaries}/rmfind +0 -0
  29. package/binaries/rmfind.cjs +178 -0
  30. package/{bin → binaries}/rmx +0 -0
  31. package/binaries/rmx.cjs +178 -0
  32. package/{bin → binaries}/submodule-token +0 -0
  33. package/binaries/submodule-token.cjs +178 -0
  34. package/binaries/test-cjs +10 -0
  35. package/binaries/test-cjs.cjs +178 -0
  36. package/binaries/test-cjs.cmd +11 -0
  37. package/binaries/yarn-clean +32 -0
  38. package/binaries/yarn-clean.cjs +178 -0
  39. package/binaries/yarn-clean.cmd +30 -0
  40. package/binaries/yarn-clean.py +148 -0
  41. package/docs-src/clean-github-actions-caches.md +26 -0
  42. package/docs-src/free-chatgpt.md +26 -0
  43. package/lib/binary-collections-config.cjs +3 -2
  44. package/lib/binary-collections-config.mjs +2 -2
  45. package/lib/binary-collections.cjs +513 -105
  46. package/lib/binary-collections.mjs +178 -117
  47. package/lib/changelog.cjs +64 -16
  48. package/lib/changelog.mjs +177 -171
  49. package/lib/{chunk-VVEZVNIV.mjs → chunk-2CBJCW7E.mjs} +3 -3
  50. package/lib/chunk-34IQDTLZ.mjs +27 -0
  51. package/lib/chunk-3HFFECCI.mjs +27 -0
  52. package/lib/chunk-4UHL4WVN.mjs +136 -0
  53. package/lib/{chunk-4BYBVEYC.mjs → chunk-66PAU5PS.mjs} +5 -4
  54. package/lib/chunk-6HHJRKFB.mjs +59 -0
  55. package/lib/chunk-6S4NXESK.mjs +26 -0
  56. package/lib/chunk-7XTEJHOE.mjs +193 -0
  57. package/lib/{chunk-ZYAQRPUL.mjs → chunk-7YD7IPFF.mjs} +2 -2
  58. package/lib/{chunk-SH3L6HHV.mjs → chunk-A2JQXI5Z.mjs} +2 -2
  59. package/lib/{chunk-EGSSKVDH.mjs → chunk-A3VUZEJK.mjs} +1 -1
  60. package/lib/chunk-AJDD5DZM.mjs +109 -0
  61. package/lib/chunk-BZWVHODJ.mjs +62 -0
  62. package/lib/chunk-FCDQGYBF.mjs +136 -0
  63. package/lib/chunk-FKI7IEB5.mjs +172 -0
  64. package/lib/chunk-GEYA2USY.mjs +207 -0
  65. package/lib/chunk-GJTGHXRA.mjs +356 -0
  66. package/lib/{chunk-YV7DO3YV.mjs → chunk-HLGOWBEO.mjs} +1 -1
  67. package/lib/chunk-ID2WBTE2.mjs +80 -0
  68. package/lib/chunk-JXFOHKDM.mjs +239 -0
  69. package/lib/{chunk-YX5U7XDR.mjs → chunk-M3YIYRHT.mjs} +6 -5
  70. package/lib/chunk-N436BNBK.mjs +514 -0
  71. package/lib/chunk-NCXAP7AA.mjs +31 -0
  72. package/lib/chunk-PDN26I7O.mjs +188 -0
  73. package/lib/{chunk-JGR2NW6D.mjs → chunk-PDSXF5HY.mjs} +3 -3
  74. package/lib/{chunk-AASHBCRW.mjs → chunk-QQ4A6DLD.mjs} +8 -0
  75. package/lib/{chunk-ONIBBBQ3.mjs → chunk-RWLXRTYP.mjs} +4 -3
  76. package/lib/chunk-TOIVAQF7.mjs +136 -0
  77. package/lib/chunk-V5SKYJUB.mjs +136 -0
  78. package/lib/chunk-WSRETQCA.mjs +59 -0
  79. package/lib/chunk-XA3SNBPA.mjs +184 -0
  80. package/lib/chunk-XVBFFVCJ.mjs +209 -0
  81. package/lib/chunk-YYLIQQKF.mjs +31 -0
  82. package/lib/{chunk-APBWENF6.mjs → chunk-Z6JLYU2J.mjs} +63 -16
  83. package/lib/chunk-ZDMWBSYF.mjs +81 -0
  84. package/lib/clean-github-actions-caches.cjs +291 -148
  85. package/lib/clean-github-actions-caches.mjs +4 -3
  86. package/lib/del-gradle.cjs +63 -15
  87. package/lib/del-gradle.js +2 -1
  88. package/lib/del-gradle.mjs +2 -2
  89. package/lib/del-node-modules.cjs +143 -148
  90. package/lib/del-node-modules.js +210 -14
  91. package/lib/del-node-modules.mjs +149 -18
  92. package/lib/del-ps.cjs +90 -21
  93. package/lib/del-ps.js +3 -2
  94. package/lib/del-ps.mjs +7 -5
  95. package/lib/del-yarn-caches.cjs +87 -18
  96. package/lib/del-yarn-caches.js +38 -3
  97. package/lib/del-yarn-caches.mjs +6 -6
  98. package/lib/find-node-modules-cli.cjs +5 -4
  99. package/lib/find-node-modules-cli.js +2 -1
  100. package/lib/find-node-modules-cli.mjs +2 -2
  101. package/lib/find-node-modules.cjs +4 -3
  102. package/lib/{find-node-modules.d.ts → find-node-modules.d.cts} +1 -1
  103. package/lib/find-node-modules.mjs +2 -2
  104. package/lib/free-chatgpt.cjs +754 -0
  105. package/lib/free-chatgpt.js +51 -0
  106. package/lib/free-chatgpt.mjs +50 -0
  107. package/lib/git/gitattributes.cjs +2 -1
  108. package/lib/git/{gitattributes.d.ts → gitattributes.d.cts} +7 -2
  109. package/lib/git/gitattributes.mjs +2 -2
  110. package/lib/git/line-endings.cjs +298 -64
  111. package/lib/git/line-endings.mjs +4 -4
  112. package/lib/git/normalize.cjs +26 -36
  113. package/lib/git/normalize.mjs +2 -2
  114. package/lib/git/permissions.cjs +77 -11
  115. package/lib/git/permissions.mjs +3 -3
  116. package/lib/git/pull-strategy.cjs +76 -9
  117. package/lib/git/pull-strategy.mjs +3 -3
  118. package/lib/git/undo-commit-cli.cjs +110 -0
  119. package/lib/git/undo-commit-cli.d.ts +1 -0
  120. package/lib/git/undo-commit-cli.js +4 -0
  121. package/lib/git/undo-commit-cli.mjs +14 -0
  122. package/lib/git/undo-commit.cjs +81 -0
  123. package/lib/git/undo-commit.d.cts +1 -0
  124. package/lib/git/undo-commit.mjs +7 -0
  125. package/lib/git/undo-staged-cli.cjs +110 -0
  126. package/lib/git/undo-staged-cli.d.ts +1 -0
  127. package/lib/git/undo-staged-cli.js +4 -0
  128. package/lib/git/undo-staged-cli.mjs +14 -0
  129. package/lib/git/undo-staged.cjs +81 -0
  130. package/lib/git/undo-staged.d.cts +1 -0
  131. package/lib/git/undo-staged.mjs +7 -0
  132. package/lib/git/user-config.cjs +313 -83
  133. package/lib/git/user-config.mjs +4 -4
  134. package/lib/git/utils.cjs +40 -60
  135. package/lib/git/utils.mjs +2 -2
  136. package/lib/git-diff-cli.cjs +857 -0
  137. package/lib/git-diff-cli.js +16 -0
  138. package/lib/git-diff-cli.mjs +17 -0
  139. package/lib/git-diff.cjs +862 -58
  140. package/lib/git-diff.d.ts +38 -83
  141. package/lib/git-diff.js +152 -0
  142. package/lib/git-diff.mjs +23 -85
  143. package/lib/git-fix.cjs +733 -97
  144. package/lib/git-fix.mjs +10 -9
  145. package/lib/git-purge.cjs +64 -16
  146. package/lib/git-purge.d.cts +1 -0
  147. package/lib/git-purge.mjs +43 -37
  148. package/lib/index.cjs +7 -6
  149. package/lib/index.d.ts +1 -1
  150. package/lib/index.js +2 -5
  151. package/lib/index.mjs +4 -4
  152. package/lib/kill-night-crows.cjs +87 -0
  153. package/lib/kill-night-crows.d.mts +1 -0
  154. package/lib/kill-night-crows.mjs +65 -0
  155. package/lib/npm-run-series.cjs +63 -16
  156. package/lib/npm-run-series.mjs +42 -36
  157. package/lib/package-resolutions-updater-cli.cjs +560 -0
  158. package/lib/package-resolutions-updater-cli.d.mts +1 -0
  159. package/lib/package-resolutions-updater-cli.mjs +124 -0
  160. package/lib/package-resolutions-updater.cjs +178 -158
  161. package/lib/package-resolutions-updater.d.mts +32 -1
  162. package/lib/package-resolutions-updater.mjs +17 -338
  163. package/lib/php-cs-fixer-staged.cjs +105 -0
  164. package/lib/php-cs-fixer-staged.d.cts +2 -0
  165. package/lib/php-cs-fixer-staged.mjs +117 -0
  166. package/lib/print-directory-tree.cjs +320 -207
  167. package/lib/print-directory-tree.mjs +3 -3
  168. package/lib/ps/connected-domain.cjs +25 -2
  169. package/lib/ps/connected-domain.d.ts +10 -2
  170. package/lib/ps/connected-domain.js +5 -2
  171. package/lib/ps/connected-domain.mjs +8 -4
  172. package/lib/ps/index.cjs +345 -322
  173. package/lib/ps/index.d.mjs +1 -1
  174. package/lib/ps/index.js +2 -1
  175. package/lib/ps/index.mjs +179 -182
  176. package/lib/ps/isWin.cjs +24 -1
  177. package/lib/ps/isWin.d.ts +1 -1
  178. package/lib/ps/isWin.js +3 -1
  179. package/lib/ps/isWin.mjs +8 -4
  180. package/lib/ps/table-parser.cjs +167 -159
  181. package/lib/ps/table-parser.d.ts +5 -0
  182. package/lib/ps/table-parser.js +10 -4
  183. package/lib/ps/table-parser.mjs +9 -5
  184. package/lib/remove-module.cjs +310 -0
  185. package/lib/remove-module.d.mts +1 -0
  186. package/lib/remove-module.mjs +111 -0
  187. package/lib/rmpath.cjs +322 -0
  188. package/lib/rmpath.d.mts +3 -0
  189. package/lib/rmpath.mjs +108 -0
  190. package/lib/submodule-install.cjs +311 -86
  191. package/lib/submodule-install.mjs +53 -5
  192. package/lib/submodule-remove-cli.cjs +107 -0
  193. package/lib/submodule-remove-cli.d.ts +1 -0
  194. package/lib/submodule-remove-cli.js +31 -0
  195. package/lib/submodule-remove-cli.mjs +28 -0
  196. package/lib/submodule-remove.cjs +46 -0
  197. package/lib/submodule-remove.d.cts +2 -0
  198. package/lib/submodule-remove.mjs +6 -0
  199. package/lib/utils/chatgpt.cjs +541 -0
  200. package/lib/utils/chatgpt.d.ts +31 -0
  201. package/lib/utils/chatgpt.js +708 -0
  202. package/lib/utils/chatgpt.mjs +8 -0
  203. package/lib/utils/findEnvFiles.cjs +107 -0
  204. package/lib/utils/findEnvFiles.d.ts +8 -0
  205. package/lib/utils/findEnvFiles.js +121 -0
  206. package/lib/utils/findEnvFiles.mjs +8 -0
  207. package/lib/utils/findWorkspaceRoot.cjs +70 -0
  208. package/lib/utils/findWorkspaceRoot.d.ts +9 -0
  209. package/lib/utils/findWorkspaceRoot.js +57 -0
  210. package/lib/utils/findWorkspaceRoot.mjs +40 -0
  211. package/lib/{utils.cjs → utils/index.cjs} +61 -14
  212. package/lib/{utils.mjs → utils/index.mjs} +2 -2
  213. package/lib/utils/isGithubTokenValid.cjs +64 -0
  214. package/lib/utils/isGithubTokenValid.d.ts +7 -0
  215. package/lib/utils/isGithubTokenValid.js +48 -0
  216. package/lib/utils/isGithubTokenValid.mjs +36 -0
  217. package/lib/yarn-reinstall.cjs +220 -38
  218. package/lib/yarn-reinstall.mjs +2 -2
  219. package/package.json +138 -104
  220. package/readme.md +48 -75
  221. package/releases/readme.md +36 -0
  222. package/requirements.txt +1 -0
  223. package/test/README.md +101 -0
  224. package/test/package.json +2 -1
  225. package/test-project/readme.md +26 -0
  226. package/tmp/test-repo/README.md +35 -0
  227. package/tmp/test-repo/package.json +1 -1
  228. package/tmp/typedoc/readme.md +320 -0
  229. package/bin/bash-dummy +0 -56
  230. package/bin/bash-dummy.cmd +0 -25
  231. package/bin/dir-tree.cmd +0 -7
  232. package/bin/git-diff +0 -4
  233. package/bin/git-diff.cmd +0 -7
  234. package/bin/git-fix +0 -36
  235. package/bin/git-fix.cmd +0 -7
  236. package/bin/rmpath +0 -70
  237. package/bin/submodule-install.txt +0 -118
  238. package/bin/submodule-remove +0 -46
  239. package/bin/submodule.txt +0 -172
  240. package/lib/binary-collections-config.d.mts +0 -18
  241. package/lib/binary-collections-config.js +0 -39
  242. package/lib/binary-collections.d.mts +0 -137
  243. package/lib/binary-collections.d.ts +0 -137
  244. package/lib/changelog.d.mts +0 -2
  245. package/lib/changelog.js +0 -226
  246. package/lib/chunk-DPKAJKFO.mjs +0 -171
  247. package/lib/chunk-G3THLIDT.mjs +0 -200
  248. package/lib/chunk-W3ENOM53.mjs +0 -18
  249. package/lib/clean-github-actions-caches.d.mts +0 -169
  250. package/lib/clean-github-actions-caches.d.ts +0 -169
  251. package/lib/del-gradle.d.mts +0 -2
  252. package/lib/del-node-modules.d.mts +0 -2
  253. package/lib/del-ps.d.mts +0 -2
  254. package/lib/del-yarn-caches.d.mts +0 -2
  255. package/lib/find-node-modules-cli.d.mts +0 -1
  256. package/lib/find-node-modules.d.mts +0 -13
  257. package/lib/find-node-modules.js +0 -53
  258. package/lib/git/gitattributes.d.mts +0 -35
  259. package/lib/git/gitattributes.js +0 -223
  260. package/lib/git/line-endings.d.mts +0 -83
  261. package/lib/git/line-endings.d.ts +0 -83
  262. package/lib/git/normalize.d.mts +0 -43
  263. package/lib/git/normalize.d.ts +0 -43
  264. package/lib/git/permissions.d.mts +0 -17
  265. package/lib/git/permissions.d.ts +0 -17
  266. package/lib/git/pull-strategy.d.mts +0 -15
  267. package/lib/git/pull-strategy.d.ts +0 -15
  268. package/lib/git/user-config.d.mts +0 -105
  269. package/lib/git/user-config.d.ts +0 -105
  270. package/lib/git/utils.d.mts +0 -69
  271. package/lib/git/utils.d.ts +0 -69
  272. package/lib/git-diff.d.mts +0 -84
  273. package/lib/git-fix.d.mts +0 -141
  274. package/lib/git-fix.d.ts +0 -141
  275. package/lib/git-purge.d.mts +0 -2
  276. package/lib/git-purge.js +0 -59
  277. package/lib/index.d.mts +0 -1
  278. package/lib/npm-run-series.d.mts +0 -1
  279. package/lib/npm-run-series.js +0 -86
  280. package/lib/package-resolutions-updater.d.ts +0 -352
  281. package/lib/print-directory-tree.d.mts +0 -234
  282. package/lib/print-directory-tree.d.ts +0 -234
  283. package/lib/ps/connected-domain.d.mts +0 -3
  284. package/lib/ps/index.d.d.mts +0 -26
  285. package/lib/ps/index.d.d.ts +0 -26
  286. package/lib/ps/index.d.mts +0 -26
  287. package/lib/ps/isWin.d.mts +0 -3
  288. package/lib/ps/table-parser.d.mts +0 -3
  289. package/lib/submodule-install.d.mts +0 -121
  290. package/lib/submodule-install.d.ts +0 -121
  291. package/lib/utils.d.mts +0 -40
  292. package/lib/utils.js +0 -181
  293. package/lib/yarn-reinstall.d.mts +0 -49
  294. package/lib/yarn-reinstall.d.ts +0 -49
  295. package/src/package-resolutions-updater.mjs +0 -350
  296. package/src/print-directory-tree.cjs +0 -234
  297. package/src/ps/index.js +0 -286
  298. package/src/yarn-reinstall.cjs +0 -49
  299. /package/{bin → binaries}/nodekill +0 -0
  300. /package/{bin → binaries}/nodekill.cmd +0 -0
  301. /package/lib/{binary-collections-config.d.ts → binary-collections-config.d.cts} +0 -0
  302. /package/lib/{changelog.d.ts → changelog.d.cts} +0 -0
  303. /package/lib/{git-purge.d.ts → free-chatgpt.d.ts} +0 -0
  304. /package/lib/{git-diff.d.cts → git-diff-cli.d.ts} +0 -0
  305. /package/lib/{npm-run-series.d.ts → npm-run-series.d.cts} +0 -0
  306. /package/lib/{utils.d.ts → utils/index.d.cts} +0 -0
package/lib/git-fix.cjs CHANGED
@@ -1,129 +1,765 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- var _a, _b;
4
- const { isGitRepository } = require("./git/utils.cjs");
5
- const { forceLfLineEndings } = require("./git/line-endings.cjs");
6
- const { ignoreFilePermissions } = require("./git/permissions.cjs");
7
- const { setPullStrategy } = require("./git/pull-strategy.cjs");
8
- const { configureGitUser } = require("./git/user-config.cjs");
9
- const { normalizeLineEndings } = require("./git/normalize.cjs");
10
- const { getArgs } = require("./utils.js");
11
- const path = require("upath");
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __esm = (fn, res) => function __init() {
4
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
5
+ };
6
+ var __commonJS = (cb, mod) => function __require() {
7
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
8
+ };
9
+
10
+ // node_modules/tsup/assets/cjs_shims.js
11
+ var init_cjs_shims = __esm({
12
+ "node_modules/tsup/assets/cjs_shims.js"() {
13
+ }
14
+ });
15
+
16
+ // src/git/utils.cjs
17
+ var require_utils = __commonJS({
18
+ "src/git/utils.cjs"(exports2, module2) {
19
+ init_cjs_shims();
20
+ var { execSync, spawnSync } = require("child_process");
21
+ function runGitCommand(args2, description) {
22
+ try {
23
+ console.log(`[i] ${description}`);
24
+ const result = spawnSync("git", args2, { encoding: "utf-8" });
25
+ if (result.status !== 0) {
26
+ console.error(`[\u2717] Failed: ${description}`);
27
+ console.error(`Error: ${result.stderr || result.stdout}`);
28
+ return false;
29
+ }
30
+ console.log(`[\u2713] ${description}`);
31
+ return true;
32
+ } catch (error) {
33
+ console.error(`[\u2717] Failed: ${description}`);
34
+ console.error(`Error: ${error.message}`);
35
+ return false;
36
+ }
37
+ }
38
+ function isGitRepository2(cwd) {
39
+ const dir = typeof cwd === "string" ? cwd : process.cwd();
40
+ try {
41
+ execSync("git rev-parse --git-dir", { stdio: "pipe", cwd: dir });
42
+ return true;
43
+ } catch {
44
+ return false;
45
+ }
46
+ }
47
+ function runGitCommandOutput(args2, description) {
48
+ try {
49
+ console.log(`[i] ${description}`);
50
+ const result = spawnSync("git", args2, { encoding: "utf-8" });
51
+ if (result.status !== 0) {
52
+ console.error(`[\u2717] Failed: ${description}`);
53
+ console.error(`Error: ${result.stderr || result.stdout}`);
54
+ return null;
55
+ }
56
+ console.log(`[\u2713] ${description}`);
57
+ return result.stdout.trim();
58
+ } catch (error) {
59
+ console.error(`[\u2717] Failed: ${description}`);
60
+ console.error(`Error: ${error.message}`);
61
+ return null;
62
+ }
63
+ }
64
+ module2.exports = {
65
+ runGitCommand,
66
+ runGitCommandOutput,
67
+ isGitRepository: isGitRepository2
68
+ };
69
+ }
70
+ });
71
+
72
+ // src/git/gitattributes.cjs
73
+ var require_gitattributes = __commonJS({
74
+ "src/git/gitattributes.cjs"(exports2, module2) {
75
+ init_cjs_shims();
76
+ var fs = require("fs");
77
+ function parseGitAttributes(gitattributesPath) {
78
+ const rules = [];
79
+ if (!fs.existsSync(gitattributesPath)) {
80
+ return rules;
81
+ }
82
+ const content = fs.readFileSync(gitattributesPath, "utf8");
83
+ const lines = content.split("\n");
84
+ lines.forEach((line, index) => {
85
+ const trimmedLine = line.trim();
86
+ if (!trimmedLine || trimmedLine.startsWith("#")) {
87
+ rules.push({
88
+ type: trimmedLine.startsWith("#") ? "comment" : "empty",
89
+ content: line,
90
+ lineNumber: index + 1
91
+ });
92
+ return;
93
+ }
94
+ const parts = trimmedLine.split(/\s+/);
95
+ if (parts.length >= 2) {
96
+ const pattern = parts[0];
97
+ const attributes = parts.slice(1).join(" ");
98
+ rules.push({
99
+ type: "rule",
100
+ pattern,
101
+ attributes,
102
+ content: line,
103
+ lineNumber: index + 1
104
+ });
105
+ } else {
106
+ rules.push({
107
+ type: "invalid",
108
+ content: line,
109
+ lineNumber: index + 1
110
+ });
111
+ }
112
+ });
113
+ return rules;
114
+ }
115
+ function patternsConflict(pattern1, pattern2) {
116
+ if (pattern1 === pattern2) {
117
+ return true;
118
+ }
119
+ if (pattern1 === "*" || pattern2 === "*") {
120
+ return pattern1 !== pattern2;
121
+ }
122
+ const normalize = (p) => p.replace(/\{[^}]+\}/g, "*").replace(/\*+/g, "*");
123
+ const norm1 = normalize(pattern1);
124
+ const norm2 = normalize(pattern2);
125
+ return norm1 === norm2;
126
+ }
127
+ function mergeGitAttributeRules(existingRules, desiredRules) {
128
+ let mergedRules;
129
+ if (existingRules.length === 0) {
130
+ mergedRules = desiredRules.map((desired, idx) => ({
131
+ type: "rule",
132
+ pattern: desired.pattern,
133
+ attributes: desired.attributes,
134
+ content: `${desired.pattern} ${desired.attributes}`,
135
+ lineNumber: idx + 1,
136
+ added: true
137
+ }));
138
+ return {
139
+ mergedRules,
140
+ conflicts: [],
141
+ changes: desiredRules.map((rule) => ({ action: "added", pattern: rule.pattern, attributes: rule.attributes }))
142
+ };
143
+ } else {
144
+ mergedRules = [...existingRules];
145
+ }
146
+ const conflicts = [];
147
+ const changes = [];
148
+ desiredRules.forEach((desired) => {
149
+ const existingIdx = mergedRules.findIndex((r) => r.type === "rule" && r.pattern === desired.pattern);
150
+ if (existingIdx !== -1) {
151
+ const existing = mergedRules[existingIdx];
152
+ if (existing.attributes === desired.attributes) {
153
+ conflicts.push({
154
+ pattern: desired.pattern,
155
+ existing: existing.attributes,
156
+ proposed: desired.attributes,
157
+ action: "kept existing (identical)"
158
+ });
159
+ } else if (desired.priority > (existing.priority || 0)) {
160
+ mergedRules[existingIdx] = {
161
+ type: "rule",
162
+ pattern: desired.pattern,
163
+ attributes: desired.attributes,
164
+ content: `${desired.pattern} ${desired.attributes}`,
165
+ lineNumber: existing.lineNumber,
166
+ replaced: true
167
+ };
168
+ conflicts.push({
169
+ pattern: desired.pattern,
170
+ existing: existing.attributes,
171
+ proposed: desired.attributes,
172
+ action: "replaced (higher priority)"
173
+ });
174
+ changes.push({
175
+ action: "replaced",
176
+ pattern: desired.pattern,
177
+ attributes: desired.attributes,
178
+ oldAttributes: existing.attributes
179
+ });
180
+ } else {
181
+ conflicts.push({
182
+ pattern: desired.pattern,
183
+ existing: existing.attributes,
184
+ proposed: desired.attributes,
185
+ action: "kept existing (lower priority)"
186
+ });
187
+ }
188
+ } else {
189
+ mergedRules.push({
190
+ type: "rule",
191
+ pattern: desired.pattern,
192
+ attributes: desired.attributes,
193
+ content: `${desired.pattern} ${desired.attributes}`,
194
+ lineNumber: mergedRules.length + 1,
195
+ added: true
196
+ });
197
+ changes.push({
198
+ action: "added",
199
+ pattern: desired.pattern,
200
+ attributes: desired.attributes
201
+ });
202
+ }
203
+ });
204
+ return { mergedRules, conflicts, changes };
205
+ }
206
+ function formatGitAttributes(rules) {
207
+ return rules.map((rule) => {
208
+ if (rule.type === "rule") {
209
+ return `${rule.pattern} ${rule.attributes}`;
210
+ }
211
+ return rule.content;
212
+ }).join("\n") + "\n";
213
+ }
214
+ function updateGitAttributes(gitattributesPath, desiredRules) {
215
+ try {
216
+ const existingRules = parseGitAttributes(gitattributesPath);
217
+ const { mergedRules, conflicts, changes } = mergeGitAttributeRules(existingRules, desiredRules);
218
+ let success = false;
219
+ if (changes.length > 0) {
220
+ const newContent = formatGitAttributes(mergedRules);
221
+ fs.writeFileSync(gitattributesPath, newContent);
222
+ success = true;
223
+ }
224
+ return {
225
+ success,
226
+ conflicts,
227
+ changes,
228
+ message: success ? `Updated .gitattributes with ${changes.length} changes` : "No changes needed - all rules already present"
229
+ };
230
+ } catch (error) {
231
+ return {
232
+ success: false,
233
+ error: error.message,
234
+ conflicts: [],
235
+ changes: []
236
+ };
237
+ }
238
+ }
239
+ module2.exports = {
240
+ parseGitAttributes,
241
+ patternsConflict,
242
+ mergeGitAttributeRules,
243
+ formatGitAttributes,
244
+ updateGitAttributes
245
+ };
246
+ module2.exports.default = module2.exports;
247
+ }
248
+ });
249
+
250
+ // src/git/line-endings.cjs
251
+ var require_line_endings = __commonJS({
252
+ "src/git/line-endings.cjs"(exports2, module2) {
253
+ init_cjs_shims();
254
+ var path2 = require("upath");
255
+ var fs = require("fs");
256
+ var { runGitCommand } = require_utils();
257
+ var { updateGitAttributes } = require_gitattributes();
258
+ function forceLfLineEndings2() {
259
+ console.log("\n=== Configuring LF Line Endings ===");
260
+ runGitCommand(["config", "core.autocrlf", "false"], "Disable automatic CRLF conversion");
261
+ runGitCommand(["config", "core.eol", "lf"], "Set end-of-line to LF");
262
+ const gitattributesPath = path2.join(process.cwd(), ".gitattributes");
263
+ if (fs.existsSync(gitattributesPath)) {
264
+ let content = fs.readFileSync(gitattributesPath, "utf8");
265
+ if (!/^\*\s+text=auto\s+eol=lf/m.test(content)) {
266
+ content = `* text=auto eol=lf
267
+ ` + content;
268
+ fs.writeFileSync(gitattributesPath, content);
269
+ }
270
+ }
271
+ const desiredRules = [
272
+ { pattern: "*", attributes: "text=auto eol=lf", priority: 1 },
273
+ {
274
+ pattern: "*.{cmd,bat,ps1,sh,cmd1,cmd2,bat1,bat2,vbs}",
275
+ attributes: "text eol=crlf",
276
+ priority: 2
277
+ },
278
+ {
279
+ pattern: "*.{png,jpg,jpeg,gif,ico,svg,bmp,webp,avif,tiff,tif,psd,ai,eps,raw}",
280
+ attributes: "binary",
281
+ priority: 3
282
+ },
283
+ {
284
+ pattern: "*.{zip,tar,gz,7z,rar,exe,dll,so,bin,jar,war,ear,apk,msi,deb,rpm,iso,img,dmg,pdf,mp3,mp4,mov,avi,mkv,flv,wmv,ogg,webm,wav,aac,m4a,otf,ttf,woff,woff2,eot}",
285
+ attributes: "binary",
286
+ priority: 3
287
+ }
288
+ ];
289
+ const result = updateGitAttributes(gitattributesPath, desiredRules);
290
+ if (result.error) {
291
+ console.log(`[\u2717] Error updating .gitattributes: ${result.error}`);
292
+ return;
293
+ }
294
+ if (result.conflicts.length > 0) {
295
+ console.log("\n[!] Detected conflicts in .gitattributes:");
296
+ result.conflicts.forEach((conflict) => {
297
+ console.log(` ${conflict.pattern}: ${conflict.existing} -> ${conflict.proposed} (${conflict.action})`);
298
+ });
299
+ }
300
+ if (result.success) {
301
+ console.log(`[\u2713] ${result.message}:`);
302
+ result.changes.forEach((change) => {
303
+ console.log(` ${change.action}: ${change.pattern} ${change.attributes}`);
304
+ });
305
+ } else {
306
+ console.log(`[i] ${result.message}`);
307
+ }
308
+ }
309
+ module2.exports = {
310
+ forceLfLineEndings: forceLfLineEndings2
311
+ };
312
+ }
313
+ });
314
+
315
+ // src/git/permissions.cjs
316
+ var require_permissions = __commonJS({
317
+ "src/git/permissions.cjs"(exports2, module2) {
318
+ init_cjs_shims();
319
+ var { runGitCommand } = require_utils();
320
+ function ignoreFilePermissions2() {
321
+ console.log("\n=== Configuring File Permissions ===");
322
+ runGitCommand(["config", "core.filemode", "false"], "Ignore file permission changes");
323
+ runGitCommand(["config", "diff.ignoreSubmodules", "dirty"], "Ignore submodule permission changes");
324
+ }
325
+ module2.exports = {
326
+ ignoreFilePermissions: ignoreFilePermissions2
327
+ };
328
+ }
329
+ });
330
+
331
+ // src/git/pull-strategy.cjs
332
+ var require_pull_strategy = __commonJS({
333
+ "src/git/pull-strategy.cjs"(exports2, module2) {
334
+ init_cjs_shims();
335
+ var { runGitCommand } = require_utils();
336
+ function setPullStrategy2() {
337
+ console.log("\n=== Configuring Pull Strategy ===");
338
+ runGitCommand(["config", "pull.rebase", "false"], "Disable automatic rebase on pull");
339
+ }
340
+ module2.exports = {
341
+ setPullStrategy: setPullStrategy2
342
+ };
343
+ }
344
+ });
345
+
346
+ // src/utils/index.cjs
347
+ var require_utils2 = __commonJS({
348
+ "src/utils/index.cjs"(exports2, module2) {
349
+ init_cjs_shims();
350
+ var fs = require("fs");
351
+ var path2 = require("upath");
352
+ var argv = require("minimist")(process.argv.slice(2));
353
+ var { exec } = require("child_process");
354
+ var { URL: URL2 } = require("url");
355
+ var { promisify } = require("util");
356
+ var execAsync = promisify(exec);
357
+ async function parseGitRemotes() {
358
+ try {
359
+ const { stdout } = await execAsync("git remote -v");
360
+ const lines = stdout.split("\n");
361
+ const remotes = {};
362
+ lines.forEach((line) => {
363
+ const [name, url] = line.split(" ");
364
+ if (name && url) {
365
+ const [repoUrl] = url.split(" ");
366
+ try {
367
+ const parsedUrl = new URL2(repoUrl);
368
+ const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
369
+ if (parsedUrl.hostname === "github.com" && pathParts.length === 2) {
370
+ let repoPath = pathParts.join("/");
371
+ if (repoPath.endsWith(".git")) {
372
+ repoPath = repoPath.slice(0, -4);
373
+ }
374
+ remotes[name] = repoPath;
375
+ }
376
+ } catch (e) {
377
+ console.error("URL Parsing Error:", e.message);
378
+ }
379
+ }
380
+ });
381
+ return remotes;
382
+ } catch (error) {
383
+ console.error("Error:", error.message);
384
+ return {};
385
+ }
386
+ }
387
+ module2.exports.parseGitRemotes = parseGitRemotes;
388
+ function joinPathPreserveDriveLetter(...segments) {
389
+ let fullPath = require("path").join(...segments);
390
+ if (/^[a-z]:\\/.test(fullPath)) {
391
+ fullPath = fullPath.charAt(0).toUpperCase() + fullPath.slice(1);
392
+ }
393
+ return fullPath;
394
+ }
395
+ module2.exports.joinPathPreserveDriveLetter = joinPathPreserveDriveLetter;
396
+ function getArgs2() {
397
+ return argv;
398
+ }
399
+ module2.exports.getArgs = getArgs2;
400
+ function del(fullPath) {
401
+ try {
402
+ if (!fs.existsSync(fullPath)) return;
403
+ const stat = fs.lstatSync(fullPath);
404
+ if (stat.isSymbolicLink()) {
405
+ try {
406
+ fs.unlinkSync(fullPath);
407
+ console.log("deleted symlink", fullPath);
408
+ } catch (e) {
409
+ console.log("failed delete symlink", fullPath, e && e.message);
410
+ }
411
+ return;
412
+ }
413
+ if (stat.isDirectory()) {
414
+ const subdir = fs.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
415
+ for (let i = 0; i < subdir.length; i++) {
416
+ del(subdir[i]);
417
+ }
418
+ try {
419
+ fs.rmdirSync(fullPath);
420
+ console.log("deleted", fullPath);
421
+ } catch (e) {
422
+ try {
423
+ fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
424
+ console.log("deleted", fullPath);
425
+ } catch (ee) {
426
+ console.log("failed delete", fullPath, ee && ee.message);
427
+ }
428
+ }
429
+ return;
430
+ }
431
+ try {
432
+ fs.unlinkSync(fullPath);
433
+ console.log("deleted", fullPath);
434
+ } catch (e) {
435
+ try {
436
+ fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
437
+ console.log("deleted", fullPath);
438
+ } catch (ee) {
439
+ console.log("failed delete", fullPath, ee && ee.message);
440
+ }
441
+ }
442
+ } catch (err) {
443
+ console.log("failed delete", fullPath, err && err.message);
444
+ }
445
+ }
446
+ module2.exports.del = del;
447
+ function delStream(globStream) {
448
+ globStream.stream().on("data", (result) => {
449
+ const fullPath = path2.resolve(process.cwd(), result);
450
+ try {
451
+ if (fs.existsSync(fullPath)) {
452
+ const stat = fs.lstatSync(fullPath);
453
+ if (stat.isSymbolicLink()) {
454
+ try {
455
+ fs.unlinkSync(fullPath);
456
+ console.log("deleted symlink", fullPath);
457
+ } catch (e) {
458
+ console.log("failed delete symlink", fullPath, e && e.message);
459
+ }
460
+ return;
461
+ }
462
+ if (stat.isDirectory()) {
463
+ const subdir = fs.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
464
+ for (let i = 0; i < subdir.length; i++) {
465
+ del(subdir[i]);
466
+ }
467
+ }
468
+ }
469
+ del(fullPath);
470
+ } catch (err) {
471
+ console.log("failed processing", fullPath, err && err.message);
472
+ }
473
+ });
474
+ }
475
+ module2.exports.delStream = delStream;
476
+ function getFileTreeString(hashArray) {
477
+ const tree = {};
478
+ const hashMap = {};
479
+ for (const entry of hashArray) {
480
+ const [filePath, hash] = entry.split(" ");
481
+ hashMap[filePath] = hash;
482
+ const parts = filePath.split("/");
483
+ let current = tree;
484
+ for (let i = 0; i < parts.length; i++) {
485
+ const part = parts[i];
486
+ if (i === parts.length - 1) {
487
+ current[part] = null;
488
+ } else {
489
+ current[part] = current[part] || {};
490
+ current = current[part];
491
+ }
492
+ }
493
+ }
494
+ function printNode(node, prefix = "", parentPath = "") {
495
+ const keys = Object.keys(node).sort();
496
+ let lines = [];
497
+ keys.forEach((key, idx) => {
498
+ const isLast = idx === keys.length - 1;
499
+ const branch = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
500
+ const currentPath = parentPath ? parentPath + "/" + key : key;
501
+ if (node[key] === null) {
502
+ lines.push(prefix + branch + key + " [" + (hashMap[currentPath] || "") + "]");
503
+ } else {
504
+ lines.push(prefix + branch + key + "/");
505
+ lines = lines.concat(printNode(node[key], prefix + (isLast ? " " : "\u2502 "), currentPath));
506
+ }
507
+ });
508
+ return lines;
509
+ }
510
+ return printNode(tree, "", "").join("\n");
511
+ }
512
+ module2.exports.getFileTreeString = getFileTreeString;
513
+ var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
514
+ module2.exports.delay = delay;
515
+ }
516
+ });
517
+
518
+ // src/git/user-config.cjs
519
+ var require_user_config = __commonJS({
520
+ "src/git/user-config.cjs"(exports2, module2) {
521
+ init_cjs_shims();
522
+ var gch = require("git-command-helper");
523
+ var { runGitCommand, runGitCommandOutput } = require_utils();
524
+ var { getArgs: getArgs2 } = require_utils2();
525
+ require("dotenv").config({ path: require("path").join(process.cwd(), ".env"), quiet: true });
526
+ function configureGitUser2(cliUser = null, cliEmail = null, options2 = {}) {
527
+ console.log("\n=== Configuring Git User ===");
528
+ let username, email;
529
+ if (cliUser && cliEmail) {
530
+ username = cliUser.trim();
531
+ email = cliEmail.trim();
532
+ console.log("[i] Using CLI-provided user configuration");
533
+ } else {
534
+ username = process.env.GITHUB_USER ? process.env.GITHUB_USER.trim() : void 0;
535
+ email = process.env.GITHUB_EMAIL ? process.env.GITHUB_EMAIL.trim() : void 0;
536
+ if (username || email) {
537
+ console.log("[i] Using environment variable user configuration");
538
+ }
539
+ }
540
+ if (!username && !email) {
541
+ console.log("[i] No Git user configuration needed (no CLI args or environment variables set)");
542
+ return;
543
+ }
544
+ if (username) {
545
+ const success = runGitCommand(["config", "user.name", username], `Set Git username to "${username}"`);
546
+ if (!success) {
547
+ console.log("[i] Failed to set Git username, but continuing...");
548
+ }
549
+ } else {
550
+ console.log("[i] No username provided, skipping username configuration");
551
+ }
552
+ if (email) {
553
+ const success = runGitCommand(["config", "user.email", email], `Set Git email to "${email}"`);
554
+ if (!success) {
555
+ console.log("[i] Failed to set Git email, but continuing...");
556
+ }
557
+ } else {
558
+ console.log("[i] No email provided, skipping email configuration");
559
+ }
560
+ if (username || email) {
561
+ console.log("[\u2713] Git user configuration completed");
562
+ }
563
+ if (username) {
564
+ const remoteUrl = runGitCommandOutput(["remote", "get-url", "origin"], "Fetching remote URL for verification");
565
+ if (remoteUrl) {
566
+ console.log(`[i] Remote URL: ${remoteUrl}`);
567
+ const parsedUrl = gch.parseGitHubUrl(remoteUrl);
568
+ if (parsedUrl && parsedUrl.owner && username && parsedUrl.owner.toLowerCase() !== username.toLowerCase()) {
569
+ console.warn(
570
+ `
571
+ [!] The GitHub remote owner ("${parsedUrl.owner}") does not match the configured username ("${username}").`
572
+ );
573
+ console.warn(`[!] If this is not intentional, consider updating the remote URL to use your username.`);
574
+ console.warn(`[!] Example: git remote set-url origin https://github.com/${username}/<repo>.git
575
+ `);
576
+ const args2 = getArgs2();
577
+ const updateRemote = options2.updateRemote || args2["update-remote"] === true;
578
+ if (updateRemote) {
579
+ let newUrl = remoteUrl;
580
+ if (/^https:\/\//.test(remoteUrl)) {
581
+ newUrl = remoteUrl.replace(/https:\/\/(?:[^@]+@)?github.com/, `https://${username}@github.com`);
582
+ } else if (/^git@github.com:/.test(remoteUrl)) {
583
+ console.warn(
584
+ `[!] For SSH remotes, set your SSH config or use HTTPS with username if you want to change authentication user.`
585
+ );
586
+ return;
587
+ }
588
+ if (newUrl !== remoteUrl) {
589
+ const updated = runGitCommand(["remote", "set-url", "origin", newUrl], `Set origin to ${newUrl}`);
590
+ if (updated) {
591
+ console.log(`[\u2713] Remote URL updated to: ${newUrl}`);
592
+ } else {
593
+ console.warn(`[!] Failed to update remote URL. Please update it manually if needed.`);
594
+ }
595
+ } else {
596
+ console.log(`[i] Remote URL does not use HTTPS or already contains the username.`);
597
+ }
598
+ } else {
599
+ console.log(`[i] Remote URL not changed. Use --update-remote to update automatically.`);
600
+ }
601
+ }
602
+ }
603
+ }
604
+ }
605
+ module2.exports = {
606
+ configureGitUser: configureGitUser2
607
+ };
608
+ }
609
+ });
610
+
611
+ // src/git/normalize.cjs
612
+ var require_normalize = __commonJS({
613
+ "src/git/normalize.cjs"(exports2, module2) {
614
+ init_cjs_shims();
615
+ var { execSync } = require("child_process");
616
+ function normalizeLineEndings2() {
617
+ console.log("\n=== Normalizing Existing Files ===");
618
+ try {
619
+ const result = execSync("git ls-files", { encoding: "utf-8", stdio: "pipe" });
620
+ if (!result.trim()) {
621
+ console.log("[i] No tracked files to normalize");
622
+ return;
623
+ }
624
+ console.log("[i] Refreshing index to detect line ending changes...");
625
+ execSync("git add --renormalize .", { stdio: "pipe" });
626
+ try {
627
+ const statusResult = execSync("git status --porcelain", { encoding: "utf-8", stdio: "pipe" });
628
+ if (statusResult.trim()) {
629
+ console.log("[\u2713] Line endings normalized for tracked files");
630
+ console.log("[i] Files with updated line endings are now staged");
631
+ console.log("[i] Run 'git status' to see the changes");
632
+ } else {
633
+ console.log("[\u2713] All files already have correct line endings");
634
+ }
635
+ } catch {
636
+ console.log("[\u2713] Line ending normalization completed");
637
+ }
638
+ } catch (error) {
639
+ console.error("[\u2717] Failed to normalize line endings");
640
+ console.error(`Error: ${error.message}`);
641
+ }
642
+ }
643
+ module2.exports = {
644
+ normalizeLineEndings: normalizeLineEndings2
645
+ };
646
+ }
647
+ });
648
+
649
+ // src/git-fix.cjs
650
+ init_cjs_shims();
651
+ var { isGitRepository } = require_utils();
652
+ var { forceLfLineEndings } = require_line_endings();
653
+ var { ignoreFilePermissions } = require_permissions();
654
+ var { setPullStrategy } = require_pull_strategy();
655
+ var { configureGitUser } = require_user_config();
656
+ var { normalizeLineEndings } = require_normalize();
657
+ var { getArgs } = require_utils2();
658
+ var path = require("upath");
659
+ require("dotenv").config({ path: path.join(process.cwd(), ".env"), quiet: true, override: true });
12
660
  function showHelp() {
13
- console.log("Git Fix Utility");
14
- console.log("----------------------------");
15
- console.log("Fixes common Git configuration issues:");
16
- console.log(" Forces LF line endings (core.autocrlf = false)");
17
- console.log(" Ignores file permission changes (core.filemode = false)");
18
- console.log(" Sets pull strategy to false (prevents auto-rebase)");
19
- console.log(" Normalizes existing line endings");
20
- console.log(" Configures Git user from environment variables");
21
- console.log("");
22
- console.log("Usage:");
23
- console.log(" git-fix Apply all fixes");
24
- console.log(" git-fix --lf-only Force LF line endings only");
25
- console.log(" git-fix --permissions Ignore file permissions only");
26
- console.log(" git-fix --normalize Normalize existing files only");
27
- console.log(" git-fix --user Configure Git user from environment");
28
- console.log(" git-fix --user NAME EMAIL Configure Git user with specified name and email");
29
- console.log(" git-fix --help | -h Show this help message");
30
- console.log("");
31
- console.log("Options can be combined: git-fix --lf-only --permissions");
32
- console.log("");
33
- console.log("User configuration precedence:");
34
- console.log(" 1. CLI arguments (--user NAME EMAIL)");
35
- console.log(" 2. Environment variables (GITHUB_USER, GITHUB_EMAIL)");
36
- console.log(" 3. Skip if neither provided");
37
- console.log("");
38
- console.log("Environment variables for --user option:");
39
- console.log(" GITHUB_USER - Git username (for user.name)");
40
- console.log(" GITHUB_EMAIL - Git email (for user.email)");
41
- process.exit(0);
661
+ console.log("Git Fix Utility");
662
+ console.log("----------------------------");
663
+ console.log("Fixes common Git configuration issues:");
664
+ console.log("\u2022 Forces LF line endings (core.autocrlf = false)");
665
+ console.log("\u2022 Ignores file permission changes (core.filemode = false)");
666
+ console.log("\u2022 Sets pull strategy to false (prevents auto-rebase)");
667
+ console.log("\u2022 Normalizes existing line endings");
668
+ console.log("\u2022 Configures Git user from environment variables");
669
+ console.log("");
670
+ console.log("Usage:");
671
+ console.log(" git-fix Apply all fixes");
672
+ console.log(" git-fix --lf-only Force LF line endings only");
673
+ console.log(" git-fix --permissions Ignore file permissions only");
674
+ console.log(" git-fix --normalize Normalize existing files only");
675
+ console.log(" git-fix --user Configure Git user from environment");
676
+ console.log(" git-fix --user NAME EMAIL Configure Git user with specified name and email");
677
+ console.log(" git-fix --help | -h Show this help message");
678
+ console.log("");
679
+ console.log("Options can be combined: git-fix --lf-only --permissions");
680
+ console.log("");
681
+ console.log("User configuration precedence:");
682
+ console.log(" 1. CLI arguments (--user NAME EMAIL)");
683
+ console.log(" 2. Environment variables (GITHUB_USER, GITHUB_EMAIL)");
684
+ console.log(" 3. Skip if neither provided");
685
+ console.log("");
686
+ console.log("Environment variables for --user option:");
687
+ console.log(" GITHUB_USER - Git username (for user.name)");
688
+ console.log(" GITHUB_EMAIL - Git email (for user.email)");
689
+ process.exit(0);
42
690
  }
43
- const args = getArgs();
44
- let userConfig = { hasUserFlag: false, cliUser: null, cliEmail: null };
691
+ var args = getArgs();
692
+ var userConfig = { hasUserFlag: false, cliUser: null, cliEmail: null };
45
693
  if (Object.prototype.hasOwnProperty.call(args, "user")) {
46
- userConfig.hasUserFlag = true;
47
- // args.user can be string, array, or boolean
48
- if (Array.isArray(args.user)) {
49
- if (args.user.length === 2) {
50
- userConfig.cliUser = args.user[0];
51
- userConfig.cliEmail = args.user[1];
52
- }
53
- else if (args.user.length === 1) {
54
- // Only one value provided, error
55
- console.error("[✗] Error: --user requires both NAME and EMAIL or no arguments");
56
- console.error("Usage: --user (uses environment variables) or --user NAME EMAIL");
57
- process.exit(1);
58
- }
59
- // If length === 0, treat as env
60
- }
61
- else if (typeof args.user === "string") {
62
- // Only one value provided, error
63
- console.error("[✗] Error: --user requires both NAME and EMAIL or no arguments");
64
- console.error("Usage: --user (uses environment variables) or --user NAME EMAIL");
65
- process.exit(1);
694
+ userConfig.hasUserFlag = true;
695
+ if (Array.isArray(args.user)) {
696
+ if (args.user.length === 2) {
697
+ userConfig.cliUser = args.user[0];
698
+ userConfig.cliEmail = args.user[1];
699
+ } else if (args.user.length === 1) {
700
+ console.error("[\u2717] Error: --user requires both NAME and EMAIL or no arguments");
701
+ console.error("Usage: --user (uses environment variables) or --user NAME EMAIL");
702
+ process.exit(1);
66
703
  }
704
+ } else if (typeof args.user === "string") {
705
+ console.error("[\u2717] Error: --user requires both NAME and EMAIL or no arguments");
706
+ console.error("Usage: --user (uses environment variables) or --user NAME EMAIL");
707
+ process.exit(1);
708
+ }
67
709
  }
68
- // Show help if requested
69
710
  if (args.help || args.h) {
70
- showHelp();
71
- process.exit(0); // Exit after showing help
711
+ showHelp();
712
+ process.exit(0);
72
713
  }
73
714
  console.log("[i] Current working directory:", path.toUnix(process.cwd()));
74
- // Check if we're in a git repository
75
715
  if (!isGitRepository(process.cwd())) {
76
- console.error("[] Error: Not in a git repository");
77
- console.error("Please run this command from within a git repository");
78
- process.exit(1);
79
- }
80
- else {
81
- console.log("[✓] Detected git repository");
716
+ console.error("[\u2717] Error: Not in a git repository");
717
+ console.error("Please run this command from within a git repository");
718
+ process.exit(1);
719
+ } else {
720
+ console.log("[\u2713] Detected git repository");
82
721
  }
83
722
  console.log("Git Fix Utility");
84
723
  console.log("===============");
85
- // Parse options
86
- const options = {
87
- lfOnly: args["lf-only"] === true,
88
- permissions: args["permissions"] === true,
89
- normalize: args["normalize"] === true,
90
- user: userConfig.hasUserFlag,
91
- updateRemote: args["update-remote"] === true,
92
- all: Object.keys(args).filter((k) => k !== "_" && args[k] === true).length === 0 && !userConfig.hasUserFlag
724
+ var options = {
725
+ lfOnly: args["lf-only"] === true,
726
+ permissions: args["permissions"] === true,
727
+ normalize: args["normalize"] === true,
728
+ user: userConfig.hasUserFlag,
729
+ updateRemote: args["update-remote"] === true,
730
+ all: Object.keys(args).filter((k) => k !== "_" && args[k] === true).length === 0 && !userConfig.hasUserFlag
93
731
  };
94
- // Execute requested fixes
95
732
  if (options.all || options.lfOnly) {
96
- forceLfLineEndings();
733
+ forceLfLineEndings();
97
734
  }
98
735
  if (options.all || options.permissions) {
99
- ignoreFilePermissions();
736
+ ignoreFilePermissions();
100
737
  }
101
738
  if (options.all) {
102
- setPullStrategy();
739
+ setPullStrategy();
103
740
  }
104
741
  if (options.all || options.user) {
105
- configureGitUser(userConfig.cliUser, userConfig.cliEmail, { updateRemote: options.updateRemote });
106
- }
107
- else if (options.updateRemote) {
108
- // If --update-remote is present without --user or --all, still call configureGitUser
109
- configureGitUser(null, null, { updateRemote: true });
742
+ configureGitUser(userConfig.cliUser, userConfig.cliEmail, { updateRemote: options.updateRemote });
743
+ } else if (options.updateRemote) {
744
+ configureGitUser(null, null, { updateRemote: true });
110
745
  }
111
746
  if (options.all || options.normalize) {
112
- normalizeLineEndings();
747
+ normalizeLineEndings();
113
748
  }
114
749
  console.log("\n=== Summary ===");
115
- console.log("[] Git fix utility completed successfully");
750
+ console.log("[\u2713] Git fix utility completed successfully");
116
751
  if (options.all || options.lfOnly || options.normalize) {
117
- console.log("[i] Line endings are now configured for LF");
752
+ console.log("[i] Line endings are now configured for LF");
118
753
  }
119
754
  if (options.all || options.permissions) {
120
- console.log("[i] File permission changes will be ignored");
755
+ console.log("[i] File permission changes will be ignored");
121
756
  }
757
+ var _a, _b;
122
758
  if (options.all || options.user) {
123
- const username = userConfig.cliUser || ((_a = process.env.GITHUB_USER) === null || _a === void 0 ? void 0 : _a.trim());
124
- const email = userConfig.cliEmail || ((_b = process.env.GITHUB_EMAIL) === null || _b === void 0 ? void 0 : _b.trim());
125
- if (username || email) {
126
- console.log("[i] Git user configuration has been applied");
127
- }
759
+ const username = userConfig.cliUser || ((_a = process.env.GITHUB_USER) == null ? void 0 : _a.trim());
760
+ const email = userConfig.cliEmail || ((_b = process.env.GITHUB_EMAIL) == null ? void 0 : _b.trim());
761
+ if (username || email) {
762
+ console.log("[i] Git user configuration has been applied");
763
+ }
128
764
  }
129
765
  console.log("[i] Repository is ready for cross-platform development");