@k03mad/actual-versions 1.0.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/.editorconfig +15 -0
- package/.github/dependabot.yml +10 -0
- package/.github/workflows/lint.yml +20 -0
- package/.github/workflows/publish.yml +34 -0
- package/.github/workflows/test.yml +20 -0
- package/.husky/pre-commit +1 -0
- package/.nvmrc +1 -0
- package/.vscode/settings.json +3 -0
- package/LICENSE +21 -0
- package/README.md +29 -0
- package/app/api.js +3 -0
- package/app/cli.js +19 -0
- package/app/tools/aria.js +12 -0
- package/app/tools/chrome.js +11 -0
- package/app/tools/curl.js +12 -0
- package/eslint.config.js +1 -0
- package/package.json +43 -0
- package/tests/api.js +25 -0
- package/tests/cli.js +41 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: Lint
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- master
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
lint:
|
|
13
|
+
runs-on: ubuntu-22.04
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-node@v4
|
|
17
|
+
with:
|
|
18
|
+
node-version-file: '.nvmrc'
|
|
19
|
+
- run: npm run setup
|
|
20
|
+
- run: npm run lint
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
environment: npm
|
|
11
|
+
runs-on: ubuntu-22.04
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
with:
|
|
15
|
+
fetch-depth: 0
|
|
16
|
+
|
|
17
|
+
- uses: tj-actions/changed-files@v44
|
|
18
|
+
id: changed-files
|
|
19
|
+
with:
|
|
20
|
+
files: package.json
|
|
21
|
+
|
|
22
|
+
- if: steps.changed-files.outputs.any_changed == 'true'
|
|
23
|
+
uses: actions/setup-node@v4
|
|
24
|
+
with:
|
|
25
|
+
node-version-file: '.nvmrc'
|
|
26
|
+
registry-url: 'https://registry.npmjs.org'
|
|
27
|
+
|
|
28
|
+
- if: steps.changed-files.outputs.any_changed == 'true'
|
|
29
|
+
run: npm run setup
|
|
30
|
+
|
|
31
|
+
- if: steps.changed-files.outputs.any_changed == 'true'
|
|
32
|
+
run: npm publish
|
|
33
|
+
env:
|
|
34
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- master
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
test:
|
|
13
|
+
runs-on: ubuntu-22.04
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-node@v4
|
|
17
|
+
with:
|
|
18
|
+
node-version-file: '.nvmrc'
|
|
19
|
+
- run: npm run setup
|
|
20
|
+
- run: npm run test
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
./node_modules/.bin/run-p -c lint test
|
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
20
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Kirill Molchanov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Get tool actual version string
|
|
2
|
+
|
|
3
|
+
## Global
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm i @k03mad/acver -g
|
|
7
|
+
acver
|
|
8
|
+
# ╔════════╤════════════════╗
|
|
9
|
+
# ║ chrome │ 126.0.6478.182 ║
|
|
10
|
+
# ╟────────┼────────────────╢
|
|
11
|
+
# ║ curl │ 8.8.0 ║
|
|
12
|
+
# ╚════════╧════════════════╝
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## API
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm i @k03mad/acver
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
import {getChromeVersion, getCurlVersion} from '@k03mad/acver';
|
|
23
|
+
|
|
24
|
+
const chrome = await getChromeVersion();
|
|
25
|
+
// '126.0.6478.182'
|
|
26
|
+
|
|
27
|
+
const curl = await getCurlVersion();
|
|
28
|
+
// '8.8.0'
|
|
29
|
+
```
|
package/app/api.js
ADDED
package/app/cli.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import {log} from '@k03mad/simple-log';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import {table} from 'table';
|
|
6
|
+
|
|
7
|
+
import * as api from './api.js';
|
|
8
|
+
|
|
9
|
+
const {blue, bold, green} = chalk;
|
|
10
|
+
|
|
11
|
+
const output = await Promise.all(
|
|
12
|
+
Object.entries(api).map(async ([key, value]) => {
|
|
13
|
+
const version = await value();
|
|
14
|
+
const tool = key.replaceAll(/Version|get/g, '').toLowerCase();
|
|
15
|
+
return [blue(bold(tool)), green(version)];
|
|
16
|
+
}),
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
log(table(output));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {requestCache} from '@k03mad/request';
|
|
2
|
+
|
|
3
|
+
const ARIA_VERSIONS_URL = 'https://aria2.github.io/';
|
|
4
|
+
const ARIA_VERSION_RE = /href=".+\/releases\/tag\/release-([\d.]+)"/;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @returns {Promise<string>}
|
|
8
|
+
*/
|
|
9
|
+
export default async () => {
|
|
10
|
+
const {body} = await requestCache(ARIA_VERSIONS_URL);
|
|
11
|
+
return body.match(ARIA_VERSION_RE)[1];
|
|
12
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {requestCache} from '@k03mad/request';
|
|
2
|
+
|
|
3
|
+
const CHROME_VERSIONS_URL = 'https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @returns {Promise<string>}
|
|
7
|
+
*/
|
|
8
|
+
export default async () => {
|
|
9
|
+
const {body} = await requestCache(CHROME_VERSIONS_URL);
|
|
10
|
+
return body.channels.Stable.version;
|
|
11
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {requestCache} from '@k03mad/request';
|
|
2
|
+
|
|
3
|
+
const CURL_VERSIONS_URL = 'https://curl.se/download.html';
|
|
4
|
+
const CURL_VERSION_RE = /href="\/download\/curl-([\d.]+).tar.gz"/;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @returns {Promise<string>}
|
|
8
|
+
*/
|
|
9
|
+
export default async () => {
|
|
10
|
+
const {body} = await requestCache(CURL_VERSIONS_URL);
|
|
11
|
+
return body.match(CURL_VERSION_RE)[1];
|
|
12
|
+
};
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default} from '@k03mad/eslint-config';
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@k03mad/actual-versions",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Get tool actual version string",
|
|
5
|
+
"maintainers": [
|
|
6
|
+
"Kirill Molchanov <k03.mad@gmail.com"
|
|
7
|
+
],
|
|
8
|
+
"bin": {
|
|
9
|
+
"acver": "app/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"main": "app/api.js",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/k03mad/ip2geo.git"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"type": "module",
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=20"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@k03mad/request": "5.8.1",
|
|
23
|
+
"@k03mad/simple-log": "2.2.1",
|
|
24
|
+
"chalk": "5.3.0",
|
|
25
|
+
"table": "6.8.2"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@k03mad/eslint-config": "22.5.0",
|
|
29
|
+
"eslint": "8.57.0",
|
|
30
|
+
"husky": "9.1.1",
|
|
31
|
+
"npm-run-all": "4.1.5",
|
|
32
|
+
"strip-ansi": "7.1.0"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"lint": "npm run lint:eslint",
|
|
36
|
+
"lint:eslint": "eslint ./ --cache",
|
|
37
|
+
"test": "node --test tests/**.js",
|
|
38
|
+
"clean": "rm -rf ./node_modules .eslintcache || true",
|
|
39
|
+
"setup": "npm run clean && npm run setup:pnpm",
|
|
40
|
+
"setup:pnpm": "npm i pnpm -g && pnpm i",
|
|
41
|
+
"prepare": "husky || true"
|
|
42
|
+
}
|
|
43
|
+
}
|
package/tests/api.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import {describe, it} from 'node:test';
|
|
3
|
+
|
|
4
|
+
import * as api from '../app/api.js';
|
|
5
|
+
|
|
6
|
+
const TESTS = {
|
|
7
|
+
getAriaVersion: /^\d\.\d+\.\d$/,
|
|
8
|
+
getChromeVersion: /^\d{3}(?:\.\d+){3}$/,
|
|
9
|
+
getCurlVersion: /^\d\.\d\.\d$/,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
describe('api', () => {
|
|
13
|
+
const steps = Object.entries(TESTS);
|
|
14
|
+
|
|
15
|
+
it('coverage', () => {
|
|
16
|
+
assert.equal(steps.length, Object.keys(api).length);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
Object.entries(TESTS).forEach(([key, value]) => {
|
|
20
|
+
it(key, async () => {
|
|
21
|
+
const version = await api[key]();
|
|
22
|
+
assert.match(version, value);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
});
|
package/tests/cli.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import cp from 'node:child_process';
|
|
3
|
+
import {before, describe, it} from 'node:test';
|
|
4
|
+
import {promisify} from 'node:util';
|
|
5
|
+
|
|
6
|
+
import stripAnsi from 'strip-ansi';
|
|
7
|
+
|
|
8
|
+
const cliFile = process.env.npm_package_bin_acver;
|
|
9
|
+
const exec = promisify(cp.exec);
|
|
10
|
+
|
|
11
|
+
const TESTS = [
|
|
12
|
+
/^aria\s+\d\.\d+\.\d$/,
|
|
13
|
+
/^chrome\s+\d{3}(?:\.\d+){3}$/,
|
|
14
|
+
/^curl\s+\d\.\d\.\d$/,
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
const TABLE_CHARS_RE = /[─│┼═║╔╗╚╝╟╢╤╧]+/g;
|
|
18
|
+
|
|
19
|
+
describe('cli', () => {
|
|
20
|
+
let versions;
|
|
21
|
+
|
|
22
|
+
before(async () => {
|
|
23
|
+
const {stdout} = await exec(cliFile);
|
|
24
|
+
|
|
25
|
+
versions = stdout
|
|
26
|
+
.split('\n')
|
|
27
|
+
.map(elem => stripAnsi(elem)
|
|
28
|
+
.replaceAll(TABLE_CHARS_RE, '')
|
|
29
|
+
.trim(),
|
|
30
|
+
)
|
|
31
|
+
.filter(Boolean);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('coverage', () => {
|
|
35
|
+
assert.equal(TESTS.length, versions.length);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
TESTS.forEach((re, i) => {
|
|
39
|
+
it(String(re), () => assert.match(versions[i], re));
|
|
40
|
+
});
|
|
41
|
+
});
|