@clerc/plugin-strict-flags 0.44.0 → 1.0.0-beta.2

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/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import * as _clerc_core from '@clerc/core';
1
+ import { Plugin } from "@clerc/core";
2
2
 
3
- declare const strictFlagsPlugin: () => _clerc_core.Plugin<_clerc_core.Clerc<{}, {}>, _clerc_core.Clerc<{}, {}>>;
4
-
5
- export { strictFlagsPlugin };
3
+ //#region src/index.d.ts
4
+ declare const strictFlagsPlugin: () => Plugin;
5
+ //#endregion
6
+ export { strictFlagsPlugin };
package/dist/index.js CHANGED
@@ -1,58 +1,14 @@
1
- import { definePlugin } from '@clerc/core';
2
-
3
- const locales$1 = {
4
- "en": {
5
- "utils.and": "%s and %s"
6
- },
7
- "zh-CN": {
8
- "utils.and": "%s \u548C %s"
9
- }
10
- };
11
- function semanticArray(arr, { add, t }) {
12
- add(locales$1);
13
- if (arr.length <= 1) {
14
- return arr[0];
15
- }
16
- return t("utils.and", arr.slice(0, -1).join(", "), arr[arr.length - 1]);
17
- }
18
-
19
- const locales = {
20
- "en": {
21
- "strictFlags.unexpectedSingle": "Unexpected flag: %s.",
22
- "strictFlags.unexpectedMore": "Unexpected flags: %s.",
23
- "strictFlags.and": "%s and %s"
24
- },
25
- "zh-CN": {
26
- "strictFlags.unexpectedSingle": "\u9884\u671F\u4E4B\u5916\u7684\u6807\u5FD7: %s\u3002",
27
- "strictFlags.unexpectedMore": "\u9884\u671F\u4E4B\u5916\u7684\u6807\u5FD7: %s\u3002",
28
- "strictFlags.and": "%s \u548C %s"
29
- }
30
- };
31
-
32
- const strictFlagsPlugin = () => definePlugin({
33
- setup: (cli) => {
34
- const { add, t } = cli.i18n;
35
- add(locales);
36
- return cli.interceptor((ctx, next) => {
37
- const keys = Object.keys(ctx.unknownFlags);
38
- if (!ctx.resolved || keys.length === 0) {
39
- next();
40
- } else {
41
- const error = keys.length > 1 ? new Error(
42
- t(
43
- "strictFlags.unexpectedMore",
44
- semanticArray(keys, cli.i18n)
45
- )
46
- ) : new Error(
47
- t(
48
- "strictFlags.unexpectedSingle",
49
- semanticArray(keys, cli.i18n)
50
- )
51
- );
52
- throw error;
53
- }
54
- });
55
- }
56
- });
57
-
58
- export { strictFlagsPlugin };
1
+ import { definePlugin } from "@clerc/core";
2
+ import { joinWithAnd } from "@clerc/utils";
3
+
4
+ //#region src/index.ts
5
+ const strictFlagsPlugin = () => definePlugin({ setup: (cli) => {
6
+ cli.interceptor(async (ctx, next) => {
7
+ const keys = Object.keys(ctx.rawParsed.unknown);
8
+ if (!ctx.resolved || keys.length === 0) await next();
9
+ else throw keys.length > 1 ? /* @__PURE__ */ new Error(`Unexpected flags: ${joinWithAnd(keys)}`) : /* @__PURE__ */ new Error(`Unexpected flag: ${keys[0]}`);
10
+ });
11
+ } });
12
+
13
+ //#endregion
14
+ export { strictFlagsPlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clerc/plugin-strict-flags",
3
- "version": "0.44.0",
3
+ "version": "1.0.0-beta.2",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve)",
5
5
  "type": "module",
6
6
  "description": "Clerc plugin strict flags",
@@ -25,13 +25,10 @@
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",
36
33
  "typesVersions": {
37
34
  "*": {
@@ -47,15 +44,17 @@
47
44
  "publishConfig": {
48
45
  "access": "public"
49
46
  },
47
+ "dependencies": {
48
+ "@clerc/utils": "1.0.0-beta.2"
49
+ },
50
50
  "devDependencies": {
51
- "@clerc/utils": "0.44.0",
52
- "@clerc/core": "0.44.0"
51
+ "@clerc/core": "1.0.0-beta.2"
53
52
  },
54
53
  "peerDependencies": {
55
54
  "@clerc/core": "*"
56
55
  },
57
56
  "scripts": {
58
- "build": "pkgroll",
59
- "watch": "pkgroll --watch"
57
+ "build": "tsdown",
58
+ "watch": "tsdown --watch"
60
59
  }
61
60
  }