yargs 13.2.1 → 13.3.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/CHANGELOG.md CHANGED
@@ -1,7 +1,48 @@
1
- # Change Log
1
+ # Changelog
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [13.3.0](https://www.github.com/yargs/yargs/compare/v13.2.4...v13.3.0) (2019-06-10)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **deps:** yargs-parser update addressing several parsing bugs ([#1357](https://www.github.com/yargs/yargs/issues/1357)) ([e230d5b](https://www.github.com/yargs/yargs/commit/e230d5b))
11
+
12
+
13
+ ### Features
14
+
15
+ * **i18n:** swap out os-locale dependency for simple inline implementation ([#1356](https://www.github.com/yargs/yargs/issues/1356)) ([4dfa19b](https://www.github.com/yargs/yargs/commit/4dfa19b))
16
+ * support defaultDescription for positional arguments ([812048c](https://www.github.com/yargs/yargs/commit/812048c))
17
+
18
+ ### [13.2.4](https://github.com/yargs/yargs/compare/v13.2.3...v13.2.4) (2019-05-13)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * **i18n:** rename unclear 'implication failed' to 'missing dependent arguments' ([#1317](https://github.com/yargs/yargs/issues/1317)) ([bf46813](https://github.com/yargs/yargs/commit/bf46813))
24
+
25
+
26
+
27
+ ### [13.2.3](https://github.com/yargs/yargs/compare/v13.2.2...v13.2.3) (2019-05-05)
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * **deps:** upgrade cliui for compatibility with latest chalk. ([#1330](https://github.com/yargs/yargs/issues/1330)) ([b20db65](https://github.com/yargs/yargs/commit/b20db65))
33
+ * address issues with dutch translation ([#1316](https://github.com/yargs/yargs/issues/1316)) ([0295132](https://github.com/yargs/yargs/commit/0295132))
34
+
35
+
36
+ ### Tests
37
+
38
+ * accept differently formatted output ([#1327](https://github.com/yargs/yargs/issues/1327)) ([c294d1b](https://github.com/yargs/yargs/commit/c294d1b))
39
+
40
+
41
+
42
+ ## [13.2.2](https://github.com/yargs/yargs/compare/v13.2.1...v13.2.2) (2019-03-06)
43
+
44
+
45
+
5
46
  ## [13.2.1](https://github.com/yargs/yargs/compare/v13.2.0...v13.2.1) (2019-02-18)
6
47
 
7
48
 
@@ -11,6 +52,13 @@ All notable changes to this project will be documented in this file. See [standa
11
52
  * support options/sub-commands in zsh completion ([0a96394](https://github.com/yargs/yargs/commit/0a96394))
12
53
 
13
54
 
55
+ # [13.2.0](https://github.com/yargs/yargs/compare/v13.1.0...v13.2.0) (2019-02-15)
56
+
57
+
58
+ ### Features
59
+
60
+ * zsh auto completion ([#1292](https://github.com/yargs/yargs/issues/1292)) ([16c5d25](https://github.com/yargs/yargs/commit/16c5d25)), closes [#1156](https://github.com/yargs/yargs/issues/1156)
61
+
14
62
 
15
63
  <a name="13.1.0"></a>
16
64
  # [13.1.0](https://github.com/yargs/yargs/compare/v13.0.0...v13.1.0) (2019-02-12)
@@ -36,7 +84,8 @@ All notable changes to this project will be documented in this file. See [standa
36
84
 
37
85
  ### Chores
38
86
 
39
- * drop Node 6 from testing matrix ([#1287](https://github.com/yargs/yargs/issues/1287)) ([ef16792](https://github.com/yargs/yargs/commit/ef16792))
87
+ * ~drop Node 6 from testing matrix ([#1287](https://github.com/yargs/yargs/issues/1287)) ([ef16792](https://github.com/yargs/yargs/commit/ef16792))~
88
+ * _opting to not drop Node 6 support until April, [see](https://github.com/nodejs/Release)._
40
89
  * update dependencies ([#1284](https://github.com/yargs/yargs/issues/1284)) ([f25de4f](https://github.com/yargs/yargs/commit/f25de4f))
41
90
 
42
91
 
package/README.md CHANGED
@@ -31,12 +31,12 @@ It gives you:
31
31
 
32
32
  Stable version:
33
33
  ```bash
34
- npm i yargs --save
34
+ npm i yargs
35
35
  ```
36
36
 
37
37
  Bleeding edge version with the most recent features:
38
38
  ```bash
39
- npm i yargs@next --save
39
+ npm i yargs@next
40
40
  ```
41
41
 
42
42
  ## Usage :
@@ -0,0 +1,49 @@
1
+ exports.completionShTemplate =
2
+ `###-begin-{{app_name}}-completions-###
3
+ #
4
+ # yargs command completion script
5
+ #
6
+ # Installation: {{app_path}} {{completion_command}} >> ~/.bashrc
7
+ # or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.
8
+ #
9
+ _yargs_completions()
10
+ {
11
+ local cur_word args type_list
12
+
13
+ cur_word="\${COMP_WORDS[COMP_CWORD]}"
14
+ args=("\${COMP_WORDS[@]}")
15
+
16
+ # ask yargs to generate completions.
17
+ type_list=$({{app_path}} --get-yargs-completions "\${args[@]}")
18
+
19
+ COMPREPLY=( $(compgen -W "\${type_list}" -- \${cur_word}) )
20
+
21
+ # if no match was found, fall back to filename completion
22
+ if [ \${#COMPREPLY[@]} -eq 0 ]; then
23
+ COMPREPLY=()
24
+ fi
25
+
26
+ return 0
27
+ }
28
+ complete -o default -F _yargs_completions {{app_name}}
29
+ ###-end-{{app_name}}-completions-###
30
+ `
31
+
32
+ exports.completionZshTemplate = `###-begin-{{app_name}}-completions-###
33
+ #
34
+ # yargs command completion script
35
+ #
36
+ # Installation: {{app_path}} {{completion_command}} >> ~/.zshrc
37
+ # or {{app_path}} {{completion_command}} >> ~/.zsh_profile on OSX.
38
+ #
39
+ _{{app_name}}_yargs_completions()
40
+ {
41
+ local reply
42
+ local si=$IFS
43
+ IFS=$'\n' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "\${words[@]}"))
44
+ IFS=$si
45
+ _describe 'values' reply
46
+ }
47
+ compdef _{{app_name}}_yargs_completions {{app_name}}
48
+ ###-end-{{app_name}}-completions-###
49
+ `
package/lib/completion.js CHANGED
@@ -1,5 +1,4 @@
1
1
  'use strict'
2
- const fs = require('fs')
3
2
  const path = require('path')
4
3
 
5
4
  // add bash completions to your
@@ -92,10 +91,8 @@ module.exports = function completion (yargs, usage, command) {
92
91
 
93
92
  // generate the completion script to add to your .bashrc.
94
93
  self.generateCompletionScript = function generateCompletionScript ($0, cmd) {
95
- let script = fs.readFileSync(
96
- path.resolve(__dirname, zshShell ? '../completion.zsh.hbs' : '../completion.sh.hbs'),
97
- 'utf-8'
98
- )
94
+ const templates = require('./completion-templates')
95
+ let script = zshShell ? templates.completionZshTemplate : templates.completionShTemplate
99
96
  const name = path.basename($0)
100
97
 
101
98
  // add ./to applications not yet installed as bin.
package/locales/de.json CHANGED
@@ -29,7 +29,7 @@
29
29
  "Invalid values:": "Unzulässige Werte:",
30
30
  "Argument: %s, Given: %s, Choices: %s": "Argument: %s, Gegeben: %s, Möglichkeiten: %s",
31
31
  "Argument check failed: %s": "Argumente-Check fehlgeschlagen: %s",
32
- "Implications failed:": "Implikationen fehlgeschlagen:",
32
+ "Implications failed:": "Fehlende abhängige Argumente:",
33
33
  "Not enough arguments following: %s": "Nicht genügend Argumente nach: %s",
34
34
  "Invalid JSON config file: %s": "Fehlerhafte JSON-Config Datei: %s",
35
35
  "Path to JSON config file": "Pfad zur JSON-Config Datei",
package/locales/en.json CHANGED
@@ -29,7 +29,7 @@
29
29
  "Invalid values:": "Invalid values:",
30
30
  "Argument: %s, Given: %s, Choices: %s": "Argument: %s, Given: %s, Choices: %s",
31
31
  "Argument check failed: %s": "Argument check failed: %s",
32
- "Implications failed:": "Implications failed:",
32
+ "Implications failed:": "Missing dependent arguments:",
33
33
  "Not enough arguments following: %s": "Not enough arguments following: %s",
34
34
  "Invalid JSON config file: %s": "Invalid JSON config file: %s",
35
35
  "Path to JSON config file": "Path to JSON config file",
package/locales/fr.json CHANGED
@@ -28,7 +28,7 @@
28
28
  "Invalid values:": "Valeurs invalides:",
29
29
  "Argument: %s, Given: %s, Choices: %s": "Argument: %s, Donné: %s, Choix: %s",
30
30
  "Argument check failed: %s": "Echec de la vérification de l'argument: %s",
31
- "Implications failed:": "Implications échouées:",
31
+ "Implications failed:": "Arguments dépendants manquants:",
32
32
  "Not enough arguments following: %s": "Pas assez d'arguments suivant: %s",
33
33
  "Invalid JSON config file: %s": "Fichier de configuration JSON invalide: %s",
34
34
  "Path to JSON config file": "Chemin du fichier de configuration JSON",
package/locales/it.json CHANGED
@@ -29,7 +29,7 @@
29
29
  "Invalid values:": "Valori non validi:",
30
30
  "Argument: %s, Given: %s, Choices: %s": "Argomento: %s, Richiesto: %s, Scelte: %s",
31
31
  "Argument check failed: %s": "Controllo dell'argomento fallito: %s",
32
- "Implications failed:": "Argomenti impliciti non soddisfatti:",
32
+ "Implications failed:": "Argomenti dipendenti mancanti:",
33
33
  "Not enough arguments following: %s": "Argomenti insufficienti dopo: %s",
34
34
  "Invalid JSON config file: %s": "File di configurazione JSON non valido: %s",
35
35
  "Path to JSON config file": "Percorso del file di configurazione JSON",
package/locales/nl.json CHANGED
@@ -1,42 +1,42 @@
1
1
  {
2
- "Commands:": "Opdrachten:",
2
+ "Commands:": "Commando's:",
3
3
  "Options:": "Opties:",
4
4
  "Examples:": "Voorbeelden:",
5
- "boolean": "boolean",
5
+ "boolean": "booleaans",
6
6
  "count": "aantal",
7
- "string": "text",
8
- "number": "nummer",
7
+ "string": "string",
8
+ "number": "getal",
9
9
  "array": "lijst",
10
10
  "required": "verplicht",
11
11
  "default:": "standaard:",
12
12
  "choices:": "keuzes:",
13
13
  "aliases:": "aliassen:",
14
14
  "generated-value": "gegenereerde waarde",
15
- "Not enough non-option arguments: got %s, need at least %s": "Niet genoeg non-optie argumenten. Gekregen: %s, minstens nodig: %s",
16
- "Too many non-option arguments: got %s, maximum of %s": "Te veel non-optie argumenten. Gekregen: %s, maximum: %s",
15
+ "Not enough non-option arguments: got %s, need at least %s": "Niet genoeg niet-optie-argumenten: %s gekregen, minstens %s nodig",
16
+ "Too many non-option arguments: got %s, maximum of %s": "Te veel niet-optie-argumenten: %s gekregen, maximum is %s",
17
17
  "Missing argument value: %s": {
18
- "one": "Missing argument value: %s",
19
- "other": "Missing argument values: %s"
18
+ "one": "Missende argumentwaarde: %s",
19
+ "other": "Missende argumentwaarden: %s"
20
20
  },
21
21
  "Missing required argument: %s": {
22
- "one": "Missend verplichte argument: %s",
22
+ "one": "Missend verplicht argument: %s",
23
23
  "other": "Missende verplichte argumenten: %s"
24
24
  },
25
25
  "Unknown argument: %s": {
26
26
  "one": "Onbekend argument: %s",
27
27
  "other": "Onbekende argumenten: %s"
28
28
  },
29
- "Invalid values:": "Ongeldige waardes:",
29
+ "Invalid values:": "Ongeldige waarden:",
30
30
  "Argument: %s, Given: %s, Choices: %s": "Argument: %s, Gegeven: %s, Keuzes: %s",
31
- "Argument check failed: %s": "Argument check mislukt: %s",
32
- "Implications failed:": "Implicaties mislukt:",
31
+ "Argument check failed: %s": "Argumentcontrole mislukt: %s",
32
+ "Implications failed:": "Ontbrekende afhankelijke argumenten:",
33
33
  "Not enough arguments following: %s": "Niet genoeg argumenten na: %s",
34
- "Invalid JSON config file: %s": "Ongeldig JSON configuratiebestand: %s",
35
- "Path to JSON config file": "Pad naar JSON configuratiebestand",
34
+ "Invalid JSON config file: %s": "Ongeldig JSON-config-bestand: %s",
35
+ "Path to JSON config file": "Pad naar JSON-config-bestand",
36
36
  "Show help": "Toon help",
37
- "Show version number": "Toon versie nummer",
37
+ "Show version number": "Toon versienummer",
38
38
  "Did you mean %s?": "Bedoelde u misschien %s?",
39
- "Arguments %s and %s are mutually exclusive": "Argumenten %s en %s zijn onderling uitsluitend",
39
+ "Arguments %s and %s are mutually exclusive": "Argumenten %s en %s kunnen niet tegelijk gebruikt worden",
40
40
  "Positionals:": "Positie-afhankelijke argumenten",
41
41
  "command": "commando"
42
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yargs",
3
- "version": "13.2.1",
3
+ "version": "13.3.2",
4
4
  "description": "yargs the modern, pirate-themed, successor to optimist.",
5
5
  "main": "./index.js",
6
6
  "contributors": [
@@ -19,31 +19,30 @@
19
19
  "LICENSE"
20
20
  ],
21
21
  "dependencies": {
22
- "cliui": "^4.0.0",
22
+ "cliui": "^5.0.0",
23
23
  "find-up": "^3.0.0",
24
24
  "get-caller-file": "^2.0.1",
25
- "os-locale": "^3.1.0",
26
25
  "require-directory": "^2.1.1",
27
26
  "require-main-filename": "^2.0.0",
28
27
  "set-blocking": "^2.0.0",
29
28
  "string-width": "^3.0.0",
30
29
  "which-module": "^2.0.0",
31
30
  "y18n": "^4.0.0",
32
- "yargs-parser": "^13.0.0"
31
+ "yargs-parser": "^13.1.2"
33
32
  },
34
33
  "devDependencies": {
35
34
  "chai": "^4.2.0",
36
35
  "chalk": "^2.4.2",
37
- "coveralls": "^3.0.2",
36
+ "coveralls": "^3.0.3",
38
37
  "cpr": "^3.0.1",
39
38
  "cross-spawn": "^6.0.4",
40
39
  "es6-promise": "^4.2.5",
41
40
  "hashish": "0.0.4",
42
41
  "mocha": "^5.2.0",
43
- "nyc": "^13.2.0",
42
+ "nyc": "^14.1.0",
44
43
  "rimraf": "^2.6.3",
45
44
  "standard": "^12.0.1",
46
- "standard-version": "^5.0.0",
45
+ "standard-version": "^6.0.1",
47
46
  "which": "^1.3.1",
48
47
  "yargs-test-extends": "^1.0.1"
49
48
  },
package/yargs.js CHANGED
@@ -231,6 +231,7 @@ function Yargs (processArgs, cwd, parentRequire) {
231
231
  function populateParserHintArray (type, keys, value) {
232
232
  keys = [].concat(keys)
233
233
  keys.forEach((key) => {
234
+ key = sanitizeKey(key)
234
235
  options[type].push(key)
235
236
  })
236
237
  }
@@ -286,8 +287,8 @@ function Yargs (processArgs, cwd, parentRequire) {
286
287
 
287
288
  function populateParserHintObject (builder, isArray, type, key, value) {
288
289
  if (Array.isArray(key)) {
290
+ const temp = Object.create(null)
289
291
  // an array of keys with one value ['x', 'y', 'z'], function parse () {}
290
- const temp = {}
291
292
  key.forEach((k) => {
292
293
  temp[k] = value
293
294
  })
@@ -298,6 +299,7 @@ function Yargs (processArgs, cwd, parentRequire) {
298
299
  builder(k, key[k])
299
300
  })
300
301
  } else {
302
+ key = sanitizeKey(key)
301
303
  // a single key value pair 'x', parse() {}
302
304
  if (isArray) {
303
305
  options[type][key] = (options[type][key] || []).concat(value)
@@ -307,6 +309,13 @@ function Yargs (processArgs, cwd, parentRequire) {
307
309
  }
308
310
  }
309
311
 
312
+ // TODO(bcoe): in future major versions move more objects towards
313
+ // Object.create(null):
314
+ function sanitizeKey (key) {
315
+ if (key === '__proto__') return '___proto___'
316
+ return key
317
+ }
318
+
310
319
  function deleteFromParserHintObject (optionKey) {
311
320
  // delete from all parsing hints:
312
321
  // boolean, array, key, alias, etc.
@@ -694,8 +703,8 @@ function Yargs (processArgs, cwd, parentRequire) {
694
703
  }
695
704
 
696
705
  // .positional() only supports a subset of the configuration
697
- // options availble to .option().
698
- const supportedOpts = ['default', 'implies', 'normalize',
706
+ // options available to .option().
707
+ const supportedOpts = ['default', 'defaultDescription', 'implies', 'normalize',
699
708
  'choices', 'conflicts', 'coerce', 'type', 'describe',
700
709
  'desc', 'description', 'alias']
701
710
  opts = objFilter(opts, (k, v) => {
@@ -1181,8 +1190,9 @@ function Yargs (processArgs, cwd, parentRequire) {
1181
1190
  if (!detectLocale) return
1182
1191
 
1183
1192
  try {
1184
- const osLocale = require('os-locale')
1185
- self.locale(osLocale.sync({ spawn: false }))
1193
+ const { env } = process
1194
+ const locale = env.LC_ALL || env.LC_MESSAGES || env.LANG || env.LANGUAGE || 'en_US'
1195
+ self.locale(locale.replace(/[.:].*/, ''))
1186
1196
  } catch (err) {
1187
1197
  // if we explode looking up locale just noop
1188
1198
  // we'll keep using the default language 'en'.
package/completion.sh.hbs DELETED
@@ -1,28 +0,0 @@
1
- ###-begin-{{app_name}}-completions-###
2
- #
3
- # yargs command completion script
4
- #
5
- # Installation: {{app_path}} {{completion_command}} >> ~/.bashrc
6
- # or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.
7
- #
8
- _yargs_completions()
9
- {
10
- local cur_word args type_list
11
-
12
- cur_word="${COMP_WORDS[COMP_CWORD]}"
13
- args=("${COMP_WORDS[@]}")
14
-
15
- # ask yargs to generate completions.
16
- type_list=$({{app_path}} --get-yargs-completions "${args[@]}")
17
-
18
- COMPREPLY=( $(compgen -W "${type_list}" -- ${cur_word}) )
19
-
20
- # if no match was found, fall back to filename completion
21
- if [ ${#COMPREPLY[@]} -eq 0 ]; then
22
- COMPREPLY=()
23
- fi
24
-
25
- return 0
26
- }
27
- complete -o default -F _yargs_completions {{app_name}}
28
- ###-end-{{app_name}}-completions-###
@@ -1,17 +0,0 @@
1
- ###-begin-{{app_name}}-completions-###
2
- #
3
- # yargs command completion script
4
- #
5
- # Installation: {{app_path}} {{completion_command}} >> ~/.zshrc
6
- # or {{app_path}} {{completion_command}} >> ~/.zsh_profile on OSX.
7
- #
8
- _{{app_name}}_yargs_completions()
9
- {
10
- local reply
11
- local si=$IFS
12
- IFS=$'\n' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "${words[@]}"))
13
- IFS=$si
14
- _describe 'values' reply
15
- }
16
- compdef _{{app_name}}_yargs_completions {{app_name}}
17
- ###-end-{{app_name}}-completions-###