binary-collections 2.0.9 → 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 -105
- package/lib/binary-collections.mjs +131 -84
- package/lib/changelog.cjs +3 -3
- package/lib/changelog.mjs +177 -171
- 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 +3 -2
- 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.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 +14 -13
- 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 +5 -5
- package/lib/package-resolutions-updater.mjs +266 -309
- 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 -86
- package/lib/submodule-install.mjs +51 -3
- 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/test-repo/package.json +1 -1
- 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 -137
- package/lib/binary-collections.d.ts +0 -137
- package/lib/changelog.d.mts +0 -2
- package/lib/changelog.js +0 -226
- 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 -352
- 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 -350
- 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/{changelog.d.ts → changelog.d.cts} +0 -0
- /package/lib/{git-purge.d.ts → free-chatgpt.d.ts} +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
package/lib/rmpath.mjs
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
require_utils
|
|
4
|
+
} from "./chunk-V3N3JEUF.mjs";
|
|
5
|
+
import {
|
|
6
|
+
__require,
|
|
7
|
+
__toESM,
|
|
8
|
+
init_esm_shims
|
|
9
|
+
} from "./chunk-QQ4A6DLD.mjs";
|
|
10
|
+
|
|
11
|
+
// src/rmpath.mjs
|
|
12
|
+
init_esm_shims();
|
|
13
|
+
var import_utils = __toESM(require_utils(), 1);
|
|
14
|
+
import dotenv from "dotenv";
|
|
15
|
+
import fs from "fs-extra";
|
|
16
|
+
import * as glob from "glob";
|
|
17
|
+
import path from "upath";
|
|
18
|
+
import { fileURLToPath, pathToFileURL } from "url";
|
|
19
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
20
|
+
var __dirname = path.dirname(__filename);
|
|
21
|
+
var dotenvPath = path.resolve(process.cwd(), ".env");
|
|
22
|
+
if (fs.existsSync(dotenvPath)) {
|
|
23
|
+
dotenv.config({ path: dotenvPath });
|
|
24
|
+
}
|
|
25
|
+
var argv = (0, import_utils.getArgs)();
|
|
26
|
+
var positional = argv._ || [];
|
|
27
|
+
var deletePatterns = [];
|
|
28
|
+
function resolveDeletePatterns(targetPath) {
|
|
29
|
+
if (fs.existsSync(targetPath) && fs.lstatSync(targetPath).isFile()) {
|
|
30
|
+
deletePatterns.push(targetPath);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const vowels = ["a", "i", "u", "e", "o", "A", "I", "U", "E", "O"];
|
|
34
|
+
const letters = [];
|
|
35
|
+
for (let i = 97; i <= 122; i++) letters.push(String.fromCharCode(i));
|
|
36
|
+
for (let i = 65; i <= 90; i++) letters.push(String.fromCharCode(i));
|
|
37
|
+
for (const letter of letters) {
|
|
38
|
+
for (const vowel of vowels) {
|
|
39
|
+
deletePatterns.push(
|
|
40
|
+
`.${letter}*`,
|
|
41
|
+
`@${letter}*`,
|
|
42
|
+
`${letter}*`,
|
|
43
|
+
`@${letter}${vowel}*`,
|
|
44
|
+
`.${letter}${vowel}*`,
|
|
45
|
+
`${letter}${vowel}*`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async function deleteMatchingFiles(baseDir) {
|
|
51
|
+
for (const pattern of deletePatterns) {
|
|
52
|
+
if (fs.existsSync(pattern)) {
|
|
53
|
+
fs.rmSync(pattern, { recursive: true, force: true });
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const matches = glob.sync(path.join(baseDir, pattern), { dot: true, nocase: true });
|
|
57
|
+
for (const fpath of matches) {
|
|
58
|
+
try {
|
|
59
|
+
console.log(`deleting ${fpath}`);
|
|
60
|
+
fs.rmSync(fpath, { recursive: true, force: true });
|
|
61
|
+
} catch (_e) {
|
|
62
|
+
console.error(`cannot delete ${fpath}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async function deleteMainScript(targetPath) {
|
|
68
|
+
if (!fs.existsSync(targetPath)) {
|
|
69
|
+
targetPath = path.resolve(process.cwd(), targetPath);
|
|
70
|
+
}
|
|
71
|
+
resolveDeletePatterns(targetPath);
|
|
72
|
+
await deleteMatchingFiles(targetPath);
|
|
73
|
+
console.log(`cleaning ${targetPath}`);
|
|
74
|
+
try {
|
|
75
|
+
fs.rmSync(targetPath, { recursive: true, force: true });
|
|
76
|
+
} catch (_e) {
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
var isMain = false;
|
|
80
|
+
try {
|
|
81
|
+
if (typeof __require !== "undefined" && typeof module !== "undefined" && __require.main === module) {
|
|
82
|
+
isMain = true;
|
|
83
|
+
}
|
|
84
|
+
} catch (_e) {
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
const mainArg = process.argv[1] && path.resolve(process.argv[1]);
|
|
88
|
+
if (mainArg && import.meta.url === pathToFileURL(mainArg).href) {
|
|
89
|
+
isMain = true;
|
|
90
|
+
}
|
|
91
|
+
} catch (_e) {
|
|
92
|
+
}
|
|
93
|
+
if (isMain) {
|
|
94
|
+
console.log("Invoked from CLI");
|
|
95
|
+
if (positional.length === 0) {
|
|
96
|
+
console.error("You need to provide a file or folder path");
|
|
97
|
+
process.exit(1);
|
|
98
|
+
} else {
|
|
99
|
+
deleteMainScript(positional[0]);
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
console.log("Not invoked from CLI");
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
deleteMainScript,
|
|
106
|
+
deleteMatchingFiles,
|
|
107
|
+
resolveDeletePatterns
|
|
108
|
+
};
|
|
@@ -1,101 +1,279 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __esm = (fn, res) => function __init() {
|
|
4
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
5
|
+
};
|
|
6
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
7
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// node_modules/tsup/assets/cjs_shims.js
|
|
11
|
+
var init_cjs_shims = __esm({
|
|
12
|
+
"node_modules/tsup/assets/cjs_shims.js"() {
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// src/utils/index.cjs
|
|
17
|
+
var require_utils = __commonJS({
|
|
18
|
+
"src/utils/index.cjs"(exports2, module2) {
|
|
19
|
+
init_cjs_shims();
|
|
20
|
+
var fs2 = require("fs");
|
|
21
|
+
var path2 = require("upath");
|
|
22
|
+
var argv = require("minimist")(process.argv.slice(2));
|
|
23
|
+
var { exec } = require("child_process");
|
|
24
|
+
var { URL: URL2 } = require("url");
|
|
25
|
+
var { promisify } = require("util");
|
|
26
|
+
var execAsync = promisify(exec);
|
|
27
|
+
async function parseGitRemotes() {
|
|
28
|
+
try {
|
|
29
|
+
const { stdout } = await execAsync("git remote -v");
|
|
30
|
+
const lines = stdout.split("\n");
|
|
31
|
+
const remotes = {};
|
|
32
|
+
lines.forEach((line) => {
|
|
33
|
+
const [name, url] = line.split(" ");
|
|
34
|
+
if (name && url) {
|
|
35
|
+
const [repoUrl] = url.split(" ");
|
|
36
|
+
try {
|
|
37
|
+
const parsedUrl = new URL2(repoUrl);
|
|
38
|
+
const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
|
|
39
|
+
if (parsedUrl.hostname === "github.com" && pathParts.length === 2) {
|
|
40
|
+
let repoPath = pathParts.join("/");
|
|
41
|
+
if (repoPath.endsWith(".git")) {
|
|
42
|
+
repoPath = repoPath.slice(0, -4);
|
|
43
|
+
}
|
|
44
|
+
remotes[name] = repoPath;
|
|
45
|
+
}
|
|
46
|
+
} catch (e) {
|
|
47
|
+
console.error("URL Parsing Error:", e.message);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return remotes;
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error("Error:", error.message);
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
module2.exports.parseGitRemotes = parseGitRemotes;
|
|
58
|
+
function joinPathPreserveDriveLetter(...segments) {
|
|
59
|
+
let fullPath = require("path").join(...segments);
|
|
60
|
+
if (/^[a-z]:\\/.test(fullPath)) {
|
|
61
|
+
fullPath = fullPath.charAt(0).toUpperCase() + fullPath.slice(1);
|
|
62
|
+
}
|
|
63
|
+
return fullPath;
|
|
64
|
+
}
|
|
65
|
+
module2.exports.joinPathPreserveDriveLetter = joinPathPreserveDriveLetter;
|
|
66
|
+
function getArgs2() {
|
|
67
|
+
return argv;
|
|
68
|
+
}
|
|
69
|
+
module2.exports.getArgs = getArgs2;
|
|
70
|
+
function del(fullPath) {
|
|
71
|
+
if (fs2.statSync(fullPath).isDirectory()) {
|
|
72
|
+
const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
|
|
73
|
+
for (let i = 0; i < subdir.length; i++) {
|
|
74
|
+
del(subdir[i]);
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
try {
|
|
78
|
+
fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
79
|
+
console.log("deleted", fullPath);
|
|
80
|
+
} catch (_) {
|
|
81
|
+
console.log("failed delete", fullPath);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
module2.exports.del = del;
|
|
86
|
+
function delStream(globStream) {
|
|
87
|
+
globStream.stream().on("data", (result) => {
|
|
88
|
+
const fullPath = path2.resolve(process.cwd(), result);
|
|
89
|
+
if (fs2.statSync(fullPath).isDirectory()) {
|
|
90
|
+
const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
|
|
91
|
+
for (let i = 0; i < subdir.length; i++) {
|
|
92
|
+
del(subdir[i]);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
del(fullPath);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
module2.exports.delStream = delStream;
|
|
99
|
+
function getFileTreeString(hashArray) {
|
|
100
|
+
const tree = {};
|
|
101
|
+
const hashMap = {};
|
|
102
|
+
for (const entry of hashArray) {
|
|
103
|
+
const [filePath, hash] = entry.split(" ");
|
|
104
|
+
hashMap[filePath] = hash;
|
|
105
|
+
const parts = filePath.split("/");
|
|
106
|
+
let current = tree;
|
|
107
|
+
for (let i = 0; i < parts.length; i++) {
|
|
108
|
+
const part = parts[i];
|
|
109
|
+
if (i === parts.length - 1) {
|
|
110
|
+
current[part] = null;
|
|
111
|
+
} else {
|
|
112
|
+
current[part] = current[part] || {};
|
|
113
|
+
current = current[part];
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function printNode(node, prefix = "", parentPath = "") {
|
|
118
|
+
const keys = Object.keys(node).sort();
|
|
119
|
+
let lines = [];
|
|
120
|
+
keys.forEach((key, idx) => {
|
|
121
|
+
const isLast = idx === keys.length - 1;
|
|
122
|
+
const branch = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
123
|
+
const currentPath = parentPath ? parentPath + "/" + key : key;
|
|
124
|
+
if (node[key] === null) {
|
|
125
|
+
lines.push(prefix + branch + key + " [" + (hashMap[currentPath] || "") + "]");
|
|
126
|
+
} else {
|
|
127
|
+
lines.push(prefix + branch + key + "/");
|
|
128
|
+
lines = lines.concat(printNode(node[key], prefix + (isLast ? " " : "\u2502 "), currentPath));
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
return lines;
|
|
132
|
+
}
|
|
133
|
+
return printNode(tree, "", "").join("\n");
|
|
134
|
+
}
|
|
135
|
+
module2.exports.getFileTreeString = getFileTreeString;
|
|
136
|
+
var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
137
|
+
module2.exports.delay = delay;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// src/submodule-install.cjs
|
|
142
|
+
init_cjs_shims();
|
|
143
|
+
var { spawnSync } = require("child_process");
|
|
144
|
+
var color = require("ansi-colors");
|
|
145
|
+
var fs = require("fs");
|
|
146
|
+
var path = require("path");
|
|
147
|
+
var dotenv = require("dotenv");
|
|
148
|
+
var envPath = path.resolve(process.cwd(), ".env");
|
|
149
|
+
if (fs.existsSync(envPath)) dotenv.config({ path: envPath });
|
|
150
|
+
var { getArgs } = require_utils();
|
|
151
|
+
var args = getArgs();
|
|
152
|
+
var positional = args._ || [];
|
|
153
|
+
if (args.help || args.h) {
|
|
154
|
+
console.log();
|
|
155
|
+
console.log("Usage: submodule-install [options] [repo-path]");
|
|
156
|
+
console.log();
|
|
157
|
+
console.log("Options:");
|
|
158
|
+
console.log(" --cwd <path> Set working directory");
|
|
159
|
+
console.log(" --help, -h Show this help message");
|
|
160
|
+
console.log();
|
|
161
|
+
console.log("Description:");
|
|
162
|
+
console.log(" Installs and updates git submodules recursively, applying access tokens for private repos.");
|
|
163
|
+
console.log();
|
|
164
|
+
process.exit(0);
|
|
165
|
+
}
|
|
166
|
+
var ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
|
|
167
|
+
var ROOT = runGit(["rev-parse", "--show-toplevel"]).trim();
|
|
168
|
+
var REPO_PATH = ROOT;
|
|
17
169
|
if (args.cwd) {
|
|
18
|
-
|
|
170
|
+
ROOT = path.resolve(args.cwd);
|
|
171
|
+
} else if (positional.length > 0) {
|
|
172
|
+
ROOT = path.resolve(positional[0]);
|
|
19
173
|
}
|
|
20
|
-
|
|
21
|
-
|
|
174
|
+
var CURRENT_PATH = ROOT;
|
|
175
|
+
var VISITED_SUBMODULES = (process.env.VISITED_SUBMODULES || "").split(path.delimiter).filter(Boolean);
|
|
176
|
+
if (VISITED_SUBMODULES.includes(CURRENT_PATH)) {
|
|
177
|
+
console.log(`Skipping ${CURRENT_PATH} (already processed) to avoid recursion.`);
|
|
178
|
+
process.exit(0);
|
|
22
179
|
}
|
|
180
|
+
VISITED_SUBMODULES.push(CURRENT_PATH);
|
|
181
|
+
process.env.VISITED_SUBMODULES = VISITED_SUBMODULES.join(path.delimiter);
|
|
23
182
|
console.log(`Installing submodules at ${ROOT}`);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
])
|
|
34
|
-
.split("\n")
|
|
35
|
-
.filter(Boolean);
|
|
183
|
+
var submoduleList = runGit([
|
|
184
|
+
"-C",
|
|
185
|
+
REPO_PATH,
|
|
186
|
+
"config",
|
|
187
|
+
"-f",
|
|
188
|
+
".gitmodules",
|
|
189
|
+
"--get-regexp",
|
|
190
|
+
"^submodule\\..*\\.path$"
|
|
191
|
+
]).split("\n").filter(Boolean);
|
|
36
192
|
for (const line of submoduleList) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
193
|
+
const [KEY, MODULE_PATH] = line.trim().split(/\s+/);
|
|
194
|
+
const RELATIVE_MODULE_PATH = path.join(ROOT, MODULE_PATH);
|
|
195
|
+
if (fs.existsSync(RELATIVE_MODULE_PATH)) {
|
|
196
|
+
console.log(`Deleting ${RELATIVE_MODULE_PATH}`);
|
|
197
|
+
fs.rmSync(RELATIVE_MODULE_PATH, { recursive: true, force: true });
|
|
198
|
+
}
|
|
199
|
+
const NAME = KEY.match(/^submodule\.(.*)\.path$/)[1];
|
|
200
|
+
const URL2 = runGit(["config", "-f", ".gitmodules", "--get", `submodule.${NAME}.url`]).trim();
|
|
201
|
+
let BRANCH = "master";
|
|
202
|
+
try {
|
|
203
|
+
BRANCH = runGit(["config", "-f", ".gitmodules", "--get", `submodule.${NAME}.branch`]).trim();
|
|
204
|
+
} catch {
|
|
205
|
+
}
|
|
206
|
+
console.log(`Submodule: ${color.cyan(NAME)}`);
|
|
207
|
+
console.log(` Location: ${color.magenta(MODULE_PATH)}`);
|
|
208
|
+
console.log(` ROOT: ${color.yellow(ROOT)}`);
|
|
209
|
+
console.log(` URL: ${color.blue(URL2)}`);
|
|
210
|
+
console.log(` Branch: ${color.green(BRANCH)}`);
|
|
211
|
+
const addResult = runGit(
|
|
212
|
+
["-C", REPO_PATH, "submodule", "add", "--force", "-b", BRANCH, "--name", NAME, URL2, MODULE_PATH],
|
|
213
|
+
true
|
|
214
|
+
);
|
|
215
|
+
if (addResult.status !== 0) {
|
|
216
|
+
console.warn(`Cannot add submodule ${MODULE_PATH}`);
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
if (!fs.existsSync(RELATIVE_MODULE_PATH)) {
|
|
220
|
+
console.warn(`Submodule directory ${RELATIVE_MODULE_PATH} does not exist after add. Attempting manual clone...`);
|
|
46
221
|
try {
|
|
47
|
-
|
|
222
|
+
runGit(["clone", "--branch", BRANCH, URL2, RELATIVE_MODULE_PATH]);
|
|
223
|
+
} catch (e) {
|
|
224
|
+
console.error(`Manual clone failed for ${RELATIVE_MODULE_PATH}: ${e.message}`);
|
|
225
|
+
continue;
|
|
48
226
|
}
|
|
49
|
-
|
|
50
|
-
|
|
227
|
+
if (!fs.existsSync(RELATIVE_MODULE_PATH)) {
|
|
228
|
+
console.error(`Submodule directory ${RELATIVE_MODULE_PATH} still does not exist after manual clone. Skipping.`);
|
|
229
|
+
continue;
|
|
51
230
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
231
|
+
}
|
|
232
|
+
const GIT_MODULES = path.join(RELATIVE_MODULE_PATH, ".gitmodules");
|
|
233
|
+
if (ACCESS_TOKEN) {
|
|
234
|
+
let URL_WITH_TOKEN = "";
|
|
235
|
+
let repoInfo;
|
|
236
|
+
if (URL2.includes("github.com")) {
|
|
237
|
+
repoInfo = URL2.replace("https://github.com/", "");
|
|
238
|
+
URL_WITH_TOKEN = `https://${ACCESS_TOKEN}@github.com/${repoInfo}`;
|
|
239
|
+
} else if (URL2.includes("gitlab.com") && typeof process.env.GITLAB_TOKEN === "string") {
|
|
240
|
+
repoInfo = URL2.replace("https://gitlab.com/", "");
|
|
241
|
+
URL_WITH_TOKEN = `https://oauth2:${ACCESS_TOKEN}@gitlab.com/${repoInfo}`;
|
|
242
|
+
} else {
|
|
243
|
+
const urlObj = new URL2(URL2);
|
|
244
|
+
repoInfo = urlObj.pathname.substring(1);
|
|
245
|
+
URL_WITH_TOKEN = `${urlObj.protocol}//${ACCESS_TOKEN}@${urlObj.host}${urlObj.pathname}`;
|
|
56
246
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
let repoInfo;
|
|
61
|
-
if (URL.includes("github.com")) {
|
|
62
|
-
repoInfo = URL.replace("https://github.com/", "");
|
|
63
|
-
URL_WITH_TOKEN = `https://${ACCESS_TOKEN}@github.com/${repoInfo}`;
|
|
64
|
-
}
|
|
65
|
-
else if (URL.includes("gitlab.com") && typeof process.env.GITLAB_TOKEN === "string") {
|
|
66
|
-
repoInfo = URL.replace("https://gitlab.com/", "");
|
|
67
|
-
URL_WITH_TOKEN = `https://oauth2:${ACCESS_TOKEN}@gitlab.com/${repoInfo}`;
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
// For other Git providers, try a generic approach
|
|
71
|
-
const urlObj = new URL(URL);
|
|
72
|
-
repoInfo = urlObj.pathname.substring(1); // Remove leading slash
|
|
73
|
-
URL_WITH_TOKEN = `${urlObj.protocol}//${ACCESS_TOKEN}@${urlObj.host}${urlObj.pathname}`;
|
|
74
|
-
}
|
|
75
|
-
if (URL_WITH_TOKEN && URL_WITH_TOKEN.length > 0) {
|
|
76
|
-
console.log(`Apply token for ${repoInfo} at ${MODULE_PATH} branch ${BRANCH}`);
|
|
77
|
-
runGit(["-C", RELATIVE_MODULE_PATH, "remote", "set-url", "origin", URL_WITH_TOKEN]);
|
|
78
|
-
}
|
|
247
|
+
if (URL_WITH_TOKEN && URL_WITH_TOKEN.length > 0) {
|
|
248
|
+
console.log(`Apply token for ${repoInfo} at ${MODULE_PATH} branch ${BRANCH}`);
|
|
249
|
+
runGit(["-C", RELATIVE_MODULE_PATH, "remote", "set-url", "origin", URL_WITH_TOKEN]);
|
|
79
250
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
251
|
+
}
|
|
252
|
+
runGit(["-C", RELATIVE_MODULE_PATH, "fetch", "--all"]);
|
|
253
|
+
runGit(["-C", RELATIVE_MODULE_PATH, "pull", "origin", BRANCH, "-X", "theirs"]);
|
|
254
|
+
if (fs.existsSync(GIT_MODULES)) {
|
|
255
|
+
console.log(`${MODULE_PATH} has submodules`);
|
|
256
|
+
const env = Object.assign({}, process.env, {
|
|
257
|
+
VISITED_SUBMODULES: process.env.VISITED_SUBMODULES + path.delimiter + path.resolve(RELATIVE_MODULE_PATH)
|
|
258
|
+
});
|
|
259
|
+
const result = spawnSync("node", [__filename, "-cwd", RELATIVE_MODULE_PATH], {
|
|
260
|
+
stdio: "inherit",
|
|
261
|
+
env,
|
|
262
|
+
cwd: RELATIVE_MODULE_PATH
|
|
263
|
+
});
|
|
264
|
+
if (result.status !== 0) {
|
|
265
|
+
console.error(`Recursive submodule failed for ${RELATIVE_MODULE_PATH}`);
|
|
266
|
+
process.exit(result.status);
|
|
89
267
|
}
|
|
268
|
+
}
|
|
90
269
|
}
|
|
91
270
|
runGit(["-C", REPO_PATH, "submodule", "update", "--init", "--recursive"]);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return result.stdout || "";
|
|
271
|
+
function runGit(args2, returnResult = false) {
|
|
272
|
+
console.log(`Executing: git ${args2.join(" ")}`);
|
|
273
|
+
const result = spawnSync("git", args2, { encoding: "utf-8" });
|
|
274
|
+
if (returnResult) return result;
|
|
275
|
+
if (result.status !== 0) {
|
|
276
|
+
throw new Error(result.stderr || `git ${args2.join(" ")} failed`);
|
|
277
|
+
}
|
|
278
|
+
return result.stdout || "";
|
|
101
279
|
}
|
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
require_utils
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-V3N3JEUF.mjs";
|
|
6
6
|
import {
|
|
7
7
|
__commonJS,
|
|
8
8
|
__filename,
|
|
9
9
|
__require,
|
|
10
10
|
init_esm_shims
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-QQ4A6DLD.mjs";
|
|
12
12
|
|
|
13
13
|
// src/submodule-install.cjs
|
|
14
14
|
var require_submodule_install = __commonJS({
|
|
15
15
|
"src/submodule-install.cjs"() {
|
|
16
16
|
init_esm_shims();
|
|
17
17
|
var { spawnSync } = __require("child_process");
|
|
18
|
+
var color = __require("ansi-colors");
|
|
18
19
|
var fs = __require("fs");
|
|
19
20
|
var path = __require("path");
|
|
20
21
|
var dotenv = __require("dotenv");
|
|
@@ -23,6 +24,19 @@ var require_submodule_install = __commonJS({
|
|
|
23
24
|
var { getArgs } = require_utils();
|
|
24
25
|
var args = getArgs();
|
|
25
26
|
var positional = args._ || [];
|
|
27
|
+
if (args.help || args.h) {
|
|
28
|
+
console.log();
|
|
29
|
+
console.log("Usage: submodule-install [options] [repo-path]");
|
|
30
|
+
console.log();
|
|
31
|
+
console.log("Options:");
|
|
32
|
+
console.log(" --cwd <path> Set working directory");
|
|
33
|
+
console.log(" --help, -h Show this help message");
|
|
34
|
+
console.log();
|
|
35
|
+
console.log("Description:");
|
|
36
|
+
console.log(" Installs and updates git submodules recursively, applying access tokens for private repos.");
|
|
37
|
+
console.log();
|
|
38
|
+
process.exit(0);
|
|
39
|
+
}
|
|
26
40
|
var ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
|
|
27
41
|
var ROOT = runGit(["rev-parse", "--show-toplevel"]).trim();
|
|
28
42
|
var REPO_PATH = ROOT;
|
|
@@ -31,6 +45,14 @@ var require_submodule_install = __commonJS({
|
|
|
31
45
|
} else if (positional.length > 0) {
|
|
32
46
|
ROOT = path.resolve(positional[0]);
|
|
33
47
|
}
|
|
48
|
+
var CURRENT_PATH = ROOT;
|
|
49
|
+
var VISITED_SUBMODULES = (process.env.VISITED_SUBMODULES || "").split(path.delimiter).filter(Boolean);
|
|
50
|
+
if (VISITED_SUBMODULES.includes(CURRENT_PATH)) {
|
|
51
|
+
console.log(`Skipping ${CURRENT_PATH} (already processed) to avoid recursion.`);
|
|
52
|
+
process.exit(0);
|
|
53
|
+
}
|
|
54
|
+
VISITED_SUBMODULES.push(CURRENT_PATH);
|
|
55
|
+
process.env.VISITED_SUBMODULES = VISITED_SUBMODULES.join(path.delimiter);
|
|
34
56
|
console.log(`Installing submodules at ${ROOT}`);
|
|
35
57
|
var submoduleList = runGit([
|
|
36
58
|
"-C",
|
|
@@ -55,6 +77,11 @@ var require_submodule_install = __commonJS({
|
|
|
55
77
|
BRANCH = runGit(["config", "-f", ".gitmodules", "--get", `submodule.${NAME}.branch`]).trim();
|
|
56
78
|
} catch {
|
|
57
79
|
}
|
|
80
|
+
console.log(`Submodule: ${color.cyan(NAME)}`);
|
|
81
|
+
console.log(` Location: ${color.magenta(MODULE_PATH)}`);
|
|
82
|
+
console.log(` ROOT: ${color.yellow(ROOT)}`);
|
|
83
|
+
console.log(` URL: ${color.blue(URL)}`);
|
|
84
|
+
console.log(` Branch: ${color.green(BRANCH)}`);
|
|
58
85
|
const addResult = runGit(
|
|
59
86
|
["-C", REPO_PATH, "submodule", "add", "--force", "-b", BRANCH, "--name", NAME, URL, MODULE_PATH],
|
|
60
87
|
true
|
|
@@ -63,6 +90,19 @@ var require_submodule_install = __commonJS({
|
|
|
63
90
|
console.warn(`Cannot add submodule ${MODULE_PATH}`);
|
|
64
91
|
continue;
|
|
65
92
|
}
|
|
93
|
+
if (!fs.existsSync(RELATIVE_MODULE_PATH)) {
|
|
94
|
+
console.warn(`Submodule directory ${RELATIVE_MODULE_PATH} does not exist after add. Attempting manual clone...`);
|
|
95
|
+
try {
|
|
96
|
+
runGit(["clone", "--branch", BRANCH, URL, RELATIVE_MODULE_PATH]);
|
|
97
|
+
} catch (e) {
|
|
98
|
+
console.error(`Manual clone failed for ${RELATIVE_MODULE_PATH}: ${e.message}`);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (!fs.existsSync(RELATIVE_MODULE_PATH)) {
|
|
102
|
+
console.error(`Submodule directory ${RELATIVE_MODULE_PATH} still does not exist after manual clone. Skipping.`);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
66
106
|
const GIT_MODULES = path.join(RELATIVE_MODULE_PATH, ".gitmodules");
|
|
67
107
|
if (ACCESS_TOKEN) {
|
|
68
108
|
let URL_WITH_TOKEN = "";
|
|
@@ -87,7 +127,14 @@ var require_submodule_install = __commonJS({
|
|
|
87
127
|
runGit(["-C", RELATIVE_MODULE_PATH, "pull", "origin", BRANCH, "-X", "theirs"]);
|
|
88
128
|
if (fs.existsSync(GIT_MODULES)) {
|
|
89
129
|
console.log(`${MODULE_PATH} has submodules`);
|
|
90
|
-
const
|
|
130
|
+
const env = Object.assign({}, process.env, {
|
|
131
|
+
VISITED_SUBMODULES: process.env.VISITED_SUBMODULES + path.delimiter + path.resolve(RELATIVE_MODULE_PATH)
|
|
132
|
+
});
|
|
133
|
+
const result = spawnSync("node", [__filename, "-cwd", RELATIVE_MODULE_PATH], {
|
|
134
|
+
stdio: "inherit",
|
|
135
|
+
env,
|
|
136
|
+
cwd: RELATIVE_MODULE_PATH
|
|
137
|
+
});
|
|
91
138
|
if (result.status !== 0) {
|
|
92
139
|
console.error(`Recursive submodule failed for ${RELATIVE_MODULE_PATH}`);
|
|
93
140
|
process.exit(result.status);
|
|
@@ -96,6 +143,7 @@ var require_submodule_install = __commonJS({
|
|
|
96
143
|
}
|
|
97
144
|
runGit(["-C", REPO_PATH, "submodule", "update", "--init", "--recursive"]);
|
|
98
145
|
function runGit(args2, returnResult = false) {
|
|
146
|
+
console.log(`Executing: git ${args2.join(" ")}`);
|
|
99
147
|
const result = spawnSync("git", args2, { encoding: "utf-8" });
|
|
100
148
|
if (returnResult) return result;
|
|
101
149
|
if (result.status !== 0) {
|