@yao-pkg/pkg-fetch 3.5.31 → 3.5.33
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/README.md +1 -1
- package/lib-es5/apply-patches.js +19 -78
- package/lib-es5/bin.js +40 -89
- package/lib-es5/build.js +198 -394
- package/lib-es5/expected-shas.json +32 -32
- package/lib-es5/expected.js +1 -1
- package/lib-es5/generate-expected-shas.js +31 -72
- package/lib-es5/index.js +125 -210
- package/lib-es5/log.js +39 -63
- package/lib-es5/parse-update-shas.js +32 -36
- package/lib-es5/places.js +13 -15
- package/lib-es5/print-hashes.js +4 -5
- package/lib-es5/system.js +17 -19
- package/lib-es5/utils.js +82 -150
- package/lib-es5/verify.js +118 -53
- package/package.json +1 -1
- package/patches/{node.v20.19.6.cpp.patch → node.v20.20.2.cpp.patch} +6 -6
- package/patches/{node.v22.21.1.cpp.patch → node.v22.22.2.cpp.patch} +12 -12
- package/patches/{node.v24.12.0.cpp.patch → node.v24.14.1.cpp.patch} +10 -10
- package/patches/patches.json +3 -3
package/lib-es5/log.js
CHANGED
|
@@ -1,87 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* eslint-disable no-underscore-dangle, no-console */
|
|
3
|
-
var __extends = (this && this.__extends) || (function () {
|
|
4
|
-
var extendStatics = function (d, b) {
|
|
5
|
-
extendStatics = Object.setPrototypeOf ||
|
|
6
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
7
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
8
|
-
return extendStatics(d, b);
|
|
9
|
-
};
|
|
10
|
-
return function (d, b) {
|
|
11
|
-
if (typeof b !== "function" && b !== null)
|
|
12
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
13
|
-
extendStatics(d, b);
|
|
14
|
-
function __() { this.constructor = d; }
|
|
15
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
16
|
-
};
|
|
17
|
-
})();
|
|
18
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
5
|
};
|
|
21
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
7
|
exports.wasReported = exports.log = void 0;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
8
|
+
const progress_1 = __importDefault(require("progress"));
|
|
9
|
+
const assert_1 = __importDefault(require("assert"));
|
|
10
|
+
const picocolors_1 = __importDefault(require("picocolors"));
|
|
11
|
+
const tty_1 = require("tty");
|
|
27
12
|
// workaround until picocolors improves its color detection
|
|
28
13
|
// https://github.com/alexeyraspopov/picocolors/issues/85
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
Log.prototype.lines = function (lines) {
|
|
14
|
+
const pc = picocolors_1.default.createColors(tty_1.WriteStream.prototype.hasColors());
|
|
15
|
+
class Log {
|
|
16
|
+
debugMode = false;
|
|
17
|
+
bar;
|
|
18
|
+
lines(lines) {
|
|
35
19
|
if (lines === undefined) {
|
|
36
20
|
return;
|
|
37
21
|
}
|
|
38
22
|
if (!Array.isArray(lines)) {
|
|
39
|
-
console.log(
|
|
23
|
+
console.log(` ${lines}`);
|
|
40
24
|
return;
|
|
41
25
|
}
|
|
42
|
-
for (
|
|
43
|
-
|
|
44
|
-
console.log(" ".concat(line));
|
|
26
|
+
for (const line of lines) {
|
|
27
|
+
console.log(` ${line}`);
|
|
45
28
|
}
|
|
46
|
-
}
|
|
47
|
-
|
|
29
|
+
}
|
|
30
|
+
debug(text, lines) {
|
|
48
31
|
if (!this.debugMode) {
|
|
49
32
|
return;
|
|
50
33
|
}
|
|
51
|
-
console.log(
|
|
34
|
+
console.log(`> ${pc.green('[debug]')} ${text}`);
|
|
52
35
|
this.lines(lines);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
console.log(
|
|
36
|
+
}
|
|
37
|
+
info(text, lines) {
|
|
38
|
+
console.log(`> ${text}`);
|
|
56
39
|
this.lines(lines);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
console.log(
|
|
40
|
+
}
|
|
41
|
+
warn(text, lines) {
|
|
42
|
+
console.log(`> ${pc.blue('Warning')} ${text}`);
|
|
60
43
|
this.lines(lines);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
console.log(
|
|
44
|
+
}
|
|
45
|
+
error(text, lines) {
|
|
46
|
+
const message = text instanceof Error ? text.stack : text;
|
|
47
|
+
console.log(`> ${pc.red('Error!')} ${message}`);
|
|
65
48
|
this.lines(lines);
|
|
66
|
-
}
|
|
67
|
-
|
|
49
|
+
}
|
|
50
|
+
enableProgress(text) {
|
|
68
51
|
(0, assert_1.default)(!this.bar);
|
|
69
52
|
text += ' '.repeat(35 - text.length);
|
|
70
|
-
this.bar = new progress_1.default(
|
|
53
|
+
this.bar = new progress_1.default(` ${text} [:bar] :percent`, {
|
|
71
54
|
stream: process.stdout,
|
|
72
55
|
width: 20,
|
|
73
56
|
complete: '=',
|
|
74
57
|
incomplete: ' ',
|
|
75
58
|
total: 100,
|
|
76
59
|
});
|
|
77
|
-
}
|
|
78
|
-
|
|
60
|
+
}
|
|
61
|
+
showProgress(percentage) {
|
|
79
62
|
if (!this.bar) {
|
|
80
63
|
return;
|
|
81
64
|
}
|
|
82
65
|
this.bar.update(percentage / 100);
|
|
83
|
-
}
|
|
84
|
-
|
|
66
|
+
}
|
|
67
|
+
disableProgress() {
|
|
85
68
|
if (!this.bar) {
|
|
86
69
|
return;
|
|
87
70
|
}
|
|
@@ -90,22 +73,15 @@ var Log = /** @class */ (function () {
|
|
|
90
73
|
this.bar.terminate();
|
|
91
74
|
}
|
|
92
75
|
delete this.bar;
|
|
93
|
-
};
|
|
94
|
-
return Log;
|
|
95
|
-
}());
|
|
96
|
-
exports.log = new Log();
|
|
97
|
-
var ReportedError = /** @class */ (function (_super) {
|
|
98
|
-
__extends(ReportedError, _super);
|
|
99
|
-
function ReportedError() {
|
|
100
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
101
|
-
_this.name = 'ReportedError';
|
|
102
|
-
_this.wasReported = true;
|
|
103
|
-
return _this;
|
|
104
76
|
}
|
|
105
|
-
|
|
106
|
-
|
|
77
|
+
}
|
|
78
|
+
exports.log = new Log();
|
|
79
|
+
class ReportedError extends Error {
|
|
80
|
+
name = 'ReportedError';
|
|
81
|
+
wasReported = true;
|
|
82
|
+
}
|
|
107
83
|
function wasReported(error, lines) {
|
|
108
|
-
|
|
84
|
+
let reportedError = new ReportedError('No message');
|
|
109
85
|
if (typeof error === 'string') {
|
|
110
86
|
exports.log.error(error, lines);
|
|
111
87
|
reportedError = new ReportedError(error);
|
|
@@ -24,19 +24,19 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.parseAndUpdateShas = void 0;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
28
|
+
const path = __importStar(require("path"));
|
|
29
|
+
const log_1 = require("./log");
|
|
30
30
|
function parseAndUpdateShas(inputFile) {
|
|
31
31
|
// Read the input file containing new SHAs
|
|
32
32
|
if (!fs.existsSync(inputFile)) {
|
|
33
|
-
throw (0, log_1.wasReported)(
|
|
33
|
+
throw (0, log_1.wasReported)(`Input file ${inputFile} does not exist`);
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const input = fs.readFileSync(inputFile, 'utf8');
|
|
36
|
+
const lines = input.split('\n').map(l => l.trim()).filter(Boolean);
|
|
37
37
|
// Read existing shas.txt
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
const shasPath = path.join(process.cwd(), 'shas.txt');
|
|
39
|
+
let shasTxt = '';
|
|
40
40
|
try {
|
|
41
41
|
shasTxt = fs.readFileSync(shasPath, 'utf8');
|
|
42
42
|
}
|
|
@@ -44,59 +44,55 @@ function parseAndUpdateShas(inputFile) {
|
|
|
44
44
|
log_1.log.info('shas.txt not found, creating new one');
|
|
45
45
|
shasTxt = '';
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
let shasArr = shasTxt.split('\n');
|
|
48
|
+
// Process each line from input
|
|
49
|
+
for (const line of lines) {
|
|
50
|
+
const [sha, patchName] = line.split(/\s+/);
|
|
50
51
|
if (!sha || !patchName) {
|
|
51
|
-
log_1.log.warn(
|
|
52
|
-
|
|
52
|
+
log_1.log.warn(`Skipping invalid line: ${line}`);
|
|
53
|
+
continue;
|
|
53
54
|
}
|
|
54
55
|
// Extract major, os, arch. E.g.: node-v22.20.0-win-x64
|
|
55
|
-
|
|
56
|
+
const match = patchName.match(/^node-v(\d+)\.[^ ]*-(.+)-(.+)$/);
|
|
56
57
|
if (!match) {
|
|
57
|
-
log_1.log.warn(
|
|
58
|
-
|
|
58
|
+
log_1.log.warn(`Skipping line with invalid patch name format: ${line}`);
|
|
59
|
+
continue;
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
const major = match[1];
|
|
62
|
+
const os = match[2];
|
|
63
|
+
const arch = match[3];
|
|
63
64
|
// Regex for matching line in shas.txt
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
shasArr = shasArr.map(
|
|
65
|
+
const re = new RegExp(`^\\S+\\s+node-v${major}\\.([0-9.]+){2}-${os}-${arch}$`);
|
|
66
|
+
let found = false;
|
|
67
|
+
shasArr = shasArr.map(l => {
|
|
67
68
|
if (re.test(l)) {
|
|
68
69
|
found = true;
|
|
69
|
-
log_1.log.info(
|
|
70
|
-
return
|
|
70
|
+
log_1.log.info(`Updating: ${l} -> ${sha} ${patchName}`);
|
|
71
|
+
return `${sha} ${patchName}`;
|
|
71
72
|
}
|
|
72
73
|
return l;
|
|
73
74
|
});
|
|
74
75
|
if (!found) {
|
|
75
|
-
log_1.log.info(
|
|
76
|
-
shasArr.push(
|
|
76
|
+
log_1.log.info(`Adding new entry: ${sha} ${patchName}`);
|
|
77
|
+
shasArr.push(`${sha} ${patchName}`);
|
|
77
78
|
}
|
|
78
|
-
};
|
|
79
|
-
// Process each line from input
|
|
80
|
-
for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
|
|
81
|
-
var line = lines_1[_i];
|
|
82
|
-
_loop_1(line);
|
|
83
79
|
}
|
|
84
80
|
// Write updated shas.txt
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
const filteredShas = shasArr.filter(Boolean);
|
|
82
|
+
const updatedContent = filteredShas.length > 0 ? `${filteredShas.join('\n')}\n` : '';
|
|
87
83
|
fs.writeFileSync(shasPath, updatedContent);
|
|
88
|
-
log_1.log.info(
|
|
84
|
+
log_1.log.info(`Successfully updated ${shasPath}`);
|
|
89
85
|
}
|
|
90
86
|
exports.parseAndUpdateShas = parseAndUpdateShas;
|
|
91
87
|
// Main execution
|
|
92
88
|
if (require.main === module) {
|
|
93
|
-
|
|
89
|
+
const args = process.argv.slice(2);
|
|
94
90
|
if (args.length !== 1) {
|
|
95
91
|
log_1.log.error('Usage: parse-update-shas.ts <input-file>');
|
|
96
92
|
log_1.log.error(' input-file: Path to file containing SHA lines in format "<sha> <patch-name>"');
|
|
97
93
|
process.exit(1);
|
|
98
94
|
}
|
|
99
|
-
|
|
95
|
+
const inputFile = args[0];
|
|
100
96
|
try {
|
|
101
97
|
parseAndUpdateShas(inputFile);
|
|
102
98
|
}
|
package/lib-es5/places.js
CHANGED
|
@@ -4,20 +4,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.remotePlace = exports.localPlace = exports.cachePath = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
const semver_1 = require("semver");
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const { PKG_CACHE_PATH } = process.env;
|
|
11
|
+
const IGNORE_TAG = Boolean(process.env.PKG_IGNORE_TAG);
|
|
12
12
|
exports.cachePath = PKG_CACHE_PATH || path_1.default.join(os_1.default.homedir(), '.pkg-cache');
|
|
13
13
|
function tagFromVersion(version) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return
|
|
14
|
+
const mj = (0, semver_1.major)(version);
|
|
15
|
+
const mn = (0, semver_1.minor)(version);
|
|
16
|
+
return `v${mj}.${mn}`;
|
|
17
17
|
}
|
|
18
|
-
function localPlace(
|
|
19
|
-
|
|
20
|
-
var binDir;
|
|
18
|
+
function localPlace({ from, output, version, nodeVersion, platform, arch, }) {
|
|
19
|
+
let binDir;
|
|
21
20
|
if (process.env.PKG_NODE_PATH) {
|
|
22
21
|
return path_1.default.resolve(process.env.PKG_NODE_PATH);
|
|
23
22
|
}
|
|
@@ -29,14 +28,13 @@ function localPlace(_a) {
|
|
|
29
28
|
? path_1.default.join(exports.cachePath)
|
|
30
29
|
: path_1.default.join(exports.cachePath, tagFromVersion(version));
|
|
31
30
|
}
|
|
32
|
-
return path_1.default.resolve(binDir,
|
|
31
|
+
return path_1.default.resolve(binDir, `${output ? 'node' : from}-${nodeVersion}-${platform}-${arch}`);
|
|
33
32
|
}
|
|
34
33
|
exports.localPlace = localPlace;
|
|
35
|
-
function remotePlace(
|
|
36
|
-
var version = _a.version, nodeVersion = _a.nodeVersion, platform = _a.platform, arch = _a.arch;
|
|
34
|
+
function remotePlace({ version, nodeVersion, platform, arch, }) {
|
|
37
35
|
return {
|
|
38
36
|
tag: tagFromVersion(version),
|
|
39
|
-
name:
|
|
37
|
+
name: `node-${nodeVersion}-${platform}-${arch}`,
|
|
40
38
|
};
|
|
41
39
|
}
|
|
42
40
|
exports.remotePlace = remotePlace;
|
package/lib-es5/print-hashes.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const expected_1 = require("./expected");
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
5
|
/* eslint-disable no-console */
|
|
6
6
|
function main() {
|
|
7
|
-
for (
|
|
8
|
-
|
|
9
|
-
console.log("".concat(expected_1.EXPECTED_HASHES[nodeVersion], " ").concat(nodeVersion));
|
|
7
|
+
for (const nodeVersion of Object.keys(expected_1.EXPECTED_HASHES).sort(utils_1.nodeBinarySortFunction)) {
|
|
8
|
+
console.log(`${expected_1.EXPECTED_HASHES[nodeVersion]} ${nodeVersion}`);
|
|
10
9
|
}
|
|
11
10
|
}
|
|
12
11
|
main();
|
package/lib-es5/system.js
CHANGED
|
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.knownArchs = exports.targetArchs = exports.hostArch = exports.knownPlatforms = exports.hostPlatform = exports.hostAbi = exports.toFancyArch = exports.toFancyPlatform = exports.isValidNodeRange = exports.abiToNodeRange = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
9
9
|
function getHostAbi() {
|
|
10
|
-
return
|
|
10
|
+
return `m${process.versions.modules}`;
|
|
11
11
|
}
|
|
12
12
|
function abiToNodeRange(abi) {
|
|
13
13
|
if (/^m?14/.test(abi))
|
|
@@ -62,25 +62,24 @@ function toFancyPlatform(platform) {
|
|
|
62
62
|
}
|
|
63
63
|
exports.toFancyPlatform = toFancyPlatform;
|
|
64
64
|
function detectAlpine() {
|
|
65
|
-
|
|
66
|
-
var platform = process.platform;
|
|
65
|
+
const { platform } = process;
|
|
67
66
|
if (platform !== 'linux') {
|
|
68
67
|
return false;
|
|
69
68
|
}
|
|
70
69
|
// https://github.com/sass/node-sass/issues/1589#issuecomment-265292579
|
|
71
|
-
|
|
70
|
+
const ldd = (0, child_process_1.spawnSync)('ldd').stderr?.toString();
|
|
72
71
|
if (ldd == null) {
|
|
73
|
-
return fs_1.default.readdirSync('/lib').some(
|
|
72
|
+
return fs_1.default.readdirSync('/lib').some((file) => file.startsWith('libc.musl'));
|
|
74
73
|
}
|
|
75
74
|
if (/\bmusl\b/.test(ldd)) {
|
|
76
75
|
return true;
|
|
77
76
|
}
|
|
78
|
-
|
|
77
|
+
const lddNode = (0, child_process_1.spawnSync)('ldd', [process.execPath]).stdout.toString();
|
|
79
78
|
return /\bmusl\b/.test(lddNode);
|
|
80
79
|
}
|
|
81
|
-
|
|
80
|
+
const isAlpine = detectAlpine();
|
|
82
81
|
function getHostPlatform() {
|
|
83
|
-
|
|
82
|
+
const { platform } = process;
|
|
84
83
|
if (isAlpine) {
|
|
85
84
|
return 'alpine';
|
|
86
85
|
}
|
|
@@ -98,11 +97,11 @@ function toFancyArch(arch) {
|
|
|
98
97
|
}
|
|
99
98
|
exports.toFancyArch = toFancyArch;
|
|
100
99
|
function getArmUnameArch() {
|
|
101
|
-
|
|
100
|
+
const uname = (0, child_process_1.spawnSync)('uname', ['-a']);
|
|
102
101
|
if (uname.error) {
|
|
103
102
|
return '';
|
|
104
103
|
}
|
|
105
|
-
|
|
104
|
+
let unameOut = uname.stdout && uname.stdout.toString();
|
|
106
105
|
unameOut = (unameOut || '').toLowerCase();
|
|
107
106
|
if (unameOut.includes('aarch64'))
|
|
108
107
|
return 'arm64';
|
|
@@ -113,29 +112,28 @@ function getArmUnameArch() {
|
|
|
113
112
|
return '';
|
|
114
113
|
}
|
|
115
114
|
function getArmHostArch() {
|
|
116
|
-
|
|
117
|
-
var cpu = fs_1.default.readFileSync('/proc/cpuinfo', 'utf8');
|
|
115
|
+
const cpu = fs_1.default.readFileSync('/proc/cpuinfo', 'utf8');
|
|
118
116
|
if (cpu.indexOf('vfpv3') >= 0) {
|
|
119
117
|
return 'armv7';
|
|
120
118
|
}
|
|
121
|
-
|
|
119
|
+
let name = cpu.split('model name')[1];
|
|
122
120
|
if (name)
|
|
123
|
-
|
|
121
|
+
[, name] = name.split(':');
|
|
124
122
|
if (name)
|
|
125
|
-
name = name.split('\n')
|
|
123
|
+
[name] = name.split('\n');
|
|
126
124
|
if (name && name.indexOf('ARMv7') >= 0)
|
|
127
125
|
return 'armv7';
|
|
128
126
|
return 'armv6';
|
|
129
127
|
}
|
|
130
128
|
function getHostArch() {
|
|
131
|
-
|
|
129
|
+
const { arch } = process;
|
|
132
130
|
if (arch === 'arm') {
|
|
133
131
|
return getArmUnameArch() || getArmHostArch();
|
|
134
132
|
}
|
|
135
133
|
return toFancyArch(arch);
|
|
136
134
|
}
|
|
137
135
|
function getTargetArchs() {
|
|
138
|
-
|
|
136
|
+
const arch = getHostArch();
|
|
139
137
|
if (arch === 'x64') {
|
|
140
138
|
return ['x64', 'x86'];
|
|
141
139
|
}
|