@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.
@@ -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.18.2-alpine-arm64": "244a74549a342ed74b531625c02168e1c0e72f328d8b8d53ab143a6813fd9466",
26
- "node-v18.18.2-alpine-x64": "b9c6d08f510ce15353d9f2441b5b096697c877b1760a6f526c203b47bf3ec83a",
27
- "node-v18.18.2-linux-arm64": "01676c5420d17a2fa53ddf4573ca21895150ae317cd54a7e26234c26d3603e7a",
28
- "node-v18.18.2-linux-x64": "d918fd7ad7d9db0cde09c570ada58a6fb9e2bf43c032a9cb87d0e572f06db646",
29
- "node-v18.18.2-linuxstatic-arm64": "2db35ca7c089fc78a8c6b44804a88aa1035344a7465b038f593cc337198285a6",
30
- "node-v18.18.2-linuxstatic-armv7": "705c75ab9155069ffb8c3f800f8d49121d2b0d07343e4da9a98477e2962602f9",
31
- "node-v18.18.2-linuxstatic-x64": "dce8f6c6f3ce48b4bbfb7a8177165c9743dba12458ccd42b9f3da3c9601fc088",
32
- "node-v18.18.2-macos-x64": "db04d8a9338e1d2f6afd53c99d0a57ec9cc4bca84165ade0d2f5fcf9871bcdb9",
33
- "node-v18.18.2-win-arm64": "ca08e24dfd5bae1a898d86f3241287e057c14e7fce37da1dff63f1bce6822b62",
34
- "node-v18.18.2-win-x64": "81b25a5dc71bb3ebc8219f4cd73ad598a1eaff16ccbb2f75cf8f5db94e08149b",
35
- "node-v18.18.2-macos-arm64": "35deec00661aa042d3557e74281c6742f0184e634da0df055c3c4214360a3070",
36
- "node-v19.8.1-alpine-arm64": "7d4fc8a17f116d6e77b6011201797897592fa03380e939fa8b49b00ba7ac641b",
37
- "node-v19.8.1-alpine-x64": "aca5632e1960d763c7b9914ebfeb929c4ca0e8c2112798eca3959ba9a5076ed8",
38
- "node-v19.8.1-linux-arm64": "4754c852da9e55591d7e54c4b9c5db1db4d52c8452b8533aab73451c1c5797f8",
39
- "node-v19.8.1-linux-x64": "757a9e3b8a72f6eecf5cbc0b8ec4b25298375c1952165c3ef2184133ac81ff44",
40
- "node-v19.8.1-linuxstatic-arm64": "46b343c2d948acdf36d1717ad3e4a0c1bf28ea1abf845e24ed4cbf4d047a0890",
41
- "node-v19.8.1-linuxstatic-armv7": "63c7154dee90dd6734cdf3eaa8ab3e1ab111772612eb48271f6cfd22f84c4dee",
42
- "node-v19.8.1-linuxstatic-x64": "39c5c208347c76d921212d7a0d885c0b54d8c698b01c0e1e4b167b87fbc6ffb1",
43
- "node-v19.8.1-macos-x64": "7288e53e6afe4d07bc5f32965ca7a051d7e72a67f09979c561dc8dabff88a5b2",
44
- "node-v19.8.1-win-arm64": "f288732fc5f5493367a5d60d1e227347099de3db26fd651607df07d37fb8222e",
45
- "node-v19.8.1-win-x64": "98b22116864d72e1ccb4d557dc36785cf731051543c5c876f1bf547872de2d1d",
46
- "node-v19.8.1-macos-arm64": "69c1113d1fbcce01e0062af12a4a1b81f6c3746ff32a8b307f8632788109c94a",
47
- "node-v20.10.0-alpine-arm64": "909d88e166499dd9311e9d8d72cce1c2ae1f81ca7f5602e5ee2d5c4eeb39d99b",
48
- "node-v20.10.0-alpine-x64": "1bcce476efb0b797cd67f4ebb3d5f824241d67246654cf18e94465a473290d6f",
49
- "node-v20.10.0-linux-x64": "d17d0a9477cd702ba0de16f903d4ffbcef1898833568c24cbf2c6ef3b0c052a4",
50
- "node-v20.10.0-linuxstatic-arm64": "38df4a161b347b481e9cbbe78a5830bdcc776183bc9cbde152f6bb60b90f9dd0",
51
- "node-v20.10.0-linuxstatic-armv7": "64d3543fae52e92c191dfd187679b28c234ff67cee17fddb1444a1fad58f4983",
52
- "node-v20.10.0-linuxstatic-x64": "345ed15e21298b206df5c102aa0225108344ae183414cd967c6b517c9671c501",
53
- "node-v20.10.0-macos-x64": "e7d7d837ea3f373b347106118d2ce187e4990534f28d9c8cfdff68084b36a69b",
54
- "node-v20.10.0-win-arm64": "13ca46f22f159d3c83357ad1f75482556abefeba1eeb15e7dc7747a29e82aba5",
55
- "node-v20.10.0-win-x64": "27472c7a532a51ab2089a35f5afbeefd1075f4939fe3f4a8dc594439bf708117",
56
- "node-v20.10.0-linux-arm64": "0162ad9d9eb1e4ce01b3a5fe519be3032d8f6e66d77cdb18105654cde28433b6",
57
- "node-v20.10.0-macos-arm64": "c61c9ddd7218ddd28e38c5d88b13cd2f972b6aaef244d0b2518bf33bfbdad997"
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
  }
@@ -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,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
- var fs_extra_1 = __importDefault(require("fs-extra"));
67
- var path_1 = __importDefault(require("path"));
68
- var semver_1 = __importDefault(require("semver"));
69
- var expected_1 = require("./expected");
70
- var system_1 = require("./system");
71
- 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"));
72
37
  exports.system = system;
73
- var places_1 = require("./places");
74
- var log_1 = require("./log");
75
- var build_1 = __importDefault(require("./build"));
76
- var utils_1 = require("./utils");
77
- var patches_json_1 = __importDefault(require("../patches/patches.json"));
78
- var package_json_1 = require("../package.json");
79
- function download(_a, local) {
80
- var tag = _a.tag, name = _a.name;
81
- return __awaiter(this, void 0, void 0, function () {
82
- var url, _b;
83
- return __generator(this, function (_c) {
84
- switch (_c.label) {
85
- case 0:
86
- url = "https://github.com/yao-pkg/pkg-fetch/releases/download/".concat(tag, "/").concat(name);
87
- _c.label = 1;
88
- case 1:
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
- return __awaiter(this, void 0, void 0, function () {
107
- var error_1;
108
- return __generator(this, function (_a) {
109
- switch (_a.label) {
110
- case 0:
111
- _a.trys.push([0, 2, , 3]);
112
- return [4 /*yield*/, fs_extra_1.default.stat(file)];
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
- var versions = Object.keys(patches_json_1.default)
126
- .filter(function (nv) { return semver_1.default.satisfies(nv, nodeRange) || nodeRange === 'latest'; })
127
- .sort(function (nv1, nv2) { return (semver_1.default.gt(nv1, nv2) ? 1 : -1); });
128
- 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();
129
69
  if (!nodeVersion) {
130
- throw (0, log_1.wasReported)("No available node version satisfies '".concat(nodeRange, "'"));
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 = "v".concat(nodeRange.slice(4)); // 'node6' -> 'v6' for semver
81
+ nodeRange = `v${nodeRange.slice(4)}`; // 'node6' -> 'v6' for semver
142
82
  }
143
- var nodeVersion = satisfyingNodeVersion(nodeRange);
83
+ const nodeVersion = satisfyingNodeVersion(nodeRange);
144
84
  return nodeVersion;
145
85
  }
146
86
  exports.getNodeVersion = getNodeVersion;
147
- function need(opts) {
148
- return __awaiter(this, void 0, void 0, function () {
149
- var _a, forceFetch, forceBuild, dryRun, output, nodeRange, _b, platform, arch, nodeVersion, fetched, built, remote, fetchFailed;
150
- return __generator(this, function (_c) {
151
- switch (_c.label) {
152
- case 0:
153
- _a = opts || {}, forceFetch = _a.forceFetch, forceBuild = _a.forceBuild, dryRun = _a.dryRun, output = _a.output, nodeRange = _a.nodeRange;
154
- _b = opts || {}, platform = _b.platform, arch = _b.arch;
155
- if (!nodeRange)
156
- throw (0, log_1.wasReported)('nodeRange not specified');
157
- if (!platform)
158
- throw (0, log_1.wasReported)('platform not specified');
159
- if (!arch)
160
- throw (0, log_1.wasReported)('arch not specified');
161
- platform = (0, system_1.toFancyPlatform)(platform); // win32 -> win
162
- arch = (0, system_1.toFancyArch)(arch); // ia32 -> x86
163
- nodeVersion = getNodeVersion(nodeRange);
164
- fetched = (0, places_1.localPlace)({
165
- from: 'fetched',
166
- arch: arch,
167
- nodeVersion: nodeVersion,
168
- platform: platform,
169
- version: package_json_1.version,
170
- output: output,
171
- });
172
- built = (0, places_1.localPlace)({
173
- from: 'built',
174
- arch: arch,
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