@yao-pkg/pkg-fetch 3.6.0 → 3.6.1
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 +28 -20
- package/lib-es5/apply-patches.js +19 -78
- package/lib-es5/bin.js +40 -89
- package/lib-es5/build.js +205 -374
- package/lib-es5/expected-shas.json +53 -34
- package/lib-es5/expected.js +1 -1
- package/lib-es5/generate-expected-shas.js +31 -72
- package/lib-es5/index.js +125 -203
- package/lib-es5/log.js +41 -61
- package/lib-es5/parse-update-shas.d.ts +3 -0
- package/lib-es5/parse-update-shas.js +106 -0
- package/lib-es5/places.js +13 -15
- package/lib-es5/print-hashes.js +4 -5
- package/lib-es5/system.js +18 -20
- package/lib-es5/utils.js +82 -140
- package/lib-es5/verify.js +133 -53
- package/package.json +12 -57
- package/patches/node.v16.20.2.cpp.patch +1 -1
- package/patches/{node.v18.18.2.cpp.patch → node.v18.20.8.cpp.patch} +207 -60
- package/patches/{node.v20.10.0.cpp.patch → node.v20.20.2.cpp.patch} +87 -50
- package/patches/{node.v19.8.1.cpp.patch → node.v22.22.3.cpp.patch} +316 -167
- package/patches/node.v24.15.0.cpp.patch +863 -0
- package/patches/node.v26.2.0.cpp.patch +809 -0
- package/patches/patches.json +5 -3
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"node-v10.24.1-alpine-arm64": "f6a59f1ace2ef1f4bf976ff85d9a74bdc71bda098e8aa018e2a089c590aeedea",
|
|
3
2
|
"node-v14.21.3-alpine-arm64": "651c2b423925c9dab1ca7695acfb1462be13264f0c1fb6c8b472474c7dbacddd",
|
|
4
3
|
"node-v14.21.3-alpine-x64": "4f2b5b16428f998302bbcf59ca229998be48e5dc6c2487edb603152651c182cd",
|
|
5
4
|
"node-v14.21.3-linux-arm64": "bb20f63ac32c4e6a0545dfcea3833e8a8a968b95e91ce01cab7f4f48f1a56064",
|
|
@@ -22,37 +21,57 @@
|
|
|
22
21
|
"node-v16.20.2-win-arm64": "7514915e02aedfbdc9f87ede04f1f251b014e312e3e184d5b94b42aeb28c2485",
|
|
23
22
|
"node-v16.20.2-win-x64": "272729724993ce07b37d328718a0152e50ec5c9d27aa972975c09b75604c0dca",
|
|
24
23
|
"node-v16.20.2-macos-arm64": "3d04eb7ddd8b614b888eeb1caa6e64a068b665ab4a26dd064051973ae5842a85",
|
|
25
|
-
"node-v18.
|
|
26
|
-
"node-v18.
|
|
27
|
-
"node-v18.
|
|
28
|
-
"node-v18.
|
|
29
|
-
"node-v18.
|
|
30
|
-
"node-v18.
|
|
31
|
-
"node-v18.
|
|
32
|
-
"node-v18.
|
|
33
|
-
"node-v18.
|
|
34
|
-
"node-v18.
|
|
35
|
-
"node-v18.
|
|
36
|
-
"node-
|
|
37
|
-
"node-
|
|
38
|
-
"node-
|
|
39
|
-
"node-
|
|
40
|
-
"node-
|
|
41
|
-
"node-
|
|
42
|
-
"node-
|
|
43
|
-
"node-
|
|
44
|
-
"node-
|
|
45
|
-
"node-
|
|
46
|
-
"node-
|
|
47
|
-
"node-
|
|
48
|
-
"node-
|
|
49
|
-
"node-
|
|
50
|
-
"node-
|
|
51
|
-
"node-
|
|
52
|
-
"node-
|
|
53
|
-
"node-
|
|
54
|
-
"node-
|
|
55
|
-
"node-
|
|
56
|
-
"node-
|
|
57
|
-
"node-
|
|
24
|
+
"node-v18.20.8-alpine-arm64": "c7f20847fbfd765517612647593c7767331a318d2b229ddac2b4afd7d13b78d0",
|
|
25
|
+
"node-v18.20.8-alpine-x64": "3b24c6f571681046a6ed1b42752b21a41e10e8c7ac19416b9571927cc10f4a49",
|
|
26
|
+
"node-v18.20.8-linux-arm64": "690ed47821dfbf842a1ba40a7cd2e28344e6ad998a89f5d0eb61da3c86fcd29c",
|
|
27
|
+
"node-v18.20.8-linux-x64": "0121b3c810db3f5e47028f0b1e2294a1a52a2aa20923c037247e39c82be0f789",
|
|
28
|
+
"node-v18.20.8-linuxstatic-arm64": "ac03e112f9229126e62924f1fefbb44c54f5fbbb4827d5ffa6243d3b8e81dfa4",
|
|
29
|
+
"node-v18.20.8-linuxstatic-armv7": "4c96d99319e850887d01cb63500e34f5db3b64944b3644f4ed5c94ae2be5b625",
|
|
30
|
+
"node-v18.20.8-linuxstatic-x64": "16e25c30e3a4d03a18e21bcd41b6980c65f837425d485e3f5f68c8362bad0625",
|
|
31
|
+
"node-v18.20.8-macos-arm64": "d3f8f8966ceb4cea5447edacda9d2f151e97e06baf21a3fcba9d7a7e8470cee9",
|
|
32
|
+
"node-v18.20.8-macos-x64": "f2cf139bfe3501d39d22b48a069f9ceb24942b0cdc001a0bc30ea3a68fbcc6b3",
|
|
33
|
+
"node-v18.20.8-win-arm64": "dd56454cfc9292f047413657c8b997006f27ecda8cd7f7dd38acf8d22317e743",
|
|
34
|
+
"node-v18.20.8-win-x64": "4d45cdfbcba3de3f6c0ddcd78251179b9d04dd2fcb2dba2fb052940a2821eb39",
|
|
35
|
+
"node-v20.20.2-alpine-arm64": "774593e1feec8ea4334a5b7e3082a37506b0568ba668da364403dd3d5a4c4384",
|
|
36
|
+
"node-v20.20.2-alpine-x64": "d21413bf5f2f4e7f26cedf17876c03dd44033c1ee8b8ee1f9d04f1b41948f009",
|
|
37
|
+
"node-v20.20.2-linux-arm64": "5a2a85e06a45faf6a26db5d9bc277fc33f77ebf19364e7bbfb62e5cc879ce86d",
|
|
38
|
+
"node-v20.20.2-linux-x64": "694a86b2b3a3635289a28735b8ab43d9c721f138cad4ee3989f8f19033e77e59",
|
|
39
|
+
"node-v20.20.2-linuxstatic-arm64": "c05b6834f7d64cec6e56c6239ea57f5d57a4f00f574afb5621e08ae838f0d8e6",
|
|
40
|
+
"node-v20.20.2-linuxstatic-armv7": "53f8268c77f57ac975a3984e6535192f3a2774b2b8e866cc618b23e512b94fbc",
|
|
41
|
+
"node-v20.20.2-linuxstatic-x64": "52885548ae2976947d7fed98b187a94043f27c8a9ce5d6a7b6a19deb43649144",
|
|
42
|
+
"node-v20.20.2-macos-arm64": "4bc19212dbb8f633742007d940a7c7a734332c6c8e1985f3ee7cbb218a8f805a",
|
|
43
|
+
"node-v20.20.2-macos-x64": "2276efd46dc3a30d5524ea60b8cb63afa5c8e45e0f17ad49065bcea7b59b7eeb",
|
|
44
|
+
"node-v20.20.2-win-arm64": "aebc71a3ebf4774adaac0cd891bfba54f9e5e4340c39b44492127de551a9b5a8",
|
|
45
|
+
"node-v20.20.2-win-x64": "f9b870a1b20c3bcf729a53112b6a72db65b050e4e6494d33ceab3413c507f01c",
|
|
46
|
+
"node-v22.22.3-alpine-arm64": "29f747d6c56bcd5ccbd0dfd033df31f226ac30deedb67186ec72cdbbe96d15cc",
|
|
47
|
+
"node-v22.22.3-alpine-x64": "a5b8a56c4ddbf5b3bdeb46706f7fe71d53d8ebbb3d19a6eb55177dffbc69323d",
|
|
48
|
+
"node-v22.22.3-linux-arm64": "c5ef71c46aeae4859f5e2338aa35a73261cc319f7f1f11893b4fe13494d040d6",
|
|
49
|
+
"node-v22.22.3-linux-x64": "8ac32aa38e6ed30372c20e7cac2d92f5d7e12c9053deebe5db94cca4228b3755",
|
|
50
|
+
"node-v22.22.3-linuxstatic-arm64": "ecda1a1ed432c753560cb1496ed6cb4e70863fc825c6ba1fa1cace34c15374cf",
|
|
51
|
+
"node-v22.22.3-linuxstatic-armv7": "6a00d7ddef6ad117389725b13255da63467dee2515b9ff56584cd9c4eb0cc3bd",
|
|
52
|
+
"node-v22.22.3-linuxstatic-x64": "53308c1386f92e15ffc6b0ab78f28b9490bc497f35346bbe8773b05acfc9911e",
|
|
53
|
+
"node-v22.22.3-macos-arm64": "d6a4a2d3fcb353bfd1d91a34751d1fff83bd3a8b987b7c891d959bca70d24237",
|
|
54
|
+
"node-v22.22.3-macos-x64": "112619345641eb70d895fa8ef99365a6819a8c6b96aaf8b6273d2ebeae5427cf",
|
|
55
|
+
"node-v22.22.3-win-arm64": "f2ef0a30dc796d40fb5c00afdeed1e6363c00e7d694dbb7119ae1b392a5e31fc",
|
|
56
|
+
"node-v22.22.3-win-x64": "3abbf32d427ea9ffcce92f8c9727daa02ab7e967c5e475ed22854a1bea8cdebb",
|
|
57
|
+
"node-v24.15.0-alpine-arm64": "43203ae081353c43cd5db4fc1ec240c90a7daa28edf3716c35a39057334f0330",
|
|
58
|
+
"node-v24.15.0-alpine-x64": "b80d375c2df76eb1c3b8046540a8c356556b18706178a05056764f34a0c1e8fd",
|
|
59
|
+
"node-v24.15.0-linux-arm64": "5099a5c5527f35f68538054386b495d747d01a6e05bf3d3a22f16edaac9a7bcb",
|
|
60
|
+
"node-v24.15.0-linux-x64": "b081411ee7a4e351368e687d95d8beeea8e8c09b27f28114592d4efcda1d6e3d",
|
|
61
|
+
"node-v24.15.0-linuxstatic-arm64": "7add1c3195a602e6bd0376df91c09b2db941ab5dda44ca662cf961eb6b27bf63",
|
|
62
|
+
"node-v24.15.0-linuxstatic-x64": "b09eab65ac2ee0bfdb1a5a9cbdfd4e6b55a851fc42fa9ae92272dfcf0b6eb7d7",
|
|
63
|
+
"node-v24.15.0-macos-arm64": "11bd187bac035582dc9a93995d434da5b953ee97be273ea90744158b9117e32a",
|
|
64
|
+
"node-v24.15.0-macos-x64": "5efe094a0444c88c165191948ee7a4866e56c79cd87a970cfafd5b93ca5d8eb7",
|
|
65
|
+
"node-v24.15.0-win-arm64": "b10c37ff4c4dc587913e49c2bc5d89e15b2ec3a23d759419dd6e69984f589f04",
|
|
66
|
+
"node-v24.15.0-win-x64": "1181784028a3319206ff5a6c2af17f78009432f0bd69325f0d0bfc128de770a8",
|
|
67
|
+
"node-v26.2.0-alpine-arm64": "8e92f5dcbedfc1300ac6d7b0b552237252d47fb9943f785e33da3f635df002aa",
|
|
68
|
+
"node-v26.2.0-alpine-x64": "fb5783ab21827ec1068b49c208d74f8b6f4b82d6f3d85f93924144688b9ac705",
|
|
69
|
+
"node-v26.2.0-linux-arm64": "462785abfbcd498deb74945e6f9d0575db610dc279d193d02a13b9c9ee1c31bb",
|
|
70
|
+
"node-v26.2.0-linux-x64": "bfa38eb20a8fc14d62fb4a3cef942de9e4e4490049771b227373d300b137e5cc",
|
|
71
|
+
"node-v26.2.0-linuxstatic-arm64": "a379ab3777825e58aee2e7e16bcf3d020e5029084d99145c00f3b129dadcc7ac",
|
|
72
|
+
"node-v26.2.0-linuxstatic-x64": "84d4f7ddcf6c9e7342e9a83b35237149570c14c9dc6f4f269bcdbd5d1606ac32",
|
|
73
|
+
"node-v26.2.0-macos-arm64": "251c29beb47324ece17d7f48090ad086a0e5cc47865335ea944d665f40dae6f3",
|
|
74
|
+
"node-v26.2.0-macos-x64": "5533c4247ebf44dff1e1e4934f907e6f9a423091334c4fc457e4325cd6129402",
|
|
75
|
+
"node-v26.2.0-win-arm64": "7ce4055e72df18d61df8bafc19f4d40d81199ff1b6281bd5363e069690799445",
|
|
76
|
+
"node-v26.2.0-win-x64": "5d6f5055b1531c26884ffce4663e4ffac4468ee0e07a079c233887b63e975943"
|
|
58
77
|
}
|
package/lib-es5/expected.js
CHANGED
|
@@ -4,6 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.EXPECTED_HASHES = void 0;
|
|
7
|
-
|
|
7
|
+
const expected_shas_json_1 = __importDefault(require("./expected-shas.json"));
|
|
8
8
|
exports.EXPECTED_HASHES = expected_shas_json_1.default;
|
|
9
9
|
//# sourceMappingURL=expected.js.map
|
|
@@ -1,81 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
4
|
};
|
|
41
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
function main() {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
(0, fs_1.writeFileSync)((0, path_1.join)(__dirname, '../lib/expected-shas.json'), "".concat(JSON.stringify(sortedShaMap, null, 2), "\n"));
|
|
74
|
-
return [2 /*return*/];
|
|
75
|
-
});
|
|
76
|
-
});
|
|
6
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const log_1 = require("./log");
|
|
10
|
+
const package_json_1 = require("../package.json");
|
|
11
|
+
const utils_1 = require("./utils");
|
|
12
|
+
async function main() {
|
|
13
|
+
const { argv } = yargs_1.default
|
|
14
|
+
.option('input', { alias: 'i', default: 'shas.txt', type: 'string' })
|
|
15
|
+
.version(package_json_1.version)
|
|
16
|
+
.alias('v', 'version')
|
|
17
|
+
.help()
|
|
18
|
+
.alias('h', 'help');
|
|
19
|
+
const shaFileContent = (0, fs_1.readFileSync)(argv.input).toString();
|
|
20
|
+
const shaMap = {};
|
|
21
|
+
for (const line of shaFileContent.split('\n')) {
|
|
22
|
+
// Expect line to be of the form
|
|
23
|
+
// <sha> node-v<version>-host-arch
|
|
24
|
+
const lineParts = line.split(/\s+/);
|
|
25
|
+
if (lineParts.length === 2) {
|
|
26
|
+
// eslint-disable-next-line prefer-destructuring
|
|
27
|
+
shaMap[lineParts[1]] = lineParts[0];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// Sort map
|
|
31
|
+
const sortedShaMap = {};
|
|
32
|
+
for (const nodeVersion of Object.keys(shaMap).sort(utils_1.nodeBinarySortFunction)) {
|
|
33
|
+
sortedShaMap[nodeVersion] = shaMap[nodeVersion];
|
|
34
|
+
}
|
|
35
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(__dirname, '../lib/expected-shas.json'), `${JSON.stringify(sortedShaMap, null, 2)}\n`);
|
|
77
36
|
}
|
|
78
|
-
main().catch(
|
|
37
|
+
main().catch((error) => {
|
|
79
38
|
if (!error.wasReported)
|
|
80
39
|
log_1.log.error(error);
|
|
81
40
|
process.exit(2);
|
package/lib-es5/index.js
CHANGED
|
@@ -22,112 +22,52 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
-
function step(op) {
|
|
39
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
-
switch (op[0]) {
|
|
44
|
-
case 0: case 1: t = op; break;
|
|
45
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
-
default:
|
|
49
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
-
if (t[2]) _.ops.pop();
|
|
54
|
-
_.trys.pop(); continue;
|
|
55
|
-
}
|
|
56
|
-
op = body.call(thisArg, _);
|
|
57
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
27
|
};
|
|
64
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
29
|
exports.system = exports.need = exports.getNodeVersion = exports.satisfyingNodeVersion = void 0;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
30
|
+
const fs_1 = require("fs");
|
|
31
|
+
const promises_1 = require("fs/promises");
|
|
32
|
+
const path_1 = __importDefault(require("path"));
|
|
33
|
+
const semver_1 = __importDefault(require("semver"));
|
|
34
|
+
const expected_1 = require("./expected");
|
|
35
|
+
const system_1 = require("./system");
|
|
36
|
+
const system = __importStar(require("./system"));
|
|
72
37
|
exports.system = system;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
function download(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
_c.trys.push([1, 4, , 5]);
|
|
90
|
-
return [4 /*yield*/, (0, utils_1.downloadUrl)(url, local)];
|
|
91
|
-
case 2:
|
|
92
|
-
_c.sent();
|
|
93
|
-
return [4 /*yield*/, (0, utils_1.plusx)(local)];
|
|
94
|
-
case 3:
|
|
95
|
-
_c.sent();
|
|
96
|
-
return [3 /*break*/, 5];
|
|
97
|
-
case 4:
|
|
98
|
-
_b = _c.sent();
|
|
99
|
-
return [2 /*return*/, false];
|
|
100
|
-
case 5: return [2 /*return*/, true];
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
});
|
|
38
|
+
const places_1 = require("./places");
|
|
39
|
+
const log_1 = require("./log");
|
|
40
|
+
const build_1 = __importDefault(require("./build"));
|
|
41
|
+
const utils_1 = require("./utils");
|
|
42
|
+
const patches_json_1 = __importDefault(require("../patches/patches.json"));
|
|
43
|
+
const package_json_1 = require("../package.json");
|
|
44
|
+
async function download({ tag, name }, local) {
|
|
45
|
+
const url = `https://github.com/yao-pkg/pkg-fetch/releases/download/${tag}/${name}`;
|
|
46
|
+
try {
|
|
47
|
+
await (0, utils_1.downloadUrl)(url, local);
|
|
48
|
+
await (0, utils_1.plusx)(local);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
104
54
|
}
|
|
105
|
-
function exists(file) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
case 1:
|
|
114
|
-
_a.sent();
|
|
115
|
-
return [2 /*return*/, true];
|
|
116
|
-
case 2:
|
|
117
|
-
error_1 = _a.sent();
|
|
118
|
-
return [2 /*return*/, false];
|
|
119
|
-
case 3: return [2 /*return*/];
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
});
|
|
55
|
+
async function exists(file) {
|
|
56
|
+
try {
|
|
57
|
+
await (0, promises_1.stat)(file);
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
123
63
|
}
|
|
124
64
|
function satisfyingNodeVersion(nodeRange) {
|
|
125
|
-
|
|
126
|
-
.filter(
|
|
127
|
-
.sort(
|
|
128
|
-
|
|
65
|
+
const versions = Object.keys(patches_json_1.default)
|
|
66
|
+
.filter((nv) => semver_1.default.satisfies(nv, nodeRange) || nodeRange === 'latest')
|
|
67
|
+
.sort((nv1, nv2) => (semver_1.default.gt(nv1, nv2) ? 1 : -1));
|
|
68
|
+
const nodeVersion = versions.pop();
|
|
129
69
|
if (!nodeVersion) {
|
|
130
|
-
throw (0, log_1.wasReported)(
|
|
70
|
+
throw (0, log_1.wasReported)(`No available node version satisfies '${nodeRange}'`);
|
|
131
71
|
}
|
|
132
72
|
return nodeVersion;
|
|
133
73
|
}
|
|
@@ -138,118 +78,100 @@ function getNodeVersion(nodeRange) {
|
|
|
138
78
|
throw (0, log_1.wasReported)("nodeRange must start with 'node'");
|
|
139
79
|
}
|
|
140
80
|
if (nodeRange !== 'latest') {
|
|
141
|
-
nodeRange =
|
|
81
|
+
nodeRange = `v${nodeRange.slice(4)}`; // 'node6' -> 'v6' for semver
|
|
142
82
|
}
|
|
143
|
-
|
|
83
|
+
const nodeVersion = satisfyingNodeVersion(nodeRange);
|
|
144
84
|
return nodeVersion;
|
|
145
85
|
}
|
|
146
86
|
exports.getNodeVersion = getNodeVersion;
|
|
147
|
-
function need(opts) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
nodeVersion: nodeVersion,
|
|
176
|
-
platform: platform,
|
|
177
|
-
version: package_json_1.version,
|
|
178
|
-
output: output,
|
|
179
|
-
});
|
|
180
|
-
remote = (0, places_1.remotePlace)({ arch: arch, nodeVersion: nodeVersion, platform: platform, version: package_json_1.version });
|
|
181
|
-
if (!!forceBuild) return [3 /*break*/, 3];
|
|
182
|
-
return [4 /*yield*/, exists(fetched)];
|
|
183
|
-
case 1:
|
|
184
|
-
if (!_c.sent()) return [3 /*break*/, 3];
|
|
185
|
-
if (dryRun) {
|
|
186
|
-
return [2 /*return*/, 'exists'];
|
|
187
|
-
}
|
|
188
|
-
return [4 /*yield*/, (0, utils_1.hash)(fetched)];
|
|
189
|
-
case 2:
|
|
190
|
-
if ((_c.sent()) === expected_1.EXPECTED_HASHES[remote.name]) {
|
|
191
|
-
return [2 /*return*/, fetched];
|
|
192
|
-
}
|
|
193
|
-
log_1.log.info('Binary hash does NOT match. Re-fetching...');
|
|
194
|
-
fs_extra_1.default.unlinkSync(fetched);
|
|
195
|
-
_c.label = 3;
|
|
196
|
-
case 3:
|
|
197
|
-
if (!!forceFetch) return [3 /*break*/, 5];
|
|
198
|
-
return [4 /*yield*/, exists(built)];
|
|
199
|
-
case 4:
|
|
200
|
-
if (_c.sent()) {
|
|
201
|
-
if (dryRun)
|
|
202
|
-
return [2 /*return*/, 'exists'];
|
|
203
|
-
if (forceBuild)
|
|
204
|
-
log_1.log.info('Reusing base binaries built locally:', built);
|
|
205
|
-
return [2 /*return*/, built];
|
|
206
|
-
}
|
|
207
|
-
_c.label = 5;
|
|
208
|
-
case 5:
|
|
209
|
-
if (!!forceBuild) return [3 /*break*/, 9];
|
|
210
|
-
if (dryRun)
|
|
211
|
-
return [2 /*return*/, 'fetched'];
|
|
212
|
-
return [4 /*yield*/, download(remote, fetched)];
|
|
213
|
-
case 6:
|
|
214
|
-
if (!_c.sent()) return [3 /*break*/, 8];
|
|
215
|
-
return [4 /*yield*/, (0, utils_1.hash)(fetched)];
|
|
216
|
-
case 7:
|
|
217
|
-
if ((_c.sent()) === expected_1.EXPECTED_HASHES[remote.name]) {
|
|
218
|
-
return [2 /*return*/, fetched];
|
|
219
|
-
}
|
|
220
|
-
fs_extra_1.default.unlinkSync(fetched);
|
|
221
|
-
throw (0, log_1.wasReported)('Binary hash does NOT match.');
|
|
222
|
-
case 8:
|
|
223
|
-
fetchFailed = true;
|
|
224
|
-
_c.label = 9;
|
|
225
|
-
case 9:
|
|
226
|
-
if (!dryRun && fetchFailed) {
|
|
227
|
-
log_1.log.info('Not found in remote cache:', JSON.stringify(remote));
|
|
228
|
-
if (forceFetch) {
|
|
229
|
-
throw (0, log_1.wasReported)("Failed to fetch.");
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
if (!dryRun) {
|
|
233
|
-
log_1.log.info('Building base binary from source:', path_1.default.basename(built));
|
|
234
|
-
}
|
|
235
|
-
if (system_1.hostPlatform !== platform) {
|
|
236
|
-
if (system_1.hostPlatform !== 'alpine' || platform !== 'linuxstatic') {
|
|
237
|
-
throw (0, log_1.wasReported)("Not able to build for '".concat(opts.platform, "' here, only for '").concat(system_1.hostPlatform, "'"));
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
if (system_1.knownArchs.indexOf(arch) < 0) {
|
|
241
|
-
throw (0, log_1.wasReported)("Unknown arch '".concat(opts.arch, "'. Specify ").concat(system_1.knownArchs.join(', ')));
|
|
242
|
-
}
|
|
243
|
-
if (dryRun) {
|
|
244
|
-
return [2 /*return*/, 'built'];
|
|
245
|
-
}
|
|
246
|
-
return [4 /*yield*/, (0, build_1.default)(nodeVersion, arch, platform, built)];
|
|
247
|
-
case 10:
|
|
248
|
-
_c.sent();
|
|
249
|
-
return [2 /*return*/, built];
|
|
250
|
-
}
|
|
251
|
-
});
|
|
87
|
+
async function need(opts) {
|
|
88
|
+
// eslint-disable-line complexity
|
|
89
|
+
const { forceFetch, forceBuild, dryRun, output, nodeRange } = opts || {};
|
|
90
|
+
let { platform, arch } = opts || {};
|
|
91
|
+
if (!nodeRange)
|
|
92
|
+
throw (0, log_1.wasReported)('nodeRange not specified');
|
|
93
|
+
if (!platform)
|
|
94
|
+
throw (0, log_1.wasReported)('platform not specified');
|
|
95
|
+
if (!arch)
|
|
96
|
+
throw (0, log_1.wasReported)('arch not specified');
|
|
97
|
+
platform = (0, system_1.toFancyPlatform)(platform); // win32 -> win
|
|
98
|
+
arch = (0, system_1.toFancyArch)(arch); // ia32 -> x86
|
|
99
|
+
const nodeVersion = getNodeVersion(nodeRange);
|
|
100
|
+
const fetched = (0, places_1.localPlace)({
|
|
101
|
+
from: 'fetched',
|
|
102
|
+
arch,
|
|
103
|
+
nodeVersion,
|
|
104
|
+
platform,
|
|
105
|
+
version: package_json_1.version,
|
|
106
|
+
output,
|
|
107
|
+
});
|
|
108
|
+
const built = (0, places_1.localPlace)({
|
|
109
|
+
from: 'built',
|
|
110
|
+
arch,
|
|
111
|
+
nodeVersion,
|
|
112
|
+
platform,
|
|
113
|
+
version: package_json_1.version,
|
|
114
|
+
output,
|
|
252
115
|
});
|
|
116
|
+
const remote = (0, places_1.remotePlace)({ arch, nodeVersion, platform, version: package_json_1.version });
|
|
117
|
+
let fetchFailed;
|
|
118
|
+
if (!forceBuild) {
|
|
119
|
+
if (await exists(fetched)) {
|
|
120
|
+
if (dryRun) {
|
|
121
|
+
return 'exists';
|
|
122
|
+
}
|
|
123
|
+
// when node path is set, skip hash check
|
|
124
|
+
if (!!process.env.PKG_NODE_PATH ||
|
|
125
|
+
(await (0, utils_1.hash)(fetched)) === expected_1.EXPECTED_HASHES[remote.name]) {
|
|
126
|
+
return fetched;
|
|
127
|
+
}
|
|
128
|
+
log_1.log.info('Binary hash does NOT match. Re-fetching...');
|
|
129
|
+
(0, fs_1.unlinkSync)(fetched);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (!forceFetch) {
|
|
133
|
+
if (await exists(built)) {
|
|
134
|
+
if (dryRun)
|
|
135
|
+
return 'exists';
|
|
136
|
+
if (forceBuild)
|
|
137
|
+
log_1.log.info('Reusing base binaries built locally:', built);
|
|
138
|
+
return built;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (!forceBuild) {
|
|
142
|
+
if (dryRun)
|
|
143
|
+
return 'fetched';
|
|
144
|
+
if (await download(remote, fetched)) {
|
|
145
|
+
if ((await (0, utils_1.hash)(fetched)) === expected_1.EXPECTED_HASHES[remote.name]) {
|
|
146
|
+
return fetched;
|
|
147
|
+
}
|
|
148
|
+
(0, fs_1.unlinkSync)(fetched);
|
|
149
|
+
throw (0, log_1.wasReported)('Binary hash does NOT match.');
|
|
150
|
+
}
|
|
151
|
+
fetchFailed = true;
|
|
152
|
+
}
|
|
153
|
+
if (!dryRun && fetchFailed) {
|
|
154
|
+
log_1.log.info('Not found in remote cache:', JSON.stringify(remote));
|
|
155
|
+
if (forceFetch) {
|
|
156
|
+
throw (0, log_1.wasReported)(`Failed to fetch.`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (!dryRun) {
|
|
160
|
+
log_1.log.info('Building base binary from source:', path_1.default.basename(built));
|
|
161
|
+
}
|
|
162
|
+
if (system_1.hostPlatform !== platform) {
|
|
163
|
+
if ((system_1.hostPlatform !== 'alpine' || platform !== 'linuxstatic') && arch !== 'ppc64') {
|
|
164
|
+
throw (0, log_1.wasReported)(`Not able to build for '${opts.platform}' here, only for '${system_1.hostPlatform}'`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (system_1.knownArchs.indexOf(arch) < 0) {
|
|
168
|
+
throw (0, log_1.wasReported)(`Unknown arch '${opts.arch}'. Specify ${system_1.knownArchs.join(', ')}`);
|
|
169
|
+
}
|
|
170
|
+
if (dryRun) {
|
|
171
|
+
return 'built';
|
|
172
|
+
}
|
|
173
|
+
await (0, build_1.default)(nodeVersion, arch, platform, built);
|
|
174
|
+
return built;
|
|
253
175
|
}
|
|
254
176
|
exports.need = need;
|
|
255
177
|
//# sourceMappingURL=index.js.map
|