@k03mad/actual-versions 1.3.0 → 1.4.0

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 CHANGED
@@ -1,17 +1,19 @@
1
- # Get tool actual version string
1
+ # Get actual versions of some tools
2
2
 
3
3
  ## CLI
4
4
 
5
5
  ```bash
6
6
  npm i @k03mad/actual-versions -g
7
7
  acver
8
- # ╔════════╤════════════════╗
9
- # ║ aria │ 1.37.0
10
- # ╟────────┼────────────────╢
11
- # ║ chrome │ 126.0.6478.182
12
- # ╟────────┼────────────────╢
13
- # ║ curl │ 8.8.0
14
- # ╚════════╧════════════════╝
8
+ # ╔════════╤═══════════════╗
9
+ # ║ aria │ 1.37.0
10
+ # ╟────────┼───────────────╢
11
+ # ║ chrome │ 127.0.6533.99
12
+ # ╟────────┼───────────────╢
13
+ # ║ curl │ 8.9.1
14
+ # ╟────────┼───────────────╢
15
+ # ║ nodejs │ 22.6.0 ║
16
+ # ╚════════╧═══════════════╝
15
17
  ```
16
18
 
17
19
  ## API
@@ -24,7 +26,8 @@ npm i @k03mad/actual-versions
24
26
  import {
25
27
  getAriaVersion
26
28
  getChromeVersion,
27
- getCurlVersion
29
+ getCurlVersion,
30
+ getNodeJsVersion,
28
31
  } from '@k03mad/actual-versions';
29
32
 
30
33
  const ariaVersion = await getAriaVersion();
@@ -35,4 +38,7 @@ const chromeVersion = await getChromeVersion();
35
38
 
36
39
  const curlVersion = await getCurlVersion();
37
40
  // '8.8.0'
41
+
42
+ const nodeJsVersion = await getNodeJsVersion();
43
+ // '22.6.0'
38
44
  ```
package/app/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import {log} from '@k03mad/simple-log';
3
+ import {log, logError} from '@k03mad/simple-log';
4
4
  import chalk from 'chalk';
5
5
  import {getBorderCharacters, table} from 'table';
6
6
 
@@ -14,17 +14,21 @@ const TOOL_NAME_RE = /get(.+)Version/;
14
14
 
15
15
  const output = await Promise.all(
16
16
  Object.entries(api).map(async ([key, value]) => {
17
- const version = await value();
18
- const tool = key.match(TOOL_NAME_RE)[1].toLowerCase();
19
-
20
- return [
21
- blue(bold(tool)),
22
- version ? green(version) : red('———'),
23
- ];
17
+ try {
18
+ const version = await value();
19
+ const tool = key.match(TOOL_NAME_RE)[1].toLowerCase();
20
+
21
+ return [
22
+ blue(bold(tool)),
23
+ version ? green(version) : red('———'),
24
+ ];
25
+ } catch (err) {
26
+ logError([key, err]);
27
+ }
24
28
  }),
25
29
  );
26
30
 
27
- const formattedTable = table(output, {
31
+ const formattedTable = table(output.filter(Boolean), {
28
32
  border: getBorderCharacters(config.table.border),
29
33
  });
30
34
 
@@ -1,29 +1,11 @@
1
1
  import {requestCache} from '@k03mad/request';
2
2
 
3
- const NODE_VERSIONS_URL = 'https://nodejs.org/dist/';
4
- const NODE_VERSION_RE = /"v([\d.]+)/g;
5
-
6
- const NODE_VERSION_DELIMITER = '.';
7
- const NODE_VERSION_DELIMITER_COUNT = 2;
3
+ const NODE_VERSIONS_URL = 'https://nodejs.org/dist/index.json';
8
4
 
9
5
  /**
10
6
  * @returns {Promise<string>}
11
7
  */
12
8
  export default async () => {
13
9
  const {body} = await requestCache(NODE_VERSIONS_URL);
14
-
15
- return [...body.matchAll(NODE_VERSION_RE)]
16
- .map(elem => elem[1])
17
- .sort((a, b) => {
18
- const first = a.split(NODE_VERSION_DELIMITER);
19
- const second = b.split(NODE_VERSION_DELIMITER);
20
-
21
- for (let i = 0; i <= NODE_VERSION_DELIMITER_COUNT; i++) {
22
- if (second[i] !== first[i]) {
23
- return Number(second[i]) - Number(first[i]);
24
- }
25
- }
26
-
27
- return 0;
28
- })[0];
10
+ return body[0].version.replace('v', '');
29
11
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@k03mad/actual-versions",
3
- "version": "1.3.0",
4
- "description": "Get tool actual version string",
3
+ "version": "1.4.0",
4
+ "description": "Get actual versions of some tools",
5
5
  "maintainers": [
6
6
  "Kirill Molchanov <k03.mad@gmail.com"
7
7
  ],
@@ -11,7 +11,7 @@
11
11
  "main": "app/api.js",
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "git+https://github.com/k03mad/ip2geo.git"
14
+ "url": "git+https://github.com/k03mad/actual-versions.git"
15
15
  },
16
16
  "license": "MIT",
17
17
  "type": "module",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@k03mad/request": "6.1.0",
23
- "@k03mad/simple-log": "2.3.0",
23
+ "@k03mad/simple-log": "3.0.0",
24
24
  "chalk": "5.3.0",
25
25
  "table": "6.8.2"
26
26
  },