@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/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
- var progress_1 = __importDefault(require("progress"));
24
- var assert_1 = __importDefault(require("assert"));
25
- var picocolors_1 = __importDefault(require("picocolors"));
26
- var tty_1 = require("tty");
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
- var pc = picocolors_1.default.createColors(tty_1.WriteStream.prototype.hasColors());
30
- var Log = /** @class */ (function () {
31
- function Log() {
32
- this.debugMode = false;
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(" ".concat(lines));
23
+ console.log(` ${lines}`);
40
24
  return;
41
25
  }
42
- for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
43
- var line = lines_1[_i];
44
- console.log(" ".concat(line));
26
+ for (const line of lines) {
27
+ console.log(` ${line}`);
45
28
  }
46
- };
47
- Log.prototype.debug = function (text, lines) {
29
+ }
30
+ debug(text, lines) {
48
31
  if (!this.debugMode) {
49
32
  return;
50
33
  }
51
- console.log("> ".concat(pc.green('[debug]'), " ").concat(text));
34
+ console.log(`> ${pc.green('[debug]')} ${text}`);
52
35
  this.lines(lines);
53
- };
54
- Log.prototype.info = function (text, lines) {
55
- console.log("> ".concat(text));
36
+ }
37
+ info(text, lines) {
38
+ console.log(`> ${text}`);
56
39
  this.lines(lines);
57
- };
58
- Log.prototype.warn = function (text, lines) {
59
- console.log("> ".concat(pc.blue('Warning'), " ").concat(text));
40
+ }
41
+ warn(text, lines) {
42
+ console.log(`> ${pc.blue('Warning')} ${text}`);
60
43
  this.lines(lines);
61
- };
62
- Log.prototype.error = function (text, lines) {
63
- var message = text instanceof Error ? text.stack : text;
64
- console.log("> ".concat(pc.red('Error!'), " ").concat(message));
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
- Log.prototype.enableProgress = function (text) {
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(" ".concat(text, " [:bar] :percent"), {
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
- Log.prototype.showProgress = function (percentage) {
60
+ }
61
+ showProgress(percentage) {
79
62
  if (!this.bar) {
80
63
  return;
81
64
  }
82
65
  this.bar.update(percentage / 100);
83
- };
84
- Log.prototype.disableProgress = function () {
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
- return ReportedError;
106
- }(Error));
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
- var reportedError = new ReportedError('No message');
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
- var fs = __importStar(require("fs"));
28
- var path = __importStar(require("path"));
29
- var log_1 = require("./log");
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)("Input file ".concat(inputFile, " does not exist"));
33
+ throw (0, log_1.wasReported)(`Input file ${inputFile} does not exist`);
34
34
  }
35
- var input = fs.readFileSync(inputFile, 'utf8');
36
- var lines = input.split('\n').map(function (l) { return l.trim(); }).filter(Boolean);
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
- var shasPath = path.join(process.cwd(), 'shas.txt');
39
- var shasTxt = '';
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
- var shasArr = shasTxt.split('\n');
48
- var _loop_1 = function (line) {
49
- var _a = line.split(/\s+/), sha = _a[0], patchName = _a[1];
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("Skipping invalid line: ".concat(line));
52
- return "continue";
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
- var match = patchName.match(/^node-v(\d+)\.[^ ]*-(.+)-(.+)$/);
56
+ const match = patchName.match(/^node-v(\d+)\.[^ ]*-(.+)-(.+)$/);
56
57
  if (!match) {
57
- log_1.log.warn("Skipping line with invalid patch name format: ".concat(line));
58
- return "continue";
58
+ log_1.log.warn(`Skipping line with invalid patch name format: ${line}`);
59
+ continue;
59
60
  }
60
- var major = match[1];
61
- var os = match[2];
62
- var arch = match[3];
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
- var re = new RegExp("^\\S+\\s+node-v".concat(major, "\\.([0-9.]+){2}-").concat(os, "-").concat(arch, "$"));
65
- var found = false;
66
- shasArr = shasArr.map(function (l) {
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("Updating: ".concat(l, " -> ").concat(sha, " ").concat(patchName));
70
- return "".concat(sha, " ").concat(patchName);
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("Adding new entry: ".concat(sha, " ").concat(patchName));
76
- shasArr.push("".concat(sha, " ").concat(patchName));
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
- var filteredShas = shasArr.filter(Boolean);
86
- var updatedContent = filteredShas.length > 0 ? "".concat(filteredShas.join('\n'), "\n") : '';
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("Successfully updated ".concat(shasPath));
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
- var args = process.argv.slice(2);
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
- var inputFile = args[0];
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
- var semver_1 = require("semver");
8
- var os_1 = __importDefault(require("os"));
9
- var path_1 = __importDefault(require("path"));
10
- var PKG_CACHE_PATH = process.env.PKG_CACHE_PATH;
11
- var IGNORE_TAG = Boolean(process.env.PKG_IGNORE_TAG);
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
- var mj = (0, semver_1.major)(version);
15
- var mn = (0, semver_1.minor)(version);
16
- return "v".concat(mj, ".").concat(mn);
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(_a) {
19
- var from = _a.from, output = _a.output, version = _a.version, nodeVersion = _a.nodeVersion, platform = _a.platform, arch = _a.arch;
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, "".concat(output ? 'node' : from, "-").concat(nodeVersion, "-").concat(platform, "-").concat(arch));
31
+ return path_1.default.resolve(binDir, `${output ? 'node' : from}-${nodeVersion}-${platform}-${arch}`);
33
32
  }
34
33
  exports.localPlace = localPlace;
35
- function remotePlace(_a) {
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: "node-".concat(nodeVersion, "-").concat(platform, "-").concat(arch),
37
+ name: `node-${nodeVersion}-${platform}-${arch}`,
40
38
  };
41
39
  }
42
40
  exports.remotePlace = remotePlace;
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var expected_1 = require("./expected");
4
- var utils_1 = require("./utils");
3
+ const expected_1 = require("./expected");
4
+ const utils_1 = require("./utils");
5
5
  /* eslint-disable no-console */
6
6
  function main() {
7
- for (var _i = 0, _a = Object.keys(expected_1.EXPECTED_HASHES).sort(utils_1.nodeBinarySortFunction); _i < _a.length; _i++) {
8
- var nodeVersion = _a[_i];
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
- var fs_1 = __importDefault(require("fs"));
8
- var child_process_1 = require("child_process");
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const child_process_1 = require("child_process");
9
9
  function getHostAbi() {
10
- return "m".concat(process.versions.modules);
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
- var _a;
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
- var ldd = (_a = (0, child_process_1.spawnSync)('ldd').stderr) === null || _a === void 0 ? void 0 : _a.toString();
70
+ const ldd = (0, child_process_1.spawnSync)('ldd').stderr?.toString();
72
71
  if (ldd == null) {
73
- return fs_1.default.readdirSync('/lib').some(function (file) { return file.startsWith('libc.musl'); });
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
- var lddNode = (0, child_process_1.spawnSync)('ldd', [process.execPath]).stdout.toString();
77
+ const lddNode = (0, child_process_1.spawnSync)('ldd', [process.execPath]).stdout.toString();
79
78
  return /\bmusl\b/.test(lddNode);
80
79
  }
81
- var isAlpine = detectAlpine();
80
+ const isAlpine = detectAlpine();
82
81
  function getHostPlatform() {
83
- var platform = process.platform;
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
- var uname = (0, child_process_1.spawnSync)('uname', ['-a']);
100
+ const uname = (0, child_process_1.spawnSync)('uname', ['-a']);
102
101
  if (uname.error) {
103
102
  return '';
104
103
  }
105
- var unameOut = uname.stdout && uname.stdout.toString();
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
- var _a;
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
- var name = cpu.split('model name')[1];
119
+ let name = cpu.split('model name')[1];
122
120
  if (name)
123
- _a = name.split(':'), name = _a[1];
121
+ [, name] = name.split(':');
124
122
  if (name)
125
- name = name.split('\n')[0];
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
- var arch = process.arch;
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
- var arch = getHostArch();
136
+ const arch = getHostArch();
139
137
  if (arch === 'x64') {
140
138
  return ['x64', 'x86'];
141
139
  }