@clerc/plugin-version 0.40.0 → 0.42.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.
Files changed (3) hide show
  1. package/README.md +25 -0
  2. package/dist/index.js +53 -1
  3. package/package.json +13 -14
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # @clerc/plugin-version
2
+
3
+ [![NPM version](https://img.shields.io/npm/v/@clerc/plugin-version?color=a1b858&label=)](https://www.npmjs.com/package/@clerc/plugin-version)
4
+
5
+ Clerc plugin to add version command to your cli.
6
+
7
+ ## 📦 Installation
8
+
9
+ ```bash
10
+ $ npm install @clerc/plugin-version
11
+ $ yarn add @clerc/plugin-version
12
+ $ pnpm add @clerc/plugin-version
13
+ ```
14
+
15
+ ## 🚀 Usage
16
+
17
+ ```ts
18
+ import { versionPlugin } from "@clerc/plugin-version";
19
+
20
+ cli.use(versionPlugin());
21
+ ```
22
+
23
+ ## 📝 License
24
+
25
+ [MIT](../../LICENSE). Made with ❤️ by [Ray](https://github.com/so1ve)
package/dist/index.js CHANGED
@@ -1 +1,53 @@
1
- import{definePlugin as v}from"@clerc/core";const p=s=>s.length===0?"":s.startsWith("v")?s:`v${s}`,a={en:{"version.description":"Show CLI version","version.notes.1":'The version string begins with a "v".'},"zh-CN":{"version.description":"\u5C55\u793A CLI \u7248\u672C","version.notes.1":'\u7248\u672C\u53F7\u5F00\u5934\u5E26\u6709 "v"\u3002'}},f=({command:s=!0,flag:r=!0}={})=>v({setup:e=>{const{add:t,t:n}=e.i18n;t(a);const o=p(e._version);return s&&(e=e.command("version",n("version.description"),{help:{notes:[n("version.notes.1")]}}).on("version",()=>{process.stdout.write(o)})),r&&(e=e.flag("version",n("version.description"),{alias:"V",type:Boolean,default:!1}),e.inspector({enforce:"pre",fn:(i,u)=>{i.flags.version?process.stdout.write(o):u()}})),e}});export{f as versionPlugin};
1
+ import { definePlugin } from '@clerc/core';
2
+ import { gracefulVersion } from '@clerc/utils';
3
+
4
+ const locales = {
5
+ "en": {
6
+ "version.description": "Show CLI version",
7
+ "version.notes.1": 'The version string begins with a "v".'
8
+ },
9
+ "zh-CN": {
10
+ "version.description": "\u5C55\u793A CLI \u7248\u672C",
11
+ "version.notes.1": '\u7248\u672C\u53F7\u5F00\u5934\u5E26\u6709 "v"\u3002'
12
+ }
13
+ };
14
+
15
+ const versionPlugin = ({
16
+ command = true,
17
+ flag = true
18
+ } = {}) => definePlugin({
19
+ setup: (cli) => {
20
+ const { add, t } = cli.i18n;
21
+ add(locales);
22
+ const gracefullyVersion = gracefulVersion(cli._version);
23
+ if (command) {
24
+ cli = cli.command("version", t("version.description"), {
25
+ help: {
26
+ notes: [t("version.notes.1")]
27
+ }
28
+ }).on("version", () => {
29
+ process.stdout.write(gracefullyVersion);
30
+ });
31
+ }
32
+ if (flag) {
33
+ cli = cli.flag("version", t("version.description"), {
34
+ alias: "V",
35
+ type: Boolean,
36
+ default: false
37
+ });
38
+ cli.inspector({
39
+ enforce: "pre",
40
+ fn: (context, next) => {
41
+ if (context.flags.version) {
42
+ process.stdout.write(gracefullyVersion);
43
+ } else {
44
+ next();
45
+ }
46
+ }
47
+ });
48
+ }
49
+ return cli;
50
+ }
51
+ });
52
+
53
+ export { versionPlugin };
package/package.json CHANGED
@@ -1,26 +1,26 @@
1
1
  {
2
2
  "name": "@clerc/plugin-version",
3
- "version": "0.40.0",
3
+ "version": "0.42.0",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve)",
5
+ "type": "module",
5
6
  "description": "Clerc plugin version",
6
7
  "keywords": [
7
- "cli",
8
- "clerc",
9
- "clerc-plugin",
8
+ "args",
10
9
  "arguments",
11
10
  "argv",
12
- "args",
11
+ "clerc",
12
+ "clerc-plugin",
13
+ "cli",
13
14
  "terminal"
14
15
  ],
15
- "type": "module",
16
- "homepage": "https://github.com/so1ve/clerc/tree/main/packages/plugin-version#readme",
16
+ "homepage": "https://github.com/clercjs/clerc/tree/main/packages/plugin-version#readme",
17
17
  "repository": {
18
18
  "type": "git",
19
- "url": "git+https://github.com/so1ve/clerc.git",
19
+ "url": "git+https://github.com/clercjs/clerc.git",
20
20
  "directory": "/"
21
21
  },
22
22
  "bugs": {
23
- "url": "https://github.com/so1ve/clerc/issues"
23
+ "url": "https://github.com/clercjs/clerc/issues"
24
24
  },
25
25
  "license": "MIT",
26
26
  "sideEffects": false,
@@ -39,15 +39,14 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
+ "dependencies": {
43
+ "@clerc/utils": "0.42.0"
44
+ },
42
45
  "peerDependencies": {
43
46
  "@clerc/core": "*"
44
47
  },
45
- "devDependencies": {
46
- "@clerc/core": "0.40.0",
47
- "@clerc/utils": "0.40.0"
48
- },
49
48
  "scripts": {
50
- "build": "pkgroll --minify",
49
+ "build": "pkgroll",
51
50
  "watch": "pkgroll --watch"
52
51
  }
53
52
  }