@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.
@@ -10,7 +10,7 @@ on:
10
10
 
11
11
  jobs:
12
12
  lint:
13
- runs-on: ubuntu-22.04
13
+ runs-on: ubuntu-latest
14
14
  steps:
15
15
  - uses: actions/checkout@v4
16
16
  - uses: actions/setup-node@v4
@@ -8,7 +8,7 @@ on:
8
8
  jobs:
9
9
  publish:
10
10
  environment: npm
11
- runs-on: ubuntu-22.04
11
+ runs-on: ubuntu-latest
12
12
  steps:
13
13
  - uses: actions/checkout@v4
14
14
  with:
@@ -10,7 +10,7 @@ on:
10
10
 
11
11
  jobs:
12
12
  test:
13
- runs-on: ubuntu-22.04
13
+ runs-on: ubuntu-latest
14
14
  steps:
15
15
  - uses: actions/checkout@v4
16
16
  - uses: actions/setup-node@v4
@@ -0,0 +1,5 @@
1
+ {
2
+ "cSpell.words": [
3
+ "acver"
4
+ ]
5
+ }
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
- logError([key, err]);
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 {body} = await requestCache(ARIA_VERSIONS_URL);
11
- return body.match(ARIA_VERSION_RE)?.[1];
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
  };
@@ -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 {body} = await requestCache(CHROME_VERSIONS_URL);
10
- return body?.channels?.Stable?.version;
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 {body} = await requestCache(CURL_VERSIONS_URL);
11
- return body.match(CURL_VERSION_RE)?.[1];
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
  };
@@ -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 {body} = await requestCache(NODE_VERSIONS_URL);
10
- return body[0].version.replace('v', '');
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": "2.6.0",
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.8.0",
29
- "eslint": "9.23.0",
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/**.js",
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
- it('check tests count', () => {
18
- assert.equal(API_FUNCTIONS.length, Object.keys(api).length);
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 tests count', () => {
42
- assert.equal(STDOUT_TOOLS.length, versions.length);
39
+ it('check tools count', () => {
40
+ assert.equal(tools.length, versions.length);
43
41
  });
44
42
 
45
- STDOUT_TOOLS.forEach((tool, i) => {
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
  });