binary-collections 2.0.7 → 2.0.9
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 +5 -2
- package/bin/{git-fix-encoding → git-fix} +1 -4
- package/bin/git-fix.cmd +7 -0
- package/bin/nodekill +0 -0
- package/bin/nodekill.ps1 +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 +123 -0
- package/lib/binary-collections.d.cts +2 -0
- package/lib/binary-collections.d.mts +137 -0
- package/lib/binary-collections.d.ts +137 -0
- package/lib/binary-collections.mjs +300 -0
- package/lib/changelog.cjs +328 -0
- package/lib/changelog.d.mts +2 -0
- package/lib/changelog.d.ts +1 -0
- package/lib/changelog.js +226 -0
- package/lib/changelog.mjs +199 -0
- package/lib/chunk-4BYBVEYC.mjs +30 -0
- package/lib/{chunk-FB6YIQYR.mjs → chunk-AASHBCRW.mjs} +17 -2
- package/lib/chunk-APBWENF6.mjs +135 -0
- package/lib/{chunk-4LEXWIIF.mjs → chunk-DPKAJKFO.mjs} +2 -4
- package/lib/chunk-EGSSKVDH.mjs +66 -0
- package/lib/{chunk-3LOB2P54.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-JL32QDSH.mjs → chunk-W3ENOM53.mjs} +2 -4
- package/lib/chunk-YV7DO3YV.mjs +48 -0
- package/lib/{chunk-BSD5CIRU.mjs → chunk-YX5U7XDR.mjs} +11 -5
- 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 +87 -3
- package/lib/del-gradle.js +1 -1
- package/lib/del-gradle.mjs +4 -6
- package/lib/del-node-modules.cjs +86 -2
- package/lib/del-node-modules.mjs +3 -5
- package/lib/del-ps.cjs +89 -5
- package/lib/del-ps.js +2 -2
- package/lib/del-ps.mjs +6 -8
- package/lib/del-yarn-caches.cjs +86 -2
- package/lib/del-yarn-caches.mjs +3 -5
- package/lib/find-node-modules-cli.cjs +8 -0
- package/lib/find-node-modules-cli.mjs +2 -3
- package/lib/find-node-modules.cjs +8 -0
- package/lib/find-node-modules.d.mts +3 -0
- package/lib/find-node-modules.d.ts +3 -0
- package/lib/find-node-modules.js +12 -0
- package/lib/find-node-modules.mjs +2 -3
- 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 +23 -24
- package/lib/git-diff.d.mts +25 -28
- package/lib/git-diff.d.ts +25 -28
- package/lib/git-diff.mjs +32 -27
- 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 +86 -2
- package/lib/git-purge.mjs +3 -5
- package/lib/index.cjs +8 -0
- package/lib/index.mjs +3 -5
- package/lib/npm-run-series.cjs +140 -1
- package/lib/npm-run-series.js +2 -1
- package/lib/npm-run-series.mjs +7 -5
- package/lib/package-resolutions-updater.cjs +447 -0
- package/lib/package-resolutions-updater.d.mts +1 -0
- package/lib/package-resolutions-updater.d.ts +352 -0
- package/lib/package-resolutions-updater.mjs +339 -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.mjs +2 -3
- package/lib/ps/index.cjs +3 -3
- package/lib/ps/index.d.mjs +1 -2
- package/lib/ps/index.js +6 -3
- package/lib/ps/index.mjs +9 -11
- package/lib/ps/isWin.mjs +2 -3
- package/lib/ps/table-parser.mjs +3 -4
- package/lib/submodule-install.cjs +18 -35
- package/lib/submodule-install.d.mts +17 -37
- package/lib/submodule-install.d.ts +17 -37
- package/lib/submodule-install.mjs +21 -29
- package/lib/utils.cjs +86 -2
- package/lib/utils.d.mts +29 -9
- package/lib/utils.d.ts +28 -8
- package/lib/utils.js +139 -8
- package/lib/utils.mjs +2 -3
- package/lib/yarn-reinstall.cjs +9 -7
- package/lib/yarn-reinstall.d.mts +12 -8
- package/lib/yarn-reinstall.d.ts +12 -8
- package/lib/yarn-reinstall.mjs +14 -10
- package/package.json +109 -80
- package/readme.md +74 -11
- package/src/package-resolutions-updater.mjs +350 -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/lib/chunk-OKYLF2MU.mjs +0 -53
- package/lib/chunk-VXZQNLPU.mjs +0 -23
- 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.mjs +0 -31
- /package/bin/{submodule-install → submodule-install.txt} +0 -0
package/lib/ps/index.js
CHANGED
|
@@ -185,7 +185,8 @@ exports.kill = function (pid, signal, next) {
|
|
|
185
185
|
return;
|
|
186
186
|
if (err) {
|
|
187
187
|
clearTimeout(checkTimeoutTimer);
|
|
188
|
-
|
|
188
|
+
if (finishCallback)
|
|
189
|
+
finishCallback(err);
|
|
189
190
|
}
|
|
190
191
|
else if (list.length > 0) {
|
|
191
192
|
checkConfident = checkConfident - 1 || 0;
|
|
@@ -195,7 +196,8 @@ exports.kill = function (pid, signal, next) {
|
|
|
195
196
|
checkConfident++;
|
|
196
197
|
if (checkConfident === 5) {
|
|
197
198
|
clearTimeout(checkTimeoutTimer);
|
|
198
|
-
|
|
199
|
+
if (finishCallback)
|
|
200
|
+
finishCallback();
|
|
199
201
|
}
|
|
200
202
|
else {
|
|
201
203
|
checkKilled(finishCallback);
|
|
@@ -203,7 +205,8 @@ exports.kill = function (pid, signal, next) {
|
|
|
203
205
|
}
|
|
204
206
|
});
|
|
205
207
|
}
|
|
206
|
-
|
|
208
|
+
if (next)
|
|
209
|
+
checkKilled(next);
|
|
207
210
|
checkTimeoutTimer =
|
|
208
211
|
next &&
|
|
209
212
|
setTimeout(function () {
|
package/lib/ps/index.mjs
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
require_table_parser
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-G3THLIDT.mjs";
|
|
5
|
+
import "../chunk-DPKAJKFO.mjs";
|
|
6
6
|
import {
|
|
7
7
|
require_isWin
|
|
8
|
-
} from "../chunk-
|
|
9
|
-
import {
|
|
10
|
-
init_esm_shims
|
|
11
|
-
} from "../chunk-VXZQNLPU.mjs";
|
|
8
|
+
} from "../chunk-W3ENOM53.mjs";
|
|
12
9
|
import {
|
|
13
10
|
__commonJS,
|
|
14
|
-
__require
|
|
15
|
-
|
|
11
|
+
__require,
|
|
12
|
+
init_esm_shims
|
|
13
|
+
} from "../chunk-AASHBCRW.mjs";
|
|
16
14
|
|
|
17
15
|
// src/ps/index.js
|
|
18
16
|
var require_ps = __commonJS({
|
|
@@ -149,7 +147,7 @@ var require_ps = __commonJS({
|
|
|
149
147
|
if (checkIsTimeout) return;
|
|
150
148
|
if (err) {
|
|
151
149
|
clearTimeout(checkTimeoutTimer);
|
|
152
|
-
finishCallback
|
|
150
|
+
if (finishCallback) finishCallback(err);
|
|
153
151
|
} else if (list.length > 0) {
|
|
154
152
|
checkConfident = checkConfident - 1 || 0;
|
|
155
153
|
checkKilled(finishCallback);
|
|
@@ -157,14 +155,14 @@ var require_ps = __commonJS({
|
|
|
157
155
|
checkConfident++;
|
|
158
156
|
if (checkConfident === 5) {
|
|
159
157
|
clearTimeout(checkTimeoutTimer);
|
|
160
|
-
finishCallback
|
|
158
|
+
if (finishCallback) finishCallback();
|
|
161
159
|
} else {
|
|
162
160
|
checkKilled(finishCallback);
|
|
163
161
|
}
|
|
164
162
|
}
|
|
165
163
|
});
|
|
166
164
|
}
|
|
167
|
-
next
|
|
165
|
+
if (next) checkKilled(next);
|
|
168
166
|
checkTimeoutTimer = next && setTimeout(function() {
|
|
169
167
|
checkIsTimeout = true;
|
|
170
168
|
next(new Error("Kill process timeout"));
|
package/lib/ps/isWin.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
require_isWin
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-FB6YIQYR.mjs";
|
|
4
|
+
} from "../chunk-W3ENOM53.mjs";
|
|
5
|
+
import "../chunk-AASHBCRW.mjs";
|
|
7
6
|
export default require_isWin();
|
package/lib/ps/table-parser.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
require_table_parser
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-FB6YIQYR.mjs";
|
|
4
|
+
} from "../chunk-G3THLIDT.mjs";
|
|
5
|
+
import "../chunk-DPKAJKFO.mjs";
|
|
6
|
+
import "../chunk-AASHBCRW.mjs";
|
|
8
7
|
export default require_table_parser();
|
|
@@ -3,39 +3,22 @@
|
|
|
3
3
|
const { spawnSync } = require("child_process");
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const path = require("path");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (fs.existsSync(envPath))
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (!trimmedLine || trimmedLine.startsWith("#"))
|
|
16
|
-
return;
|
|
17
|
-
// Extract key and value
|
|
18
|
-
const [key, ...vals] = trimmedLine.split("=");
|
|
19
|
-
if (!key)
|
|
20
|
-
return;
|
|
21
|
-
const value = vals
|
|
22
|
-
.join("=")
|
|
23
|
-
.trim()
|
|
24
|
-
.replace(/^['"]|['"]$/g, ""); // Remove surrounding quotes
|
|
25
|
-
process.env[key.trim()] = value;
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
// Parse CLI args
|
|
29
|
-
const args = process.argv.slice(2);
|
|
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
|
+
const ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
|
|
30
15
|
let ROOT = runGit(["rev-parse", "--show-toplevel"]).trim();
|
|
31
16
|
let REPO_PATH = ROOT;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
ROOT = path.resolve(args[i].split("=")[1]);
|
|
38
|
-
}
|
|
17
|
+
if (args.cwd) {
|
|
18
|
+
ROOT = path.resolve(args.cwd);
|
|
19
|
+
}
|
|
20
|
+
else if (positional.length > 0) {
|
|
21
|
+
ROOT = path.resolve(positional[0]);
|
|
39
22
|
}
|
|
40
23
|
console.log(`Installing submodules at ${ROOT}`);
|
|
41
24
|
// Get submodule paths
|
|
@@ -72,22 +55,22 @@ for (const line of submoduleList) {
|
|
|
72
55
|
continue;
|
|
73
56
|
}
|
|
74
57
|
const GIT_MODULES = path.join(RELATIVE_MODULE_PATH, ".gitmodules");
|
|
75
|
-
if (
|
|
58
|
+
if (ACCESS_TOKEN) {
|
|
76
59
|
let URL_WITH_TOKEN = "";
|
|
77
60
|
let repoInfo;
|
|
78
61
|
if (URL.includes("github.com")) {
|
|
79
62
|
repoInfo = URL.replace("https://github.com/", "");
|
|
80
|
-
URL_WITH_TOKEN = `https://${
|
|
63
|
+
URL_WITH_TOKEN = `https://${ACCESS_TOKEN}@github.com/${repoInfo}`;
|
|
81
64
|
}
|
|
82
65
|
else if (URL.includes("gitlab.com") && typeof process.env.GITLAB_TOKEN === "string") {
|
|
83
66
|
repoInfo = URL.replace("https://gitlab.com/", "");
|
|
84
|
-
URL_WITH_TOKEN = `https://oauth2:${
|
|
67
|
+
URL_WITH_TOKEN = `https://oauth2:${ACCESS_TOKEN}@gitlab.com/${repoInfo}`;
|
|
85
68
|
}
|
|
86
69
|
else {
|
|
87
70
|
// For other Git providers, try a generic approach
|
|
88
71
|
const urlObj = new URL(URL);
|
|
89
72
|
repoInfo = urlObj.pathname.substring(1); // Remove leading slash
|
|
90
|
-
URL_WITH_TOKEN = `${urlObj.protocol}//${
|
|
73
|
+
URL_WITH_TOKEN = `${urlObj.protocol}//${ACCESS_TOKEN}@${urlObj.host}${urlObj.pathname}`;
|
|
91
74
|
}
|
|
92
75
|
if (URL_WITH_TOKEN && URL_WITH_TOKEN.length > 0) {
|
|
93
76
|
console.log(`Apply token for ${repoInfo} at ${MODULE_PATH} branch ${BRANCH}`);
|
|
@@ -1,45 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const { spawnSync } = require("child_process");
|
|
3
|
+
|
|
3
4
|
const fs = require("fs");
|
|
4
5
|
const path = require("path");
|
|
6
|
+
const dotenv = require("dotenv");
|
|
5
7
|
|
|
6
|
-
//
|
|
7
|
-
const envPath = path.resolve(
|
|
8
|
-
|
|
9
|
-
// Check if .env exists and read it
|
|
10
|
-
if (fs.existsSync(envPath)) {
|
|
11
|
-
const envContent = fs.readFileSync(envPath, "utf8");
|
|
12
|
-
|
|
13
|
-
// Split into lines and process each
|
|
14
|
-
envContent.split("\n").forEach((line) => {
|
|
15
|
-
const trimmedLine = line.trim();
|
|
16
|
-
|
|
17
|
-
// Ignore empty lines and comments
|
|
18
|
-
if (!trimmedLine || trimmedLine.startsWith("#")) return;
|
|
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 });
|
|
19
11
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const value = vals
|
|
25
|
-
.join("=")
|
|
26
|
-
.trim()
|
|
27
|
-
.replace(/^['"]|['"]$/g, ""); // Remove surrounding quotes
|
|
28
|
-
process.env[key.trim()] = value;
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Parse CLI args
|
|
33
|
-
const args = process.argv.slice(2);
|
|
12
|
+
const { getArgs } = require("./utils.js");
|
|
13
|
+
const args = getArgs();
|
|
14
|
+
const positional = args._ || [];
|
|
15
|
+
const ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
|
|
34
16
|
let ROOT = runGit(["rev-parse", "--show-toplevel"]).trim();
|
|
35
17
|
let REPO_PATH = ROOT;
|
|
36
18
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
ROOT = path.resolve(args[i].split("=")[1]);
|
|
42
|
-
}
|
|
19
|
+
if (args.cwd) {
|
|
20
|
+
ROOT = path.resolve(args.cwd);
|
|
21
|
+
} else if (positional.length > 0) {
|
|
22
|
+
ROOT = path.resolve(positional[0]);
|
|
43
23
|
}
|
|
44
24
|
|
|
45
25
|
console.log(`Installing submodules at ${ROOT}`);
|
|
@@ -88,21 +68,21 @@ for (const line of submoduleList) {
|
|
|
88
68
|
|
|
89
69
|
const GIT_MODULES = path.join(RELATIVE_MODULE_PATH, ".gitmodules");
|
|
90
70
|
|
|
91
|
-
if (
|
|
71
|
+
if (ACCESS_TOKEN) {
|
|
92
72
|
let URL_WITH_TOKEN = "";
|
|
93
73
|
let repoInfo;
|
|
94
74
|
|
|
95
75
|
if (URL.includes("github.com")) {
|
|
96
76
|
repoInfo = URL.replace("https://github.com/", "");
|
|
97
|
-
URL_WITH_TOKEN = `https://${
|
|
77
|
+
URL_WITH_TOKEN = `https://${ACCESS_TOKEN}@github.com/${repoInfo}`;
|
|
98
78
|
} else if (URL.includes("gitlab.com") && typeof process.env.GITLAB_TOKEN === "string") {
|
|
99
79
|
repoInfo = URL.replace("https://gitlab.com/", "");
|
|
100
|
-
URL_WITH_TOKEN = `https://oauth2:${
|
|
80
|
+
URL_WITH_TOKEN = `https://oauth2:${ACCESS_TOKEN}@gitlab.com/${repoInfo}`;
|
|
101
81
|
} else {
|
|
102
82
|
// For other Git providers, try a generic approach
|
|
103
83
|
const urlObj = new URL(URL);
|
|
104
84
|
repoInfo = urlObj.pathname.substring(1); // Remove leading slash
|
|
105
|
-
URL_WITH_TOKEN = `${urlObj.protocol}//${
|
|
85
|
+
URL_WITH_TOKEN = `${urlObj.protocol}//${ACCESS_TOKEN}@${urlObj.host}${urlObj.pathname}`;
|
|
106
86
|
}
|
|
107
87
|
|
|
108
88
|
if (URL_WITH_TOKEN && URL_WITH_TOKEN.length > 0) {
|
|
@@ -1,45 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const { spawnSync } = require("child_process");
|
|
3
|
+
|
|
3
4
|
const fs = require("fs");
|
|
4
5
|
const path = require("path");
|
|
6
|
+
const dotenv = require("dotenv");
|
|
5
7
|
|
|
6
|
-
//
|
|
7
|
-
const envPath = path.resolve(
|
|
8
|
-
|
|
9
|
-
// Check if .env exists and read it
|
|
10
|
-
if (fs.existsSync(envPath)) {
|
|
11
|
-
const envContent = fs.readFileSync(envPath, "utf8");
|
|
12
|
-
|
|
13
|
-
// Split into lines and process each
|
|
14
|
-
envContent.split("\n").forEach((line) => {
|
|
15
|
-
const trimmedLine = line.trim();
|
|
16
|
-
|
|
17
|
-
// Ignore empty lines and comments
|
|
18
|
-
if (!trimmedLine || trimmedLine.startsWith("#")) return;
|
|
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 });
|
|
19
11
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const value = vals
|
|
25
|
-
.join("=")
|
|
26
|
-
.trim()
|
|
27
|
-
.replace(/^['"]|['"]$/g, ""); // Remove surrounding quotes
|
|
28
|
-
process.env[key.trim()] = value;
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Parse CLI args
|
|
33
|
-
const args = process.argv.slice(2);
|
|
12
|
+
const { getArgs } = require("./utils.js");
|
|
13
|
+
const args = getArgs();
|
|
14
|
+
const positional = args._ || [];
|
|
15
|
+
const ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
|
|
34
16
|
let ROOT = runGit(["rev-parse", "--show-toplevel"]).trim();
|
|
35
17
|
let REPO_PATH = ROOT;
|
|
36
18
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
ROOT = path.resolve(args[i].split("=")[1]);
|
|
42
|
-
}
|
|
19
|
+
if (args.cwd) {
|
|
20
|
+
ROOT = path.resolve(args.cwd);
|
|
21
|
+
} else if (positional.length > 0) {
|
|
22
|
+
ROOT = path.resolve(positional[0]);
|
|
43
23
|
}
|
|
44
24
|
|
|
45
25
|
console.log(`Installing submodules at ${ROOT}`);
|
|
@@ -88,21 +68,21 @@ for (const line of submoduleList) {
|
|
|
88
68
|
|
|
89
69
|
const GIT_MODULES = path.join(RELATIVE_MODULE_PATH, ".gitmodules");
|
|
90
70
|
|
|
91
|
-
if (
|
|
71
|
+
if (ACCESS_TOKEN) {
|
|
92
72
|
let URL_WITH_TOKEN = "";
|
|
93
73
|
let repoInfo;
|
|
94
74
|
|
|
95
75
|
if (URL.includes("github.com")) {
|
|
96
76
|
repoInfo = URL.replace("https://github.com/", "");
|
|
97
|
-
URL_WITH_TOKEN = `https://${
|
|
77
|
+
URL_WITH_TOKEN = `https://${ACCESS_TOKEN}@github.com/${repoInfo}`;
|
|
98
78
|
} else if (URL.includes("gitlab.com") && typeof process.env.GITLAB_TOKEN === "string") {
|
|
99
79
|
repoInfo = URL.replace("https://gitlab.com/", "");
|
|
100
|
-
URL_WITH_TOKEN = `https://oauth2:${
|
|
80
|
+
URL_WITH_TOKEN = `https://oauth2:${ACCESS_TOKEN}@gitlab.com/${repoInfo}`;
|
|
101
81
|
} else {
|
|
102
82
|
// For other Git providers, try a generic approach
|
|
103
83
|
const urlObj = new URL(URL);
|
|
104
84
|
repoInfo = urlObj.pathname.substring(1); // Remove leading slash
|
|
105
|
-
URL_WITH_TOKEN = `${urlObj.protocol}//${
|
|
85
|
+
URL_WITH_TOKEN = `${urlObj.protocol}//${ACCESS_TOKEN}@${urlObj.host}${urlObj.pathname}`;
|
|
106
86
|
}
|
|
107
87
|
|
|
108
88
|
if (URL_WITH_TOKEN && URL_WITH_TOKEN.length > 0) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
init_esm_shims
|
|
7
|
-
} from "./chunk-VXZQNLPU.mjs";
|
|
4
|
+
require_utils
|
|
5
|
+
} from "./chunk-APBWENF6.mjs";
|
|
8
6
|
import {
|
|
9
7
|
__commonJS,
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
__filename,
|
|
9
|
+
__require,
|
|
10
|
+
init_esm_shims
|
|
11
|
+
} from "./chunk-AASHBCRW.mjs";
|
|
12
12
|
|
|
13
13
|
// src/submodule-install.cjs
|
|
14
14
|
var require_submodule_install = __commonJS({
|
|
@@ -17,27 +17,19 @@ var require_submodule_install = __commonJS({
|
|
|
17
17
|
var { spawnSync } = __require("child_process");
|
|
18
18
|
var fs = __require("fs");
|
|
19
19
|
var path = __require("path");
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (!key) return;
|
|
28
|
-
const value = vals.join("=").trim().replace(/^['"]|['"]$/g, "");
|
|
29
|
-
process.env[key.trim()] = value;
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
var args = process.argv.slice(2);
|
|
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 ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
|
|
33
27
|
var ROOT = runGit(["rev-parse", "--show-toplevel"]).trim();
|
|
34
28
|
var REPO_PATH = ROOT;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
ROOT = path.resolve(args[i].split("=")[1]);
|
|
40
|
-
}
|
|
29
|
+
if (args.cwd) {
|
|
30
|
+
ROOT = path.resolve(args.cwd);
|
|
31
|
+
} else if (positional.length > 0) {
|
|
32
|
+
ROOT = path.resolve(positional[0]);
|
|
41
33
|
}
|
|
42
34
|
console.log(`Installing submodules at ${ROOT}`);
|
|
43
35
|
var submoduleList = runGit([
|
|
@@ -72,19 +64,19 @@ var require_submodule_install = __commonJS({
|
|
|
72
64
|
continue;
|
|
73
65
|
}
|
|
74
66
|
const GIT_MODULES = path.join(RELATIVE_MODULE_PATH, ".gitmodules");
|
|
75
|
-
if (
|
|
67
|
+
if (ACCESS_TOKEN) {
|
|
76
68
|
let URL_WITH_TOKEN = "";
|
|
77
69
|
let repoInfo;
|
|
78
70
|
if (URL.includes("github.com")) {
|
|
79
71
|
repoInfo = URL.replace("https://github.com/", "");
|
|
80
|
-
URL_WITH_TOKEN = `https://${
|
|
72
|
+
URL_WITH_TOKEN = `https://${ACCESS_TOKEN}@github.com/${repoInfo}`;
|
|
81
73
|
} else if (URL.includes("gitlab.com") && typeof process.env.GITLAB_TOKEN === "string") {
|
|
82
74
|
repoInfo = URL.replace("https://gitlab.com/", "");
|
|
83
|
-
URL_WITH_TOKEN = `https://oauth2:${
|
|
75
|
+
URL_WITH_TOKEN = `https://oauth2:${ACCESS_TOKEN}@gitlab.com/${repoInfo}`;
|
|
84
76
|
} else {
|
|
85
77
|
const urlObj = new URL(URL);
|
|
86
78
|
repoInfo = urlObj.pathname.substring(1);
|
|
87
|
-
URL_WITH_TOKEN = `${urlObj.protocol}//${
|
|
79
|
+
URL_WITH_TOKEN = `${urlObj.protocol}//${ACCESS_TOKEN}@${urlObj.host}${urlObj.pathname}`;
|
|
88
80
|
}
|
|
89
81
|
if (URL_WITH_TOKEN && URL_WITH_TOKEN.length > 0) {
|
|
90
82
|
console.log(`Apply token for ${repoInfo} at ${MODULE_PATH} branch ${BRANCH}`);
|
package/lib/utils.cjs
CHANGED
|
@@ -1,9 +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
|
}
|
|
51
|
+
module.exports.getArgs = getArgs;
|
|
7
52
|
function del(fullPath) {
|
|
8
53
|
if (fs.statSync(fullPath).isDirectory()) {
|
|
9
54
|
const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
|
|
@@ -19,6 +64,7 @@ function del(fullPath) {
|
|
|
19
64
|
}
|
|
20
65
|
}
|
|
21
66
|
}
|
|
67
|
+
module.exports.del = del;
|
|
22
68
|
function delStream(globStream) {
|
|
23
69
|
globStream.stream().on("data", (result) => {
|
|
24
70
|
const fullPath = path.resolve(process.cwd(), result);
|
|
@@ -31,5 +77,43 @@ function delStream(globStream) {
|
|
|
31
77
|
del(fullPath);
|
|
32
78
|
});
|
|
33
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,16 +1,36 @@
|
|
|
1
|
+
export function parseGitRemotes(): Promise<{}>;
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
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.
|
|
8
|
+
*/
|
|
9
|
+
export function joinPathPreserveDriveLetter(...segments: string[]): string;
|
|
10
|
+
/**
|
|
11
|
+
* Returns parsed command line arguments using minimist.
|
|
12
|
+
* @returns {import('minimist').ParsedArgs} Parsed command line arguments
|
|
13
|
+
*/
|
|
14
|
+
export function getArgs(): import("minimist").ParsedArgs;
|
|
15
|
+
/**
|
|
16
|
+
* Recursively deletes a file or directory at the given path.
|
|
17
|
+
* @param {string} fullPath Absolute path to the file or directory to delete.
|
|
4
18
|
*/
|
|
5
19
|
export function del(fullPath: string): void;
|
|
6
20
|
/**
|
|
7
|
-
* glob stream
|
|
8
|
-
* @param {glob.Glob} globStream
|
|
21
|
+
* Handles a glob stream to delete matched files and directories recursively.
|
|
22
|
+
* @param {glob.Glob} globStream Glob stream object.
|
|
9
23
|
*/
|
|
10
24
|
export function delStream(globStream: glob.Glob): void;
|
|
11
|
-
export function getArgs(): import("minimist").ParsedArgs;
|
|
12
25
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @param {
|
|
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.
|
|
15
35
|
*/
|
|
16
|
-
export function delay(ms: number): Promise<
|
|
36
|
+
export function delay(ms: number): Promise<void>;
|