@k03mad/actual-versions 3.0.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/app/api.js +1 -0
- package/app/tools/ubuntu.js +12 -0
- package/package.json +2 -2
- 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';
|
|
@@ -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.
|
|
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"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"scripts": {
|
|
33
33
|
"lint": "npm run lint:eslint",
|
|
34
34
|
"lint:eslint": "eslint ./ --cache",
|
|
35
|
-
"test": "node --test tests
|
|
35
|
+
"test": "node --test tests/*.js",
|
|
36
36
|
"clean": "rm -rf ./node_modules .eslintcache || true",
|
|
37
37
|
"setup": "npm run clean && npm run setup:pnpm",
|
|
38
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
|
});
|