zcatalyst-cli 1.12.1 → 1.13.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.
Files changed (179) hide show
  1. package/lib/apig-utils.js +39 -39
  2. package/lib/archiver.js +13 -9
  3. package/lib/authentication/index.js +22 -18
  4. package/lib/authentication/login.js +32 -32
  5. package/lib/bin/catalyst.js +15 -15
  6. package/lib/cli_table/src/cell.js +26 -26
  7. package/lib/cli_table/src/layout-manager.js +44 -45
  8. package/lib/cli_table/src/table.js +9 -9
  9. package/lib/cli_table/src/utils.js +35 -36
  10. package/lib/client-utils.js +18 -18
  11. package/lib/client.js +1 -1
  12. package/lib/command_needs/auth.js +7 -7
  13. package/lib/command_needs/rc.js +24 -24
  14. package/lib/commands/apig/disable.js +5 -5
  15. package/lib/commands/apig/enable.js +5 -5
  16. package/lib/commands/apig/status.js +9 -9
  17. package/lib/commands/client/delete.js +18 -18
  18. package/lib/commands/client/setup.js +8 -4
  19. package/lib/commands/deploy.js +18 -14
  20. package/lib/commands/ds/export.js +11 -11
  21. package/lib/commands/ds/import.js +12 -12
  22. package/lib/commands/ds/status.js +10 -10
  23. package/lib/commands/event/generate/index.js +21 -17
  24. package/lib/commands/event/generate/integ.js +7 -3
  25. package/lib/commands/functions/add.js +8 -4
  26. package/lib/commands/functions/config.js +5 -5
  27. package/lib/commands/functions/delete.js +20 -20
  28. package/lib/commands/functions/setup.js +8 -4
  29. package/lib/commands/functions/shell.js +7 -3
  30. package/lib/commands/help.js +4 -4
  31. package/lib/commands/iac/export.js +8 -8
  32. package/lib/commands/iac/import.js +23 -19
  33. package/lib/commands/iac/pack.js +15 -11
  34. package/lib/commands/iac/status.js +6 -2
  35. package/lib/commands/index.js +5 -1
  36. package/lib/commands/init.js +14 -10
  37. package/lib/commands/login.js +5 -1
  38. package/lib/commands/logout.js +5 -1
  39. package/lib/commands/project/list.js +14 -10
  40. package/lib/commands/project/reset.js +5 -5
  41. package/lib/commands/project/use.js +9 -9
  42. package/lib/commands/pull.js +18 -14
  43. package/lib/commands/run.js +13 -9
  44. package/lib/commands/serve.js +5 -1
  45. package/lib/commands/token/generate.js +6 -2
  46. package/lib/commands/token/list.js +7 -3
  47. package/lib/commands/token/revoke.js +6 -2
  48. package/lib/commands/whoami.js +3 -3
  49. package/lib/dc.js +2 -2
  50. package/lib/deploy/features/apig.js +6 -6
  51. package/lib/deploy/features/client.js +1 -1
  52. package/lib/deploy/features/functions/index.js +9 -9
  53. package/lib/deploy/features/index.js +5 -1
  54. package/lib/deploy/index.js +2 -2
  55. package/lib/endpoints/index.js +17 -13
  56. package/lib/endpoints/lib/apig.js +5 -5
  57. package/lib/endpoints/lib/applogic.js +4 -4
  58. package/lib/endpoints/lib/cache.js +3 -3
  59. package/lib/endpoints/lib/catalyst-details.js +1 -1
  60. package/lib/endpoints/lib/client.js +5 -5
  61. package/lib/endpoints/lib/datastore.js +2 -2
  62. package/lib/endpoints/lib/ds-bulk.js +5 -5
  63. package/lib/endpoints/lib/env.js +1 -1
  64. package/lib/endpoints/lib/event-bus.js +1 -1
  65. package/lib/endpoints/lib/filestore.js +2 -2
  66. package/lib/endpoints/lib/functions.js +4 -4
  67. package/lib/endpoints/lib/iac.js +10 -10
  68. package/lib/endpoints/lib/project.js +20 -5
  69. package/lib/endpoints/lib/queue.js +3 -3
  70. package/lib/endpoints/lib/sdk.js +1 -1
  71. package/lib/endpoints/lib/zcql.js +1 -1
  72. package/lib/error.js +1 -1
  73. package/lib/errorOut.js +2 -2
  74. package/lib/event_generate/cache.js +5 -5
  75. package/lib/event_generate/custom.js +2 -2
  76. package/lib/event_generate/datastore.js +5 -5
  77. package/lib/event_generate/filestore.js +5 -5
  78. package/lib/event_generate/integration/cliq.js +3 -3
  79. package/lib/event_generate/user.js +1 -1
  80. package/lib/event_generate/webapp.js +5 -5
  81. package/lib/execute-script.js +19 -15
  82. package/lib/express_middlewares/authenticator.js +32 -5
  83. package/lib/express_middlewares/logger.js +2 -2
  84. package/lib/express_middlewares/unknownReqProxy.js +1 -1
  85. package/lib/fn-utils/index.js +5 -1
  86. package/lib/fn-utils/lib/common.js +44 -44
  87. package/lib/fn-utils/lib/integ.js +9 -9
  88. package/lib/fn-utils/lib/java.js +46 -46
  89. package/lib/fn-utils/lib/node.js +7 -7
  90. package/lib/fn-watcher.js +9 -11
  91. package/lib/iac/status/bundle.js +5 -5
  92. package/lib/iac/status/deploy.js +4 -4
  93. package/lib/index.js +2 -2
  94. package/lib/init/dependencies/npm-install.js +1 -1
  95. package/lib/init/dependencies/package-json.js +6 -6
  96. package/lib/init/features/client/index.js +5 -1
  97. package/lib/init/features/client/initializers/angular.js +16 -12
  98. package/lib/init/features/client/initializers/basic.js +10 -6
  99. package/lib/init/features/client/initializers/lyte.js +11 -7
  100. package/lib/init/features/client/initializers/react.js +13 -9
  101. package/lib/init/features/functions/index.js +9 -9
  102. package/lib/init/features/functions/languages/java.js +10 -10
  103. package/lib/init/features/functions/languages/node.js +9 -9
  104. package/lib/init/features/index.js +12 -8
  105. package/lib/init/features/project.js +20 -20
  106. package/lib/init/index.js +2 -2
  107. package/lib/init/util/client.js +7 -3
  108. package/lib/init/util/functions.js +1 -1
  109. package/lib/init/util/project.js +4 -4
  110. package/lib/internal/api.js +19 -19
  111. package/lib/internal/command.js +20 -16
  112. package/lib/internal/config.js +5 -5
  113. package/lib/internal/credential.js +10 -10
  114. package/lib/internal/crypt.js +5 -5
  115. package/lib/internal/rc.js +5 -5
  116. package/lib/migration/global/1.6.2.js +3 -3
  117. package/lib/migration/index.js +22 -18
  118. package/lib/option-filter.js +34 -30
  119. package/lib/optional-import.js +12 -8
  120. package/lib/plugin-loader.js +7 -3
  121. package/lib/port-resolver.js +4 -4
  122. package/lib/progress.js +2 -2
  123. package/lib/prompt/index.js +5 -1
  124. package/lib/prompt/types/file-path.js +1 -1
  125. package/lib/pull/features/apig.js +9 -9
  126. package/lib/pull/features/client.js +7 -7
  127. package/lib/pull/features/functions/index.js +14 -14
  128. package/lib/pull/features/index.js +5 -1
  129. package/lib/pull/index.js +4 -4
  130. package/lib/repl-server.js +2 -2
  131. package/lib/serve/features/apig.js +1 -1
  132. package/lib/serve/features/index.js +8 -4
  133. package/lib/serve/index.js +15 -11
  134. package/lib/serve/server/index.js +34 -27
  135. package/lib/serve/server/lib/java/JavaaioServer.java +2 -1
  136. package/lib/serve/server/lib/java/lib/catalyst-cli-java-runtime-1.0.0.jar +0 -0
  137. package/lib/serve/server/lib/java/lib/catalyst-java-runtime-1.0.0.jar +0 -0
  138. package/lib/serve/server/lib/java/lib/zip4j-2.5.0.jar +0 -0
  139. package/lib/serve/server/lib/master.js +26 -15
  140. package/lib/serve/server/lib/node.js +7 -3
  141. package/lib/serve/server/lib/web_client/index.js +3 -3
  142. package/lib/serve/server/lib/web_client/server.js +17 -17
  143. package/lib/shell/dependencies/http-functions.js +38 -33
  144. package/lib/shell/dependencies/invoker/bio/java/JavabioInvoker.java +7 -2
  145. package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +7 -2
  146. package/lib/shell/dependencies/invoker/event/java/JavaeventInvoker.java +7 -2
  147. package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +7 -2
  148. package/lib/shell/dependencies/invoker/integ/node.js +8 -4
  149. package/lib/shell/dependencies/local-function.js +44 -40
  150. package/lib/shell/index.js +12 -12
  151. package/lib/shell/prepare/index.js +2 -2
  152. package/lib/shell/prepare/languages/index.js +5 -1
  153. package/lib/shell/prepare/languages/java.js +1 -1
  154. package/lib/throbber/index.js +17 -17
  155. package/lib/throbber/utils.js +9 -9
  156. package/lib/track.js +7 -7
  157. package/lib/util_modules/config/index.js +5 -1
  158. package/lib/util_modules/constants/lib/auth.js +6 -6
  159. package/lib/util_modules/constants/lib/cliq-handlers.js +2 -2
  160. package/lib/util_modules/constants/lib/template.js +21 -21
  161. package/lib/util_modules/constants/lib/urls.js +11 -11
  162. package/lib/util_modules/context-help.js +15 -15
  163. package/lib/util_modules/fs/index.js +5 -1
  164. package/lib/util_modules/fs/lib/async.js +4 -4
  165. package/lib/util_modules/fs/utils.js +1 -1
  166. package/lib/util_modules/logger.js +2 -2
  167. package/lib/util_modules/parser/toml.js +1 -1
  168. package/lib/util_modules/project.js +6 -6
  169. package/lib/util_modules/shell.js +4 -4
  170. package/lib/winston.js +5 -5
  171. package/package.json +39 -39
  172. package/scripts/postInstall.js +7 -6
  173. package/docs/.DS_Store +0 -0
  174. package/lib/serve/server/lib/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  175. package/templates/.DS_Store +0 -0
  176. package/templates/init/.DS_Store +0 -0
  177. package/templates/init/client/.DS_Store +0 -0
  178. package/templates/init/client/react/.DS_Store +0 -0
  179. package/templates/init/functions/node/integ/cliq/.DS_Store +0 -0
@@ -16,7 +16,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
16
16
  const path_1 = require("path");
17
17
  const fs_1 = require("../util_modules/fs");
18
18
  const runtime_store_1 = __importDefault(require("../runtime-store"));
19
- const pkg = fs_1.SYNC.readJSONFile(path_1.resolve(__dirname, '../../package.json'), {
19
+ const pkg = fs_1.SYNC.readJSONFile((0, path_1.resolve)(__dirname, '../../package.json'), {
20
20
  checkpath: true,
21
21
  throws: false
22
22
  });
@@ -34,15 +34,15 @@ const env_1 = require("../util_modules/env");
34
34
  const js_1 = require("../util_modules/js");
35
35
  const logger_1 = require("../util_modules/logger");
36
36
  const errorOut_1 = __importDefault(require("../errorOut"));
37
- logger_1.debug();
38
- logger_1.debug(js_1.JS.repeat('-', 70));
39
- logger_1.debug(ansi_colors_1.bold('Command: ') + process.argv.join(' '));
40
- logger_1.debug(ansi_colors_1.bold('CLI Version: ') + pkg.version);
41
- logger_1.debug(ansi_colors_1.bold('Platform: ') + process.platform);
42
- logger_1.debug(ansi_colors_1.bold('Node Version: ') + process.version);
43
- logger_1.debug(ansi_colors_1.bold('Time: ') + new Date().toString());
44
- logger_1.debug(js_1.JS.repeat('-', 70));
45
- logger_1.debug();
37
+ (0, logger_1.debug)();
38
+ (0, logger_1.debug)(js_1.JS.repeat('-', 70));
39
+ (0, logger_1.debug)((0, ansi_colors_1.bold)('Command: ') + process.argv.join(' '));
40
+ (0, logger_1.debug)((0, ansi_colors_1.bold)('CLI Version: ') + pkg.version);
41
+ (0, logger_1.debug)((0, ansi_colors_1.bold)('Platform: ') + process.platform);
42
+ (0, logger_1.debug)((0, ansi_colors_1.bold)('Node Version: ') + process.version);
43
+ (0, logger_1.debug)((0, ansi_colors_1.bold)('Time: ') + new Date().toString());
44
+ (0, logger_1.debug)(js_1.JS.repeat('-', 70));
45
+ (0, logger_1.debug)();
46
46
  process.on('beforeExit', (code) => __awaiter(void 0, void 0, void 0, function* () {
47
47
  code = process.exitCode || code;
48
48
  if (code > 0 && process.stdout.isTTY) {
@@ -53,7 +53,7 @@ process.on('beforeExit', (code) => __awaiter(void 0, void 0, void 0, function* (
53
53
  const cmd = yield cmdPromise;
54
54
  if (code === 1 && cmd) {
55
55
  const commandName = js_1.JS.get(js_1.JS.last(cmd.args), '_name', '[command]');
56
- help = 'Having trouble? Try ' + ansi_colors_1.bold('catalyst ' + commandName + ' --help');
56
+ help = 'Having trouble? Try ' + (0, ansi_colors_1.bold)('catalyst ' + commandName + ' --help');
57
57
  }
58
58
  else {
59
59
  help =
@@ -71,10 +71,10 @@ process.on('beforeExit', (code) => __awaiter(void 0, void 0, void 0, function* (
71
71
  process.exit(code);
72
72
  }));
73
73
  process.on('exit', (code) => {
74
- if (env_1.isPrimaryShell()) {
74
+ if ((0, env_1.isPrimaryShell)()) {
75
75
  fs_1.SYNC.deleteTempDir();
76
76
  }
77
- const logFile = path_1.join(process.cwd(), constants_1.FILENAME.log);
77
+ const logFile = (0, path_1.join)(process.cwd(), constants_1.FILENAME.log);
78
78
  if (code < 2 && fs_1.SYNC.fileExists(logFile)) {
79
79
  fs_1.SYNC.deleteFile(logFile);
80
80
  }
@@ -84,9 +84,9 @@ process.on('exit', (code) => {
84
84
  }).notify({ defer: false, isGlobal: true });
85
85
  });
86
86
  process.on('uncaughtException', (err) => {
87
- errorOut_1.default(err);
87
+ (0, errorOut_1.default)(err);
88
88
  });
89
89
  process.on('unhandledRejection', (reason, promise) => {
90
- errorOut_1.default(util_1.inspect(reason || promise));
90
+ (0, errorOut_1.default)((0, util_1.inspect)(reason || promise));
91
91
  });
92
92
  const cmdPromise = __1.default.processArgs(process.argv);
@@ -12,7 +12,7 @@ class Cell {
12
12
  }
13
13
  options = options || {};
14
14
  this.options = options;
15
- let content = options.content;
15
+ const content = options.content;
16
16
  if (['boolean', 'number', 'string'].indexOf(typeof content) !== -1) {
17
17
  this.content = String(content);
18
18
  }
@@ -27,15 +27,15 @@ class Cell {
27
27
  }
28
28
  mergeTableOptions(tableOptions, cells) {
29
29
  this.cells = cells;
30
- let optionsChars = this.options.chars || {};
31
- let tableChars = tableOptions.chars;
32
- let chars = (this.chars = {});
33
- CHAR_NAMES.forEach(function (name) {
30
+ const optionsChars = this.options.chars || {};
31
+ const tableChars = tableOptions.chars;
32
+ const chars = (this.chars = {});
33
+ CHAR_NAMES.forEach((name) => {
34
34
  setOption(optionsChars, tableChars, name, chars);
35
35
  });
36
36
  this.truncate = this.options.truncate || tableOptions.truncate;
37
- let style = (this.options.style = this.options.style || {});
38
- let tableStyle = tableOptions.style;
37
+ const style = (this.options.style = this.options.style || {});
38
+ const tableStyle = tableOptions.style;
39
39
  setOption(style, tableStyle, 'padding-left', this);
40
40
  setOption(style, tableStyle, 'padding-right', this);
41
41
  this.head = style.head || tableStyle.head;
@@ -59,8 +59,8 @@ class Cell {
59
59
  this.desiredHeight = this.lines.length;
60
60
  }
61
61
  init(tableOptions) {
62
- let x = this.x;
63
- let y = this.y;
62
+ const x = this.x;
63
+ const y = this.y;
64
64
  this.widths = tableOptions.colWidths.slice(x, x + this.colSpan);
65
65
  this.heights = tableOptions.rowHeights.slice(y, y + this.rowSpan);
66
66
  this.width = this.widths.reduce(sumPlusOne, -1);
@@ -76,7 +76,7 @@ class Cell {
76
76
  if (lineNum == 'bottom') {
77
77
  return this.drawBottom(this.drawRight);
78
78
  }
79
- let padLen = Math.max(this.height - this.lines.length, 0);
79
+ const padLen = Math.max(this.height - this.lines.length, 0);
80
80
  let padTop;
81
81
  switch (this.vAlign) {
82
82
  case 'center':
@@ -91,11 +91,11 @@ class Cell {
91
91
  if (lineNum < padTop || lineNum >= padTop + this.lines.length) {
92
92
  return this.drawEmpty(this.drawRight, spanningCell);
93
93
  }
94
- let forceTruncation = this.lines.length > this.height && lineNum + 1 >= this.height;
94
+ const forceTruncation = this.lines.length > this.height && lineNum + 1 >= this.height;
95
95
  return this.drawLine(lineNum - padTop, this.drawRight, forceTruncation, spanningCell);
96
96
  }
97
97
  drawTop(drawRight) {
98
- let content = [];
98
+ const content = [];
99
99
  if (this.cells) {
100
100
  this.widths.forEach(function (width, index) {
101
101
  content.push(this._topLeftChar(index));
@@ -112,7 +112,7 @@ class Cell {
112
112
  return this.wrapWithStyleColors('border', content.join(''));
113
113
  }
114
114
  _topLeftChar(offset) {
115
- let x = this.x + offset;
115
+ const x = this.x + offset;
116
116
  let leftChar;
117
117
  if (this.y == 0) {
118
118
  leftChar = x == 0 ? 'topLeft' : offset == 0 ? 'topMid' : 'top';
@@ -124,7 +124,7 @@ class Cell {
124
124
  else {
125
125
  leftChar = offset == 0 ? 'midMid' : 'bottomMid';
126
126
  if (this.cells) {
127
- let spanAbove = this.cells[this.y - 1][x] instanceof Cell.ColSpanCell;
127
+ const spanAbove = this.cells[this.y - 1][x] instanceof Cell.ColSpanCell;
128
128
  if (spanAbove) {
129
129
  leftChar = offset == 0 ? 'topMid' : 'mid';
130
130
  }
@@ -170,11 +170,11 @@ class Cell {
170
170
  left = this.chars.rightMid;
171
171
  }
172
172
  }
173
- let leftPadding = utils.repeat(' ', this.paddingLeft);
174
- let right = drawRight ? this.chars.right : '';
175
- let rightPadding = utils.repeat(' ', this.paddingRight);
173
+ const leftPadding = utils.repeat(' ', this.paddingLeft);
174
+ const right = drawRight ? this.chars.right : '';
175
+ const rightPadding = utils.repeat(' ', this.paddingRight);
176
176
  let line = this.lines[lineNum];
177
- let len = this.width - (this.paddingLeft + this.paddingRight);
177
+ const len = this.width - (this.paddingLeft + this.paddingRight);
178
178
  if (forceTruncationSymbol) {
179
179
  line += this.truncate || '…';
180
180
  }
@@ -192,9 +192,9 @@ class Cell {
192
192
  return left + content + right;
193
193
  }
194
194
  drawBottom(drawRight) {
195
- let left = this.chars[this.x == 0 ? 'bottomLeft' : 'bottomMid'];
196
- let content = utils.repeat(this.chars.bottom, this.width);
197
- let right = drawRight ? this.chars.bottomRight : '';
195
+ const left = this.chars[this.x == 0 ? 'bottomLeft' : 'bottomMid'];
196
+ const content = utils.repeat(this.chars.bottom, this.width);
197
+ const right = drawRight ? this.chars.bottomRight : '';
198
198
  return this.wrapWithStyleColors('border', left + content + right);
199
199
  }
200
200
  drawEmpty(drawRight, spanningCell) {
@@ -208,8 +208,8 @@ class Cell {
208
208
  left = this.chars.rightMid;
209
209
  }
210
210
  }
211
- let right = drawRight ? this.chars.right : '';
212
- let content = utils.repeat(' ', this.width);
211
+ const right = drawRight ? this.chars.right : '';
212
+ const content = utils.repeat(' ', this.width);
213
213
  return this.stylizeLine(left, content, right);
214
214
  }
215
215
  }
@@ -226,8 +226,8 @@ class RowSpanCell {
226
226
  this.originalCell = originalCell;
227
227
  }
228
228
  init(tableOptions) {
229
- let y = this.y;
230
- let originalY = this.originalCell.y;
229
+ const y = this.y;
230
+ const originalY = this.originalCell.y;
231
231
  this.cellOffset = y - originalY;
232
232
  this.offset = findDimension(tableOptions.rowHeights, originalY, this.cellOffset);
233
233
  }
@@ -263,7 +263,7 @@ function findDimension(dimensionTable, startingIndex, span) {
263
263
  function sumPlusOne(a, b) {
264
264
  return a + b + 1;
265
265
  }
266
- let CHAR_NAMES = [
266
+ const CHAR_NAMES = [
267
267
  'top',
268
268
  'top-mid',
269
269
  'top-left',
@@ -1,19 +1,18 @@
1
1
  "use strict";
2
- const objectAssign = require('object-assign');
3
2
  const Cell = require('./cell');
4
3
  const { ColSpanCell, RowSpanCell } = Cell;
5
4
  (function () {
6
5
  function layoutTable(table) {
7
- table.forEach(function (row, rowIndex) {
6
+ table.forEach((row, rowIndex) => {
8
7
  let prevCell = null;
9
- row.forEach(function (cell, columnIndex) {
8
+ row.forEach((cell, columnIndex) => {
10
9
  cell.y = rowIndex;
11
10
  cell.x = prevCell ? prevCell.x + 1 : columnIndex;
12
11
  for (let y = rowIndex; y >= 0; y--) {
13
- let row2 = table[y];
14
- let xMax = y === rowIndex ? columnIndex : row2.length;
12
+ const row2 = table[y];
13
+ const xMax = y === rowIndex ? columnIndex : row2.length;
15
14
  for (let x = 0; x < xMax; x++) {
16
- let cell2 = row2[x];
15
+ const cell2 = row2[x];
17
16
  while (cellsConflict(cell, cell2)) {
18
17
  cell.x++;
19
18
  }
@@ -25,8 +24,8 @@ const { ColSpanCell, RowSpanCell } = Cell;
25
24
  }
26
25
  function maxWidth(table) {
27
26
  let mw = 0;
28
- table.forEach(function (row) {
29
- row.forEach(function (cell) {
27
+ table.forEach((row) => {
28
+ row.forEach((cell) => {
30
29
  mw = Math.max(mw, cell.x + (cell.colSpan || 1));
31
30
  });
32
31
  });
@@ -36,23 +35,23 @@ const { ColSpanCell, RowSpanCell } = Cell;
36
35
  return table.length;
37
36
  }
38
37
  function cellsConflict(cell1, cell2) {
39
- let yMin1 = cell1.y;
40
- let yMax1 = cell1.y - 1 + (cell1.rowSpan || 1);
41
- let yMin2 = cell2.y;
42
- let yMax2 = cell2.y - 1 + (cell2.rowSpan || 1);
43
- let yConflict = !(yMin1 > yMax2 || yMin2 > yMax1);
44
- let xMin1 = cell1.x;
45
- let xMax1 = cell1.x - 1 + (cell1.colSpan || 1);
46
- let xMin2 = cell2.x;
47
- let xMax2 = cell2.x - 1 + (cell2.colSpan || 1);
48
- let xConflict = !(xMin1 > xMax2 || xMin2 > xMax1);
38
+ const yMin1 = cell1.y;
39
+ const yMax1 = cell1.y - 1 + (cell1.rowSpan || 1);
40
+ const yMin2 = cell2.y;
41
+ const yMax2 = cell2.y - 1 + (cell2.rowSpan || 1);
42
+ const yConflict = !(yMin1 > yMax2 || yMin2 > yMax1);
43
+ const xMin1 = cell1.x;
44
+ const xMax1 = cell1.x - 1 + (cell1.colSpan || 1);
45
+ const xMin2 = cell2.x;
46
+ const xMax2 = cell2.x - 1 + (cell2.colSpan || 1);
47
+ const xConflict = !(xMin1 > xMax2 || xMin2 > xMax1);
49
48
  return yConflict && xConflict;
50
49
  }
51
50
  function conflictExists(rows, x, y) {
52
- let i_max = Math.min(rows.length - 1, y);
53
- let cell = { x: x, y: y };
51
+ const i_max = Math.min(rows.length - 1, y);
52
+ const cell = { x: x, y: y };
54
53
  for (let i = 0; i <= i_max; i++) {
55
- let row = rows[i];
54
+ const row = rows[i];
56
55
  for (let j = 0; j < row.length; j++) {
57
56
  if (cellsConflict(cell, row[j])) {
58
57
  return true;
@@ -70,10 +69,10 @@ const { ColSpanCell, RowSpanCell } = Cell;
70
69
  return true;
71
70
  }
72
71
  function addRowSpanCells(table) {
73
- table.forEach(function (row, rowIndex) {
74
- row.forEach(function (cell) {
72
+ table.forEach((row, rowIndex) => {
73
+ row.forEach((cell) => {
75
74
  for (let i = 1; i < cell.rowSpan; i++) {
76
- let rowSpanCell = new RowSpanCell(cell);
75
+ const rowSpanCell = new RowSpanCell(cell);
77
76
  rowSpanCell.x = cell.x;
78
77
  rowSpanCell.y = cell.y + i;
79
78
  rowSpanCell.colSpan = cell.colSpan;
@@ -84,11 +83,11 @@ const { ColSpanCell, RowSpanCell } = Cell;
84
83
  }
85
84
  function addColSpanCells(cellRows) {
86
85
  for (let rowIndex = cellRows.length - 1; rowIndex >= 0; rowIndex--) {
87
- let cellColumns = cellRows[rowIndex];
86
+ const cellColumns = cellRows[rowIndex];
88
87
  for (let columnIndex = 0; columnIndex < cellColumns.length; columnIndex++) {
89
- let cell = cellColumns[columnIndex];
88
+ const cell = cellColumns[columnIndex];
90
89
  for (let k = 1; k < cell.colSpan; k++) {
91
- let colSpanCell = new ColSpanCell();
90
+ const colSpanCell = new ColSpanCell();
92
91
  colSpanCell.x = cell.x + k;
93
92
  colSpanCell.y = cell.y;
94
93
  cellColumns.splice(columnIndex + 1, 0, colSpanCell);
@@ -104,12 +103,12 @@ const { ColSpanCell, RowSpanCell } = Cell;
104
103
  row.splice(x, 0, cell);
105
104
  }
106
105
  function fillInTable(table) {
107
- let h_max = maxHeight(table);
108
- let w_max = maxWidth(table);
106
+ const h_max = maxHeight(table);
107
+ const w_max = maxWidth(table);
109
108
  for (let y = 0; y < h_max; y++) {
110
109
  for (let x = 0; x < w_max; x++) {
111
110
  if (!conflictExists(table, x, y)) {
112
- let opts = { x: x, y: y, colSpan: 1, rowSpan: 1 };
111
+ const opts = { x: x, y: y, colSpan: 1, rowSpan: 1 };
113
112
  x++;
114
113
  while (x < w_max && !conflictExists(table, x, y)) {
115
114
  opts.colSpan++;
@@ -120,7 +119,7 @@ const { ColSpanCell, RowSpanCell } = Cell;
120
119
  opts.rowSpan++;
121
120
  y2++;
122
121
  }
123
- let cell = new Cell(opts);
122
+ const cell = new Cell(opts);
124
123
  cell.x = opts.x;
125
124
  cell.y = opts.y;
126
125
  insertCell(cell, table[y]);
@@ -129,9 +128,9 @@ const { ColSpanCell, RowSpanCell } = Cell;
129
128
  }
130
129
  }
131
130
  function generateCells(rows) {
132
- return rows.map(function (row) {
131
+ return rows.map((row) => {
133
132
  if (!Array.isArray(row)) {
134
- let key = Object.keys(row)[0];
133
+ const key = Object.keys(row)[0];
135
134
  row = row[key];
136
135
  if (Array.isArray(row)) {
137
136
  row = row.slice();
@@ -141,13 +140,13 @@ const { ColSpanCell, RowSpanCell } = Cell;
141
140
  row = [key, row];
142
141
  }
143
142
  }
144
- return row.map(function (cell) {
143
+ return row.map((cell) => {
145
144
  return new Cell(cell);
146
145
  });
147
146
  });
148
147
  }
149
148
  function makeTableLayout(rows) {
150
- let cellRows = generateCells(rows);
149
+ const cellRows = generateCells(rows);
151
150
  layoutTable(cellRows);
152
151
  fillInTable(cellRows);
153
152
  addRowSpanCells(cellRows);
@@ -166,10 +165,10 @@ const { ColSpanCell, RowSpanCell } = Cell;
166
165
  })();
167
166
  function makeComputeWidths(colSpan, desiredWidth, x, forcedMin) {
168
167
  return function (vals, table) {
169
- let result = [];
170
- let spanners = [];
171
- table.forEach(function (row) {
172
- row.forEach(function (cell) {
168
+ const result = [];
169
+ const spanners = [];
170
+ table.forEach((row) => {
171
+ row.forEach((cell) => {
173
172
  if ((cell[colSpan] || 1) > 1) {
174
173
  spanners.push(cell);
175
174
  }
@@ -178,15 +177,15 @@ function makeComputeWidths(colSpan, desiredWidth, x, forcedMin) {
178
177
  }
179
178
  });
180
179
  });
181
- vals.forEach(function (val, index) {
180
+ vals.forEach((val, index) => {
182
181
  if (typeof val === 'number') {
183
182
  result[index] = val;
184
183
  }
185
184
  });
186
185
  for (let k = spanners.length - 1; k >= 0; k--) {
187
- let cell = spanners[k];
188
- let span = cell[colSpan];
189
- let col = cell[x];
186
+ const cell = spanners[k];
187
+ const span = cell[colSpan];
188
+ const col = cell[x];
190
189
  let existingWidth = result[col];
191
190
  let editableCols = typeof vals[col] === 'number' ? 0 : 1;
192
191
  for (let i = 1; i < span; i++) {
@@ -199,7 +198,7 @@ function makeComputeWidths(colSpan, desiredWidth, x, forcedMin) {
199
198
  let i = 0;
200
199
  while (editableCols > 0 && cell[desiredWidth] > existingWidth) {
201
200
  if (typeof vals[col + i] !== 'number') {
202
- let dif = Math.round((cell[desiredWidth] - existingWidth) / editableCols);
201
+ const dif = Math.round((cell[desiredWidth] - existingWidth) / editableCols);
203
202
  existingWidth += dif;
204
203
  result[col + i] += dif;
205
204
  editableCols--;
@@ -208,7 +207,7 @@ function makeComputeWidths(colSpan, desiredWidth, x, forcedMin) {
208
207
  }
209
208
  }
210
209
  }
211
- objectAssign(vals, result);
210
+ Object.assign(vals, result);
212
211
  for (let j = 0; j < vals.length; j++) {
213
212
  vals[j] = Math.max(forcedMin, vals[j] || 0);
214
213
  }
@@ -8,7 +8,7 @@ class Table extends Array {
8
8
  }
9
9
  toString() {
10
10
  let array = this;
11
- let headersPresent = this.options.head && this.options.head.length;
11
+ const headersPresent = this.options.head && this.options.head.length;
12
12
  if (headersPresent) {
13
13
  array = [this.options.head];
14
14
  if (this.length) {
@@ -18,7 +18,7 @@ class Table extends Array {
18
18
  else {
19
19
  this.options.style.head = [];
20
20
  }
21
- let cells = tableLayout.makeTableLayout(array);
21
+ const cells = tableLayout.makeTableLayout(array);
22
22
  cells.forEach(function (row) {
23
23
  row.forEach(function (cell) {
24
24
  cell.mergeTableOptions(this.options, cells);
@@ -31,10 +31,10 @@ class Table extends Array {
31
31
  cell.init(this.options);
32
32
  }, this);
33
33
  }, this);
34
- let result = [];
34
+ const result = [];
35
35
  for (let rowIndex = 0; rowIndex < cells.length; rowIndex++) {
36
- let row = cells[rowIndex];
37
- let heightOfRow = this.options.rowHeights[rowIndex];
36
+ const row = cells[rowIndex];
37
+ const heightOfRow = this.options.rowHeights[rowIndex];
38
38
  if (rowIndex === 0 ||
39
39
  !this.options.style.compact ||
40
40
  (rowIndex == 1 && headersPresent)) {
@@ -50,16 +50,16 @@ class Table extends Array {
50
50
  return result.join('\n');
51
51
  }
52
52
  get width() {
53
- let str = this.toString().split('\n');
53
+ const str = this.toString().split('\n');
54
54
  return str[0].length;
55
55
  }
56
56
  }
57
57
  function doDraw(row, lineNum, result) {
58
- let line = [];
59
- row.forEach(function (cell) {
58
+ const line = [];
59
+ row.forEach((cell) => {
60
60
  line.push(cell.draw(lineNum));
61
61
  });
62
- let str = line.join('');
62
+ const str = line.join('');
63
63
  if (str.length) {
64
64
  result.push(str);
65
65
  }
@@ -1,14 +1,13 @@
1
1
  "use strict";
2
- const objectAssign = require('object-assign');
3
2
  const stringWidth = require('string-width');
4
3
  function codeRegex(capture) {
5
4
  return capture ? /\u001b\[((?:\d*;){0,5}\d*)m/g : /\u001b\[(?:\d*;){0,5}\d*m/g;
6
5
  }
7
6
  function strlen(str) {
8
- let code = codeRegex();
9
- let stripped = ('' + str).replace(code, '');
10
- let split = stripped.split('\n');
11
- return split.reduce(function (memo, s) {
7
+ const code = codeRegex();
8
+ const stripped = ('' + str).replace(code, '');
9
+ const split = stripped.split('\n');
10
+ return split.reduce((memo, s) => {
12
11
  return stringWidth(s) > memo ? stringWidth(s) : memo;
13
12
  }, 0);
14
13
  }
@@ -16,17 +15,17 @@ function repeat(str, times) {
16
15
  return Array(times + 1).join(str);
17
16
  }
18
17
  function pad(str, len, pad, dir) {
19
- let length = strlen(str);
18
+ const length = strlen(str);
20
19
  if (len + 1 >= length) {
21
- let padlen = len - length;
20
+ const padlen = len - length;
22
21
  switch (dir) {
23
22
  case 'right': {
24
23
  str = repeat(pad, padlen) + str;
25
24
  break;
26
25
  }
27
26
  case 'center': {
28
- let right = Math.ceil(padlen / 2);
29
- let left = padlen - right;
27
+ const right = Math.ceil(padlen / 2);
28
+ const left = padlen - right;
30
29
  str = repeat(pad, left) + str + repeat(pad, right);
31
30
  break;
32
31
  }
@@ -38,7 +37,7 @@ function pad(str, len, pad, dir) {
38
37
  }
39
38
  return str;
40
39
  }
41
- let codeCache = {};
40
+ const codeCache = {};
42
41
  function addToCodeCache(name, on, off) {
43
42
  on = '\u001b[' + on + 'm';
44
43
  off = '\u001b[' + off + 'm';
@@ -52,7 +51,7 @@ addToCodeCache('underline', 4, 24);
52
51
  addToCodeCache('inverse', 7, 27);
53
52
  addToCodeCache('strikethrough', 9, 29);
54
53
  function updateState(state, controlChars) {
55
- let controlCode = controlChars[1] ? parseInt(controlChars[1].split(';')[0]) : 0;
54
+ const controlCode = controlChars[1] ? parseInt(controlChars[1].split(';')[0]) : 0;
56
55
  if ((controlCode >= 30 && controlCode <= 39) || (controlCode >= 90 && controlCode <= 97)) {
57
56
  state.lastForegroundAdded = controlChars[0];
58
57
  return;
@@ -62,22 +61,22 @@ function updateState(state, controlChars) {
62
61
  return;
63
62
  }
64
63
  if (controlCode === 0) {
65
- for (let i in state) {
64
+ for (const i in state) {
66
65
  if (Object.prototype.hasOwnProperty.call(state, i)) {
67
66
  delete state[i];
68
67
  }
69
68
  }
70
69
  return;
71
70
  }
72
- let info = codeCache[controlChars[0]];
71
+ const info = codeCache[controlChars[0]];
73
72
  if (info) {
74
73
  state[info.set] = info.to;
75
74
  }
76
75
  }
77
76
  function readState(line) {
78
- let code = codeRegex(true);
77
+ const code = codeRegex(true);
79
78
  let controlChars = code.exec(line);
80
- let state = {};
79
+ const state = {};
81
80
  while (controlChars !== null) {
82
81
  updateState(state, controlChars);
83
82
  controlChars = code.exec(line);
@@ -85,11 +84,11 @@ function readState(line) {
85
84
  return state;
86
85
  }
87
86
  function unwindState(state, ret) {
88
- let lastBackgroundAdded = state.lastBackgroundAdded;
89
- let lastForegroundAdded = state.lastForegroundAdded;
87
+ const lastBackgroundAdded = state.lastBackgroundAdded;
88
+ const lastForegroundAdded = state.lastForegroundAdded;
90
89
  delete state.lastBackgroundAdded;
91
90
  delete state.lastForegroundAdded;
92
- Object.keys(state).forEach(function (key) {
91
+ Object.keys(state).forEach((key) => {
93
92
  if (state[key]) {
94
93
  ret += codeCache[key].off;
95
94
  }
@@ -103,11 +102,11 @@ function unwindState(state, ret) {
103
102
  return ret;
104
103
  }
105
104
  function rewindState(state, ret) {
106
- let lastBackgroundAdded = state.lastBackgroundAdded;
107
- let lastForegroundAdded = state.lastForegroundAdded;
105
+ const lastBackgroundAdded = state.lastBackgroundAdded;
106
+ const lastForegroundAdded = state.lastForegroundAdded;
108
107
  delete state.lastBackgroundAdded;
109
108
  delete state.lastForegroundAdded;
110
- Object.keys(state).forEach(function (key) {
109
+ Object.keys(state).forEach((key) => {
111
110
  if (state[key]) {
112
111
  ret = codeCache[key].on + ret;
113
112
  }
@@ -130,13 +129,13 @@ function truncateWidth(str, desiredLength) {
130
129
  return str;
131
130
  }
132
131
  function truncateWidthWithAnsi(str, desiredLength) {
133
- let code = codeRegex(true);
134
- let split = str.split(codeRegex());
132
+ const code = codeRegex(true);
133
+ const split = str.split(codeRegex());
135
134
  let splitIndex = 0;
136
135
  let retLen = 0;
137
136
  let ret = '';
138
137
  let myArray;
139
- let state = {};
138
+ const state = {};
140
139
  while (retLen < desiredLength) {
141
140
  myArray = code.exec(str);
142
141
  let toAdd = split[splitIndex];
@@ -158,12 +157,12 @@ function truncateWidthWithAnsi(str, desiredLength) {
158
157
  }
159
158
  function truncate(str, desiredLength, truncateChar) {
160
159
  truncateChar = truncateChar || '…';
161
- let lengthOfStr = strlen(str);
160
+ const lengthOfStr = strlen(str);
162
161
  if (lengthOfStr <= desiredLength) {
163
162
  return str;
164
163
  }
165
164
  desiredLength -= strlen(truncateChar);
166
- let ret = truncateWidthWithAnsi(str, desiredLength);
165
+ const ret = truncateWidthWithAnsi(str, desiredLength);
167
166
  return ret + truncateChar;
168
167
  }
169
168
  function defaultOptions() {
@@ -203,19 +202,19 @@ function defaultOptions() {
203
202
  function mergeOptions(options, defaults) {
204
203
  options = options || {};
205
204
  defaults = defaults || defaultOptions();
206
- let ret = objectAssign({}, defaults, options);
207
- ret.chars = objectAssign({}, defaults.chars, options.chars);
208
- ret.style = objectAssign({}, defaults.style, options.style);
205
+ const ret = Object.assign({}, defaults, options);
206
+ ret.chars = Object.assign({}, defaults.chars, options.chars);
207
+ ret.style = Object.assign({}, defaults.style, options.style);
209
208
  return ret;
210
209
  }
211
210
  function wordWrap(maxLength, input) {
212
- let lines = [];
213
- let split = input.split(/(\s+)/g);
211
+ const lines = [];
212
+ const split = input.split(/(\s+)/g);
214
213
  let line = [];
215
214
  let lineLength = 0;
216
215
  let whitespace;
217
216
  for (let i = 0; i < split.length; i += 2) {
218
- let word = split[i];
217
+ const word = split[i];
219
218
  let newLength = lineLength + strlen(word);
220
219
  if (lineLength > 0 && whitespace) {
221
220
  newLength += whitespace.length;
@@ -239,7 +238,7 @@ function wordWrap(maxLength, input) {
239
238
  return lines;
240
239
  }
241
240
  function multiLineWordWrap(maxLength, input) {
242
- let output = [];
241
+ const output = [];
243
242
  input = input.split('\n');
244
243
  for (let i = 0; i < input.length; i++) {
245
244
  output.push.apply(output, wordWrap(maxLength, input[i]));
@@ -248,11 +247,11 @@ function multiLineWordWrap(maxLength, input) {
248
247
  }
249
248
  function colorizeLines(input) {
250
249
  let state = {};
251
- let output = [];
250
+ const output = [];
252
251
  for (let i = 0; i < input.length; i++) {
253
- let line = rewindState(state, input[i]);
252
+ const line = rewindState(state, input[i]);
254
253
  state = readState(line);
255
- let temp = objectAssign({}, state);
254
+ const temp = Object.assign({}, state);
256
255
  output.push(unwindState(temp, line));
257
256
  }
258
257
  return output;