binary-collections 2.0.10 → 2.0.11
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/.puppeterrc.cjs +25 -0
- package/binaries/binary-executor.cjs +138 -3
- package/binaries/clean-nodemodule.cjs +138 -3
- package/binaries/clean-nodemodules.cjs +138 -3
- package/binaries/dev.cjs +138 -3
- package/binaries/empty.cjs +138 -3
- package/binaries/git-reduce-size.cjs +138 -3
- package/binaries/javakill.cjs +138 -3
- package/binaries/kill-night-crows.bat +7 -0
- package/binaries/kill-night-crows.ps1 +172 -0
- package/binaries/kill-process.cjs +138 -3
- package/binaries/nodekill.cjs +138 -3
- package/binaries/prod.cjs +138 -3
- package/binaries/py +111 -0
- package/binaries/py.cjs +178 -0
- package/binaries/py.cmd +49 -0
- package/binaries/rmfind.cjs +138 -3
- package/binaries/rmx.cjs +138 -3
- package/binaries/submodule-token.cjs +138 -3
- package/binaries/test-cjs +10 -0
- package/binaries/test-cjs.cjs +178 -0
- package/binaries/test-cjs.cmd +11 -0
- package/binaries/yarn-clean +32 -0
- package/binaries/yarn-clean.cjs +178 -0
- package/binaries/yarn-clean.cmd +30 -0
- package/binaries/yarn-clean.py +148 -0
- package/lib/binary-collections-config.cjs +1 -1
- package/lib/binary-collections-config.mjs +1 -1
- package/lib/binary-collections.cjs +167 -106
- package/lib/binary-collections.mjs +108 -94
- package/lib/changelog.cjs +61 -13
- package/lib/changelog.mjs +1 -1
- package/lib/{chunk-AI4CVPJ7.mjs → chunk-2CBJCW7E.mjs} +4 -4
- package/lib/chunk-34IQDTLZ.mjs +27 -0
- package/lib/chunk-3HFFECCI.mjs +27 -0
- package/lib/{chunk-SBNDSKG5.mjs → chunk-4UHL4WVN.mjs} +1 -1
- package/lib/chunk-7XTEJHOE.mjs +193 -0
- package/lib/chunk-AJDD5DZM.mjs +109 -0
- package/lib/chunk-BZWVHODJ.mjs +62 -0
- package/lib/{chunk-BEZKJ25G.mjs → chunk-FCDQGYBF.mjs} +5 -9
- package/lib/chunk-GEYA2USY.mjs +207 -0
- package/lib/chunk-ID2WBTE2.mjs +80 -0
- package/lib/chunk-JXFOHKDM.mjs +239 -0
- package/lib/{chunk-DI5MDPSN.mjs → chunk-N436BNBK.mjs} +192 -64
- package/lib/chunk-NCXAP7AA.mjs +31 -0
- package/lib/chunk-PDN26I7O.mjs +188 -0
- package/lib/{chunk-E6FDDAOO.mjs → chunk-RWLXRTYP.mjs} +1 -1
- package/lib/{chunk-BDCHCWHD.mjs → chunk-TOIVAQF7.mjs} +4 -4
- package/lib/chunk-V5SKYJUB.mjs +136 -0
- package/lib/{chunk-HMRMTYZM.mjs → chunk-WSRETQCA.mjs} +21 -2
- package/lib/chunk-XA3SNBPA.mjs +184 -0
- package/lib/chunk-YYLIQQKF.mjs +31 -0
- package/lib/{chunk-V3N3JEUF.mjs → chunk-Z6JLYU2J.mjs} +60 -13
- package/lib/{chunk-O6SWBEOQ.mjs → chunk-ZDMWBSYF.mjs} +2 -2
- package/lib/clean-github-actions-caches.cjs +63 -15
- package/lib/clean-github-actions-caches.mjs +3 -3
- package/lib/del-gradle.cjs +61 -13
- package/lib/del-gradle.js +1 -0
- package/lib/del-gradle.mjs +1 -1
- package/lib/del-node-modules.cjs +143 -148
- package/lib/del-node-modules.js +210 -14
- package/lib/del-node-modules.mjs +148 -17
- package/lib/del-ps.cjs +61 -13
- package/lib/del-ps.js +1 -0
- package/lib/del-ps.mjs +1 -1
- package/lib/del-yarn-caches.cjs +61 -13
- package/lib/del-yarn-caches.mjs +1 -1
- package/lib/find-node-modules-cli.js +1 -0
- package/lib/free-chatgpt.cjs +253 -47
- package/lib/free-chatgpt.mjs +2 -2
- package/lib/git/gitattributes.cjs +1 -0
- package/lib/git/gitattributes.d.cts +7 -2
- package/lib/git/gitattributes.mjs +1 -1
- package/lib/git/line-endings.cjs +2 -1
- package/lib/git/line-endings.mjs +2 -2
- package/lib/git/undo-commit-cli.cjs +110 -0
- package/lib/git/undo-commit-cli.d.ts +1 -0
- package/lib/git/undo-commit-cli.js +4 -0
- package/lib/git/undo-commit-cli.mjs +14 -0
- package/lib/git/undo-commit.cjs +81 -0
- package/lib/git/undo-commit.d.cts +1 -0
- package/lib/git/undo-commit.mjs +7 -0
- package/lib/git/undo-staged-cli.cjs +110 -0
- package/lib/git/undo-staged-cli.d.ts +1 -0
- package/lib/git/undo-staged-cli.js +4 -0
- package/lib/git/undo-staged-cli.mjs +14 -0
- package/lib/git/undo-staged.cjs +81 -0
- package/lib/git/undo-staged.d.cts +1 -0
- package/lib/git/undo-staged.mjs +7 -0
- package/lib/git/user-config.cjs +61 -14
- package/lib/git/user-config.mjs +2 -2
- package/lib/git-diff-cli.cjs +255 -49
- package/lib/git-diff-cli.d.ts +1 -0
- package/lib/git-diff-cli.js +1 -0
- package/lib/git-diff-cli.mjs +5 -4
- package/lib/git-diff.cjs +254 -49
- package/lib/git-diff.mjs +4 -4
- package/lib/git-fix.cjs +64 -16
- package/lib/git-fix.mjs +10 -10
- package/lib/git-purge.cjs +61 -13
- package/lib/git-purge.mjs +1 -1
- package/lib/kill-night-crows.cjs +87 -0
- package/lib/kill-night-crows.d.mts +1 -0
- package/lib/kill-night-crows.mjs +65 -0
- package/lib/npm-run-series.cjs +60 -13
- package/lib/npm-run-series.mjs +1 -1
- package/lib/package-resolutions-updater-cli.cjs +560 -0
- package/lib/package-resolutions-updater-cli.d.mts +1 -0
- package/lib/package-resolutions-updater-cli.mjs +124 -0
- package/lib/package-resolutions-updater.cjs +174 -154
- package/lib/package-resolutions-updater.d.mts +32 -1
- package/lib/package-resolutions-updater.mjs +16 -294
- package/lib/php-cs-fixer-staged.cjs +105 -0
- package/lib/php-cs-fixer-staged.d.cts +2 -0
- package/lib/php-cs-fixer-staged.mjs +117 -0
- package/lib/print-directory-tree.cjs +62 -14
- package/lib/print-directory-tree.mjs +2 -2
- package/lib/ps/connected-domain.d.ts +1 -1
- package/lib/ps/index.js +1 -0
- package/lib/remove-module.cjs +61 -13
- package/lib/remove-module.mjs +1 -1
- package/lib/rmpath.cjs +63 -15
- package/lib/rmpath.mjs +2 -2
- package/lib/submodule-install.cjs +62 -15
- package/lib/submodule-install.mjs +3 -3
- package/lib/submodule-remove-cli.cjs +5 -1
- package/lib/submodule-remove-cli.mjs +1 -1
- package/lib/submodule-remove.cjs +4 -1
- package/lib/submodule-remove.mjs +1 -1
- package/lib/utils/chatgpt.cjs +192 -34
- package/lib/utils/chatgpt.js +210 -43
- package/lib/utils/chatgpt.mjs +1 -1
- package/lib/utils/findEnvFiles.cjs +107 -0
- package/lib/utils/findEnvFiles.d.ts +8 -0
- package/lib/utils/findEnvFiles.js +121 -0
- package/lib/utils/findEnvFiles.mjs +8 -0
- package/lib/utils/findWorkspaceRoot.cjs +70 -0
- package/lib/utils/findWorkspaceRoot.d.ts +9 -0
- package/lib/utils/findWorkspaceRoot.js +57 -0
- package/lib/utils/findWorkspaceRoot.mjs +40 -0
- package/lib/utils/index.cjs +60 -13
- package/lib/utils/index.mjs +1 -1
- package/lib/utils/isGithubTokenValid.cjs +64 -0
- package/lib/utils/isGithubTokenValid.d.ts +7 -0
- package/lib/utils/isGithubTokenValid.js +48 -0
- package/lib/utils/isGithubTokenValid.mjs +36 -0
- package/lib/yarn-reinstall.cjs +61 -13
- package/lib/yarn-reinstall.mjs +1 -1
- package/package.json +107 -93
- package/readme.md +33 -34
- package/releases/readme.md +1 -1
- package/requirements.txt +1 -0
- package/lib/chunk-4EWQC6GZ.mjs +0 -382
- package/lib/chunk-4ZI7BQKQ.mjs +0 -381
- package/lib/chunk-5J2BEPY5.mjs +0 -83
- package/lib/chunk-AGZYRDC2.mjs +0 -323
- package/lib/chunk-HN52G2YL.mjs +0 -305
- package/lib/chunk-HO6GHCOB.mjs +0 -385
- package/lib/chunk-LEM5OMRP.mjs +0 -384
- package/lib/chunk-RCP7DHVY.mjs +0 -190
- package/lib/chunk-U6SO4QEV.mjs +0 -320
- package/lib/chunk-XD6BJK6Q.mjs +0 -351
- package/lib/chunk-YXSFGA2D.mjs +0 -383
- package/lib/git/gitattributes.d.ts +0 -33
- package/lib/git/gitattributes.js +0 -223
package/lib/del-node-modules.js
CHANGED
|
@@ -1,15 +1,211 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
});
|
|
10
|
+
};
|
|
11
|
+
const fs = require("fs");
|
|
12
|
+
const fsp = fs.promises;
|
|
13
|
+
const path = require("path");
|
|
14
|
+
const os = require("os");
|
|
15
|
+
const minimist = require("minimist");
|
|
16
|
+
// ----------------------
|
|
17
|
+
// CLI
|
|
18
|
+
// ----------------------
|
|
19
|
+
const argv = minimist(process.argv.slice(2), {
|
|
20
|
+
boolean: ["force", "help"],
|
|
21
|
+
alias: { h: "help", f: "force", c: "concurrent" },
|
|
22
|
+
default: { force: false, concurrent: 2 }
|
|
14
23
|
});
|
|
15
|
-
|
|
24
|
+
if (argv.help) {
|
|
25
|
+
console.log(`Usage: clean-node [--force] [-c|--concurrent N]
|
|
26
|
+
By default runs in dry-run mode. Use --force to actually delete.
|
|
27
|
+
Use -c/--concurrent to set concurrent removals (default 2).`);
|
|
28
|
+
process.exit(0);
|
|
29
|
+
}
|
|
30
|
+
const DRY_RUN = !argv.force;
|
|
31
|
+
const defaultConcurrency = Math.max(2, os.cpus().length || 2);
|
|
32
|
+
const CONCURRENCY = Math.max(1, Number(argv.concurrent || argv.c || defaultConcurrency));
|
|
33
|
+
// ----------------------
|
|
34
|
+
// CONSTANTS
|
|
35
|
+
// ----------------------
|
|
36
|
+
const customChars = "@.";
|
|
37
|
+
const vowels = "aeiouAEIOU";
|
|
38
|
+
const alnum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
39
|
+
const combined = alnum + vowels + customChars;
|
|
40
|
+
const ROOT = process.cwd();
|
|
41
|
+
// ----------------------
|
|
42
|
+
// HELPERS
|
|
43
|
+
// ----------------------
|
|
44
|
+
function isSymlinkAsync(p) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
try {
|
|
47
|
+
return (yield fsp.lstat(p)).isSymbolicLink();
|
|
48
|
+
}
|
|
49
|
+
catch (_a) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function removeAsync(target) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
if (yield isSymlinkAsync(target)) {
|
|
57
|
+
console.log("Skipping symlink", target);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (DRY_RUN) {
|
|
61
|
+
console.log("Would remove", target);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
yield fsp.rm(target, { recursive: true, force: true });
|
|
66
|
+
console.log("Deleting", target);
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
console.error("Failed:", target, e.message);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function runWithConcurrency(tasks, concurrency) {
|
|
74
|
+
return new Promise((resolve, reject) => {
|
|
75
|
+
let i = 0;
|
|
76
|
+
let active = 0;
|
|
77
|
+
let done = 0;
|
|
78
|
+
const total = tasks.length;
|
|
79
|
+
if (total === 0)
|
|
80
|
+
return resolve();
|
|
81
|
+
function next() {
|
|
82
|
+
if (done === total)
|
|
83
|
+
return resolve();
|
|
84
|
+
while (active < concurrency && i < total) {
|
|
85
|
+
const idx = i++;
|
|
86
|
+
active++;
|
|
87
|
+
Promise.resolve()
|
|
88
|
+
.then(() => tasks[idx]())
|
|
89
|
+
.then(() => {
|
|
90
|
+
active--;
|
|
91
|
+
done++;
|
|
92
|
+
next();
|
|
93
|
+
})
|
|
94
|
+
.catch((err) => reject(err));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
next();
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
// `removeAsync` is the single deletion path; synchronous removals were
|
|
101
|
+
// removed in favor of collecting targets and executing them with
|
|
102
|
+
// `runWithConcurrency` so all deletions respect `DRY_RUN` and concurrency.
|
|
103
|
+
/**
|
|
104
|
+
* Walk (no symlink traversal)
|
|
105
|
+
*/
|
|
106
|
+
function walk(dir, callback, { skipNodeModulesChildren = false } = {}) {
|
|
107
|
+
let entries;
|
|
108
|
+
try {
|
|
109
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
110
|
+
}
|
|
111
|
+
catch (_a) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
for (const entry of entries) {
|
|
115
|
+
const fullPath = path.join(dir, entry.name);
|
|
116
|
+
// 🚫 never follow symlinks
|
|
117
|
+
if (entry.isSymbolicLink())
|
|
118
|
+
continue;
|
|
119
|
+
// skip inside node_modules/*
|
|
120
|
+
if (skipNodeModulesChildren && dir.includes("node_modules"))
|
|
121
|
+
continue;
|
|
122
|
+
callback(fullPath, entry);
|
|
123
|
+
if (entry.isDirectory()) {
|
|
124
|
+
if (skipNodeModulesChildren && entry.name === "node_modules") {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
walk(fullPath, callback, { skipNodeModulesChildren });
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
// ----------------------
|
|
132
|
+
// NODE_MODULES HANDLER
|
|
133
|
+
// ----------------------
|
|
134
|
+
function processNodeModules(dir) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
console.log("Found:", dir);
|
|
137
|
+
let items;
|
|
138
|
+
try {
|
|
139
|
+
items = fs.readdirSync(dir, { withFileTypes: true });
|
|
140
|
+
}
|
|
141
|
+
catch (_a) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
// determine targets whose first char is in the allowed combined set
|
|
145
|
+
const targets = items.filter((entry) => entry.name.length && combined.includes(entry.name[0]));
|
|
146
|
+
const tasks = targets.map((entry) => () => __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
const name = entry.name;
|
|
148
|
+
const target = path.join(dir, name);
|
|
149
|
+
// 🚫 skip symlinks entirely (Dirent gives this cheaply)
|
|
150
|
+
if (entry.isSymbolicLink && entry.isSymbolicLink()) {
|
|
151
|
+
console.log("Skipping symlink", target);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
yield removeAsync(target);
|
|
155
|
+
}));
|
|
156
|
+
// run with limited concurrency
|
|
157
|
+
yield runWithConcurrency(tasks, CONCURRENCY);
|
|
158
|
+
yield removeAsync(dir);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
// ----------------------
|
|
162
|
+
// MAIN
|
|
163
|
+
// ----------------------
|
|
164
|
+
function main() {
|
|
165
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
+
const nodeModulesDirs = [];
|
|
167
|
+
// find node_modules
|
|
168
|
+
walk(ROOT, (fullPath, entry) => {
|
|
169
|
+
if (entry.isDirectory() && entry.name === "node_modules") {
|
|
170
|
+
nodeModulesDirs.push(fullPath);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
for (const dir of nodeModulesDirs) {
|
|
174
|
+
// process each node_modules directory, await to avoid too many parallel top-level ops
|
|
175
|
+
// (internals already limit concurrency)
|
|
176
|
+
yield processNodeModules(dir);
|
|
177
|
+
}
|
|
178
|
+
// collect package/yarn targets then remove them with concurrency
|
|
179
|
+
const packageLocks = [];
|
|
180
|
+
const yarnLocks = [];
|
|
181
|
+
const yarnCaches = [];
|
|
182
|
+
walk(ROOT, (fullPath, entry) => {
|
|
183
|
+
const base = path.basename(fullPath);
|
|
184
|
+
if (base === "package-lock.json")
|
|
185
|
+
packageLocks.push(fullPath);
|
|
186
|
+
if (base === "yarn.lock")
|
|
187
|
+
yarnLocks.push(fullPath);
|
|
188
|
+
if (entry.isDirectory() && fullPath.endsWith(path.join(".yarn", "cache")))
|
|
189
|
+
yarnCaches.push(fullPath);
|
|
190
|
+
}, { skipNodeModulesChildren: true });
|
|
191
|
+
if (DRY_RUN) {
|
|
192
|
+
console.log("Would remove package-lock.json files:");
|
|
193
|
+
for (const p of packageLocks)
|
|
194
|
+
console.log(p);
|
|
195
|
+
console.log("Would remove yarn.lock files:");
|
|
196
|
+
for (const p of yarnLocks)
|
|
197
|
+
console.log(p);
|
|
198
|
+
console.log("Would remove .yarn/cache directories:");
|
|
199
|
+
for (const p of yarnCaches)
|
|
200
|
+
console.log(p);
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
const allTasks = [];
|
|
204
|
+
allTasks.push(...packageLocks.map((p) => () => __awaiter(this, void 0, void 0, function* () { return removeAsync(p); })));
|
|
205
|
+
allTasks.push(...yarnLocks.map((p) => () => __awaiter(this, void 0, void 0, function* () { return removeAsync(p); })));
|
|
206
|
+
allTasks.push(...yarnCaches.map((p) => () => __awaiter(this, void 0, void 0, function* () { return removeAsync(p); })));
|
|
207
|
+
yield runWithConcurrency(allTasks, CONCURRENCY);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
main();
|
package/lib/del-node-modules.mjs
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
require_utils
|
|
4
|
-
} from "./chunk-V3N3JEUF.mjs";
|
|
5
2
|
import {
|
|
6
3
|
__require,
|
|
7
4
|
init_esm_shims
|
|
@@ -9,18 +6,152 @@ import {
|
|
|
9
6
|
|
|
10
7
|
// src/del-node-modules.js
|
|
11
8
|
init_esm_shims();
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var g3 = new glob.Glob("**/node_modules", {
|
|
22
|
-
withFileTypes: false,
|
|
23
|
-
cwd: process.cwd(),
|
|
24
|
-
ignore: globalIgnore
|
|
9
|
+
var fs = __require("fs");
|
|
10
|
+
var fsp = fs.promises;
|
|
11
|
+
var path = __require("path");
|
|
12
|
+
var os = __require("os");
|
|
13
|
+
var minimist = __require("minimist");
|
|
14
|
+
var argv = minimist(process.argv.slice(2), {
|
|
15
|
+
boolean: ["force", "help"],
|
|
16
|
+
alias: { h: "help", f: "force", c: "concurrent" },
|
|
17
|
+
default: { force: false, concurrent: 2 }
|
|
25
18
|
});
|
|
26
|
-
|
|
19
|
+
if (argv.help) {
|
|
20
|
+
console.log(`Usage: clean-node [--force] [-c|--concurrent N]
|
|
21
|
+
By default runs in dry-run mode. Use --force to actually delete.
|
|
22
|
+
Use -c/--concurrent to set concurrent removals (default 2).`);
|
|
23
|
+
process.exit(0);
|
|
24
|
+
}
|
|
25
|
+
var DRY_RUN = !argv.force;
|
|
26
|
+
var defaultConcurrency = Math.max(2, os.cpus().length || 2);
|
|
27
|
+
var CONCURRENCY = Math.max(1, Number(argv.concurrent || argv.c || defaultConcurrency));
|
|
28
|
+
var customChars = "@.";
|
|
29
|
+
var vowels = "aeiouAEIOU";
|
|
30
|
+
var alnum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
31
|
+
var combined = alnum + vowels + customChars;
|
|
32
|
+
var ROOT = process.cwd();
|
|
33
|
+
async function isSymlinkAsync(p) {
|
|
34
|
+
try {
|
|
35
|
+
return (await fsp.lstat(p)).isSymbolicLink();
|
|
36
|
+
} catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async function removeAsync(target) {
|
|
41
|
+
if (await isSymlinkAsync(target)) {
|
|
42
|
+
console.log("Skipping symlink", target);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (DRY_RUN) {
|
|
46
|
+
console.log("Would remove", target);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
await fsp.rm(target, { recursive: true, force: true });
|
|
51
|
+
console.log("Deleting", target);
|
|
52
|
+
} catch (e) {
|
|
53
|
+
console.error("Failed:", target, e.message);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function runWithConcurrency(tasks, concurrency) {
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
let i = 0;
|
|
59
|
+
let active = 0;
|
|
60
|
+
let done = 0;
|
|
61
|
+
const total = tasks.length;
|
|
62
|
+
if (total === 0) return resolve();
|
|
63
|
+
function next() {
|
|
64
|
+
if (done === total) return resolve();
|
|
65
|
+
while (active < concurrency && i < total) {
|
|
66
|
+
const idx = i++;
|
|
67
|
+
active++;
|
|
68
|
+
Promise.resolve().then(() => tasks[idx]()).then(() => {
|
|
69
|
+
active--;
|
|
70
|
+
done++;
|
|
71
|
+
next();
|
|
72
|
+
}).catch((err) => reject(err));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
next();
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function walk(dir, callback, { skipNodeModulesChildren = false } = {}) {
|
|
79
|
+
let entries;
|
|
80
|
+
try {
|
|
81
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
82
|
+
} catch {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
for (const entry of entries) {
|
|
86
|
+
const fullPath = path.join(dir, entry.name);
|
|
87
|
+
if (entry.isSymbolicLink()) continue;
|
|
88
|
+
if (skipNodeModulesChildren && dir.includes("node_modules")) continue;
|
|
89
|
+
callback(fullPath, entry);
|
|
90
|
+
if (entry.isDirectory()) {
|
|
91
|
+
if (skipNodeModulesChildren && entry.name === "node_modules") {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
walk(fullPath, callback, { skipNodeModulesChildren });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async function processNodeModules(dir) {
|
|
99
|
+
console.log("Found:", dir);
|
|
100
|
+
let items;
|
|
101
|
+
try {
|
|
102
|
+
items = fs.readdirSync(dir, { withFileTypes: true });
|
|
103
|
+
} catch {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const targets = items.filter((entry) => entry.name.length && combined.includes(entry.name[0]));
|
|
107
|
+
const tasks = targets.map((entry) => async () => {
|
|
108
|
+
const name = entry.name;
|
|
109
|
+
const target = path.join(dir, name);
|
|
110
|
+
if (entry.isSymbolicLink && entry.isSymbolicLink()) {
|
|
111
|
+
console.log("Skipping symlink", target);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
await removeAsync(target);
|
|
115
|
+
});
|
|
116
|
+
await runWithConcurrency(tasks, CONCURRENCY);
|
|
117
|
+
await removeAsync(dir);
|
|
118
|
+
}
|
|
119
|
+
async function main() {
|
|
120
|
+
const nodeModulesDirs = [];
|
|
121
|
+
walk(ROOT, (fullPath, entry) => {
|
|
122
|
+
if (entry.isDirectory() && entry.name === "node_modules") {
|
|
123
|
+
nodeModulesDirs.push(fullPath);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
for (const dir of nodeModulesDirs) {
|
|
127
|
+
await processNodeModules(dir);
|
|
128
|
+
}
|
|
129
|
+
const packageLocks = [];
|
|
130
|
+
const yarnLocks = [];
|
|
131
|
+
const yarnCaches = [];
|
|
132
|
+
walk(
|
|
133
|
+
ROOT,
|
|
134
|
+
(fullPath, entry) => {
|
|
135
|
+
const base = path.basename(fullPath);
|
|
136
|
+
if (base === "package-lock.json") packageLocks.push(fullPath);
|
|
137
|
+
if (base === "yarn.lock") yarnLocks.push(fullPath);
|
|
138
|
+
if (entry.isDirectory() && fullPath.endsWith(path.join(".yarn", "cache"))) yarnCaches.push(fullPath);
|
|
139
|
+
},
|
|
140
|
+
{ skipNodeModulesChildren: true }
|
|
141
|
+
);
|
|
142
|
+
if (DRY_RUN) {
|
|
143
|
+
console.log("Would remove package-lock.json files:");
|
|
144
|
+
for (const p of packageLocks) console.log(p);
|
|
145
|
+
console.log("Would remove yarn.lock files:");
|
|
146
|
+
for (const p of yarnLocks) console.log(p);
|
|
147
|
+
console.log("Would remove .yarn/cache directories:");
|
|
148
|
+
for (const p of yarnCaches) console.log(p);
|
|
149
|
+
} else {
|
|
150
|
+
const allTasks = [];
|
|
151
|
+
allTasks.push(...packageLocks.map((p) => async () => removeAsync(p)));
|
|
152
|
+
allTasks.push(...yarnLocks.map((p) => async () => removeAsync(p)));
|
|
153
|
+
allTasks.push(...yarnCaches.map((p) => async () => removeAsync(p)));
|
|
154
|
+
await runWithConcurrency(allTasks, CONCURRENCY);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
main();
|
package/lib/del-ps.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -97,31 +98,78 @@ var require_utils = __commonJS({
|
|
|
97
98
|
}
|
|
98
99
|
module2.exports.getArgs = getArgs2;
|
|
99
100
|
function del(fullPath) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
try {
|
|
102
|
+
if (!fs.existsSync(fullPath)) return;
|
|
103
|
+
const stat = fs.lstatSync(fullPath);
|
|
104
|
+
if (stat.isSymbolicLink()) {
|
|
105
|
+
try {
|
|
106
|
+
fs.unlinkSync(fullPath);
|
|
107
|
+
console.log("deleted symlink", fullPath);
|
|
108
|
+
} catch (e) {
|
|
109
|
+
console.log("failed delete symlink", fullPath, e && e.message);
|
|
110
|
+
}
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (stat.isDirectory()) {
|
|
114
|
+
const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
|
|
115
|
+
for (let i = 0; i < subdir.length; i++) {
|
|
116
|
+
del(subdir[i]);
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
fs.rmdirSync(fullPath);
|
|
120
|
+
console.log("deleted", fullPath);
|
|
121
|
+
} catch (e) {
|
|
122
|
+
try {
|
|
123
|
+
fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
124
|
+
console.log("deleted", fullPath);
|
|
125
|
+
} catch (ee) {
|
|
126
|
+
console.log("failed delete", fullPath, ee && ee.message);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return;
|
|
104
130
|
}
|
|
105
|
-
} else {
|
|
106
131
|
try {
|
|
107
|
-
fs.
|
|
132
|
+
fs.unlinkSync(fullPath);
|
|
108
133
|
console.log("deleted", fullPath);
|
|
109
|
-
} catch (
|
|
110
|
-
|
|
134
|
+
} catch (e) {
|
|
135
|
+
try {
|
|
136
|
+
fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
137
|
+
console.log("deleted", fullPath);
|
|
138
|
+
} catch (ee) {
|
|
139
|
+
console.log("failed delete", fullPath, ee && ee.message);
|
|
140
|
+
}
|
|
111
141
|
}
|
|
142
|
+
} catch (err) {
|
|
143
|
+
console.log("failed delete", fullPath, err && err.message);
|
|
112
144
|
}
|
|
113
145
|
}
|
|
114
146
|
module2.exports.del = del;
|
|
115
147
|
function delStream(globStream) {
|
|
116
148
|
globStream.stream().on("data", (result) => {
|
|
117
149
|
const fullPath = path.resolve(process.cwd(), result);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
150
|
+
try {
|
|
151
|
+
if (fs.existsSync(fullPath)) {
|
|
152
|
+
const stat = fs.lstatSync(fullPath);
|
|
153
|
+
if (stat.isSymbolicLink()) {
|
|
154
|
+
try {
|
|
155
|
+
fs.unlinkSync(fullPath);
|
|
156
|
+
console.log("deleted symlink", fullPath);
|
|
157
|
+
} catch (e) {
|
|
158
|
+
console.log("failed delete symlink", fullPath, e && e.message);
|
|
159
|
+
}
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (stat.isDirectory()) {
|
|
163
|
+
const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
|
|
164
|
+
for (let i = 0; i < subdir.length; i++) {
|
|
165
|
+
del(subdir[i]);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
122
168
|
}
|
|
169
|
+
del(fullPath);
|
|
170
|
+
} catch (err) {
|
|
171
|
+
console.log("failed processing", fullPath, err && err.message);
|
|
123
172
|
}
|
|
124
|
-
del(fullPath);
|
|
125
173
|
});
|
|
126
174
|
}
|
|
127
175
|
module2.exports.delStream = delStream;
|
package/lib/del-ps.js
CHANGED
package/lib/del-ps.mjs
CHANGED
package/lib/del-yarn-caches.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -88,31 +89,78 @@ var require_utils = __commonJS({
|
|
|
88
89
|
}
|
|
89
90
|
module2.exports.getArgs = getArgs;
|
|
90
91
|
function del(fullPath) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
try {
|
|
93
|
+
if (!fs.existsSync(fullPath)) return;
|
|
94
|
+
const stat = fs.lstatSync(fullPath);
|
|
95
|
+
if (stat.isSymbolicLink()) {
|
|
96
|
+
try {
|
|
97
|
+
fs.unlinkSync(fullPath);
|
|
98
|
+
console.log("deleted symlink", fullPath);
|
|
99
|
+
} catch (e) {
|
|
100
|
+
console.log("failed delete symlink", fullPath, e && e.message);
|
|
101
|
+
}
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (stat.isDirectory()) {
|
|
105
|
+
const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
|
|
106
|
+
for (let i = 0; i < subdir.length; i++) {
|
|
107
|
+
del(subdir[i]);
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
fs.rmdirSync(fullPath);
|
|
111
|
+
console.log("deleted", fullPath);
|
|
112
|
+
} catch (e) {
|
|
113
|
+
try {
|
|
114
|
+
fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
115
|
+
console.log("deleted", fullPath);
|
|
116
|
+
} catch (ee) {
|
|
117
|
+
console.log("failed delete", fullPath, ee && ee.message);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return;
|
|
95
121
|
}
|
|
96
|
-
} else {
|
|
97
122
|
try {
|
|
98
|
-
fs.
|
|
123
|
+
fs.unlinkSync(fullPath);
|
|
99
124
|
console.log("deleted", fullPath);
|
|
100
|
-
} catch (
|
|
101
|
-
|
|
125
|
+
} catch (e) {
|
|
126
|
+
try {
|
|
127
|
+
fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
128
|
+
console.log("deleted", fullPath);
|
|
129
|
+
} catch (ee) {
|
|
130
|
+
console.log("failed delete", fullPath, ee && ee.message);
|
|
131
|
+
}
|
|
102
132
|
}
|
|
133
|
+
} catch (err) {
|
|
134
|
+
console.log("failed delete", fullPath, err && err.message);
|
|
103
135
|
}
|
|
104
136
|
}
|
|
105
137
|
module2.exports.del = del;
|
|
106
138
|
function delStream2(globStream) {
|
|
107
139
|
globStream.stream().on("data", (result) => {
|
|
108
140
|
const fullPath = path.resolve(process.cwd(), result);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
141
|
+
try {
|
|
142
|
+
if (fs.existsSync(fullPath)) {
|
|
143
|
+
const stat = fs.lstatSync(fullPath);
|
|
144
|
+
if (stat.isSymbolicLink()) {
|
|
145
|
+
try {
|
|
146
|
+
fs.unlinkSync(fullPath);
|
|
147
|
+
console.log("deleted symlink", fullPath);
|
|
148
|
+
} catch (e) {
|
|
149
|
+
console.log("failed delete symlink", fullPath, e && e.message);
|
|
150
|
+
}
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (stat.isDirectory()) {
|
|
154
|
+
const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
|
|
155
|
+
for (let i = 0; i < subdir.length; i++) {
|
|
156
|
+
del(subdir[i]);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
113
159
|
}
|
|
160
|
+
del(fullPath);
|
|
161
|
+
} catch (err) {
|
|
162
|
+
console.log("failed processing", fullPath, err && err.message);
|
|
114
163
|
}
|
|
115
|
-
del(fullPath);
|
|
116
164
|
});
|
|
117
165
|
}
|
|
118
166
|
module2.exports.delStream = delStream2;
|
package/lib/del-yarn-caches.mjs
CHANGED