@trayai/tray-sync-cli 0.0.6 → 0.0.8

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 (95) hide show
  1. package/README.md +20 -6
  2. package/dist/commands/env.js +15 -8
  3. package/dist/commands/promote.js +1 -1
  4. package/dist/views/env/env.v2.js +115 -0
  5. package/dist/views/icons.js +6 -0
  6. package/dist/views/promote/promote.v2.js +46 -0
  7. package/node_modules/@colors/colors/LICENSE +26 -0
  8. package/node_modules/@colors/colors/README.md +219 -0
  9. package/node_modules/@colors/colors/examples/normal-usage.js +83 -0
  10. package/node_modules/@colors/colors/examples/safe-string.js +80 -0
  11. package/node_modules/@colors/colors/index.d.ts +136 -0
  12. package/node_modules/@colors/colors/lib/colors.js +211 -0
  13. package/node_modules/@colors/colors/lib/custom/trap.js +46 -0
  14. package/node_modules/@colors/colors/lib/custom/zalgo.js +110 -0
  15. package/node_modules/@colors/colors/lib/extendStringPrototype.js +110 -0
  16. package/node_modules/@colors/colors/lib/index.js +13 -0
  17. package/node_modules/@colors/colors/lib/maps/america.js +10 -0
  18. package/node_modules/@colors/colors/lib/maps/rainbow.js +12 -0
  19. package/node_modules/@colors/colors/lib/maps/random.js +11 -0
  20. package/node_modules/@colors/colors/lib/maps/zebra.js +5 -0
  21. package/node_modules/@colors/colors/lib/styles.js +95 -0
  22. package/node_modules/@colors/colors/lib/system/has-flag.js +35 -0
  23. package/node_modules/@colors/colors/lib/system/supports-colors.js +151 -0
  24. package/node_modules/@colors/colors/package.json +45 -0
  25. package/node_modules/@colors/colors/safe.d.ts +48 -0
  26. package/node_modules/@colors/colors/safe.js +10 -0
  27. package/node_modules/@colors/colors/themes/generic-logging.js +12 -0
  28. package/node_modules/ansi-regex/index.d.ts +33 -0
  29. package/node_modules/ansi-regex/index.js +14 -0
  30. package/node_modules/ansi-regex/license +9 -0
  31. package/node_modules/ansi-regex/package.json +61 -0
  32. package/node_modules/ansi-regex/readme.md +66 -0
  33. package/node_modules/ansis/LICENSE +15 -0
  34. package/node_modules/ansis/README.md +5 -0
  35. package/node_modules/ansis/index.cjs +1 -0
  36. package/node_modules/ansis/index.d.ts +1 -0
  37. package/node_modules/ansis/index.mjs +1 -0
  38. package/node_modules/ansis/package.json +19 -0
  39. package/node_modules/cli-table3/LICENSE +21 -0
  40. package/node_modules/cli-table3/README.md +236 -0
  41. package/node_modules/cli-table3/index.d.ts +96 -0
  42. package/node_modules/cli-table3/index.js +1 -0
  43. package/node_modules/cli-table3/node_modules/ansi-regex/index.d.ts +37 -0
  44. package/node_modules/cli-table3/node_modules/ansi-regex/index.js +10 -0
  45. package/node_modules/cli-table3/node_modules/ansi-regex/license +9 -0
  46. package/node_modules/cli-table3/node_modules/ansi-regex/package.json +55 -0
  47. package/node_modules/cli-table3/node_modules/ansi-regex/readme.md +78 -0
  48. package/node_modules/cli-table3/node_modules/string-width/index.d.ts +29 -0
  49. package/node_modules/cli-table3/node_modules/string-width/index.js +47 -0
  50. package/node_modules/cli-table3/node_modules/string-width/license +9 -0
  51. package/node_modules/cli-table3/node_modules/string-width/package.json +56 -0
  52. package/node_modules/cli-table3/node_modules/string-width/readme.md +50 -0
  53. package/node_modules/cli-table3/node_modules/strip-ansi/index.d.ts +17 -0
  54. package/node_modules/cli-table3/node_modules/strip-ansi/index.js +4 -0
  55. package/node_modules/cli-table3/node_modules/strip-ansi/license +9 -0
  56. package/node_modules/cli-table3/node_modules/strip-ansi/package.json +54 -0
  57. package/node_modules/cli-table3/node_modules/strip-ansi/readme.md +46 -0
  58. package/node_modules/cli-table3/package.json +100 -0
  59. package/node_modules/cli-table3/src/cell.js +409 -0
  60. package/node_modules/cli-table3/src/debug.js +28 -0
  61. package/node_modules/cli-table3/src/layout-manager.js +254 -0
  62. package/node_modules/cli-table3/src/table.js +106 -0
  63. package/node_modules/cli-table3/src/utils.js +344 -0
  64. package/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
  65. package/node_modules/emoji-regex/README.md +73 -0
  66. package/node_modules/emoji-regex/es2015/index.js +6 -0
  67. package/node_modules/emoji-regex/es2015/text.js +6 -0
  68. package/node_modules/emoji-regex/index.d.ts +23 -0
  69. package/node_modules/emoji-regex/index.js +6 -0
  70. package/node_modules/emoji-regex/package.json +50 -0
  71. package/node_modules/emoji-regex/text.js +6 -0
  72. package/node_modules/get-east-asian-width/index.d.ts +60 -0
  73. package/node_modules/get-east-asian-width/index.js +30 -0
  74. package/node_modules/get-east-asian-width/license +9 -0
  75. package/node_modules/get-east-asian-width/lookup-data.js +21 -0
  76. package/node_modules/get-east-asian-width/lookup.js +138 -0
  77. package/node_modules/get-east-asian-width/package.json +71 -0
  78. package/node_modules/get-east-asian-width/readme.md +65 -0
  79. package/node_modules/get-east-asian-width/utilities.js +24 -0
  80. package/node_modules/is-fullwidth-code-point/index.d.ts +17 -0
  81. package/node_modules/is-fullwidth-code-point/index.js +50 -0
  82. package/node_modules/is-fullwidth-code-point/license +9 -0
  83. package/node_modules/is-fullwidth-code-point/package.json +42 -0
  84. package/node_modules/is-fullwidth-code-point/readme.md +39 -0
  85. package/node_modules/string-width/index.d.ts +39 -0
  86. package/node_modules/string-width/index.js +207 -0
  87. package/node_modules/string-width/license +9 -0
  88. package/node_modules/string-width/package.json +65 -0
  89. package/node_modules/string-width/readme.md +66 -0
  90. package/node_modules/strip-ansi/index.d.ts +15 -0
  91. package/node_modules/strip-ansi/index.js +19 -0
  92. package/node_modules/strip-ansi/license +9 -0
  93. package/node_modules/strip-ansi/package.json +59 -0
  94. package/node_modules/strip-ansi/readme.md +37 -0
  95. package/package.json +9 -2
@@ -0,0 +1,28 @@
1
+ let messages = [];
2
+ let level = 0;
3
+
4
+ const debug = (msg, min) => {
5
+ if (level >= min) {
6
+ messages.push(msg);
7
+ }
8
+ };
9
+
10
+ debug.WARN = 1;
11
+ debug.INFO = 2;
12
+ debug.DEBUG = 3;
13
+
14
+ debug.reset = () => {
15
+ messages = [];
16
+ };
17
+
18
+ debug.setDebugLevel = (v) => {
19
+ level = v;
20
+ };
21
+
22
+ debug.warn = (msg) => debug(msg, debug.WARN);
23
+ debug.info = (msg) => debug(msg, debug.INFO);
24
+ debug.debug = (msg) => debug(msg, debug.DEBUG);
25
+
26
+ debug.debugMessages = () => messages;
27
+
28
+ module.exports = debug;
@@ -0,0 +1,254 @@
1
+ const { warn, debug } = require('./debug');
2
+ const Cell = require('./cell');
3
+ const { ColSpanCell, RowSpanCell } = Cell;
4
+
5
+ (function () {
6
+ function next(alloc, col) {
7
+ if (alloc[col] > 0) {
8
+ return next(alloc, col + 1);
9
+ }
10
+ return col;
11
+ }
12
+
13
+ function layoutTable(table) {
14
+ let alloc = {};
15
+ table.forEach(function (row, rowIndex) {
16
+ let col = 0;
17
+ row.forEach(function (cell) {
18
+ cell.y = rowIndex;
19
+ // Avoid erroneous call to next() on first row
20
+ cell.x = rowIndex ? next(alloc, col) : col;
21
+ const rowSpan = cell.rowSpan || 1;
22
+ const colSpan = cell.colSpan || 1;
23
+ if (rowSpan > 1) {
24
+ for (let cs = 0; cs < colSpan; cs++) {
25
+ alloc[cell.x + cs] = rowSpan;
26
+ }
27
+ }
28
+ col = cell.x + colSpan;
29
+ });
30
+ Object.keys(alloc).forEach((idx) => {
31
+ alloc[idx]--;
32
+ if (alloc[idx] < 1) delete alloc[idx];
33
+ });
34
+ });
35
+ }
36
+
37
+ function maxWidth(table) {
38
+ let mw = 0;
39
+ table.forEach(function (row) {
40
+ row.forEach(function (cell) {
41
+ mw = Math.max(mw, cell.x + (cell.colSpan || 1));
42
+ });
43
+ });
44
+ return mw;
45
+ }
46
+
47
+ function maxHeight(table) {
48
+ return table.length;
49
+ }
50
+
51
+ function cellsConflict(cell1, cell2) {
52
+ let yMin1 = cell1.y;
53
+ let yMax1 = cell1.y - 1 + (cell1.rowSpan || 1);
54
+ let yMin2 = cell2.y;
55
+ let yMax2 = cell2.y - 1 + (cell2.rowSpan || 1);
56
+ let yConflict = !(yMin1 > yMax2 || yMin2 > yMax1);
57
+
58
+ let xMin1 = cell1.x;
59
+ let xMax1 = cell1.x - 1 + (cell1.colSpan || 1);
60
+ let xMin2 = cell2.x;
61
+ let xMax2 = cell2.x - 1 + (cell2.colSpan || 1);
62
+ let xConflict = !(xMin1 > xMax2 || xMin2 > xMax1);
63
+
64
+ return yConflict && xConflict;
65
+ }
66
+
67
+ function conflictExists(rows, x, y) {
68
+ let i_max = Math.min(rows.length - 1, y);
69
+ let cell = { x: x, y: y };
70
+ for (let i = 0; i <= i_max; i++) {
71
+ let row = rows[i];
72
+ for (let j = 0; j < row.length; j++) {
73
+ if (cellsConflict(cell, row[j])) {
74
+ return true;
75
+ }
76
+ }
77
+ }
78
+ return false;
79
+ }
80
+
81
+ function allBlank(rows, y, xMin, xMax) {
82
+ for (let x = xMin; x < xMax; x++) {
83
+ if (conflictExists(rows, x, y)) {
84
+ return false;
85
+ }
86
+ }
87
+ return true;
88
+ }
89
+
90
+ function addRowSpanCells(table) {
91
+ table.forEach(function (row, rowIndex) {
92
+ row.forEach(function (cell) {
93
+ for (let i = 1; i < cell.rowSpan; i++) {
94
+ let rowSpanCell = new RowSpanCell(cell);
95
+ rowSpanCell.x = cell.x;
96
+ rowSpanCell.y = cell.y + i;
97
+ rowSpanCell.colSpan = cell.colSpan;
98
+ insertCell(rowSpanCell, table[rowIndex + i]);
99
+ }
100
+ });
101
+ });
102
+ }
103
+
104
+ function addColSpanCells(cellRows) {
105
+ for (let rowIndex = cellRows.length - 1; rowIndex >= 0; rowIndex--) {
106
+ let cellColumns = cellRows[rowIndex];
107
+ for (let columnIndex = 0; columnIndex < cellColumns.length; columnIndex++) {
108
+ let cell = cellColumns[columnIndex];
109
+ for (let k = 1; k < cell.colSpan; k++) {
110
+ let colSpanCell = new ColSpanCell();
111
+ colSpanCell.x = cell.x + k;
112
+ colSpanCell.y = cell.y;
113
+ cellColumns.splice(columnIndex + 1, 0, colSpanCell);
114
+ }
115
+ }
116
+ }
117
+ }
118
+
119
+ function insertCell(cell, row) {
120
+ let x = 0;
121
+ while (x < row.length && row[x].x < cell.x) {
122
+ x++;
123
+ }
124
+ row.splice(x, 0, cell);
125
+ }
126
+
127
+ function fillInTable(table) {
128
+ let h_max = maxHeight(table);
129
+ let w_max = maxWidth(table);
130
+ debug(`Max rows: ${h_max}; Max cols: ${w_max}`);
131
+ for (let y = 0; y < h_max; y++) {
132
+ for (let x = 0; x < w_max; x++) {
133
+ if (!conflictExists(table, x, y)) {
134
+ let opts = { x: x, y: y, colSpan: 1, rowSpan: 1 };
135
+ x++;
136
+ while (x < w_max && !conflictExists(table, x, y)) {
137
+ opts.colSpan++;
138
+ x++;
139
+ }
140
+ let y2 = y + 1;
141
+ while (y2 < h_max && allBlank(table, y2, opts.x, opts.x + opts.colSpan)) {
142
+ opts.rowSpan++;
143
+ y2++;
144
+ }
145
+ let cell = new Cell(opts);
146
+ cell.x = opts.x;
147
+ cell.y = opts.y;
148
+ warn(`Missing cell at ${cell.y}-${cell.x}.`);
149
+ insertCell(cell, table[y]);
150
+ }
151
+ }
152
+ }
153
+ }
154
+
155
+ function generateCells(rows) {
156
+ return rows.map(function (row) {
157
+ if (!Array.isArray(row)) {
158
+ let key = Object.keys(row)[0];
159
+ row = row[key];
160
+ if (Array.isArray(row)) {
161
+ row = row.slice();
162
+ row.unshift(key);
163
+ } else {
164
+ row = [key, row];
165
+ }
166
+ }
167
+ return row.map(function (cell) {
168
+ return new Cell(cell);
169
+ });
170
+ });
171
+ }
172
+
173
+ function makeTableLayout(rows) {
174
+ let cellRows = generateCells(rows);
175
+ layoutTable(cellRows);
176
+ fillInTable(cellRows);
177
+ addRowSpanCells(cellRows);
178
+ addColSpanCells(cellRows);
179
+ return cellRows;
180
+ }
181
+
182
+ module.exports = {
183
+ makeTableLayout: makeTableLayout,
184
+ layoutTable: layoutTable,
185
+ addRowSpanCells: addRowSpanCells,
186
+ maxWidth: maxWidth,
187
+ fillInTable: fillInTable,
188
+ computeWidths: makeComputeWidths('colSpan', 'desiredWidth', 'x', 1),
189
+ computeHeights: makeComputeWidths('rowSpan', 'desiredHeight', 'y', 1),
190
+ };
191
+ })();
192
+
193
+ function makeComputeWidths(colSpan, desiredWidth, x, forcedMin) {
194
+ return function (vals, table) {
195
+ let result = [];
196
+ let spanners = [];
197
+ let auto = {};
198
+ table.forEach(function (row) {
199
+ row.forEach(function (cell) {
200
+ if ((cell[colSpan] || 1) > 1) {
201
+ spanners.push(cell);
202
+ } else {
203
+ result[cell[x]] = Math.max(result[cell[x]] || 0, cell[desiredWidth] || 0, forcedMin);
204
+ }
205
+ });
206
+ });
207
+
208
+ vals.forEach(function (val, index) {
209
+ if (typeof val === 'number') {
210
+ result[index] = val;
211
+ }
212
+ });
213
+
214
+ //spanners.forEach(function(cell){
215
+ for (let k = spanners.length - 1; k >= 0; k--) {
216
+ let cell = spanners[k];
217
+ let span = cell[colSpan];
218
+ let col = cell[x];
219
+ let existingWidth = result[col];
220
+ let editableCols = typeof vals[col] === 'number' ? 0 : 1;
221
+ if (typeof existingWidth === 'number') {
222
+ for (let i = 1; i < span; i++) {
223
+ existingWidth += 1 + result[col + i];
224
+ if (typeof vals[col + i] !== 'number') {
225
+ editableCols++;
226
+ }
227
+ }
228
+ } else {
229
+ existingWidth = desiredWidth === 'desiredWidth' ? cell.desiredWidth - 1 : 1;
230
+ if (!auto[col] || auto[col] < existingWidth) {
231
+ auto[col] = existingWidth;
232
+ }
233
+ }
234
+
235
+ if (cell[desiredWidth] > existingWidth) {
236
+ let i = 0;
237
+ while (editableCols > 0 && cell[desiredWidth] > existingWidth) {
238
+ if (typeof vals[col + i] !== 'number') {
239
+ let dif = Math.round((cell[desiredWidth] - existingWidth) / editableCols);
240
+ existingWidth += dif;
241
+ result[col + i] += dif;
242
+ editableCols--;
243
+ }
244
+ i++;
245
+ }
246
+ }
247
+ }
248
+
249
+ Object.assign(vals, result, auto);
250
+ for (let j = 0; j < vals.length; j++) {
251
+ vals[j] = Math.max(forcedMin, vals[j] || 0);
252
+ }
253
+ };
254
+ }
@@ -0,0 +1,106 @@
1
+ const debug = require('./debug');
2
+ const utils = require('./utils');
3
+ const tableLayout = require('./layout-manager');
4
+
5
+ class Table extends Array {
6
+ constructor(opts) {
7
+ super();
8
+
9
+ const options = utils.mergeOptions(opts);
10
+ Object.defineProperty(this, 'options', {
11
+ value: options,
12
+ enumerable: options.debug,
13
+ });
14
+
15
+ if (options.debug) {
16
+ switch (typeof options.debug) {
17
+ case 'boolean':
18
+ debug.setDebugLevel(debug.WARN);
19
+ break;
20
+ case 'number':
21
+ debug.setDebugLevel(options.debug);
22
+ break;
23
+ case 'string':
24
+ debug.setDebugLevel(parseInt(options.debug, 10));
25
+ break;
26
+ default:
27
+ debug.setDebugLevel(debug.WARN);
28
+ debug.warn(`Debug option is expected to be boolean, number, or string. Received a ${typeof options.debug}`);
29
+ }
30
+ Object.defineProperty(this, 'messages', {
31
+ get() {
32
+ return debug.debugMessages();
33
+ },
34
+ });
35
+ }
36
+ }
37
+
38
+ toString() {
39
+ let array = this;
40
+ let headersPresent = this.options.head && this.options.head.length;
41
+ if (headersPresent) {
42
+ array = [this.options.head];
43
+ if (this.length) {
44
+ array.push.apply(array, this);
45
+ }
46
+ } else {
47
+ this.options.style.head = [];
48
+ }
49
+
50
+ let cells = tableLayout.makeTableLayout(array);
51
+
52
+ cells.forEach(function (row) {
53
+ row.forEach(function (cell) {
54
+ cell.mergeTableOptions(this.options, cells);
55
+ }, this);
56
+ }, this);
57
+
58
+ tableLayout.computeWidths(this.options.colWidths, cells);
59
+ tableLayout.computeHeights(this.options.rowHeights, cells);
60
+
61
+ cells.forEach(function (row) {
62
+ row.forEach(function (cell) {
63
+ cell.init(this.options);
64
+ }, this);
65
+ }, this);
66
+
67
+ let result = [];
68
+
69
+ for (let rowIndex = 0; rowIndex < cells.length; rowIndex++) {
70
+ let row = cells[rowIndex];
71
+ let heightOfRow = this.options.rowHeights[rowIndex];
72
+
73
+ if (rowIndex === 0 || !this.options.style.compact || (rowIndex == 1 && headersPresent)) {
74
+ doDraw(row, 'top', result);
75
+ }
76
+
77
+ for (let lineNum = 0; lineNum < heightOfRow; lineNum++) {
78
+ doDraw(row, lineNum, result);
79
+ }
80
+
81
+ if (rowIndex + 1 == cells.length) {
82
+ doDraw(row, 'bottom', result);
83
+ }
84
+ }
85
+
86
+ return result.join('\n');
87
+ }
88
+
89
+ get width() {
90
+ let str = this.toString().split('\n');
91
+ return str[0].length;
92
+ }
93
+ }
94
+
95
+ Table.reset = () => debug.reset();
96
+
97
+ function doDraw(row, lineNum, result) {
98
+ let line = [];
99
+ row.forEach(function (cell) {
100
+ line.push(cell.draw(lineNum));
101
+ });
102
+ let str = line.join('');
103
+ if (str.length) result.push(str);
104
+ }
105
+
106
+ module.exports = Table;