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.
- package/binaries/binary-executor.cjs +43 -0
- package/{bin → binaries}/clean-nodemodule +0 -0
- package/binaries/clean-nodemodule.cjs +43 -0
- package/binaries/clean-nodemodule.cmd +4 -0
- package/{bin → binaries}/clean-nodemodules +0 -0
- package/binaries/clean-nodemodules.cjs +43 -0
- package/binaries/clean-nodemodules.cmd +5 -0
- package/{bin → binaries}/dev +0 -0
- package/binaries/dev.cjs +43 -0
- package/{bin → binaries}/empty +0 -0
- package/binaries/empty.cjs +43 -0
- package/{bin → binaries}/git-reduce-size +0 -0
- package/binaries/git-reduce-size.cjs +43 -0
- package/binaries/javakill.cjs +43 -0
- package/{bin → binaries}/javakill.cmd +0 -0
- package/{bin → binaries}/kill-process +0 -0
- package/binaries/kill-process.cjs +43 -0
- package/binaries/nodekill.cjs +43 -0
- package/{bin → binaries}/nodekill.ps1 +0 -0
- package/{bin → binaries}/prod +0 -0
- package/binaries/prod.cjs +43 -0
- package/{bin → binaries}/rmfind +0 -0
- package/binaries/rmfind.cjs +43 -0
- package/{bin → binaries}/rmx +0 -0
- package/binaries/rmx.cjs +43 -0
- package/{bin → binaries}/submodule-token +0 -0
- package/binaries/submodule-token.cjs +43 -0
- package/docs-src/clean-github-actions-caches.md +26 -0
- package/docs-src/free-chatgpt.md +26 -0
- package/lib/binary-collections-config.cjs +3 -2
- package/lib/binary-collections-config.mjs +2 -2
- package/lib/binary-collections.cjs +452 -87
- package/lib/binary-collections.mjs +247 -8
- package/lib/changelog.cjs +328 -0
- package/lib/changelog.mjs +205 -0
- package/lib/chunk-4EWQC6GZ.mjs +382 -0
- package/lib/chunk-4ZI7BQKQ.mjs +381 -0
- package/lib/chunk-5J2BEPY5.mjs +83 -0
- package/lib/{chunk-4BYBVEYC.mjs → chunk-66PAU5PS.mjs} +5 -4
- package/lib/chunk-6HHJRKFB.mjs +59 -0
- package/lib/chunk-6S4NXESK.mjs +26 -0
- package/lib/{chunk-ZYAQRPUL.mjs → chunk-7YD7IPFF.mjs} +2 -2
- package/lib/{chunk-SH3L6HHV.mjs → chunk-A2JQXI5Z.mjs} +2 -2
- package/lib/{chunk-EGSSKVDH.mjs → chunk-A3VUZEJK.mjs} +1 -1
- package/lib/chunk-AGZYRDC2.mjs +323 -0
- package/lib/{chunk-VVEZVNIV.mjs → chunk-AI4CVPJ7.mjs} +6 -6
- package/lib/chunk-BDCHCWHD.mjs +136 -0
- package/lib/chunk-BEZKJ25G.mjs +140 -0
- package/lib/chunk-DI5MDPSN.mjs +386 -0
- package/lib/{chunk-ONIBBBQ3.mjs → chunk-E6FDDAOO.mjs} +4 -3
- package/lib/chunk-FKI7IEB5.mjs +172 -0
- package/lib/chunk-GJTGHXRA.mjs +356 -0
- package/lib/{chunk-YV7DO3YV.mjs → chunk-HLGOWBEO.mjs} +1 -1
- package/lib/chunk-HMRMTYZM.mjs +40 -0
- package/lib/chunk-HN52G2YL.mjs +305 -0
- package/lib/chunk-HO6GHCOB.mjs +385 -0
- package/lib/chunk-LEM5OMRP.mjs +384 -0
- package/lib/{chunk-YX5U7XDR.mjs → chunk-M3YIYRHT.mjs} +6 -5
- package/lib/chunk-O6SWBEOQ.mjs +81 -0
- package/lib/{chunk-JGR2NW6D.mjs → chunk-PDSXF5HY.mjs} +3 -3
- package/lib/{chunk-AASHBCRW.mjs → chunk-QQ4A6DLD.mjs} +8 -0
- package/lib/chunk-RCP7DHVY.mjs +190 -0
- package/lib/chunk-SBNDSKG5.mjs +136 -0
- package/lib/chunk-U6SO4QEV.mjs +320 -0
- package/lib/{chunk-APBWENF6.mjs → chunk-V3N3JEUF.mjs} +3 -3
- package/lib/chunk-XD6BJK6Q.mjs +351 -0
- package/lib/chunk-XVBFFVCJ.mjs +209 -0
- package/lib/chunk-YXSFGA2D.mjs +383 -0
- package/lib/clean-github-actions-caches.cjs +243 -148
- package/lib/clean-github-actions-caches.mjs +4 -3
- package/lib/del-gradle.cjs +2 -2
- package/lib/del-gradle.js +1 -1
- package/lib/del-gradle.mjs +2 -2
- package/lib/del-node-modules.cjs +2 -2
- package/lib/del-node-modules.js +1 -1
- package/lib/del-node-modules.mjs +2 -2
- package/lib/del-ps.cjs +29 -8
- package/lib/del-ps.js +2 -2
- package/lib/del-ps.mjs +7 -5
- package/lib/del-yarn-caches.cjs +26 -5
- package/lib/del-yarn-caches.js +38 -3
- package/lib/del-yarn-caches.mjs +6 -6
- package/lib/find-node-modules-cli.cjs +5 -4
- package/lib/find-node-modules-cli.js +1 -1
- package/lib/find-node-modules-cli.mjs +2 -2
- package/lib/find-node-modules.cjs +4 -3
- package/lib/{find-node-modules.d.ts → find-node-modules.d.cts} +1 -1
- package/lib/find-node-modules.mjs +2 -2
- package/lib/free-chatgpt.cjs +548 -0
- package/lib/free-chatgpt.d.ts +1 -0
- package/lib/free-chatgpt.js +51 -0
- package/lib/free-chatgpt.mjs +50 -0
- package/lib/git/gitattributes.cjs +1 -1
- package/lib/git/{gitattributes.d.mts → gitattributes.d.cts} +5 -7
- package/lib/git/gitattributes.mjs +2 -2
- package/lib/git/line-endings.cjs +297 -64
- package/lib/git/line-endings.mjs +4 -4
- package/lib/git/normalize.cjs +26 -36
- package/lib/git/normalize.mjs +2 -2
- package/lib/git/permissions.cjs +77 -11
- package/lib/git/permissions.mjs +3 -3
- package/lib/git/pull-strategy.cjs +76 -9
- package/lib/git/pull-strategy.mjs +3 -3
- package/lib/git/user-config.cjs +266 -83
- package/lib/git/user-config.mjs +4 -4
- package/lib/git/utils.cjs +40 -60
- package/lib/git/utils.mjs +2 -2
- package/lib/git-diff-cli.cjs +651 -0
- package/lib/git-diff-cli.d.ts +1 -0
- package/lib/git-diff-cli.js +15 -0
- package/lib/git-diff-cli.mjs +16 -0
- package/lib/git-diff.cjs +657 -58
- package/lib/git-diff.d.ts +38 -83
- package/lib/git-diff.js +152 -0
- package/lib/git-diff.mjs +23 -85
- package/lib/git-fix.cjs +685 -97
- package/lib/git-fix.mjs +12 -11
- package/lib/git-purge.cjs +3 -3
- package/lib/git-purge.d.cts +1 -0
- package/lib/git-purge.mjs +43 -37
- package/lib/index.cjs +7 -6
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -5
- package/lib/index.mjs +4 -4
- package/lib/npm-run-series.cjs +3 -3
- package/lib/npm-run-series.mjs +42 -36
- package/lib/package-resolutions-updater.cjs +174 -1
- package/lib/package-resolutions-updater.mjs +270 -290
- package/lib/print-directory-tree.cjs +275 -210
- package/lib/print-directory-tree.mjs +2 -2
- package/lib/ps/connected-domain.cjs +25 -2
- package/lib/ps/connected-domain.d.ts +10 -2
- package/lib/ps/connected-domain.js +5 -2
- package/lib/ps/connected-domain.mjs +8 -4
- package/lib/ps/index.cjs +345 -322
- package/lib/ps/index.d.mjs +1 -1
- package/lib/ps/index.js +1 -1
- package/lib/ps/index.mjs +179 -182
- package/lib/ps/isWin.cjs +24 -1
- package/lib/ps/isWin.d.ts +1 -1
- package/lib/ps/isWin.js +3 -1
- package/lib/ps/isWin.mjs +8 -4
- package/lib/ps/table-parser.cjs +167 -159
- package/lib/ps/table-parser.d.ts +5 -0
- package/lib/ps/table-parser.js +10 -4
- package/lib/ps/table-parser.mjs +9 -5
- package/lib/remove-module.cjs +262 -0
- package/lib/remove-module.d.mts +1 -0
- package/lib/remove-module.mjs +111 -0
- package/lib/rmpath.cjs +274 -0
- package/lib/rmpath.d.mts +3 -0
- package/lib/rmpath.mjs +108 -0
- package/lib/submodule-install.cjs +264 -85
- package/lib/submodule-install.mjs +56 -7
- package/lib/submodule-remove-cli.cjs +103 -0
- package/lib/submodule-remove-cli.d.ts +1 -0
- package/lib/submodule-remove-cli.js +31 -0
- package/lib/submodule-remove-cli.mjs +28 -0
- package/lib/submodule-remove.cjs +43 -0
- package/lib/submodule-remove.d.cts +2 -0
- package/lib/submodule-remove.mjs +6 -0
- package/lib/utils/chatgpt.cjs +383 -0
- package/lib/utils/chatgpt.d.ts +31 -0
- package/lib/utils/chatgpt.js +541 -0
- package/lib/utils/chatgpt.mjs +8 -0
- package/lib/{utils.cjs → utils/index.cjs} +1 -1
- package/lib/{utils.mjs → utils/index.mjs} +2 -2
- package/lib/yarn-reinstall.cjs +172 -38
- package/lib/yarn-reinstall.mjs +2 -2
- package/package.json +91 -71
- package/readme.md +43 -69
- package/releases/readme.md +36 -0
- package/test/README.md +101 -0
- package/test/package.json +2 -1
- package/test-project/readme.md +26 -0
- package/tmp/test-repo/README.md +35 -0
- package/tmp/typedoc/readme.md +320 -0
- package/bin/bash-dummy +0 -56
- package/bin/bash-dummy.cmd +0 -25
- package/bin/dir-tree.cmd +0 -7
- package/bin/git-diff +0 -4
- package/bin/git-diff.cmd +0 -7
- package/bin/git-fix +0 -36
- package/bin/git-fix.cmd +0 -7
- package/bin/rmpath +0 -70
- package/bin/submodule-install.txt +0 -118
- package/bin/submodule-remove +0 -46
- package/bin/submodule.txt +0 -172
- package/lib/binary-collections-config.d.mts +0 -18
- package/lib/binary-collections-config.js +0 -39
- package/lib/binary-collections.d.mts +0 -121
- package/lib/binary-collections.d.ts +0 -121
- package/lib/chunk-DPKAJKFO.mjs +0 -171
- package/lib/chunk-G3THLIDT.mjs +0 -200
- package/lib/chunk-W3ENOM53.mjs +0 -18
- package/lib/clean-github-actions-caches.d.mts +0 -169
- package/lib/clean-github-actions-caches.d.ts +0 -169
- package/lib/del-gradle.d.mts +0 -2
- package/lib/del-node-modules.d.mts +0 -2
- package/lib/del-ps.d.mts +0 -2
- package/lib/del-yarn-caches.d.mts +0 -2
- package/lib/find-node-modules-cli.d.mts +0 -1
- package/lib/find-node-modules.d.mts +0 -13
- package/lib/find-node-modules.js +0 -53
- package/lib/git/line-endings.d.mts +0 -83
- package/lib/git/line-endings.d.ts +0 -83
- package/lib/git/normalize.d.mts +0 -43
- package/lib/git/normalize.d.ts +0 -43
- package/lib/git/permissions.d.mts +0 -17
- package/lib/git/permissions.d.ts +0 -17
- package/lib/git/pull-strategy.d.mts +0 -15
- package/lib/git/pull-strategy.d.ts +0 -15
- package/lib/git/user-config.d.mts +0 -105
- package/lib/git/user-config.d.ts +0 -105
- package/lib/git/utils.d.mts +0 -69
- package/lib/git/utils.d.ts +0 -69
- package/lib/git-diff.d.mts +0 -84
- package/lib/git-fix.d.mts +0 -141
- package/lib/git-fix.d.ts +0 -141
- package/lib/git-purge.d.mts +0 -2
- package/lib/git-purge.js +0 -59
- package/lib/index.d.mts +0 -1
- package/lib/npm-run-series.d.mts +0 -1
- package/lib/npm-run-series.d.ts +0 -2
- package/lib/npm-run-series.js +0 -86
- package/lib/package-resolutions-updater.d.ts +0 -326
- package/lib/print-directory-tree.d.mts +0 -234
- package/lib/print-directory-tree.d.ts +0 -234
- package/lib/ps/connected-domain.d.mts +0 -3
- package/lib/ps/index.d.d.mts +0 -26
- package/lib/ps/index.d.d.ts +0 -26
- package/lib/ps/index.d.mts +0 -26
- package/lib/ps/isWin.d.mts +0 -3
- package/lib/ps/table-parser.d.mts +0 -3
- package/lib/submodule-install.d.mts +0 -121
- package/lib/submodule-install.d.ts +0 -121
- package/lib/utils.d.mts +0 -40
- package/lib/utils.js +0 -181
- package/lib/yarn-reinstall.d.mts +0 -49
- package/lib/yarn-reinstall.d.ts +0 -49
- package/src/package-resolutions-updater.mjs +0 -325
- package/src/print-directory-tree.cjs +0 -234
- package/src/ps/index.js +0 -286
- package/src/yarn-reinstall.cjs +0 -49
- /package/{bin → binaries}/nodekill +0 -0
- /package/{bin → binaries}/nodekill.cmd +0 -0
- /package/lib/{binary-collections-config.d.ts → binary-collections-config.d.cts} +0 -0
- /package/lib/{git-purge.d.ts → changelog.d.cts} +0 -0
- /package/lib/{git-diff.d.cts → npm-run-series.d.cts} +0 -0
- /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
|
+
});
|
package/lib/rmpath.d.mts
ADDED