binary-collections 2.0.8 → 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/lib/binary-collections.cjs +19 -1
- package/lib/binary-collections.d.mts +17 -1
- package/lib/binary-collections.d.ts +17 -1
- package/lib/binary-collections.mjs +192 -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/clean-github-actions-caches.cjs +1 -1
- package/lib/clean-github-actions-caches.d.mts +1 -1
- package/lib/clean-github-actions-caches.d.ts +1 -1
- package/lib/clean-github-actions-caches.mjs +1 -1
- package/lib/git-fix.mjs +3 -3
- package/lib/package-resolutions-updater.cjs +174 -1
- package/lib/package-resolutions-updater.d.ts +27 -1
- package/lib/package-resolutions-updater.mjs +24 -1
- package/lib/submodule-install.cjs +5 -4
- package/lib/submodule-install.d.mts +5 -5
- package/lib/submodule-install.d.ts +5 -5
- package/lib/submodule-install.mjs +5 -4
- package/package.json +1 -1
- package/src/package-resolutions-updater.mjs +26 -1
- package/tmp/test-repo/package.json +1 -1
|
@@ -4,6 +4,8 @@ import fs from 'fs';
|
|
|
4
4
|
import https from 'https';
|
|
5
5
|
import os from 'os';
|
|
6
6
|
import path from 'path';
|
|
7
|
+
import { getArgs } from './utils.js';
|
|
8
|
+
import 'minimist';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* 📦 GitHub Package Resolver
|
|
@@ -35,6 +37,30 @@ import path from 'path';
|
|
|
35
37
|
|
|
36
38
|
const projectDir = process.cwd();
|
|
37
39
|
const envPath = path.join(projectDir, ".env");
|
|
40
|
+
const args = getArgs();
|
|
41
|
+
const ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
|
|
42
|
+
|
|
43
|
+
// Show help if --help/-h is passed
|
|
44
|
+
if (args.help || args.h) {
|
|
45
|
+
showHelp();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Display help information for the package-resolutions-updater script.
|
|
50
|
+
*/
|
|
51
|
+
function showHelp() {
|
|
52
|
+
const helpText = `\n\
|
|
53
|
+
GitHub Package Resolutions Updater\n\
|
|
54
|
+
Usage:\n node src/package-resolutions-updater.mjs [options]\n\
|
|
55
|
+
Options:\n --help, -h Show this help message\n\
|
|
56
|
+
Description:\n Updates the commit hashes in package.json's 'resolutions' field for GitHub tarball URLs to point to the latest commit SHA of the corresponding repository and branch.\n\
|
|
57
|
+
Features:\n - Parses GitHub URLs to extract repository owner, name, and branch.\n - Fetches the latest commit SHA across all branches using GitHub's API.\n - Replaces the old branch or commit in the URL with the latest SHA.\n - Overwrites package.json with the updated URLs.\n\
|
|
58
|
+
Requirements:\n - GitHub Personal Access Token (GITHUB_TOKEN) via .env\n - ESM support (type: "module" in package.json)\n - Node.js v18+ recommended\n\
|
|
59
|
+
Dependencies:\n - ansi-colors – for styled terminal output\n - dotenv – to load GitHub token from .env\n\
|
|
60
|
+
Examples:\n node src/package-resolutions-updater.mjs\n node src/package-resolutions-updater.mjs --help\n\n`;
|
|
61
|
+
console.log(helpText);
|
|
62
|
+
process.exit(0);
|
|
63
|
+
}
|
|
38
64
|
|
|
39
65
|
// Load the .env file using dotenv (ESM import)
|
|
40
66
|
if (fs.existsSync(envPath)) dotenv.config({ path: envPath });
|
|
@@ -128,7 +154,7 @@ function fetchJson(url) {
|
|
|
128
154
|
"User-Agent": selectedUserAgent,
|
|
129
155
|
Accept: "application/vnd.github.v3+json",
|
|
130
156
|
"X-GitHub-Api-Version": "2022-11-28",
|
|
131
|
-
...(
|
|
157
|
+
...(ACCESS_TOKEN ? { Authorization: `token ${ACCESS_TOKEN}` } : {})
|
|
132
158
|
};
|
|
133
159
|
return new Promise((resolve, reject) => {
|
|
134
160
|
https
|
|
@@ -39,8 +39,31 @@ import fs from "fs";
|
|
|
39
39
|
import https from "https";
|
|
40
40
|
import os from "os";
|
|
41
41
|
import path from "path";
|
|
42
|
+
import { getArgs } from "./utils.js";
|
|
42
43
|
const projectDir = process.cwd();
|
|
43
44
|
const envPath = path.join(projectDir, ".env");
|
|
45
|
+
const args = getArgs();
|
|
46
|
+
const ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
|
|
47
|
+
// Show help if --help/-h is passed
|
|
48
|
+
if (args.help || args.h) {
|
|
49
|
+
showHelp();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Display help information for the package-resolutions-updater script.
|
|
53
|
+
*/
|
|
54
|
+
function showHelp() {
|
|
55
|
+
const helpText = `\n\
|
|
56
|
+
GitHub Package Resolutions Updater\n\
|
|
57
|
+
Usage:\n node src/package-resolutions-updater.mjs [options]\n\
|
|
58
|
+
Options:\n --help, -h Show this help message\n\
|
|
59
|
+
Description:\n Updates the commit hashes in package.json's 'resolutions' field for GitHub tarball URLs to point to the latest commit SHA of the corresponding repository and branch.\n\
|
|
60
|
+
Features:\n - Parses GitHub URLs to extract repository owner, name, and branch.\n - Fetches the latest commit SHA across all branches using GitHub's API.\n - Replaces the old branch or commit in the URL with the latest SHA.\n - Overwrites package.json with the updated URLs.\n\
|
|
61
|
+
Requirements:\n - GitHub Personal Access Token (GITHUB_TOKEN) via .env\n - ESM support (type: "module" in package.json)\n - Node.js v18+ recommended\n\
|
|
62
|
+
Dependencies:\n - ansi-colors – for styled terminal output\n - dotenv – to load GitHub token from .env\n\
|
|
63
|
+
Examples:\n node src/package-resolutions-updater.mjs\n node src/package-resolutions-updater.mjs --help\n\n`;
|
|
64
|
+
console.log(helpText);
|
|
65
|
+
process.exit(0);
|
|
66
|
+
}
|
|
44
67
|
// Load the .env file using dotenv (ESM import)
|
|
45
68
|
if (fs.existsSync(envPath))
|
|
46
69
|
dotenv.config({ path: envPath });
|
|
@@ -128,7 +151,7 @@ catch (_e) {
|
|
|
128
151
|
* @returns {Promise<any>}
|
|
129
152
|
*/
|
|
130
153
|
function fetchJson(url) {
|
|
131
|
-
const headers = Object.assign({ "User-Agent": selectedUserAgent, Accept: "application/vnd.github.v3+json", "X-GitHub-Api-Version": "2022-11-28" }, (
|
|
154
|
+
const headers = Object.assign({ "User-Agent": selectedUserAgent, Accept: "application/vnd.github.v3+json", "X-GitHub-Api-Version": "2022-11-28" }, (ACCESS_TOKEN ? { Authorization: `token ${ACCESS_TOKEN}` } : {}));
|
|
132
155
|
return new Promise((resolve, reject) => {
|
|
133
156
|
https
|
|
134
157
|
.get(url, { headers }, (res) => {
|
|
@@ -11,6 +11,7 @@ if (fs.existsSync(envPath))
|
|
|
11
11
|
const { getArgs } = require("./utils.js");
|
|
12
12
|
const args = getArgs();
|
|
13
13
|
const positional = args._ || [];
|
|
14
|
+
const ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
|
|
14
15
|
let ROOT = runGit(["rev-parse", "--show-toplevel"]).trim();
|
|
15
16
|
let REPO_PATH = ROOT;
|
|
16
17
|
if (args.cwd) {
|
|
@@ -54,22 +55,22 @@ for (const line of submoduleList) {
|
|
|
54
55
|
continue;
|
|
55
56
|
}
|
|
56
57
|
const GIT_MODULES = path.join(RELATIVE_MODULE_PATH, ".gitmodules");
|
|
57
|
-
if (
|
|
58
|
+
if (ACCESS_TOKEN) {
|
|
58
59
|
let URL_WITH_TOKEN = "";
|
|
59
60
|
let repoInfo;
|
|
60
61
|
if (URL.includes("github.com")) {
|
|
61
62
|
repoInfo = URL.replace("https://github.com/", "");
|
|
62
|
-
URL_WITH_TOKEN = `https://${
|
|
63
|
+
URL_WITH_TOKEN = `https://${ACCESS_TOKEN}@github.com/${repoInfo}`;
|
|
63
64
|
}
|
|
64
65
|
else if (URL.includes("gitlab.com") && typeof process.env.GITLAB_TOKEN === "string") {
|
|
65
66
|
repoInfo = URL.replace("https://gitlab.com/", "");
|
|
66
|
-
URL_WITH_TOKEN = `https://oauth2:${
|
|
67
|
+
URL_WITH_TOKEN = `https://oauth2:${ACCESS_TOKEN}@gitlab.com/${repoInfo}`;
|
|
67
68
|
}
|
|
68
69
|
else {
|
|
69
70
|
// For other Git providers, try a generic approach
|
|
70
71
|
const urlObj = new URL(URL);
|
|
71
72
|
repoInfo = urlObj.pathname.substring(1); // Remove leading slash
|
|
72
|
-
URL_WITH_TOKEN = `${urlObj.protocol}//${
|
|
73
|
+
URL_WITH_TOKEN = `${urlObj.protocol}//${ACCESS_TOKEN}@${urlObj.host}${urlObj.pathname}`;
|
|
73
74
|
}
|
|
74
75
|
if (URL_WITH_TOKEN && URL_WITH_TOKEN.length > 0) {
|
|
75
76
|
console.log(`Apply token for ${repoInfo} at ${MODULE_PATH} branch ${BRANCH}`);
|
|
@@ -12,7 +12,7 @@ if (fs.existsSync(envPath)) dotenv.config({ path: envPath });
|
|
|
12
12
|
const { getArgs } = require("./utils.js");
|
|
13
13
|
const args = getArgs();
|
|
14
14
|
const positional = args._ || [];
|
|
15
|
-
|
|
15
|
+
const ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
|
|
16
16
|
let ROOT = runGit(["rev-parse", "--show-toplevel"]).trim();
|
|
17
17
|
let REPO_PATH = ROOT;
|
|
18
18
|
|
|
@@ -68,21 +68,21 @@ for (const line of submoduleList) {
|
|
|
68
68
|
|
|
69
69
|
const GIT_MODULES = path.join(RELATIVE_MODULE_PATH, ".gitmodules");
|
|
70
70
|
|
|
71
|
-
if (
|
|
71
|
+
if (ACCESS_TOKEN) {
|
|
72
72
|
let URL_WITH_TOKEN = "";
|
|
73
73
|
let repoInfo;
|
|
74
74
|
|
|
75
75
|
if (URL.includes("github.com")) {
|
|
76
76
|
repoInfo = URL.replace("https://github.com/", "");
|
|
77
|
-
URL_WITH_TOKEN = `https://${
|
|
77
|
+
URL_WITH_TOKEN = `https://${ACCESS_TOKEN}@github.com/${repoInfo}`;
|
|
78
78
|
} else if (URL.includes("gitlab.com") && typeof process.env.GITLAB_TOKEN === "string") {
|
|
79
79
|
repoInfo = URL.replace("https://gitlab.com/", "");
|
|
80
|
-
URL_WITH_TOKEN = `https://oauth2:${
|
|
80
|
+
URL_WITH_TOKEN = `https://oauth2:${ACCESS_TOKEN}@gitlab.com/${repoInfo}`;
|
|
81
81
|
} else {
|
|
82
82
|
// For other Git providers, try a generic approach
|
|
83
83
|
const urlObj = new URL(URL);
|
|
84
84
|
repoInfo = urlObj.pathname.substring(1); // Remove leading slash
|
|
85
|
-
URL_WITH_TOKEN = `${urlObj.protocol}//${
|
|
85
|
+
URL_WITH_TOKEN = `${urlObj.protocol}//${ACCESS_TOKEN}@${urlObj.host}${urlObj.pathname}`;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
if (URL_WITH_TOKEN && URL_WITH_TOKEN.length > 0) {
|
|
@@ -12,7 +12,7 @@ if (fs.existsSync(envPath)) dotenv.config({ path: envPath });
|
|
|
12
12
|
const { getArgs } = require("./utils.js");
|
|
13
13
|
const args = getArgs();
|
|
14
14
|
const positional = args._ || [];
|
|
15
|
-
|
|
15
|
+
const ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
|
|
16
16
|
let ROOT = runGit(["rev-parse", "--show-toplevel"]).trim();
|
|
17
17
|
let REPO_PATH = ROOT;
|
|
18
18
|
|
|
@@ -68,21 +68,21 @@ for (const line of submoduleList) {
|
|
|
68
68
|
|
|
69
69
|
const GIT_MODULES = path.join(RELATIVE_MODULE_PATH, ".gitmodules");
|
|
70
70
|
|
|
71
|
-
if (
|
|
71
|
+
if (ACCESS_TOKEN) {
|
|
72
72
|
let URL_WITH_TOKEN = "";
|
|
73
73
|
let repoInfo;
|
|
74
74
|
|
|
75
75
|
if (URL.includes("github.com")) {
|
|
76
76
|
repoInfo = URL.replace("https://github.com/", "");
|
|
77
|
-
URL_WITH_TOKEN = `https://${
|
|
77
|
+
URL_WITH_TOKEN = `https://${ACCESS_TOKEN}@github.com/${repoInfo}`;
|
|
78
78
|
} else if (URL.includes("gitlab.com") && typeof process.env.GITLAB_TOKEN === "string") {
|
|
79
79
|
repoInfo = URL.replace("https://gitlab.com/", "");
|
|
80
|
-
URL_WITH_TOKEN = `https://oauth2:${
|
|
80
|
+
URL_WITH_TOKEN = `https://oauth2:${ACCESS_TOKEN}@gitlab.com/${repoInfo}`;
|
|
81
81
|
} else {
|
|
82
82
|
// For other Git providers, try a generic approach
|
|
83
83
|
const urlObj = new URL(URL);
|
|
84
84
|
repoInfo = urlObj.pathname.substring(1); // Remove leading slash
|
|
85
|
-
URL_WITH_TOKEN = `${urlObj.protocol}//${
|
|
85
|
+
URL_WITH_TOKEN = `${urlObj.protocol}//${ACCESS_TOKEN}@${urlObj.host}${urlObj.pathname}`;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
if (URL_WITH_TOKEN && URL_WITH_TOKEN.length > 0) {
|
|
@@ -23,6 +23,7 @@ var require_submodule_install = __commonJS({
|
|
|
23
23
|
var { getArgs } = require_utils();
|
|
24
24
|
var args = getArgs();
|
|
25
25
|
var positional = args._ || [];
|
|
26
|
+
var ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
|
|
26
27
|
var ROOT = runGit(["rev-parse", "--show-toplevel"]).trim();
|
|
27
28
|
var REPO_PATH = ROOT;
|
|
28
29
|
if (args.cwd) {
|
|
@@ -63,19 +64,19 @@ var require_submodule_install = __commonJS({
|
|
|
63
64
|
continue;
|
|
64
65
|
}
|
|
65
66
|
const GIT_MODULES = path.join(RELATIVE_MODULE_PATH, ".gitmodules");
|
|
66
|
-
if (
|
|
67
|
+
if (ACCESS_TOKEN) {
|
|
67
68
|
let URL_WITH_TOKEN = "";
|
|
68
69
|
let repoInfo;
|
|
69
70
|
if (URL.includes("github.com")) {
|
|
70
71
|
repoInfo = URL.replace("https://github.com/", "");
|
|
71
|
-
URL_WITH_TOKEN = `https://${
|
|
72
|
+
URL_WITH_TOKEN = `https://${ACCESS_TOKEN}@github.com/${repoInfo}`;
|
|
72
73
|
} else if (URL.includes("gitlab.com") && typeof process.env.GITLAB_TOKEN === "string") {
|
|
73
74
|
repoInfo = URL.replace("https://gitlab.com/", "");
|
|
74
|
-
URL_WITH_TOKEN = `https://oauth2:${
|
|
75
|
+
URL_WITH_TOKEN = `https://oauth2:${ACCESS_TOKEN}@gitlab.com/${repoInfo}`;
|
|
75
76
|
} else {
|
|
76
77
|
const urlObj = new URL(URL);
|
|
77
78
|
repoInfo = urlObj.pathname.substring(1);
|
|
78
|
-
URL_WITH_TOKEN = `${urlObj.protocol}//${
|
|
79
|
+
URL_WITH_TOKEN = `${urlObj.protocol}//${ACCESS_TOKEN}@${urlObj.host}${urlObj.pathname}`;
|
|
79
80
|
}
|
|
80
81
|
if (URL_WITH_TOKEN && URL_WITH_TOKEN.length > 0) {
|
|
81
82
|
console.log(`Apply token for ${repoInfo} at ${MODULE_PATH} branch ${BRANCH}`);
|
package/package.json
CHANGED
|
@@ -31,9 +31,34 @@ import fs from "fs";
|
|
|
31
31
|
import https from "https";
|
|
32
32
|
import os from "os";
|
|
33
33
|
import path from "path";
|
|
34
|
+
import { getArgs } from "./utils.js";
|
|
34
35
|
|
|
35
36
|
const projectDir = process.cwd();
|
|
36
37
|
const envPath = path.join(projectDir, ".env");
|
|
38
|
+
const args = getArgs();
|
|
39
|
+
const ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
|
|
40
|
+
|
|
41
|
+
// Show help if --help/-h is passed
|
|
42
|
+
if (args.help || args.h) {
|
|
43
|
+
showHelp();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Display help information for the package-resolutions-updater script.
|
|
48
|
+
*/
|
|
49
|
+
function showHelp() {
|
|
50
|
+
const helpText = `\n\
|
|
51
|
+
GitHub Package Resolutions Updater\n\
|
|
52
|
+
Usage:\n node src/package-resolutions-updater.mjs [options]\n\
|
|
53
|
+
Options:\n --help, -h Show this help message\n\
|
|
54
|
+
Description:\n Updates the commit hashes in package.json's 'resolutions' field for GitHub tarball URLs to point to the latest commit SHA of the corresponding repository and branch.\n\
|
|
55
|
+
Features:\n - Parses GitHub URLs to extract repository owner, name, and branch.\n - Fetches the latest commit SHA across all branches using GitHub's API.\n - Replaces the old branch or commit in the URL with the latest SHA.\n - Overwrites package.json with the updated URLs.\n\
|
|
56
|
+
Requirements:\n - GitHub Personal Access Token (GITHUB_TOKEN) via .env\n - ESM support (type: "module" in package.json)\n - Node.js v18+ recommended\n\
|
|
57
|
+
Dependencies:\n - ansi-colors – for styled terminal output\n - dotenv – to load GitHub token from .env\n\
|
|
58
|
+
Examples:\n node src/package-resolutions-updater.mjs\n node src/package-resolutions-updater.mjs --help\n\n`;
|
|
59
|
+
console.log(helpText);
|
|
60
|
+
process.exit(0);
|
|
61
|
+
}
|
|
37
62
|
|
|
38
63
|
// Load the .env file using dotenv (ESM import)
|
|
39
64
|
if (fs.existsSync(envPath)) dotenv.config({ path: envPath });
|
|
@@ -127,7 +152,7 @@ function fetchJson(url) {
|
|
|
127
152
|
"User-Agent": selectedUserAgent,
|
|
128
153
|
Accept: "application/vnd.github.v3+json",
|
|
129
154
|
"X-GitHub-Api-Version": "2022-11-28",
|
|
130
|
-
...(
|
|
155
|
+
...(ACCESS_TOKEN ? { Authorization: `token ${ACCESS_TOKEN}` } : {})
|
|
131
156
|
};
|
|
132
157
|
return new Promise((resolve, reject) => {
|
|
133
158
|
https
|