@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.
@@ -32,36 +32,36 @@
32
32
  "node-v18.20.8-macos-x64": "f2cf139bfe3501d39d22b48a069f9ceb24942b0cdc001a0bc30ea3a68fbcc6b3",
33
33
  "node-v18.20.8-win-arm64": "dd56454cfc9292f047413657c8b997006f27ecda8cd7f7dd38acf8d22317e743",
34
34
  "node-v18.20.8-win-x64": "4d45cdfbcba3de3f6c0ddcd78251179b9d04dd2fcb2dba2fb052940a2821eb39",
35
- "node-v20.19.6-alpine-arm64": "3e7ddc77635f6225b8cba469b948752d16decdb94293b13ea6c9ce4792526d2e",
36
- "node-v20.19.6-alpine-x64": "39f3a1fb1c83ecd3483e4335124bd9282dba239fcdf85430b7aea8fbfb8a1206",
37
- "node-v20.19.6-linux-arm64": "3f19fd984a558d2b3cc2f78fae2a3927b9d87a631ad454eeccf7ffd10e7c6f19",
38
- "node-v20.19.6-linux-x64": "de270a8b37db68307fead80ddb75718c5599d4a96004d052588e24fac0a5e8f5",
39
- "node-v20.19.6-linuxstatic-arm64": "049aefa14949d95ded5e3761b263171b1a5d430c1b6af10ab82ffbdfd945507a",
40
- "node-v20.19.6-linuxstatic-armv7": "96b66e0cb1bc3f53e4e652e4a1b4d1c51acec13d2c9136c7cb0f565d75ba60f5",
41
- "node-v20.19.6-linuxstatic-x64": "ddc9c76e002e6e1768139099d27bf297bf564750187cef230e3113f773a97724",
42
- "node-v20.19.6-macos-arm64": "4f50f1d0484cc69043abacd266de603773dc84a2d5ae0233453c701fed0d2241",
43
- "node-v20.19.6-macos-x64": "9ed57a94c5dfc099fc262884b633fad61a7fba19b4b43ca2fd7a2ec0ffa5580d",
44
- "node-v20.19.6-win-arm64": "a0384fe007e78340cc863224dafd5a6de5c97b83ea8c764e1f31abfeaea07d03",
45
- "node-v20.19.6-win-x64": "3203fce16436a5e78f77e927c2d1616404d567e20fd11d9f21cb41aa524978a7",
46
- "node-v22.21.1-alpine-arm64": "fd1c1829fd457946e7e2e647632651b1552063f044199a53c9768d8502ec94b0",
47
- "node-v22.21.1-alpine-x64": "ada5bd34905be599208e78d4b086ce7f3b66fe29362a233b1d2d4b687048816f",
48
- "node-v22.21.1-linux-arm64": "4e14e66e431cfd5b2481754751af0e74e5741b3be1180c06b106c2998846dad9",
49
- "node-v22.21.1-linux-x64": "63c6f17f8fd19665e99e5d0b2c2d4668e0aa735564c28a8246940fb447fdf618",
50
- "node-v22.21.1-linuxstatic-arm64": "67b57eddac3ef13f00ba393732cd84f62f4dee62e8bf87b727d4cc2806fb7911",
51
- "node-v22.21.1-linuxstatic-armv7": "3394b6e575af93426353d4d602e5baf444538703712fdacd51571f69f2f32f0e",
52
- "node-v22.21.1-linuxstatic-x64": "2f65505ec0044d6a47c888e28e2bd5f1ccbb64ccac9ac5f90fc51a2df2720d10",
53
- "node-v22.21.1-macos-arm64": "844260a5faef047965604ffeb442ddd4336864e0262f565f08a83a62c2960c28",
54
- "node-v22.21.1-macos-x64": "f9b827483f14c8474f76c6538712c284a40c3b37402ecb046fbae04022b54e35",
55
- "node-v22.21.1-win-arm64": "17e55802bcc4bc1690009797b62a72f6f2f6cc127541b60a4a2ed578b117f899",
56
- "node-v22.21.1-win-x64": "440be9af0d908922ec3e8678724e8473ada0af46dfe2cd5ba75bc14e0048df99",
57
- "node-v24.12.0-alpine-arm64": "7795a8932f8dfdebc3636cf83bfa69b7da2e4256dbfa99fe39a4c201a95d70f8",
58
- "node-v24.12.0-alpine-x64": "d157149a911313dda8ceb6bc93096d531a850b0e6c1b76b2ac721e4f49413ce9",
59
- "node-v24.12.0-linux-arm64": "9a5816b9e3552bb5a914aeed16326a569e18dcc17f07ad8dd28b4a7fa67066a4",
60
- "node-v24.12.0-linux-x64": "81a0b40e6d7d14d501e100a5a1f08eb3621c2323ee66c6bfd42f7bf7407b06dc",
61
- "node-v24.12.0-linuxstatic-arm64": "fdb80c730160db3157923e8fef52df595aba597757affb9f7c0e11c5562f4ccd",
62
- "node-v24.12.0-linuxstatic-x64": "4f9f3c2a1e3155f4203f8043e04412e7be90dc16ac7f78341083f9f1076b138c",
63
- "node-v24.12.0-macos-arm64": "9dffdd09697f041369fec623e86dc866f00a4daaa9da84808f7352372339d9de",
64
- "node-v24.12.0-macos-x64": "a7e48452945f37a831f96ab49f52d5049b989c68137cd398553787d3d1b14554",
65
- "node-v24.12.0-win-arm64": "9db6863e384aa746d1ae369c38aa11f3e46550240bb0abcbedb27d2a085c669d",
66
- "node-v24.12.0-win-x64": "78eda417c8baf713d1790b8b42d8e6eec846101bb4249776d68069d64d240570"
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.2-alpine-arm64": "1f4c95a621a16d5a38297e3b2214bc383212e5ddf01e43c56962d315af626fb1",
47
+ "node-v22.22.2-alpine-x64": "39d09e5a5cfde1b731ce3a0fe2296f81ca664b017c28140c1b9833b9917a0209",
48
+ "node-v22.22.2-linux-arm64": "d568971c932f576bc5c7b985a3fa6a094fe7073ee9be5c9afb798e0623f85665",
49
+ "node-v22.22.2-linux-x64": "107a8432235e1c38c747a09a8210662eda77edf08bbd76b2edd7211ccb026a3f",
50
+ "node-v22.22.2-linuxstatic-arm64": "9087e9d548507f05142f8a6fc4180af6d97998190cd49c87bb85f5385c77684b",
51
+ "node-v22.22.2-linuxstatic-armv7": "a457acce0c989f468e6be39906490ba4cfc1e278c34b2c6a11be519eef27f71b",
52
+ "node-v22.22.2-linuxstatic-x64": "879320d0e07a3d1f58d4ed756ddbb124bf6bfb1bef66795ba56888bfa017f8cf",
53
+ "node-v22.22.2-macos-arm64": "246e45953da4100c518b9db97317d2b7a862ca8dc02306e04ee96941174aa86a",
54
+ "node-v22.22.2-macos-x64": "4f968aa3fe580d20e09c54ca836b3ba0b2fe3a3921cffea18eaedb9619b2a27c",
55
+ "node-v22.22.2-win-arm64": "6dc7f0e83a362d67824ff2cc6f6e604ad59bd6ffdaa27eaef4b2d07739cdd8a9",
56
+ "node-v22.22.2-win-x64": "66ed75e181a7bb9ea341f9f10361ffcc97d074c11f56f6eb7435c8b872938caa",
57
+ "node-v24.14.1-alpine-arm64": "e787fe77879f9d2dbe43a9c3017c65df23329f3896d418eb98152b62ec77922a",
58
+ "node-v24.14.1-alpine-x64": "9585f7f447e8ed2eeb4fa4616a18a7b00d9299169ee9a8d8910f8ea8fc69c654",
59
+ "node-v24.14.1-linux-arm64": "955d73226d9ea08614488fa36f7cdea7b968dca2084533a65c01db0d2d964d35",
60
+ "node-v24.14.1-linux-x64": "e7188d4caa1773042a7de021aaa48ab8aa65cc25ff7cdfb4cb56e4466ad43270",
61
+ "node-v24.14.1-linuxstatic-arm64": "b54e89a51df513d2b130f4d8e68891d70c519e3b6fb5aafd51967ada77aed387",
62
+ "node-v24.14.1-linuxstatic-x64": "7b8cb78b2b5ae1986b87a82247636d00332531a0901060f2646a287b1f4f7ca1",
63
+ "node-v24.14.1-macos-arm64": "f3351cbc18dc65af7d7996c10b69d5bad6d4378fac44c634f80698ffd5b188b0",
64
+ "node-v24.14.1-macos-x64": "6f572f76035265cfe1fe629f176fe664676d989faec81982534e1e872ff0ae9f",
65
+ "node-v24.14.1-win-arm64": "56f7360c96bd21508e456aa43cae60af6a0364d335681a76157647a46bc21ecf",
66
+ "node-v24.14.1-win-x64": "8f29033efabc7ac06272be22ec89d4e917ada0724f36fcd2a654dccdff132450"
67
67
  }
@@ -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
- var expected_shas_json_1 = __importDefault(require("./expected-shas.json"));
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
- var yargs_1 = __importDefault(require("yargs"));
43
- var fs_1 = require("fs");
44
- var path_1 = require("path");
45
- var log_1 = require("./log");
46
- var package_json_1 = require("../package.json");
47
- var utils_1 = require("./utils");
48
- function main() {
49
- return __awaiter(this, void 0, void 0, function () {
50
- var argv, shaFileContent, shaMap, _i, _a, line, lineParts, sortedShaMap, _b, _c, nodeVersion;
51
- return __generator(this, function (_d) {
52
- argv = yargs_1.default
53
- .option('input', { alias: 'i', default: 'shas.txt', type: 'string' })
54
- .version(package_json_1.version)
55
- .alias('v', 'version')
56
- .help()
57
- .alias('h', 'help').argv;
58
- shaFileContent = (0, fs_1.readFileSync)(argv.input).toString();
59
- shaMap = {};
60
- for (_i = 0, _a = shaFileContent.split('\n'); _i < _a.length; _i++) {
61
- line = _a[_i];
62
- lineParts = line.split(/\s+/);
63
- if (lineParts.length === 2) {
64
- // eslint-disable-next-line prefer-destructuring
65
- shaMap[lineParts[1]] = lineParts[0];
66
- }
67
- }
68
- sortedShaMap = {};
69
- for (_b = 0, _c = Object.keys(shaMap).sort(utils_1.nodeBinarySortFunction); _b < _c.length; _b++) {
70
- nodeVersion = _c[_b];
71
- sortedShaMap[nodeVersion] = shaMap[nodeVersion];
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(function (error) {
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,113 +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
- var fs_1 = require("fs");
67
- var promises_1 = require("fs/promises");
68
- var path_1 = __importDefault(require("path"));
69
- var semver_1 = __importDefault(require("semver"));
70
- var expected_1 = require("./expected");
71
- var system_1 = require("./system");
72
- var system = __importStar(require("./system"));
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"));
73
37
  exports.system = system;
74
- var places_1 = require("./places");
75
- var log_1 = require("./log");
76
- var build_1 = __importDefault(require("./build"));
77
- var utils_1 = require("./utils");
78
- var patches_json_1 = __importDefault(require("../patches/patches.json"));
79
- var package_json_1 = require("../package.json");
80
- function download(_a, local) {
81
- var tag = _a.tag, name = _a.name;
82
- return __awaiter(this, void 0, void 0, function () {
83
- var url, _b;
84
- return __generator(this, function (_c) {
85
- switch (_c.label) {
86
- case 0:
87
- url = "https://github.com/yao-pkg/pkg-fetch/releases/download/".concat(tag, "/").concat(name);
88
- _c.label = 1;
89
- case 1:
90
- _c.trys.push([1, 4, , 5]);
91
- return [4 /*yield*/, (0, utils_1.downloadUrl)(url, local)];
92
- case 2:
93
- _c.sent();
94
- return [4 /*yield*/, (0, utils_1.plusx)(local)];
95
- case 3:
96
- _c.sent();
97
- return [3 /*break*/, 5];
98
- case 4:
99
- _b = _c.sent();
100
- return [2 /*return*/, false];
101
- case 5: return [2 /*return*/, true];
102
- }
103
- });
104
- });
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;
105
54
  }
106
- function exists(file) {
107
- return __awaiter(this, void 0, void 0, function () {
108
- var error_1;
109
- return __generator(this, function (_a) {
110
- switch (_a.label) {
111
- case 0:
112
- _a.trys.push([0, 2, , 3]);
113
- return [4 /*yield*/, (0, promises_1.stat)(file)];
114
- case 1:
115
- _a.sent();
116
- return [2 /*return*/, true];
117
- case 2:
118
- error_1 = _a.sent();
119
- return [2 /*return*/, false];
120
- case 3: return [2 /*return*/];
121
- }
122
- });
123
- });
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
+ }
124
63
  }
125
64
  function satisfyingNodeVersion(nodeRange) {
126
- var versions = Object.keys(patches_json_1.default)
127
- .filter(function (nv) { return semver_1.default.satisfies(nv, nodeRange) || nodeRange === 'latest'; })
128
- .sort(function (nv1, nv2) { return (semver_1.default.gt(nv1, nv2) ? 1 : -1); });
129
- var nodeVersion = versions.pop();
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();
130
69
  if (!nodeVersion) {
131
- throw (0, log_1.wasReported)("No available node version satisfies '".concat(nodeRange, "'"));
70
+ throw (0, log_1.wasReported)(`No available node version satisfies '${nodeRange}'`);
132
71
  }
133
72
  return nodeVersion;
134
73
  }
@@ -139,124 +78,100 @@ function getNodeVersion(nodeRange) {
139
78
  throw (0, log_1.wasReported)("nodeRange must start with 'node'");
140
79
  }
141
80
  if (nodeRange !== 'latest') {
142
- nodeRange = "v".concat(nodeRange.slice(4)); // 'node6' -> 'v6' for semver
81
+ nodeRange = `v${nodeRange.slice(4)}`; // 'node6' -> 'v6' for semver
143
82
  }
144
- var nodeVersion = satisfyingNodeVersion(nodeRange);
83
+ const nodeVersion = satisfyingNodeVersion(nodeRange);
145
84
  return nodeVersion;
146
85
  }
147
86
  exports.getNodeVersion = getNodeVersion;
148
- function need(opts) {
149
- return __awaiter(this, void 0, void 0, function () {
150
- var _a, forceFetch, forceBuild, dryRun, output, nodeRange, _b, platform, arch, nodeVersion, fetched, built, remote, fetchFailed, _c;
151
- return __generator(this, function (_d) {
152
- switch (_d.label) {
153
- case 0:
154
- _a = opts || {}, forceFetch = _a.forceFetch, forceBuild = _a.forceBuild, dryRun = _a.dryRun, output = _a.output, nodeRange = _a.nodeRange;
155
- _b = opts || {}, platform = _b.platform, arch = _b.arch;
156
- if (!nodeRange)
157
- throw (0, log_1.wasReported)('nodeRange not specified');
158
- if (!platform)
159
- throw (0, log_1.wasReported)('platform not specified');
160
- if (!arch)
161
- throw (0, log_1.wasReported)('arch not specified');
162
- platform = (0, system_1.toFancyPlatform)(platform); // win32 -> win
163
- arch = (0, system_1.toFancyArch)(arch); // ia32 -> x86
164
- nodeVersion = getNodeVersion(nodeRange);
165
- fetched = (0, places_1.localPlace)({
166
- from: 'fetched',
167
- arch: arch,
168
- nodeVersion: nodeVersion,
169
- platform: platform,
170
- version: package_json_1.version,
171
- output: output,
172
- });
173
- built = (0, places_1.localPlace)({
174
- from: 'built',
175
- arch: arch,
176
- nodeVersion: nodeVersion,
177
- platform: platform,
178
- version: package_json_1.version,
179
- output: output,
180
- });
181
- remote = (0, places_1.remotePlace)({ arch: arch, nodeVersion: nodeVersion, platform: platform, version: package_json_1.version });
182
- if (!!forceBuild) return [3 /*break*/, 4];
183
- return [4 /*yield*/, exists(fetched)];
184
- case 1:
185
- if (!_d.sent()) return [3 /*break*/, 4];
186
- if (dryRun) {
187
- return [2 /*return*/, 'exists'];
188
- }
189
- _c = !!process.env.PKG_NODE_PATH;
190
- if (_c) return [3 /*break*/, 3];
191
- return [4 /*yield*/, (0, utils_1.hash)(fetched)];
192
- case 2:
193
- _c = (_d.sent()) === expected_1.EXPECTED_HASHES[remote.name];
194
- _d.label = 3;
195
- case 3:
196
- // when node path is set, skip hash check
197
- if (_c) {
198
- return [2 /*return*/, fetched];
199
- }
200
- log_1.log.info('Binary hash does NOT match. Re-fetching...');
201
- (0, fs_1.unlinkSync)(fetched);
202
- _d.label = 4;
203
- case 4:
204
- if (!!forceFetch) return [3 /*break*/, 6];
205
- return [4 /*yield*/, exists(built)];
206
- case 5:
207
- if (_d.sent()) {
208
- if (dryRun)
209
- return [2 /*return*/, 'exists'];
210
- if (forceBuild)
211
- log_1.log.info('Reusing base binaries built locally:', built);
212
- return [2 /*return*/, built];
213
- }
214
- _d.label = 6;
215
- case 6:
216
- if (!!forceBuild) return [3 /*break*/, 10];
217
- if (dryRun)
218
- return [2 /*return*/, 'fetched'];
219
- return [4 /*yield*/, download(remote, fetched)];
220
- case 7:
221
- if (!_d.sent()) return [3 /*break*/, 9];
222
- return [4 /*yield*/, (0, utils_1.hash)(fetched)];
223
- case 8:
224
- if ((_d.sent()) === expected_1.EXPECTED_HASHES[remote.name]) {
225
- return [2 /*return*/, fetched];
226
- }
227
- (0, fs_1.unlinkSync)(fetched);
228
- throw (0, log_1.wasReported)('Binary hash does NOT match.');
229
- case 9:
230
- fetchFailed = true;
231
- _d.label = 10;
232
- case 10:
233
- if (!dryRun && fetchFailed) {
234
- log_1.log.info('Not found in remote cache:', JSON.stringify(remote));
235
- if (forceFetch) {
236
- throw (0, log_1.wasReported)("Failed to fetch.");
237
- }
238
- }
239
- if (!dryRun) {
240
- log_1.log.info('Building base binary from source:', path_1.default.basename(built));
241
- }
242
- if (system_1.hostPlatform !== platform) {
243
- if ((system_1.hostPlatform !== 'alpine' || platform !== 'linuxstatic') && arch !== 'ppc64') {
244
- throw (0, log_1.wasReported)("Not able to build for '".concat(opts.platform, "' here, only for '").concat(system_1.hostPlatform, "'"));
245
- }
246
- }
247
- if (system_1.knownArchs.indexOf(arch) < 0) {
248
- throw (0, log_1.wasReported)("Unknown arch '".concat(opts.arch, "'. Specify ").concat(system_1.knownArchs.join(', ')));
249
- }
250
- if (dryRun) {
251
- return [2 /*return*/, 'built'];
252
- }
253
- return [4 /*yield*/, (0, build_1.default)(nodeVersion, arch, platform, built)];
254
- case 11:
255
- _d.sent();
256
- return [2 /*return*/, built];
257
- }
258
- });
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,
259
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;
260
175
  }
261
176
  exports.need = need;
262
177
  //# sourceMappingURL=index.js.map