@node-cli/parser 1.0.2 → 2.0.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/README.md CHANGED
@@ -13,6 +13,7 @@
13
13
  | Argument | Type |
14
14
  | ------------------------- | ----------------- |
15
15
  | options | Object |
16
+ | options.meta | import.meta |
16
17
  | options.examples | Array of Object |
17
18
  | options.flags | Object |
18
19
  | options.parameters | Object |
@@ -25,6 +26,7 @@
25
26
  ```js
26
27
  import { parser } from "@node-cli/parser";
27
28
  const { flags, parameters } = parser({
29
+ meta: import.meta, // this is required for --version to work correctly
28
30
  examples: [
29
31
  {
30
32
  command: 'my-cli --verbose --command "chmod +x" bin',
package/dist/parser.d.ts CHANGED
@@ -13,6 +13,7 @@ type Parameters = {
13
13
  };
14
14
  };
15
15
  export type ParserConfiguration = {
16
+ meta: any;
16
17
  flags?: Flags;
17
18
  parameters?: Parameters;
18
19
  usage?: boolean | string;
package/dist/parser.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { meowOptionsHelper, meowParserHelper, shallowMerge } from "./utilities.js";
2
2
  import meow from "meow";
3
3
  export const parser = (configuration)=>{
4
- const { defaultFlags ={} , defaultParameters ={} , ...others } = configuration;
4
+ const { meta , defaultFlags ={} , defaultParameters ={} , ...others } = configuration;
5
5
  const { helpText , options } = meowOptionsHelper(others);
6
6
  const cli = meow(helpText, {
7
7
  ...options,
8
- importMeta: import.meta
8
+ importMeta: meta
9
9
  });
10
10
  meowParserHelper({
11
11
  cli
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/parser.ts"],"sourcesContent":["import {\n\tmeowOptionsHelper,\n\tmeowParserHelper,\n\tshallowMerge,\n} from \"./utilities.js\";\n\nimport meow from \"meow\";\n\ntype Flags = {\n\t[key: string]: {\n\t\tshortFlag?: string;\n\t\tdefault?: string | number | boolean;\n\t\tdescription: string;\n\t\ttype: string;\n\t};\n};\ntype Parameters = {\n\t[key: string]: {\n\t\tdefault?: string | number | boolean;\n\t\tdescription: string;\n\t};\n};\nexport type ParserConfiguration = {\n\tflags?: Flags;\n\tparameters?: Parameters;\n\tusage?: boolean | string;\n\texamples?:\n\t\t| string\n\t\t| { command?: string; description?: string; comment?: string }[];\n\tdefaultFlags?: any;\n\tdefaultParameters?: any;\n};\n\nexport const parser = (configuration: ParserConfiguration) => {\n\tconst {\n\t\tdefaultFlags = {},\n\t\tdefaultParameters = {},\n\t\t...others\n\t} = configuration;\n\tconst { helpText, options } = meowOptionsHelper(others);\n\tconst cli = meow(helpText, { ...options, importMeta: import.meta });\n\tmeowParserHelper({ cli });\n\n\treturn {\n\t\tflags: shallowMerge(defaultFlags, cli.flags),\n\t\tparameters: shallowMerge(defaultParameters, cli.input),\n\t};\n};\n"],"names":["meowOptionsHelper","meowParserHelper","shallowMerge","meow","parser","configuration","defaultFlags","defaultParameters","others","helpText","options","cli","importMeta","flags","parameters","input"],"mappings":"AAAA,SACCA,iBAAiB,EACjBC,gBAAgB,EAChBC,YAAY,QACN,iBAAiB;AAExB,OAAOC,UAAU,OAAO;AA2BxB,OAAO,MAAMC,SAAS,CAACC;IACtB,MAAM,EACLC,cAAe,CAAC,EAAC,EACjBC,mBAAoB,CAAC,EAAC,EACtB,GAAGC,QACH,GAAGH;IACJ,MAAM,EAAEI,SAAQ,EAAEC,QAAO,EAAE,GAAGV,kBAAkBQ;IAChD,MAAMG,MAAMR,KAAKM,UAAU;QAAE,GAAGC,OAAO;QAAEE,YAAY;IAAY;IACjEX,iBAAiB;QAAEU;IAAI;IAEvB,OAAO;QACNE,OAAOX,aAAaI,cAAcK,IAAIE;QACtCC,YAAYZ,aAAaK,mBAAmBI,IAAII;IACjD;AACD,EAAE"}
1
+ {"version":3,"sources":["../src/parser.ts"],"sourcesContent":["import {\n\tmeowOptionsHelper,\n\tmeowParserHelper,\n\tshallowMerge,\n} from \"./utilities.js\";\n\nimport meow from \"meow\";\n\ntype Flags = {\n\t[key: string]: {\n\t\tshortFlag?: string;\n\t\tdefault?: string | number | boolean;\n\t\tdescription: string;\n\t\ttype: string;\n\t};\n};\ntype Parameters = {\n\t[key: string]: {\n\t\tdefault?: string | number | boolean;\n\t\tdescription: string;\n\t};\n};\nexport type ParserConfiguration = {\n\tmeta: any;\n\tflags?: Flags;\n\tparameters?: Parameters;\n\tusage?: boolean | string;\n\texamples?:\n\t\t| string\n\t\t| { command?: string; description?: string; comment?: string }[];\n\tdefaultFlags?: any;\n\tdefaultParameters?: any;\n};\n\nexport const parser = (configuration: ParserConfiguration) => {\n\tconst {\n\t\tmeta,\n\t\tdefaultFlags = {},\n\t\tdefaultParameters = {},\n\t\t...others\n\t} = configuration;\n\tconst { helpText, options } = meowOptionsHelper(others);\n\tconst cli = meow(helpText, {\n\t\t...options,\n\t\timportMeta: meta,\n\t});\n\tmeowParserHelper({ cli });\n\n\treturn {\n\t\tflags: shallowMerge(defaultFlags, cli.flags),\n\t\tparameters: shallowMerge(defaultParameters, cli.input),\n\t};\n};\n"],"names":["meowOptionsHelper","meowParserHelper","shallowMerge","meow","parser","configuration","meta","defaultFlags","defaultParameters","others","helpText","options","cli","importMeta","flags","parameters","input"],"mappings":"AAAA,SACCA,iBAAiB,EACjBC,gBAAgB,EAChBC,YAAY,QACN,iBAAiB;AAExB,OAAOC,UAAU,OAAO;AA4BxB,OAAO,MAAMC,SAAS,CAACC;IACtB,MAAM,EACLC,KAAI,EACJC,cAAe,CAAC,EAAC,EACjBC,mBAAoB,CAAC,EAAC,EACtB,GAAGC,QACH,GAAGJ;IACJ,MAAM,EAAEK,SAAQ,EAAEC,QAAO,EAAE,GAAGX,kBAAkBS;IAChD,MAAMG,MAAMT,KAAKO,UAAU;QAC1B,GAAGC,OAAO;QACVE,YAAYP;IACb;IACAL,iBAAiB;QAAEW;IAAI;IAEvB,OAAO;QACNE,OAAOZ,aAAaK,cAAcK,IAAIE;QACtCC,YAAYb,aAAaM,mBAAmBI,IAAII;IACjD;AACD,EAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-cli/parser",
3
- "version": "1.0.2",
3
+ "version": "2.0.0",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "description": "A simple CLI parser helper",
@@ -24,7 +24,7 @@
24
24
  "build:js": "swc --source-maps --out-dir dist src",
25
25
  "build:types": "tsc",
26
26
  "clean": "rimraf dist types coverage",
27
- "lint": "eslint \"src/*.ts\"",
27
+ "lint": "prettier --write \"src/*.ts\" && eslint --fix \"src/*.ts\"",
28
28
  "test": "cross-env-shell NODE_OPTIONS=--experimental-vm-modules jest",
29
29
  "test:coverage": "npm run test -- --coverage",
30
30
  "watch": "swc --watch --out-dir dist src"
@@ -32,5 +32,5 @@
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "gitHead": "d1d89854e385600edfd9c2aead7c9bc568bcc657"
35
+ "gitHead": "5d4bd8b98b32bdd62be28061190fe766767ec7f7"
36
36
  }