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
@@ -0,0 +1,262 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __esm = (fn, res) => function __init() {
8
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
+ };
10
+ var __commonJS = (cb, mod) => function __require() {
11
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+
30
+ // node_modules/tsup/assets/cjs_shims.js
31
+ var init_cjs_shims = __esm({
32
+ "node_modules/tsup/assets/cjs_shims.js"() {
33
+ }
34
+ });
35
+
36
+ // src/utils/index.cjs
37
+ var require_utils = __commonJS({
38
+ "src/utils/index.cjs"(exports2, module2) {
39
+ init_cjs_shims();
40
+ var fs2 = require("fs");
41
+ var path2 = require("upath");
42
+ var argv2 = require("minimist")(process.argv.slice(2));
43
+ var { exec } = require("child_process");
44
+ var { URL: URL2 } = require("url");
45
+ var { promisify } = require("util");
46
+ var execAsync = promisify(exec);
47
+ async function parseGitRemotes() {
48
+ try {
49
+ const { stdout } = await execAsync("git remote -v");
50
+ const lines = stdout.split("\n");
51
+ const remotes = {};
52
+ lines.forEach((line) => {
53
+ const [name, url] = line.split(" ");
54
+ if (name && url) {
55
+ const [repoUrl] = url.split(" ");
56
+ try {
57
+ const parsedUrl = new URL2(repoUrl);
58
+ const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
59
+ if (parsedUrl.hostname === "github.com" && pathParts.length === 2) {
60
+ let repoPath = pathParts.join("/");
61
+ if (repoPath.endsWith(".git")) {
62
+ repoPath = repoPath.slice(0, -4);
63
+ }
64
+ remotes[name] = repoPath;
65
+ }
66
+ } catch (e) {
67
+ console.error("URL Parsing Error:", e.message);
68
+ }
69
+ }
70
+ });
71
+ return remotes;
72
+ } catch (error) {
73
+ console.error("Error:", error.message);
74
+ return {};
75
+ }
76
+ }
77
+ module2.exports.parseGitRemotes = parseGitRemotes;
78
+ function joinPathPreserveDriveLetter(...segments) {
79
+ let fullPath = require("path").join(...segments);
80
+ if (/^[a-z]:\\/.test(fullPath)) {
81
+ fullPath = fullPath.charAt(0).toUpperCase() + fullPath.slice(1);
82
+ }
83
+ return fullPath;
84
+ }
85
+ module2.exports.joinPathPreserveDriveLetter = joinPathPreserveDriveLetter;
86
+ function getArgs2() {
87
+ return argv2;
88
+ }
89
+ module2.exports.getArgs = getArgs2;
90
+ function del(fullPath) {
91
+ if (fs2.statSync(fullPath).isDirectory()) {
92
+ const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
93
+ for (let i = 0; i < subdir.length; i++) {
94
+ del(subdir[i]);
95
+ }
96
+ } else {
97
+ try {
98
+ fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
99
+ console.log("deleted", fullPath);
100
+ } catch (_) {
101
+ console.log("failed delete", fullPath);
102
+ }
103
+ }
104
+ }
105
+ module2.exports.del = del;
106
+ function delStream(globStream) {
107
+ globStream.stream().on("data", (result) => {
108
+ const fullPath = path2.resolve(process.cwd(), result);
109
+ if (fs2.statSync(fullPath).isDirectory()) {
110
+ const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
111
+ for (let i = 0; i < subdir.length; i++) {
112
+ del(subdir[i]);
113
+ }
114
+ }
115
+ del(fullPath);
116
+ });
117
+ }
118
+ module2.exports.delStream = delStream;
119
+ function getFileTreeString(hashArray) {
120
+ const tree = {};
121
+ const hashMap = {};
122
+ for (const entry of hashArray) {
123
+ const [filePath, hash] = entry.split(" ");
124
+ hashMap[filePath] = hash;
125
+ const parts = filePath.split("/");
126
+ let current = tree;
127
+ for (let i = 0; i < parts.length; i++) {
128
+ const part = parts[i];
129
+ if (i === parts.length - 1) {
130
+ current[part] = null;
131
+ } else {
132
+ current[part] = current[part] || {};
133
+ current = current[part];
134
+ }
135
+ }
136
+ }
137
+ function printNode(node, prefix = "", parentPath = "") {
138
+ const keys = Object.keys(node).sort();
139
+ let lines = [];
140
+ keys.forEach((key, idx) => {
141
+ const isLast = idx === keys.length - 1;
142
+ const branch = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
143
+ const currentPath = parentPath ? parentPath + "/" + key : key;
144
+ if (node[key] === null) {
145
+ lines.push(prefix + branch + key + " [" + (hashMap[currentPath] || "") + "]");
146
+ } else {
147
+ lines.push(prefix + branch + key + "/");
148
+ lines = lines.concat(printNode(node[key], prefix + (isLast ? " " : "\u2502 "), currentPath));
149
+ }
150
+ });
151
+ return lines;
152
+ }
153
+ return printNode(tree, "", "").join("\n");
154
+ }
155
+ module2.exports.getFileTreeString = getFileTreeString;
156
+ var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
157
+ module2.exports.delay = delay;
158
+ }
159
+ });
160
+
161
+ // src/remove-module.mjs
162
+ init_cjs_shims();
163
+ var import_utils = __toESM(require_utils(), 1);
164
+ var import_fs = __toESM(require("fs"), 1);
165
+ var import_path = __toESM(require("path"), 1);
166
+ var glob = __toESM(require("glob"), 1);
167
+ var argv = (0, import_utils.getArgs)();
168
+ var positional = argv._ || [];
169
+ if (argv.help || argv.h) {
170
+ console.log();
171
+ console.log("Usage: remove-module <moduleName> [<moduleName> ...]");
172
+ console.log();
173
+ console.log("Removes a module from one or more dependency directories:");
174
+ console.log(" - node_modules (Node.js, with --node)");
175
+ console.log(" - vendor/composer (PHP Composer, with --composer)");
176
+ console.log(" - venv/.venv site-packages (Python, with --venv)");
177
+ console.log();
178
+ console.log("Options:");
179
+ console.log(" --node Remove from node_modules (default if no flag given)");
180
+ console.log(" --composer Remove from vendor/composer");
181
+ console.log(" --venv Remove from venv/.venv site-packages");
182
+ console.log(" --help, -h Show this help message");
183
+ console.log();
184
+ process.exit(0);
185
+ }
186
+ if (positional.length === 0) {
187
+ console.log();
188
+ console.error("No module name provided.");
189
+ console.log();
190
+ process.exit(1);
191
+ } else {
192
+ if (!argv.node && !argv.composer && !argv.venv) {
193
+ argv.node = true;
194
+ }
195
+ }
196
+ for (const moduleName of positional) {
197
+ if (argv.node) {
198
+ const modulePath = import_path.default.resolve("node_modules", moduleName);
199
+ if (import_fs.default.existsSync(modulePath)) {
200
+ try {
201
+ import_fs.default.rmSync(modulePath, { recursive: true, force: true });
202
+ console.log();
203
+ console.log(`Module ${moduleName} removed successfully.`);
204
+ console.log();
205
+ } catch (error) {
206
+ console.log();
207
+ console.error(`Failed to remove module ${moduleName}:`, error.message);
208
+ console.log();
209
+ }
210
+ }
211
+ }
212
+ if (argv.composer) {
213
+ const vendorPath = import_path.default.resolve("vendor", "composer", moduleName);
214
+ if (import_fs.default.existsSync(vendorPath)) {
215
+ try {
216
+ import_fs.default.rmSync(vendorPath, { recursive: true, force: true });
217
+ console.log();
218
+ console.log(`Vendor module ${moduleName} removed successfully.`);
219
+ console.log();
220
+ } catch (error) {
221
+ console.log();
222
+ console.error(`Failed to remove vendor module ${moduleName}:`, error.message);
223
+ console.log();
224
+ }
225
+ }
226
+ }
227
+ if (argv.venv) {
228
+ const venvs = [".venv", "venv"];
229
+ for (const venv of venvs) {
230
+ const sitePackages = import_path.default.resolve(venv, "Lib", "site-packages");
231
+ const venvModulePaths = [
232
+ // main package directory (for packages)
233
+ import_path.default.resolve(sitePackages, moduleName),
234
+ // main module file (for single-file modules)
235
+ import_path.default.resolve(sitePackages, moduleName + ".py"),
236
+ // dist-info metadata directories
237
+ ...glob.sync(`${moduleName}-*.dist-info`, { cwd: sitePackages }).map((p) => import_path.default.resolve(sitePackages, p)),
238
+ // egg-info metadata directories
239
+ ...glob.sync(`${moduleName}-*.egg-info`, { cwd: sitePackages }).map((p) => import_path.default.resolve(sitePackages, p)),
240
+ // compiled extension files (.pyd for Windows, .so for Linux)
241
+ ...glob.sync(`${moduleName}*.pyd`, { cwd: sitePackages }).map((p) => import_path.default.resolve(sitePackages, p)),
242
+ ...glob.sync(`${moduleName}*.so`, { cwd: sitePackages }).map((p) => import_path.default.resolve(sitePackages, p)),
243
+ // editable install directories (legacy pattern)
244
+ ...glob.sync(`_*editable_*${moduleName}*`, { cwd: sitePackages }).map((p) => import_path.default.resolve(sitePackages, p))
245
+ ];
246
+ for (const venvModulePath of venvModulePaths) {
247
+ if (import_fs.default.existsSync(venvModulePath)) {
248
+ try {
249
+ import_fs.default.rmSync(venvModulePath, { recursive: true, force: true });
250
+ console.log();
251
+ console.log(`Virtual environment module ${moduleName} removed successfully.`);
252
+ console.log();
253
+ } catch (error) {
254
+ console.log();
255
+ console.error(`Failed to remove virtual environment module ${moduleName}:`, error.message);
256
+ console.log();
257
+ }
258
+ }
259
+ }
260
+ }
261
+ }
262
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,111 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ require_utils
4
+ } from "./chunk-V3N3JEUF.mjs";
5
+ import {
6
+ __toESM,
7
+ init_esm_shims
8
+ } from "./chunk-QQ4A6DLD.mjs";
9
+
10
+ // src/remove-module.mjs
11
+ init_esm_shims();
12
+ var import_utils = __toESM(require_utils(), 1);
13
+ import fs from "fs";
14
+ import path from "path";
15
+ import * as glob from "glob";
16
+ var argv = (0, import_utils.getArgs)();
17
+ var positional = argv._ || [];
18
+ if (argv.help || argv.h) {
19
+ console.log();
20
+ console.log("Usage: remove-module <moduleName> [<moduleName> ...]");
21
+ console.log();
22
+ console.log("Removes a module from one or more dependency directories:");
23
+ console.log(" - node_modules (Node.js, with --node)");
24
+ console.log(" - vendor/composer (PHP Composer, with --composer)");
25
+ console.log(" - venv/.venv site-packages (Python, with --venv)");
26
+ console.log();
27
+ console.log("Options:");
28
+ console.log(" --node Remove from node_modules (default if no flag given)");
29
+ console.log(" --composer Remove from vendor/composer");
30
+ console.log(" --venv Remove from venv/.venv site-packages");
31
+ console.log(" --help, -h Show this help message");
32
+ console.log();
33
+ process.exit(0);
34
+ }
35
+ if (positional.length === 0) {
36
+ console.log();
37
+ console.error("No module name provided.");
38
+ console.log();
39
+ process.exit(1);
40
+ } else {
41
+ if (!argv.node && !argv.composer && !argv.venv) {
42
+ argv.node = true;
43
+ }
44
+ }
45
+ for (const moduleName of positional) {
46
+ if (argv.node) {
47
+ const modulePath = path.resolve("node_modules", moduleName);
48
+ if (fs.existsSync(modulePath)) {
49
+ try {
50
+ fs.rmSync(modulePath, { recursive: true, force: true });
51
+ console.log();
52
+ console.log(`Module ${moduleName} removed successfully.`);
53
+ console.log();
54
+ } catch (error) {
55
+ console.log();
56
+ console.error(`Failed to remove module ${moduleName}:`, error.message);
57
+ console.log();
58
+ }
59
+ }
60
+ }
61
+ if (argv.composer) {
62
+ const vendorPath = path.resolve("vendor", "composer", moduleName);
63
+ if (fs.existsSync(vendorPath)) {
64
+ try {
65
+ fs.rmSync(vendorPath, { recursive: true, force: true });
66
+ console.log();
67
+ console.log(`Vendor module ${moduleName} removed successfully.`);
68
+ console.log();
69
+ } catch (error) {
70
+ console.log();
71
+ console.error(`Failed to remove vendor module ${moduleName}:`, error.message);
72
+ console.log();
73
+ }
74
+ }
75
+ }
76
+ if (argv.venv) {
77
+ const venvs = [".venv", "venv"];
78
+ for (const venv of venvs) {
79
+ const sitePackages = path.resolve(venv, "Lib", "site-packages");
80
+ const venvModulePaths = [
81
+ // main package directory (for packages)
82
+ path.resolve(sitePackages, moduleName),
83
+ // main module file (for single-file modules)
84
+ path.resolve(sitePackages, moduleName + ".py"),
85
+ // dist-info metadata directories
86
+ ...glob.sync(`${moduleName}-*.dist-info`, { cwd: sitePackages }).map((p) => path.resolve(sitePackages, p)),
87
+ // egg-info metadata directories
88
+ ...glob.sync(`${moduleName}-*.egg-info`, { cwd: sitePackages }).map((p) => path.resolve(sitePackages, p)),
89
+ // compiled extension files (.pyd for Windows, .so for Linux)
90
+ ...glob.sync(`${moduleName}*.pyd`, { cwd: sitePackages }).map((p) => path.resolve(sitePackages, p)),
91
+ ...glob.sync(`${moduleName}*.so`, { cwd: sitePackages }).map((p) => path.resolve(sitePackages, p)),
92
+ // editable install directories (legacy pattern)
93
+ ...glob.sync(`_*editable_*${moduleName}*`, { cwd: sitePackages }).map((p) => path.resolve(sitePackages, p))
94
+ ];
95
+ for (const venvModulePath of venvModulePaths) {
96
+ if (fs.existsSync(venvModulePath)) {
97
+ try {
98
+ fs.rmSync(venvModulePath, { recursive: true, force: true });
99
+ console.log();
100
+ console.log(`Virtual environment module ${moduleName} removed successfully.`);
101
+ console.log();
102
+ } catch (error) {
103
+ console.log();
104
+ console.error(`Failed to remove virtual environment module ${moduleName}:`, error.message);
105
+ console.log();
106
+ }
107
+ }
108
+ }
109
+ }
110
+ }
111
+ }
package/lib/rmpath.cjs ADDED
@@ -0,0 +1,274 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __esm = (fn, res) => function __init() {
8
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
+ };
10
+ var __commonJS = (cb, mod) => function __require() {
11
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
+ };
13
+ var __export = (target, all) => {
14
+ for (var name in all)
15
+ __defProp(target, name, { get: all[name], enumerable: true });
16
+ };
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") {
19
+ for (let key of __getOwnPropNames(from))
20
+ if (!__hasOwnProp.call(to, key) && key !== except)
21
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
+ }
23
+ return to;
24
+ };
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26
+ // If the importer is in node compatibility mode or this is not an ESM
27
+ // file that has been converted to a CommonJS file using a Babel-
28
+ // compatible transform (i.e. "__esModule" has not been set), then set
29
+ // "default" to the CommonJS "module.exports" for node compatibility.
30
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31
+ mod
32
+ ));
33
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
+
35
+ // node_modules/tsup/assets/cjs_shims.js
36
+ var getImportMetaUrl, importMetaUrl;
37
+ var init_cjs_shims = __esm({
38
+ "node_modules/tsup/assets/cjs_shims.js"() {
39
+ getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
40
+ importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
41
+ }
42
+ });
43
+
44
+ // src/utils/index.cjs
45
+ var require_utils = __commonJS({
46
+ "src/utils/index.cjs"(exports2, module2) {
47
+ init_cjs_shims();
48
+ var fs2 = require("fs");
49
+ var path2 = require("upath");
50
+ var argv2 = require("minimist")(process.argv.slice(2));
51
+ var { exec } = require("child_process");
52
+ var { URL: URL2 } = require("url");
53
+ var { promisify } = require("util");
54
+ var execAsync = promisify(exec);
55
+ async function parseGitRemotes() {
56
+ try {
57
+ const { stdout } = await execAsync("git remote -v");
58
+ const lines = stdout.split("\n");
59
+ const remotes = {};
60
+ lines.forEach((line) => {
61
+ const [name, url] = line.split(" ");
62
+ if (name && url) {
63
+ const [repoUrl] = url.split(" ");
64
+ try {
65
+ const parsedUrl = new URL2(repoUrl);
66
+ const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
67
+ if (parsedUrl.hostname === "github.com" && pathParts.length === 2) {
68
+ let repoPath = pathParts.join("/");
69
+ if (repoPath.endsWith(".git")) {
70
+ repoPath = repoPath.slice(0, -4);
71
+ }
72
+ remotes[name] = repoPath;
73
+ }
74
+ } catch (e) {
75
+ console.error("URL Parsing Error:", e.message);
76
+ }
77
+ }
78
+ });
79
+ return remotes;
80
+ } catch (error) {
81
+ console.error("Error:", error.message);
82
+ return {};
83
+ }
84
+ }
85
+ module2.exports.parseGitRemotes = parseGitRemotes;
86
+ function joinPathPreserveDriveLetter(...segments) {
87
+ let fullPath = require("path").join(...segments);
88
+ if (/^[a-z]:\\/.test(fullPath)) {
89
+ fullPath = fullPath.charAt(0).toUpperCase() + fullPath.slice(1);
90
+ }
91
+ return fullPath;
92
+ }
93
+ module2.exports.joinPathPreserveDriveLetter = joinPathPreserveDriveLetter;
94
+ function getArgs2() {
95
+ return argv2;
96
+ }
97
+ module2.exports.getArgs = getArgs2;
98
+ function del(fullPath) {
99
+ if (fs2.statSync(fullPath).isDirectory()) {
100
+ const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
101
+ for (let i = 0; i < subdir.length; i++) {
102
+ del(subdir[i]);
103
+ }
104
+ } else {
105
+ try {
106
+ fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
107
+ console.log("deleted", fullPath);
108
+ } catch (_) {
109
+ console.log("failed delete", fullPath);
110
+ }
111
+ }
112
+ }
113
+ module2.exports.del = del;
114
+ function delStream(globStream) {
115
+ globStream.stream().on("data", (result) => {
116
+ const fullPath = path2.resolve(process.cwd(), result);
117
+ if (fs2.statSync(fullPath).isDirectory()) {
118
+ const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
119
+ for (let i = 0; i < subdir.length; i++) {
120
+ del(subdir[i]);
121
+ }
122
+ }
123
+ del(fullPath);
124
+ });
125
+ }
126
+ module2.exports.delStream = delStream;
127
+ function getFileTreeString(hashArray) {
128
+ const tree = {};
129
+ const hashMap = {};
130
+ for (const entry of hashArray) {
131
+ const [filePath, hash] = entry.split(" ");
132
+ hashMap[filePath] = hash;
133
+ const parts = filePath.split("/");
134
+ let current = tree;
135
+ for (let i = 0; i < parts.length; i++) {
136
+ const part = parts[i];
137
+ if (i === parts.length - 1) {
138
+ current[part] = null;
139
+ } else {
140
+ current[part] = current[part] || {};
141
+ current = current[part];
142
+ }
143
+ }
144
+ }
145
+ function printNode(node, prefix = "", parentPath = "") {
146
+ const keys = Object.keys(node).sort();
147
+ let lines = [];
148
+ keys.forEach((key, idx) => {
149
+ const isLast = idx === keys.length - 1;
150
+ const branch = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
151
+ const currentPath = parentPath ? parentPath + "/" + key : key;
152
+ if (node[key] === null) {
153
+ lines.push(prefix + branch + key + " [" + (hashMap[currentPath] || "") + "]");
154
+ } else {
155
+ lines.push(prefix + branch + key + "/");
156
+ lines = lines.concat(printNode(node[key], prefix + (isLast ? " " : "\u2502 "), currentPath));
157
+ }
158
+ });
159
+ return lines;
160
+ }
161
+ return printNode(tree, "", "").join("\n");
162
+ }
163
+ module2.exports.getFileTreeString = getFileTreeString;
164
+ var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
165
+ module2.exports.delay = delay;
166
+ }
167
+ });
168
+
169
+ // src/rmpath.mjs
170
+ var rmpath_exports = {};
171
+ __export(rmpath_exports, {
172
+ deleteMainScript: () => deleteMainScript,
173
+ deleteMatchingFiles: () => deleteMatchingFiles,
174
+ resolveDeletePatterns: () => resolveDeletePatterns
175
+ });
176
+ module.exports = __toCommonJS(rmpath_exports);
177
+ init_cjs_shims();
178
+ var import_dotenv = __toESM(require("dotenv"), 1);
179
+ var import_fs_extra = __toESM(require("fs-extra"), 1);
180
+ var glob = __toESM(require("glob"), 1);
181
+ var import_upath = __toESM(require("upath"), 1);
182
+ var import_url = require("url");
183
+ var import_utils = __toESM(require_utils(), 1);
184
+ var __filename2 = (0, import_url.fileURLToPath)(importMetaUrl);
185
+ var __dirname = import_upath.default.dirname(__filename2);
186
+ var dotenvPath = import_upath.default.resolve(process.cwd(), ".env");
187
+ if (import_fs_extra.default.existsSync(dotenvPath)) {
188
+ import_dotenv.default.config({ path: dotenvPath });
189
+ }
190
+ var argv = (0, import_utils.getArgs)();
191
+ var positional = argv._ || [];
192
+ var deletePatterns = [];
193
+ function resolveDeletePatterns(targetPath) {
194
+ if (import_fs_extra.default.existsSync(targetPath) && import_fs_extra.default.lstatSync(targetPath).isFile()) {
195
+ deletePatterns.push(targetPath);
196
+ return;
197
+ }
198
+ const vowels = ["a", "i", "u", "e", "o", "A", "I", "U", "E", "O"];
199
+ const letters = [];
200
+ for (let i = 97; i <= 122; i++) letters.push(String.fromCharCode(i));
201
+ for (let i = 65; i <= 90; i++) letters.push(String.fromCharCode(i));
202
+ for (const letter of letters) {
203
+ for (const vowel of vowels) {
204
+ deletePatterns.push(
205
+ `.${letter}*`,
206
+ `@${letter}*`,
207
+ `${letter}*`,
208
+ `@${letter}${vowel}*`,
209
+ `.${letter}${vowel}*`,
210
+ `${letter}${vowel}*`
211
+ );
212
+ }
213
+ }
214
+ }
215
+ async function deleteMatchingFiles(baseDir) {
216
+ for (const pattern of deletePatterns) {
217
+ if (import_fs_extra.default.existsSync(pattern)) {
218
+ import_fs_extra.default.rmSync(pattern, { recursive: true, force: true });
219
+ continue;
220
+ }
221
+ const matches = glob.sync(import_upath.default.join(baseDir, pattern), { dot: true, nocase: true });
222
+ for (const fpath of matches) {
223
+ try {
224
+ console.log(`deleting ${fpath}`);
225
+ import_fs_extra.default.rmSync(fpath, { recursive: true, force: true });
226
+ } catch (_e) {
227
+ console.error(`cannot delete ${fpath}`);
228
+ }
229
+ }
230
+ }
231
+ }
232
+ async function deleteMainScript(targetPath) {
233
+ if (!import_fs_extra.default.existsSync(targetPath)) {
234
+ targetPath = import_upath.default.resolve(process.cwd(), targetPath);
235
+ }
236
+ resolveDeletePatterns(targetPath);
237
+ await deleteMatchingFiles(targetPath);
238
+ console.log(`cleaning ${targetPath}`);
239
+ try {
240
+ import_fs_extra.default.rmSync(targetPath, { recursive: true, force: true });
241
+ } catch (_e) {
242
+ }
243
+ }
244
+ var isMain = false;
245
+ try {
246
+ if (typeof require !== "undefined" && typeof module !== "undefined" && require.main === module) {
247
+ isMain = true;
248
+ }
249
+ } catch (_e) {
250
+ }
251
+ try {
252
+ const mainArg = process.argv[1] && import_upath.default.resolve(process.argv[1]);
253
+ if (mainArg && importMetaUrl === (0, import_url.pathToFileURL)(mainArg).href) {
254
+ isMain = true;
255
+ }
256
+ } catch (_e) {
257
+ }
258
+ if (isMain) {
259
+ console.log("Invoked from CLI");
260
+ if (positional.length === 0) {
261
+ console.error("You need to provide a file or folder path");
262
+ process.exit(1);
263
+ } else {
264
+ deleteMainScript(positional[0]);
265
+ }
266
+ } else {
267
+ console.log("Not invoked from CLI");
268
+ }
269
+ // Annotate the CommonJS export names for ESM import in node:
270
+ 0 && (module.exports = {
271
+ deleteMainScript,
272
+ deleteMatchingFiles,
273
+ resolveDeletePatterns
274
+ });
@@ -0,0 +1,3 @@
1
+ export function resolveDeletePatterns(targetPath: any): void;
2
+ export function deleteMatchingFiles(baseDir: any): Promise<void>;
3
+ export function deleteMainScript(targetPath: any): Promise<void>;