@k03mad/actual-versions 1.1.0 → 1.1.2
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/cli.js +8 -2
- package/config.js +9 -0
- package/package.json +3 -3
- package/tests/api.js +14 -13
- package/tests/cli.js +18 -10
package/app/cli.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import {log} from '@k03mad/simple-log';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
|
-
import {table} from 'table';
|
|
5
|
+
import {getBorderCharacters, table} from 'table';
|
|
6
|
+
|
|
7
|
+
import config from '../config.js';
|
|
6
8
|
|
|
7
9
|
import * as api from './api.js';
|
|
8
10
|
|
|
@@ -22,4 +24,8 @@ const output = await Promise.all(
|
|
|
22
24
|
}),
|
|
23
25
|
);
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
const formattedTable = table(output, {
|
|
28
|
+
border: getBorderCharacters(config.table.border),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
log(formattedTable);
|
package/config.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@k03mad/actual-versions",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Get tool actual version string",
|
|
5
5
|
"maintainers": [
|
|
6
6
|
"Kirill Molchanov <k03.mad@gmail.com"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"node": ">=20"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@k03mad/request": "
|
|
22
|
+
"@k03mad/request": "6.0.3",
|
|
23
23
|
"@k03mad/simple-log": "2.2.1",
|
|
24
24
|
"chalk": "5.3.0",
|
|
25
25
|
"table": "6.8.2"
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@k03mad/eslint-config": "22.5.0",
|
|
29
29
|
"eslint": "8.57.0",
|
|
30
|
-
"husky": "9.1.
|
|
30
|
+
"husky": "9.1.4",
|
|
31
31
|
"npm-run-all": "4.1.5",
|
|
32
32
|
"strip-ansi": "7.1.0"
|
|
33
33
|
},
|
package/tests/api.js
CHANGED
|
@@ -2,24 +2,25 @@ import assert from 'node:assert/strict';
|
|
|
2
2
|
import {describe, it} from 'node:test';
|
|
3
3
|
|
|
4
4
|
import * as api from '../app/api.js';
|
|
5
|
+
import config from '../config.js';
|
|
5
6
|
|
|
6
|
-
const
|
|
7
|
-
getAriaVersion
|
|
8
|
-
getChromeVersion
|
|
9
|
-
getCurlVersion
|
|
10
|
-
|
|
7
|
+
const API_FUNCTIONS = [
|
|
8
|
+
'getAriaVersion',
|
|
9
|
+
'getChromeVersion',
|
|
10
|
+
'getCurlVersion',
|
|
11
|
+
];
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
const steps = Object.entries(TESTS);
|
|
13
|
+
const versionRe = new RegExp(`^${config.version.re}`);
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
describe('api', () => {
|
|
16
|
+
it('check tests count', () => {
|
|
17
|
+
assert.equal(API_FUNCTIONS.length, Object.keys(api).length);
|
|
17
18
|
});
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
it(
|
|
21
|
-
const version = await api[
|
|
22
|
-
assert.match(version,
|
|
20
|
+
API_FUNCTIONS.forEach(fn => {
|
|
21
|
+
it(`check fn output: ${fn}()`, async () => {
|
|
22
|
+
const version = await api[fn]();
|
|
23
|
+
assert.match(version, versionRe);
|
|
23
24
|
});
|
|
24
25
|
});
|
|
25
26
|
});
|
package/tests/cli.js
CHANGED
|
@@ -4,17 +4,23 @@ import {before, describe, it} from 'node:test';
|
|
|
4
4
|
import {promisify} from 'node:util';
|
|
5
5
|
|
|
6
6
|
import stripAnsi from 'strip-ansi';
|
|
7
|
+
import {getBorderCharacters} from 'table';
|
|
8
|
+
|
|
9
|
+
import config from '../config.js';
|
|
7
10
|
|
|
8
11
|
const cliFile = process.env.npm_package_bin_acver;
|
|
9
12
|
const exec = promisify(cp.exec);
|
|
10
13
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
const tableBorderChars = Object.values(getBorderCharacters(config.table.border));
|
|
15
|
+
const tableBorderCharsRe = new RegExp(tableBorderChars.join('|'), 'g');
|
|
16
|
+
|
|
17
|
+
const STDOUT_TOOLS = [
|
|
18
|
+
'aria',
|
|
19
|
+
'chrome',
|
|
20
|
+
'curl',
|
|
15
21
|
];
|
|
16
22
|
|
|
17
|
-
const
|
|
23
|
+
const versionRe = tool => new RegExp(`^${tool}\\s+${config.version.re}`);
|
|
18
24
|
|
|
19
25
|
describe('cli', () => {
|
|
20
26
|
let versions;
|
|
@@ -25,17 +31,19 @@ describe('cli', () => {
|
|
|
25
31
|
versions = stdout
|
|
26
32
|
.split('\n')
|
|
27
33
|
.map(elem => stripAnsi(elem)
|
|
28
|
-
.replaceAll(
|
|
34
|
+
.replaceAll(tableBorderCharsRe, '')
|
|
29
35
|
.trim(),
|
|
30
36
|
)
|
|
31
37
|
.filter(Boolean);
|
|
32
38
|
});
|
|
33
39
|
|
|
34
|
-
it('
|
|
35
|
-
assert.equal(
|
|
40
|
+
it('check tests count', () => {
|
|
41
|
+
assert.equal(STDOUT_TOOLS.length, versions.length);
|
|
36
42
|
});
|
|
37
43
|
|
|
38
|
-
|
|
39
|
-
it(
|
|
44
|
+
STDOUT_TOOLS.forEach((tool, i) => {
|
|
45
|
+
it(`check stdout output: #${i + 1} tool: ${tool}`, () => {
|
|
46
|
+
assert.match(versions[i], versionRe(tool));
|
|
47
|
+
});
|
|
40
48
|
});
|
|
41
49
|
});
|