contensis-cli 1.3.1-beta.4 → 1.3.1-beta.6

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.
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var html_formatter_exports = {};
20
+ __export(html_formatter_exports, {
21
+ htmlFormatter: () => htmlFormatter
22
+ });
23
+ module.exports = __toCommonJS(html_formatter_exports);
24
+ var import_json = require("./json.formatter");
25
+ const htmlFormatter = (entries, isDoc = true) => {
26
+ const flatEntries = [];
27
+ if (Array.isArray(entries))
28
+ for (const entry of entries) {
29
+ flatEntries.push((0, import_json.flattenObject)(entry));
30
+ }
31
+ else flatEntries.push((0, import_json.flattenObject)(entries));
32
+ const columns = new Set(flatEntries.map((e) => Object.keys(e)).flat());
33
+ let table = `<table id="contensis-cli-table"><thead><tr>`;
34
+ for (const column of columns) {
35
+ table += `<td>${column}</td>`;
36
+ }
37
+ table += `</tr></thead><tbody>`;
38
+ for (const row of flatEntries) {
39
+ table += `<tr>`;
40
+ for (const column of columns) {
41
+ const val = row[column];
42
+ table += `<td>${typeof val === "undefined" ? "" : val}</td>`;
43
+ }
44
+ table += `</tr>`;
45
+ }
46
+ table += `</tbody></table>`;
47
+ if (isDoc)
48
+ table = `<html><head>${headTag()}</head><body>${table}${scriptTag()}</body></html>`;
49
+ return table;
50
+ };
51
+ const headTag = () => {
52
+ return `<link rel="stylesheet" href="https://cdn.datatables.net/2.1.8/css/dataTables.dataTables.css" />
53
+ <script
54
+ src="https://code.jquery.com/jquery-3.7.1.slim.min.js"
55
+ integrity="sha256-kmHvs0B+OpCW5GVHUNjv9rOmY0IvSIRcf7zGUDTDQM8="
56
+ crossorigin="anonymous"></script>
57
+ <script src="https://cdn.datatables.net/2.1.8/js/dataTables.js"></script>`;
58
+ };
59
+ const scriptTag = () => {
60
+ return `<script>
61
+ let table = new DataTable('#contensis-cli-table', {
62
+ pageLength: 50
63
+ });
64
+ </script>`;
65
+ };
66
+ // Annotate the CommonJS export names for ESM import in node:
67
+ 0 && (module.exports = {
68
+ htmlFormatter
69
+ });
70
+ //# sourceMappingURL=html.formatter.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/util/html.formatter.ts"],
4
+ "sourcesContent": ["import { flattenObject } from './json.formatter';\n\nexport const htmlFormatter = <T>(entries: T | T[], isDoc = true) => {\n // Flatten the passed in object\n const flatEntries = [] as any[];\n if (Array.isArray(entries))\n for (const entry of entries) {\n flatEntries.push(flattenObject(entry));\n }\n else flatEntries.push(flattenObject(entries));\n\n // Parse the flattened object to csv\n // const csv = stringify(flatEntries, { header: true });\n // Create an exhaustive list of columns from the entries array\n const columns = new Set<string>(flatEntries.map(e => Object.keys(e)).flat());\n\n let table = `<table id=\"contensis-cli-table\"><thead><tr>`;\n for (const column of columns) {\n table += `<td>${column}</td>`;\n }\n table += `</tr></thead><tbody>`;\n for (const row of flatEntries) {\n table += `<tr>`;\n for (const column of columns) {\n const val = row[column];\n table += `<td>${typeof val === 'undefined' ? '' : val}</td>`;\n }\n table += `</tr>`;\n }\n table += `</tbody></table>`;\n\n if (isDoc)\n table = `<html><head>${headTag()}</head><body>${table}${scriptTag()}</body></html>`;\n return table;\n};\n\nconst headTag = () => {\n return `<link rel=\"stylesheet\" href=\"https://cdn.datatables.net/2.1.8/css/dataTables.dataTables.css\" />\n<script\n src=\"https://code.jquery.com/jquery-3.7.1.slim.min.js\"\n integrity=\"sha256-kmHvs0B+OpCW5GVHUNjv9rOmY0IvSIRcf7zGUDTDQM8=\"\n crossorigin=\"anonymous\"></script>\n<script src=\"https://cdn.datatables.net/2.1.8/js/dataTables.js\"></script>`;\n};\n\nconst scriptTag = () => {\n return `<script>\nlet table = new DataTable('#contensis-cli-table', {\n pageLength: 50\n});\n</script>`;\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA8B;AAEvB,MAAM,gBAAgB,CAAI,SAAkB,QAAQ,SAAS;AAElE,QAAM,cAAc,CAAC;AACrB,MAAI,MAAM,QAAQ,OAAO;AACvB,eAAW,SAAS,SAAS;AAC3B,kBAAY,SAAK,2BAAc,KAAK,CAAC;AAAA,IACvC;AAAA,MACG,aAAY,SAAK,2BAAc,OAAO,CAAC;AAK5C,QAAM,UAAU,IAAI,IAAY,YAAY,IAAI,OAAK,OAAO,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;AAE3E,MAAI,QAAQ;AACZ,aAAW,UAAU,SAAS;AAC5B,aAAS,OAAO,MAAM;AAAA,EACxB;AACA,WAAS;AACT,aAAW,OAAO,aAAa;AAC7B,aAAS;AACT,eAAW,UAAU,SAAS;AAC5B,YAAM,MAAM,IAAI,MAAM;AACtB,eAAS,OAAO,OAAO,QAAQ,cAAc,KAAK,GAAG;AAAA,IACvD;AACA,aAAS;AAAA,EACX;AACA,WAAS;AAET,MAAI;AACF,YAAQ,eAAe,QAAQ,CAAC,gBAAgB,KAAK,GAAG,UAAU,CAAC;AACrE,SAAO;AACT;AAEA,MAAM,UAAU,MAAM;AACpB,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAMT;AAEA,MAAM,YAAY,MAAM;AACtB,SAAO;AAAA;AAAA;AAAA;AAAA;AAKT;",
6
+ "names": []
7
+ }
@@ -69,11 +69,10 @@ ${Logger.infoText(
69
69
  if (progress.active) progress.current.interrupt(message);
70
70
  else console.log(message);
71
71
  };
72
- static warning = (content) => {
72
+ static warning = (content, newline = "\n") => {
73
73
  const message = `${Logger.getPrefix()} ${Logger.warningText(
74
74
  `${Logger.isUserTerminal ? "\u26A0\uFE0F " : "[WARN]"} ${content}`
75
- )}
76
- `;
75
+ )}${newline}`;
77
76
  if (progress.active) progress.current.interrupt(message);
78
77
  else console.log(message);
79
78
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/util/logger.ts"],
4
- "sourcesContent": ["import chalk from 'chalk';\nimport dateFormat from 'dateformat';\nimport deepCleaner from 'deep-cleaner';\nimport {\n ansiEscapeCodes,\n first,\n partition,\n strlen,\n} from 'printable-characters';\n// import ProgressBar from 'progress';\nimport { isSysError, tryStringify } from '.';\n\ntype LogMethod = (content: string) => void;\ntype LogErrorMethod = (content: string, err?: any, newline?: string) => void;\ntype LogJsonMethod = (content: any, depth?: number, indent?: string) => void;\ntype LogJsonDepthMethod = (content: any, depth?: number) => void;\ntype LogArrayMethod = (contentArray: string[]) => void;\ntype LogErrorFunc = (\n err: any,\n msg?: string,\n level?: 'error' | 'critical'\n) => void;\n\nexport class Logger {\n static isUserTerminal = !!process.stdout.columns;\n static getPrefix = () => {\n return Logger.isUserTerminal\n ? Logger.infoText(`[cli]`)\n : `[${dateFormat(new Date(), 'dd/mm HH:MM:ss')}]`;\n };\n static errorText = chalk.bold.red;\n static warningText = chalk.keyword('orange');\n static successText = chalk.keyword('green');\n static helpText = chalk.blue;\n static highlightText = chalk.yellow;\n static infoText = chalk.keyword('grey');\n static standardText = chalk.keyword('white');\n static boldText = chalk.bold;\n static critical: LogMethod = content => {\n const message = `${Logger.getPrefix()} ${Logger.errorText(\n '[CRITICAL]'\n )} ${content}`;\n console.log(message);\n };\n static error: LogErrorMethod = (content, err, newline = '\\n') => {\n const message = `${Logger.getPrefix()} ${Logger.errorText(\n `${Logger.isUserTerminal ? '\u274C' : '[ERROR]'} ${content}${\n err\n ? `\\n\\n${Logger.infoText(\n isSysError(err) ? err.toString() : JSON.stringify(err, null, 2)\n )}`\n : ''\n }`\n )}${newline}`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n };\n static warning: LogMethod = content => {\n const message = `${Logger.getPrefix()} ${Logger.warningText(\n `${Logger.isUserTerminal ? '\u26A0\uFE0F ' : '[WARN]'} ${content}`\n )}\\n`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n // }\n };\n static success: LogMethod = content => {\n const message = `${Logger.getPrefix()} ${Logger.successText(\n `${Logger.isUserTerminal ? '\u2705' : '[OK]'} ${content}`\n )}`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n };\n static info: LogMethod = content => {\n const message = `${Logger.getPrefix()} ${\n Logger.isUserTerminal ? chalk.bgCyan(' \u2139 ') : '[INFO]'\n } ${Logger.infoText(content)}`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n };\n static help: LogMethod = content => {\n const message = `${Logger.getPrefix()} ${chalk.blue(\n `${Logger.isUserTerminal ? '\u23E9' : '[HELP]'} ${content}`\n )}\\n`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n };\n static standard: LogMethod = content => {\n const message = `${Logger.getPrefix()} ${\n Logger.isUserTerminal ? '\u25FB\uFE0F' : '[STD]'\n } \\n${Logger.standardText(content)}`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n progress.current.interrupt(message);\n };\n static debug: LogMethod = content => {\n if (['true', '1'].includes(process.env.debug || '')) {\n const message = `${Logger.getPrefix()} ${\n Logger.isUserTerminal ? chalk.bgGrey(' \u2699 ') : '[DEBUG]'\n } ${Logger.infoText(content)}`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n }\n };\n static json: LogJsonDepthMethod = (content, depth = 9) =>\n console.dir(deepCleaner(content), { colors: true, depth });\n static mixed: LogArrayMethod = contentArray =>\n console.log(`${Logger.getPrefix()} ${contentArray.join(' ')}`);\n static line = () =>\n Logger.raw(` ${Logger.infoText(`-------------------------------------`)}`);\n\n static object: LogJsonMethod = content => {\n for (const [key, value] of Object.entries(content || {})) {\n if (value && typeof value === 'object') {\n Logger.raw(` ${chalk.bold.grey(key)}:`);\n if (key === 'fields' && Array.isArray(value)) {\n for (const field of value || []) {\n Logger.raw(\n ` ${chalk.bold(field.id)}${\n field.id === content.entryTitleField\n ? '**'\n : field.validations.minCount?.value ||\n typeof field.validations.required?.message !== 'undefined'\n ? '*'\n : ''\n }: ${chalk.grey(\n `${field.dataType}${\n field.dataFormat\n ? `<${\n Array.isArray(\n field.validations.allowedFieldTypes?.fields\n )\n ? `composer[${field.validations.allowedFieldTypes.fields\n .map((f: any) => f.id)\n .join(' | ')}]`\n : field.dataFormat\n }${\n field.dataFormat === 'entry'\n ? `, ${field.validations.allowedContentTypes.contentTypes.join(\n ' | '\n )}`\n : ''\n }${\n field.dataFormat === 'contenttype'\n ? `[${field.validations?.allowedDataFormats.dataFormats.join(\n ' | '\n )}], ${(\n field.validations?.allowedIds?.ids || ['*']\n ).join(' | ')}`\n : ''\n }>`\n : ''\n }${\n field.validations.maxLength?.value\n ? `(${field.validations.maxLength.value})`\n : ''\n }`\n )}`\n );\n }\n } else if (key === 'groups' && Array.isArray(value)) {\n for (const group of value || []) {\n const description =\n Object.keys(group.description).length &&\n Object.values(group.description)?.[0];\n Logger.raw(\n ` ${chalk.bold(group.id)}${\n description\n ? `: ${chalk.grey(Object.values(group.description)?.[0])}`\n : ''\n }`\n );\n }\n } else {\n Logger.objectRecurse(value, 3, ' ');\n // for (const [innerkey, innervalue] of Object.entries(value)) {\n // if (innervalue && typeof innervalue === 'object') {\n // Logger.raw(` ${chalk.bold.grey(innerkey)}:`);\n // console.table(innervalue);\n // } else if (\n // typeof innervalue !== 'undefined' &&\n // innervalue !== null\n // ) {\n // Logger.raw(` ${chalk.bold.grey(innerkey)}: ${innervalue}`);\n // }\n // }\n }\n } else if (typeof value !== 'undefined' && value !== null) {\n const valueText =\n key === 'id' && typeof value === 'string'\n ? Logger.highlightText(value)\n : value;\n Logger.raw(` ${chalk.bold.grey(key)}: ${valueText}`);\n }\n }\n };\n\n static objectRecurse: LogJsonMethod = (content, depth = 3, indent = '') => {\n if (Array.isArray(content)) {\n for (const item of content) {\n if (item && typeof item === 'object') {\n if (Array.isArray(item) && depth > 3)\n if (item.length)\n Logger.raw(chalk.grey(`${indent} [${item.join(', ')}]`));\n else Logger.objectRecurse(item, depth + 1, `${indent} `);\n else {\n if (Array.isArray(item))\n Logger.raw(\n `${indent}${chalk.grey(`[`)}${item.join(', ')}${chalk.grey(\n `]`\n )}`\n );\n else if (typeof item === 'object' && item)\n Logger.objectRecurse(item, depth + 1, `${indent} `);\n else Logger.raw(`${indent}${item}`);\n }\n } else Logger.raw(`${indent}${item}`);\n }\n } else {\n let pos = 0;\n for (const [key, value] of Object.entries(content)) {\n if (key === 'stack') continue; // skip stack output for errors\n const thisIndent =\n pos === 0 ? `${indent.substring(0, indent.length - 2)}- ` : indent;\n if (Array.isArray(value)) {\n if (value.length) Logger.raw(`${thisIndent}${chalk.bold.grey(key)}:`);\n for (const item of value) {\n if (item && typeof item === 'object') {\n if (Array.isArray(item) && depth > 3)\n Logger.raw(chalk.grey(`${indent} [${item.join(', ')}]`));\n else Logger.objectRecurse(item, depth + 1, `${indent} `);\n } else {\n Logger.raw(`${indent} ${item}`);\n }\n }\n } else if (value && typeof value === 'object') {\n Logger.raw(`${indent}${chalk.bold.grey(key)}:`);\n\n Logger.objectRecurse(value, depth + 1, `${indent} `);\n // console.table(value);\n } else if (typeof value !== 'undefined' && value !== null) {\n Logger.raw(`${thisIndent}${chalk.bold.grey(key)}: ${value}`);\n }\n pos++;\n }\n }\n };\n static raw: LogMethod = (content: string) => {\n if (progress.active) progress.current.interrupt(content);\n else console.log(content);\n };\n\n static limits = (\n content: string,\n displayLength = 30,\n consoleWidth = process.stdout.columns,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n logMethod: Function = console.info\n ) => {\n if (consoleWidth) {\n const contentArray = content.endsWith('\\n')\n ? content.split('\\n').slice(0, -1)\n : content.split('\\n');\n const contentLines = contentArray.slice(\n 0,\n consoleWidth ? displayLength : undefined\n );\n for (const line of contentLines)\n logMethod(\n line\n .split('~n')\n .map(l =>\n consoleWidth && strlen(l) > consoleWidth\n ? first(l, consoleWidth)\n : l\n )\n .join('\\n')\n );\n } else {\n logMethod(content.replace(ansiEscapeCodes, '').replaceAll('~n', '\\n'));\n }\n\n const tableArray = content.split('\\n');\n if (consoleWidth && tableArray.length > displayLength)\n console.info(\n `\\n`,\n `- and ${tableArray.length - displayLength} more...\\n`\n );\n };\n}\n\nexport const logError: LogErrorFunc = (\n err = new Error('Undefined error'),\n msg,\n level = 'error'\n) => {\n Logger[level](msg || err.message || err?.data?.message || err.Message);\n (Array.isArray(err) ? err : [err]).map((error: AppError) => {\n if (typeof error === 'string') {\n Logger.raw(`${Logger.infoText(error)}\\n`);\n return;\n }\n if ('stack' in error) Logger.raw(` ${Logger.infoText(error.stack)}\\n`);\n if ('data' in error)\n Logger.raw(` ${Logger.infoText(tryStringify(error.data))}\\n`);\n });\n //Logger.line();\n return null;\n};\n\nexport const addNewLines = (\n message = '',\n newLineSeparater = '\\n',\n atPosition = process.stdout.columns\n) => {\n if (message === '' || atPosition === 0) {\n return '';\n }\n\n let result = '';\n let lengthCounter = 0;\n\n // Partition the message string into an array of\n // [nonPrintable, printable][]\n const partitioned = partition(message);\n const addSeparater = () => {\n // If line length counter has exceeded the console width\n // add a new line separater and reset the line length counter\n if (lengthCounter >= atPosition) {\n result += newLineSeparater;\n lengthCounter = 0;\n }\n };\n\n // Loop through the partitioned message parts\n for (const [nonPrintable, printable] of partitioned) {\n // Convert string to array as this will provide accurate\n // lengths and splicing methods with all unicode chars\n const textParts = Array.from(printable);\n // Splice the remaining allowable line length from the text parts array\n const text = textParts.splice(0, atPosition - lengthCounter);\n // In the first iteration append the non printable unicode chars\n // to the beginning of the spliced text\n result += nonPrintable + text.join('');\n // Keep a count of the current line length\n // as one line of output could span multiple \"partitions\"\n lengthCounter += text.length;\n addSeparater();\n\n // Handle any remaining text in this \"partition\"\n while (textParts.length) {\n // Splice the remaining allowable line length from the text parts array\n const text = textParts.splice(0, atPosition - lengthCounter);\n // Append the spliced text to the result\n result += text.join('');\n // Increase line length counter\n lengthCounter += text.length;\n addSeparater();\n }\n }\n return result;\n};\n\nexport const progress = {\n current: { interrupt: (x: string) => {} },\n active: false,\n // done: () => new ProgressBar('', 0),\n // colours: { green: '\\u001b[42m \\u001b[0m', red: '\\u001b[41m \\u001b[0m' },\n // current: new ProgressBar(`:bar`, {\n // complete: '=',\n // incomplete: ' ',\n // width: 20,\n // total: 100,\n // }),\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,wBAAuB;AACvB,0BAAwB;AACxB,kCAKO;AAEP,eAAyC;AAalC,MAAM,OAAO;AAAA,EAClB,OAAO,iBAAiB,CAAC,CAAC,QAAQ,OAAO;AAAA,EACzC,OAAO,YAAY,MAAM;AACvB,WAAO,OAAO,iBACV,OAAO,SAAS,OAAO,IACvB,QAAI,kBAAAA,SAAW,oBAAI,KAAK,GAAG,gBAAgB,CAAC;AAAA,EAClD;AAAA,EACA,OAAO,YAAY,aAAAC,QAAM,KAAK;AAAA,EAC9B,OAAO,cAAc,aAAAA,QAAM,QAAQ,QAAQ;AAAA,EAC3C,OAAO,cAAc,aAAAA,QAAM,QAAQ,OAAO;AAAA,EAC1C,OAAO,WAAW,aAAAA,QAAM;AAAA,EACxB,OAAO,gBAAgB,aAAAA,QAAM;AAAA,EAC7B,OAAO,WAAW,aAAAA,QAAM,QAAQ,MAAM;AAAA,E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;AAAA;AAAA;AAAA;AAAA;AASV;",
4
+ "sourcesContent": ["import chalk from 'chalk';\nimport dateFormat from 'dateformat';\nimport deepCleaner from 'deep-cleaner';\nimport {\n ansiEscapeCodes,\n first,\n partition,\n strlen,\n} from 'printable-characters';\n// import ProgressBar from 'progress';\nimport { isSysError, tryStringify } from '.';\n\ntype LogMethod = (content: string) => void;\ntype LogErrorMethod = (content: string, err?: any, newline?: string) => void;\ntype LogJsonMethod = (content: any, depth?: number, indent?: string) => void;\ntype LogJsonDepthMethod = (content: any, depth?: number) => void;\ntype LogArrayMethod = (contentArray: string[]) => void;\ntype LogErrorFunc = (\n err: any,\n msg?: string,\n level?: 'error' | 'critical'\n) => void;\n\nexport class Logger {\n static isUserTerminal = !!process.stdout.columns;\n static getPrefix = () => {\n return Logger.isUserTerminal\n ? Logger.infoText(`[cli]`)\n : `[${dateFormat(new Date(), 'dd/mm HH:MM:ss')}]`;\n };\n static errorText = chalk.bold.red;\n static warningText = chalk.keyword('orange');\n static successText = chalk.keyword('green');\n static helpText = chalk.blue;\n static highlightText = chalk.yellow;\n static infoText = chalk.keyword('grey');\n static standardText = chalk.keyword('white');\n static boldText = chalk.bold;\n static critical: LogMethod = content => {\n const message = `${Logger.getPrefix()} ${Logger.errorText(\n '[CRITICAL]'\n )} ${content}`;\n console.log(message);\n };\n static error: LogErrorMethod = (content, err, newline = '\\n') => {\n const message = `${Logger.getPrefix()} ${Logger.errorText(\n `${Logger.isUserTerminal ? '\u274C' : '[ERROR]'} ${content}${\n err\n ? `\\n\\n${Logger.infoText(\n isSysError(err) ? err.toString() : JSON.stringify(err, null, 2)\n )}`\n : ''\n }`\n )}${newline}`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n };\n static warning: LogMethod = (content, newline = '\\n') => {\n const message = `${Logger.getPrefix()} ${Logger.warningText(\n `${Logger.isUserTerminal ? '\u26A0\uFE0F ' : '[WARN]'} ${content}`\n )}${newline}`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n // }\n };\n static success: LogMethod = content => {\n const message = `${Logger.getPrefix()} ${Logger.successText(\n `${Logger.isUserTerminal ? '\u2705' : '[OK]'} ${content}`\n )}`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n };\n static info: LogMethod = content => {\n const message = `${Logger.getPrefix()} ${\n Logger.isUserTerminal ? chalk.bgCyan(' \u2139 ') : '[INFO]'\n } ${Logger.infoText(content)}`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n };\n static help: LogMethod = content => {\n const message = `${Logger.getPrefix()} ${chalk.blue(\n `${Logger.isUserTerminal ? '\u23E9' : '[HELP]'} ${content}`\n )}\\n`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n };\n static standard: LogMethod = content => {\n const message = `${Logger.getPrefix()} ${\n Logger.isUserTerminal ? '\u25FB\uFE0F' : '[STD]'\n } \\n${Logger.standardText(content)}`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n progress.current.interrupt(message);\n };\n static debug: LogMethod = content => {\n if (['true', '1'].includes(process.env.debug || '')) {\n const message = `${Logger.getPrefix()} ${\n Logger.isUserTerminal ? chalk.bgGrey(' \u2699 ') : '[DEBUG]'\n } ${Logger.infoText(content)}`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n }\n };\n static json: LogJsonDepthMethod = (content, depth = 9) =>\n console.dir(deepCleaner(content), { colors: true, depth });\n static mixed: LogArrayMethod = contentArray =>\n console.log(`${Logger.getPrefix()} ${contentArray.join(' ')}`);\n static line = () =>\n Logger.raw(` ${Logger.infoText(`-------------------------------------`)}`);\n\n static object: LogJsonMethod = content => {\n for (const [key, value] of Object.entries(content || {})) {\n if (value && typeof value === 'object') {\n Logger.raw(` ${chalk.bold.grey(key)}:`);\n if (key === 'fields' && Array.isArray(value)) {\n for (const field of value || []) {\n Logger.raw(\n ` ${chalk.bold(field.id)}${\n field.id === content.entryTitleField\n ? '**'\n : field.validations.minCount?.value ||\n typeof field.validations.required?.message !== 'undefined'\n ? '*'\n : ''\n }: ${chalk.grey(\n `${field.dataType}${\n field.dataFormat\n ? `<${\n Array.isArray(\n field.validations.allowedFieldTypes?.fields\n )\n ? `composer[${field.validations.allowedFieldTypes.fields\n .map((f: any) => f.id)\n .join(' | ')}]`\n : field.dataFormat\n }${\n field.dataFormat === 'entry'\n ? `, ${field.validations.allowedContentTypes.contentTypes.join(\n ' | '\n )}`\n : ''\n }${\n field.dataFormat === 'contenttype'\n ? `[${field.validations?.allowedDataFormats.dataFormats.join(\n ' | '\n )}], ${(\n field.validations?.allowedIds?.ids || ['*']\n ).join(' | ')}`\n : ''\n }>`\n : ''\n }${\n field.validations.maxLength?.value\n ? `(${field.validations.maxLength.value})`\n : ''\n }`\n )}`\n );\n }\n } else if (key === 'groups' && Array.isArray(value)) {\n for (const group of value || []) {\n const description =\n Object.keys(group.description).length &&\n Object.values(group.description)?.[0];\n Logger.raw(\n ` ${chalk.bold(group.id)}${\n description\n ? `: ${chalk.grey(Object.values(group.description)?.[0])}`\n : ''\n }`\n );\n }\n } else {\n Logger.objectRecurse(value, 3, ' ');\n // for (const [innerkey, innervalue] of Object.entries(value)) {\n // if (innervalue && typeof innervalue === 'object') {\n // Logger.raw(` ${chalk.bold.grey(innerkey)}:`);\n // console.table(innervalue);\n // } else if (\n // typeof innervalue !== 'undefined' &&\n // innervalue !== null\n // ) {\n // Logger.raw(` ${chalk.bold.grey(innerkey)}: ${innervalue}`);\n // }\n // }\n }\n } else if (typeof value !== 'undefined' && value !== null) {\n const valueText =\n key === 'id' && typeof value === 'string'\n ? Logger.highlightText(value)\n : value;\n Logger.raw(` ${chalk.bold.grey(key)}: ${valueText}`);\n }\n }\n };\n\n static objectRecurse: LogJsonMethod = (content, depth = 3, indent = '') => {\n if (Array.isArray(content)) {\n for (const item of content) {\n if (item && typeof item === 'object') {\n if (Array.isArray(item) && depth > 3)\n if (item.length)\n Logger.raw(chalk.grey(`${indent} [${item.join(', ')}]`));\n else Logger.objectRecurse(item, depth + 1, `${indent} `);\n else {\n if (Array.isArray(item))\n Logger.raw(\n `${indent}${chalk.grey(`[`)}${item.join(', ')}${chalk.grey(\n `]`\n )}`\n );\n else if (typeof item === 'object' && item)\n Logger.objectRecurse(item, depth + 1, `${indent} `);\n else Logger.raw(`${indent}${item}`);\n }\n } else Logger.raw(`${indent}${item}`);\n }\n } else {\n let pos = 0;\n for (const [key, value] of Object.entries(content)) {\n if (key === 'stack') continue; // skip stack output for errors\n const thisIndent =\n pos === 0 ? `${indent.substring(0, indent.length - 2)}- ` : indent;\n if (Array.isArray(value)) {\n if (value.length) Logger.raw(`${thisIndent}${chalk.bold.grey(key)}:`);\n for (const item of value) {\n if (item && typeof item === 'object') {\n if (Array.isArray(item) && depth > 3)\n Logger.raw(chalk.grey(`${indent} [${item.join(', ')}]`));\n else Logger.objectRecurse(item, depth + 1, `${indent} `);\n } else {\n Logger.raw(`${indent} ${item}`);\n }\n }\n } else if (value && typeof value === 'object') {\n Logger.raw(`${indent}${chalk.bold.grey(key)}:`);\n\n Logger.objectRecurse(value, depth + 1, `${indent} `);\n // console.table(value);\n } else if (typeof value !== 'undefined' && value !== null) {\n Logger.raw(`${thisIndent}${chalk.bold.grey(key)}: ${value}`);\n }\n pos++;\n }\n }\n };\n static raw: LogMethod = (content: string) => {\n if (progress.active) progress.current.interrupt(content);\n else console.log(content);\n };\n\n static limits = (\n content: string,\n displayLength = 30,\n consoleWidth = process.stdout.columns,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n logMethod: Function = console.info\n ) => {\n if (consoleWidth) {\n const contentArray = content.endsWith('\\n')\n ? content.split('\\n').slice(0, -1)\n : content.split('\\n');\n const contentLines = contentArray.slice(\n 0,\n consoleWidth ? displayLength : undefined\n );\n for (const line of contentLines)\n logMethod(\n line\n .split('~n')\n .map(l =>\n consoleWidth && strlen(l) > consoleWidth\n ? first(l, consoleWidth)\n : l\n )\n .join('\\n')\n );\n } else {\n logMethod(content.replace(ansiEscapeCodes, '').replaceAll('~n', '\\n'));\n }\n\n const tableArray = content.split('\\n');\n if (consoleWidth && tableArray.length > displayLength)\n console.info(\n `\\n`,\n `- and ${tableArray.length - displayLength} more...\\n`\n );\n };\n}\n\nexport const logError: LogErrorFunc = (\n err = new Error('Undefined error'),\n msg,\n level = 'error'\n) => {\n Logger[level](msg || err.message || err?.data?.message || err.Message);\n (Array.isArray(err) ? err : [err]).map((error: AppError) => {\n if (typeof error === 'string') {\n Logger.raw(`${Logger.infoText(error)}\\n`);\n return;\n }\n if ('stack' in error) Logger.raw(` ${Logger.infoText(error.stack)}\\n`);\n if ('data' in error)\n Logger.raw(` ${Logger.infoText(tryStringify(error.data))}\\n`);\n });\n //Logger.line();\n return null;\n};\n\nexport const addNewLines = (\n message = '',\n newLineSeparater = '\\n',\n atPosition = process.stdout.columns\n) => {\n if (message === '' || atPosition === 0) {\n return '';\n }\n\n let result = '';\n let lengthCounter = 0;\n\n // Partition the message string into an array of\n // [nonPrintable, printable][]\n const partitioned = partition(message);\n const addSeparater = () => {\n // If line length counter has exceeded the console width\n // add a new line separater and reset the line length counter\n if (lengthCounter >= atPosition) {\n result += newLineSeparater;\n lengthCounter = 0;\n }\n };\n\n // Loop through the partitioned message parts\n for (const [nonPrintable, printable] of partitioned) {\n // Convert string to array as this will provide accurate\n // lengths and splicing methods with all unicode chars\n const textParts = Array.from(printable);\n // Splice the remaining allowable line length from the text parts array\n const text = textParts.splice(0, atPosition - lengthCounter);\n // In the first iteration append the non printable unicode chars\n // to the beginning of the spliced text\n result += nonPrintable + text.join('');\n // Keep a count of the current line length\n // as one line of output could span multiple \"partitions\"\n lengthCounter += text.length;\n addSeparater();\n\n // Handle any remaining text in this \"partition\"\n while (textParts.length) {\n // Splice the remaining allowable line length from the text parts array\n const text = textParts.splice(0, atPosition - lengthCounter);\n // Append the spliced text to the result\n result += text.join('');\n // Increase line length counter\n lengthCounter += text.length;\n addSeparater();\n }\n }\n return result;\n};\n\nexport const progress = {\n current: { interrupt: (x: string) => {} },\n active: false,\n // done: () => new ProgressBar('', 0),\n // colours: { green: '\\u001b[42m \\u001b[0m', red: '\\u001b[41m \\u001b[0m' },\n // current: new ProgressBar(`:bar`, {\n // complete: '=',\n // incomplete: ' ',\n // width: 20,\n // total: 100,\n // }),\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,wBAAuB;AACvB,0BAAwB;AACxB,kCAKO;AAEP,eAAyC;AAalC,MAAM,OAAO;AAAA,EAClB,OAAO,iBAAiB,CAAC,CAAC,QAAQ,OAAO;AAAA,EACzC,OAAO,YAAY,MAAM;AACvB,WAAO,OAAO,iBACV,OAAO,SAAS,OAAO,IACvB,QAAI,kBAAAA,SAAW,oBAAI,KAAK,GAAG,gBAAgB,CAAC;AAAA,EAClD;AAAA,EACA,OAAO,YAAY,aAAAC,QAAM,KAAK;AAAA,EAC9B,OAAO,cAAc,aAAAA,QAAM,QAAQ,QAAQ;AAAA,EAC3C,OAAO,cAAc,aAAAA,QAAM,QAAQ,OAAO;AAAA,EAC1C,OAAO,WAAW,aAAAA,QAAM;AAAA,EACxB,OAAO,gBAAgB,aAAAA,QAAM;AAAA,EAC7B,OAAO,WAAW,aAAAA,QAAM,QAAQ,MAAM;AAAA,EACtC,OAAO,eAAe,aAAAA,QAAM,QAAQ,OAAO;AAAA,EAC3C,OAAO,WAAW,aAAAA,QAAM;AAAA,EACxB,OAAO,WAAsB,aAAW;AACtC,UAAM,UAAU,GAAG,OAAO,UAAU,CAAC,KAAK,OAAO;AAAA,MAC/C;AAAA,IACF,CAAC,IAAI,OAAO;AACZ,YAAQ,IAAI,OAAO;AAAA,EACrB;AAAA,EACA,OAAO,QAAwB,CAAC,SAAS,KAAK,UAAU,SAAS;AAC/D,UAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,OAAO;AAAA,MAC9C,GAAG,OAAO,iBAAiB,WAAM,SAAS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;AAAA,CAAI;AAAA,EACjE,CAAC;AAED,SAAO;AACT;AAEO,MAAM,cAAc,CACzB,UAAU,IACV,mBAAmB,MACnB,aAAa,QAAQ,OAAO,YACzB;AACH,MAAI,YAAY,MAAM,eAAe,GAAG;AACtC,WAAO;AAAA,EACT;AAEA,MAAI,SAAS;AACb,MAAI,gBAAgB;AAIpB,QAAM,kBAAc,uCAAU,OAAO;AACrC,QAAM,eAAe,MAAM;AAGzB,QAAI,iBAAiB,YAAY;AAC/B,gBAAU;AACV,sBAAgB;AAAA,IAClB;AAAA,EACF;AAGA,aAAW,CAAC,cAAc,SAAS,KAAK,aAAa;AAGnD,UAAM,YAAY,MAAM,KAAK,SAAS;AAEtC,UAAM,OAAO,UAAU,OAAO,GAAG,aAAa,aAAa;AAG3D,cAAU,eAAe,KAAK,KAAK,EAAE;AAGrC,qBAAiB,KAAK;AACtB,iBAAa;AAGb,WAAO,UAAU,QAAQ;AAEvB,YAAME,QAAO,UAAU,OAAO,GAAG,aAAa,aAAa;AAE3D,gBAAUA,MAAK,KAAK,EAAE;AAEtB,uBAAiBA,MAAK;AACtB,mBAAa;AAAA,IACf;AAAA,EACF;AACA,SAAO;AACT;AAEO,MAAM,WAAW;AAAA,EACtB,SAAS,EAAE,WAAW,CAAC,MAAc;AAAA,EAAC,EAAE;AAAA,EACxC,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASV;",
6
6
  "names": ["dateFormat", "chalk", "deepCleaner", "text"]
7
7
  }
package/dist/version.js CHANGED
@@ -21,7 +21,7 @@ __export(version_exports, {
21
21
  LIB_VERSION: () => LIB_VERSION
22
22
  });
23
23
  module.exports = __toCommonJS(version_exports);
24
- const LIB_VERSION = "1.3.1-beta.4";
24
+ const LIB_VERSION = "1.3.1-beta.6";
25
25
  // Annotate the CommonJS export names for ESM import in node:
26
26
  0 && (module.exports = {
27
27
  LIB_VERSION
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/version.ts"],
4
- "sourcesContent": ["export const LIB_VERSION = \"1.3.1-beta.4\";\n"],
4
+ "sourcesContent": ["export const LIB_VERSION = \"1.3.1-beta.6\";\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contensis-cli",
3
- "version": "1.3.1-beta.4",
3
+ "version": "1.3.1-beta.6",
4
4
  "description": "A fully featured Contensis command line interface with a shell UI provides simple and intuitive ways to manage or profile your content in any NodeJS terminal.",
5
5
  "repository": "https://github.com/contensis/cli",
6
6
  "homepage": "https://github.com/contensis/cli/tree/main/packages/contensis-cli#readme",
@@ -60,8 +60,8 @@ const output = new Option(
60
60
 
61
61
  const format = new Option(
62
62
  '-f --format <format>',
63
- 'format output as csv, json, xml or table (default)'
64
- ).choices(['csv', 'json', 'xml', 'table']);
63
+ 'format output as csv, json, html, xml or default'
64
+ ).choices(['csv', 'json', 'html', 'xml', 'table']);
65
65
 
66
66
  /* Connect options */
67
67
  const alias = new Option(
@@ -183,7 +183,7 @@ export const noCache = new Option(
183
183
 
184
184
  export const noPublish = new Option(
185
185
  '--no-publish',
186
- 'don\'t publish created or updated entries'
186
+ "don't publish created or updated entries"
187
187
  );
188
188
 
189
189
  export const addConnectOptions = (program: Command) =>
@@ -115,6 +115,8 @@ export const LogMessages = {
115
115
  `[${env}] Unable to update project ${Logger.highlightText(id)}`,
116
116
  },
117
117
  migrate: {
118
+ preview: () => `🔍 IMPORT PREVIEW 🔭`,
119
+ commit: () => `COMMITTING IMPORT ✨☄️ `,
118
120
  models: {
119
121
  result: (
120
122
  status: keyof MigrateModelsResult['project']['contentTypes']
@@ -9,7 +9,7 @@ export type CliUrls =
9
9
  }
10
10
  | undefined;
11
11
 
12
- export type OutputFormat = 'json' | 'csv' | 'xml';
12
+ export type OutputFormat = 'json' | 'csv' | 'html' | 'xml';
13
13
 
14
14
  export type OutputOptions = {
15
15
  format?: OutputFormat;
@@ -50,6 +50,7 @@ import {
50
50
  printNodesMigrateResult,
51
51
  } from '~/util/console.printer';
52
52
  import { csvFormatter } from '~/util/csv.formatter';
53
+ import { htmlFormatter } from '~/util/html.formatter';
53
54
  import { jsonFormatter, limitFields } from '~/util/json.formatter';
54
55
  import { xmlFormatter } from '~/util/xml.formatter';
55
56
  import { isDebug } from '~/util/debug';
@@ -1363,9 +1364,9 @@ class ContensisCli {
1363
1364
  if (contensis) {
1364
1365
  log.line();
1365
1366
  if (contensis.isPreview) {
1366
- console.log(log.successText(` -- IMPORT PREVIEW -- `));
1367
+ log.success(messages.migrate.preview());
1367
1368
  } else {
1368
- console.log(log.warningText(` *** COMMITTING IMPORT *** `));
1369
+ log.warning(messages.migrate.commit());
1369
1370
  }
1370
1371
 
1371
1372
  const [migrateErr, result] = await contensis.MigrateContentModels();
@@ -1877,9 +1878,9 @@ class ContensisCli {
1877
1878
  if (contensis) {
1878
1879
  log.line();
1879
1880
  if (contensis.isPreview) {
1880
- console.log(log.successText(` -- IMPORT PREVIEW -- `));
1881
+ log.success(messages.migrate.preview());
1881
1882
  } else {
1882
- console.log(log.warningText(` *** COMMITTING IMPORT *** `));
1883
+ log.warning(messages.migrate.commit());
1883
1884
  }
1884
1885
 
1885
1886
  const [err, result] = await contensis.MigrateEntries();
@@ -1973,9 +1974,9 @@ class ContensisCli {
1973
1974
  if (contensis) {
1974
1975
  log.line();
1975
1976
  if (contensis.isPreview) {
1976
- console.log(log.successText(` -- IMPORT PREVIEW -- `));
1977
+ log.success(messages.migrate.preview());
1977
1978
  } else {
1978
- console.log(log.warningText(` *** COMMITTING IMPORT *** `));
1979
+ log.warning(messages.migrate.commit());
1979
1980
  }
1980
1981
 
1981
1982
  const [err, result] = await to(
@@ -2080,9 +2081,9 @@ class ContensisCli {
2080
2081
  if (contensis) {
2081
2082
  log.line();
2082
2083
  if (contensis.isPreview) {
2083
- console.log(log.successText(` -- IMPORT PREVIEW -- `));
2084
+ log.success(messages.migrate.preview());
2084
2085
  } else {
2085
- console.log(log.warningText(` *** COMMITTING IMPORT *** `));
2086
+ log.warning(messages.migrate.commit());
2086
2087
  }
2087
2088
 
2088
2089
  const [err, result] = await contensis.MigrateNodes();
@@ -2764,6 +2765,9 @@ class ContensisCli {
2764
2765
  } else if (format === 'csv') {
2765
2766
  log.raw('');
2766
2767
  log.raw(log.infoText(await csvFormatter(limitFields(obj, fields))));
2768
+ } else if (format === 'html') {
2769
+ log.raw('');
2770
+ log.raw(log.infoText(htmlFormatter(limitFields(obj, fields))));
2767
2771
  } else if (format === 'xml') {
2768
2772
  log.raw('');
2769
2773
  log.raw(log.infoText(xmlFormatter(limitFields(obj, fields))));
@@ -2778,6 +2782,8 @@ class ContensisCli {
2778
2782
  const isText = !tryParse(obj) && typeof obj === 'string';
2779
2783
  if (format === 'csv') {
2780
2784
  writeString = await csvFormatter(limitFields(obj, fields));
2785
+ } else if (format === 'html') {
2786
+ writeString = htmlFormatter(limitFields(obj, fields));
2781
2787
  } else if (format === 'xml') {
2782
2788
  writeString = xmlFormatter(limitFields(obj, fields));
2783
2789
  } else
@@ -0,0 +1,52 @@
1
+ import { flattenObject } from './json.formatter';
2
+
3
+ export const htmlFormatter = <T>(entries: T | T[], isDoc = true) => {
4
+ // Flatten the passed in object
5
+ const flatEntries = [] as any[];
6
+ if (Array.isArray(entries))
7
+ for (const entry of entries) {
8
+ flatEntries.push(flattenObject(entry));
9
+ }
10
+ else flatEntries.push(flattenObject(entries));
11
+
12
+ // Parse the flattened object to csv
13
+ // const csv = stringify(flatEntries, { header: true });
14
+ // Create an exhaustive list of columns from the entries array
15
+ const columns = new Set<string>(flatEntries.map(e => Object.keys(e)).flat());
16
+
17
+ let table = `<table id="contensis-cli-table"><thead><tr>`;
18
+ for (const column of columns) {
19
+ table += `<td>${column}</td>`;
20
+ }
21
+ table += `</tr></thead><tbody>`;
22
+ for (const row of flatEntries) {
23
+ table += `<tr>`;
24
+ for (const column of columns) {
25
+ const val = row[column];
26
+ table += `<td>${typeof val === 'undefined' ? '' : val}</td>`;
27
+ }
28
+ table += `</tr>`;
29
+ }
30
+ table += `</tbody></table>`;
31
+
32
+ if (isDoc)
33
+ table = `<html><head>${headTag()}</head><body>${table}${scriptTag()}</body></html>`;
34
+ return table;
35
+ };
36
+
37
+ const headTag = () => {
38
+ return `<link rel="stylesheet" href="https://cdn.datatables.net/2.1.8/css/dataTables.dataTables.css" />
39
+ <script
40
+ src="https://code.jquery.com/jquery-3.7.1.slim.min.js"
41
+ integrity="sha256-kmHvs0B+OpCW5GVHUNjv9rOmY0IvSIRcf7zGUDTDQM8="
42
+ crossorigin="anonymous"></script>
43
+ <script src="https://cdn.datatables.net/2.1.8/js/dataTables.js"></script>`;
44
+ };
45
+
46
+ const scriptTag = () => {
47
+ return `<script>
48
+ let table = new DataTable('#contensis-cli-table', {
49
+ pageLength: 50
50
+ });
51
+ </script>`;
52
+ };
@@ -55,10 +55,10 @@ export class Logger {
55
55
  if (progress.active) progress.current.interrupt(message);
56
56
  else console.log(message);
57
57
  };
58
- static warning: LogMethod = content => {
58
+ static warning: LogMethod = (content, newline = '\n') => {
59
59
  const message = `${Logger.getPrefix()} ${Logger.warningText(
60
60
  `${Logger.isUserTerminal ? '⚠️ ' : '[WARN]'} ${content}`
61
- )}\n`;
61
+ )}${newline}`;
62
62
  if (progress.active) progress.current.interrupt(message);
63
63
  else console.log(message);
64
64
  // }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const LIB_VERSION = "1.3.1-beta.4";
1
+ export const LIB_VERSION = "1.3.1-beta.6";