binary-collections 2.0.7 → 2.0.8
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/bin/dir-tree.cmd +7 -0
- package/bin/git-diff +4 -0
- package/bin/git-diff.cmd +5 -2
- package/bin/{git-fix-encoding → git-fix} +1 -4
- package/bin/git-fix.cmd +7 -0
- package/bin/nodekill +0 -0
- package/bin/nodekill.ps1 +0 -0
- package/bin/{submodule → submodule.txt} +0 -0
- package/lib/binary-collections-config.cjs +14 -0
- package/lib/binary-collections-config.d.mts +18 -0
- package/lib/binary-collections-config.d.ts +16 -0
- package/lib/binary-collections-config.js +39 -0
- package/lib/binary-collections-config.mjs +6 -0
- package/lib/binary-collections.cjs +105 -0
- package/lib/binary-collections.d.cts +2 -0
- package/lib/binary-collections.d.mts +121 -0
- package/lib/binary-collections.d.ts +121 -0
- package/lib/binary-collections.mjs +108 -0
- package/lib/chunk-4BYBVEYC.mjs +30 -0
- package/lib/{chunk-FB6YIQYR.mjs → chunk-AASHBCRW.mjs} +17 -2
- package/lib/chunk-APBWENF6.mjs +135 -0
- package/lib/{chunk-4LEXWIIF.mjs → chunk-DPKAJKFO.mjs} +2 -4
- package/lib/chunk-EGSSKVDH.mjs +66 -0
- package/lib/{chunk-3LOB2P54.mjs → chunk-G3THLIDT.mjs} +3 -5
- package/lib/chunk-JGR2NW6D.mjs +187 -0
- package/lib/chunk-ONIBBBQ3.mjs +108 -0
- package/lib/chunk-SH3L6HHV.mjs +27 -0
- package/lib/chunk-VVEZVNIV.mjs +81 -0
- package/lib/{chunk-JL32QDSH.mjs → chunk-W3ENOM53.mjs} +2 -4
- package/lib/chunk-YV7DO3YV.mjs +48 -0
- package/lib/{chunk-BSD5CIRU.mjs → chunk-YX5U7XDR.mjs} +11 -5
- package/lib/chunk-ZYAQRPUL.mjs +28 -0
- package/lib/clean-github-actions-caches.cjs +162 -0
- package/lib/clean-github-actions-caches.d.cts +1 -0
- package/lib/clean-github-actions-caches.d.mts +169 -0
- package/lib/clean-github-actions-caches.d.ts +169 -0
- package/lib/clean-github-actions-caches.mjs +132 -0
- package/lib/del-gradle.cjs +87 -3
- package/lib/del-gradle.js +1 -1
- package/lib/del-gradle.mjs +4 -6
- package/lib/del-node-modules.cjs +86 -2
- package/lib/del-node-modules.mjs +3 -5
- package/lib/del-ps.cjs +89 -5
- package/lib/del-ps.js +2 -2
- package/lib/del-ps.mjs +6 -8
- package/lib/del-yarn-caches.cjs +86 -2
- package/lib/del-yarn-caches.mjs +3 -5
- package/lib/find-node-modules-cli.cjs +8 -0
- package/lib/find-node-modules-cli.mjs +2 -3
- package/lib/find-node-modules.cjs +8 -0
- package/lib/find-node-modules.d.mts +3 -0
- package/lib/find-node-modules.d.ts +3 -0
- package/lib/find-node-modules.js +12 -0
- package/lib/find-node-modules.mjs +2 -3
- package/lib/git/gitattributes.cjs +171 -0
- package/lib/git/gitattributes.d.mts +35 -0
- package/lib/git/gitattributes.d.ts +33 -0
- package/lib/git/gitattributes.js +223 -0
- package/lib/git/gitattributes.mjs +6 -0
- package/lib/git/line-endings.cjs +74 -0
- package/lib/git/line-endings.d.cts +7 -0
- package/lib/git/line-endings.d.mts +83 -0
- package/lib/git/line-endings.d.ts +83 -0
- package/lib/git/line-endings.mjs +8 -0
- package/lib/git/normalize.cjs +42 -0
- package/lib/git/normalize.d.cts +6 -0
- package/lib/git/normalize.d.mts +43 -0
- package/lib/git/normalize.d.ts +43 -0
- package/lib/git/normalize.mjs +6 -0
- package/lib/git/permissions.cjs +15 -0
- package/lib/git/permissions.d.cts +6 -0
- package/lib/git/permissions.d.mts +17 -0
- package/lib/git/permissions.d.ts +17 -0
- package/lib/git/permissions.mjs +7 -0
- package/lib/git/pull-strategy.cjs +13 -0
- package/lib/git/pull-strategy.d.cts +5 -0
- package/lib/git/pull-strategy.d.mts +15 -0
- package/lib/git/pull-strategy.d.ts +15 -0
- package/lib/git/pull-strategy.mjs +7 -0
- package/lib/git/user-config.cjs +100 -0
- package/lib/git/user-config.d.cts +10 -0
- package/lib/git/user-config.d.mts +105 -0
- package/lib/git/user-config.d.ts +105 -0
- package/lib/git/user-config.mjs +8 -0
- package/lib/git/utils.cjs +70 -0
- package/lib/git/utils.d.cts +20 -0
- package/lib/git/utils.d.mts +69 -0
- package/lib/git/utils.d.ts +69 -0
- package/lib/git/utils.mjs +6 -0
- package/lib/git-diff.cjs +23 -24
- package/lib/git-diff.d.mts +25 -28
- package/lib/git-diff.d.ts +25 -28
- package/lib/git-diff.mjs +32 -27
- package/lib/git-fix.cjs +129 -0
- package/lib/git-fix.d.cts +2 -0
- package/lib/git-fix.d.mts +141 -0
- package/lib/git-fix.d.ts +141 -0
- package/lib/git-fix.mjs +151 -0
- package/lib/git-purge.cjs +86 -2
- package/lib/git-purge.mjs +3 -5
- package/lib/index.cjs +8 -0
- package/lib/index.mjs +3 -5
- package/lib/npm-run-series.cjs +140 -1
- package/lib/npm-run-series.js +2 -1
- package/lib/npm-run-series.mjs +7 -5
- package/lib/package-resolutions-updater.cjs +274 -0
- package/lib/package-resolutions-updater.d.mts +1 -0
- package/lib/package-resolutions-updater.d.ts +326 -0
- package/lib/package-resolutions-updater.mjs +316 -0
- package/lib/print-directory-tree.cjs +241 -0
- package/lib/print-directory-tree.d.cts +1 -0
- package/lib/print-directory-tree.d.mts +234 -0
- package/lib/print-directory-tree.d.ts +234 -0
- package/lib/print-directory-tree.mjs +182 -0
- package/lib/ps/connected-domain.mjs +2 -3
- package/lib/ps/index.cjs +3 -3
- package/lib/ps/index.d.mjs +1 -2
- package/lib/ps/index.js +6 -3
- package/lib/ps/index.mjs +9 -11
- package/lib/ps/isWin.mjs +2 -3
- package/lib/ps/table-parser.mjs +3 -4
- package/lib/submodule-install.cjs +13 -31
- package/lib/submodule-install.d.mts +12 -32
- package/lib/submodule-install.d.ts +12 -32
- package/lib/submodule-install.mjs +16 -25
- package/lib/utils.cjs +86 -2
- package/lib/utils.d.mts +29 -9
- package/lib/utils.d.ts +28 -8
- package/lib/utils.js +139 -8
- package/lib/utils.mjs +2 -3
- package/lib/yarn-reinstall.cjs +9 -7
- package/lib/yarn-reinstall.d.mts +12 -8
- package/lib/yarn-reinstall.d.ts +12 -8
- package/lib/yarn-reinstall.mjs +14 -10
- package/package.json +109 -80
- package/readme.md +74 -11
- package/src/package-resolutions-updater.mjs +325 -0
- package/src/print-directory-tree.cjs +234 -0
- package/src/ps/index.js +4 -3
- package/src/yarn-reinstall.cjs +49 -0
- package/test-project/package.json +16 -0
- package/tmp/test-repo/package.json +7 -0
- package/bin/git-fix-encoding.cmd +0 -6
- package/lib/chunk-OKYLF2MU.mjs +0 -53
- package/lib/chunk-VXZQNLPU.mjs +0 -23
- package/lib/package-resolutions.cjs +0 -28
- package/lib/package-resolutions.d.mts +0 -25
- package/lib/package-resolutions.d.ts +0 -25
- package/lib/package-resolutions.mjs +0 -31
- /package/bin/{submodule-install → submodule-install.txt} +0 -0
package/lib/git-diff.d.ts
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
const { execSync } = require("child_process");
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
const path = require("path");
|
|
5
|
+
const { getTempPath } = require("./binary-collections-config");
|
|
5
6
|
|
|
6
|
-
// Output path
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
// Output path using centralized temp directory configuration
|
|
8
|
+
const OUTPUT = getTempPath("git-diff.txt");
|
|
9
|
+
const CACHE_DIR = path.dirname(OUTPUT);
|
|
9
10
|
|
|
10
11
|
// Ensure output directory exists
|
|
11
12
|
if (!fs.existsSync(CACHE_DIR)) {
|
|
@@ -28,7 +29,10 @@ function showHelp() {
|
|
|
28
29
|
function runGitDiff(command, successMessage, errorMessage) {
|
|
29
30
|
try {
|
|
30
31
|
console.log(`[i] Running command: ${command}`);
|
|
31
|
-
const result = execSync(command, {
|
|
32
|
+
const result = execSync(command, {
|
|
33
|
+
encoding: "utf8",
|
|
34
|
+
maxBuffer: 1024 * 1024 * 10 // 10MB buffer to handle large diffs
|
|
35
|
+
});
|
|
32
36
|
|
|
33
37
|
// If result is empty, inform user but don't treat as error
|
|
34
38
|
if (!result || result.trim() === "") {
|
|
@@ -54,34 +58,27 @@ function runGitDiff(command, successMessage, errorMessage) {
|
|
|
54
58
|
}
|
|
55
59
|
}
|
|
56
60
|
|
|
57
|
-
|
|
58
|
-
const args =
|
|
61
|
+
const { getArgs } = require("./utils.js");
|
|
62
|
+
const args = getArgs();
|
|
63
|
+
const positional = args._ || [];
|
|
59
64
|
|
|
60
65
|
// Show help if no arguments or --help/-h is passed
|
|
61
|
-
if (args
|
|
66
|
+
if (args.help || args.h) {
|
|
62
67
|
showHelp();
|
|
63
68
|
}
|
|
64
69
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
} else {
|
|
79
|
-
runGitDiff(
|
|
80
|
-
`git --no-pager diff --cached -- "${file}"`,
|
|
81
|
-
`Staged diff of "${file}" saved to "${OUTPUT}"`,
|
|
82
|
-
`Failed to generate diff for "${file}"`
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
break;
|
|
70
|
+
if (args["staged-only"] || args.s || args.S) {
|
|
71
|
+
runGitDiff("git --no-pager diff --staged", `Full staged diff saved to "${OUTPUT}"`, "Failed to save staged diff");
|
|
72
|
+
} else {
|
|
73
|
+
// Handle specific file diff
|
|
74
|
+
const file = positional[0];
|
|
75
|
+
if (!file) {
|
|
76
|
+
runGitDiff("git --no-pager diff", `Full staged diff saved to "${OUTPUT}"`, "Failed to save all diff's");
|
|
77
|
+
} else {
|
|
78
|
+
runGitDiff(
|
|
79
|
+
`git --no-pager diff --cached -- "${file}"`,
|
|
80
|
+
`Staged diff of "${file}" saved to "${OUTPUT}"`,
|
|
81
|
+
`Failed to generate diff for "${file}"`
|
|
82
|
+
);
|
|
86
83
|
}
|
|
87
84
|
}
|
package/lib/git-diff.mjs
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
} from "./chunk-
|
|
4
|
+
require_binary_collections_config
|
|
5
|
+
} from "./chunk-4BYBVEYC.mjs";
|
|
6
|
+
import {
|
|
7
|
+
require_utils
|
|
8
|
+
} from "./chunk-APBWENF6.mjs";
|
|
6
9
|
import {
|
|
7
10
|
__commonJS,
|
|
8
|
-
__require
|
|
9
|
-
|
|
11
|
+
__require,
|
|
12
|
+
init_esm_shims
|
|
13
|
+
} from "./chunk-AASHBCRW.mjs";
|
|
10
14
|
|
|
11
15
|
// src/git-diff.cjs
|
|
12
16
|
var require_git_diff = __commonJS({
|
|
@@ -15,8 +19,9 @@ var require_git_diff = __commonJS({
|
|
|
15
19
|
var { execSync } = __require("child_process");
|
|
16
20
|
var fs = __require("fs");
|
|
17
21
|
var path = __require("path");
|
|
18
|
-
var
|
|
19
|
-
var OUTPUT =
|
|
22
|
+
var { getTempPath } = require_binary_collections_config();
|
|
23
|
+
var OUTPUT = getTempPath("git-diff.txt");
|
|
24
|
+
var CACHE_DIR = path.dirname(OUTPUT);
|
|
20
25
|
if (!fs.existsSync(CACHE_DIR)) {
|
|
21
26
|
fs.mkdirSync(CACHE_DIR, { recursive: true });
|
|
22
27
|
}
|
|
@@ -35,7 +40,11 @@ var require_git_diff = __commonJS({
|
|
|
35
40
|
function runGitDiff(command, successMessage, errorMessage) {
|
|
36
41
|
try {
|
|
37
42
|
console.log(`[i] Running command: ${command}`);
|
|
38
|
-
const result = execSync(command, {
|
|
43
|
+
const result = execSync(command, {
|
|
44
|
+
encoding: "utf8",
|
|
45
|
+
maxBuffer: 1024 * 1024 * 10
|
|
46
|
+
// 10MB buffer to handle large diffs
|
|
47
|
+
});
|
|
39
48
|
if (!result || result.trim() === "") {
|
|
40
49
|
console.log(`[i] No changes found for the specified criteria`);
|
|
41
50
|
fs.writeFileSync(OUTPUT, "# No changes found\n");
|
|
@@ -54,28 +63,24 @@ var require_git_diff = __commonJS({
|
|
|
54
63
|
process.exit(1);
|
|
55
64
|
}
|
|
56
65
|
}
|
|
57
|
-
var
|
|
58
|
-
|
|
66
|
+
var { getArgs } = require_utils();
|
|
67
|
+
var args = getArgs();
|
|
68
|
+
var positional = args._ || [];
|
|
69
|
+
if (args.help || args.h) {
|
|
59
70
|
showHelp();
|
|
60
71
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
`git --no-pager diff --cached -- "${file}"`,
|
|
74
|
-
`Staged diff of "${file}" saved to "${OUTPUT}"`,
|
|
75
|
-
`Failed to generate diff for "${file}"`
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
break;
|
|
72
|
+
if (args["staged-only"] || args.s || args.S) {
|
|
73
|
+
runGitDiff("git --no-pager diff --staged", `Full staged diff saved to "${OUTPUT}"`, "Failed to save staged diff");
|
|
74
|
+
} else {
|
|
75
|
+
const file = positional[0];
|
|
76
|
+
if (!file) {
|
|
77
|
+
runGitDiff("git --no-pager diff", `Full staged diff saved to "${OUTPUT}"`, "Failed to save all diff's");
|
|
78
|
+
} else {
|
|
79
|
+
runGitDiff(
|
|
80
|
+
`git --no-pager diff --cached -- "${file}"`,
|
|
81
|
+
`Staged diff of "${file}" saved to "${OUTPUT}"`,
|
|
82
|
+
`Failed to generate diff for "${file}"`
|
|
83
|
+
);
|
|
79
84
|
}
|
|
80
85
|
}
|
|
81
86
|
}
|
package/lib/git-fix.cjs
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
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");
|
|
12
|
+
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);
|
|
42
|
+
}
|
|
43
|
+
const args = getArgs();
|
|
44
|
+
let userConfig = { hasUserFlag: false, cliUser: null, cliEmail: null };
|
|
45
|
+
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);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Show help if requested
|
|
69
|
+
if (args.help || args.h) {
|
|
70
|
+
showHelp();
|
|
71
|
+
process.exit(0); // Exit after showing help
|
|
72
|
+
}
|
|
73
|
+
console.log("[i] Current working directory:", path.toUnix(process.cwd()));
|
|
74
|
+
// Check if we're in a git repository
|
|
75
|
+
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");
|
|
82
|
+
}
|
|
83
|
+
console.log("Git Fix Utility");
|
|
84
|
+
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
|
|
93
|
+
};
|
|
94
|
+
// Execute requested fixes
|
|
95
|
+
if (options.all || options.lfOnly) {
|
|
96
|
+
forceLfLineEndings();
|
|
97
|
+
}
|
|
98
|
+
if (options.all || options.permissions) {
|
|
99
|
+
ignoreFilePermissions();
|
|
100
|
+
}
|
|
101
|
+
if (options.all) {
|
|
102
|
+
setPullStrategy();
|
|
103
|
+
}
|
|
104
|
+
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 });
|
|
110
|
+
}
|
|
111
|
+
if (options.all || options.normalize) {
|
|
112
|
+
normalizeLineEndings();
|
|
113
|
+
}
|
|
114
|
+
console.log("\n=== Summary ===");
|
|
115
|
+
console.log("[✓] Git fix utility completed successfully");
|
|
116
|
+
if (options.all || options.lfOnly || options.normalize) {
|
|
117
|
+
console.log("[i] Line endings are now configured for LF");
|
|
118
|
+
}
|
|
119
|
+
if (options.all || options.permissions) {
|
|
120
|
+
console.log("[i] File permission changes will be ignored");
|
|
121
|
+
}
|
|
122
|
+
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
|
+
}
|
|
128
|
+
}
|
|
129
|
+
console.log("[i] Repository is ready for cross-platform development");
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { isGitRepository } = require("./git/utils.cjs");
|
|
3
|
+
const { forceLfLineEndings } = require("./git/line-endings.cjs");
|
|
4
|
+
const { ignoreFilePermissions } = require("./git/permissions.cjs");
|
|
5
|
+
const { setPullStrategy } = require("./git/pull-strategy.cjs");
|
|
6
|
+
const { configureGitUser } = require("./git/user-config.cjs");
|
|
7
|
+
const { normalizeLineEndings } = require("./git/normalize.cjs");
|
|
8
|
+
const { getArgs } = require("./utils.js");
|
|
9
|
+
const path = require("upath");
|
|
10
|
+
|
|
11
|
+
function showHelp() {
|
|
12
|
+
console.log("Git Fix Utility");
|
|
13
|
+
console.log("----------------------------");
|
|
14
|
+
console.log("Fixes common Git configuration issues:");
|
|
15
|
+
console.log("• Forces LF line endings (core.autocrlf = false)");
|
|
16
|
+
console.log("• Ignores file permission changes (core.filemode = false)");
|
|
17
|
+
console.log("• Sets pull strategy to false (prevents auto-rebase)");
|
|
18
|
+
console.log("• Normalizes existing line endings");
|
|
19
|
+
console.log("• Configures Git user from environment variables");
|
|
20
|
+
console.log("");
|
|
21
|
+
console.log("Usage:");
|
|
22
|
+
console.log(" git-fix Apply all fixes");
|
|
23
|
+
console.log(" git-fix --lf-only Force LF line endings only");
|
|
24
|
+
console.log(" git-fix --permissions Ignore file permissions only");
|
|
25
|
+
console.log(" git-fix --normalize Normalize existing files only");
|
|
26
|
+
console.log(" git-fix --user Configure Git user from environment");
|
|
27
|
+
console.log(" git-fix --user NAME EMAIL Configure Git user with specified name and email");
|
|
28
|
+
console.log(" git-fix --help | -h Show this help message");
|
|
29
|
+
console.log("");
|
|
30
|
+
console.log("Options can be combined: git-fix --lf-only --permissions");
|
|
31
|
+
console.log("");
|
|
32
|
+
console.log("User configuration precedence:");
|
|
33
|
+
console.log(" 1. CLI arguments (--user NAME EMAIL)");
|
|
34
|
+
console.log(" 2. Environment variables (GITHUB_USER, GITHUB_EMAIL)");
|
|
35
|
+
console.log(" 3. Skip if neither provided");
|
|
36
|
+
console.log("");
|
|
37
|
+
console.log("Environment variables for --user option:");
|
|
38
|
+
console.log(" GITHUB_USER - Git username (for user.name)");
|
|
39
|
+
console.log(" GITHUB_EMAIL - Git email (for user.email)");
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const args = getArgs();
|
|
44
|
+
|
|
45
|
+
let userConfig = { hasUserFlag: false, cliUser: null, cliEmail: null };
|
|
46
|
+
if (Object.prototype.hasOwnProperty.call(args, "user")) {
|
|
47
|
+
userConfig.hasUserFlag = true;
|
|
48
|
+
// args.user can be string, array, or boolean
|
|
49
|
+
if (Array.isArray(args.user)) {
|
|
50
|
+
if (args.user.length === 2) {
|
|
51
|
+
userConfig.cliUser = args.user[0];
|
|
52
|
+
userConfig.cliEmail = args.user[1];
|
|
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
|
+
} else if (typeof args.user === "string") {
|
|
61
|
+
// Only one value provided, error
|
|
62
|
+
console.error("[✗] Error: --user requires both NAME and EMAIL or no arguments");
|
|
63
|
+
console.error("Usage: --user (uses environment variables) or --user NAME EMAIL");
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Show help if requested
|
|
69
|
+
if (args.help || args.h) {
|
|
70
|
+
showHelp();
|
|
71
|
+
process.exit(0); // Exit after showing help
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
console.log("[i] Current working directory:", path.toUnix(process.cwd()));
|
|
75
|
+
|
|
76
|
+
// Check if we're in a git repository
|
|
77
|
+
if (!isGitRepository(process.cwd())) {
|
|
78
|
+
console.error("[✗] Error: Not in a git repository");
|
|
79
|
+
console.error("Please run this command from within a git repository");
|
|
80
|
+
process.exit(1);
|
|
81
|
+
} else {
|
|
82
|
+
console.log("[✓] Detected git repository");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
console.log("Git Fix Utility");
|
|
86
|
+
console.log("===============");
|
|
87
|
+
|
|
88
|
+
// Parse options
|
|
89
|
+
const options = {
|
|
90
|
+
lfOnly: args["lf-only"] === true,
|
|
91
|
+
permissions: args["permissions"] === true,
|
|
92
|
+
normalize: args["normalize"] === true,
|
|
93
|
+
user: userConfig.hasUserFlag,
|
|
94
|
+
updateRemote: args["update-remote"] === true,
|
|
95
|
+
all: Object.keys(args).filter((k) => k !== "_" && args[k] === true).length === 0 && !userConfig.hasUserFlag
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// Execute requested fixes
|
|
99
|
+
if (options.all || options.lfOnly) {
|
|
100
|
+
forceLfLineEndings();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (options.all || options.permissions) {
|
|
104
|
+
ignoreFilePermissions();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (options.all) {
|
|
108
|
+
setPullStrategy();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (options.all || options.user) {
|
|
112
|
+
configureGitUser(userConfig.cliUser, userConfig.cliEmail, { updateRemote: options.updateRemote });
|
|
113
|
+
} else if (options.updateRemote) {
|
|
114
|
+
// If --update-remote is present without --user or --all, still call configureGitUser
|
|
115
|
+
configureGitUser(null, null, { updateRemote: true });
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (options.all || options.normalize) {
|
|
119
|
+
normalizeLineEndings();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
console.log("\n=== Summary ===");
|
|
123
|
+
console.log("[✓] Git fix utility completed successfully");
|
|
124
|
+
|
|
125
|
+
if (options.all || options.lfOnly || options.normalize) {
|
|
126
|
+
console.log("[i] Line endings are now configured for LF");
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (options.all || options.permissions) {
|
|
130
|
+
console.log("[i] File permission changes will be ignored");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (options.all || options.user) {
|
|
134
|
+
const username = userConfig.cliUser || process.env.GITHUB_USER?.trim();
|
|
135
|
+
const email = userConfig.cliEmail || process.env.GITHUB_EMAIL?.trim();
|
|
136
|
+
if (username || email) {
|
|
137
|
+
console.log("[i] Git user configuration has been applied");
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
console.log("[i] Repository is ready for cross-platform development");
|
package/lib/git-fix.d.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { isGitRepository } = require("./git/utils.cjs");
|
|
3
|
+
const { forceLfLineEndings } = require("./git/line-endings.cjs");
|
|
4
|
+
const { ignoreFilePermissions } = require("./git/permissions.cjs");
|
|
5
|
+
const { setPullStrategy } = require("./git/pull-strategy.cjs");
|
|
6
|
+
const { configureGitUser } = require("./git/user-config.cjs");
|
|
7
|
+
const { normalizeLineEndings } = require("./git/normalize.cjs");
|
|
8
|
+
const { getArgs } = require("./utils.js");
|
|
9
|
+
const path = require("upath");
|
|
10
|
+
|
|
11
|
+
function showHelp() {
|
|
12
|
+
console.log("Git Fix Utility");
|
|
13
|
+
console.log("----------------------------");
|
|
14
|
+
console.log("Fixes common Git configuration issues:");
|
|
15
|
+
console.log("• Forces LF line endings (core.autocrlf = false)");
|
|
16
|
+
console.log("• Ignores file permission changes (core.filemode = false)");
|
|
17
|
+
console.log("• Sets pull strategy to false (prevents auto-rebase)");
|
|
18
|
+
console.log("• Normalizes existing line endings");
|
|
19
|
+
console.log("• Configures Git user from environment variables");
|
|
20
|
+
console.log("");
|
|
21
|
+
console.log("Usage:");
|
|
22
|
+
console.log(" git-fix Apply all fixes");
|
|
23
|
+
console.log(" git-fix --lf-only Force LF line endings only");
|
|
24
|
+
console.log(" git-fix --permissions Ignore file permissions only");
|
|
25
|
+
console.log(" git-fix --normalize Normalize existing files only");
|
|
26
|
+
console.log(" git-fix --user Configure Git user from environment");
|
|
27
|
+
console.log(" git-fix --user NAME EMAIL Configure Git user with specified name and email");
|
|
28
|
+
console.log(" git-fix --help | -h Show this help message");
|
|
29
|
+
console.log("");
|
|
30
|
+
console.log("Options can be combined: git-fix --lf-only --permissions");
|
|
31
|
+
console.log("");
|
|
32
|
+
console.log("User configuration precedence:");
|
|
33
|
+
console.log(" 1. CLI arguments (--user NAME EMAIL)");
|
|
34
|
+
console.log(" 2. Environment variables (GITHUB_USER, GITHUB_EMAIL)");
|
|
35
|
+
console.log(" 3. Skip if neither provided");
|
|
36
|
+
console.log("");
|
|
37
|
+
console.log("Environment variables for --user option:");
|
|
38
|
+
console.log(" GITHUB_USER - Git username (for user.name)");
|
|
39
|
+
console.log(" GITHUB_EMAIL - Git email (for user.email)");
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const args = getArgs();
|
|
44
|
+
|
|
45
|
+
let userConfig = { hasUserFlag: false, cliUser: null, cliEmail: null };
|
|
46
|
+
if (Object.prototype.hasOwnProperty.call(args, "user")) {
|
|
47
|
+
userConfig.hasUserFlag = true;
|
|
48
|
+
// args.user can be string, array, or boolean
|
|
49
|
+
if (Array.isArray(args.user)) {
|
|
50
|
+
if (args.user.length === 2) {
|
|
51
|
+
userConfig.cliUser = args.user[0];
|
|
52
|
+
userConfig.cliEmail = args.user[1];
|
|
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
|
+
} else if (typeof args.user === "string") {
|
|
61
|
+
// Only one value provided, error
|
|
62
|
+
console.error("[✗] Error: --user requires both NAME and EMAIL or no arguments");
|
|
63
|
+
console.error("Usage: --user (uses environment variables) or --user NAME EMAIL");
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Show help if requested
|
|
69
|
+
if (args.help || args.h) {
|
|
70
|
+
showHelp();
|
|
71
|
+
process.exit(0); // Exit after showing help
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
console.log("[i] Current working directory:", path.toUnix(process.cwd()));
|
|
75
|
+
|
|
76
|
+
// Check if we're in a git repository
|
|
77
|
+
if (!isGitRepository(process.cwd())) {
|
|
78
|
+
console.error("[✗] Error: Not in a git repository");
|
|
79
|
+
console.error("Please run this command from within a git repository");
|
|
80
|
+
process.exit(1);
|
|
81
|
+
} else {
|
|
82
|
+
console.log("[✓] Detected git repository");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
console.log("Git Fix Utility");
|
|
86
|
+
console.log("===============");
|
|
87
|
+
|
|
88
|
+
// Parse options
|
|
89
|
+
const options = {
|
|
90
|
+
lfOnly: args["lf-only"] === true,
|
|
91
|
+
permissions: args["permissions"] === true,
|
|
92
|
+
normalize: args["normalize"] === true,
|
|
93
|
+
user: userConfig.hasUserFlag,
|
|
94
|
+
updateRemote: args["update-remote"] === true,
|
|
95
|
+
all: Object.keys(args).filter((k) => k !== "_" && args[k] === true).length === 0 && !userConfig.hasUserFlag
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// Execute requested fixes
|
|
99
|
+
if (options.all || options.lfOnly) {
|
|
100
|
+
forceLfLineEndings();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (options.all || options.permissions) {
|
|
104
|
+
ignoreFilePermissions();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (options.all) {
|
|
108
|
+
setPullStrategy();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (options.all || options.user) {
|
|
112
|
+
configureGitUser(userConfig.cliUser, userConfig.cliEmail, { updateRemote: options.updateRemote });
|
|
113
|
+
} else if (options.updateRemote) {
|
|
114
|
+
// If --update-remote is present without --user or --all, still call configureGitUser
|
|
115
|
+
configureGitUser(null, null, { updateRemote: true });
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (options.all || options.normalize) {
|
|
119
|
+
normalizeLineEndings();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
console.log("\n=== Summary ===");
|
|
123
|
+
console.log("[✓] Git fix utility completed successfully");
|
|
124
|
+
|
|
125
|
+
if (options.all || options.lfOnly || options.normalize) {
|
|
126
|
+
console.log("[i] Line endings are now configured for LF");
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (options.all || options.permissions) {
|
|
130
|
+
console.log("[i] File permission changes will be ignored");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (options.all || options.user) {
|
|
134
|
+
const username = userConfig.cliUser || process.env.GITHUB_USER?.trim();
|
|
135
|
+
const email = userConfig.cliEmail || process.env.GITHUB_EMAIL?.trim();
|
|
136
|
+
if (username || email) {
|
|
137
|
+
console.log("[i] Git user configuration has been applied");
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
console.log("[i] Repository is ready for cross-platform development");
|