binary-collections 2.0.8 → 2.0.10
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.
- package/binaries/binary-executor.cjs +43 -0
- package/{bin → binaries}/clean-nodemodule +0 -0
- package/binaries/clean-nodemodule.cjs +43 -0
- package/binaries/clean-nodemodule.cmd +4 -0
- package/{bin → binaries}/clean-nodemodules +0 -0
- package/binaries/clean-nodemodules.cjs +43 -0
- package/binaries/clean-nodemodules.cmd +5 -0
- package/{bin → binaries}/dev +0 -0
- package/binaries/dev.cjs +43 -0
- package/{bin → binaries}/empty +0 -0
- package/binaries/empty.cjs +43 -0
- package/{bin → binaries}/git-reduce-size +0 -0
- package/binaries/git-reduce-size.cjs +43 -0
- package/binaries/javakill.cjs +43 -0
- package/{bin → binaries}/javakill.cmd +0 -0
- package/{bin → binaries}/kill-process +0 -0
- package/binaries/kill-process.cjs +43 -0
- package/binaries/nodekill.cjs +43 -0
- package/{bin → binaries}/nodekill.ps1 +0 -0
- package/{bin → binaries}/prod +0 -0
- package/binaries/prod.cjs +43 -0
- package/{bin → binaries}/rmfind +0 -0
- package/binaries/rmfind.cjs +43 -0
- package/{bin → binaries}/rmx +0 -0
- package/binaries/rmx.cjs +43 -0
- package/{bin → binaries}/submodule-token +0 -0
- package/binaries/submodule-token.cjs +43 -0
- package/docs-src/clean-github-actions-caches.md +26 -0
- package/docs-src/free-chatgpt.md +26 -0
- package/lib/binary-collections-config.cjs +3 -2
- package/lib/binary-collections-config.mjs +2 -2
- package/lib/binary-collections.cjs +452 -87
- package/lib/binary-collections.mjs +247 -8
- package/lib/changelog.cjs +328 -0
- package/lib/changelog.mjs +205 -0
- package/lib/chunk-4EWQC6GZ.mjs +382 -0
- package/lib/chunk-4ZI7BQKQ.mjs +381 -0
- package/lib/chunk-5J2BEPY5.mjs +83 -0
- package/lib/{chunk-4BYBVEYC.mjs → chunk-66PAU5PS.mjs} +5 -4
- package/lib/chunk-6HHJRKFB.mjs +59 -0
- package/lib/chunk-6S4NXESK.mjs +26 -0
- package/lib/{chunk-ZYAQRPUL.mjs → chunk-7YD7IPFF.mjs} +2 -2
- package/lib/{chunk-SH3L6HHV.mjs → chunk-A2JQXI5Z.mjs} +2 -2
- package/lib/{chunk-EGSSKVDH.mjs → chunk-A3VUZEJK.mjs} +1 -1
- package/lib/chunk-AGZYRDC2.mjs +323 -0
- package/lib/{chunk-VVEZVNIV.mjs → chunk-AI4CVPJ7.mjs} +6 -6
- package/lib/chunk-BDCHCWHD.mjs +136 -0
- package/lib/chunk-BEZKJ25G.mjs +140 -0
- package/lib/chunk-DI5MDPSN.mjs +386 -0
- package/lib/{chunk-ONIBBBQ3.mjs → chunk-E6FDDAOO.mjs} +4 -3
- package/lib/chunk-FKI7IEB5.mjs +172 -0
- package/lib/chunk-GJTGHXRA.mjs +356 -0
- package/lib/{chunk-YV7DO3YV.mjs → chunk-HLGOWBEO.mjs} +1 -1
- package/lib/chunk-HMRMTYZM.mjs +40 -0
- package/lib/chunk-HN52G2YL.mjs +305 -0
- package/lib/chunk-HO6GHCOB.mjs +385 -0
- package/lib/chunk-LEM5OMRP.mjs +384 -0
- package/lib/{chunk-YX5U7XDR.mjs → chunk-M3YIYRHT.mjs} +6 -5
- package/lib/chunk-O6SWBEOQ.mjs +81 -0
- package/lib/{chunk-JGR2NW6D.mjs → chunk-PDSXF5HY.mjs} +3 -3
- package/lib/{chunk-AASHBCRW.mjs → chunk-QQ4A6DLD.mjs} +8 -0
- package/lib/chunk-RCP7DHVY.mjs +190 -0
- package/lib/chunk-SBNDSKG5.mjs +136 -0
- package/lib/chunk-U6SO4QEV.mjs +320 -0
- package/lib/{chunk-APBWENF6.mjs → chunk-V3N3JEUF.mjs} +3 -3
- package/lib/chunk-XD6BJK6Q.mjs +351 -0
- package/lib/chunk-XVBFFVCJ.mjs +209 -0
- package/lib/chunk-YXSFGA2D.mjs +383 -0
- package/lib/clean-github-actions-caches.cjs +243 -148
- package/lib/clean-github-actions-caches.mjs +4 -3
- package/lib/del-gradle.cjs +2 -2
- package/lib/del-gradle.js +1 -1
- package/lib/del-gradle.mjs +2 -2
- package/lib/del-node-modules.cjs +2 -2
- package/lib/del-node-modules.js +1 -1
- package/lib/del-node-modules.mjs +2 -2
- package/lib/del-ps.cjs +29 -8
- package/lib/del-ps.js +2 -2
- package/lib/del-ps.mjs +7 -5
- package/lib/del-yarn-caches.cjs +26 -5
- package/lib/del-yarn-caches.js +38 -3
- package/lib/del-yarn-caches.mjs +6 -6
- package/lib/find-node-modules-cli.cjs +5 -4
- package/lib/find-node-modules-cli.js +1 -1
- package/lib/find-node-modules-cli.mjs +2 -2
- package/lib/find-node-modules.cjs +4 -3
- package/lib/{find-node-modules.d.ts → find-node-modules.d.cts} +1 -1
- package/lib/find-node-modules.mjs +2 -2
- package/lib/free-chatgpt.cjs +548 -0
- package/lib/free-chatgpt.d.ts +1 -0
- package/lib/free-chatgpt.js +51 -0
- package/lib/free-chatgpt.mjs +50 -0
- package/lib/git/gitattributes.cjs +1 -1
- package/lib/git/{gitattributes.d.mts → gitattributes.d.cts} +5 -7
- package/lib/git/gitattributes.mjs +2 -2
- package/lib/git/line-endings.cjs +297 -64
- package/lib/git/line-endings.mjs +4 -4
- package/lib/git/normalize.cjs +26 -36
- package/lib/git/normalize.mjs +2 -2
- package/lib/git/permissions.cjs +77 -11
- package/lib/git/permissions.mjs +3 -3
- package/lib/git/pull-strategy.cjs +76 -9
- package/lib/git/pull-strategy.mjs +3 -3
- package/lib/git/user-config.cjs +266 -83
- package/lib/git/user-config.mjs +4 -4
- package/lib/git/utils.cjs +40 -60
- package/lib/git/utils.mjs +2 -2
- package/lib/git-diff-cli.cjs +651 -0
- package/lib/git-diff-cli.d.ts +1 -0
- package/lib/git-diff-cli.js +15 -0
- package/lib/git-diff-cli.mjs +16 -0
- package/lib/git-diff.cjs +657 -58
- package/lib/git-diff.d.ts +38 -83
- package/lib/git-diff.js +152 -0
- package/lib/git-diff.mjs +23 -85
- package/lib/git-fix.cjs +685 -97
- package/lib/git-fix.mjs +12 -11
- package/lib/git-purge.cjs +3 -3
- package/lib/git-purge.d.cts +1 -0
- package/lib/git-purge.mjs +43 -37
- package/lib/index.cjs +7 -6
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -5
- package/lib/index.mjs +4 -4
- package/lib/npm-run-series.cjs +3 -3
- package/lib/npm-run-series.mjs +42 -36
- package/lib/package-resolutions-updater.cjs +174 -1
- package/lib/package-resolutions-updater.mjs +270 -290
- package/lib/print-directory-tree.cjs +275 -210
- package/lib/print-directory-tree.mjs +2 -2
- package/lib/ps/connected-domain.cjs +25 -2
- package/lib/ps/connected-domain.d.ts +10 -2
- package/lib/ps/connected-domain.js +5 -2
- package/lib/ps/connected-domain.mjs +8 -4
- package/lib/ps/index.cjs +345 -322
- package/lib/ps/index.d.mjs +1 -1
- package/lib/ps/index.js +1 -1
- package/lib/ps/index.mjs +179 -182
- package/lib/ps/isWin.cjs +24 -1
- package/lib/ps/isWin.d.ts +1 -1
- package/lib/ps/isWin.js +3 -1
- package/lib/ps/isWin.mjs +8 -4
- package/lib/ps/table-parser.cjs +167 -159
- package/lib/ps/table-parser.d.ts +5 -0
- package/lib/ps/table-parser.js +10 -4
- package/lib/ps/table-parser.mjs +9 -5
- package/lib/remove-module.cjs +262 -0
- package/lib/remove-module.d.mts +1 -0
- package/lib/remove-module.mjs +111 -0
- package/lib/rmpath.cjs +274 -0
- package/lib/rmpath.d.mts +3 -0
- package/lib/rmpath.mjs +108 -0
- package/lib/submodule-install.cjs +264 -85
- package/lib/submodule-install.mjs +56 -7
- package/lib/submodule-remove-cli.cjs +103 -0
- package/lib/submodule-remove-cli.d.ts +1 -0
- package/lib/submodule-remove-cli.js +31 -0
- package/lib/submodule-remove-cli.mjs +28 -0
- package/lib/submodule-remove.cjs +43 -0
- package/lib/submodule-remove.d.cts +2 -0
- package/lib/submodule-remove.mjs +6 -0
- package/lib/utils/chatgpt.cjs +383 -0
- package/lib/utils/chatgpt.d.ts +31 -0
- package/lib/utils/chatgpt.js +541 -0
- package/lib/utils/chatgpt.mjs +8 -0
- package/lib/{utils.cjs → utils/index.cjs} +1 -1
- package/lib/{utils.mjs → utils/index.mjs} +2 -2
- package/lib/yarn-reinstall.cjs +172 -38
- package/lib/yarn-reinstall.mjs +2 -2
- package/package.json +91 -71
- package/readme.md +43 -69
- package/releases/readme.md +36 -0
- package/test/README.md +101 -0
- package/test/package.json +2 -1
- package/test-project/readme.md +26 -0
- package/tmp/test-repo/README.md +35 -0
- package/tmp/typedoc/readme.md +320 -0
- package/bin/bash-dummy +0 -56
- package/bin/bash-dummy.cmd +0 -25
- package/bin/dir-tree.cmd +0 -7
- package/bin/git-diff +0 -4
- package/bin/git-diff.cmd +0 -7
- package/bin/git-fix +0 -36
- package/bin/git-fix.cmd +0 -7
- package/bin/rmpath +0 -70
- package/bin/submodule-install.txt +0 -118
- package/bin/submodule-remove +0 -46
- package/bin/submodule.txt +0 -172
- package/lib/binary-collections-config.d.mts +0 -18
- package/lib/binary-collections-config.js +0 -39
- package/lib/binary-collections.d.mts +0 -121
- package/lib/binary-collections.d.ts +0 -121
- package/lib/chunk-DPKAJKFO.mjs +0 -171
- package/lib/chunk-G3THLIDT.mjs +0 -200
- package/lib/chunk-W3ENOM53.mjs +0 -18
- package/lib/clean-github-actions-caches.d.mts +0 -169
- package/lib/clean-github-actions-caches.d.ts +0 -169
- package/lib/del-gradle.d.mts +0 -2
- package/lib/del-node-modules.d.mts +0 -2
- package/lib/del-ps.d.mts +0 -2
- package/lib/del-yarn-caches.d.mts +0 -2
- package/lib/find-node-modules-cli.d.mts +0 -1
- package/lib/find-node-modules.d.mts +0 -13
- package/lib/find-node-modules.js +0 -53
- package/lib/git/line-endings.d.mts +0 -83
- package/lib/git/line-endings.d.ts +0 -83
- package/lib/git/normalize.d.mts +0 -43
- package/lib/git/normalize.d.ts +0 -43
- package/lib/git/permissions.d.mts +0 -17
- package/lib/git/permissions.d.ts +0 -17
- package/lib/git/pull-strategy.d.mts +0 -15
- package/lib/git/pull-strategy.d.ts +0 -15
- package/lib/git/user-config.d.mts +0 -105
- package/lib/git/user-config.d.ts +0 -105
- package/lib/git/utils.d.mts +0 -69
- package/lib/git/utils.d.ts +0 -69
- package/lib/git-diff.d.mts +0 -84
- package/lib/git-fix.d.mts +0 -141
- package/lib/git-fix.d.ts +0 -141
- package/lib/git-purge.d.mts +0 -2
- package/lib/git-purge.js +0 -59
- package/lib/index.d.mts +0 -1
- package/lib/npm-run-series.d.mts +0 -1
- package/lib/npm-run-series.d.ts +0 -2
- package/lib/npm-run-series.js +0 -86
- package/lib/package-resolutions-updater.d.ts +0 -326
- package/lib/print-directory-tree.d.mts +0 -234
- package/lib/print-directory-tree.d.ts +0 -234
- package/lib/ps/connected-domain.d.mts +0 -3
- package/lib/ps/index.d.d.mts +0 -26
- package/lib/ps/index.d.d.ts +0 -26
- package/lib/ps/index.d.mts +0 -26
- package/lib/ps/isWin.d.mts +0 -3
- package/lib/ps/table-parser.d.mts +0 -3
- package/lib/submodule-install.d.mts +0 -121
- package/lib/submodule-install.d.ts +0 -121
- package/lib/utils.d.mts +0 -40
- package/lib/utils.js +0 -181
- package/lib/yarn-reinstall.d.mts +0 -49
- package/lib/yarn-reinstall.d.ts +0 -49
- package/src/package-resolutions-updater.mjs +0 -325
- package/src/print-directory-tree.cjs +0 -234
- package/src/ps/index.js +0 -286
- package/src/yarn-reinstall.cjs +0 -49
- /package/{bin → binaries}/nodekill +0 -0
- /package/{bin → binaries}/nodekill.cmd +0 -0
- /package/lib/{binary-collections-config.d.ts → binary-collections-config.d.cts} +0 -0
- /package/lib/{git-purge.d.ts → changelog.d.cts} +0 -0
- /package/lib/{git-diff.d.cts → npm-run-series.d.cts} +0 -0
- /package/lib/{utils.d.ts → utils/index.d.cts} +0 -0
package/lib/git-fix.cjs
CHANGED
|
@@ -1,129 +1,717 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
}
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
// src/git/line-endings.cjs
|
|
250
|
+
var require_line_endings = __commonJS({
|
|
251
|
+
"src/git/line-endings.cjs"(exports2, module2) {
|
|
252
|
+
init_cjs_shims();
|
|
253
|
+
var path2 = require("upath");
|
|
254
|
+
var fs = require("fs");
|
|
255
|
+
var { runGitCommand } = require_utils();
|
|
256
|
+
var { updateGitAttributes } = require_gitattributes().default;
|
|
257
|
+
function forceLfLineEndings2() {
|
|
258
|
+
console.log("\n=== Configuring LF Line Endings ===");
|
|
259
|
+
runGitCommand(["config", "core.autocrlf", "false"], "Disable automatic CRLF conversion");
|
|
260
|
+
runGitCommand(["config", "core.eol", "lf"], "Set end-of-line to LF");
|
|
261
|
+
const gitattributesPath = path2.join(process.cwd(), ".gitattributes");
|
|
262
|
+
if (fs.existsSync(gitattributesPath)) {
|
|
263
|
+
let content = fs.readFileSync(gitattributesPath, "utf8");
|
|
264
|
+
if (!/^\*\s+text=auto\s+eol=lf/m.test(content)) {
|
|
265
|
+
content = `* text=auto eol=lf
|
|
266
|
+
` + content;
|
|
267
|
+
fs.writeFileSync(gitattributesPath, content);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
const desiredRules = [
|
|
271
|
+
{ pattern: "*", attributes: "text=auto eol=lf", priority: 1 },
|
|
272
|
+
{
|
|
273
|
+
pattern: "*.{cmd,bat,ps1,sh,cmd1,cmd2,bat1,bat2,vbs}",
|
|
274
|
+
attributes: "text eol=crlf",
|
|
275
|
+
priority: 2
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
pattern: "*.{png,jpg,jpeg,gif,ico,svg,bmp,webp,avif,tiff,tif,psd,ai,eps,raw}",
|
|
279
|
+
attributes: "binary",
|
|
280
|
+
priority: 3
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
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}",
|
|
284
|
+
attributes: "binary",
|
|
285
|
+
priority: 3
|
|
286
|
+
}
|
|
287
|
+
];
|
|
288
|
+
const result = updateGitAttributes(gitattributesPath, desiredRules);
|
|
289
|
+
if (result.error) {
|
|
290
|
+
console.log(`[\u2717] Error updating .gitattributes: ${result.error}`);
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
if (result.conflicts.length > 0) {
|
|
294
|
+
console.log("\n[!] Detected conflicts in .gitattributes:");
|
|
295
|
+
result.conflicts.forEach((conflict) => {
|
|
296
|
+
console.log(` ${conflict.pattern}: ${conflict.existing} -> ${conflict.proposed} (${conflict.action})`);
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
if (result.success) {
|
|
300
|
+
console.log(`[\u2713] ${result.message}:`);
|
|
301
|
+
result.changes.forEach((change) => {
|
|
302
|
+
console.log(` ${change.action}: ${change.pattern} ${change.attributes}`);
|
|
303
|
+
});
|
|
304
|
+
} else {
|
|
305
|
+
console.log(`[i] ${result.message}`);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
module2.exports = {
|
|
309
|
+
forceLfLineEndings: forceLfLineEndings2
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
// src/git/permissions.cjs
|
|
315
|
+
var require_permissions = __commonJS({
|
|
316
|
+
"src/git/permissions.cjs"(exports2, module2) {
|
|
317
|
+
init_cjs_shims();
|
|
318
|
+
var { runGitCommand } = require_utils();
|
|
319
|
+
function ignoreFilePermissions2() {
|
|
320
|
+
console.log("\n=== Configuring File Permissions ===");
|
|
321
|
+
runGitCommand(["config", "core.filemode", "false"], "Ignore file permission changes");
|
|
322
|
+
runGitCommand(["config", "diff.ignoreSubmodules", "dirty"], "Ignore submodule permission changes");
|
|
323
|
+
}
|
|
324
|
+
module2.exports = {
|
|
325
|
+
ignoreFilePermissions: ignoreFilePermissions2
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
// src/git/pull-strategy.cjs
|
|
331
|
+
var require_pull_strategy = __commonJS({
|
|
332
|
+
"src/git/pull-strategy.cjs"(exports2, module2) {
|
|
333
|
+
init_cjs_shims();
|
|
334
|
+
var { runGitCommand } = require_utils();
|
|
335
|
+
function setPullStrategy2() {
|
|
336
|
+
console.log("\n=== Configuring Pull Strategy ===");
|
|
337
|
+
runGitCommand(["config", "pull.rebase", "false"], "Disable automatic rebase on pull");
|
|
338
|
+
}
|
|
339
|
+
module2.exports = {
|
|
340
|
+
setPullStrategy: setPullStrategy2
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
// src/utils/index.cjs
|
|
346
|
+
var require_utils2 = __commonJS({
|
|
347
|
+
"src/utils/index.cjs"(exports2, module2) {
|
|
348
|
+
init_cjs_shims();
|
|
349
|
+
var fs = require("fs");
|
|
350
|
+
var path2 = require("upath");
|
|
351
|
+
var argv = require("minimist")(process.argv.slice(2));
|
|
352
|
+
var { exec } = require("child_process");
|
|
353
|
+
var { URL: URL2 } = require("url");
|
|
354
|
+
var { promisify } = require("util");
|
|
355
|
+
var execAsync = promisify(exec);
|
|
356
|
+
async function parseGitRemotes() {
|
|
357
|
+
try {
|
|
358
|
+
const { stdout } = await execAsync("git remote -v");
|
|
359
|
+
const lines = stdout.split("\n");
|
|
360
|
+
const remotes = {};
|
|
361
|
+
lines.forEach((line) => {
|
|
362
|
+
const [name, url] = line.split(" ");
|
|
363
|
+
if (name && url) {
|
|
364
|
+
const [repoUrl] = url.split(" ");
|
|
365
|
+
try {
|
|
366
|
+
const parsedUrl = new URL2(repoUrl);
|
|
367
|
+
const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
|
|
368
|
+
if (parsedUrl.hostname === "github.com" && pathParts.length === 2) {
|
|
369
|
+
let repoPath = pathParts.join("/");
|
|
370
|
+
if (repoPath.endsWith(".git")) {
|
|
371
|
+
repoPath = repoPath.slice(0, -4);
|
|
372
|
+
}
|
|
373
|
+
remotes[name] = repoPath;
|
|
374
|
+
}
|
|
375
|
+
} catch (e) {
|
|
376
|
+
console.error("URL Parsing Error:", e.message);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
return remotes;
|
|
381
|
+
} catch (error) {
|
|
382
|
+
console.error("Error:", error.message);
|
|
383
|
+
return {};
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
module2.exports.parseGitRemotes = parseGitRemotes;
|
|
387
|
+
function joinPathPreserveDriveLetter(...segments) {
|
|
388
|
+
let fullPath = require("path").join(...segments);
|
|
389
|
+
if (/^[a-z]:\\/.test(fullPath)) {
|
|
390
|
+
fullPath = fullPath.charAt(0).toUpperCase() + fullPath.slice(1);
|
|
391
|
+
}
|
|
392
|
+
return fullPath;
|
|
393
|
+
}
|
|
394
|
+
module2.exports.joinPathPreserveDriveLetter = joinPathPreserveDriveLetter;
|
|
395
|
+
function getArgs2() {
|
|
396
|
+
return argv;
|
|
397
|
+
}
|
|
398
|
+
module2.exports.getArgs = getArgs2;
|
|
399
|
+
function del(fullPath) {
|
|
400
|
+
if (fs.statSync(fullPath).isDirectory()) {
|
|
401
|
+
const subdir = fs.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
|
|
402
|
+
for (let i = 0; i < subdir.length; i++) {
|
|
403
|
+
del(subdir[i]);
|
|
404
|
+
}
|
|
405
|
+
} else {
|
|
406
|
+
try {
|
|
407
|
+
fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
408
|
+
console.log("deleted", fullPath);
|
|
409
|
+
} catch (_) {
|
|
410
|
+
console.log("failed delete", fullPath);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
module2.exports.del = del;
|
|
415
|
+
function delStream(globStream) {
|
|
416
|
+
globStream.stream().on("data", (result) => {
|
|
417
|
+
const fullPath = path2.resolve(process.cwd(), result);
|
|
418
|
+
if (fs.statSync(fullPath).isDirectory()) {
|
|
419
|
+
const subdir = fs.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
|
|
420
|
+
for (let i = 0; i < subdir.length; i++) {
|
|
421
|
+
del(subdir[i]);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
del(fullPath);
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
module2.exports.delStream = delStream;
|
|
428
|
+
function getFileTreeString(hashArray) {
|
|
429
|
+
const tree = {};
|
|
430
|
+
const hashMap = {};
|
|
431
|
+
for (const entry of hashArray) {
|
|
432
|
+
const [filePath, hash] = entry.split(" ");
|
|
433
|
+
hashMap[filePath] = hash;
|
|
434
|
+
const parts = filePath.split("/");
|
|
435
|
+
let current = tree;
|
|
436
|
+
for (let i = 0; i < parts.length; i++) {
|
|
437
|
+
const part = parts[i];
|
|
438
|
+
if (i === parts.length - 1) {
|
|
439
|
+
current[part] = null;
|
|
440
|
+
} else {
|
|
441
|
+
current[part] = current[part] || {};
|
|
442
|
+
current = current[part];
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
function printNode(node, prefix = "", parentPath = "") {
|
|
447
|
+
const keys = Object.keys(node).sort();
|
|
448
|
+
let lines = [];
|
|
449
|
+
keys.forEach((key, idx) => {
|
|
450
|
+
const isLast = idx === keys.length - 1;
|
|
451
|
+
const branch = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
452
|
+
const currentPath = parentPath ? parentPath + "/" + key : key;
|
|
453
|
+
if (node[key] === null) {
|
|
454
|
+
lines.push(prefix + branch + key + " [" + (hashMap[currentPath] || "") + "]");
|
|
455
|
+
} else {
|
|
456
|
+
lines.push(prefix + branch + key + "/");
|
|
457
|
+
lines = lines.concat(printNode(node[key], prefix + (isLast ? " " : "\u2502 "), currentPath));
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
return lines;
|
|
461
|
+
}
|
|
462
|
+
return printNode(tree, "", "").join("\n");
|
|
463
|
+
}
|
|
464
|
+
module2.exports.getFileTreeString = getFileTreeString;
|
|
465
|
+
var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
466
|
+
module2.exports.delay = delay;
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
// src/git/user-config.cjs
|
|
471
|
+
var require_user_config = __commonJS({
|
|
472
|
+
"src/git/user-config.cjs"(exports2, module2) {
|
|
473
|
+
init_cjs_shims();
|
|
474
|
+
var gch = require("git-command-helper");
|
|
475
|
+
var { runGitCommand, runGitCommandOutput } = require_utils();
|
|
476
|
+
var { getArgs: getArgs2 } = require_utils2();
|
|
477
|
+
require("dotenv").config({ path: require("path").join(process.cwd(), ".env") });
|
|
478
|
+
function configureGitUser2(cliUser = null, cliEmail = null, options2 = {}) {
|
|
479
|
+
console.log("\n=== Configuring Git User ===");
|
|
480
|
+
let username, email;
|
|
481
|
+
if (cliUser && cliEmail) {
|
|
482
|
+
username = cliUser.trim();
|
|
483
|
+
email = cliEmail.trim();
|
|
484
|
+
console.log("[i] Using CLI-provided user configuration");
|
|
485
|
+
} else {
|
|
486
|
+
username = process.env.GITHUB_USER ? process.env.GITHUB_USER.trim() : void 0;
|
|
487
|
+
email = process.env.GITHUB_EMAIL ? process.env.GITHUB_EMAIL.trim() : void 0;
|
|
488
|
+
if (username || email) {
|
|
489
|
+
console.log("[i] Using environment variable user configuration");
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
if (!username && !email) {
|
|
493
|
+
console.log("[i] No Git user configuration needed (no CLI args or environment variables set)");
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
if (username) {
|
|
497
|
+
const success = runGitCommand(["config", "user.name", username], `Set Git username to "${username}"`);
|
|
498
|
+
if (!success) {
|
|
499
|
+
console.log("[i] Failed to set Git username, but continuing...");
|
|
500
|
+
}
|
|
501
|
+
} else {
|
|
502
|
+
console.log("[i] No username provided, skipping username configuration");
|
|
503
|
+
}
|
|
504
|
+
if (email) {
|
|
505
|
+
const success = runGitCommand(["config", "user.email", email], `Set Git email to "${email}"`);
|
|
506
|
+
if (!success) {
|
|
507
|
+
console.log("[i] Failed to set Git email, but continuing...");
|
|
508
|
+
}
|
|
509
|
+
} else {
|
|
510
|
+
console.log("[i] No email provided, skipping email configuration");
|
|
511
|
+
}
|
|
512
|
+
if (username || email) {
|
|
513
|
+
console.log("[\u2713] Git user configuration completed");
|
|
514
|
+
}
|
|
515
|
+
if (username) {
|
|
516
|
+
const remoteUrl = runGitCommandOutput(["remote", "get-url", "origin"], "Fetching remote URL for verification");
|
|
517
|
+
if (remoteUrl) {
|
|
518
|
+
console.log(`[i] Remote URL: ${remoteUrl}`);
|
|
519
|
+
const parsedUrl = gch.parseGitHubUrl(remoteUrl);
|
|
520
|
+
if (parsedUrl && parsedUrl.owner && username && parsedUrl.owner.toLowerCase() !== username.toLowerCase()) {
|
|
521
|
+
console.warn(
|
|
522
|
+
`
|
|
523
|
+
[!] The GitHub remote owner ("${parsedUrl.owner}") does not match the configured username ("${username}").`
|
|
524
|
+
);
|
|
525
|
+
console.warn(`[!] If this is not intentional, consider updating the remote URL to use your username.`);
|
|
526
|
+
console.warn(`[!] Example: git remote set-url origin https://github.com/${username}/<repo>.git
|
|
527
|
+
`);
|
|
528
|
+
const args2 = getArgs2();
|
|
529
|
+
const updateRemote = options2.updateRemote || args2["update-remote"] === true;
|
|
530
|
+
if (updateRemote) {
|
|
531
|
+
let newUrl = remoteUrl;
|
|
532
|
+
if (/^https:\/\//.test(remoteUrl)) {
|
|
533
|
+
newUrl = remoteUrl.replace(/https:\/\/(?:[^@]+@)?github.com/, `https://${username}@github.com`);
|
|
534
|
+
} else if (/^git@github.com:/.test(remoteUrl)) {
|
|
535
|
+
console.warn(
|
|
536
|
+
`[!] For SSH remotes, set your SSH config or use HTTPS with username if you want to change authentication user.`
|
|
537
|
+
);
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
if (newUrl !== remoteUrl) {
|
|
541
|
+
const updated = runGitCommand(["remote", "set-url", "origin", newUrl], `Set origin to ${newUrl}`);
|
|
542
|
+
if (updated) {
|
|
543
|
+
console.log(`[\u2713] Remote URL updated to: ${newUrl}`);
|
|
544
|
+
} else {
|
|
545
|
+
console.warn(`[!] Failed to update remote URL. Please update it manually if needed.`);
|
|
546
|
+
}
|
|
547
|
+
} else {
|
|
548
|
+
console.log(`[i] Remote URL does not use HTTPS or already contains the username.`);
|
|
549
|
+
}
|
|
550
|
+
} else {
|
|
551
|
+
console.log(`[i] Remote URL not changed. Use --update-remote to update automatically.`);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
module2.exports = {
|
|
558
|
+
configureGitUser: configureGitUser2
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
// src/git/normalize.cjs
|
|
564
|
+
var require_normalize = __commonJS({
|
|
565
|
+
"src/git/normalize.cjs"(exports2, module2) {
|
|
566
|
+
init_cjs_shims();
|
|
567
|
+
var { execSync } = require("child_process");
|
|
568
|
+
function normalizeLineEndings2() {
|
|
569
|
+
console.log("\n=== Normalizing Existing Files ===");
|
|
570
|
+
try {
|
|
571
|
+
const result = execSync("git ls-files", { encoding: "utf-8", stdio: "pipe" });
|
|
572
|
+
if (!result.trim()) {
|
|
573
|
+
console.log("[i] No tracked files to normalize");
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
console.log("[i] Refreshing index to detect line ending changes...");
|
|
577
|
+
execSync("git add --renormalize .", { stdio: "pipe" });
|
|
578
|
+
try {
|
|
579
|
+
const statusResult = execSync("git status --porcelain", { encoding: "utf-8", stdio: "pipe" });
|
|
580
|
+
if (statusResult.trim()) {
|
|
581
|
+
console.log("[\u2713] Line endings normalized for tracked files");
|
|
582
|
+
console.log("[i] Files with updated line endings are now staged");
|
|
583
|
+
console.log("[i] Run 'git status' to see the changes");
|
|
584
|
+
} else {
|
|
585
|
+
console.log("[\u2713] All files already have correct line endings");
|
|
586
|
+
}
|
|
587
|
+
} catch {
|
|
588
|
+
console.log("[\u2713] Line ending normalization completed");
|
|
589
|
+
}
|
|
590
|
+
} catch (error) {
|
|
591
|
+
console.error("[\u2717] Failed to normalize line endings");
|
|
592
|
+
console.error(`Error: ${error.message}`);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
module2.exports = {
|
|
596
|
+
normalizeLineEndings: normalizeLineEndings2
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
// src/git-fix.cjs
|
|
602
|
+
init_cjs_shims();
|
|
603
|
+
var { isGitRepository } = require_utils();
|
|
604
|
+
var { forceLfLineEndings } = require_line_endings();
|
|
605
|
+
var { ignoreFilePermissions } = require_permissions();
|
|
606
|
+
var { setPullStrategy } = require_pull_strategy();
|
|
607
|
+
var { configureGitUser } = require_user_config();
|
|
608
|
+
var { normalizeLineEndings } = require_normalize();
|
|
609
|
+
var { getArgs } = require_utils2();
|
|
610
|
+
var path = require("upath");
|
|
611
|
+
require("dotenv").config({ path: path.join(process.cwd(), ".env") });
|
|
12
612
|
function showHelp() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
613
|
+
console.log("Git Fix Utility");
|
|
614
|
+
console.log("----------------------------");
|
|
615
|
+
console.log("Fixes common Git configuration issues:");
|
|
616
|
+
console.log("\u2022 Forces LF line endings (core.autocrlf = false)");
|
|
617
|
+
console.log("\u2022 Ignores file permission changes (core.filemode = false)");
|
|
618
|
+
console.log("\u2022 Sets pull strategy to false (prevents auto-rebase)");
|
|
619
|
+
console.log("\u2022 Normalizes existing line endings");
|
|
620
|
+
console.log("\u2022 Configures Git user from environment variables");
|
|
621
|
+
console.log("");
|
|
622
|
+
console.log("Usage:");
|
|
623
|
+
console.log(" git-fix Apply all fixes");
|
|
624
|
+
console.log(" git-fix --lf-only Force LF line endings only");
|
|
625
|
+
console.log(" git-fix --permissions Ignore file permissions only");
|
|
626
|
+
console.log(" git-fix --normalize Normalize existing files only");
|
|
627
|
+
console.log(" git-fix --user Configure Git user from environment");
|
|
628
|
+
console.log(" git-fix --user NAME EMAIL Configure Git user with specified name and email");
|
|
629
|
+
console.log(" git-fix --help | -h Show this help message");
|
|
630
|
+
console.log("");
|
|
631
|
+
console.log("Options can be combined: git-fix --lf-only --permissions");
|
|
632
|
+
console.log("");
|
|
633
|
+
console.log("User configuration precedence:");
|
|
634
|
+
console.log(" 1. CLI arguments (--user NAME EMAIL)");
|
|
635
|
+
console.log(" 2. Environment variables (GITHUB_USER, GITHUB_EMAIL)");
|
|
636
|
+
console.log(" 3. Skip if neither provided");
|
|
637
|
+
console.log("");
|
|
638
|
+
console.log("Environment variables for --user option:");
|
|
639
|
+
console.log(" GITHUB_USER - Git username (for user.name)");
|
|
640
|
+
console.log(" GITHUB_EMAIL - Git email (for user.email)");
|
|
641
|
+
process.exit(0);
|
|
42
642
|
}
|
|
43
|
-
|
|
44
|
-
|
|
643
|
+
var args = getArgs();
|
|
644
|
+
var userConfig = { hasUserFlag: false, cliUser: null, cliEmail: null };
|
|
45
645
|
if (Object.prototype.hasOwnProperty.call(args, "user")) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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);
|
|
646
|
+
userConfig.hasUserFlag = true;
|
|
647
|
+
if (Array.isArray(args.user)) {
|
|
648
|
+
if (args.user.length === 2) {
|
|
649
|
+
userConfig.cliUser = args.user[0];
|
|
650
|
+
userConfig.cliEmail = args.user[1];
|
|
651
|
+
} else if (args.user.length === 1) {
|
|
652
|
+
console.error("[\u2717] Error: --user requires both NAME and EMAIL or no arguments");
|
|
653
|
+
console.error("Usage: --user (uses environment variables) or --user NAME EMAIL");
|
|
654
|
+
process.exit(1);
|
|
66
655
|
}
|
|
656
|
+
} else if (typeof args.user === "string") {
|
|
657
|
+
console.error("[\u2717] Error: --user requires both NAME and EMAIL or no arguments");
|
|
658
|
+
console.error("Usage: --user (uses environment variables) or --user NAME EMAIL");
|
|
659
|
+
process.exit(1);
|
|
660
|
+
}
|
|
67
661
|
}
|
|
68
|
-
// Show help if requested
|
|
69
662
|
if (args.help || args.h) {
|
|
70
|
-
|
|
71
|
-
|
|
663
|
+
showHelp();
|
|
664
|
+
process.exit(0);
|
|
72
665
|
}
|
|
73
666
|
console.log("[i] Current working directory:", path.toUnix(process.cwd()));
|
|
74
|
-
// Check if we're in a git repository
|
|
75
667
|
if (!isGitRepository(process.cwd())) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
console.log("[✓] Detected git repository");
|
|
668
|
+
console.error("[\u2717] Error: Not in a git repository");
|
|
669
|
+
console.error("Please run this command from within a git repository");
|
|
670
|
+
process.exit(1);
|
|
671
|
+
} else {
|
|
672
|
+
console.log("[\u2713] Detected git repository");
|
|
82
673
|
}
|
|
83
674
|
console.log("Git Fix Utility");
|
|
84
675
|
console.log("===============");
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
all: Object.keys(args).filter((k) => k !== "_" && args[k] === true).length === 0 && !userConfig.hasUserFlag
|
|
676
|
+
var options = {
|
|
677
|
+
lfOnly: args["lf-only"] === true,
|
|
678
|
+
permissions: args["permissions"] === true,
|
|
679
|
+
normalize: args["normalize"] === true,
|
|
680
|
+
user: userConfig.hasUserFlag,
|
|
681
|
+
updateRemote: args["update-remote"] === true,
|
|
682
|
+
all: Object.keys(args).filter((k) => k !== "_" && args[k] === true).length === 0 && !userConfig.hasUserFlag
|
|
93
683
|
};
|
|
94
|
-
// Execute requested fixes
|
|
95
684
|
if (options.all || options.lfOnly) {
|
|
96
|
-
|
|
685
|
+
forceLfLineEndings();
|
|
97
686
|
}
|
|
98
687
|
if (options.all || options.permissions) {
|
|
99
|
-
|
|
688
|
+
ignoreFilePermissions();
|
|
100
689
|
}
|
|
101
690
|
if (options.all) {
|
|
102
|
-
|
|
691
|
+
setPullStrategy();
|
|
103
692
|
}
|
|
104
693
|
if (options.all || options.user) {
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// If --update-remote is present without --user or --all, still call configureGitUser
|
|
109
|
-
configureGitUser(null, null, { updateRemote: true });
|
|
694
|
+
configureGitUser(userConfig.cliUser, userConfig.cliEmail, { updateRemote: options.updateRemote });
|
|
695
|
+
} else if (options.updateRemote) {
|
|
696
|
+
configureGitUser(null, null, { updateRemote: true });
|
|
110
697
|
}
|
|
111
698
|
if (options.all || options.normalize) {
|
|
112
|
-
|
|
699
|
+
normalizeLineEndings();
|
|
113
700
|
}
|
|
114
701
|
console.log("\n=== Summary ===");
|
|
115
|
-
console.log("[
|
|
702
|
+
console.log("[\u2713] Git fix utility completed successfully");
|
|
116
703
|
if (options.all || options.lfOnly || options.normalize) {
|
|
117
|
-
|
|
704
|
+
console.log("[i] Line endings are now configured for LF");
|
|
118
705
|
}
|
|
119
706
|
if (options.all || options.permissions) {
|
|
120
|
-
|
|
707
|
+
console.log("[i] File permission changes will be ignored");
|
|
121
708
|
}
|
|
709
|
+
var _a, _b;
|
|
122
710
|
if (options.all || options.user) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
711
|
+
const username = userConfig.cliUser || ((_a = process.env.GITHUB_USER) == null ? void 0 : _a.trim());
|
|
712
|
+
const email = userConfig.cliEmail || ((_b = process.env.GITHUB_EMAIL) == null ? void 0 : _b.trim());
|
|
713
|
+
if (username || email) {
|
|
714
|
+
console.log("[i] Git user configuration has been applied");
|
|
715
|
+
}
|
|
128
716
|
}
|
|
129
717
|
console.log("[i] Repository is ready for cross-platform development");
|