@k03mad/actual-versions 2.6.0 → 3.1.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/.github/workflows/lint.yml +1 -1
- package/.github/workflows/publish.yml +1 -1
- package/.github/workflows/test.yml +1 -1
- package/.vscode/settings.json +5 -0
- package/app/api.js +1 -0
- package/app/cli.js +2 -3
- package/app/tools/aria.js +4 -4
- package/app/tools/chrome.js +4 -4
- package/app/tools/curl.js +4 -4
- package/app/tools/nodejs.js +4 -4
- package/app/tools/ubuntu.js +12 -0
- package/package.json +4 -6
- package/tests/api.js +3 -14
- package/tests/cli.js +8 -10
package/app/api.js
CHANGED
|
@@ -2,3 +2,4 @@ export {default as getAriaVersion} from './tools/aria.js';
|
|
|
2
2
|
export {default as getChromeVersion} from './tools/chrome.js';
|
|
3
3
|
export {default as getCurlVersion} from './tools/curl.js';
|
|
4
4
|
export {default as getNodeJsVersion} from './tools/nodejs.js';
|
|
5
|
+
export {default as getUbuntuVersion} from './tools/ubuntu.js';
|
package/app/cli.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {log, logError} from '@k03mad/simple-log';
|
|
4
3
|
import chalk from 'chalk';
|
|
5
4
|
import {getBorderCharacters, table} from 'table';
|
|
6
5
|
|
|
@@ -23,7 +22,7 @@ const output = await Promise.all(
|
|
|
23
22
|
version ? green(version) : red('———'),
|
|
24
23
|
];
|
|
25
24
|
} catch (err) {
|
|
26
|
-
|
|
25
|
+
console.log(`[${key}] ${err}`);
|
|
27
26
|
}
|
|
28
27
|
}),
|
|
29
28
|
);
|
|
@@ -32,4 +31,4 @@ const formattedTable = table(output.filter(Boolean), {
|
|
|
32
31
|
border: getBorderCharacters(config.table.border),
|
|
33
32
|
});
|
|
34
33
|
|
|
35
|
-
log(formattedTable);
|
|
34
|
+
console.log(formattedTable);
|
package/app/tools/aria.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {requestCache} from '@k03mad/request';
|
|
2
|
-
|
|
3
1
|
const ARIA_VERSIONS_URL = 'https://aria2.github.io/';
|
|
4
2
|
const ARIA_VERSION_RE = /href=".+\/releases\/tag\/release-([\d.]+)"/;
|
|
5
3
|
|
|
@@ -7,6 +5,8 @@ const ARIA_VERSION_RE = /href=".+\/releases\/tag\/release-([\d.]+)"/;
|
|
|
7
5
|
* @returns {Promise<string>}
|
|
8
6
|
*/
|
|
9
7
|
export default async () => {
|
|
10
|
-
const
|
|
11
|
-
|
|
8
|
+
const response = await fetch(ARIA_VERSIONS_URL);
|
|
9
|
+
const text = await response.text();
|
|
10
|
+
|
|
11
|
+
return text.match(ARIA_VERSION_RE)?.[1];
|
|
12
12
|
};
|
package/app/tools/chrome.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {requestCache} from '@k03mad/request';
|
|
2
|
-
|
|
3
1
|
const CHROME_VERSIONS_URL = 'https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json';
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
4
|
* @returns {Promise<string>}
|
|
7
5
|
*/
|
|
8
6
|
export default async () => {
|
|
9
|
-
const
|
|
10
|
-
|
|
7
|
+
const response = await fetch(CHROME_VERSIONS_URL);
|
|
8
|
+
const json = await response.json();
|
|
9
|
+
|
|
10
|
+
return json?.channels?.Stable?.version;
|
|
11
11
|
};
|
package/app/tools/curl.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {requestCache} from '@k03mad/request';
|
|
2
|
-
|
|
3
1
|
const CURL_VERSIONS_URL = 'https://curl.se/download.html';
|
|
4
2
|
const CURL_VERSION_RE = /href="\/download\/curl-([\d.]+).tar.gz"/;
|
|
5
3
|
|
|
@@ -7,6 +5,8 @@ const CURL_VERSION_RE = /href="\/download\/curl-([\d.]+).tar.gz"/;
|
|
|
7
5
|
* @returns {Promise<string>}
|
|
8
6
|
*/
|
|
9
7
|
export default async () => {
|
|
10
|
-
const
|
|
11
|
-
|
|
8
|
+
const response = await fetch(CURL_VERSIONS_URL);
|
|
9
|
+
const text = await response.text();
|
|
10
|
+
|
|
11
|
+
return text.match(CURL_VERSION_RE)?.[1];
|
|
12
12
|
};
|
package/app/tools/nodejs.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {requestCache} from '@k03mad/request';
|
|
2
|
-
|
|
3
1
|
const NODE_VERSIONS_URL = 'https://nodejs.org/dist/index.json';
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
4
|
* @returns {Promise<string>}
|
|
7
5
|
*/
|
|
8
6
|
export default async () => {
|
|
9
|
-
const
|
|
10
|
-
|
|
7
|
+
const response = await fetch(NODE_VERSIONS_URL);
|
|
8
|
+
const json = await response.json();
|
|
9
|
+
|
|
10
|
+
return json[0].version.replace('v', '');
|
|
11
11
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const UBUNTU_VERSIONS_URL = 'https://launchpad.net/ubuntu/+series';
|
|
2
|
+
const UBUNTU_VERSION_RE = / \((\d+\.\d+)\).+\n.+Current Stable Release/;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @returns {Promise<string>}
|
|
6
|
+
*/
|
|
7
|
+
export default async () => {
|
|
8
|
+
const response = await fetch(UBUNTU_VERSIONS_URL);
|
|
9
|
+
const text = await response.text();
|
|
10
|
+
|
|
11
|
+
return text.match(UBUNTU_VERSION_RE)?.[1];
|
|
12
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@k03mad/actual-versions",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Get actual versions of some tools",
|
|
5
5
|
"maintainers": [
|
|
6
6
|
"Kirill Molchanov <k03.mad@gmail.com"
|
|
@@ -19,14 +19,12 @@
|
|
|
19
19
|
"node": ">=22"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@k03mad/request": "7.9.0",
|
|
23
|
-
"@k03mad/simple-log": "5.3.0",
|
|
24
22
|
"chalk": "5.4.1",
|
|
25
23
|
"table": "6.9.0"
|
|
26
24
|
},
|
|
27
25
|
"devDependencies": {
|
|
28
|
-
"@k03mad/eslint-config": "28.
|
|
29
|
-
"eslint": "9.
|
|
26
|
+
"@k03mad/eslint-config": "28.9.0",
|
|
27
|
+
"eslint": "9.24.0",
|
|
30
28
|
"husky": "9.1.7",
|
|
31
29
|
"npm-run-all": "4.1.5",
|
|
32
30
|
"strip-ansi": "7.1.0"
|
|
@@ -34,7 +32,7 @@
|
|
|
34
32
|
"scripts": {
|
|
35
33
|
"lint": "npm run lint:eslint",
|
|
36
34
|
"lint:eslint": "eslint ./ --cache",
|
|
37
|
-
"test": "node --test tests
|
|
35
|
+
"test": "node --test tests/*.js",
|
|
38
36
|
"clean": "rm -rf ./node_modules .eslintcache || true",
|
|
39
37
|
"setup": "npm run clean && npm run setup:pnpm",
|
|
40
38
|
"setup:pnpm": "npm i pnpm -g && pnpm i",
|
package/tests/api.js
CHANGED
|
@@ -4,23 +4,12 @@ import {describe, it} from 'node:test';
|
|
|
4
4
|
import * as api from '../app/api.js';
|
|
5
5
|
import config from '../config.js';
|
|
6
6
|
|
|
7
|
-
const API_FUNCTIONS = [
|
|
8
|
-
'getAriaVersion',
|
|
9
|
-
'getChromeVersion',
|
|
10
|
-
'getCurlVersion',
|
|
11
|
-
'getNodeJsVersion',
|
|
12
|
-
];
|
|
13
|
-
|
|
14
7
|
const versionRe = new RegExp(`^${config.version.re}`);
|
|
15
8
|
|
|
16
9
|
describe('api', () => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
API_FUNCTIONS.forEach(fn => {
|
|
22
|
-
it(`check fn output: ${fn}()`, async () => {
|
|
23
|
-
const version = await api[fn]();
|
|
10
|
+
Object.entries(api).forEach(([name, fn]) => {
|
|
11
|
+
it(`check fn output: ${name}()`, async () => {
|
|
12
|
+
const version = await fn();
|
|
24
13
|
assert.match(version, versionRe);
|
|
25
14
|
});
|
|
26
15
|
});
|
package/tests/cli.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import assert from 'node:assert/strict';
|
|
2
2
|
import cp from 'node:child_process';
|
|
3
|
+
import fs from 'node:fs/promises';
|
|
4
|
+
import path from 'node:path';
|
|
3
5
|
import {before, describe, it} from 'node:test';
|
|
4
6
|
import {promisify} from 'node:util';
|
|
5
7
|
|
|
@@ -14,15 +16,11 @@ const exec = promisify(cp.exec);
|
|
|
14
16
|
const tableBorderChars = Object.values(getBorderCharacters(config.table.border));
|
|
15
17
|
const tableBorderCharsRe = new RegExp(tableBorderChars.join('|'), 'g');
|
|
16
18
|
|
|
17
|
-
const STDOUT_TOOLS = [
|
|
18
|
-
'aria',
|
|
19
|
-
'chrome',
|
|
20
|
-
'curl',
|
|
21
|
-
'nodejs',
|
|
22
|
-
];
|
|
23
|
-
|
|
24
19
|
const versionRe = tool => new RegExp(`^${tool}\\s+${config.version.re}`);
|
|
25
20
|
|
|
21
|
+
const dir = await fs.readdir('./app/tools');
|
|
22
|
+
const tools = dir.map(elem => path.basename(elem, '.js'));
|
|
23
|
+
|
|
26
24
|
describe('cli', () => {
|
|
27
25
|
let versions;
|
|
28
26
|
|
|
@@ -38,11 +36,11 @@ describe('cli', () => {
|
|
|
38
36
|
.filter(Boolean);
|
|
39
37
|
});
|
|
40
38
|
|
|
41
|
-
it('check
|
|
42
|
-
assert.equal(
|
|
39
|
+
it('check tools count', () => {
|
|
40
|
+
assert.equal(tools.length, versions.length);
|
|
43
41
|
});
|
|
44
42
|
|
|
45
|
-
|
|
43
|
+
tools.forEach((tool, i) => {
|
|
46
44
|
it(`check stdout output: #${i + 1} tool: ${tool}`, () => {
|
|
47
45
|
assert.match(versions[i], versionRe(tool));
|
|
48
46
|
});
|