@clerc/plugin-strict-flags 1.0.0-beta.9 → 1.0.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 (2) hide show
  1. package/dist/index.js +10 -2
  2. package/package.json +3 -9
package/dist/index.js CHANGED
@@ -1,11 +1,19 @@
1
1
  import { definePlugin } from "@clerc/core";
2
- import { joinWithAnd } from "@clerc/utils";
3
2
 
3
+ //#region ../utils/src/index.ts
4
+ function joinWithAnd(values) {
5
+ if (values.length === 0) return "";
6
+ if (values.length === 1) return values[0];
7
+ const last = values.pop();
8
+ return `${values.join(", ")} and ${last}`;
9
+ }
10
+
11
+ //#endregion
4
12
  //#region src/index.ts
5
13
  const strictFlagsPlugin = () => definePlugin({ setup: (cli) => {
6
14
  cli.interceptor(async (ctx, next) => {
7
15
  const keys = Object.keys(ctx.rawParsed.unknown);
8
- if (!ctx.resolved || keys.length === 0) await next();
16
+ if (!ctx.command || keys.length === 0) await next();
9
17
  else throw keys.length > 1 ? /* @__PURE__ */ new Error(`Unexpected flags: ${joinWithAnd(keys)}`) : /* @__PURE__ */ new Error(`Unexpected flag: ${keys[0]}`);
10
18
  });
11
19
  } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clerc/plugin-strict-flags",
3
- "version": "1.0.0-beta.9",
3
+ "version": "1.0.1",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve)",
5
5
  "type": "module",
6
6
  "description": "Clerc plugin strict flags",
@@ -44,17 +44,11 @@
44
44
  "publishConfig": {
45
45
  "access": "public"
46
46
  },
47
- "dependencies": {
48
- "@clerc/utils": "1.0.0-beta.9"
49
- },
50
47
  "devDependencies": {
51
- "@clerc/core": "1.0.0-beta.9"
48
+ "@clerc/core": "1.0.1",
49
+ "@clerc/utils": "1.0.1"
52
50
  },
53
51
  "peerDependencies": {
54
52
  "@clerc/core": "*"
55
- },
56
- "scripts": {
57
- "build": "tsdown",
58
- "watch": "tsdown --watch"
59
53
  }
60
54
  }