binary-collections 2.0.7 → 2.0.9

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 (155) hide show
  1. package/bin/dir-tree.cmd +7 -0
  2. package/bin/git-diff +4 -0
  3. package/bin/git-diff.cmd +5 -2
  4. package/bin/{git-fix-encoding → git-fix} +1 -4
  5. package/bin/git-fix.cmd +7 -0
  6. package/bin/nodekill +0 -0
  7. package/bin/nodekill.ps1 +0 -0
  8. package/bin/{submodule → submodule.txt} +0 -0
  9. package/lib/binary-collections-config.cjs +14 -0
  10. package/lib/binary-collections-config.d.mts +18 -0
  11. package/lib/binary-collections-config.d.ts +16 -0
  12. package/lib/binary-collections-config.js +39 -0
  13. package/lib/binary-collections-config.mjs +6 -0
  14. package/lib/binary-collections.cjs +123 -0
  15. package/lib/binary-collections.d.cts +2 -0
  16. package/lib/binary-collections.d.mts +137 -0
  17. package/lib/binary-collections.d.ts +137 -0
  18. package/lib/binary-collections.mjs +300 -0
  19. package/lib/changelog.cjs +328 -0
  20. package/lib/changelog.d.mts +2 -0
  21. package/lib/changelog.d.ts +1 -0
  22. package/lib/changelog.js +226 -0
  23. package/lib/changelog.mjs +199 -0
  24. package/lib/chunk-4BYBVEYC.mjs +30 -0
  25. package/lib/{chunk-FB6YIQYR.mjs → chunk-AASHBCRW.mjs} +17 -2
  26. package/lib/chunk-APBWENF6.mjs +135 -0
  27. package/lib/{chunk-4LEXWIIF.mjs → chunk-DPKAJKFO.mjs} +2 -4
  28. package/lib/chunk-EGSSKVDH.mjs +66 -0
  29. package/lib/{chunk-3LOB2P54.mjs → chunk-G3THLIDT.mjs} +3 -5
  30. package/lib/chunk-JGR2NW6D.mjs +187 -0
  31. package/lib/chunk-ONIBBBQ3.mjs +108 -0
  32. package/lib/chunk-SH3L6HHV.mjs +27 -0
  33. package/lib/chunk-VVEZVNIV.mjs +81 -0
  34. package/lib/{chunk-JL32QDSH.mjs → chunk-W3ENOM53.mjs} +2 -4
  35. package/lib/chunk-YV7DO3YV.mjs +48 -0
  36. package/lib/{chunk-BSD5CIRU.mjs → chunk-YX5U7XDR.mjs} +11 -5
  37. package/lib/chunk-ZYAQRPUL.mjs +28 -0
  38. package/lib/clean-github-actions-caches.cjs +162 -0
  39. package/lib/clean-github-actions-caches.d.cts +1 -0
  40. package/lib/clean-github-actions-caches.d.mts +169 -0
  41. package/lib/clean-github-actions-caches.d.ts +169 -0
  42. package/lib/clean-github-actions-caches.mjs +132 -0
  43. package/lib/del-gradle.cjs +87 -3
  44. package/lib/del-gradle.js +1 -1
  45. package/lib/del-gradle.mjs +4 -6
  46. package/lib/del-node-modules.cjs +86 -2
  47. package/lib/del-node-modules.mjs +3 -5
  48. package/lib/del-ps.cjs +89 -5
  49. package/lib/del-ps.js +2 -2
  50. package/lib/del-ps.mjs +6 -8
  51. package/lib/del-yarn-caches.cjs +86 -2
  52. package/lib/del-yarn-caches.mjs +3 -5
  53. package/lib/find-node-modules-cli.cjs +8 -0
  54. package/lib/find-node-modules-cli.mjs +2 -3
  55. package/lib/find-node-modules.cjs +8 -0
  56. package/lib/find-node-modules.d.mts +3 -0
  57. package/lib/find-node-modules.d.ts +3 -0
  58. package/lib/find-node-modules.js +12 -0
  59. package/lib/find-node-modules.mjs +2 -3
  60. package/lib/git/gitattributes.cjs +171 -0
  61. package/lib/git/gitattributes.d.mts +35 -0
  62. package/lib/git/gitattributes.d.ts +33 -0
  63. package/lib/git/gitattributes.js +223 -0
  64. package/lib/git/gitattributes.mjs +6 -0
  65. package/lib/git/line-endings.cjs +74 -0
  66. package/lib/git/line-endings.d.cts +7 -0
  67. package/lib/git/line-endings.d.mts +83 -0
  68. package/lib/git/line-endings.d.ts +83 -0
  69. package/lib/git/line-endings.mjs +8 -0
  70. package/lib/git/normalize.cjs +42 -0
  71. package/lib/git/normalize.d.cts +6 -0
  72. package/lib/git/normalize.d.mts +43 -0
  73. package/lib/git/normalize.d.ts +43 -0
  74. package/lib/git/normalize.mjs +6 -0
  75. package/lib/git/permissions.cjs +15 -0
  76. package/lib/git/permissions.d.cts +6 -0
  77. package/lib/git/permissions.d.mts +17 -0
  78. package/lib/git/permissions.d.ts +17 -0
  79. package/lib/git/permissions.mjs +7 -0
  80. package/lib/git/pull-strategy.cjs +13 -0
  81. package/lib/git/pull-strategy.d.cts +5 -0
  82. package/lib/git/pull-strategy.d.mts +15 -0
  83. package/lib/git/pull-strategy.d.ts +15 -0
  84. package/lib/git/pull-strategy.mjs +7 -0
  85. package/lib/git/user-config.cjs +100 -0
  86. package/lib/git/user-config.d.cts +10 -0
  87. package/lib/git/user-config.d.mts +105 -0
  88. package/lib/git/user-config.d.ts +105 -0
  89. package/lib/git/user-config.mjs +8 -0
  90. package/lib/git/utils.cjs +70 -0
  91. package/lib/git/utils.d.cts +20 -0
  92. package/lib/git/utils.d.mts +69 -0
  93. package/lib/git/utils.d.ts +69 -0
  94. package/lib/git/utils.mjs +6 -0
  95. package/lib/git-diff.cjs +23 -24
  96. package/lib/git-diff.d.mts +25 -28
  97. package/lib/git-diff.d.ts +25 -28
  98. package/lib/git-diff.mjs +32 -27
  99. package/lib/git-fix.cjs +129 -0
  100. package/lib/git-fix.d.cts +2 -0
  101. package/lib/git-fix.d.mts +141 -0
  102. package/lib/git-fix.d.ts +141 -0
  103. package/lib/git-fix.mjs +151 -0
  104. package/lib/git-purge.cjs +86 -2
  105. package/lib/git-purge.mjs +3 -5
  106. package/lib/index.cjs +8 -0
  107. package/lib/index.mjs +3 -5
  108. package/lib/npm-run-series.cjs +140 -1
  109. package/lib/npm-run-series.js +2 -1
  110. package/lib/npm-run-series.mjs +7 -5
  111. package/lib/package-resolutions-updater.cjs +447 -0
  112. package/lib/package-resolutions-updater.d.mts +1 -0
  113. package/lib/package-resolutions-updater.d.ts +352 -0
  114. package/lib/package-resolutions-updater.mjs +339 -0
  115. package/lib/print-directory-tree.cjs +241 -0
  116. package/lib/print-directory-tree.d.cts +1 -0
  117. package/lib/print-directory-tree.d.mts +234 -0
  118. package/lib/print-directory-tree.d.ts +234 -0
  119. package/lib/print-directory-tree.mjs +182 -0
  120. package/lib/ps/connected-domain.mjs +2 -3
  121. package/lib/ps/index.cjs +3 -3
  122. package/lib/ps/index.d.mjs +1 -2
  123. package/lib/ps/index.js +6 -3
  124. package/lib/ps/index.mjs +9 -11
  125. package/lib/ps/isWin.mjs +2 -3
  126. package/lib/ps/table-parser.mjs +3 -4
  127. package/lib/submodule-install.cjs +18 -35
  128. package/lib/submodule-install.d.mts +17 -37
  129. package/lib/submodule-install.d.ts +17 -37
  130. package/lib/submodule-install.mjs +21 -29
  131. package/lib/utils.cjs +86 -2
  132. package/lib/utils.d.mts +29 -9
  133. package/lib/utils.d.ts +28 -8
  134. package/lib/utils.js +139 -8
  135. package/lib/utils.mjs +2 -3
  136. package/lib/yarn-reinstall.cjs +9 -7
  137. package/lib/yarn-reinstall.d.mts +12 -8
  138. package/lib/yarn-reinstall.d.ts +12 -8
  139. package/lib/yarn-reinstall.mjs +14 -10
  140. package/package.json +109 -80
  141. package/readme.md +74 -11
  142. package/src/package-resolutions-updater.mjs +350 -0
  143. package/src/print-directory-tree.cjs +234 -0
  144. package/src/ps/index.js +4 -3
  145. package/src/yarn-reinstall.cjs +49 -0
  146. package/test-project/package.json +16 -0
  147. package/tmp/test-repo/package.json +7 -0
  148. package/bin/git-fix-encoding.cmd +0 -6
  149. package/lib/chunk-OKYLF2MU.mjs +0 -53
  150. package/lib/chunk-VXZQNLPU.mjs +0 -23
  151. package/lib/package-resolutions.cjs +0 -28
  152. package/lib/package-resolutions.d.mts +0 -25
  153. package/lib/package-resolutions.d.ts +0 -25
  154. package/lib/package-resolutions.mjs +0 -31
  155. /package/bin/{submodule-install → submodule-install.txt} +0 -0
@@ -0,0 +1,105 @@
1
+ const gch = require("git-command-helper");
2
+ const { runGitCommand, runGitCommandOutput } = require("./utils.cjs");
3
+ const { getArgs } = require("../utils.js");
4
+
5
+ /**
6
+ * Configure Git user from CLI arguments or environment variables
7
+ * @param {string|null} cliUser - Username from CLI arguments
8
+ * @param {string|null} cliEmail - Email from CLI arguments
9
+ * @param {object} [options] - Options object
10
+ * @param {boolean} [options.updateRemote] - If true, update remote URL without prompt
11
+ */
12
+ function configureGitUser(cliUser = null, cliEmail = null, options = {}) {
13
+ console.log("\n=== Configuring Git User ===");
14
+
15
+ // Determine user and email with CLI args taking precedence
16
+ let username, email;
17
+
18
+ if (cliUser && cliEmail) {
19
+ username = cliUser.trim();
20
+ email = cliEmail.trim();
21
+ console.log("[i] Using CLI-provided user configuration");
22
+ } else {
23
+ username = process.env.GITHUB_USER ? process.env.GITHUB_USER.trim() : undefined;
24
+ email = process.env.GITHUB_EMAIL ? process.env.GITHUB_EMAIL.trim() : undefined;
25
+ if (username || email) {
26
+ console.log("[i] Using environment variable user configuration");
27
+ }
28
+ }
29
+
30
+ if (!username && !email) {
31
+ console.log("[i] No Git user configuration needed (no CLI args or environment variables set)");
32
+ return;
33
+ }
34
+
35
+ if (username) {
36
+ const success = runGitCommand(["config", "user.name", username], `Set Git username to "${username}"`);
37
+ if (!success) {
38
+ console.log("[i] Failed to set Git username, but continuing...");
39
+ }
40
+ } else {
41
+ console.log("[i] No username provided, skipping username configuration");
42
+ }
43
+
44
+ if (email) {
45
+ const success = runGitCommand(["config", "user.email", email], `Set Git email to "${email}"`);
46
+ if (!success) {
47
+ console.log("[i] Failed to set Git email, but continuing...");
48
+ }
49
+ } else {
50
+ console.log("[i] No email provided, skipping email configuration");
51
+ }
52
+
53
+ if (username || email) {
54
+ console.log("[✓] Git user configuration completed");
55
+ }
56
+
57
+ if (username) {
58
+ // Ask user to modify the origin remote URL if it doesn't match the username
59
+ const remoteUrl = runGitCommandOutput(["remote", "get-url", "origin"], "Fetching remote URL for verification");
60
+ if (remoteUrl) {
61
+ console.log(`[i] Remote URL: ${remoteUrl}`);
62
+ const parsedUrl = gch.parseGitHubUrl(remoteUrl);
63
+ if (parsedUrl && parsedUrl.owner && username && parsedUrl.owner.toLowerCase() !== username.toLowerCase()) {
64
+ console.warn(
65
+ `\n[!] The GitHub remote owner ("${parsedUrl.owner}") does not match the configured username ("${username}").`
66
+ );
67
+ console.warn(`[!] If this is not intentional, consider updating the remote URL to use your username.`);
68
+ console.warn(`[!] Example: git remote set-url origin https://github.com/${username}/<repo>.git\n`);
69
+ // Check for --update-remote CLI argument or options.updateRemote
70
+ const args = getArgs();
71
+ const updateRemote = options.updateRemote || args["update-remote"] === true;
72
+ if (updateRemote) {
73
+ // Only update the username in the URL, not the repo path
74
+ let newUrl = remoteUrl;
75
+ // Handle https:// and git@ URLs
76
+ if (/^https:\/\//.test(remoteUrl)) {
77
+ newUrl = remoteUrl.replace(/https:\/\/(?:[^@]+@)?github.com/, `https://${username}@github.com`);
78
+ } else if (/^git@github.com:/.test(remoteUrl)) {
79
+ // For git@github.com:user/repo.git, do not change path, just warn user to use HTTPS with username if needed
80
+ console.warn(
81
+ `[!] For SSH remotes, set your SSH config or use HTTPS with username if you want to change authentication user.`
82
+ );
83
+ return;
84
+ }
85
+ if (newUrl !== remoteUrl) {
86
+ const updated = runGitCommand(["remote", "set-url", "origin", newUrl], `Set origin to ${newUrl}`);
87
+ if (updated) {
88
+ console.log(`[✓] Remote URL updated to: ${newUrl}`);
89
+ } else {
90
+ console.warn(`[!] Failed to update remote URL. Please update it manually if needed.`);
91
+ }
92
+ } else {
93
+ console.log(`[i] Remote URL does not use HTTPS or already contains the username.`);
94
+ }
95
+ } else {
96
+ console.log(`[i] Remote URL not changed. Use --update-remote to update automatically.`);
97
+ }
98
+ }
99
+ }
100
+ }
101
+ }
102
+
103
+ module.exports = {
104
+ configureGitUser
105
+ };
@@ -0,0 +1,8 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ require_user_config
4
+ } from "../chunk-ONIBBBQ3.mjs";
5
+ import "../chunk-EGSSKVDH.mjs";
6
+ import "../chunk-APBWENF6.mjs";
7
+ import "../chunk-AASHBCRW.mjs";
8
+ export default require_user_config();
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ const { execSync, spawnSync } = require("child_process");
3
+ /**
4
+ * Execute a git command with proper error handling and logging
5
+ * @param {string[]} args - Git command arguments
6
+ * @param {string} description - Description of the operation for logging
7
+ * @returns {boolean} - True if successful, false otherwise
8
+ */
9
+ function runGitCommand(args, description) {
10
+ try {
11
+ console.log(`[i] ${description}`);
12
+ const result = spawnSync("git", args, { encoding: "utf-8" });
13
+ if (result.status !== 0) {
14
+ console.error(`[✗] Failed: ${description}`);
15
+ console.error(`Error: ${result.stderr || result.stdout}`);
16
+ return false;
17
+ }
18
+ console.log(`[✓] ${description}`);
19
+ return true;
20
+ }
21
+ catch (error) {
22
+ console.error(`[✗] Failed: ${description}`);
23
+ console.error(`Error: ${error.message}`);
24
+ return false;
25
+ }
26
+ }
27
+ /**
28
+ * Check if the given cwd (or current directory) is a git repository
29
+ * @param {string} [cwd] - Directory to check (defaults to current directory at call time)
30
+ * @returns {boolean} - True if in a git repository, false otherwise
31
+ */
32
+ function isGitRepository(cwd) {
33
+ const dir = typeof cwd === "string" ? cwd : process.cwd();
34
+ try {
35
+ execSync("git rev-parse --git-dir", { stdio: "pipe", cwd: dir });
36
+ return true;
37
+ }
38
+ catch (_a) {
39
+ return false;
40
+ }
41
+ }
42
+ /**
43
+ * Execute a git command and return stdout (or null on error)
44
+ * @param {string[]} args - Git command arguments
45
+ * @param {string} description - Description of the operation for logging
46
+ * @returns {string|null} - stdout string if successful, null otherwise
47
+ */
48
+ function runGitCommandOutput(args, description) {
49
+ try {
50
+ console.log(`[i] ${description}`);
51
+ const result = spawnSync("git", args, { encoding: "utf-8" });
52
+ if (result.status !== 0) {
53
+ console.error(`[✗] Failed: ${description}`);
54
+ console.error(`Error: ${result.stderr || result.stdout}`);
55
+ return null;
56
+ }
57
+ console.log(`[✓] ${description}`);
58
+ return result.stdout.trim();
59
+ }
60
+ catch (error) {
61
+ console.error(`[✗] Failed: ${description}`);
62
+ console.error(`Error: ${error.message}`);
63
+ return null;
64
+ }
65
+ }
66
+ module.exports = {
67
+ runGitCommand,
68
+ runGitCommandOutput,
69
+ isGitRepository
70
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Execute a git command with proper error handling and logging
3
+ * @param {string[]} args - Git command arguments
4
+ * @param {string} description - Description of the operation for logging
5
+ * @returns {boolean} - True if successful, false otherwise
6
+ */
7
+ export function runGitCommand(args: string[], description: string): boolean;
8
+ /**
9
+ * Execute a git command and return stdout (or null on error)
10
+ * @param {string[]} args - Git command arguments
11
+ * @param {string} description - Description of the operation for logging
12
+ * @returns {string|null} - stdout string if successful, null otherwise
13
+ */
14
+ export function runGitCommandOutput(args: string[], description: string): string | null;
15
+ /**
16
+ * Check if the given cwd (or current directory) is a git repository
17
+ * @param {string} [cwd] - Directory to check (defaults to current directory at call time)
18
+ * @returns {boolean} - True if in a git repository, false otherwise
19
+ */
20
+ export function isGitRepository(cwd?: string): boolean;
@@ -0,0 +1,69 @@
1
+ const { execSync, spawnSync } = require("child_process");
2
+ /**
3
+ * Execute a git command with proper error handling and logging
4
+ * @param {string[]} args - Git command arguments
5
+ * @param {string} description - Description of the operation for logging
6
+ * @returns {boolean} - True if successful, false otherwise
7
+ */
8
+ function runGitCommand(args, description) {
9
+ try {
10
+ console.log(`[i] ${description}`);
11
+ const result = spawnSync("git", args, { encoding: "utf-8" });
12
+ if (result.status !== 0) {
13
+ console.error(`[✗] Failed: ${description}`);
14
+ console.error(`Error: ${result.stderr || result.stdout}`);
15
+ return false;
16
+ }
17
+ console.log(`[✓] ${description}`);
18
+ return true;
19
+ } catch (error) {
20
+ console.error(`[✗] Failed: ${description}`);
21
+ console.error(`Error: ${error.message}`);
22
+ return false;
23
+ }
24
+ }
25
+
26
+ /**
27
+ * Check if the given cwd (or current directory) is a git repository
28
+ * @param {string} [cwd] - Directory to check (defaults to current directory at call time)
29
+ * @returns {boolean} - True if in a git repository, false otherwise
30
+ */
31
+ function isGitRepository(cwd) {
32
+ const dir = typeof cwd === "string" ? cwd : process.cwd();
33
+ try {
34
+ execSync("git rev-parse --git-dir", { stdio: "pipe", cwd: dir });
35
+ return true;
36
+ } catch {
37
+ return false;
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Execute a git command and return stdout (or null on error)
43
+ * @param {string[]} args - Git command arguments
44
+ * @param {string} description - Description of the operation for logging
45
+ * @returns {string|null} - stdout string if successful, null otherwise
46
+ */
47
+ function runGitCommandOutput(args, description) {
48
+ try {
49
+ console.log(`[i] ${description}`);
50
+ const result = spawnSync("git", args, { encoding: "utf-8" });
51
+ if (result.status !== 0) {
52
+ console.error(`[✗] Failed: ${description}`);
53
+ console.error(`Error: ${result.stderr || result.stdout}`);
54
+ return null;
55
+ }
56
+ console.log(`[✓] ${description}`);
57
+ return result.stdout.trim();
58
+ } catch (error) {
59
+ console.error(`[✗] Failed: ${description}`);
60
+ console.error(`Error: ${error.message}`);
61
+ return null;
62
+ }
63
+ }
64
+
65
+ module.exports = {
66
+ runGitCommand,
67
+ runGitCommandOutput,
68
+ isGitRepository
69
+ };
@@ -0,0 +1,69 @@
1
+ const { execSync, spawnSync } = require("child_process");
2
+ /**
3
+ * Execute a git command with proper error handling and logging
4
+ * @param {string[]} args - Git command arguments
5
+ * @param {string} description - Description of the operation for logging
6
+ * @returns {boolean} - True if successful, false otherwise
7
+ */
8
+ function runGitCommand(args, description) {
9
+ try {
10
+ console.log(`[i] ${description}`);
11
+ const result = spawnSync("git", args, { encoding: "utf-8" });
12
+ if (result.status !== 0) {
13
+ console.error(`[✗] Failed: ${description}`);
14
+ console.error(`Error: ${result.stderr || result.stdout}`);
15
+ return false;
16
+ }
17
+ console.log(`[✓] ${description}`);
18
+ return true;
19
+ } catch (error) {
20
+ console.error(`[✗] Failed: ${description}`);
21
+ console.error(`Error: ${error.message}`);
22
+ return false;
23
+ }
24
+ }
25
+
26
+ /**
27
+ * Check if the given cwd (or current directory) is a git repository
28
+ * @param {string} [cwd] - Directory to check (defaults to current directory at call time)
29
+ * @returns {boolean} - True if in a git repository, false otherwise
30
+ */
31
+ function isGitRepository(cwd) {
32
+ const dir = typeof cwd === "string" ? cwd : process.cwd();
33
+ try {
34
+ execSync("git rev-parse --git-dir", { stdio: "pipe", cwd: dir });
35
+ return true;
36
+ } catch {
37
+ return false;
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Execute a git command and return stdout (or null on error)
43
+ * @param {string[]} args - Git command arguments
44
+ * @param {string} description - Description of the operation for logging
45
+ * @returns {string|null} - stdout string if successful, null otherwise
46
+ */
47
+ function runGitCommandOutput(args, description) {
48
+ try {
49
+ console.log(`[i] ${description}`);
50
+ const result = spawnSync("git", args, { encoding: "utf-8" });
51
+ if (result.status !== 0) {
52
+ console.error(`[✗] Failed: ${description}`);
53
+ console.error(`Error: ${result.stderr || result.stdout}`);
54
+ return null;
55
+ }
56
+ console.log(`[✓] ${description}`);
57
+ return result.stdout.trim();
58
+ } catch (error) {
59
+ console.error(`[✗] Failed: ${description}`);
60
+ console.error(`Error: ${error.message}`);
61
+ return null;
62
+ }
63
+ }
64
+
65
+ module.exports = {
66
+ runGitCommand,
67
+ runGitCommandOutput,
68
+ isGitRepository
69
+ };
@@ -0,0 +1,6 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ require_utils
4
+ } from "../chunk-EGSSKVDH.mjs";
5
+ import "../chunk-AASHBCRW.mjs";
6
+ export default require_utils();
package/lib/git-diff.cjs CHANGED
@@ -3,9 +3,10 @@
3
3
  const { execSync } = require("child_process");
4
4
  const fs = require("fs");
5
5
  const path = require("path");
6
- // Output path
7
- const CACHE_DIR = ".cache/git";
8
- const OUTPUT = path.join(CACHE_DIR, "diff.txt");
6
+ const { getTempPath } = require("./binary-collections-config");
7
+ // Output path using centralized temp directory configuration
8
+ const OUTPUT = getTempPath("git-diff.txt");
9
+ const CACHE_DIR = path.dirname(OUTPUT);
9
10
  // Ensure output directory exists
10
11
  if (!fs.existsSync(CACHE_DIR)) {
11
12
  fs.mkdirSync(CACHE_DIR, { recursive: true });
@@ -25,7 +26,10 @@ function showHelp() {
25
26
  function runGitDiff(command, successMessage, errorMessage) {
26
27
  try {
27
28
  console.log(`[i] Running command: ${command}`);
28
- const result = execSync(command, { encoding: "utf8" });
29
+ const result = execSync(command, {
30
+ encoding: "utf8",
31
+ maxBuffer: 1024 * 1024 * 10 // 10MB buffer to handle large diffs
32
+ });
29
33
  // If result is empty, inform user but don't treat as error
30
34
  if (!result || result.trim() === "") {
31
35
  console.log(`[i] No changes found for the specified criteria`);
@@ -47,28 +51,23 @@ function runGitDiff(command, successMessage, errorMessage) {
47
51
  process.exit(1);
48
52
  }
49
53
  }
50
- // Parse command line arguments
51
- const args = process.argv.slice(2);
54
+ const { getArgs } = require("./utils.js");
55
+ const args = getArgs();
56
+ const positional = args._ || [];
52
57
  // Show help if no arguments or --help/-h is passed
53
- if (args[0] === "--help" || args[0] === "-h") {
58
+ if (args.help || args.h) {
54
59
  showHelp();
55
60
  }
56
- // Parse options
57
- switch (args[0]) {
58
- case "--staged-only":
59
- case "-s":
60
- case "-S":
61
- runGitDiff("git --no-pager diff --staged", `Full staged diff saved to "${OUTPUT}"`, "Failed to save staged diff");
62
- break;
63
- default: {
64
- // Handle specific file diff
65
- const file = args[0];
66
- if (!file) {
67
- runGitDiff("git --no-pager diff", `Full staged diff saved to "${OUTPUT}"`, "Failed to save all diff's");
68
- }
69
- else {
70
- runGitDiff(`git --no-pager diff --cached -- "${file}"`, `Staged diff of "${file}" saved to "${OUTPUT}"`, `Failed to generate diff for "${file}"`);
71
- }
72
- break;
61
+ if (args["staged-only"] || args.s || args.S) {
62
+ runGitDiff("git --no-pager diff --staged", `Full staged diff saved to "${OUTPUT}"`, "Failed to save staged diff");
63
+ }
64
+ else {
65
+ // Handle specific file diff
66
+ const file = positional[0];
67
+ if (!file) {
68
+ runGitDiff("git --no-pager diff", `Full staged diff saved to "${OUTPUT}"`, "Failed to save all diff's");
69
+ }
70
+ else {
71
+ runGitDiff(`git --no-pager diff --cached -- "${file}"`, `Staged diff of "${file}" saved to "${OUTPUT}"`, `Failed to generate diff for "${file}"`);
73
72
  }
74
73
  }
@@ -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 CACHE_DIR = ".cache/git";
8
- const OUTPUT = path.join(CACHE_DIR, "diff.txt");
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, { encoding: "utf8" });
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
- // Parse command line arguments
58
- const args = process.argv.slice(2);
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[0] === "--help" || args[0] === "-h") {
66
+ if (args.help || args.h) {
62
67
  showHelp();
63
68
  }
64
69
 
65
- // Parse options
66
- switch (args[0]) {
67
- case "--staged-only":
68
- case "-s":
69
- case "-S":
70
- runGitDiff("git --no-pager diff --staged", `Full staged diff saved to "${OUTPUT}"`, "Failed to save staged diff");
71
- break;
72
-
73
- default: {
74
- // Handle specific file diff
75
- const file = args[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
- );
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.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 CACHE_DIR = ".cache/git";
8
- const OUTPUT = path.join(CACHE_DIR, "diff.txt");
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, { encoding: "utf8" });
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
- // Parse command line arguments
58
- const args = process.argv.slice(2);
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[0] === "--help" || args[0] === "-h") {
66
+ if (args.help || args.h) {
62
67
  showHelp();
63
68
  }
64
69
 
65
- // Parse options
66
- switch (args[0]) {
67
- case "--staged-only":
68
- case "-s":
69
- case "-S":
70
- runGitDiff("git --no-pager diff --staged", `Full staged diff saved to "${OUTPUT}"`, "Failed to save staged diff");
71
- break;
72
-
73
- default: {
74
- // Handle specific file diff
75
- const file = args[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
- );
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
- init_esm_shims
5
- } from "./chunk-VXZQNLPU.mjs";
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
- } from "./chunk-FB6YIQYR.mjs";
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 CACHE_DIR = ".cache/git";
19
- var OUTPUT = path.join(CACHE_DIR, "diff.txt");
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, { encoding: "utf8" });
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 args = process.argv.slice(2);
58
- if (args[0] === "--help" || args[0] === "-h") {
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
- switch (args[0]) {
62
- case "--staged-only":
63
- case "-s":
64
- case "-S":
65
- runGitDiff("git --no-pager diff --staged", `Full staged diff saved to "${OUTPUT}"`, "Failed to save staged diff");
66
- break;
67
- default: {
68
- const file = args[0];
69
- if (!file) {
70
- runGitDiff("git --no-pager diff", `Full staged diff saved to "${OUTPUT}"`, "Failed to save all diff's");
71
- } else {
72
- runGitDiff(
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
  }