@clerc/plugin-strict-flags 0.10.4 → 0.11.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/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ import { definePlugin } from '@clerc/core';
2
+ import { semanticArray } from '@clerc/utils';
3
+
4
+ const strictFlagsPlugin = () => definePlugin({
5
+ setup: (cli) => {
6
+ return cli.inspector((ctx, next) => {
7
+ const keys = Object.keys(ctx.unknownFlags);
8
+ if (!ctx.resolved || keys.length === 0) {
9
+ next();
10
+ } else {
11
+ throw new Error(`Unexpected flags: ${semanticArray(keys)}`);
12
+ }
13
+ });
14
+ }
15
+ });
16
+
17
+ export { strictFlagsPlugin };
package/dist/index.mjs CHANGED
@@ -1,13 +1,15 @@
1
1
  import { definePlugin } from '@clerc/core';
2
+ import { semanticArray } from '@clerc/utils';
2
3
 
3
4
  const strictFlagsPlugin = () => definePlugin({
4
- setup(cli) {
5
+ setup: (cli) => {
5
6
  return cli.inspector((ctx, next) => {
6
7
  const keys = Object.keys(ctx.unknownFlags);
7
- if (keys.length > 0) {
8
- throw new Error(`Unexpected flags: ${keys.join(", ")}`);
8
+ if (!ctx.resolved || keys.length === 0) {
9
+ next();
10
+ } else {
11
+ throw new Error(`Unexpected flags: ${semanticArray(keys)}`);
9
12
  }
10
- next();
11
13
  });
12
14
  }
13
15
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clerc/plugin-strict-flags",
3
- "version": "0.10.4",
3
+ "version": "0.11.0",
4
4
  "author": "Ray <nn_201312@163.com> (https://github.com/so1ve)",
5
5
  "description": "Clerc plugin strict flags",
6
6
  "keywords": [
@@ -12,6 +12,7 @@
12
12
  "args",
13
13
  "terminal"
14
14
  ],
15
+ "type": "module",
15
16
  "homepage": "https://github.com/so1ve/clerc/tree/main/packages/plugin-strict-flags#readme",
16
17
  "repository": {
17
18
  "type": "git",
@@ -26,11 +27,10 @@
26
27
  "exports": {
27
28
  ".": {
28
29
  "types": "./dist/index.d.ts",
29
- "require": "./dist/index.cjs",
30
30
  "import": "./dist/index.mjs"
31
31
  }
32
32
  },
33
- "main": "dist/index.cjs",
33
+ "main": "dist/index.js",
34
34
  "module": "dist/index.mjs",
35
35
  "types": "dist/index.d.ts",
36
36
  "typesVersions": {
@@ -51,7 +51,7 @@
51
51
  "@clerc/core": "*"
52
52
  },
53
53
  "devDependencies": {
54
- "@clerc/core": "0.10.4"
54
+ "@clerc/core": "0.11.0"
55
55
  },
56
56
  "scripts": {
57
57
  "build": "puild",
package/dist/index.cjs DELETED
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var core = require('@clerc/core');
6
-
7
- const strictFlagsPlugin = () => core.definePlugin({
8
- setup(cli) {
9
- return cli.inspector((ctx, next) => {
10
- const keys = Object.keys(ctx.unknownFlags);
11
- if (keys.length > 0) {
12
- throw new Error(`Unexpected flags: ${keys.join(", ")}`);
13
- }
14
- next();
15
- });
16
- }
17
- });
18
-
19
- exports.strictFlagsPlugin = strictFlagsPlugin;