binary-collections 2.0.6 → 2.0.8
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/bin/dir-tree.cmd +7 -0
- package/bin/git-diff +4 -0
- package/bin/git-diff.cmd +7 -0
- package/bin/{git-fix-encoding → git-fix} +1 -4
- package/bin/git-fix.cmd +7 -0
- package/bin/nodekill +0 -0
- package/bin/nodekill.cmd +0 -0
- package/bin/{submodule-install → submodule-install.txt} +0 -0
- package/bin/{submodule → submodule.txt} +0 -0
- package/lib/binary-collections-config.cjs +14 -0
- package/lib/binary-collections-config.d.mts +18 -0
- package/lib/binary-collections-config.d.ts +16 -0
- package/lib/binary-collections-config.js +39 -0
- package/lib/binary-collections-config.mjs +6 -0
- package/lib/binary-collections.cjs +105 -0
- package/lib/binary-collections.d.cts +2 -0
- package/lib/binary-collections.d.mts +121 -0
- package/lib/binary-collections.d.ts +121 -0
- package/lib/binary-collections.mjs +108 -0
- package/lib/chunk-4BYBVEYC.mjs +30 -0
- package/lib/chunk-AASHBCRW.mjs +57 -0
- package/lib/chunk-APBWENF6.mjs +135 -0
- package/lib/{chunk-M4IBUK4H.mjs → chunk-DPKAJKFO.mjs} +2 -4
- package/lib/chunk-EGSSKVDH.mjs +66 -0
- package/lib/{chunk-GA4DDV65.mjs → chunk-G3THLIDT.mjs} +3 -5
- package/lib/chunk-JGR2NW6D.mjs +187 -0
- package/lib/chunk-ONIBBBQ3.mjs +108 -0
- package/lib/chunk-SH3L6HHV.mjs +27 -0
- package/lib/chunk-VVEZVNIV.mjs +81 -0
- package/lib/{chunk-E75HJFJO.mjs → chunk-W3ENOM53.mjs} +2 -4
- package/lib/chunk-YV7DO3YV.mjs +48 -0
- package/lib/chunk-YX5U7XDR.mjs +58 -0
- package/lib/chunk-ZYAQRPUL.mjs +28 -0
- package/lib/clean-github-actions-caches.cjs +162 -0
- package/lib/clean-github-actions-caches.d.cts +1 -0
- package/lib/clean-github-actions-caches.d.mts +169 -0
- package/lib/clean-github-actions-caches.d.ts +169 -0
- package/lib/clean-github-actions-caches.mjs +132 -0
- package/lib/del-gradle.cjs +99 -15
- package/lib/del-gradle.d.ts +1 -2
- package/lib/del-gradle.js +12 -69
- package/lib/del-gradle.mjs +4 -6
- package/lib/del-node-modules.cjs +98 -14
- package/lib/del-node-modules.d.ts +1 -2
- package/lib/del-node-modules.js +11 -68
- package/lib/del-node-modules.mjs +3 -5
- package/lib/del-ps.cjs +98 -627
- package/lib/del-ps.d.ts +1 -2
- package/lib/del-ps.js +27 -702
- package/lib/del-ps.mjs +7 -12
- package/lib/del-yarn-caches.cjs +98 -14
- package/lib/del-yarn-caches.d.ts +1 -2
- package/lib/del-yarn-caches.js +6 -63
- package/lib/del-yarn-caches.mjs +3 -5
- package/lib/find-node-modules-cli.cjs +67 -0
- package/lib/find-node-modules-cli.d.mts +1 -0
- package/lib/find-node-modules-cli.d.ts +2 -0
- package/lib/find-node-modules-cli.js +3 -0
- package/lib/find-node-modules-cli.mjs +13 -0
- package/lib/find-node-modules.cjs +39 -9
- package/lib/find-node-modules.d.mts +12 -1
- package/lib/find-node-modules.d.ts +12 -2
- package/lib/find-node-modules.js +53 -12
- package/lib/find-node-modules.mjs +4 -19
- package/lib/git/gitattributes.cjs +171 -0
- package/lib/git/gitattributes.d.mts +35 -0
- package/lib/git/gitattributes.d.ts +33 -0
- package/lib/git/gitattributes.js +223 -0
- package/lib/git/gitattributes.mjs +6 -0
- package/lib/git/line-endings.cjs +74 -0
- package/lib/git/line-endings.d.cts +7 -0
- package/lib/git/line-endings.d.mts +83 -0
- package/lib/git/line-endings.d.ts +83 -0
- package/lib/git/line-endings.mjs +8 -0
- package/lib/git/normalize.cjs +42 -0
- package/lib/git/normalize.d.cts +6 -0
- package/lib/git/normalize.d.mts +43 -0
- package/lib/git/normalize.d.ts +43 -0
- package/lib/git/normalize.mjs +6 -0
- package/lib/git/permissions.cjs +15 -0
- package/lib/git/permissions.d.cts +6 -0
- package/lib/git/permissions.d.mts +17 -0
- package/lib/git/permissions.d.ts +17 -0
- package/lib/git/permissions.mjs +7 -0
- package/lib/git/pull-strategy.cjs +13 -0
- package/lib/git/pull-strategy.d.cts +5 -0
- package/lib/git/pull-strategy.d.mts +15 -0
- package/lib/git/pull-strategy.d.ts +15 -0
- package/lib/git/pull-strategy.mjs +7 -0
- package/lib/git/user-config.cjs +100 -0
- package/lib/git/user-config.d.cts +10 -0
- package/lib/git/user-config.d.mts +105 -0
- package/lib/git/user-config.d.ts +105 -0
- package/lib/git/user-config.mjs +8 -0
- package/lib/git/utils.cjs +70 -0
- package/lib/git/utils.d.cts +20 -0
- package/lib/git/utils.d.mts +69 -0
- package/lib/git/utils.d.ts +69 -0
- package/lib/git/utils.mjs +6 -0
- package/lib/git-diff.cjs +73 -0
- package/lib/git-diff.d.cts +2 -0
- package/lib/git-diff.d.mts +84 -0
- package/lib/git-diff.d.ts +84 -0
- package/lib/git-diff.mjs +88 -0
- package/lib/git-fix.cjs +129 -0
- package/lib/git-fix.d.cts +2 -0
- package/lib/git-fix.d.mts +141 -0
- package/lib/git-fix.d.ts +141 -0
- package/lib/git-fix.mjs +151 -0
- package/lib/git-purge.cjs +92 -621
- package/lib/git-purge.d.ts +1 -2
- package/lib/git-purge.js +53 -698
- package/lib/git-purge.mjs +4 -9
- package/lib/index.cjs +99 -1
- package/lib/index.d.mts +1 -2
- package/lib/index.d.ts +2 -2
- package/lib/index.js +8 -2
- package/lib/index.mjs +10 -3
- package/lib/npm-run-series.cjs +140 -1
- package/lib/npm-run-series.d.ts +1 -0
- package/lib/npm-run-series.js +81 -56
- package/lib/npm-run-series.mjs +7 -5
- package/lib/package-resolutions-updater.cjs +274 -0
- package/lib/package-resolutions-updater.d.mts +1 -0
- package/lib/package-resolutions-updater.d.ts +326 -0
- package/lib/package-resolutions-updater.mjs +316 -0
- package/lib/print-directory-tree.cjs +241 -0
- package/lib/print-directory-tree.d.cts +1 -0
- package/lib/print-directory-tree.d.mts +234 -0
- package/lib/print-directory-tree.d.ts +234 -0
- package/lib/print-directory-tree.mjs +182 -0
- package/lib/ps/connected-domain.cjs +0 -0
- package/lib/ps/connected-domain.d.ts +1 -2
- package/lib/ps/connected-domain.js +196 -150
- package/lib/ps/connected-domain.mjs +2 -3
- package/lib/ps/index.cjs +3 -3
- package/lib/ps/index.d.mjs +1 -2
- package/lib/ps/index.d.ts +2 -26
- package/lib/ps/index.js +233 -535
- package/lib/ps/index.mjs +9 -11
- package/lib/ps/isWin.cjs +0 -0
- package/lib/ps/isWin.d.ts +1 -2
- package/lib/ps/isWin.js +1 -2
- package/lib/ps/isWin.mjs +2 -3
- package/lib/ps/table-parser.cjs +0 -0
- package/lib/ps/table-parser.d.ts +1 -3
- package/lib/ps/table-parser.js +254 -345
- package/lib/ps/table-parser.mjs +3 -4
- package/lib/submodule-install.cjs +100 -0
- package/lib/submodule-install.d.cts +2 -0
- package/lib/submodule-install.d.mts +121 -0
- package/lib/submodule-install.d.ts +121 -0
- package/lib/submodule-install.mjs +107 -0
- package/lib/utils.cjs +98 -14
- package/lib/utils.d.mts +29 -9
- package/lib/utils.d.ts +30 -14
- package/lib/utils.js +173 -27
- package/lib/utils.mjs +2 -3
- package/lib/yarn-reinstall.cjs +44 -0
- package/lib/yarn-reinstall.d.cts +1 -0
- package/lib/yarn-reinstall.d.mts +49 -0
- package/lib/yarn-reinstall.d.ts +49 -0
- package/lib/yarn-reinstall.mjs +54 -0
- package/package.json +126 -99
- package/readme.md +238 -50
- package/src/package-resolutions-updater.mjs +325 -0
- package/src/print-directory-tree.cjs +234 -0
- package/src/ps/index.js +4 -3
- package/src/yarn-reinstall.cjs +49 -0
- package/test-project/package.json +16 -0
- package/tmp/test-repo/package.json +7 -0
- package/bin/git-fix-encoding.cmd +0 -6
- package/eslint.config.cjs +0 -97
- package/lib/chunk-7MSZ52XC.mjs +0 -14
- package/lib/chunk-AVDT32AY.mjs +0 -20
- package/lib/chunk-LPLPQBYP.mjs +0 -53
- package/lib/chunk-S4SJ7SDW.mjs +0 -625
- package/lib/package-resolutions.cjs +0 -28
- package/lib/package-resolutions.d.mts +0 -25
- package/lib/package-resolutions.d.ts +0 -25
- package/lib/package-resolutions.js +0 -28
- package/lib/package-resolutions.mjs +0 -31
- package/lib/ps/index.d.js +0 -17
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
const { spawnSync } = require("child_process");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const dotenv = require("dotenv");
|
|
7
|
+
// Load .env using dotenv from process.cwd()
|
|
8
|
+
const envPath = path.resolve(process.cwd(), ".env");
|
|
9
|
+
if (fs.existsSync(envPath))
|
|
10
|
+
dotenv.config({ path: envPath });
|
|
11
|
+
const { getArgs } = require("./utils.js");
|
|
12
|
+
const args = getArgs();
|
|
13
|
+
const positional = args._ || [];
|
|
14
|
+
let ROOT = runGit(["rev-parse", "--show-toplevel"]).trim();
|
|
15
|
+
let REPO_PATH = ROOT;
|
|
16
|
+
if (args.cwd) {
|
|
17
|
+
ROOT = path.resolve(args.cwd);
|
|
18
|
+
}
|
|
19
|
+
else if (positional.length > 0) {
|
|
20
|
+
ROOT = path.resolve(positional[0]);
|
|
21
|
+
}
|
|
22
|
+
console.log(`Installing submodules at ${ROOT}`);
|
|
23
|
+
// Get submodule paths
|
|
24
|
+
const submoduleList = runGit([
|
|
25
|
+
"-C",
|
|
26
|
+
REPO_PATH,
|
|
27
|
+
"config",
|
|
28
|
+
"-f",
|
|
29
|
+
".gitmodules",
|
|
30
|
+
"--get-regexp",
|
|
31
|
+
"^submodule\\..*\\.path$"
|
|
32
|
+
])
|
|
33
|
+
.split("\n")
|
|
34
|
+
.filter(Boolean);
|
|
35
|
+
for (const line of submoduleList) {
|
|
36
|
+
const [KEY, MODULE_PATH] = line.trim().split(/\s+/);
|
|
37
|
+
const RELATIVE_MODULE_PATH = path.join(ROOT, MODULE_PATH);
|
|
38
|
+
if (fs.existsSync(RELATIVE_MODULE_PATH)) {
|
|
39
|
+
console.log(`Deleting ${RELATIVE_MODULE_PATH}`);
|
|
40
|
+
fs.rmSync(RELATIVE_MODULE_PATH, { recursive: true, force: true });
|
|
41
|
+
}
|
|
42
|
+
const NAME = KEY.match(/^submodule\.(.*)\.path$/)[1];
|
|
43
|
+
const URL = runGit(["config", "-f", ".gitmodules", "--get", `submodule.${NAME}.url`]).trim();
|
|
44
|
+
let BRANCH = "master";
|
|
45
|
+
try {
|
|
46
|
+
BRANCH = runGit(["config", "-f", ".gitmodules", "--get", `submodule.${NAME}.branch`]).trim();
|
|
47
|
+
}
|
|
48
|
+
catch (_a) {
|
|
49
|
+
// silently ignore if branch is not set
|
|
50
|
+
}
|
|
51
|
+
const addResult = runGit(["-C", REPO_PATH, "submodule", "add", "--force", "-b", BRANCH, "--name", NAME, URL, MODULE_PATH], true);
|
|
52
|
+
if (addResult.status !== 0) {
|
|
53
|
+
console.warn(`Cannot add submodule ${MODULE_PATH}`);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const GIT_MODULES = path.join(RELATIVE_MODULE_PATH, ".gitmodules");
|
|
57
|
+
if (process.env.ACCESS_TOKEN) {
|
|
58
|
+
let URL_WITH_TOKEN = "";
|
|
59
|
+
let repoInfo;
|
|
60
|
+
if (URL.includes("github.com")) {
|
|
61
|
+
repoInfo = URL.replace("https://github.com/", "");
|
|
62
|
+
URL_WITH_TOKEN = `https://${process.env.ACCESS_TOKEN}@github.com/${repoInfo}`;
|
|
63
|
+
}
|
|
64
|
+
else if (URL.includes("gitlab.com") && typeof process.env.GITLAB_TOKEN === "string") {
|
|
65
|
+
repoInfo = URL.replace("https://gitlab.com/", "");
|
|
66
|
+
URL_WITH_TOKEN = `https://oauth2:${process.env.ACCESS_TOKEN}@gitlab.com/${repoInfo}`;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
// For other Git providers, try a generic approach
|
|
70
|
+
const urlObj = new URL(URL);
|
|
71
|
+
repoInfo = urlObj.pathname.substring(1); // Remove leading slash
|
|
72
|
+
URL_WITH_TOKEN = `${urlObj.protocol}//${process.env.ACCESS_TOKEN}@${urlObj.host}${urlObj.pathname}`;
|
|
73
|
+
}
|
|
74
|
+
if (URL_WITH_TOKEN && URL_WITH_TOKEN.length > 0) {
|
|
75
|
+
console.log(`Apply token for ${repoInfo} at ${MODULE_PATH} branch ${BRANCH}`);
|
|
76
|
+
runGit(["-C", RELATIVE_MODULE_PATH, "remote", "set-url", "origin", URL_WITH_TOKEN]);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
runGit(["-C", RELATIVE_MODULE_PATH, "fetch", "--all"]);
|
|
80
|
+
runGit(["-C", RELATIVE_MODULE_PATH, "pull", "origin", BRANCH, "-X", "theirs"]);
|
|
81
|
+
if (fs.existsSync(GIT_MODULES)) {
|
|
82
|
+
console.log(`${MODULE_PATH} has submodules`);
|
|
83
|
+
const result = spawnSync("node", [__filename, "-cwd", RELATIVE_MODULE_PATH], { stdio: "inherit" });
|
|
84
|
+
if (result.status !== 0) {
|
|
85
|
+
console.error(`Recursive submodule failed for ${RELATIVE_MODULE_PATH}`);
|
|
86
|
+
process.exit(result.status);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
runGit(["-C", REPO_PATH, "submodule", "update", "--init", "--recursive"]);
|
|
91
|
+
// ----------- Helper Functions -----------
|
|
92
|
+
function runGit(args, returnResult = false) {
|
|
93
|
+
const result = spawnSync("git", args, { encoding: "utf-8" });
|
|
94
|
+
if (returnResult)
|
|
95
|
+
return result;
|
|
96
|
+
if (result.status !== 0) {
|
|
97
|
+
throw new Error(result.stderr || `git ${args.join(" ")} failed`);
|
|
98
|
+
}
|
|
99
|
+
return result.stdout || "";
|
|
100
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawnSync } = require("child_process");
|
|
3
|
+
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const dotenv = require("dotenv");
|
|
7
|
+
|
|
8
|
+
// Load .env using dotenv from process.cwd()
|
|
9
|
+
const envPath = path.resolve(process.cwd(), ".env");
|
|
10
|
+
if (fs.existsSync(envPath)) dotenv.config({ path: envPath });
|
|
11
|
+
|
|
12
|
+
const { getArgs } = require("./utils.js");
|
|
13
|
+
const args = getArgs();
|
|
14
|
+
const positional = args._ || [];
|
|
15
|
+
|
|
16
|
+
let ROOT = runGit(["rev-parse", "--show-toplevel"]).trim();
|
|
17
|
+
let REPO_PATH = ROOT;
|
|
18
|
+
|
|
19
|
+
if (args.cwd) {
|
|
20
|
+
ROOT = path.resolve(args.cwd);
|
|
21
|
+
} else if (positional.length > 0) {
|
|
22
|
+
ROOT = path.resolve(positional[0]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
console.log(`Installing submodules at ${ROOT}`);
|
|
26
|
+
|
|
27
|
+
// Get submodule paths
|
|
28
|
+
const submoduleList = runGit([
|
|
29
|
+
"-C",
|
|
30
|
+
REPO_PATH,
|
|
31
|
+
"config",
|
|
32
|
+
"-f",
|
|
33
|
+
".gitmodules",
|
|
34
|
+
"--get-regexp",
|
|
35
|
+
"^submodule\\..*\\.path$"
|
|
36
|
+
])
|
|
37
|
+
.split("\n")
|
|
38
|
+
.filter(Boolean);
|
|
39
|
+
|
|
40
|
+
for (const line of submoduleList) {
|
|
41
|
+
const [KEY, MODULE_PATH] = line.trim().split(/\s+/);
|
|
42
|
+
const RELATIVE_MODULE_PATH = path.join(ROOT, MODULE_PATH);
|
|
43
|
+
|
|
44
|
+
if (fs.existsSync(RELATIVE_MODULE_PATH)) {
|
|
45
|
+
console.log(`Deleting ${RELATIVE_MODULE_PATH}`);
|
|
46
|
+
fs.rmSync(RELATIVE_MODULE_PATH, { recursive: true, force: true });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const NAME = KEY.match(/^submodule\.(.*)\.path$/)[1];
|
|
50
|
+
const URL = runGit(["config", "-f", ".gitmodules", "--get", `submodule.${NAME}.url`]).trim();
|
|
51
|
+
|
|
52
|
+
let BRANCH = "master";
|
|
53
|
+
try {
|
|
54
|
+
BRANCH = runGit(["config", "-f", ".gitmodules", "--get", `submodule.${NAME}.branch`]).trim();
|
|
55
|
+
} catch {
|
|
56
|
+
// silently ignore if branch is not set
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const addResult = runGit(
|
|
60
|
+
["-C", REPO_PATH, "submodule", "add", "--force", "-b", BRANCH, "--name", NAME, URL, MODULE_PATH],
|
|
61
|
+
true
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
if (addResult.status !== 0) {
|
|
65
|
+
console.warn(`Cannot add submodule ${MODULE_PATH}`);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const GIT_MODULES = path.join(RELATIVE_MODULE_PATH, ".gitmodules");
|
|
70
|
+
|
|
71
|
+
if (process.env.ACCESS_TOKEN) {
|
|
72
|
+
let URL_WITH_TOKEN = "";
|
|
73
|
+
let repoInfo;
|
|
74
|
+
|
|
75
|
+
if (URL.includes("github.com")) {
|
|
76
|
+
repoInfo = URL.replace("https://github.com/", "");
|
|
77
|
+
URL_WITH_TOKEN = `https://${process.env.ACCESS_TOKEN}@github.com/${repoInfo}`;
|
|
78
|
+
} else if (URL.includes("gitlab.com") && typeof process.env.GITLAB_TOKEN === "string") {
|
|
79
|
+
repoInfo = URL.replace("https://gitlab.com/", "");
|
|
80
|
+
URL_WITH_TOKEN = `https://oauth2:${process.env.ACCESS_TOKEN}@gitlab.com/${repoInfo}`;
|
|
81
|
+
} else {
|
|
82
|
+
// For other Git providers, try a generic approach
|
|
83
|
+
const urlObj = new URL(URL);
|
|
84
|
+
repoInfo = urlObj.pathname.substring(1); // Remove leading slash
|
|
85
|
+
URL_WITH_TOKEN = `${urlObj.protocol}//${process.env.ACCESS_TOKEN}@${urlObj.host}${urlObj.pathname}`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (URL_WITH_TOKEN && URL_WITH_TOKEN.length > 0) {
|
|
89
|
+
console.log(`Apply token for ${repoInfo} at ${MODULE_PATH} branch ${BRANCH}`);
|
|
90
|
+
runGit(["-C", RELATIVE_MODULE_PATH, "remote", "set-url", "origin", URL_WITH_TOKEN]);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
runGit(["-C", RELATIVE_MODULE_PATH, "fetch", "--all"]);
|
|
95
|
+
runGit(["-C", RELATIVE_MODULE_PATH, "pull", "origin", BRANCH, "-X", "theirs"]);
|
|
96
|
+
|
|
97
|
+
if (fs.existsSync(GIT_MODULES)) {
|
|
98
|
+
console.log(`${MODULE_PATH} has submodules`);
|
|
99
|
+
const result = spawnSync("node", [__filename, "-cwd", RELATIVE_MODULE_PATH], { stdio: "inherit" });
|
|
100
|
+
if (result.status !== 0) {
|
|
101
|
+
console.error(`Recursive submodule failed for ${RELATIVE_MODULE_PATH}`);
|
|
102
|
+
process.exit(result.status);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
runGit(["-C", REPO_PATH, "submodule", "update", "--init", "--recursive"]);
|
|
108
|
+
|
|
109
|
+
// ----------- Helper Functions -----------
|
|
110
|
+
|
|
111
|
+
function runGit(args, returnResult = false) {
|
|
112
|
+
const result = spawnSync("git", args, { encoding: "utf-8" });
|
|
113
|
+
|
|
114
|
+
if (returnResult) return result;
|
|
115
|
+
|
|
116
|
+
if (result.status !== 0) {
|
|
117
|
+
throw new Error(result.stderr || `git ${args.join(" ")} failed`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return result.stdout || "";
|
|
121
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawnSync } = require("child_process");
|
|
3
|
+
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const dotenv = require("dotenv");
|
|
7
|
+
|
|
8
|
+
// Load .env using dotenv from process.cwd()
|
|
9
|
+
const envPath = path.resolve(process.cwd(), ".env");
|
|
10
|
+
if (fs.existsSync(envPath)) dotenv.config({ path: envPath });
|
|
11
|
+
|
|
12
|
+
const { getArgs } = require("./utils.js");
|
|
13
|
+
const args = getArgs();
|
|
14
|
+
const positional = args._ || [];
|
|
15
|
+
|
|
16
|
+
let ROOT = runGit(["rev-parse", "--show-toplevel"]).trim();
|
|
17
|
+
let REPO_PATH = ROOT;
|
|
18
|
+
|
|
19
|
+
if (args.cwd) {
|
|
20
|
+
ROOT = path.resolve(args.cwd);
|
|
21
|
+
} else if (positional.length > 0) {
|
|
22
|
+
ROOT = path.resolve(positional[0]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
console.log(`Installing submodules at ${ROOT}`);
|
|
26
|
+
|
|
27
|
+
// Get submodule paths
|
|
28
|
+
const submoduleList = runGit([
|
|
29
|
+
"-C",
|
|
30
|
+
REPO_PATH,
|
|
31
|
+
"config",
|
|
32
|
+
"-f",
|
|
33
|
+
".gitmodules",
|
|
34
|
+
"--get-regexp",
|
|
35
|
+
"^submodule\\..*\\.path$"
|
|
36
|
+
])
|
|
37
|
+
.split("\n")
|
|
38
|
+
.filter(Boolean);
|
|
39
|
+
|
|
40
|
+
for (const line of submoduleList) {
|
|
41
|
+
const [KEY, MODULE_PATH] = line.trim().split(/\s+/);
|
|
42
|
+
const RELATIVE_MODULE_PATH = path.join(ROOT, MODULE_PATH);
|
|
43
|
+
|
|
44
|
+
if (fs.existsSync(RELATIVE_MODULE_PATH)) {
|
|
45
|
+
console.log(`Deleting ${RELATIVE_MODULE_PATH}`);
|
|
46
|
+
fs.rmSync(RELATIVE_MODULE_PATH, { recursive: true, force: true });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const NAME = KEY.match(/^submodule\.(.*)\.path$/)[1];
|
|
50
|
+
const URL = runGit(["config", "-f", ".gitmodules", "--get", `submodule.${NAME}.url`]).trim();
|
|
51
|
+
|
|
52
|
+
let BRANCH = "master";
|
|
53
|
+
try {
|
|
54
|
+
BRANCH = runGit(["config", "-f", ".gitmodules", "--get", `submodule.${NAME}.branch`]).trim();
|
|
55
|
+
} catch {
|
|
56
|
+
// silently ignore if branch is not set
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const addResult = runGit(
|
|
60
|
+
["-C", REPO_PATH, "submodule", "add", "--force", "-b", BRANCH, "--name", NAME, URL, MODULE_PATH],
|
|
61
|
+
true
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
if (addResult.status !== 0) {
|
|
65
|
+
console.warn(`Cannot add submodule ${MODULE_PATH}`);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const GIT_MODULES = path.join(RELATIVE_MODULE_PATH, ".gitmodules");
|
|
70
|
+
|
|
71
|
+
if (process.env.ACCESS_TOKEN) {
|
|
72
|
+
let URL_WITH_TOKEN = "";
|
|
73
|
+
let repoInfo;
|
|
74
|
+
|
|
75
|
+
if (URL.includes("github.com")) {
|
|
76
|
+
repoInfo = URL.replace("https://github.com/", "");
|
|
77
|
+
URL_WITH_TOKEN = `https://${process.env.ACCESS_TOKEN}@github.com/${repoInfo}`;
|
|
78
|
+
} else if (URL.includes("gitlab.com") && typeof process.env.GITLAB_TOKEN === "string") {
|
|
79
|
+
repoInfo = URL.replace("https://gitlab.com/", "");
|
|
80
|
+
URL_WITH_TOKEN = `https://oauth2:${process.env.ACCESS_TOKEN}@gitlab.com/${repoInfo}`;
|
|
81
|
+
} else {
|
|
82
|
+
// For other Git providers, try a generic approach
|
|
83
|
+
const urlObj = new URL(URL);
|
|
84
|
+
repoInfo = urlObj.pathname.substring(1); // Remove leading slash
|
|
85
|
+
URL_WITH_TOKEN = `${urlObj.protocol}//${process.env.ACCESS_TOKEN}@${urlObj.host}${urlObj.pathname}`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (URL_WITH_TOKEN && URL_WITH_TOKEN.length > 0) {
|
|
89
|
+
console.log(`Apply token for ${repoInfo} at ${MODULE_PATH} branch ${BRANCH}`);
|
|
90
|
+
runGit(["-C", RELATIVE_MODULE_PATH, "remote", "set-url", "origin", URL_WITH_TOKEN]);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
runGit(["-C", RELATIVE_MODULE_PATH, "fetch", "--all"]);
|
|
95
|
+
runGit(["-C", RELATIVE_MODULE_PATH, "pull", "origin", BRANCH, "-X", "theirs"]);
|
|
96
|
+
|
|
97
|
+
if (fs.existsSync(GIT_MODULES)) {
|
|
98
|
+
console.log(`${MODULE_PATH} has submodules`);
|
|
99
|
+
const result = spawnSync("node", [__filename, "-cwd", RELATIVE_MODULE_PATH], { stdio: "inherit" });
|
|
100
|
+
if (result.status !== 0) {
|
|
101
|
+
console.error(`Recursive submodule failed for ${RELATIVE_MODULE_PATH}`);
|
|
102
|
+
process.exit(result.status);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
runGit(["-C", REPO_PATH, "submodule", "update", "--init", "--recursive"]);
|
|
108
|
+
|
|
109
|
+
// ----------- Helper Functions -----------
|
|
110
|
+
|
|
111
|
+
function runGit(args, returnResult = false) {
|
|
112
|
+
const result = spawnSync("git", args, { encoding: "utf-8" });
|
|
113
|
+
|
|
114
|
+
if (returnResult) return result;
|
|
115
|
+
|
|
116
|
+
if (result.status !== 0) {
|
|
117
|
+
throw new Error(result.stderr || `git ${args.join(" ")} failed`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return result.stdout || "";
|
|
121
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
require_utils
|
|
5
|
+
} from "./chunk-APBWENF6.mjs";
|
|
6
|
+
import {
|
|
7
|
+
__commonJS,
|
|
8
|
+
__filename,
|
|
9
|
+
__require,
|
|
10
|
+
init_esm_shims
|
|
11
|
+
} from "./chunk-AASHBCRW.mjs";
|
|
12
|
+
|
|
13
|
+
// src/submodule-install.cjs
|
|
14
|
+
var require_submodule_install = __commonJS({
|
|
15
|
+
"src/submodule-install.cjs"() {
|
|
16
|
+
init_esm_shims();
|
|
17
|
+
var { spawnSync } = __require("child_process");
|
|
18
|
+
var fs = __require("fs");
|
|
19
|
+
var path = __require("path");
|
|
20
|
+
var dotenv = __require("dotenv");
|
|
21
|
+
var envPath = path.resolve(process.cwd(), ".env");
|
|
22
|
+
if (fs.existsSync(envPath)) dotenv.config({ path: envPath });
|
|
23
|
+
var { getArgs } = require_utils();
|
|
24
|
+
var args = getArgs();
|
|
25
|
+
var positional = args._ || [];
|
|
26
|
+
var ROOT = runGit(["rev-parse", "--show-toplevel"]).trim();
|
|
27
|
+
var REPO_PATH = ROOT;
|
|
28
|
+
if (args.cwd) {
|
|
29
|
+
ROOT = path.resolve(args.cwd);
|
|
30
|
+
} else if (positional.length > 0) {
|
|
31
|
+
ROOT = path.resolve(positional[0]);
|
|
32
|
+
}
|
|
33
|
+
console.log(`Installing submodules at ${ROOT}`);
|
|
34
|
+
var submoduleList = runGit([
|
|
35
|
+
"-C",
|
|
36
|
+
REPO_PATH,
|
|
37
|
+
"config",
|
|
38
|
+
"-f",
|
|
39
|
+
".gitmodules",
|
|
40
|
+
"--get-regexp",
|
|
41
|
+
"^submodule\\..*\\.path$"
|
|
42
|
+
]).split("\n").filter(Boolean);
|
|
43
|
+
for (const line of submoduleList) {
|
|
44
|
+
const [KEY, MODULE_PATH] = line.trim().split(/\s+/);
|
|
45
|
+
const RELATIVE_MODULE_PATH = path.join(ROOT, MODULE_PATH);
|
|
46
|
+
if (fs.existsSync(RELATIVE_MODULE_PATH)) {
|
|
47
|
+
console.log(`Deleting ${RELATIVE_MODULE_PATH}`);
|
|
48
|
+
fs.rmSync(RELATIVE_MODULE_PATH, { recursive: true, force: true });
|
|
49
|
+
}
|
|
50
|
+
const NAME = KEY.match(/^submodule\.(.*)\.path$/)[1];
|
|
51
|
+
const URL = runGit(["config", "-f", ".gitmodules", "--get", `submodule.${NAME}.url`]).trim();
|
|
52
|
+
let BRANCH = "master";
|
|
53
|
+
try {
|
|
54
|
+
BRANCH = runGit(["config", "-f", ".gitmodules", "--get", `submodule.${NAME}.branch`]).trim();
|
|
55
|
+
} catch {
|
|
56
|
+
}
|
|
57
|
+
const addResult = runGit(
|
|
58
|
+
["-C", REPO_PATH, "submodule", "add", "--force", "-b", BRANCH, "--name", NAME, URL, MODULE_PATH],
|
|
59
|
+
true
|
|
60
|
+
);
|
|
61
|
+
if (addResult.status !== 0) {
|
|
62
|
+
console.warn(`Cannot add submodule ${MODULE_PATH}`);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const GIT_MODULES = path.join(RELATIVE_MODULE_PATH, ".gitmodules");
|
|
66
|
+
if (process.env.ACCESS_TOKEN) {
|
|
67
|
+
let URL_WITH_TOKEN = "";
|
|
68
|
+
let repoInfo;
|
|
69
|
+
if (URL.includes("github.com")) {
|
|
70
|
+
repoInfo = URL.replace("https://github.com/", "");
|
|
71
|
+
URL_WITH_TOKEN = `https://${process.env.ACCESS_TOKEN}@github.com/${repoInfo}`;
|
|
72
|
+
} else if (URL.includes("gitlab.com") && typeof process.env.GITLAB_TOKEN === "string") {
|
|
73
|
+
repoInfo = URL.replace("https://gitlab.com/", "");
|
|
74
|
+
URL_WITH_TOKEN = `https://oauth2:${process.env.ACCESS_TOKEN}@gitlab.com/${repoInfo}`;
|
|
75
|
+
} else {
|
|
76
|
+
const urlObj = new URL(URL);
|
|
77
|
+
repoInfo = urlObj.pathname.substring(1);
|
|
78
|
+
URL_WITH_TOKEN = `${urlObj.protocol}//${process.env.ACCESS_TOKEN}@${urlObj.host}${urlObj.pathname}`;
|
|
79
|
+
}
|
|
80
|
+
if (URL_WITH_TOKEN && URL_WITH_TOKEN.length > 0) {
|
|
81
|
+
console.log(`Apply token for ${repoInfo} at ${MODULE_PATH} branch ${BRANCH}`);
|
|
82
|
+
runGit(["-C", RELATIVE_MODULE_PATH, "remote", "set-url", "origin", URL_WITH_TOKEN]);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
runGit(["-C", RELATIVE_MODULE_PATH, "fetch", "--all"]);
|
|
86
|
+
runGit(["-C", RELATIVE_MODULE_PATH, "pull", "origin", BRANCH, "-X", "theirs"]);
|
|
87
|
+
if (fs.existsSync(GIT_MODULES)) {
|
|
88
|
+
console.log(`${MODULE_PATH} has submodules`);
|
|
89
|
+
const result = spawnSync("node", [__filename, "-cwd", RELATIVE_MODULE_PATH], { stdio: "inherit" });
|
|
90
|
+
if (result.status !== 0) {
|
|
91
|
+
console.error(`Recursive submodule failed for ${RELATIVE_MODULE_PATH}`);
|
|
92
|
+
process.exit(result.status);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
runGit(["-C", REPO_PATH, "submodule", "update", "--init", "--recursive"]);
|
|
97
|
+
function runGit(args2, returnResult = false) {
|
|
98
|
+
const result = spawnSync("git", args2, { encoding: "utf-8" });
|
|
99
|
+
if (returnResult) return result;
|
|
100
|
+
if (result.status !== 0) {
|
|
101
|
+
throw new Error(result.stderr || `git ${args2.join(" ")} failed`);
|
|
102
|
+
}
|
|
103
|
+
return result.stdout || "";
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
export default require_submodule_install();
|
package/lib/utils.cjs
CHANGED
|
@@ -1,21 +1,54 @@
|
|
|
1
1
|
// src/utils.js
|
|
2
|
-
var
|
|
2
|
+
var fs = require("fs");
|
|
3
|
+
var path = require("upath");
|
|
3
4
|
var argv = require("minimist")(process.argv.slice(2));
|
|
5
|
+
var { exec } = require("child_process");
|
|
6
|
+
var { URL } = require("url");
|
|
7
|
+
var { promisify } = require("util");
|
|
8
|
+
var execAsync = promisify(exec);
|
|
9
|
+
async function parseGitRemotes() {
|
|
10
|
+
try {
|
|
11
|
+
const { stdout } = await execAsync("git remote -v");
|
|
12
|
+
const lines = stdout.split("\n");
|
|
13
|
+
const remotes = {};
|
|
14
|
+
lines.forEach((line) => {
|
|
15
|
+
const [name, url] = line.split(" ");
|
|
16
|
+
if (name && url) {
|
|
17
|
+
const [repoUrl] = url.split(" ");
|
|
18
|
+
try {
|
|
19
|
+
const parsedUrl = new URL(repoUrl);
|
|
20
|
+
const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
|
|
21
|
+
if (parsedUrl.hostname === "github.com" && pathParts.length === 2) {
|
|
22
|
+
let repoPath = pathParts.join("/");
|
|
23
|
+
if (repoPath.endsWith(".git")) {
|
|
24
|
+
repoPath = repoPath.slice(0, -4);
|
|
25
|
+
}
|
|
26
|
+
remotes[name] = repoPath;
|
|
27
|
+
}
|
|
28
|
+
} catch (e) {
|
|
29
|
+
console.error("URL Parsing Error:", e.message);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return remotes;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error("Error:", error.message);
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
module.exports.parseGitRemotes = parseGitRemotes;
|
|
40
|
+
function joinPathPreserveDriveLetter(...segments) {
|
|
41
|
+
let fullPath = require("path").join(...segments);
|
|
42
|
+
if (/^[a-z]:\\/.test(fullPath)) {
|
|
43
|
+
fullPath = fullPath.charAt(0).toUpperCase() + fullPath.slice(1);
|
|
44
|
+
}
|
|
45
|
+
return fullPath;
|
|
46
|
+
}
|
|
47
|
+
module.exports.joinPathPreserveDriveLetter = joinPathPreserveDriveLetter;
|
|
4
48
|
function getArgs() {
|
|
5
49
|
return argv;
|
|
6
50
|
}
|
|
7
|
-
|
|
8
|
-
globStream.stream().on("data", (result) => {
|
|
9
|
-
const fullPath = path.resolve(process.cwd(), result);
|
|
10
|
-
if (fs.statSync(fullPath).isDirectory()) {
|
|
11
|
-
const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
|
|
12
|
-
for (let i = 0; i < subdir.length; i++) {
|
|
13
|
-
del(subdir[i]);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
del(fullPath);
|
|
17
|
-
});
|
|
18
|
-
}
|
|
51
|
+
module.exports.getArgs = getArgs;
|
|
19
52
|
function del(fullPath) {
|
|
20
53
|
if (fs.statSync(fullPath).isDirectory()) {
|
|
21
54
|
const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
|
|
@@ -31,5 +64,56 @@ function del(fullPath) {
|
|
|
31
64
|
}
|
|
32
65
|
}
|
|
33
66
|
}
|
|
67
|
+
module.exports.del = del;
|
|
68
|
+
function delStream(globStream) {
|
|
69
|
+
globStream.stream().on("data", (result) => {
|
|
70
|
+
const fullPath = path.resolve(process.cwd(), result);
|
|
71
|
+
if (fs.statSync(fullPath).isDirectory()) {
|
|
72
|
+
const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
|
|
73
|
+
for (let i = 0; i < subdir.length; i++) {
|
|
74
|
+
del(subdir[i]);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
del(fullPath);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
module.exports.delStream = delStream;
|
|
81
|
+
function getFileTreeString(hashArray) {
|
|
82
|
+
const tree = {};
|
|
83
|
+
const hashMap = {};
|
|
84
|
+
for (const entry of hashArray) {
|
|
85
|
+
const [filePath, hash] = entry.split(" ");
|
|
86
|
+
hashMap[filePath] = hash;
|
|
87
|
+
const parts = filePath.split("/");
|
|
88
|
+
let current = tree;
|
|
89
|
+
for (let i = 0; i < parts.length; i++) {
|
|
90
|
+
const part = parts[i];
|
|
91
|
+
if (i === parts.length - 1) {
|
|
92
|
+
current[part] = null;
|
|
93
|
+
} else {
|
|
94
|
+
current[part] = current[part] || {};
|
|
95
|
+
current = current[part];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function printNode(node, prefix = "", parentPath = "") {
|
|
100
|
+
const keys = Object.keys(node).sort();
|
|
101
|
+
let lines = [];
|
|
102
|
+
keys.forEach((key, idx) => {
|
|
103
|
+
const isLast = idx === keys.length - 1;
|
|
104
|
+
const branch = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
105
|
+
const currentPath = parentPath ? parentPath + "/" + key : key;
|
|
106
|
+
if (node[key] === null) {
|
|
107
|
+
lines.push(prefix + branch + key + " [" + (hashMap[currentPath] || "") + "]");
|
|
108
|
+
} else {
|
|
109
|
+
lines.push(prefix + branch + key + "/");
|
|
110
|
+
lines = lines.concat(printNode(node[key], prefix + (isLast ? " " : "\u2502 "), currentPath));
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
return lines;
|
|
114
|
+
}
|
|
115
|
+
return printNode(tree, "", "").join("\n");
|
|
116
|
+
}
|
|
117
|
+
module.exports.getFileTreeString = getFileTreeString;
|
|
34
118
|
var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
35
|
-
module.exports =
|
|
119
|
+
module.exports.delay = delay;
|
package/lib/utils.d.mts
CHANGED
|
@@ -1,20 +1,40 @@
|
|
|
1
1
|
import * as minimist from 'minimist';
|
|
2
2
|
|
|
3
|
+
declare function parseGitRemotes(): Promise<{}>;
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* Joins all given path segments together and normalizes the resulting path.
|
|
6
|
+
* Preserves the case of the drive letter on Windows.
|
|
7
|
+
*
|
|
8
|
+
* @param {...string} segments Path segments to join.
|
|
9
|
+
* @returns {string} Normalized path with drive letter case preserved.
|
|
10
|
+
*/
|
|
11
|
+
declare function joinPathPreserveDriveLetter(...segments: string[]): string;
|
|
12
|
+
/**
|
|
13
|
+
* Returns parsed command line arguments using minimist.
|
|
14
|
+
* @returns {import('minimist').ParsedArgs} Parsed command line arguments
|
|
15
|
+
*/
|
|
16
|
+
declare function getArgs(): minimist.ParsedArgs;
|
|
17
|
+
/**
|
|
18
|
+
* Recursively deletes a file or directory at the given path.
|
|
19
|
+
* @param {string} fullPath Absolute path to the file or directory to delete.
|
|
6
20
|
*/
|
|
7
21
|
declare function del(fullPath: string): void;
|
|
8
22
|
/**
|
|
9
|
-
* glob stream
|
|
10
|
-
* @param {glob.Glob} globStream
|
|
23
|
+
* Handles a glob stream to delete matched files and directories recursively.
|
|
24
|
+
* @param {glob.Glob} globStream Glob stream object.
|
|
11
25
|
*/
|
|
12
26
|
declare function delStream(globStream: glob.Glob): void;
|
|
13
|
-
declare function getArgs(): minimist.ParsedArgs;
|
|
14
27
|
/**
|
|
15
|
-
*
|
|
16
|
-
* @param {
|
|
28
|
+
* Creates a directory/file tree string from an array of file paths and hashes.
|
|
29
|
+
* @param {string[]} hashArray Array of strings in the format 'relative/path/to/file hash'.
|
|
30
|
+
* @returns {string} Directory/file tree as a string, with file hashes.
|
|
31
|
+
*/
|
|
32
|
+
declare function getFileTreeString(hashArray: string[]): string;
|
|
33
|
+
/**
|
|
34
|
+
* Creates an async delay for the specified number of milliseconds.
|
|
35
|
+
* @param {number} ms Number of milliseconds to delay.
|
|
36
|
+
* @returns {Promise<void>} Promise that resolves after the specified delay.
|
|
17
37
|
*/
|
|
18
|
-
declare function delay(ms: number): Promise<
|
|
38
|
+
declare function delay(ms: number): Promise<void>;
|
|
19
39
|
|
|
20
|
-
export { del, delStream, delay, getArgs };
|
|
40
|
+
export { del, delStream, delay, getArgs, getFileTreeString, joinPathPreserveDriveLetter, parseGitRemotes };
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,20 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export function parseGitRemotes(): Promise<{}>;
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Joins all given path segments together and normalizes the resulting path.
|
|
4
|
+
* Preserves the case of the drive letter on Windows.
|
|
5
|
+
*
|
|
6
|
+
* @param {...string} segments Path segments to join.
|
|
7
|
+
* @returns {string} Normalized path with drive letter case preserved.
|
|
6
8
|
*/
|
|
7
|
-
|
|
9
|
+
export function joinPathPreserveDriveLetter(...segments: string[]): string;
|
|
8
10
|
/**
|
|
9
|
-
*
|
|
10
|
-
* @
|
|
11
|
+
* Returns parsed command line arguments using minimist.
|
|
12
|
+
* @returns {import('minimist').ParsedArgs} Parsed command line arguments
|
|
11
13
|
*/
|
|
12
|
-
|
|
13
|
-
declare function getArgs(): minimist.ParsedArgs;
|
|
14
|
+
export function getArgs(): import("minimist").ParsedArgs;
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
-
* @param {
|
|
16
|
+
* Recursively deletes a file or directory at the given path.
|
|
17
|
+
* @param {string} fullPath Absolute path to the file or directory to delete.
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
export function del(fullPath: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Handles a glob stream to delete matched files and directories recursively.
|
|
22
|
+
* @param {glob.Glob} globStream Glob stream object.
|
|
23
|
+
*/
|
|
24
|
+
export function delStream(globStream: glob.Glob): void;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a directory/file tree string from an array of file paths and hashes.
|
|
27
|
+
* @param {string[]} hashArray Array of strings in the format 'relative/path/to/file hash'.
|
|
28
|
+
* @returns {string} Directory/file tree as a string, with file hashes.
|
|
29
|
+
*/
|
|
30
|
+
export function getFileTreeString(hashArray: string[]): string;
|
|
31
|
+
/**
|
|
32
|
+
* Creates an async delay for the specified number of milliseconds.
|
|
33
|
+
* @param {number} ms Number of milliseconds to delay.
|
|
34
|
+
* @returns {Promise<void>} Promise that resolves after the specified delay.
|
|
35
|
+
*/
|
|
36
|
+
export function delay(ms: number): Promise<void>;
|