@clerc/plugin-version 0.43.0 → 1.0.0-beta.1

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/dist/index.d.ts +20 -16
  2. package/dist/index.js +22 -51
  3. package/package.json +18 -10
package/dist/index.d.ts CHANGED
@@ -1,19 +1,23 @@
1
- import * as _clerc_core from '@clerc/core';
1
+ import { Plugin } from "@clerc/core";
2
2
 
3
+ //#region src/index.d.ts
3
4
  interface VersionPluginOptions {
4
- /**
5
- * Whether to register the version command.
6
- *
7
- * @default true
8
- */
9
- command?: boolean;
10
- /**
11
- * Whether to register the global version flag.
12
- *
13
- * @default true
14
- */
15
- flag?: boolean;
5
+ /**
6
+ * Whether to register the version command.
7
+ *
8
+ * @default true
9
+ */
10
+ command?: boolean;
11
+ /**
12
+ * Whether to register the global version flag.
13
+ *
14
+ * @default true
15
+ */
16
+ flag?: boolean;
16
17
  }
17
- declare const versionPlugin: ({ command, flag, }?: VersionPluginOptions) => _clerc_core.Plugin<_clerc_core.Clerc<{}, {}>, _clerc_core.Clerc<{}, {}>>;
18
-
19
- export { versionPlugin };
18
+ declare const versionPlugin: ({
19
+ command,
20
+ flag
21
+ }?: VersionPluginOptions) => Plugin;
22
+ //#endregion
23
+ export { versionPlugin };
package/dist/index.js CHANGED
@@ -1,53 +1,24 @@
1
- import { definePlugin } from '@clerc/core';
2
- import { gracefulVersion } from '@clerc/utils';
1
+ import { definePlugin } from "@clerc/core";
2
+ import { formatVersion } from "@clerc/utils";
3
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
- };
4
+ //#region src/index.ts
5
+ const versionPlugin = ({ command = true, flag = true } = {}) => definePlugin({ setup: (cli) => {
6
+ const formattedVersion = formatVersion(cli._version);
7
+ if (command) cli.command("version", "Prints current version", {}).on("version", () => {
8
+ console.log(formattedVersion);
9
+ });
10
+ if (flag) cli.globalFlag("version", "Prints current version", {
11
+ alias: "V",
12
+ type: Boolean,
13
+ default: false
14
+ }).interceptor({
15
+ enforce: "pre",
16
+ handler: async (ctx, next) => {
17
+ if (ctx.flags.version) console.log(formattedVersion);
18
+ else await next();
19
+ }
20
+ });
21
+ } });
14
22
 
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.interceptor({
39
- enforce: "pre",
40
- fn: (ctx, next) => {
41
- if (ctx.flags.version) {
42
- process.stdout.write(gracefullyVersion);
43
- } else {
44
- next();
45
- }
46
- }
47
- });
48
- }
49
- return cli;
50
- }
51
- });
52
-
53
- export { versionPlugin };
23
+ //#endregion
24
+ export { versionPlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clerc/plugin-version",
3
- "version": "0.43.0",
3
+ "version": "1.0.0-beta.1",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve)",
5
5
  "type": "module",
6
6
  "description": "Clerc plugin version",
@@ -25,14 +25,19 @@
25
25
  "license": "MIT",
26
26
  "sideEffects": false,
27
27
  "exports": {
28
- ".": {
29
- "types": "./dist/index.d.ts",
30
- "import": "./dist/index.js"
31
- }
28
+ ".": "./dist/index.js"
32
29
  },
33
- "main": "dist/index.js",
34
- "module": "dist/index.js",
30
+ "main": "./dist/index.js",
31
+ "module": "./dist/index.js",
35
32
  "types": "dist/index.d.ts",
33
+ "typesVersions": {
34
+ "*": {
35
+ "*": [
36
+ "./dist/*",
37
+ "./dist/index.d.ts"
38
+ ]
39
+ }
40
+ },
36
41
  "files": [
37
42
  "dist"
38
43
  ],
@@ -40,13 +45,16 @@
40
45
  "access": "public"
41
46
  },
42
47
  "dependencies": {
43
- "@clerc/utils": "0.43.0"
48
+ "@clerc/utils": "1.0.0-beta.1"
49
+ },
50
+ "devDependencies": {
51
+ "@clerc/core": "1.0.0-beta.1"
44
52
  },
45
53
  "peerDependencies": {
46
54
  "@clerc/core": "*"
47
55
  },
48
56
  "scripts": {
49
- "build": "pkgroll",
50
- "watch": "pkgroll --watch"
57
+ "build": "tsdown",
58
+ "watch": "tsdown --watch"
51
59
  }
52
60
  }