binary-collections 2.0.5 → 2.0.7

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 (126) hide show
  1. package/bin/bash-dummy +7 -2
  2. package/bin/clean-nodemodule +7 -2
  3. package/bin/clean-nodemodules +7 -2
  4. package/bin/dev +7 -2
  5. package/bin/empty +7 -2
  6. package/bin/git-diff.cmd +4 -0
  7. package/bin/git-fix-encoding +7 -2
  8. package/bin/git-fix-encoding.cmd +0 -0
  9. package/bin/git-reduce-size +7 -2
  10. package/bin/kill-process +7 -2
  11. package/bin/nodekill +7 -2
  12. package/bin/nodekill.cmd +0 -0
  13. package/bin/nodekill.ps1 +0 -0
  14. package/bin/prod +7 -2
  15. package/bin/rmfind +7 -2
  16. package/bin/rmpath +7 -2
  17. package/bin/rmx +9 -3
  18. package/bin/submodule +13 -2
  19. package/bin/submodule-install +7 -2
  20. package/bin/submodule-remove +7 -2
  21. package/lib/chunk-3LOB2P54.mjs +202 -0
  22. package/lib/chunk-4LEXWIIF.mjs +173 -0
  23. package/lib/chunk-BSD5CIRU.mjs +52 -0
  24. package/lib/chunk-FB6YIQYR.mjs +42 -0
  25. package/lib/chunk-JL32QDSH.mjs +20 -0
  26. package/lib/chunk-OKYLF2MU.mjs +53 -0
  27. package/lib/chunk-VXZQNLPU.mjs +23 -0
  28. package/lib/del-gradle.cjs +72 -0
  29. package/lib/del-gradle.d.mts +2 -0
  30. package/lib/del-gradle.d.ts +1 -0
  31. package/lib/del-gradle.js +15 -0
  32. package/lib/del-gradle.mjs +28 -0
  33. package/lib/del-node-modules.cjs +72 -0
  34. package/lib/del-node-modules.d.mts +2 -0
  35. package/lib/del-node-modules.d.ts +1 -0
  36. package/lib/del-node-modules.js +11 -15
  37. package/lib/del-node-modules.mjs +28 -0
  38. package/lib/del-ps.cjs +93 -0
  39. package/lib/del-ps.d.mts +2 -0
  40. package/lib/del-ps.d.ts +1 -0
  41. package/lib/del-ps.js +31 -0
  42. package/lib/del-ps.mjs +43 -0
  43. package/lib/del-yarn-caches.cjs +65 -0
  44. package/lib/del-yarn-caches.d.mts +2 -0
  45. package/lib/del-yarn-caches.d.ts +1 -0
  46. package/lib/del-yarn-caches.js +6 -9
  47. package/lib/del-yarn-caches.mjs +21 -0
  48. package/lib/find-node-modules-cli.cjs +59 -0
  49. package/lib/find-node-modules-cli.d.mts +1 -0
  50. package/lib/find-node-modules-cli.d.ts +2 -0
  51. package/lib/find-node-modules-cli.js +3 -0
  52. package/lib/find-node-modules-cli.mjs +14 -0
  53. package/lib/find-node-modules.cjs +34 -0
  54. package/lib/find-node-modules.d.mts +10 -0
  55. package/lib/find-node-modules.d.ts +9 -0
  56. package/lib/find-node-modules.js +41 -13
  57. package/lib/find-node-modules.mjs +7 -0
  58. package/lib/git-diff.cjs +74 -0
  59. package/lib/git-diff.d.cts +2 -0
  60. package/lib/git-diff.d.mts +87 -0
  61. package/lib/git-diff.d.ts +87 -0
  62. package/lib/git-diff.mjs +83 -0
  63. package/lib/git-purge.cjs +91 -0
  64. package/lib/git-purge.d.mts +2 -0
  65. package/lib/git-purge.d.ts +1 -0
  66. package/lib/git-purge.js +59 -0
  67. package/lib/git-purge.mjs +47 -0
  68. package/lib/index.cjs +92 -0
  69. package/lib/index.d.mts +1 -0
  70. package/lib/index.d.ts +2 -0
  71. package/lib/index.js +8 -0
  72. package/lib/index.mjs +18 -0
  73. package/lib/npm-run-series.cjs +61 -0
  74. package/lib/npm-run-series.d.mts +1 -0
  75. package/lib/npm-run-series.d.ts +2 -0
  76. package/lib/npm-run-series.js +80 -39
  77. package/lib/npm-run-series.mjs +47 -0
  78. package/lib/package-resolutions.cjs +28 -0
  79. package/lib/package-resolutions.d.mts +25 -0
  80. package/lib/package-resolutions.d.ts +25 -0
  81. package/lib/package-resolutions.mjs +31 -0
  82. package/lib/ps/connected-domain.cjs +156 -0
  83. package/lib/ps/connected-domain.d.mts +3 -0
  84. package/lib/ps/connected-domain.d.ts +2 -0
  85. package/lib/ps/connected-domain.js +202 -0
  86. package/lib/ps/connected-domain.mjs +7 -0
  87. package/lib/ps/index.cjs +555 -0
  88. package/lib/ps/index.d.cjs +17 -0
  89. package/lib/ps/index.d.d.mts +26 -0
  90. package/lib/ps/index.d.d.ts +26 -0
  91. package/lib/ps/index.d.mjs +8 -0
  92. package/lib/ps/index.d.mts +26 -0
  93. package/lib/ps/index.d.ts +2 -0
  94. package/lib/ps/index.js +250 -0
  95. package/lib/ps/index.mjs +203 -0
  96. package/lib/ps/isWin.cjs +3 -0
  97. package/lib/ps/isWin.d.mts +3 -0
  98. package/lib/ps/isWin.d.ts +2 -0
  99. package/lib/ps/isWin.js +2 -0
  100. package/lib/ps/isWin.mjs +7 -0
  101. package/lib/ps/table-parser.cjs +359 -0
  102. package/lib/ps/table-parser.d.mts +3 -0
  103. package/lib/ps/table-parser.d.ts +1 -0
  104. package/lib/ps/table-parser.js +268 -0
  105. package/lib/ps/table-parser.mjs +8 -0
  106. package/lib/submodule-install.cjs +118 -0
  107. package/lib/submodule-install.d.cts +2 -0
  108. package/lib/submodule-install.d.mts +141 -0
  109. package/lib/submodule-install.d.ts +141 -0
  110. package/lib/submodule-install.mjs +116 -0
  111. package/lib/utils.cjs +35 -0
  112. package/lib/utils.d.mts +20 -0
  113. package/lib/utils.d.ts +16 -0
  114. package/lib/utils.js +42 -28
  115. package/lib/utils.mjs +7 -0
  116. package/lib/yarn-reinstall.cjs +42 -0
  117. package/lib/yarn-reinstall.d.cts +1 -0
  118. package/lib/yarn-reinstall.d.mts +45 -0
  119. package/lib/yarn-reinstall.d.ts +45 -0
  120. package/lib/yarn-reinstall.mjs +50 -0
  121. package/package.json +80 -38
  122. package/readme.md +188 -40
  123. package/src/ps/index.js +285 -0
  124. package/test/package.json +19 -0
  125. package/index.js +0 -1
  126. package/lib/package-resolutions.json +0 -22
package/lib/del-ps.cjs ADDED
@@ -0,0 +1,93 @@
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __esm = (fn, res) => function __init() {
3
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
4
+ };
5
+ var __commonJS = (cb, mod) => function __require() {
6
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
7
+ };
8
+
9
+ // node_modules/tsup/assets/cjs_shims.js
10
+ var init_cjs_shims = __esm({
11
+ "node_modules/tsup/assets/cjs_shims.js"() {
12
+ }
13
+ });
14
+
15
+ // src/ps/isWin.js
16
+ var require_isWin = __commonJS({
17
+ "src/ps/isWin.js"(exports2, module2) {
18
+ init_cjs_shims();
19
+ var isWin2 = process.platform === "win32";
20
+ module2.exports = isWin2;
21
+ }
22
+ });
23
+
24
+ // src/utils.js
25
+ var require_utils = __commonJS({
26
+ "src/utils.js"(exports2, module2) {
27
+ init_cjs_shims();
28
+ var { fs, path } = require("sbg-utility");
29
+ var argv = require("minimist")(process.argv.slice(2));
30
+ function getArgs() {
31
+ return argv;
32
+ }
33
+ function del(fullPath) {
34
+ if (fs.statSync(fullPath).isDirectory()) {
35
+ const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
36
+ for (let i = 0; i < subdir.length; i++) {
37
+ del(subdir[i]);
38
+ }
39
+ } else {
40
+ try {
41
+ fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
42
+ console.log("deleted", fullPath);
43
+ } catch (_) {
44
+ console.log("failed delete", fullPath);
45
+ }
46
+ }
47
+ }
48
+ function delStream(globStream) {
49
+ globStream.stream().on("data", (result) => {
50
+ const fullPath = path.resolve(process.cwd(), result);
51
+ if (fs.statSync(fullPath).isDirectory()) {
52
+ const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
53
+ for (let i = 0; i < subdir.length; i++) {
54
+ del(subdir[i]);
55
+ }
56
+ }
57
+ del(fullPath);
58
+ });
59
+ }
60
+ var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
61
+ module2.exports = { del, delStream, getArgs, delay };
62
+ }
63
+ });
64
+
65
+ // src/del-ps.js
66
+ init_cjs_shims();
67
+ var crossSpawn = require("cross-spawn");
68
+ var ps = require("ps-node");
69
+ var isWin = require_isWin();
70
+ var utils = require_utils();
71
+ utils.getArgs()._.forEach((command) => {
72
+ ps.lookup(
73
+ {
74
+ command,
75
+ psargs: "ux"
76
+ },
77
+ function(err, resultList) {
78
+ if (err) {
79
+ throw new Error(err);
80
+ }
81
+ resultList.forEach(function(process2) {
82
+ if (process2) {
83
+ if (!isWin) {
84
+ crossSpawn.spawnAsync("kill", ["-9", process2.pid]).catch((e) => console.log(`kill failed ${e.message}`));
85
+ crossSpawn.spawnAsync("killall", ["-9", process2.pid]).catch((e) => console.log(`killall failed ${e.message}`));
86
+ } else {
87
+ crossSpawn.spawnAsync("wmic", ["process", "where", `"name like '${command}'" delete`]).catch((e) => console.log(`wmic failed ${e.message}`));
88
+ }
89
+ }
90
+ });
91
+ }
92
+ );
93
+ });
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1 @@
1
+ export {};
package/lib/del-ps.js ADDED
@@ -0,0 +1,31 @@
1
+ const crossSpawn = require("cross-spawn");
2
+ const ps = require("ps-node");
3
+ const isWin = require("./ps/isWin");
4
+ const utils = require("./utils");
5
+ utils.getArgs()._.forEach((command) => {
6
+ ps.lookup({
7
+ command,
8
+ psargs: "ux"
9
+ }, function (err, resultList) {
10
+ if (err) {
11
+ throw new Error(err);
12
+ }
13
+ resultList.forEach(function (process) {
14
+ if (process) {
15
+ // console.log('PID: %s, COMMAND: %s, ARGUMENTS: %s', process.pid, process.command, process.arguments);
16
+ if (!isWin) {
17
+ crossSpawn.spawnAsync("kill", ["-9", process.pid]).catch((e) => console.log(`kill failed ${e.message}`));
18
+ crossSpawn
19
+ .spawnAsync("killall", ["-9", process.pid])
20
+ .catch((e) => console.log(`killall failed ${e.message}`));
21
+ }
22
+ else {
23
+ // wmic process where "name like 'java.exe'" delete
24
+ crossSpawn
25
+ .spawnAsync("wmic", ["process", "where", `"name like '${command}'" delete`])
26
+ .catch((e) => console.log(`wmic failed ${e.message}`));
27
+ }
28
+ }
29
+ });
30
+ });
31
+ });
package/lib/del-ps.mjs ADDED
@@ -0,0 +1,43 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ require_isWin
4
+ } from "./chunk-JL32QDSH.mjs";
5
+ import {
6
+ require_utils
7
+ } from "./chunk-OKYLF2MU.mjs";
8
+ import {
9
+ init_esm_shims
10
+ } from "./chunk-VXZQNLPU.mjs";
11
+ import {
12
+ __require
13
+ } from "./chunk-FB6YIQYR.mjs";
14
+
15
+ // src/del-ps.js
16
+ init_esm_shims();
17
+ var crossSpawn = __require("cross-spawn");
18
+ var ps = __require("ps-node");
19
+ var isWin = require_isWin();
20
+ var utils = require_utils();
21
+ utils.getArgs()._.forEach((command) => {
22
+ ps.lookup(
23
+ {
24
+ command,
25
+ psargs: "ux"
26
+ },
27
+ function(err, resultList) {
28
+ if (err) {
29
+ throw new Error(err);
30
+ }
31
+ resultList.forEach(function(process) {
32
+ if (process) {
33
+ if (!isWin) {
34
+ crossSpawn.spawnAsync("kill", ["-9", process.pid]).catch((e) => console.log(`kill failed ${e.message}`));
35
+ crossSpawn.spawnAsync("killall", ["-9", process.pid]).catch((e) => console.log(`killall failed ${e.message}`));
36
+ } else {
37
+ crossSpawn.spawnAsync("wmic", ["process", "where", `"name like '${command}'" delete`]).catch((e) => console.log(`wmic failed ${e.message}`));
38
+ }
39
+ }
40
+ });
41
+ }
42
+ );
43
+ });
@@ -0,0 +1,65 @@
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __esm = (fn, res) => function __init() {
3
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
4
+ };
5
+ var __commonJS = (cb, mod) => function __require() {
6
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
7
+ };
8
+
9
+ // node_modules/tsup/assets/cjs_shims.js
10
+ var init_cjs_shims = __esm({
11
+ "node_modules/tsup/assets/cjs_shims.js"() {
12
+ }
13
+ });
14
+
15
+ // src/utils.js
16
+ var require_utils = __commonJS({
17
+ "src/utils.js"(exports2, module2) {
18
+ init_cjs_shims();
19
+ var { fs, path } = require("sbg-utility");
20
+ var argv = require("minimist")(process.argv.slice(2));
21
+ function getArgs() {
22
+ return argv;
23
+ }
24
+ function del(fullPath) {
25
+ if (fs.statSync(fullPath).isDirectory()) {
26
+ const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
27
+ for (let i = 0; i < subdir.length; i++) {
28
+ del(subdir[i]);
29
+ }
30
+ } else {
31
+ try {
32
+ fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
33
+ console.log("deleted", fullPath);
34
+ } catch (_) {
35
+ console.log("failed delete", fullPath);
36
+ }
37
+ }
38
+ }
39
+ function delStream2(globStream) {
40
+ globStream.stream().on("data", (result) => {
41
+ const fullPath = path.resolve(process.cwd(), result);
42
+ if (fs.statSync(fullPath).isDirectory()) {
43
+ const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
44
+ for (let i = 0; i < subdir.length; i++) {
45
+ del(subdir[i]);
46
+ }
47
+ }
48
+ del(fullPath);
49
+ });
50
+ }
51
+ var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
52
+ module2.exports = { del, delStream: delStream2, getArgs, delay };
53
+ }
54
+ });
55
+
56
+ // src/del-yarn-caches.js
57
+ init_cjs_shims();
58
+ var glob = require("glob");
59
+ var { delStream } = require_utils();
60
+ var g3 = new glob.Glob(["**/.yarn/cache*", "**/.yarn/*.gz"], {
61
+ withFileTypes: false,
62
+ cwd: process.cwd(),
63
+ ignore: ["**/.git*", "**/vendor/**"]
64
+ });
65
+ delStream(g3);
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,11 +1,8 @@
1
- const glob = require('glob');
2
- const { delStream } = require('./utils');
3
- // const path = require('path');
4
- // process.cwd = () => path.resolve(__dirname + '/../../../Repositories');
5
-
6
- const g3 = new glob.Glob(['**/.yarn/cache*', '**/.yarn/*.gz'], {
7
- withFileTypes: false,
8
- cwd: process.cwd(),
9
- ignore: ['**/.git*', '**/vendor/**']
1
+ const glob = require("glob");
2
+ const { delStream } = require("./utils");
3
+ const g3 = new glob.Glob(["**/.yarn/cache*", "**/.yarn/*.gz"], {
4
+ withFileTypes: false,
5
+ cwd: process.cwd(),
6
+ ignore: ["**/.git*", "**/vendor/**"]
10
7
  });
11
8
  delStream(g3);
@@ -0,0 +1,21 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ require_utils
4
+ } from "./chunk-OKYLF2MU.mjs";
5
+ import {
6
+ init_esm_shims
7
+ } from "./chunk-VXZQNLPU.mjs";
8
+ import {
9
+ __require
10
+ } from "./chunk-FB6YIQYR.mjs";
11
+
12
+ // src/del-yarn-caches.js
13
+ init_esm_shims();
14
+ var glob = __require("glob");
15
+ var { delStream } = require_utils();
16
+ var g3 = new glob.Glob(["**/.yarn/cache*", "**/.yarn/*.gz"], {
17
+ withFileTypes: false,
18
+ cwd: process.cwd(),
19
+ ignore: ["**/.git*", "**/vendor/**"]
20
+ });
21
+ delStream(g3);
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env node
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/find-node-modules.js
17
+ var require_find_node_modules = __commonJS({
18
+ "src/find-node-modules.js"(exports2, module2) {
19
+ init_cjs_shims();
20
+ var glob = require("glob");
21
+ var path = require("path");
22
+ function findNodeModules2(dir = process.cwd(), callback = null) {
23
+ const finalDir = typeof dir === "string" ? dir : process.cwd();
24
+ return new Promise((resolve, reject) => {
25
+ const results = [];
26
+ const g3 = new glob.Glob("**/node_modules", {
27
+ withFileTypes: false,
28
+ cwd: finalDir,
29
+ ignore: ["**/.git*", "**/vendor/**"]
30
+ });
31
+ const stream = g3.stream();
32
+ stream.on("data", (result) => {
33
+ const fullPath = path.resolve(finalDir, result);
34
+ if (typeof callback === "function") {
35
+ try {
36
+ callback(fullPath);
37
+ } catch (err) {
38
+ console.error("findNodeModules callback error:", err);
39
+ }
40
+ }
41
+ results.push(fullPath);
42
+ });
43
+ stream.on("error", (err) => reject(err));
44
+ stream.on("end", () => {
45
+ if (results.length === 0) {
46
+ console.log("No node_modules directories found.");
47
+ }
48
+ resolve(results);
49
+ });
50
+ });
51
+ }
52
+ module2.exports = findNodeModules2;
53
+ }
54
+ });
55
+
56
+ // src/find-node-modules-cli.js
57
+ init_cjs_shims();
58
+ var findNodeModules = require_find_node_modules();
59
+ findNodeModules(null, console.log);
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ const findNodeModules = require("./find-node-modules");
3
+ findNodeModules(null, console.log);
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
3
+ import {
4
+ require_find_node_modules
5
+ } from "./chunk-BSD5CIRU.mjs";
6
+ import {
7
+ init_esm_shims
8
+ } from "./chunk-VXZQNLPU.mjs";
9
+ import "./chunk-FB6YIQYR.mjs";
10
+
11
+ // src/find-node-modules-cli.js
12
+ init_esm_shims();
13
+ var findNodeModules = require_find_node_modules();
14
+ findNodeModules(null, console.log);
@@ -0,0 +1,34 @@
1
+ // src/find-node-modules.js
2
+ var glob = require("glob");
3
+ var path = require("path");
4
+ function findNodeModules(dir = process.cwd(), callback = null) {
5
+ const finalDir = typeof dir === "string" ? dir : process.cwd();
6
+ return new Promise((resolve, reject) => {
7
+ const results = [];
8
+ const g3 = new glob.Glob("**/node_modules", {
9
+ withFileTypes: false,
10
+ cwd: finalDir,
11
+ ignore: ["**/.git*", "**/vendor/**"]
12
+ });
13
+ const stream = g3.stream();
14
+ stream.on("data", (result) => {
15
+ const fullPath = path.resolve(finalDir, result);
16
+ if (typeof callback === "function") {
17
+ try {
18
+ callback(fullPath);
19
+ } catch (err) {
20
+ console.error("findNodeModules callback error:", err);
21
+ }
22
+ }
23
+ results.push(fullPath);
24
+ });
25
+ stream.on("error", (err) => reject(err));
26
+ stream.on("end", () => {
27
+ if (results.length === 0) {
28
+ console.log("No node_modules directories found.");
29
+ }
30
+ resolve(results);
31
+ });
32
+ });
33
+ }
34
+ module.exports = findNodeModules;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Asynchronously finds all "node_modules" directories within the given directory.
3
+ *
4
+ * @param {string} [dir=process.cwd()] - The directory to start the search from. Defaults to the current working directory.
5
+ * @param {function} [callback=null] - Optional callback function that gets called with each found "node_modules" path.
6
+ * @returns {Promise<string[]>} - A promise that resolves to an array of full paths to "node_modules" directories.
7
+ */
8
+ declare function findNodeModules(dir?: string, callback?: Function): Promise<string[]>;
9
+
10
+ export { findNodeModules as default };
@@ -0,0 +1,9 @@
1
+ export = findNodeModules;
2
+ /**
3
+ * Asynchronously finds all "node_modules" directories within the given directory.
4
+ *
5
+ * @param {string} [dir=process.cwd()] - The directory to start the search from. Defaults to the current working directory.
6
+ * @param {function} [callback=null] - Optional callback function that gets called with each found "node_modules" path.
7
+ * @returns {Promise<string[]>} - A promise that resolves to an array of full paths to "node_modules" directories.
8
+ */
9
+ declare function findNodeModules(dir?: string, callback?: Function): Promise<string[]>;
@@ -1,13 +1,41 @@
1
- const glob = require('glob');
2
- const path = require('path');
3
- // process.cwd = () => path.resolve(__dirname + '/../../../Repositories');
4
-
5
- const g3 = new glob.Glob('**/node_modules', {
6
- withFileTypes: false,
7
- cwd: process.cwd(),
8
- ignore: ['**/.git*', '**/vendor/**']
9
- });
10
- g3.stream().on('data', (result) => {
11
- const fullPath = path.resolve(process.cwd(), result);
12
- console.log(fullPath);
13
- });
1
+ const glob = require("glob");
2
+ const path = require("path");
3
+ /**
4
+ * Asynchronously finds all "node_modules" directories within the given directory.
5
+ *
6
+ * @param {string} [dir=process.cwd()] - The directory to start the search from. Defaults to the current working directory.
7
+ * @param {function} [callback=null] - Optional callback function that gets called with each found "node_modules" path.
8
+ * @returns {Promise<string[]>} - A promise that resolves to an array of full paths to "node_modules" directories.
9
+ */
10
+ function findNodeModules(dir = process.cwd(), callback = null) {
11
+ const finalDir = typeof dir === "string" ? dir : process.cwd();
12
+ return new Promise((resolve, reject) => {
13
+ const results = [];
14
+ const g3 = new glob.Glob("**/node_modules", {
15
+ withFileTypes: false,
16
+ cwd: finalDir,
17
+ ignore: ["**/.git*", "**/vendor/**"]
18
+ });
19
+ const stream = g3.stream();
20
+ stream.on("data", (result) => {
21
+ const fullPath = path.resolve(finalDir, result);
22
+ if (typeof callback === "function") {
23
+ try {
24
+ callback(fullPath); // Safely invoke callback
25
+ }
26
+ catch (err) {
27
+ console.error("findNodeModules callback error:", err);
28
+ }
29
+ }
30
+ results.push(fullPath);
31
+ });
32
+ stream.on("error", (err) => reject(err)); // Handle errors
33
+ stream.on("end", () => {
34
+ if (results.length === 0) {
35
+ console.log("No node_modules directories found.");
36
+ }
37
+ resolve(results); // Resolve the full array when the stream ends
38
+ });
39
+ });
40
+ }
41
+ module.exports = findNodeModules;
@@ -0,0 +1,7 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ require_find_node_modules
4
+ } from "./chunk-BSD5CIRU.mjs";
5
+ import "./chunk-VXZQNLPU.mjs";
6
+ import "./chunk-FB6YIQYR.mjs";
7
+ export default require_find_node_modules();
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ const { execSync } = require("child_process");
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ // Output path
7
+ const CACHE_DIR = ".cache/git";
8
+ const OUTPUT = path.join(CACHE_DIR, "diff.txt");
9
+ // Ensure output directory exists
10
+ if (!fs.existsSync(CACHE_DIR)) {
11
+ fs.mkdirSync(CACHE_DIR, { recursive: true });
12
+ }
13
+ function showHelp() {
14
+ console.log("Git Diff Helper");
15
+ console.log("----------------------------");
16
+ console.log("Usage:");
17
+ console.log(" git-diff FILE Show staged diff of specified file");
18
+ console.log(" git-diff --staged-only Show staged diff of all files");
19
+ console.log(" git-diff -s | -S Same as --staged-only");
20
+ console.log(" git-diff --help | -h Show this help message");
21
+ console.log("");
22
+ console.log(`Output is saved to: ${OUTPUT}`);
23
+ process.exit(0);
24
+ }
25
+ function runGitDiff(command, successMessage, errorMessage) {
26
+ try {
27
+ console.log(`[i] Running command: ${command}`);
28
+ const result = execSync(command, { encoding: "utf8" });
29
+ // If result is empty, inform user but don't treat as error
30
+ if (!result || result.trim() === "") {
31
+ console.log(`[i] No changes found for the specified criteria`);
32
+ fs.writeFileSync(OUTPUT, "# No changes found\n");
33
+ console.log(`[✓] Empty diff saved to "${OUTPUT}"`);
34
+ return;
35
+ }
36
+ fs.writeFileSync(OUTPUT, result);
37
+ console.log(`[✓] ${successMessage}`);
38
+ }
39
+ catch (error) {
40
+ console.error(`[✗] ${errorMessage}`);
41
+ console.error(`Command: ${command}`);
42
+ console.error(`Error: ${error.message}`);
43
+ // Check if it's a git-related error
44
+ if (error.message.includes("not a git repository")) {
45
+ console.error("Make sure you are in a git repository");
46
+ }
47
+ process.exit(1);
48
+ }
49
+ }
50
+ // Parse command line arguments
51
+ const args = process.argv.slice(2);
52
+ // Show help if no arguments or --help/-h is passed
53
+ if (args[0] === "--help" || args[0] === "-h") {
54
+ showHelp();
55
+ }
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;
73
+ }
74
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env node
2
+ const { execSync } = require("child_process");
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+
6
+ // Output path
7
+ const CACHE_DIR = ".cache/git";
8
+ const OUTPUT = path.join(CACHE_DIR, "diff.txt");
9
+
10
+ // Ensure output directory exists
11
+ if (!fs.existsSync(CACHE_DIR)) {
12
+ fs.mkdirSync(CACHE_DIR, { recursive: true });
13
+ }
14
+
15
+ function showHelp() {
16
+ console.log("Git Diff Helper");
17
+ console.log("----------------------------");
18
+ console.log("Usage:");
19
+ console.log(" git-diff FILE Show staged diff of specified file");
20
+ console.log(" git-diff --staged-only Show staged diff of all files");
21
+ console.log(" git-diff -s | -S Same as --staged-only");
22
+ console.log(" git-diff --help | -h Show this help message");
23
+ console.log("");
24
+ console.log(`Output is saved to: ${OUTPUT}`);
25
+ process.exit(0);
26
+ }
27
+
28
+ function runGitDiff(command, successMessage, errorMessage) {
29
+ try {
30
+ console.log(`[i] Running command: ${command}`);
31
+ const result = execSync(command, { encoding: "utf8" });
32
+
33
+ // If result is empty, inform user but don't treat as error
34
+ if (!result || result.trim() === "") {
35
+ console.log(`[i] No changes found for the specified criteria`);
36
+ fs.writeFileSync(OUTPUT, "# No changes found\n");
37
+ console.log(`[✓] Empty diff saved to "${OUTPUT}"`);
38
+ return;
39
+ }
40
+
41
+ fs.writeFileSync(OUTPUT, result);
42
+ console.log(`[✓] ${successMessage}`);
43
+ } catch (error) {
44
+ console.error(`[✗] ${errorMessage}`);
45
+ console.error(`Command: ${command}`);
46
+ console.error(`Error: ${error.message}`);
47
+
48
+ // Check if it's a git-related error
49
+ if (error.message.includes("not a git repository")) {
50
+ console.error("Make sure you are in a git repository");
51
+ }
52
+
53
+ process.exit(1);
54
+ }
55
+ }
56
+
57
+ // Parse command line arguments
58
+ const args = process.argv.slice(2);
59
+
60
+ // Show help if no arguments or --help/-h is passed
61
+ if (args[0] === "--help" || args[0] === "-h") {
62
+ showHelp();
63
+ }
64
+
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;
86
+ }
87
+ }