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
@@ -1,220 +1,286 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __esm = (fn, res) => function __init() {
3
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
4
  };
11
- const fs = require("fs").promises;
12
- const path = require("path");
13
- const crypto = require("crypto");
14
- const { execSync } = require("child_process");
15
- const glob = require("glob");
16
- const { getArgs } = require("./utils.js");
17
- const sbgUtil = require("sbg-utility");
18
- const dotenv = require("dotenv");
19
- const projectDir = process.cwd();
20
- const envPath = path.join(projectDir, ".env");
21
- // Load the .env file using dotenv (ESM import)
22
- if (fs.existsSync(envPath))
23
- dotenv.config({ path: envPath });
24
- // Parse CLI arguments
25
- const argv = getArgs();
26
- // Main logic wrapped in an async function
27
- function main() {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- // Determine output file from CLI args
30
- let relativeOutputFile = "tmp/directory-structure.txt";
31
- if (argv.output || argv.o) {
32
- relativeOutputFile = argv.output || argv.o;
33
- }
34
- // If not absolute, resolve relative to projectDir
35
- const outputFile = path.isAbsolute(relativeOutputFile)
36
- ? relativeOutputFile
37
- : path.join(projectDir, relativeOutputFile);
38
- // Create or clear the hash file
39
- sbgUtil.writefile(outputFile, "");
40
- /**
41
- * List of file extensions to include
42
- * @type {string[]}
43
- */
44
- let extensions = [];
45
- if (argv.ext) {
46
- extensions = argv.ext
47
- .split(",")
48
- .map((e) => e.trim().replace(/^\./, ""))
49
- .filter(Boolean);
50
- }
51
- // Directories to exclude
52
- let excludeDirs = [
53
- "node_modules",
54
- "vendor",
55
- "venv",
56
- ".venv",
57
- ".git",
58
- ".hg",
59
- ".svn",
60
- ".idea",
61
- ".vscode",
62
- "dist",
63
- "build",
64
- "out",
65
- "coverage",
66
- ".DS_Store"
67
- ];
68
- if (argv.exclude) {
69
- const userExcludes = argv.exclude
70
- .split(",")
71
- .map((d) => d.trim())
72
- .filter(Boolean);
73
- if (argv["override-exclude"] || argv.we) {
74
- // Override the default excludes with user-provided ones
75
- excludeDirs = userExcludes;
76
- }
77
- else {
78
- // Append user-provided excludes to the default ones
79
- excludeDirs = excludeDirs.concat(userExcludes);
80
- }
81
- }
82
- // Convert excludeDirs into glob ignore patterns
83
- const ignorePatterns = excludeDirs.map((dir) => `**/${dir}/**`);
84
- // Initialize an array to hold the formatted outputs
85
- let hashArray = [];
86
- // Helper function to hash and add file if not already processed
87
- const processedFiles = new Set();
88
- /**
89
- * Hashes a file and pushes its relative path and hash to the hashArray.
90
- * @param {string} file - The absolute path to the file.
91
- * @returns {Promise<void>} Resolves when the file has been processed and added to hashArray.
92
- */
93
- function hashAndPush(file) {
94
- return __awaiter(this, void 0, void 0, function* () {
95
- if (processedFiles.has(file))
96
- return;
97
- processedFiles.add(file);
98
- let relativePath = path.relative(projectDir, file);
99
- relativePath = relativePath.split(path.sep).join("/");
100
- try {
101
- const stats = yield fs.stat(file);
102
- const pseudoHash = `${stats.size}-${stats.mtimeMs}`;
103
- const hash = crypto.createHash("sha256").update(pseudoHash).digest("hex");
104
- hashArray.push(`${relativePath} ${hash.slice(0, 8)}`);
105
- }
106
- catch (err) {
107
- console.error(`Error processing file: ${file}`, err instanceof Error ? err.message : "<unknown error>");
108
- if (err && err.code === "ENOENT") {
109
- hashArray.push(`${relativePath} <file not found>`);
110
- }
111
- else {
112
- hashArray.push(`${relativePath} <error: ${err && err.code ? `code ${err.code}` : "unknown"}>`);
113
- }
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/index.cjs
16
+ var require_utils = __commonJS({
17
+ "src/utils/index.cjs"(exports2, module2) {
18
+ init_cjs_shims();
19
+ var fs2 = require("fs");
20
+ var path2 = require("upath");
21
+ var argv2 = require("minimist")(process.argv.slice(2));
22
+ var { exec } = require("child_process");
23
+ var { URL: URL2 } = require("url");
24
+ var { promisify } = require("util");
25
+ var execAsync = promisify(exec);
26
+ async function parseGitRemotes() {
27
+ try {
28
+ const { stdout } = await execAsync("git remote -v");
29
+ const lines = stdout.split("\n");
30
+ const remotes = {};
31
+ lines.forEach((line) => {
32
+ const [name, url] = line.split(" ");
33
+ if (name && url) {
34
+ const [repoUrl] = url.split(" ");
35
+ try {
36
+ const parsedUrl = new URL2(repoUrl);
37
+ const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
38
+ if (parsedUrl.hostname === "github.com" && pathParts.length === 2) {
39
+ let repoPath = pathParts.join("/");
40
+ if (repoPath.endsWith(".git")) {
41
+ repoPath = repoPath.slice(0, -4);
114
42
  }
115
- });
116
- }
117
- // Collect all files to process (extensions + special files)
118
- const initialFiles = [
119
- path.join(projectDir, "package.json"),
120
- path.join(projectDir, "composer.json"),
121
- path.join(projectDir, "requirements.txt")
122
- ];
123
- let patterns = [];
124
- if (argv.pattern) {
125
- if (Array.isArray(argv.pattern)) {
126
- patterns = argv.pattern.map((p) => p.trim()).filter(Boolean);
127
- }
128
- else {
129
- patterns = [argv.pattern.trim()];
43
+ remotes[name] = repoPath;
44
+ }
45
+ } catch (e) {
46
+ console.error("URL Parsing Error:", e.message);
130
47
  }
48
+ }
49
+ });
50
+ return remotes;
51
+ } catch (error) {
52
+ console.error("Error:", error.message);
53
+ return {};
54
+ }
55
+ }
56
+ module2.exports.parseGitRemotes = parseGitRemotes;
57
+ function joinPathPreserveDriveLetter(...segments) {
58
+ let fullPath = require("path").join(...segments);
59
+ if (/^[a-z]:\\/.test(fullPath)) {
60
+ fullPath = fullPath.charAt(0).toUpperCase() + fullPath.slice(1);
61
+ }
62
+ return fullPath;
63
+ }
64
+ module2.exports.joinPathPreserveDriveLetter = joinPathPreserveDriveLetter;
65
+ function getArgs2() {
66
+ return argv2;
67
+ }
68
+ module2.exports.getArgs = getArgs2;
69
+ function del(fullPath) {
70
+ if (fs2.statSync(fullPath).isDirectory()) {
71
+ const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
72
+ for (let i = 0; i < subdir.length; i++) {
73
+ del(subdir[i]);
131
74
  }
132
- else if (extensions.length === 0) {
133
- patterns = ["**/*.*"];
75
+ } else {
76
+ try {
77
+ fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
78
+ console.log("deleted", fullPath);
79
+ } catch (_) {
80
+ console.log("failed delete", fullPath);
134
81
  }
135
- else {
136
- patterns = extensions.map((ext) => `**/*.${ext}`);
82
+ }
83
+ }
84
+ module2.exports.del = del;
85
+ function delStream(globStream) {
86
+ globStream.stream().on("data", (result) => {
87
+ const fullPath = path2.resolve(process.cwd(), result);
88
+ if (fs2.statSync(fullPath).isDirectory()) {
89
+ const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
90
+ for (let i = 0; i < subdir.length; i++) {
91
+ del(subdir[i]);
92
+ }
137
93
  }
138
- const globFiles = glob.sync(patterns.length === 1 ? patterns[0] : `{${patterns.join(",")}}`, {
139
- cwd: projectDir,
140
- ignore: ignorePatterns,
141
- absolute: true,
142
- nodir: true
143
- });
144
- const allFiles = new Set([...initialFiles, ...globFiles]);
145
- // Hash all unique files
146
- yield Promise.all(Array.from(allFiles).map(hashAndPush));
147
- // Sort the hashArray by file paths
148
- hashArray.sort((a, b) => a.localeCompare(b));
149
- /**
150
- * Generates a directory/file tree string from a hash array of file paths and hashes.
151
- *
152
- * @param {string[]} hashArray - Array of strings in the format 'relative/path/to/file hash'.
153
- * @returns {string} The directory/file tree as a string, with file hashes.
154
- */
155
- function getFileTreeString(hashArray) {
156
- const tree = {};
157
- // Map file paths to hashes for quick lookup
158
- const hashMap = {};
159
- for (const entry of hashArray) {
160
- const [filePath, hash] = entry.split(" ");
161
- hashMap[filePath] = hash;
162
- const parts = filePath.split("/");
163
- let current = tree;
164
- for (let i = 0; i < parts.length; i++) {
165
- const part = parts[i];
166
- if (i === parts.length - 1) {
167
- current[part] = null; // file
168
- }
169
- else {
170
- current[part] = current[part] || {};
171
- current = current[part];
172
- }
173
- }
174
- }
175
- /**
176
- * Recursively builds the tree string for a given node.
177
- *
178
- * @param {Object} node - The current node in the tree.
179
- * @param {string} prefix - The prefix for the current tree level.
180
- * @param {string} parentPath - The path to the current node.
181
- * @returns {string[]} Array of lines representing the tree structure.
182
- */
183
- function printNode(node, prefix = "", parentPath = "") {
184
- const keys = Object.keys(node).sort();
185
- let lines = [];
186
- keys.forEach((key, idx) => {
187
- const isLast = idx === keys.length - 1;
188
- const branch = isLast ? "└── " : "├── ";
189
- const currentPath = parentPath ? parentPath + "/" + key : key;
190
- if (node[key] === null) {
191
- // file: show hash
192
- lines.push(prefix + branch + key + " [" + (hashMap[currentPath] || "") + "]");
193
- }
194
- else {
195
- lines.push(prefix + branch + key + "/");
196
- lines = lines.concat(printNode(node[key], prefix + (isLast ? " " : "│ "), currentPath));
197
- }
198
- });
199
- return lines;
200
- }
201
- return printNode(tree, "", "").join("\n");
94
+ del(fullPath);
95
+ });
96
+ }
97
+ module2.exports.delStream = delStream;
98
+ function getFileTreeString(hashArray) {
99
+ const tree = {};
100
+ const hashMap = {};
101
+ for (const entry of hashArray) {
102
+ const [filePath, hash] = entry.split(" ");
103
+ hashMap[filePath] = hash;
104
+ const parts = filePath.split("/");
105
+ let current = tree;
106
+ for (let i = 0; i < parts.length; i++) {
107
+ const part = parts[i];
108
+ if (i === parts.length - 1) {
109
+ current[part] = null;
110
+ } else {
111
+ current[part] = current[part] || {};
112
+ current = current[part];
113
+ }
202
114
  }
203
- // Write directory/file tree to the output file (hashes are included in the tree)
204
- const fileTreeString = getFileTreeString(hashArray);
205
- yield fs.writeFile(outputFile, fileTreeString + "\n", "utf-8");
206
- // Add the hash file to the commit if --git-add is present
207
- if (argv["git-add"]) {
208
- execSync(`git add ${relativeOutputFile}`);
209
- console.log(`Directory tree written to ${relativeOutputFile} and staged for git.`);
115
+ }
116
+ function printNode(node, prefix = "", parentPath = "") {
117
+ const keys = Object.keys(node).sort();
118
+ let lines = [];
119
+ keys.forEach((key, idx) => {
120
+ const isLast = idx === keys.length - 1;
121
+ const branch = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
122
+ const currentPath = parentPath ? parentPath + "/" + key : key;
123
+ if (node[key] === null) {
124
+ lines.push(prefix + branch + key + " [" + (hashMap[currentPath] || "") + "]");
125
+ } else {
126
+ lines.push(prefix + branch + key + "/");
127
+ lines = lines.concat(printNode(node[key], prefix + (isLast ? " " : "\u2502 "), currentPath));
128
+ }
129
+ });
130
+ return lines;
131
+ }
132
+ return printNode(tree, "", "").join("\n");
133
+ }
134
+ module2.exports.getFileTreeString = getFileTreeString;
135
+ var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
136
+ module2.exports.delay = delay;
137
+ }
138
+ });
139
+
140
+ // src/print-directory-tree.cjs
141
+ init_cjs_shims();
142
+ var fs = require("fs").promises;
143
+ var path = require("path");
144
+ var crypto = require("crypto");
145
+ var { execSync } = require("child_process");
146
+ var glob = require("glob");
147
+ var { getArgs } = require_utils();
148
+ var sbgUtil = require("sbg-utility");
149
+ var dotenv = require("dotenv");
150
+ var projectDir = process.cwd();
151
+ var envPath = path.join(projectDir, ".env");
152
+ if (fs.existsSync(envPath)) dotenv.config({ path: envPath });
153
+ var argv = getArgs();
154
+ async function main() {
155
+ let relativeOutputFile = "tmp/directory-structure.txt";
156
+ if (argv.output || argv.o) {
157
+ relativeOutputFile = argv.output || argv.o;
158
+ }
159
+ const outputFile = path.isAbsolute(relativeOutputFile) ? relativeOutputFile : path.join(projectDir, relativeOutputFile);
160
+ sbgUtil.writefile(outputFile, "");
161
+ let extensions = [];
162
+ if (argv.ext) {
163
+ extensions = argv.ext.split(",").map((e) => e.trim().replace(/^\./, "")).filter(Boolean);
164
+ }
165
+ let excludeDirs = [
166
+ "node_modules",
167
+ "vendor",
168
+ "venv",
169
+ ".venv",
170
+ ".git",
171
+ ".hg",
172
+ ".svn",
173
+ ".idea",
174
+ ".vscode",
175
+ "dist",
176
+ "build",
177
+ "out",
178
+ "coverage",
179
+ ".DS_Store"
180
+ ];
181
+ if (argv.exclude) {
182
+ const userExcludes = argv.exclude.split(",").map((d) => d.trim()).filter(Boolean);
183
+ if (argv["override-exclude"] || argv.we) {
184
+ excludeDirs = userExcludes;
185
+ } else {
186
+ excludeDirs = excludeDirs.concat(userExcludes);
187
+ }
188
+ }
189
+ const ignorePatterns = excludeDirs.map((dir) => `**/${dir}/**`);
190
+ let hashArray = [];
191
+ const processedFiles = /* @__PURE__ */ new Set();
192
+ async function hashAndPush(file) {
193
+ if (processedFiles.has(file)) return;
194
+ processedFiles.add(file);
195
+ let relativePath = path.relative(projectDir, file);
196
+ relativePath = relativePath.split(path.sep).join("/");
197
+ try {
198
+ const stats = await fs.stat(file);
199
+ const pseudoHash = `${stats.size}-${stats.mtimeMs}`;
200
+ const hash = crypto.createHash("sha256").update(pseudoHash).digest("hex");
201
+ hashArray.push(`${relativePath} ${hash.slice(0, 8)}`);
202
+ } catch (err) {
203
+ console.error(`Error processing file: ${file}`, err instanceof Error ? err.message : "<unknown error>");
204
+ if (err && err.code === "ENOENT") {
205
+ hashArray.push(`${relativePath} <file not found>`);
206
+ } else {
207
+ hashArray.push(`${relativePath} <error: ${err && err.code ? `code ${err.code}` : "unknown"}>`);
208
+ }
209
+ }
210
+ }
211
+ const initialFiles = [
212
+ path.join(projectDir, "package.json"),
213
+ path.join(projectDir, "composer.json"),
214
+ path.join(projectDir, "requirements.txt")
215
+ ];
216
+ let patterns = [];
217
+ if (argv.pattern) {
218
+ if (Array.isArray(argv.pattern)) {
219
+ patterns = argv.pattern.map((p) => p.trim()).filter(Boolean);
220
+ } else {
221
+ patterns = [argv.pattern.trim()];
222
+ }
223
+ } else if (extensions.length === 0) {
224
+ patterns = ["**/*.*"];
225
+ } else {
226
+ patterns = extensions.map((ext) => `**/*.${ext}`);
227
+ }
228
+ const globFiles = glob.sync(patterns.length === 1 ? patterns[0] : `{${patterns.join(",")}}`, {
229
+ cwd: projectDir,
230
+ ignore: ignorePatterns,
231
+ absolute: true,
232
+ nodir: true
233
+ });
234
+ const allFiles = /* @__PURE__ */ new Set([...initialFiles, ...globFiles]);
235
+ await Promise.all(Array.from(allFiles).map(hashAndPush));
236
+ hashArray.sort((a, b) => a.localeCompare(b));
237
+ function getFileTreeString(hashArray2) {
238
+ const tree = {};
239
+ const hashMap = {};
240
+ for (const entry of hashArray2) {
241
+ const [filePath, hash] = entry.split(" ");
242
+ hashMap[filePath] = hash;
243
+ const parts = filePath.split("/");
244
+ let current = tree;
245
+ for (let i = 0; i < parts.length; i++) {
246
+ const part = parts[i];
247
+ if (i === parts.length - 1) {
248
+ current[part] = null;
249
+ } else {
250
+ current[part] = current[part] || {};
251
+ current = current[part];
210
252
  }
211
- else {
212
- console.log(`Directory tree written to ${relativeOutputFile}.`);
253
+ }
254
+ }
255
+ function printNode(node, prefix = "", parentPath = "") {
256
+ const keys = Object.keys(node).sort();
257
+ let lines = [];
258
+ keys.forEach((key, idx) => {
259
+ const isLast = idx === keys.length - 1;
260
+ const branch = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
261
+ const currentPath = parentPath ? parentPath + "/" + key : key;
262
+ if (node[key] === null) {
263
+ lines.push(prefix + branch + key + " [" + (hashMap[currentPath] || "") + "]");
264
+ } else {
265
+ lines.push(prefix + branch + key + "/");
266
+ lines = lines.concat(printNode(node[key], prefix + (isLast ? " " : "\u2502 "), currentPath));
213
267
  }
214
- });
268
+ });
269
+ return lines;
270
+ }
271
+ return printNode(tree, "", "").join("\n");
272
+ }
273
+ const fileTreeString = getFileTreeString(hashArray);
274
+ await fs.writeFile(outputFile, fileTreeString + "\n", "utf-8");
275
+ if (argv["git-add"]) {
276
+ execSync(`git add ${relativeOutputFile}`);
277
+ console.log(`Directory tree written to ${relativeOutputFile} and staged for git.`);
278
+ } else {
279
+ console.log(`Directory tree written to ${relativeOutputFile}.`);
280
+ }
215
281
  }
216
282
  if (argv.help || argv.h) {
217
- console.log(`
283
+ console.log(`
218
284
  Usage: node print-directory-tree.cjs [options]
219
285
 
220
286
  Options:
@@ -232,10 +298,9 @@ Examples:
232
298
  node print-directory-tree.cjs --exclude=dist,build
233
299
  node print-directory-tree.cjs --output=tmp/tree.txt
234
300
  `);
235
- process.exit(0);
301
+ process.exit(0);
236
302
  }
237
- // Execute the main function
238
303
  main().catch((err) => {
239
- console.error(err);
240
- process.exit(1);
304
+ console.error(err);
305
+ process.exit(1);
241
306
  });
@@ -1,12 +1,12 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  require_utils
4
- } from "./chunk-APBWENF6.mjs";
4
+ } from "./chunk-V3N3JEUF.mjs";
5
5
  import {
6
6
  __commonJS,
7
7
  __require,
8
8
  init_esm_shims
9
- } from "./chunk-AASHBCRW.mjs";
9
+ } from "./chunk-QQ4A6DLD.mjs";
10
10
 
11
11
  // src/print-directory-tree.cjs
12
12
  var require_print_directory_tree = __commonJS({
@@ -1,5 +1,28 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
1
19
  // src/ps/connected-domain.js
2
- module.exports = function(tdArray, indicator, hardlink) {
20
+ var connected_domain_exports = {};
21
+ __export(connected_domain_exports, {
22
+ default: () => connected_domain_default
23
+ });
24
+ module.exports = __toCommonJS(connected_domain_exports);
25
+ function connected_domain_default(tdArray, indicator, hardlink) {
3
26
  hardlink = hardlink || false;
4
27
  if (!tdArray) {
5
28
  throw new Error("tdArray must be provided");
@@ -153,4 +176,4 @@ module.exports = function(tdArray, indicator, hardlink) {
153
176
  }
154
177
  }
155
178
  return result;
156
- };
179
+ }
@@ -1,2 +1,10 @@
1
- declare function _exports(tdArray: any[], indicator: Function, hardlink: boolean): any;
2
- export = _exports;
1
+ /**
2
+ * calculate all the connected domains based on the given two-dimensional array
3
+ */
4
+ /**
5
+ * @param {Array} tdArray
6
+ * @param {Function} indicator It receive the raw point data as the first parameter and decide what kind of domain the point belongs to, it should return a string as a domain identifier.
7
+ * @param {Boolean} hardlink If use hard link. Default to false.
8
+ * @return {Object} [{ bounding: { w: 12, h: 19, x: 0, y: 1 }, points: [ { x: 1, y: 2, point: {} } ], identifier: 'blue', domainId: 1 } ]
9
+ */
10
+ export default function _default(tdArray: any[], indicator: Function, hardlink: boolean): any;
@@ -1,13 +1,16 @@
1
+ "use strict";
1
2
  /**
2
3
  * calculate all the connected domains based on the given two-dimensional array
3
4
  */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = default_1;
4
7
  /**
5
8
  * @param {Array} tdArray
6
9
  * @param {Function} indicator It receive the raw point data as the first parameter and decide what kind of domain the point belongs to, it should return a string as a domain identifier.
7
10
  * @param {Boolean} hardlink If use hard link. Default to false.
8
11
  * @return {Object} [{ bounding: { w: 12, h: 19, x: 0, y: 1 }, points: [ { x: 1, y: 2, point: {} } ], identifier: 'blue', domainId: 1 } ]
9
12
  */
10
- module.exports = function (tdArray, indicator, hardlink) {
13
+ function default_1(tdArray, indicator, hardlink) {
11
14
  hardlink = hardlink || false;
12
15
  if (!tdArray) {
13
16
  throw new Error("tdArray must be provided");
@@ -199,4 +202,4 @@ module.exports = function (tdArray, indicator, hardlink) {
199
202
  }
200
203
  }
201
204
  return result;
202
- };
205
+ }
@@ -1,6 +1,10 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
- require_connected_domain
4
- } from "../chunk-DPKAJKFO.mjs";
5
- import "../chunk-AASHBCRW.mjs";
6
- export default require_connected_domain();
3
+ connected_domain_default,
4
+ init_connected_domain
5
+ } from "../chunk-FKI7IEB5.mjs";
6
+ import "../chunk-QQ4A6DLD.mjs";
7
+ init_connected_domain();
8
+ export {
9
+ connected_domain_default as default
10
+ };