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.
Files changed (150) 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 +105 -0
  15. package/lib/binary-collections.d.cts +2 -0
  16. package/lib/binary-collections.d.mts +121 -0
  17. package/lib/binary-collections.d.ts +121 -0
  18. package/lib/binary-collections.mjs +108 -0
  19. package/lib/chunk-4BYBVEYC.mjs +30 -0
  20. package/lib/{chunk-FB6YIQYR.mjs → chunk-AASHBCRW.mjs} +17 -2
  21. package/lib/chunk-APBWENF6.mjs +135 -0
  22. package/lib/{chunk-4LEXWIIF.mjs → chunk-DPKAJKFO.mjs} +2 -4
  23. package/lib/chunk-EGSSKVDH.mjs +66 -0
  24. package/lib/{chunk-3LOB2P54.mjs → chunk-G3THLIDT.mjs} +3 -5
  25. package/lib/chunk-JGR2NW6D.mjs +187 -0
  26. package/lib/chunk-ONIBBBQ3.mjs +108 -0
  27. package/lib/chunk-SH3L6HHV.mjs +27 -0
  28. package/lib/chunk-VVEZVNIV.mjs +81 -0
  29. package/lib/{chunk-JL32QDSH.mjs → chunk-W3ENOM53.mjs} +2 -4
  30. package/lib/chunk-YV7DO3YV.mjs +48 -0
  31. package/lib/{chunk-BSD5CIRU.mjs → chunk-YX5U7XDR.mjs} +11 -5
  32. package/lib/chunk-ZYAQRPUL.mjs +28 -0
  33. package/lib/clean-github-actions-caches.cjs +162 -0
  34. package/lib/clean-github-actions-caches.d.cts +1 -0
  35. package/lib/clean-github-actions-caches.d.mts +169 -0
  36. package/lib/clean-github-actions-caches.d.ts +169 -0
  37. package/lib/clean-github-actions-caches.mjs +132 -0
  38. package/lib/del-gradle.cjs +87 -3
  39. package/lib/del-gradle.js +1 -1
  40. package/lib/del-gradle.mjs +4 -6
  41. package/lib/del-node-modules.cjs +86 -2
  42. package/lib/del-node-modules.mjs +3 -5
  43. package/lib/del-ps.cjs +89 -5
  44. package/lib/del-ps.js +2 -2
  45. package/lib/del-ps.mjs +6 -8
  46. package/lib/del-yarn-caches.cjs +86 -2
  47. package/lib/del-yarn-caches.mjs +3 -5
  48. package/lib/find-node-modules-cli.cjs +8 -0
  49. package/lib/find-node-modules-cli.mjs +2 -3
  50. package/lib/find-node-modules.cjs +8 -0
  51. package/lib/find-node-modules.d.mts +3 -0
  52. package/lib/find-node-modules.d.ts +3 -0
  53. package/lib/find-node-modules.js +12 -0
  54. package/lib/find-node-modules.mjs +2 -3
  55. package/lib/git/gitattributes.cjs +171 -0
  56. package/lib/git/gitattributes.d.mts +35 -0
  57. package/lib/git/gitattributes.d.ts +33 -0
  58. package/lib/git/gitattributes.js +223 -0
  59. package/lib/git/gitattributes.mjs +6 -0
  60. package/lib/git/line-endings.cjs +74 -0
  61. package/lib/git/line-endings.d.cts +7 -0
  62. package/lib/git/line-endings.d.mts +83 -0
  63. package/lib/git/line-endings.d.ts +83 -0
  64. package/lib/git/line-endings.mjs +8 -0
  65. package/lib/git/normalize.cjs +42 -0
  66. package/lib/git/normalize.d.cts +6 -0
  67. package/lib/git/normalize.d.mts +43 -0
  68. package/lib/git/normalize.d.ts +43 -0
  69. package/lib/git/normalize.mjs +6 -0
  70. package/lib/git/permissions.cjs +15 -0
  71. package/lib/git/permissions.d.cts +6 -0
  72. package/lib/git/permissions.d.mts +17 -0
  73. package/lib/git/permissions.d.ts +17 -0
  74. package/lib/git/permissions.mjs +7 -0
  75. package/lib/git/pull-strategy.cjs +13 -0
  76. package/lib/git/pull-strategy.d.cts +5 -0
  77. package/lib/git/pull-strategy.d.mts +15 -0
  78. package/lib/git/pull-strategy.d.ts +15 -0
  79. package/lib/git/pull-strategy.mjs +7 -0
  80. package/lib/git/user-config.cjs +100 -0
  81. package/lib/git/user-config.d.cts +10 -0
  82. package/lib/git/user-config.d.mts +105 -0
  83. package/lib/git/user-config.d.ts +105 -0
  84. package/lib/git/user-config.mjs +8 -0
  85. package/lib/git/utils.cjs +70 -0
  86. package/lib/git/utils.d.cts +20 -0
  87. package/lib/git/utils.d.mts +69 -0
  88. package/lib/git/utils.d.ts +69 -0
  89. package/lib/git/utils.mjs +6 -0
  90. package/lib/git-diff.cjs +23 -24
  91. package/lib/git-diff.d.mts +25 -28
  92. package/lib/git-diff.d.ts +25 -28
  93. package/lib/git-diff.mjs +32 -27
  94. package/lib/git-fix.cjs +129 -0
  95. package/lib/git-fix.d.cts +2 -0
  96. package/lib/git-fix.d.mts +141 -0
  97. package/lib/git-fix.d.ts +141 -0
  98. package/lib/git-fix.mjs +151 -0
  99. package/lib/git-purge.cjs +86 -2
  100. package/lib/git-purge.mjs +3 -5
  101. package/lib/index.cjs +8 -0
  102. package/lib/index.mjs +3 -5
  103. package/lib/npm-run-series.cjs +140 -1
  104. package/lib/npm-run-series.js +2 -1
  105. package/lib/npm-run-series.mjs +7 -5
  106. package/lib/package-resolutions-updater.cjs +274 -0
  107. package/lib/package-resolutions-updater.d.mts +1 -0
  108. package/lib/package-resolutions-updater.d.ts +326 -0
  109. package/lib/package-resolutions-updater.mjs +316 -0
  110. package/lib/print-directory-tree.cjs +241 -0
  111. package/lib/print-directory-tree.d.cts +1 -0
  112. package/lib/print-directory-tree.d.mts +234 -0
  113. package/lib/print-directory-tree.d.ts +234 -0
  114. package/lib/print-directory-tree.mjs +182 -0
  115. package/lib/ps/connected-domain.mjs +2 -3
  116. package/lib/ps/index.cjs +3 -3
  117. package/lib/ps/index.d.mjs +1 -2
  118. package/lib/ps/index.js +6 -3
  119. package/lib/ps/index.mjs +9 -11
  120. package/lib/ps/isWin.mjs +2 -3
  121. package/lib/ps/table-parser.mjs +3 -4
  122. package/lib/submodule-install.cjs +13 -31
  123. package/lib/submodule-install.d.mts +12 -32
  124. package/lib/submodule-install.d.ts +12 -32
  125. package/lib/submodule-install.mjs +16 -25
  126. package/lib/utils.cjs +86 -2
  127. package/lib/utils.d.mts +29 -9
  128. package/lib/utils.d.ts +28 -8
  129. package/lib/utils.js +139 -8
  130. package/lib/utils.mjs +2 -3
  131. package/lib/yarn-reinstall.cjs +9 -7
  132. package/lib/yarn-reinstall.d.mts +12 -8
  133. package/lib/yarn-reinstall.d.ts +12 -8
  134. package/lib/yarn-reinstall.mjs +14 -10
  135. package/package.json +109 -80
  136. package/readme.md +74 -11
  137. package/src/package-resolutions-updater.mjs +325 -0
  138. package/src/print-directory-tree.cjs +234 -0
  139. package/src/ps/index.js +4 -3
  140. package/src/yarn-reinstall.cjs +49 -0
  141. package/test-project/package.json +16 -0
  142. package/tmp/test-repo/package.json +7 -0
  143. package/bin/git-fix-encoding.cmd +0 -6
  144. package/lib/chunk-OKYLF2MU.mjs +0 -53
  145. package/lib/chunk-VXZQNLPU.mjs +0 -23
  146. package/lib/package-resolutions.cjs +0 -28
  147. package/lib/package-resolutions.d.mts +0 -25
  148. package/lib/package-resolutions.d.ts +0 -25
  149. package/lib/package-resolutions.mjs +0 -31
  150. /package/bin/{submodule-install → submodule-install.txt} +0 -0
package/lib/ps/index.js CHANGED
@@ -185,7 +185,8 @@ exports.kill = function (pid, signal, next) {
185
185
  return;
186
186
  if (err) {
187
187
  clearTimeout(checkTimeoutTimer);
188
- finishCallback && finishCallback(err);
188
+ if (finishCallback)
189
+ finishCallback(err);
189
190
  }
190
191
  else if (list.length > 0) {
191
192
  checkConfident = checkConfident - 1 || 0;
@@ -195,7 +196,8 @@ exports.kill = function (pid, signal, next) {
195
196
  checkConfident++;
196
197
  if (checkConfident === 5) {
197
198
  clearTimeout(checkTimeoutTimer);
198
- finishCallback && finishCallback();
199
+ if (finishCallback)
200
+ finishCallback();
199
201
  }
200
202
  else {
201
203
  checkKilled(finishCallback);
@@ -203,7 +205,8 @@ exports.kill = function (pid, signal, next) {
203
205
  }
204
206
  });
205
207
  }
206
- next && checkKilled(next);
208
+ if (next)
209
+ checkKilled(next);
207
210
  checkTimeoutTimer =
208
211
  next &&
209
212
  setTimeout(function () {
package/lib/ps/index.mjs CHANGED
@@ -1,18 +1,16 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  require_table_parser
4
- } from "../chunk-3LOB2P54.mjs";
5
- import "../chunk-4LEXWIIF.mjs";
4
+ } from "../chunk-G3THLIDT.mjs";
5
+ import "../chunk-DPKAJKFO.mjs";
6
6
  import {
7
7
  require_isWin
8
- } from "../chunk-JL32QDSH.mjs";
9
- import {
10
- init_esm_shims
11
- } from "../chunk-VXZQNLPU.mjs";
8
+ } from "../chunk-W3ENOM53.mjs";
12
9
  import {
13
10
  __commonJS,
14
- __require
15
- } from "../chunk-FB6YIQYR.mjs";
11
+ __require,
12
+ init_esm_shims
13
+ } from "../chunk-AASHBCRW.mjs";
16
14
 
17
15
  // src/ps/index.js
18
16
  var require_ps = __commonJS({
@@ -149,7 +147,7 @@ var require_ps = __commonJS({
149
147
  if (checkIsTimeout) return;
150
148
  if (err) {
151
149
  clearTimeout(checkTimeoutTimer);
152
- finishCallback && finishCallback(err);
150
+ if (finishCallback) finishCallback(err);
153
151
  } else if (list.length > 0) {
154
152
  checkConfident = checkConfident - 1 || 0;
155
153
  checkKilled(finishCallback);
@@ -157,14 +155,14 @@ var require_ps = __commonJS({
157
155
  checkConfident++;
158
156
  if (checkConfident === 5) {
159
157
  clearTimeout(checkTimeoutTimer);
160
- finishCallback && finishCallback();
158
+ if (finishCallback) finishCallback();
161
159
  } else {
162
160
  checkKilled(finishCallback);
163
161
  }
164
162
  }
165
163
  });
166
164
  }
167
- next && checkKilled(next);
165
+ if (next) checkKilled(next);
168
166
  checkTimeoutTimer = next && setTimeout(function() {
169
167
  checkIsTimeout = true;
170
168
  next(new Error("Kill process timeout"));
package/lib/ps/isWin.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  require_isWin
4
- } from "../chunk-JL32QDSH.mjs";
5
- import "../chunk-VXZQNLPU.mjs";
6
- import "../chunk-FB6YIQYR.mjs";
4
+ } from "../chunk-W3ENOM53.mjs";
5
+ import "../chunk-AASHBCRW.mjs";
7
6
  export default require_isWin();
@@ -1,8 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  require_table_parser
4
- } from "../chunk-3LOB2P54.mjs";
5
- import "../chunk-4LEXWIIF.mjs";
6
- import "../chunk-VXZQNLPU.mjs";
7
- import "../chunk-FB6YIQYR.mjs";
4
+ } from "../chunk-G3THLIDT.mjs";
5
+ import "../chunk-DPKAJKFO.mjs";
6
+ import "../chunk-AASHBCRW.mjs";
8
7
  export default require_table_parser();
@@ -3,39 +3,21 @@
3
3
  const { spawnSync } = require("child_process");
4
4
  const fs = require("fs");
5
5
  const path = require("path");
6
- // Path to .env file
7
- const envPath = path.resolve(__dirname, ".env");
8
- // Check if .env exists and read it
9
- if (fs.existsSync(envPath)) {
10
- const envContent = fs.readFileSync(envPath, "utf8");
11
- // Split into lines and process each
12
- envContent.split("\n").forEach((line) => {
13
- const trimmedLine = line.trim();
14
- // Ignore empty lines and comments
15
- if (!trimmedLine || trimmedLine.startsWith("#"))
16
- return;
17
- // Extract key and value
18
- const [key, ...vals] = trimmedLine.split("=");
19
- if (!key)
20
- return;
21
- const value = vals
22
- .join("=")
23
- .trim()
24
- .replace(/^['"]|['"]$/g, ""); // Remove surrounding quotes
25
- process.env[key.trim()] = value;
26
- });
27
- }
28
- // Parse CLI args
29
- const args = process.argv.slice(2);
6
+ const dotenv = require("dotenv");
7
+ // Load .env using dotenv from process.cwd()
8
+ const envPath = path.resolve(process.cwd(), ".env");
9
+ if (fs.existsSync(envPath))
10
+ dotenv.config({ path: envPath });
11
+ const { getArgs } = require("./utils.js");
12
+ const args = getArgs();
13
+ const positional = args._ || [];
30
14
  let ROOT = runGit(["rev-parse", "--show-toplevel"]).trim();
31
15
  let REPO_PATH = ROOT;
32
- for (let i = 0; i < args.length; i++) {
33
- if (args[i] === "-cwd" && args[i + 1]) {
34
- ROOT = path.resolve(args[++i]);
35
- }
36
- else if (args[i].startsWith("--cwd=")) {
37
- ROOT = path.resolve(args[i].split("=")[1]);
38
- }
16
+ if (args.cwd) {
17
+ ROOT = path.resolve(args.cwd);
18
+ }
19
+ else if (positional.length > 0) {
20
+ ROOT = path.resolve(positional[0]);
39
21
  }
40
22
  console.log(`Installing submodules at ${ROOT}`);
41
23
  // Get submodule paths
@@ -1,45 +1,25 @@
1
1
  #!/usr/bin/env node
2
2
  const { spawnSync } = require("child_process");
3
+
3
4
  const fs = require("fs");
4
5
  const path = require("path");
6
+ const dotenv = require("dotenv");
5
7
 
6
- // Path to .env file
7
- const envPath = path.resolve(__dirname, ".env");
8
-
9
- // Check if .env exists and read it
10
- if (fs.existsSync(envPath)) {
11
- const envContent = fs.readFileSync(envPath, "utf8");
12
-
13
- // Split into lines and process each
14
- envContent.split("\n").forEach((line) => {
15
- const trimmedLine = line.trim();
16
-
17
- // Ignore empty lines and comments
18
- if (!trimmedLine || trimmedLine.startsWith("#")) return;
8
+ // Load .env using dotenv from process.cwd()
9
+ const envPath = path.resolve(process.cwd(), ".env");
10
+ if (fs.existsSync(envPath)) dotenv.config({ path: envPath });
19
11
 
20
- // Extract key and value
21
- const [key, ...vals] = trimmedLine.split("=");
22
- if (!key) return;
12
+ const { getArgs } = require("./utils.js");
13
+ const args = getArgs();
14
+ const positional = args._ || [];
23
15
 
24
- const value = vals
25
- .join("=")
26
- .trim()
27
- .replace(/^['"]|['"]$/g, ""); // Remove surrounding quotes
28
- process.env[key.trim()] = value;
29
- });
30
- }
31
-
32
- // Parse CLI args
33
- const args = process.argv.slice(2);
34
16
  let ROOT = runGit(["rev-parse", "--show-toplevel"]).trim();
35
17
  let REPO_PATH = ROOT;
36
18
 
37
- for (let i = 0; i < args.length; i++) {
38
- if (args[i] === "-cwd" && args[i + 1]) {
39
- ROOT = path.resolve(args[++i]);
40
- } else if (args[i].startsWith("--cwd=")) {
41
- ROOT = path.resolve(args[i].split("=")[1]);
42
- }
19
+ if (args.cwd) {
20
+ ROOT = path.resolve(args.cwd);
21
+ } else if (positional.length > 0) {
22
+ ROOT = path.resolve(positional[0]);
43
23
  }
44
24
 
45
25
  console.log(`Installing submodules at ${ROOT}`);
@@ -1,45 +1,25 @@
1
1
  #!/usr/bin/env node
2
2
  const { spawnSync } = require("child_process");
3
+
3
4
  const fs = require("fs");
4
5
  const path = require("path");
6
+ const dotenv = require("dotenv");
5
7
 
6
- // Path to .env file
7
- const envPath = path.resolve(__dirname, ".env");
8
-
9
- // Check if .env exists and read it
10
- if (fs.existsSync(envPath)) {
11
- const envContent = fs.readFileSync(envPath, "utf8");
12
-
13
- // Split into lines and process each
14
- envContent.split("\n").forEach((line) => {
15
- const trimmedLine = line.trim();
16
-
17
- // Ignore empty lines and comments
18
- if (!trimmedLine || trimmedLine.startsWith("#")) return;
8
+ // Load .env using dotenv from process.cwd()
9
+ const envPath = path.resolve(process.cwd(), ".env");
10
+ if (fs.existsSync(envPath)) dotenv.config({ path: envPath });
19
11
 
20
- // Extract key and value
21
- const [key, ...vals] = trimmedLine.split("=");
22
- if (!key) return;
12
+ const { getArgs } = require("./utils.js");
13
+ const args = getArgs();
14
+ const positional = args._ || [];
23
15
 
24
- const value = vals
25
- .join("=")
26
- .trim()
27
- .replace(/^['"]|['"]$/g, ""); // Remove surrounding quotes
28
- process.env[key.trim()] = value;
29
- });
30
- }
31
-
32
- // Parse CLI args
33
- const args = process.argv.slice(2);
34
16
  let ROOT = runGit(["rev-parse", "--show-toplevel"]).trim();
35
17
  let REPO_PATH = ROOT;
36
18
 
37
- for (let i = 0; i < args.length; i++) {
38
- if (args[i] === "-cwd" && args[i + 1]) {
39
- ROOT = path.resolve(args[++i]);
40
- } else if (args[i].startsWith("--cwd=")) {
41
- ROOT = path.resolve(args[i].split("=")[1]);
42
- }
19
+ if (args.cwd) {
20
+ ROOT = path.resolve(args.cwd);
21
+ } else if (positional.length > 0) {
22
+ ROOT = path.resolve(positional[0]);
43
23
  }
44
24
 
45
25
  console.log(`Installing submodules at ${ROOT}`);
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
3
3
  import {
4
- __dirname,
5
- __filename,
6
- init_esm_shims
7
- } from "./chunk-VXZQNLPU.mjs";
4
+ require_utils
5
+ } from "./chunk-APBWENF6.mjs";
8
6
  import {
9
7
  __commonJS,
10
- __require
11
- } from "./chunk-FB6YIQYR.mjs";
8
+ __filename,
9
+ __require,
10
+ init_esm_shims
11
+ } from "./chunk-AASHBCRW.mjs";
12
12
 
13
13
  // src/submodule-install.cjs
14
14
  var require_submodule_install = __commonJS({
@@ -17,27 +17,18 @@ var require_submodule_install = __commonJS({
17
17
  var { spawnSync } = __require("child_process");
18
18
  var fs = __require("fs");
19
19
  var path = __require("path");
20
- var envPath = path.resolve(__dirname, ".env");
21
- if (fs.existsSync(envPath)) {
22
- const envContent = fs.readFileSync(envPath, "utf8");
23
- envContent.split("\n").forEach((line) => {
24
- const trimmedLine = line.trim();
25
- if (!trimmedLine || trimmedLine.startsWith("#")) return;
26
- const [key, ...vals] = trimmedLine.split("=");
27
- if (!key) return;
28
- const value = vals.join("=").trim().replace(/^['"]|['"]$/g, "");
29
- process.env[key.trim()] = value;
30
- });
31
- }
32
- var args = process.argv.slice(2);
20
+ var dotenv = __require("dotenv");
21
+ var envPath = path.resolve(process.cwd(), ".env");
22
+ if (fs.existsSync(envPath)) dotenv.config({ path: envPath });
23
+ var { getArgs } = require_utils();
24
+ var args = getArgs();
25
+ var positional = args._ || [];
33
26
  var ROOT = runGit(["rev-parse", "--show-toplevel"]).trim();
34
27
  var REPO_PATH = ROOT;
35
- for (let i = 0; i < args.length; i++) {
36
- if (args[i] === "-cwd" && args[i + 1]) {
37
- ROOT = path.resolve(args[++i]);
38
- } else if (args[i].startsWith("--cwd=")) {
39
- ROOT = path.resolve(args[i].split("=")[1]);
40
- }
28
+ if (args.cwd) {
29
+ ROOT = path.resolve(args.cwd);
30
+ } else if (positional.length > 0) {
31
+ ROOT = path.resolve(positional[0]);
41
32
  }
42
33
  console.log(`Installing submodules at ${ROOT}`);
43
34
  var submoduleList = runGit([
package/lib/utils.cjs CHANGED
@@ -1,9 +1,54 @@
1
1
  // src/utils.js
2
- var { fs, path } = require("sbg-utility");
2
+ var fs = require("fs");
3
+ var path = require("upath");
3
4
  var argv = require("minimist")(process.argv.slice(2));
5
+ var { exec } = require("child_process");
6
+ var { URL } = require("url");
7
+ var { promisify } = require("util");
8
+ var execAsync = promisify(exec);
9
+ async function parseGitRemotes() {
10
+ try {
11
+ const { stdout } = await execAsync("git remote -v");
12
+ const lines = stdout.split("\n");
13
+ const remotes = {};
14
+ lines.forEach((line) => {
15
+ const [name, url] = line.split(" ");
16
+ if (name && url) {
17
+ const [repoUrl] = url.split(" ");
18
+ try {
19
+ const parsedUrl = new URL(repoUrl);
20
+ const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
21
+ if (parsedUrl.hostname === "github.com" && pathParts.length === 2) {
22
+ let repoPath = pathParts.join("/");
23
+ if (repoPath.endsWith(".git")) {
24
+ repoPath = repoPath.slice(0, -4);
25
+ }
26
+ remotes[name] = repoPath;
27
+ }
28
+ } catch (e) {
29
+ console.error("URL Parsing Error:", e.message);
30
+ }
31
+ }
32
+ });
33
+ return remotes;
34
+ } catch (error) {
35
+ console.error("Error:", error.message);
36
+ return {};
37
+ }
38
+ }
39
+ module.exports.parseGitRemotes = parseGitRemotes;
40
+ function joinPathPreserveDriveLetter(...segments) {
41
+ let fullPath = require("path").join(...segments);
42
+ if (/^[a-z]:\\/.test(fullPath)) {
43
+ fullPath = fullPath.charAt(0).toUpperCase() + fullPath.slice(1);
44
+ }
45
+ return fullPath;
46
+ }
47
+ module.exports.joinPathPreserveDriveLetter = joinPathPreserveDriveLetter;
4
48
  function getArgs() {
5
49
  return argv;
6
50
  }
51
+ module.exports.getArgs = getArgs;
7
52
  function del(fullPath) {
8
53
  if (fs.statSync(fullPath).isDirectory()) {
9
54
  const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
@@ -19,6 +64,7 @@ function del(fullPath) {
19
64
  }
20
65
  }
21
66
  }
67
+ module.exports.del = del;
22
68
  function delStream(globStream) {
23
69
  globStream.stream().on("data", (result) => {
24
70
  const fullPath = path.resolve(process.cwd(), result);
@@ -31,5 +77,43 @@ function delStream(globStream) {
31
77
  del(fullPath);
32
78
  });
33
79
  }
80
+ module.exports.delStream = delStream;
81
+ function getFileTreeString(hashArray) {
82
+ const tree = {};
83
+ const hashMap = {};
84
+ for (const entry of hashArray) {
85
+ const [filePath, hash] = entry.split(" ");
86
+ hashMap[filePath] = hash;
87
+ const parts = filePath.split("/");
88
+ let current = tree;
89
+ for (let i = 0; i < parts.length; i++) {
90
+ const part = parts[i];
91
+ if (i === parts.length - 1) {
92
+ current[part] = null;
93
+ } else {
94
+ current[part] = current[part] || {};
95
+ current = current[part];
96
+ }
97
+ }
98
+ }
99
+ function printNode(node, prefix = "", parentPath = "") {
100
+ const keys = Object.keys(node).sort();
101
+ let lines = [];
102
+ keys.forEach((key, idx) => {
103
+ const isLast = idx === keys.length - 1;
104
+ const branch = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
105
+ const currentPath = parentPath ? parentPath + "/" + key : key;
106
+ if (node[key] === null) {
107
+ lines.push(prefix + branch + key + " [" + (hashMap[currentPath] || "") + "]");
108
+ } else {
109
+ lines.push(prefix + branch + key + "/");
110
+ lines = lines.concat(printNode(node[key], prefix + (isLast ? " " : "\u2502 "), currentPath));
111
+ }
112
+ });
113
+ return lines;
114
+ }
115
+ return printNode(tree, "", "").join("\n");
116
+ }
117
+ module.exports.getFileTreeString = getFileTreeString;
34
118
  var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
35
- module.exports = { del, delStream, getArgs, delay };
119
+ module.exports.delay = delay;
package/lib/utils.d.mts CHANGED
@@ -1,20 +1,40 @@
1
1
  import * as minimist from 'minimist';
2
2
 
3
+ declare function parseGitRemotes(): Promise<{}>;
3
4
  /**
4
- * delete file recursive
5
- * @param {string} fullPath
5
+ * Joins all given path segments together and normalizes the resulting path.
6
+ * Preserves the case of the drive letter on Windows.
7
+ *
8
+ * @param {...string} segments Path segments to join.
9
+ * @returns {string} Normalized path with drive letter case preserved.
10
+ */
11
+ declare function joinPathPreserveDriveLetter(...segments: string[]): string;
12
+ /**
13
+ * Returns parsed command line arguments using minimist.
14
+ * @returns {import('minimist').ParsedArgs} Parsed command line arguments
15
+ */
16
+ declare function getArgs(): minimist.ParsedArgs;
17
+ /**
18
+ * Recursively deletes a file or directory at the given path.
19
+ * @param {string} fullPath Absolute path to the file or directory to delete.
6
20
  */
7
21
  declare function del(fullPath: string): void;
8
22
  /**
9
- * glob stream handler
10
- * @param {glob.Glob} globStream
23
+ * Handles a glob stream to delete matched files and directories recursively.
24
+ * @param {glob.Glob} globStream Glob stream object.
11
25
  */
12
26
  declare function delStream(globStream: glob.Glob): void;
13
- declare function getArgs(): minimist.ParsedArgs;
14
27
  /**
15
- * async delayed
16
- * @param {number} ms
28
+ * Creates a directory/file tree string from an array of file paths and hashes.
29
+ * @param {string[]} hashArray Array of strings in the format 'relative/path/to/file hash'.
30
+ * @returns {string} Directory/file tree as a string, with file hashes.
31
+ */
32
+ declare function getFileTreeString(hashArray: string[]): string;
33
+ /**
34
+ * Creates an async delay for the specified number of milliseconds.
35
+ * @param {number} ms Number of milliseconds to delay.
36
+ * @returns {Promise<void>} Promise that resolves after the specified delay.
17
37
  */
18
- declare function delay(ms: number): Promise<any>;
38
+ declare function delay(ms: number): Promise<void>;
19
39
 
20
- export { del, delStream, delay, getArgs };
40
+ export { del, delStream, delay, getArgs, getFileTreeString, joinPathPreserveDriveLetter, parseGitRemotes };
package/lib/utils.d.ts CHANGED
@@ -1,16 +1,36 @@
1
+ export function parseGitRemotes(): Promise<{}>;
1
2
  /**
2
- * delete file recursive
3
- * @param {string} fullPath
3
+ * Joins all given path segments together and normalizes the resulting path.
4
+ * Preserves the case of the drive letter on Windows.
5
+ *
6
+ * @param {...string} segments Path segments to join.
7
+ * @returns {string} Normalized path with drive letter case preserved.
8
+ */
9
+ export function joinPathPreserveDriveLetter(...segments: string[]): string;
10
+ /**
11
+ * Returns parsed command line arguments using minimist.
12
+ * @returns {import('minimist').ParsedArgs} Parsed command line arguments
13
+ */
14
+ export function getArgs(): import("minimist").ParsedArgs;
15
+ /**
16
+ * Recursively deletes a file or directory at the given path.
17
+ * @param {string} fullPath Absolute path to the file or directory to delete.
4
18
  */
5
19
  export function del(fullPath: string): void;
6
20
  /**
7
- * glob stream handler
8
- * @param {glob.Glob} globStream
21
+ * Handles a glob stream to delete matched files and directories recursively.
22
+ * @param {glob.Glob} globStream Glob stream object.
9
23
  */
10
24
  export function delStream(globStream: glob.Glob): void;
11
- export function getArgs(): import("minimist").ParsedArgs;
12
25
  /**
13
- * async delayed
14
- * @param {number} ms
26
+ * Creates a directory/file tree string from an array of file paths and hashes.
27
+ * @param {string[]} hashArray Array of strings in the format 'relative/path/to/file hash'.
28
+ * @returns {string} Directory/file tree as a string, with file hashes.
29
+ */
30
+ export function getFileTreeString(hashArray: string[]): string;
31
+ /**
32
+ * Creates an async delay for the specified number of milliseconds.
33
+ * @param {number} ms Number of milliseconds to delay.
34
+ * @returns {Promise<void>} Promise that resolves after the specified delay.
15
35
  */
16
- export function delay(ms: number): Promise<any>;
36
+ export function delay(ms: number): Promise<void>;