contensis-cli 1.0.12-beta.1 → 1.0.12-beta.11

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 (61) hide show
  1. package/README.md +9 -9
  2. package/dist/commands/get.js +13 -1
  3. package/dist/commands/get.js.map +2 -2
  4. package/dist/commands/globalOptions.js +9 -10
  5. package/dist/commands/globalOptions.js.map +2 -2
  6. package/dist/commands/import.js +25 -10
  7. package/dist/commands/import.js.map +2 -2
  8. package/dist/commands/index.js +2 -2
  9. package/dist/commands/index.js.map +2 -2
  10. package/dist/commands/list.js +9 -0
  11. package/dist/commands/list.js.map +2 -2
  12. package/dist/commands/remove.js +13 -0
  13. package/dist/commands/remove.js.map +2 -2
  14. package/dist/localisation/en-GB.js +8 -2
  15. package/dist/localisation/en-GB.js.map +2 -2
  16. package/dist/mappers/DevInit-to-CIWorkflow.js +6 -8
  17. package/dist/mappers/DevInit-to-CIWorkflow.js.map +2 -2
  18. package/dist/mappers/DevInit-to-RolePermissions.js.map +2 -2
  19. package/dist/providers/file-provider.js +5 -1
  20. package/dist/providers/file-provider.js.map +2 -2
  21. package/dist/services/ContensisAuthService.js.map +2 -2
  22. package/dist/services/ContensisCliService.js +164 -75
  23. package/dist/services/ContensisCliService.js.map +3 -3
  24. package/dist/services/ContensisDevService.js +48 -53
  25. package/dist/services/ContensisDevService.js.map +3 -3
  26. package/dist/shell.js +5 -0
  27. package/dist/shell.js.map +2 -2
  28. package/dist/util/console.printer.js +111 -10
  29. package/dist/util/console.printer.js.map +2 -2
  30. package/dist/util/error.js +36 -0
  31. package/dist/util/error.js.map +7 -0
  32. package/dist/util/find.js +10 -2
  33. package/dist/util/find.js.map +2 -2
  34. package/dist/util/git.js +1 -0
  35. package/dist/util/git.js.map +2 -2
  36. package/dist/util/logger.js +52 -9
  37. package/dist/util/logger.js.map +3 -3
  38. package/dist/version.js +1 -1
  39. package/dist/version.js.map +1 -1
  40. package/package.json +4 -4
  41. package/src/commands/get.ts +19 -1
  42. package/src/commands/globalOptions.ts +9 -7
  43. package/src/commands/import.ts +41 -13
  44. package/src/commands/index.ts +2 -3
  45. package/src/commands/list.ts +15 -0
  46. package/src/commands/remove.ts +20 -0
  47. package/src/localisation/en-GB.ts +10 -3
  48. package/src/mappers/DevInit-to-CIWorkflow.ts +6 -8
  49. package/src/mappers/DevInit-to-RolePermissions.ts +1 -0
  50. package/src/models/Cache.d.ts +1 -1
  51. package/src/providers/file-provider.ts +5 -1
  52. package/src/services/ContensisAuthService.ts +1 -1
  53. package/src/services/ContensisCliService.ts +206 -101
  54. package/src/services/ContensisDevService.ts +70 -66
  55. package/src/shell.ts +5 -0
  56. package/src/util/console.printer.ts +238 -12
  57. package/src/util/error.ts +7 -0
  58. package/src/util/find.ts +13 -2
  59. package/src/util/git.ts +2 -1
  60. package/src/util/logger.ts +90 -15
  61. package/src/version.ts +1 -1
@@ -2,7 +2,12 @@
2
2
  import chalk from 'chalk';
3
3
  import dateFormat from 'dateformat';
4
4
  import deepCleaner from 'deep-cleaner';
5
- import { ansiEscapeCodes, first, strlen } from 'printable-characters';
5
+ import {
6
+ ansiEscapeCodes,
7
+ first,
8
+ partition,
9
+ strlen,
10
+ } from 'printable-characters';
6
11
  // import ProgressBar from 'progress';
7
12
  import { isSysError, tryStringify } from '.';
8
13
 
@@ -225,24 +230,41 @@ export class Logger {
225
230
  else console.log(content);
226
231
  };
227
232
 
228
- static limits = (content: string, displayLength = 30) => {
229
- const consoleWidth = process.stdout.columns;
230
- console.info(
231
- consoleWidth
232
- ? content
233
- .split('\n')
234
- .slice(0, consoleWidth ? displayLength : undefined)
235
- .map((line: string) =>
236
- consoleWidth && strlen(line) > consoleWidth
237
- ? first(line, consoleWidth)
238
- : line
233
+ static limits = (
234
+ content: string,
235
+ displayLength = 30,
236
+ consoleWidth = process.stdout.columns,
237
+ logMethod: Function = console.info
238
+ ) => {
239
+ if (consoleWidth) {
240
+ const contentArray = content.endsWith('\n')
241
+ ? content.split('\n').slice(0, -1)
242
+ : content.split('\n');
243
+ const contentLines = contentArray.slice(
244
+ 0,
245
+ consoleWidth ? displayLength : undefined
246
+ );
247
+ for (const line of contentLines)
248
+ logMethod(
249
+ line
250
+ .split('~n')
251
+ .map(l =>
252
+ consoleWidth && strlen(l) > consoleWidth
253
+ ? first(l, consoleWidth)
254
+ : l
239
255
  )
240
256
  .join('\n')
241
- : content.replace(ansiEscapeCodes, '')
242
- );
257
+ );
258
+ } else {
259
+ logMethod(content.replace(ansiEscapeCodes, '').replaceAll('~n', '\n'));
260
+ }
261
+
243
262
  const tableArray = content.split('\n');
244
263
  if (consoleWidth && tableArray.length > displayLength)
245
- console.info(`\n`, `- and ${tableArray.length - displayLength} more...`);
264
+ console.info(
265
+ `\n`,
266
+ `- and ${tableArray.length - displayLength} more...\n`
267
+ );
246
268
  };
247
269
  }
248
270
 
@@ -265,6 +287,59 @@ export const logError: LogErrorFunc = (
265
287
  return null;
266
288
  };
267
289
 
290
+ export const addNewLines = (
291
+ message = '',
292
+ newLineSeparater = '\n',
293
+ atPosition = process.stdout.columns
294
+ ) => {
295
+ if (message === '' || atPosition === 0) {
296
+ return '';
297
+ }
298
+
299
+ let result = '';
300
+ let lengthCounter = 0;
301
+
302
+ // Partition the message string into an array of
303
+ // [nonPrintable, printable][]
304
+ const partitioned = partition(message);
305
+ const addSeparater = () => {
306
+ // If line length counter has exceeded the console width
307
+ // add a new line separater and reset the line length counter
308
+ if (lengthCounter >= atPosition) {
309
+ result += newLineSeparater;
310
+ lengthCounter = 0;
311
+ }
312
+ };
313
+
314
+ // Loop through the partitioned message parts
315
+ for (const [nonPrintable, printable] of partitioned) {
316
+ // Convert string to array as this will provide accurate
317
+ // lengths and splicing methods with all unicode chars
318
+ const textParts = Array.from(printable);
319
+ // Splice the remaining allowable line length from the text parts array
320
+ const text = textParts.splice(0, atPosition - lengthCounter);
321
+ // In the first iteration append the non printable unicode chars
322
+ // to the beginning of the spliced text
323
+ result += nonPrintable + text.join('');
324
+ // Keep a count of the current line length
325
+ // as one line of output could span multiple "partitions"
326
+ lengthCounter += text.length;
327
+ addSeparater();
328
+
329
+ // Handle any remaining text in this "partition"
330
+ while (textParts.length) {
331
+ // Splice the remaining allowable line length from the text parts array
332
+ const text = textParts.splice(0, atPosition - lengthCounter);
333
+ // Append the spliced text to the result
334
+ result += text.join('');
335
+ // Increase line length counter
336
+ lengthCounter += text.length;
337
+ addSeparater();
338
+ }
339
+ }
340
+ return result;
341
+ };
342
+
268
343
  export const progress = {
269
344
  current: { interrupt: (x: string) => {} },
270
345
  active: false,
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const LIB_VERSION = "1.0.12-beta.1";
1
+ export const LIB_VERSION = "1.0.12-beta.11";