version-io 4.0.1 → 6.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/ChangeLog CHANGED
@@ -1,3 +1,23 @@
1
+ 2026.02.02, v6.0.0
2
+
3
+ feature:
4
+ - 97aea7c version-io: add -e
5
+ - dd68ea2 version-io: drop support of node < 22
6
+ - 0a6d90b version-io: try-to-catch v4.0.5
7
+ - a8c2a33 version-io: putout v41.16.0
8
+ - 566b17c version-io: madrun v12.1.3
9
+ - b9bb256 version-io: eslint-plugin-putout v30.0.2
10
+
11
+ 2025.03.30, v5.0.0
12
+
13
+ feature:
14
+ - 1624b5d version-io: migrate to ESM
15
+ - a11fae2 version-io: putout v39.5.0
16
+ - 626950e version-io: pkg-up v5.0.0
17
+ - 7aff931 version-io: madrun v11.0.0
18
+ - cacb058 version-io: eslint-plugin-putout v26.1.0
19
+ - 74a5de6 version-io: eslint v9.23.0
20
+
1
21
  2020.04.28, v4.0.1
2
22
 
3
23
  fix:
package/README.md CHANGED
@@ -1,12 +1,11 @@
1
1
  # Version-io
2
2
 
3
- Semantic versioning tool. Apply major, minor, patch and version to `package.json`.
3
+ Semantic versioning tool. Apply `major`, `minor`, `patch` and version to `package.json`.
4
4
 
5
5
  ## Install
6
6
 
7
7
  `npm i version-io -g`
8
8
 
9
-
10
9
  ## How to use?
11
10
 
12
11
  Show current version:
@@ -15,6 +14,7 @@ Show current version:
15
14
  # version
16
15
  v1.0.0
17
16
  ```
17
+
18
18
  Set new version:
19
19
 
20
20
  ```
@@ -30,25 +30,39 @@ Apply minor, major or patch:
30
30
  v1.1.0
31
31
  ```
32
32
 
33
+ Extended view:
34
+
35
+ ```
36
+ # version -e
37
+
38
+ 1 | {
39
+ 2 | "version": "5.0.0",
40
+ 3 | "engines": {
41
+ 4 | "node": ">=22"
42
+ 5 | }
43
+ 6 | }
44
+ ```
45
+
33
46
  ## Use as module
34
47
 
35
48
  Install `version-io` with:
36
49
 
37
50
  ```
38
- npm i version-io --save
51
+ npm i version-io -g
39
52
  ```
40
53
 
41
- Format: `version(number, callback);`
42
- - `number` could be new version number or `minor|major|patch`
54
+ ## API
55
+
56
+ ### `updateVersion(number: VersionNumber)`
57
+
58
+ - `VersionNumber` could be new version number or `minor|major|patch`
43
59
 
44
- You could update version in `package.json` with:
45
60
  ```js
46
- import version from 'version-io';
61
+ import {updateVersion} from 'version-io';
47
62
 
48
- const version = await version();
63
+ await updateVersion('patch');
49
64
  ```
50
65
 
51
66
  ## License
52
67
 
53
68
  MIT
54
-
package/bin/version.js CHANGED
@@ -1,46 +1,59 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- 'use strict';
4
-
5
- const readjson = require('readjson');
6
- const tryToCatch = require('try-to-catch');
7
-
8
- const version = require('..');
9
- const args = process.argv.slice(2);
10
- const arg = args[0];
11
- const pkgUp = require('pkg-up');
12
-
13
- main()
14
-
15
- async function main() {
16
- if (/^(-v|--version)$/.test(arg))
17
- return console.log('v' + require('../package').version);
18
-
19
- if (arg) {
20
- const [e, data] = await tryToCatch(version, arg);
21
-
22
- if (e)
23
- return console.error(e.message);
24
-
25
- if (data)
26
- console.log(data);
27
-
28
- return;
29
- }
3
+ import process from 'node:process';
4
+ import readjson from 'readjson';
5
+ import {tryToCatch} from 'try-to-catch';
6
+ import {packageUp} from 'package-up';
7
+ import {updateVersion} from '../lib/version.js';
8
+
9
+ const {stringify} = JSON;
10
+
11
+ const [arg] = process.argv.slice(2);
12
+
13
+ const isExtended = arg && arg === '-e';
14
+
15
+ if (/^(-v|--version)$/.test(arg))
16
+ process.exit();
17
+
18
+ if (arg && !isExtended) {
19
+ const [e, data] = await tryToCatch(updateVersion, arg);
30
20
 
31
- const name = await pkgUp();
21
+ if (e)
22
+ process.exit();
32
23
 
33
- if (!name)
34
- return console.error('package.json: not found');
24
+ if (data)
25
+ console.log(data);
35
26
 
36
- const [error, info] = await tryToCatch(readjson, name);
27
+ process.exit();
28
+ }
29
+
30
+ const name = await packageUp();
31
+
32
+ if (!name)
33
+ process.exit();
34
+
35
+ const [error, info] = await tryToCatch(readjson, name);
36
+
37
+ if (!error) {
38
+ if (!isExtended) {
39
+ console.log(info.version || '<no version>');
40
+ process.exit();
41
+ }
37
42
 
38
- if (!error)
39
- return console.log(info.version || 'no version');
43
+ const {codeFrameColumns} = await import('@putout/babel');
44
+ const result = stringify({
45
+ version: info.version,
46
+ engines: info.engines,
47
+ }, null, 4);
40
48
 
41
- if (error.code === 'ENOENT')
42
- return console.error('package.json: not found');
49
+ console.log(codeFrameColumns(result, {}, {
50
+ highlightCode: true,
51
+ }));
43
52
 
44
- return console.error('package.json:', error.message);
53
+ process.exit();
45
54
  }
46
55
 
56
+ if (error.code === 'ENOENT')
57
+ process.exit(1);
58
+
59
+ console.error('package.json:', error.message);
package/lib/version.js CHANGED
@@ -1,30 +1,32 @@
1
- 'use strict';
1
+ import assert from 'node:assert';
2
+ import _readjson from 'readjson';
3
+ import _writejson from 'writejson';
4
+ import minor from 'minor';
5
+ import {packageUp as _packageUp} from 'package-up';
2
6
 
3
- const assert = require('assert');
4
- const readjson = require('readjson');
5
- const writejson = require('writejson');
6
- const minor = require('minor');
7
- const pkgUp = require('pkg-up');
8
-
9
- module.exports = async (version) => {
7
+ export const updateVersion = async (version, overrides) => {
10
8
  assert(version, 'version could not be empty!');
11
9
 
12
- const name = await pkgUp();
13
- const json = await readjson(name);
10
+ const {
11
+ packageUp = _packageUp,
12
+ readjson = _readjson,
13
+ writejson = _writejson,
14
+ } = overrides;
14
15
 
15
- if (!version)
16
- return `v${json.version}`;
16
+ const name = await packageUp();
17
+ const json = await readjson(name);
17
18
 
18
- await update(name, version, json);
19
+ await update(name, version, json, {
20
+ writejson,
21
+ });
19
22
  };
20
23
 
21
- async function update(name, version, info) {
24
+ async function update(name, version, info, {writejson}) {
22
25
  const mmpRegExp = /major|minor|patch/;
23
26
  const vRegExp = /^v/;
24
27
 
25
28
  if (mmpRegExp.test(version))
26
29
  version = minor(version, info.version);
27
-
28
30
  else if (vRegExp.test(version))
29
31
  version = version.slice(1);
30
32
 
@@ -34,4 +36,3 @@ async function update(name, version, info) {
34
36
  space: 2,
35
37
  });
36
38
  }
37
-
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "version-io",
3
- "version": "4.0.1",
3
+ "version": "6.0.0",
4
+ "type": "module",
4
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
5
6
  "description": "Semantic versioning tool. Apply major, minor, patch and version to package.json.",
6
7
  "homepage": "http://github.com/coderaiser/version-io",
@@ -10,28 +11,33 @@
10
11
  },
11
12
  "repository": {
12
13
  "type": "git",
13
- "url": "git://github.com/coderaiser/version-io.git"
14
+ "url": "git+https://github.com/coderaiser/version-io.git"
14
15
  },
15
16
  "dependencies": {
17
+ "@putout/babel": "^5.2.11",
16
18
  "minor": "^1.2.0",
17
- "pkg-up": "^3.1.0",
19
+ "package-up": "^5.0.0",
18
20
  "readjson": "^2.0.1",
19
- "try-to-catch": "^3.0.0",
21
+ "try-to-catch": "^4.0.5",
20
22
  "writejson": "^3.0.0"
21
23
  },
22
24
  "engines": {
23
- "node": ">=8"
25
+ "node": ">=22"
24
26
  },
25
27
  "license": "MIT",
26
28
  "devDependencies": {
27
- "eslint": "^6.8.0",
28
- "eslint-plugin-node": "^11.1.0",
29
- "eslint-plugin-putout": "^3.7.1",
30
- "madrun": "^5.5.0",
31
- "putout": "^7.23.0"
29
+ "c8": "^10.1.3",
30
+ "eslint": "^9.23.0",
31
+ "eslint-plugin-putout": "^30.0.2",
32
+ "madrun": "^12.1.3",
33
+ "putout": "^41.16.0",
34
+ "supertape": "^12.2.0"
32
35
  },
33
36
  "scripts": {
37
+ "test": "madrun test",
34
38
  "lint": "madrun lint",
35
- "fix:lint": "madrun fix:lint"
39
+ "fix:lint": "madrun fix:lint",
40
+ "coverage": "madrun coverage",
41
+ "report": "madrun report"
36
42
  }
37
43
  }