binary-collections 2.0.8 → 2.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/binaries/binary-executor.cjs +43 -0
  2. package/{bin → binaries}/clean-nodemodule +0 -0
  3. package/binaries/clean-nodemodule.cjs +43 -0
  4. package/binaries/clean-nodemodule.cmd +4 -0
  5. package/{bin → binaries}/clean-nodemodules +0 -0
  6. package/binaries/clean-nodemodules.cjs +43 -0
  7. package/binaries/clean-nodemodules.cmd +5 -0
  8. package/{bin → binaries}/dev +0 -0
  9. package/binaries/dev.cjs +43 -0
  10. package/{bin → binaries}/empty +0 -0
  11. package/binaries/empty.cjs +43 -0
  12. package/{bin → binaries}/git-reduce-size +0 -0
  13. package/binaries/git-reduce-size.cjs +43 -0
  14. package/binaries/javakill.cjs +43 -0
  15. package/{bin → binaries}/javakill.cmd +0 -0
  16. package/{bin → binaries}/kill-process +0 -0
  17. package/binaries/kill-process.cjs +43 -0
  18. package/binaries/nodekill.cjs +43 -0
  19. package/{bin → binaries}/nodekill.ps1 +0 -0
  20. package/{bin → binaries}/prod +0 -0
  21. package/binaries/prod.cjs +43 -0
  22. package/{bin → binaries}/rmfind +0 -0
  23. package/binaries/rmfind.cjs +43 -0
  24. package/{bin → binaries}/rmx +0 -0
  25. package/binaries/rmx.cjs +43 -0
  26. package/{bin → binaries}/submodule-token +0 -0
  27. package/binaries/submodule-token.cjs +43 -0
  28. package/docs-src/clean-github-actions-caches.md +26 -0
  29. package/docs-src/free-chatgpt.md +26 -0
  30. package/lib/binary-collections-config.cjs +3 -2
  31. package/lib/binary-collections-config.mjs +2 -2
  32. package/lib/binary-collections.cjs +452 -87
  33. package/lib/binary-collections.mjs +247 -8
  34. package/lib/changelog.cjs +328 -0
  35. package/lib/changelog.mjs +205 -0
  36. package/lib/chunk-4EWQC6GZ.mjs +382 -0
  37. package/lib/chunk-4ZI7BQKQ.mjs +381 -0
  38. package/lib/chunk-5J2BEPY5.mjs +83 -0
  39. package/lib/{chunk-4BYBVEYC.mjs → chunk-66PAU5PS.mjs} +5 -4
  40. package/lib/chunk-6HHJRKFB.mjs +59 -0
  41. package/lib/chunk-6S4NXESK.mjs +26 -0
  42. package/lib/{chunk-ZYAQRPUL.mjs → chunk-7YD7IPFF.mjs} +2 -2
  43. package/lib/{chunk-SH3L6HHV.mjs → chunk-A2JQXI5Z.mjs} +2 -2
  44. package/lib/{chunk-EGSSKVDH.mjs → chunk-A3VUZEJK.mjs} +1 -1
  45. package/lib/chunk-AGZYRDC2.mjs +323 -0
  46. package/lib/{chunk-VVEZVNIV.mjs → chunk-AI4CVPJ7.mjs} +6 -6
  47. package/lib/chunk-BDCHCWHD.mjs +136 -0
  48. package/lib/chunk-BEZKJ25G.mjs +140 -0
  49. package/lib/chunk-DI5MDPSN.mjs +386 -0
  50. package/lib/{chunk-ONIBBBQ3.mjs → chunk-E6FDDAOO.mjs} +4 -3
  51. package/lib/chunk-FKI7IEB5.mjs +172 -0
  52. package/lib/chunk-GJTGHXRA.mjs +356 -0
  53. package/lib/{chunk-YV7DO3YV.mjs → chunk-HLGOWBEO.mjs} +1 -1
  54. package/lib/chunk-HMRMTYZM.mjs +40 -0
  55. package/lib/chunk-HN52G2YL.mjs +305 -0
  56. package/lib/chunk-HO6GHCOB.mjs +385 -0
  57. package/lib/chunk-LEM5OMRP.mjs +384 -0
  58. package/lib/{chunk-YX5U7XDR.mjs → chunk-M3YIYRHT.mjs} +6 -5
  59. package/lib/chunk-O6SWBEOQ.mjs +81 -0
  60. package/lib/{chunk-JGR2NW6D.mjs → chunk-PDSXF5HY.mjs} +3 -3
  61. package/lib/{chunk-AASHBCRW.mjs → chunk-QQ4A6DLD.mjs} +8 -0
  62. package/lib/chunk-RCP7DHVY.mjs +190 -0
  63. package/lib/chunk-SBNDSKG5.mjs +136 -0
  64. package/lib/chunk-U6SO4QEV.mjs +320 -0
  65. package/lib/{chunk-APBWENF6.mjs → chunk-V3N3JEUF.mjs} +3 -3
  66. package/lib/chunk-XD6BJK6Q.mjs +351 -0
  67. package/lib/chunk-XVBFFVCJ.mjs +209 -0
  68. package/lib/chunk-YXSFGA2D.mjs +383 -0
  69. package/lib/clean-github-actions-caches.cjs +243 -148
  70. package/lib/clean-github-actions-caches.mjs +4 -3
  71. package/lib/del-gradle.cjs +2 -2
  72. package/lib/del-gradle.js +1 -1
  73. package/lib/del-gradle.mjs +2 -2
  74. package/lib/del-node-modules.cjs +2 -2
  75. package/lib/del-node-modules.js +1 -1
  76. package/lib/del-node-modules.mjs +2 -2
  77. package/lib/del-ps.cjs +29 -8
  78. package/lib/del-ps.js +2 -2
  79. package/lib/del-ps.mjs +7 -5
  80. package/lib/del-yarn-caches.cjs +26 -5
  81. package/lib/del-yarn-caches.js +38 -3
  82. package/lib/del-yarn-caches.mjs +6 -6
  83. package/lib/find-node-modules-cli.cjs +5 -4
  84. package/lib/find-node-modules-cli.js +1 -1
  85. package/lib/find-node-modules-cli.mjs +2 -2
  86. package/lib/find-node-modules.cjs +4 -3
  87. package/lib/{find-node-modules.d.ts → find-node-modules.d.cts} +1 -1
  88. package/lib/find-node-modules.mjs +2 -2
  89. package/lib/free-chatgpt.cjs +548 -0
  90. package/lib/free-chatgpt.d.ts +1 -0
  91. package/lib/free-chatgpt.js +51 -0
  92. package/lib/free-chatgpt.mjs +50 -0
  93. package/lib/git/gitattributes.cjs +1 -1
  94. package/lib/git/{gitattributes.d.mts → gitattributes.d.cts} +5 -7
  95. package/lib/git/gitattributes.mjs +2 -2
  96. package/lib/git/line-endings.cjs +297 -64
  97. package/lib/git/line-endings.mjs +4 -4
  98. package/lib/git/normalize.cjs +26 -36
  99. package/lib/git/normalize.mjs +2 -2
  100. package/lib/git/permissions.cjs +77 -11
  101. package/lib/git/permissions.mjs +3 -3
  102. package/lib/git/pull-strategy.cjs +76 -9
  103. package/lib/git/pull-strategy.mjs +3 -3
  104. package/lib/git/user-config.cjs +266 -83
  105. package/lib/git/user-config.mjs +4 -4
  106. package/lib/git/utils.cjs +40 -60
  107. package/lib/git/utils.mjs +2 -2
  108. package/lib/git-diff-cli.cjs +651 -0
  109. package/lib/git-diff-cli.d.ts +1 -0
  110. package/lib/git-diff-cli.js +15 -0
  111. package/lib/git-diff-cli.mjs +16 -0
  112. package/lib/git-diff.cjs +657 -58
  113. package/lib/git-diff.d.ts +38 -83
  114. package/lib/git-diff.js +152 -0
  115. package/lib/git-diff.mjs +23 -85
  116. package/lib/git-fix.cjs +685 -97
  117. package/lib/git-fix.mjs +12 -11
  118. package/lib/git-purge.cjs +3 -3
  119. package/lib/git-purge.d.cts +1 -0
  120. package/lib/git-purge.mjs +43 -37
  121. package/lib/index.cjs +7 -6
  122. package/lib/index.d.ts +1 -1
  123. package/lib/index.js +2 -5
  124. package/lib/index.mjs +4 -4
  125. package/lib/npm-run-series.cjs +3 -3
  126. package/lib/npm-run-series.mjs +42 -36
  127. package/lib/package-resolutions-updater.cjs +174 -1
  128. package/lib/package-resolutions-updater.mjs +270 -290
  129. package/lib/print-directory-tree.cjs +275 -210
  130. package/lib/print-directory-tree.mjs +2 -2
  131. package/lib/ps/connected-domain.cjs +25 -2
  132. package/lib/ps/connected-domain.d.ts +10 -2
  133. package/lib/ps/connected-domain.js +5 -2
  134. package/lib/ps/connected-domain.mjs +8 -4
  135. package/lib/ps/index.cjs +345 -322
  136. package/lib/ps/index.d.mjs +1 -1
  137. package/lib/ps/index.js +1 -1
  138. package/lib/ps/index.mjs +179 -182
  139. package/lib/ps/isWin.cjs +24 -1
  140. package/lib/ps/isWin.d.ts +1 -1
  141. package/lib/ps/isWin.js +3 -1
  142. package/lib/ps/isWin.mjs +8 -4
  143. package/lib/ps/table-parser.cjs +167 -159
  144. package/lib/ps/table-parser.d.ts +5 -0
  145. package/lib/ps/table-parser.js +10 -4
  146. package/lib/ps/table-parser.mjs +9 -5
  147. package/lib/remove-module.cjs +262 -0
  148. package/lib/remove-module.d.mts +1 -0
  149. package/lib/remove-module.mjs +111 -0
  150. package/lib/rmpath.cjs +274 -0
  151. package/lib/rmpath.d.mts +3 -0
  152. package/lib/rmpath.mjs +108 -0
  153. package/lib/submodule-install.cjs +264 -85
  154. package/lib/submodule-install.mjs +56 -7
  155. package/lib/submodule-remove-cli.cjs +103 -0
  156. package/lib/submodule-remove-cli.d.ts +1 -0
  157. package/lib/submodule-remove-cli.js +31 -0
  158. package/lib/submodule-remove-cli.mjs +28 -0
  159. package/lib/submodule-remove.cjs +43 -0
  160. package/lib/submodule-remove.d.cts +2 -0
  161. package/lib/submodule-remove.mjs +6 -0
  162. package/lib/utils/chatgpt.cjs +383 -0
  163. package/lib/utils/chatgpt.d.ts +31 -0
  164. package/lib/utils/chatgpt.js +541 -0
  165. package/lib/utils/chatgpt.mjs +8 -0
  166. package/lib/{utils.cjs → utils/index.cjs} +1 -1
  167. package/lib/{utils.mjs → utils/index.mjs} +2 -2
  168. package/lib/yarn-reinstall.cjs +172 -38
  169. package/lib/yarn-reinstall.mjs +2 -2
  170. package/package.json +91 -71
  171. package/readme.md +43 -69
  172. package/releases/readme.md +36 -0
  173. package/test/README.md +101 -0
  174. package/test/package.json +2 -1
  175. package/test-project/readme.md +26 -0
  176. package/tmp/test-repo/README.md +35 -0
  177. package/tmp/typedoc/readme.md +320 -0
  178. package/bin/bash-dummy +0 -56
  179. package/bin/bash-dummy.cmd +0 -25
  180. package/bin/dir-tree.cmd +0 -7
  181. package/bin/git-diff +0 -4
  182. package/bin/git-diff.cmd +0 -7
  183. package/bin/git-fix +0 -36
  184. package/bin/git-fix.cmd +0 -7
  185. package/bin/rmpath +0 -70
  186. package/bin/submodule-install.txt +0 -118
  187. package/bin/submodule-remove +0 -46
  188. package/bin/submodule.txt +0 -172
  189. package/lib/binary-collections-config.d.mts +0 -18
  190. package/lib/binary-collections-config.js +0 -39
  191. package/lib/binary-collections.d.mts +0 -121
  192. package/lib/binary-collections.d.ts +0 -121
  193. package/lib/chunk-DPKAJKFO.mjs +0 -171
  194. package/lib/chunk-G3THLIDT.mjs +0 -200
  195. package/lib/chunk-W3ENOM53.mjs +0 -18
  196. package/lib/clean-github-actions-caches.d.mts +0 -169
  197. package/lib/clean-github-actions-caches.d.ts +0 -169
  198. package/lib/del-gradle.d.mts +0 -2
  199. package/lib/del-node-modules.d.mts +0 -2
  200. package/lib/del-ps.d.mts +0 -2
  201. package/lib/del-yarn-caches.d.mts +0 -2
  202. package/lib/find-node-modules-cli.d.mts +0 -1
  203. package/lib/find-node-modules.d.mts +0 -13
  204. package/lib/find-node-modules.js +0 -53
  205. package/lib/git/line-endings.d.mts +0 -83
  206. package/lib/git/line-endings.d.ts +0 -83
  207. package/lib/git/normalize.d.mts +0 -43
  208. package/lib/git/normalize.d.ts +0 -43
  209. package/lib/git/permissions.d.mts +0 -17
  210. package/lib/git/permissions.d.ts +0 -17
  211. package/lib/git/pull-strategy.d.mts +0 -15
  212. package/lib/git/pull-strategy.d.ts +0 -15
  213. package/lib/git/user-config.d.mts +0 -105
  214. package/lib/git/user-config.d.ts +0 -105
  215. package/lib/git/utils.d.mts +0 -69
  216. package/lib/git/utils.d.ts +0 -69
  217. package/lib/git-diff.d.mts +0 -84
  218. package/lib/git-fix.d.mts +0 -141
  219. package/lib/git-fix.d.ts +0 -141
  220. package/lib/git-purge.d.mts +0 -2
  221. package/lib/git-purge.js +0 -59
  222. package/lib/index.d.mts +0 -1
  223. package/lib/npm-run-series.d.mts +0 -1
  224. package/lib/npm-run-series.d.ts +0 -2
  225. package/lib/npm-run-series.js +0 -86
  226. package/lib/package-resolutions-updater.d.ts +0 -326
  227. package/lib/print-directory-tree.d.mts +0 -234
  228. package/lib/print-directory-tree.d.ts +0 -234
  229. package/lib/ps/connected-domain.d.mts +0 -3
  230. package/lib/ps/index.d.d.mts +0 -26
  231. package/lib/ps/index.d.d.ts +0 -26
  232. package/lib/ps/index.d.mts +0 -26
  233. package/lib/ps/isWin.d.mts +0 -3
  234. package/lib/ps/table-parser.d.mts +0 -3
  235. package/lib/submodule-install.d.mts +0 -121
  236. package/lib/submodule-install.d.ts +0 -121
  237. package/lib/utils.d.mts +0 -40
  238. package/lib/utils.js +0 -181
  239. package/lib/yarn-reinstall.d.mts +0 -49
  240. package/lib/yarn-reinstall.d.ts +0 -49
  241. package/src/package-resolutions-updater.mjs +0 -325
  242. package/src/print-directory-tree.cjs +0 -234
  243. package/src/ps/index.js +0 -286
  244. package/src/yarn-reinstall.cjs +0 -49
  245. /package/{bin → binaries}/nodekill +0 -0
  246. /package/{bin → binaries}/nodekill.cmd +0 -0
  247. /package/lib/{binary-collections-config.d.ts → binary-collections-config.d.cts} +0 -0
  248. /package/lib/{git-purge.d.ts → changelog.d.cts} +0 -0
  249. /package/lib/{git-diff.d.cts → npm-run-series.d.cts} +0 -0
  250. /package/lib/{utils.d.ts → utils/index.d.cts} +0 -0
package/lib/rmpath.mjs ADDED
@@ -0,0 +1,108 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ require_utils
4
+ } from "./chunk-V3N3JEUF.mjs";
5
+ import {
6
+ __require,
7
+ __toESM,
8
+ init_esm_shims
9
+ } from "./chunk-QQ4A6DLD.mjs";
10
+
11
+ // src/rmpath.mjs
12
+ init_esm_shims();
13
+ var import_utils = __toESM(require_utils(), 1);
14
+ import dotenv from "dotenv";
15
+ import fs from "fs-extra";
16
+ import * as glob from "glob";
17
+ import path from "upath";
18
+ import { fileURLToPath, pathToFileURL } from "url";
19
+ var __filename = fileURLToPath(import.meta.url);
20
+ var __dirname = path.dirname(__filename);
21
+ var dotenvPath = path.resolve(process.cwd(), ".env");
22
+ if (fs.existsSync(dotenvPath)) {
23
+ dotenv.config({ path: dotenvPath });
24
+ }
25
+ var argv = (0, import_utils.getArgs)();
26
+ var positional = argv._ || [];
27
+ var deletePatterns = [];
28
+ function resolveDeletePatterns(targetPath) {
29
+ if (fs.existsSync(targetPath) && fs.lstatSync(targetPath).isFile()) {
30
+ deletePatterns.push(targetPath);
31
+ return;
32
+ }
33
+ const vowels = ["a", "i", "u", "e", "o", "A", "I", "U", "E", "O"];
34
+ const letters = [];
35
+ for (let i = 97; i <= 122; i++) letters.push(String.fromCharCode(i));
36
+ for (let i = 65; i <= 90; i++) letters.push(String.fromCharCode(i));
37
+ for (const letter of letters) {
38
+ for (const vowel of vowels) {
39
+ deletePatterns.push(
40
+ `.${letter}*`,
41
+ `@${letter}*`,
42
+ `${letter}*`,
43
+ `@${letter}${vowel}*`,
44
+ `.${letter}${vowel}*`,
45
+ `${letter}${vowel}*`
46
+ );
47
+ }
48
+ }
49
+ }
50
+ async function deleteMatchingFiles(baseDir) {
51
+ for (const pattern of deletePatterns) {
52
+ if (fs.existsSync(pattern)) {
53
+ fs.rmSync(pattern, { recursive: true, force: true });
54
+ continue;
55
+ }
56
+ const matches = glob.sync(path.join(baseDir, pattern), { dot: true, nocase: true });
57
+ for (const fpath of matches) {
58
+ try {
59
+ console.log(`deleting ${fpath}`);
60
+ fs.rmSync(fpath, { recursive: true, force: true });
61
+ } catch (_e) {
62
+ console.error(`cannot delete ${fpath}`);
63
+ }
64
+ }
65
+ }
66
+ }
67
+ async function deleteMainScript(targetPath) {
68
+ if (!fs.existsSync(targetPath)) {
69
+ targetPath = path.resolve(process.cwd(), targetPath);
70
+ }
71
+ resolveDeletePatterns(targetPath);
72
+ await deleteMatchingFiles(targetPath);
73
+ console.log(`cleaning ${targetPath}`);
74
+ try {
75
+ fs.rmSync(targetPath, { recursive: true, force: true });
76
+ } catch (_e) {
77
+ }
78
+ }
79
+ var isMain = false;
80
+ try {
81
+ if (typeof __require !== "undefined" && typeof module !== "undefined" && __require.main === module) {
82
+ isMain = true;
83
+ }
84
+ } catch (_e) {
85
+ }
86
+ try {
87
+ const mainArg = process.argv[1] && path.resolve(process.argv[1]);
88
+ if (mainArg && import.meta.url === pathToFileURL(mainArg).href) {
89
+ isMain = true;
90
+ }
91
+ } catch (_e) {
92
+ }
93
+ if (isMain) {
94
+ console.log("Invoked from CLI");
95
+ if (positional.length === 0) {
96
+ console.error("You need to provide a file or folder path");
97
+ process.exit(1);
98
+ } else {
99
+ deleteMainScript(positional[0]);
100
+ }
101
+ } else {
102
+ console.log("Not invoked from CLI");
103
+ }
104
+ export {
105
+ deleteMainScript,
106
+ deleteMatchingFiles,
107
+ resolveDeletePatterns
108
+ };
@@ -1,100 +1,279 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- const { spawnSync } = require("child_process");
4
- const fs = require("fs");
5
- const path = require("path");
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._ || [];
14
- let ROOT = runGit(["rev-parse", "--show-toplevel"]).trim();
15
- let REPO_PATH = ROOT;
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/utils/index.cjs
17
+ var require_utils = __commonJS({
18
+ "src/utils/index.cjs"(exports2, module2) {
19
+ init_cjs_shims();
20
+ var fs2 = require("fs");
21
+ var path2 = require("upath");
22
+ var argv = require("minimist")(process.argv.slice(2));
23
+ var { exec } = require("child_process");
24
+ var { URL: URL2 } = require("url");
25
+ var { promisify } = require("util");
26
+ var execAsync = promisify(exec);
27
+ async function parseGitRemotes() {
28
+ try {
29
+ const { stdout } = await execAsync("git remote -v");
30
+ const lines = stdout.split("\n");
31
+ const remotes = {};
32
+ lines.forEach((line) => {
33
+ const [name, url] = line.split(" ");
34
+ if (name && url) {
35
+ const [repoUrl] = url.split(" ");
36
+ try {
37
+ const parsedUrl = new URL2(repoUrl);
38
+ const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
39
+ if (parsedUrl.hostname === "github.com" && pathParts.length === 2) {
40
+ let repoPath = pathParts.join("/");
41
+ if (repoPath.endsWith(".git")) {
42
+ repoPath = repoPath.slice(0, -4);
43
+ }
44
+ remotes[name] = repoPath;
45
+ }
46
+ } catch (e) {
47
+ console.error("URL Parsing Error:", e.message);
48
+ }
49
+ }
50
+ });
51
+ return remotes;
52
+ } catch (error) {
53
+ console.error("Error:", error.message);
54
+ return {};
55
+ }
56
+ }
57
+ module2.exports.parseGitRemotes = parseGitRemotes;
58
+ function joinPathPreserveDriveLetter(...segments) {
59
+ let fullPath = require("path").join(...segments);
60
+ if (/^[a-z]:\\/.test(fullPath)) {
61
+ fullPath = fullPath.charAt(0).toUpperCase() + fullPath.slice(1);
62
+ }
63
+ return fullPath;
64
+ }
65
+ module2.exports.joinPathPreserveDriveLetter = joinPathPreserveDriveLetter;
66
+ function getArgs2() {
67
+ return argv;
68
+ }
69
+ module2.exports.getArgs = getArgs2;
70
+ function del(fullPath) {
71
+ if (fs2.statSync(fullPath).isDirectory()) {
72
+ const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
73
+ for (let i = 0; i < subdir.length; i++) {
74
+ del(subdir[i]);
75
+ }
76
+ } else {
77
+ try {
78
+ fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
79
+ console.log("deleted", fullPath);
80
+ } catch (_) {
81
+ console.log("failed delete", fullPath);
82
+ }
83
+ }
84
+ }
85
+ module2.exports.del = del;
86
+ function delStream(globStream) {
87
+ globStream.stream().on("data", (result) => {
88
+ const fullPath = path2.resolve(process.cwd(), result);
89
+ if (fs2.statSync(fullPath).isDirectory()) {
90
+ const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
91
+ for (let i = 0; i < subdir.length; i++) {
92
+ del(subdir[i]);
93
+ }
94
+ }
95
+ del(fullPath);
96
+ });
97
+ }
98
+ module2.exports.delStream = delStream;
99
+ function getFileTreeString(hashArray) {
100
+ const tree = {};
101
+ const hashMap = {};
102
+ for (const entry of hashArray) {
103
+ const [filePath, hash] = entry.split(" ");
104
+ hashMap[filePath] = hash;
105
+ const parts = filePath.split("/");
106
+ let current = tree;
107
+ for (let i = 0; i < parts.length; i++) {
108
+ const part = parts[i];
109
+ if (i === parts.length - 1) {
110
+ current[part] = null;
111
+ } else {
112
+ current[part] = current[part] || {};
113
+ current = current[part];
114
+ }
115
+ }
116
+ }
117
+ function printNode(node, prefix = "", parentPath = "") {
118
+ const keys = Object.keys(node).sort();
119
+ let lines = [];
120
+ keys.forEach((key, idx) => {
121
+ const isLast = idx === keys.length - 1;
122
+ const branch = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
123
+ const currentPath = parentPath ? parentPath + "/" + key : key;
124
+ if (node[key] === null) {
125
+ lines.push(prefix + branch + key + " [" + (hashMap[currentPath] || "") + "]");
126
+ } else {
127
+ lines.push(prefix + branch + key + "/");
128
+ lines = lines.concat(printNode(node[key], prefix + (isLast ? " " : "\u2502 "), currentPath));
129
+ }
130
+ });
131
+ return lines;
132
+ }
133
+ return printNode(tree, "", "").join("\n");
134
+ }
135
+ module2.exports.getFileTreeString = getFileTreeString;
136
+ var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
137
+ module2.exports.delay = delay;
138
+ }
139
+ });
140
+
141
+ // src/submodule-install.cjs
142
+ init_cjs_shims();
143
+ var { spawnSync } = require("child_process");
144
+ var color = require("ansi-colors");
145
+ var fs = require("fs");
146
+ var path = require("path");
147
+ var dotenv = require("dotenv");
148
+ var envPath = path.resolve(process.cwd(), ".env");
149
+ if (fs.existsSync(envPath)) dotenv.config({ path: envPath });
150
+ var { getArgs } = require_utils();
151
+ var args = getArgs();
152
+ var positional = args._ || [];
153
+ if (args.help || args.h) {
154
+ console.log();
155
+ console.log("Usage: submodule-install [options] [repo-path]");
156
+ console.log();
157
+ console.log("Options:");
158
+ console.log(" --cwd <path> Set working directory");
159
+ console.log(" --help, -h Show this help message");
160
+ console.log();
161
+ console.log("Description:");
162
+ console.log(" Installs and updates git submodules recursively, applying access tokens for private repos.");
163
+ console.log();
164
+ process.exit(0);
165
+ }
166
+ var ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
167
+ var ROOT = runGit(["rev-parse", "--show-toplevel"]).trim();
168
+ var REPO_PATH = ROOT;
16
169
  if (args.cwd) {
17
- ROOT = path.resolve(args.cwd);
170
+ ROOT = path.resolve(args.cwd);
171
+ } else if (positional.length > 0) {
172
+ ROOT = path.resolve(positional[0]);
18
173
  }
19
- else if (positional.length > 0) {
20
- ROOT = path.resolve(positional[0]);
174
+ var CURRENT_PATH = ROOT;
175
+ var VISITED_SUBMODULES = (process.env.VISITED_SUBMODULES || "").split(path.delimiter).filter(Boolean);
176
+ if (VISITED_SUBMODULES.includes(CURRENT_PATH)) {
177
+ console.log(`Skipping ${CURRENT_PATH} (already processed) to avoid recursion.`);
178
+ process.exit(0);
21
179
  }
180
+ VISITED_SUBMODULES.push(CURRENT_PATH);
181
+ process.env.VISITED_SUBMODULES = VISITED_SUBMODULES.join(path.delimiter);
22
182
  console.log(`Installing submodules at ${ROOT}`);
23
- // Get submodule paths
24
- const submoduleList = runGit([
25
- "-C",
26
- REPO_PATH,
27
- "config",
28
- "-f",
29
- ".gitmodules",
30
- "--get-regexp",
31
- "^submodule\\..*\\.path$"
32
- ])
33
- .split("\n")
34
- .filter(Boolean);
183
+ var submoduleList = runGit([
184
+ "-C",
185
+ REPO_PATH,
186
+ "config",
187
+ "-f",
188
+ ".gitmodules",
189
+ "--get-regexp",
190
+ "^submodule\\..*\\.path$"
191
+ ]).split("\n").filter(Boolean);
35
192
  for (const line of submoduleList) {
36
- const [KEY, MODULE_PATH] = line.trim().split(/\s+/);
37
- const RELATIVE_MODULE_PATH = path.join(ROOT, MODULE_PATH);
38
- if (fs.existsSync(RELATIVE_MODULE_PATH)) {
39
- console.log(`Deleting ${RELATIVE_MODULE_PATH}`);
40
- fs.rmSync(RELATIVE_MODULE_PATH, { recursive: true, force: true });
41
- }
42
- const NAME = KEY.match(/^submodule\.(.*)\.path$/)[1];
43
- const URL = runGit(["config", "-f", ".gitmodules", "--get", `submodule.${NAME}.url`]).trim();
44
- let BRANCH = "master";
193
+ const [KEY, MODULE_PATH] = line.trim().split(/\s+/);
194
+ const RELATIVE_MODULE_PATH = path.join(ROOT, MODULE_PATH);
195
+ if (fs.existsSync(RELATIVE_MODULE_PATH)) {
196
+ console.log(`Deleting ${RELATIVE_MODULE_PATH}`);
197
+ fs.rmSync(RELATIVE_MODULE_PATH, { recursive: true, force: true });
198
+ }
199
+ const NAME = KEY.match(/^submodule\.(.*)\.path$/)[1];
200
+ const URL2 = runGit(["config", "-f", ".gitmodules", "--get", `submodule.${NAME}.url`]).trim();
201
+ let BRANCH = "master";
202
+ try {
203
+ BRANCH = runGit(["config", "-f", ".gitmodules", "--get", `submodule.${NAME}.branch`]).trim();
204
+ } catch {
205
+ }
206
+ console.log(`Submodule: ${color.cyan(NAME)}`);
207
+ console.log(` Location: ${color.magenta(MODULE_PATH)}`);
208
+ console.log(` ROOT: ${color.yellow(ROOT)}`);
209
+ console.log(` URL: ${color.blue(URL2)}`);
210
+ console.log(` Branch: ${color.green(BRANCH)}`);
211
+ const addResult = runGit(
212
+ ["-C", REPO_PATH, "submodule", "add", "--force", "-b", BRANCH, "--name", NAME, URL2, MODULE_PATH],
213
+ true
214
+ );
215
+ if (addResult.status !== 0) {
216
+ console.warn(`Cannot add submodule ${MODULE_PATH}`);
217
+ continue;
218
+ }
219
+ if (!fs.existsSync(RELATIVE_MODULE_PATH)) {
220
+ console.warn(`Submodule directory ${RELATIVE_MODULE_PATH} does not exist after add. Attempting manual clone...`);
45
221
  try {
46
- BRANCH = runGit(["config", "-f", ".gitmodules", "--get", `submodule.${NAME}.branch`]).trim();
222
+ runGit(["clone", "--branch", BRANCH, URL2, RELATIVE_MODULE_PATH]);
223
+ } catch (e) {
224
+ console.error(`Manual clone failed for ${RELATIVE_MODULE_PATH}: ${e.message}`);
225
+ continue;
47
226
  }
48
- catch (_a) {
49
- // silently ignore if branch is not set
227
+ if (!fs.existsSync(RELATIVE_MODULE_PATH)) {
228
+ console.error(`Submodule directory ${RELATIVE_MODULE_PATH} still does not exist after manual clone. Skipping.`);
229
+ continue;
50
230
  }
51
- const addResult = runGit(["-C", REPO_PATH, "submodule", "add", "--force", "-b", BRANCH, "--name", NAME, URL, MODULE_PATH], true);
52
- if (addResult.status !== 0) {
53
- console.warn(`Cannot add submodule ${MODULE_PATH}`);
54
- continue;
231
+ }
232
+ const GIT_MODULES = path.join(RELATIVE_MODULE_PATH, ".gitmodules");
233
+ if (ACCESS_TOKEN) {
234
+ let URL_WITH_TOKEN = "";
235
+ let repoInfo;
236
+ if (URL2.includes("github.com")) {
237
+ repoInfo = URL2.replace("https://github.com/", "");
238
+ URL_WITH_TOKEN = `https://${ACCESS_TOKEN}@github.com/${repoInfo}`;
239
+ } else if (URL2.includes("gitlab.com") && typeof process.env.GITLAB_TOKEN === "string") {
240
+ repoInfo = URL2.replace("https://gitlab.com/", "");
241
+ URL_WITH_TOKEN = `https://oauth2:${ACCESS_TOKEN}@gitlab.com/${repoInfo}`;
242
+ } else {
243
+ const urlObj = new URL2(URL2);
244
+ repoInfo = urlObj.pathname.substring(1);
245
+ URL_WITH_TOKEN = `${urlObj.protocol}//${ACCESS_TOKEN}@${urlObj.host}${urlObj.pathname}`;
55
246
  }
56
- const GIT_MODULES = path.join(RELATIVE_MODULE_PATH, ".gitmodules");
57
- if (process.env.ACCESS_TOKEN) {
58
- let URL_WITH_TOKEN = "";
59
- let repoInfo;
60
- if (URL.includes("github.com")) {
61
- repoInfo = URL.replace("https://github.com/", "");
62
- URL_WITH_TOKEN = `https://${process.env.ACCESS_TOKEN}@github.com/${repoInfo}`;
63
- }
64
- else if (URL.includes("gitlab.com") && typeof process.env.GITLAB_TOKEN === "string") {
65
- repoInfo = URL.replace("https://gitlab.com/", "");
66
- URL_WITH_TOKEN = `https://oauth2:${process.env.ACCESS_TOKEN}@gitlab.com/${repoInfo}`;
67
- }
68
- else {
69
- // For other Git providers, try a generic approach
70
- const urlObj = new URL(URL);
71
- repoInfo = urlObj.pathname.substring(1); // Remove leading slash
72
- URL_WITH_TOKEN = `${urlObj.protocol}//${process.env.ACCESS_TOKEN}@${urlObj.host}${urlObj.pathname}`;
73
- }
74
- if (URL_WITH_TOKEN && URL_WITH_TOKEN.length > 0) {
75
- console.log(`Apply token for ${repoInfo} at ${MODULE_PATH} branch ${BRANCH}`);
76
- runGit(["-C", RELATIVE_MODULE_PATH, "remote", "set-url", "origin", URL_WITH_TOKEN]);
77
- }
247
+ if (URL_WITH_TOKEN && URL_WITH_TOKEN.length > 0) {
248
+ console.log(`Apply token for ${repoInfo} at ${MODULE_PATH} branch ${BRANCH}`);
249
+ runGit(["-C", RELATIVE_MODULE_PATH, "remote", "set-url", "origin", URL_WITH_TOKEN]);
78
250
  }
79
- runGit(["-C", RELATIVE_MODULE_PATH, "fetch", "--all"]);
80
- runGit(["-C", RELATIVE_MODULE_PATH, "pull", "origin", BRANCH, "-X", "theirs"]);
81
- if (fs.existsSync(GIT_MODULES)) {
82
- console.log(`${MODULE_PATH} has submodules`);
83
- const result = spawnSync("node", [__filename, "-cwd", RELATIVE_MODULE_PATH], { stdio: "inherit" });
84
- if (result.status !== 0) {
85
- console.error(`Recursive submodule failed for ${RELATIVE_MODULE_PATH}`);
86
- process.exit(result.status);
87
- }
251
+ }
252
+ runGit(["-C", RELATIVE_MODULE_PATH, "fetch", "--all"]);
253
+ runGit(["-C", RELATIVE_MODULE_PATH, "pull", "origin", BRANCH, "-X", "theirs"]);
254
+ if (fs.existsSync(GIT_MODULES)) {
255
+ console.log(`${MODULE_PATH} has submodules`);
256
+ const env = Object.assign({}, process.env, {
257
+ VISITED_SUBMODULES: process.env.VISITED_SUBMODULES + path.delimiter + path.resolve(RELATIVE_MODULE_PATH)
258
+ });
259
+ const result = spawnSync("node", [__filename, "-cwd", RELATIVE_MODULE_PATH], {
260
+ stdio: "inherit",
261
+ env,
262
+ cwd: RELATIVE_MODULE_PATH
263
+ });
264
+ if (result.status !== 0) {
265
+ console.error(`Recursive submodule failed for ${RELATIVE_MODULE_PATH}`);
266
+ process.exit(result.status);
88
267
  }
268
+ }
89
269
  }
90
270
  runGit(["-C", REPO_PATH, "submodule", "update", "--init", "--recursive"]);
91
- // ----------- Helper Functions -----------
92
- function runGit(args, returnResult = false) {
93
- const result = spawnSync("git", args, { encoding: "utf-8" });
94
- if (returnResult)
95
- return result;
96
- if (result.status !== 0) {
97
- throw new Error(result.stderr || `git ${args.join(" ")} failed`);
98
- }
99
- return result.stdout || "";
271
+ function runGit(args2, returnResult = false) {
272
+ console.log(`Executing: git ${args2.join(" ")}`);
273
+ const result = spawnSync("git", args2, { encoding: "utf-8" });
274
+ if (returnResult) return result;
275
+ if (result.status !== 0) {
276
+ throw new Error(result.stderr || `git ${args2.join(" ")} failed`);
277
+ }
278
+ return result.stdout || "";
100
279
  }
@@ -2,19 +2,20 @@
2
2
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
3
3
  import {
4
4
  require_utils
5
- } from "./chunk-APBWENF6.mjs";
5
+ } from "./chunk-V3N3JEUF.mjs";
6
6
  import {
7
7
  __commonJS,
8
8
  __filename,
9
9
  __require,
10
10
  init_esm_shims
11
- } from "./chunk-AASHBCRW.mjs";
11
+ } from "./chunk-QQ4A6DLD.mjs";
12
12
 
13
13
  // src/submodule-install.cjs
14
14
  var require_submodule_install = __commonJS({
15
15
  "src/submodule-install.cjs"() {
16
16
  init_esm_shims();
17
17
  var { spawnSync } = __require("child_process");
18
+ var color = __require("ansi-colors");
18
19
  var fs = __require("fs");
19
20
  var path = __require("path");
20
21
  var dotenv = __require("dotenv");
@@ -23,6 +24,20 @@ var require_submodule_install = __commonJS({
23
24
  var { getArgs } = require_utils();
24
25
  var args = getArgs();
25
26
  var positional = args._ || [];
27
+ if (args.help || args.h) {
28
+ console.log();
29
+ console.log("Usage: submodule-install [options] [repo-path]");
30
+ console.log();
31
+ console.log("Options:");
32
+ console.log(" --cwd <path> Set working directory");
33
+ console.log(" --help, -h Show this help message");
34
+ console.log();
35
+ console.log("Description:");
36
+ console.log(" Installs and updates git submodules recursively, applying access tokens for private repos.");
37
+ console.log();
38
+ process.exit(0);
39
+ }
40
+ var ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
26
41
  var ROOT = runGit(["rev-parse", "--show-toplevel"]).trim();
27
42
  var REPO_PATH = ROOT;
28
43
  if (args.cwd) {
@@ -30,6 +45,14 @@ var require_submodule_install = __commonJS({
30
45
  } else if (positional.length > 0) {
31
46
  ROOT = path.resolve(positional[0]);
32
47
  }
48
+ var CURRENT_PATH = ROOT;
49
+ var VISITED_SUBMODULES = (process.env.VISITED_SUBMODULES || "").split(path.delimiter).filter(Boolean);
50
+ if (VISITED_SUBMODULES.includes(CURRENT_PATH)) {
51
+ console.log(`Skipping ${CURRENT_PATH} (already processed) to avoid recursion.`);
52
+ process.exit(0);
53
+ }
54
+ VISITED_SUBMODULES.push(CURRENT_PATH);
55
+ process.env.VISITED_SUBMODULES = VISITED_SUBMODULES.join(path.delimiter);
33
56
  console.log(`Installing submodules at ${ROOT}`);
34
57
  var submoduleList = runGit([
35
58
  "-C",
@@ -54,6 +77,11 @@ var require_submodule_install = __commonJS({
54
77
  BRANCH = runGit(["config", "-f", ".gitmodules", "--get", `submodule.${NAME}.branch`]).trim();
55
78
  } catch {
56
79
  }
80
+ console.log(`Submodule: ${color.cyan(NAME)}`);
81
+ console.log(` Location: ${color.magenta(MODULE_PATH)}`);
82
+ console.log(` ROOT: ${color.yellow(ROOT)}`);
83
+ console.log(` URL: ${color.blue(URL)}`);
84
+ console.log(` Branch: ${color.green(BRANCH)}`);
57
85
  const addResult = runGit(
58
86
  ["-C", REPO_PATH, "submodule", "add", "--force", "-b", BRANCH, "--name", NAME, URL, MODULE_PATH],
59
87
  true
@@ -62,20 +90,33 @@ var require_submodule_install = __commonJS({
62
90
  console.warn(`Cannot add submodule ${MODULE_PATH}`);
63
91
  continue;
64
92
  }
93
+ if (!fs.existsSync(RELATIVE_MODULE_PATH)) {
94
+ console.warn(`Submodule directory ${RELATIVE_MODULE_PATH} does not exist after add. Attempting manual clone...`);
95
+ try {
96
+ runGit(["clone", "--branch", BRANCH, URL, RELATIVE_MODULE_PATH]);
97
+ } catch (e) {
98
+ console.error(`Manual clone failed for ${RELATIVE_MODULE_PATH}: ${e.message}`);
99
+ continue;
100
+ }
101
+ if (!fs.existsSync(RELATIVE_MODULE_PATH)) {
102
+ console.error(`Submodule directory ${RELATIVE_MODULE_PATH} still does not exist after manual clone. Skipping.`);
103
+ continue;
104
+ }
105
+ }
65
106
  const GIT_MODULES = path.join(RELATIVE_MODULE_PATH, ".gitmodules");
66
- if (process.env.ACCESS_TOKEN) {
107
+ if (ACCESS_TOKEN) {
67
108
  let URL_WITH_TOKEN = "";
68
109
  let repoInfo;
69
110
  if (URL.includes("github.com")) {
70
111
  repoInfo = URL.replace("https://github.com/", "");
71
- URL_WITH_TOKEN = `https://${process.env.ACCESS_TOKEN}@github.com/${repoInfo}`;
112
+ URL_WITH_TOKEN = `https://${ACCESS_TOKEN}@github.com/${repoInfo}`;
72
113
  } else if (URL.includes("gitlab.com") && typeof process.env.GITLAB_TOKEN === "string") {
73
114
  repoInfo = URL.replace("https://gitlab.com/", "");
74
- URL_WITH_TOKEN = `https://oauth2:${process.env.ACCESS_TOKEN}@gitlab.com/${repoInfo}`;
115
+ URL_WITH_TOKEN = `https://oauth2:${ACCESS_TOKEN}@gitlab.com/${repoInfo}`;
75
116
  } else {
76
117
  const urlObj = new URL(URL);
77
118
  repoInfo = urlObj.pathname.substring(1);
78
- URL_WITH_TOKEN = `${urlObj.protocol}//${process.env.ACCESS_TOKEN}@${urlObj.host}${urlObj.pathname}`;
119
+ URL_WITH_TOKEN = `${urlObj.protocol}//${ACCESS_TOKEN}@${urlObj.host}${urlObj.pathname}`;
79
120
  }
80
121
  if (URL_WITH_TOKEN && URL_WITH_TOKEN.length > 0) {
81
122
  console.log(`Apply token for ${repoInfo} at ${MODULE_PATH} branch ${BRANCH}`);
@@ -86,7 +127,14 @@ var require_submodule_install = __commonJS({
86
127
  runGit(["-C", RELATIVE_MODULE_PATH, "pull", "origin", BRANCH, "-X", "theirs"]);
87
128
  if (fs.existsSync(GIT_MODULES)) {
88
129
  console.log(`${MODULE_PATH} has submodules`);
89
- const result = spawnSync("node", [__filename, "-cwd", RELATIVE_MODULE_PATH], { stdio: "inherit" });
130
+ const env = Object.assign({}, process.env, {
131
+ VISITED_SUBMODULES: process.env.VISITED_SUBMODULES + path.delimiter + path.resolve(RELATIVE_MODULE_PATH)
132
+ });
133
+ const result = spawnSync("node", [__filename, "-cwd", RELATIVE_MODULE_PATH], {
134
+ stdio: "inherit",
135
+ env,
136
+ cwd: RELATIVE_MODULE_PATH
137
+ });
90
138
  if (result.status !== 0) {
91
139
  console.error(`Recursive submodule failed for ${RELATIVE_MODULE_PATH}`);
92
140
  process.exit(result.status);
@@ -95,6 +143,7 @@ var require_submodule_install = __commonJS({
95
143
  }
96
144
  runGit(["-C", REPO_PATH, "submodule", "update", "--init", "--recursive"]);
97
145
  function runGit(args2, returnResult = false) {
146
+ console.log(`Executing: git ${args2.join(" ")}`);
98
147
  const result = spawnSync("git", args2, { encoding: "utf-8" });
99
148
  if (returnResult) return result;
100
149
  if (result.status !== 0) {