yargs 16.0.3 → 16.2.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.
@@ -1,12 +1,13 @@
1
- 'use strict'
1
+ 'use strict';
2
2
 
3
- import cliui from 'https://unpkg.com/cliui@7.0.1/index.mjs'
4
- import Parser from "https://unpkg.com/yargs-parser@19.0.0/browser.js";
5
- import { getProcessArgvBin } from '../../build/lib/utils/process-argv.js'
6
- import { YError } from '../../build/lib/yerror.js'
3
+ import cliui from 'https://unpkg.com/cliui@7.0.1/index.mjs'; // eslint-disable-line
4
+ import Parser from 'https://unpkg.com/yargs-parser@19.0.0/browser.js'; // eslint-disable-line
5
+ import {getProcessArgvBin} from '../../build/lib/utils/process-argv.js';
6
+ import {YError} from '../../build/lib/yerror.js';
7
7
 
8
- const REQUIRE_ERROR = 'require is not supported in browser'
9
- const REQUIRE_DIRECTORY_ERROR = 'loading a directory of commands is not supported in browser'
8
+ const REQUIRE_ERROR = 'require is not supported in browser';
9
+ const REQUIRE_DIRECTORY_ERROR =
10
+ 'loading a directory of commands is not supported in browser';
10
11
 
11
12
  export default {
12
13
  assert: {
@@ -15,26 +16,26 @@ export default {
15
16
  },
16
17
  strictEqual: (a, b) => {
17
18
  // noop.
18
- }
19
+ },
19
20
  },
20
21
  cliui,
21
22
  findUp: () => undefined,
22
- getEnv: (key) => {
23
+ getEnv: key => {
23
24
  // There is no environment in browser:
24
- return undefined
25
+ return undefined;
25
26
  },
26
27
  inspect: console.log,
27
28
  getCallerFile: () => {
28
- throw new YError(REQUIRE_DIRECTORY_ERROR)
29
+ throw new YError(REQUIRE_DIRECTORY_ERROR);
29
30
  },
30
31
  getProcessArgvBin,
31
32
  mainFilename: 'yargs',
32
33
  Parser,
33
34
  path: {
34
- basename: (str) => str,
35
- dirname: (str) => str,
36
- extname: (str) => str,
37
- relative: (str) => str
35
+ basename: str => str,
36
+ dirname: str => str,
37
+ extname: str => str,
38
+ relative: str => str,
38
39
  },
39
40
  process: {
40
41
  argv: () => [],
@@ -42,50 +43,50 @@ export default {
42
43
  execPath: () => '',
43
44
  // exit is noop browser:
44
45
  exit: () => {},
45
- nextTick: (cb) => {
46
- window.setTimeout(cb, 1)
46
+ nextTick: cb => {
47
+ window.setTimeout(cb, 1);
47
48
  },
48
- stdColumns: 80
49
+ stdColumns: 80,
49
50
  },
50
51
  readFileSync: () => {
51
- return ''
52
+ return '';
52
53
  },
53
54
  require: () => {
54
- throw new YError(REQUIRE_ERROR)
55
+ throw new YError(REQUIRE_ERROR);
55
56
  },
56
57
  requireDirectory: () => {
57
- throw new YError(REQUIRE_DIRECTORY_ERROR)
58
+ throw new YError(REQUIRE_DIRECTORY_ERROR);
58
59
  },
59
- stringWidth: (str) => {
60
- return [...str].length
60
+ stringWidth: str => {
61
+ return [...str].length;
61
62
  },
62
63
  // TODO: replace this with y18n once it's ported to ESM:
63
64
  y18n: {
64
65
  __: (...str) => {
65
- if (str.length === 0) return ''
66
- const args = str.slice(1)
67
- return sprintf(str[0], ...args)
66
+ if (str.length === 0) return '';
67
+ const args = str.slice(1);
68
+ return sprintf(str[0], ...args);
68
69
  },
69
70
  __n: (str1, str2, count, ...args) => {
70
71
  if (count === 1) {
71
- return sprintf(str1, ...args)
72
+ return sprintf(str1, ...args);
72
73
  } else {
73
- return sprintf(str2, ...args)
74
+ return sprintf(str2, ...args);
74
75
  }
75
76
  },
76
77
  getLocale: () => {
77
- return 'en_US'
78
+ return 'en_US';
78
79
  },
79
80
  setLocale: () => {},
80
- updateLocale: () => {}
81
- }
82
- }
81
+ updateLocale: () => {},
82
+ },
83
+ };
83
84
 
84
85
  function sprintf(_str, ...args) {
85
- let str = ''
86
- const split = _str.split('%s')
86
+ let str = '';
87
+ const split = _str.split('%s');
87
88
  split.forEach((token, i) => {
88
- str += `${token}${split[i + 1] !== undefined && args[i] ? args[i] : ''}`
89
- })
90
- return str
89
+ str += `${token}${split[i + 1] !== undefined && args[i] ? args[i] : ''}`;
90
+ });
91
+ return str;
91
92
  }
package/package.json CHANGED
@@ -1,22 +1,30 @@
1
1
  {
2
2
  "name": "yargs",
3
- "version": "16.0.3",
3
+ "version": "16.2.0",
4
4
  "description": "yargs the modern, pirate-themed, successor to optimist.",
5
5
  "main": "./index.cjs",
6
6
  "exports": {
7
- ".": {
8
- "import": "./index.mjs",
9
- "require": "./index.cjs"
10
- },
7
+ "./package.json": "./package.json",
8
+ ".": [
9
+ {
10
+ "import": "./index.mjs",
11
+ "require": "./index.cjs"
12
+ },
13
+ "./index.cjs"
14
+ ],
11
15
  "./helpers": {
12
- "import": "./helpers.mjs"
16
+ "import": "./helpers/helpers.mjs",
17
+ "require": "./helpers/index.js"
13
18
  },
14
- "./yargs": {
15
- "require": "./yargs"
16
- }
19
+ "./yargs": [
20
+ {
21
+ "require": "./yargs"
22
+ },
23
+ "./yargs"
24
+ ]
17
25
  },
18
26
  "type": "module",
19
- "module": "./build/index.mjs",
27
+ "module": "./index.mjs",
20
28
  "contributors": [
21
29
  {
22
30
  "name": "Yargs Contributors",
@@ -26,7 +34,8 @@
26
34
  "files": [
27
35
  "browser.mjs",
28
36
  "index.cjs",
29
- "helpers.mjs",
37
+ "helpers/*.js",
38
+ "helpers/*",
30
39
  "index.mjs",
31
40
  "yargs",
32
41
  "build",
@@ -36,20 +45,18 @@
36
45
  "!*.d.ts"
37
46
  ],
38
47
  "dependencies": {
39
- "cliui": "^7.0.0",
40
- "escalade": "^3.0.2",
48
+ "cliui": "^7.0.2",
49
+ "escalade": "^3.1.1",
41
50
  "get-caller-file": "^2.0.5",
42
51
  "require-directory": "^2.1.1",
43
52
  "string-width": "^4.2.0",
44
- "y18n": "^5.0.1",
45
- "yargs-parser": "^20.0.0"
53
+ "y18n": "^5.0.5",
54
+ "yargs-parser": "^20.2.2"
46
55
  },
47
56
  "devDependencies": {
48
57
  "@types/chai": "^4.2.11",
49
58
  "@types/mocha": "^8.0.0",
50
- "@types/node": "^14.0.27",
51
- "@typescript-eslint/eslint-plugin": "^3.0.0",
52
- "@typescript-eslint/parser": "^3.0.0",
59
+ "@types/node": "^14.11.2",
53
60
  "@wessberg/rollup-plugin-ts": "^1.3.2",
54
61
  "c8": "^7.0.0",
55
62
  "chai": "^4.2.0",
@@ -58,10 +65,7 @@
58
65
  "cpr": "^3.0.1",
59
66
  "cross-env": "^7.0.2",
60
67
  "cross-spawn": "^7.0.0",
61
- "eslint": "^6.8.0",
62
- "eslint-plugin-import": "^2.20.1",
63
- "eslint-plugin-node": "^11.0.0",
64
- "gts": "^2.0.0-alpha.4",
68
+ "gts": "^3.0.0",
65
69
  "hashish": "0.0.4",
66
70
  "mocha": "^8.0.0",
67
71
  "rimraf": "^3.0.2",
@@ -73,8 +77,8 @@
73
77
  "yargs-test-extends": "^1.0.1"
74
78
  },
75
79
  "scripts": {
76
- "check": "standardx './*.ts' && standardx '**/*.ts'",
77
- "fix": "standardx --fix './*.ts' && standardx --fix '**/*.ts'",
80
+ "fix": "gts fix && npm run fix:js",
81
+ "fix:js": "standardx --fix '**/*.mjs' && standardx --fix '**/*.cjs' && standardx --fix './*.mjs' && standardx --fix './*.cjs'",
78
82
  "posttest": "npm run check",
79
83
  "test": "c8 mocha ./test/*.cjs --require ./test/before.cjs --timeout=12000 --check-leaks",
80
84
  "test:esm": "c8 mocha ./test/esm/*.mjs --check-leaks",
@@ -84,7 +88,10 @@
84
88
  "compile": "rimraf build && tsc",
85
89
  "postcompile": "npm run build:cjs",
86
90
  "build:cjs": "rollup -c rollup.config.cjs",
87
- "postbuild:cjs": "rimraf ./build/index.cjs.d.ts"
91
+ "postbuild:cjs": "rimraf ./build/index.cjs.d.ts",
92
+ "check": "gts lint && npm run check:js",
93
+ "check:js": "standardx '**/*.mjs' && standardx '**/*.cjs' && standardx './*.mjs' && standardx './*.cjs'",
94
+ "clean": "gts clean"
88
95
  },
89
96
  "repository": {
90
97
  "type": "git",
@@ -94,7 +101,9 @@
94
101
  "standardx": {
95
102
  "ignore": [
96
103
  "build",
97
- "**/example/**"
104
+ "helpers",
105
+ "**/example/**",
106
+ "**/platform-shims/esm.mjs"
98
107
  ]
99
108
  },
100
109
  "keywords": [
package/yargs CHANGED
@@ -1,8 +1,9 @@
1
1
  // TODO: consolidate on using a helpers file at some point in the future, which
2
- // is the approach currently used to export Parser and applyExtends for ESM:
3
- const {applyExtends, cjsPlatformShim, Parser, Yargs} = require('./build/index.cjs')
2
+ // is the approach currently used to export Parser and applyExtends for ESM:
3
+ const {applyExtends, cjsPlatformShim, Parser, Yargs, processArgv} = require('./build/index.cjs')
4
4
  Yargs.applyExtends = (config, cwd, mergeExtends) => {
5
5
  return applyExtends(config, cwd, mergeExtends, cjsPlatformShim)
6
6
  }
7
+ Yargs.hideBin = processArgv.hideBin
7
8
  Yargs.Parser = Parser
8
9
  module.exports = Yargs
package/helpers.mjs DELETED
@@ -1,14 +0,0 @@
1
- import { applyExtends as _applyExtends } from './build/lib/utils/apply-extends.js'
2
- import { hideBin } from './build/lib/utils/process-argv.js'
3
- import Parser from 'yargs-parser'
4
- import shim from './lib/platform-shims/esm.mjs'
5
-
6
- const applyExtends = (config, cwd, mergeExtends) => {
7
- return _applyExtends(config, cwd, mergeExtends, shim)
8
- }
9
-
10
- export {
11
- applyExtends,
12
- hideBin,
13
- Parser,
14
- }