@oclif/core 2.8.10 → 2.8.12

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.
@@ -10,6 +10,7 @@ const util_2 = require("util");
10
10
  const stream_1 = require("../stream");
11
11
  const sw = require('string-width');
12
12
  const { orderBy } = require('natural-orderby');
13
+ const sliceAnsi = require('slice-ansi');
13
14
  class Table {
14
15
  constructor(data, columns, options = {}) {
15
16
  this.data = data;
@@ -258,7 +259,12 @@ class Table {
258
259
  const colorWidth = (d.length - visualWidth);
259
260
  let cell = d.padEnd(width + colorWidth);
260
261
  if ((cell.length - colorWidth) > width || visualWidth === width) {
261
- cell = cell.slice(0, width - 2) + '… ';
262
+ // truncate the cell, preserving ANSI escape sequences, and keeping
263
+ // into account the width of fullwidth unicode characters
264
+ cell = sliceAnsi(cell, 0, width - 2) + '… ';
265
+ // pad with spaces; this is necessary in case the original string
266
+ // contained fullwidth characters which cannot be split
267
+ cell += ' '.repeat(width - sw(cell));
262
268
  }
263
269
  l += cell;
264
270
  }
@@ -85,11 +85,16 @@ class Parser {
85
85
  if (this.flagAliases[char]) {
86
86
  return this.flagAliases[char].name;
87
87
  }
88
- return Object.keys(this.input.flags).find(k => this.input.flags[k].char === char);
88
+ return Object.keys(this.input.flags).find(k => (this.input.flags[k].char === char && char !== undefined && this.input.flags[k].char !== undefined));
89
+ };
90
+ const findFlag = (arg) => {
91
+ const isLong = arg.startsWith('--');
92
+ const short = isLong ? false : arg.startsWith('-');
93
+ const name = isLong ? findLongFlag(arg) : (short ? findShortFlag(arg) : undefined);
94
+ return { name, isLong };
89
95
  };
90
96
  const parseFlag = (arg) => {
91
- const long = arg.startsWith('--');
92
- const name = long ? findLongFlag(arg) : findShortFlag(arg);
97
+ const { name, isLong } = findFlag(arg);
93
98
  if (!name) {
94
99
  const i = arg.indexOf('=');
95
100
  if (i !== -1) {
@@ -106,16 +111,17 @@ class Parser {
106
111
  const flag = this.input.flags[name];
107
112
  if (flag.type === 'option') {
108
113
  this.currentFlag = flag;
109
- const input = long || arg.length < 3 ? this.argv.shift() : arg.slice(arg[2] === '=' ? 3 : 2);
110
- if (typeof input !== 'string') {
114
+ const input = isLong || arg.length < 3 ? this.argv.shift() : arg.slice(arg[2] === '=' ? 3 : 2);
115
+ // if the value ends up being one of the command's flags, the user didn't provide an input
116
+ if ((typeof input !== 'string') || findFlag(input).name) {
111
117
  throw new errors_1.CLIError(`Flag --${name} expects a value`);
112
118
  }
113
- this.raw.push({ type: 'flag', flag: flag.name, input });
119
+ this.raw.push({ type: 'flag', flag: flag.name, input: input });
114
120
  }
115
121
  else {
116
122
  this.raw.push({ type: 'flag', flag: flag.name, input: arg });
117
123
  // push the rest of the short characters back on the stack
118
- if (!long && arg.length > 2) {
124
+ if (!isLong && arg.length > 2) {
119
125
  this.argv.unshift(`-${arg.slice(2)}`);
120
126
  }
121
127
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oclif/core",
3
3
  "description": "base library for oclif CLIs",
4
- "version": "2.8.10",
4
+ "version": "2.8.12",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {
@@ -24,7 +24,8 @@
24
24
  "natural-orderby": "^2.0.3",
25
25
  "object-treeify": "^1.1.33",
26
26
  "password-prompt": "^1.1.2",
27
- "semver": "^7.3.7",
27
+ "semver": "^7.5.3",
28
+ "slice-ansi": "^4.0.0",
28
29
  "string-width": "^4.2.3",
29
30
  "strip-ansi": "^6.0.1",
30
31
  "supports-color": "^8.1.1",
@@ -53,8 +54,9 @@
53
54
  "@types/node": "^16",
54
55
  "@types/node-notifier": "^8.0.2",
55
56
  "@types/proxyquire": "^1.3.28",
56
- "@types/semver": "^7.3.13",
57
+ "@types/semver": "^7.5.0",
57
58
  "@types/shelljs": "^0.8.11",
59
+ "@types/slice-ansi": "^4.0.0",
58
60
  "@types/strip-ansi": "^5.2.1",
59
61
  "@types/supports-color": "^8.1.1",
60
62
  "@types/wordwrap": "^1.0.1",
@@ -108,6 +110,7 @@
108
110
  "commitlint": "commitlint",
109
111
  "lint": "eslint . --ext .ts --config .eslintrc",
110
112
  "posttest": "yarn lint",
113
+ "compile": "tsc",
111
114
  "prepack": "yarn run build",
112
115
  "test": "mocha --forbid-only \"test/**/*.test.ts\"",
113
116
  "test:e2e": "mocha --forbid-only \"test/**/*.e2e.ts\" --timeout 1200000",