contensis-cli 1.2.1 → 1.2.2-beta.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.
- package/README.md +1 -1
- package/dist/commands/copy.js +2 -5
- package/dist/commands/copy.js.map +2 -2
- package/dist/commands/diff.js +4 -4
- package/dist/commands/diff.js.map +2 -2
- package/dist/commands/get.js +4 -3
- package/dist/commands/get.js.map +2 -2
- package/dist/commands/globalOptions.js +13 -3
- package/dist/commands/globalOptions.js.map +2 -2
- package/dist/commands/import.js +8 -9
- package/dist/commands/import.js.map +2 -2
- package/dist/commands/index.js +3 -3
- package/dist/commands/index.js.map +2 -2
- package/dist/commands/list.js +7 -2
- package/dist/commands/list.js.map +2 -2
- package/dist/services/ContensisCliService.js +21 -8
- package/dist/services/ContensisCliService.js.map +2 -2
- package/dist/util/logger.js +4 -3
- package/dist/util/logger.js.map +2 -2
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +2 -2
- package/src/commands/copy.ts +4 -4
- package/src/commands/diff.ts +5 -4
- package/src/commands/get.ts +6 -2
- package/src/commands/globalOptions.ts +15 -11
- package/src/commands/import.ts +21 -10
- package/src/commands/index.ts +3 -3
- package/src/commands/list.ts +7 -1
- package/src/services/ContensisCliService.ts +23 -4
- package/src/util/logger.ts +3 -2
- package/src/version.ts +1 -1
package/dist/util/logger.js
CHANGED
|
@@ -162,9 +162,10 @@ ${Logger.standardText(content)}`;
|
|
|
162
162
|
for (const item of content) {
|
|
163
163
|
if (item && typeof item === "object") {
|
|
164
164
|
if (Array.isArray(item) && depth > 3)
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
if (item.length)
|
|
166
|
+
Logger.raw(import_chalk.default.grey(`${indent} [${item.join(", ")}]`));
|
|
167
|
+
else
|
|
168
|
+
Logger.objectRecurse(item, depth + 1, `${indent} `);
|
|
168
169
|
} else
|
|
169
170
|
Logger.raw(`${indent}${item}`);
|
|
170
171
|
}
|
package/dist/util/logger.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/util/logger.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable no-console */\nimport 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 : ''\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 Logger.raw(chalk.grey(`${indent} [${item.join(', ')}]`));\n else Logger.objectRecurse(item, depth + 1, `${indent} `);\n } else Logger.raw(`${indent}${item}`);\n }\n } else {\n let pos = 0;\n for (const [key, value] of Object.entries(content)) {\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 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;AACA,m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OACb,MAAM,aAEV,MAAM,eAAe,UACjB,KAAK,MAAM,YAAY,oBAAoB,aAAa;AAAA,kBACtD;AAAA,gBACF,MACA,QAEN,OAEJ,WAAM,YAAY,cAAlB,mBAA6B,SACzB,IAAI,MAAM,YAAY,UAAU,WAChC;AAAA,cAER;AAAA,YACF;AAAA,UACF;AAAA,QACF,WAAW,QAAQ,YAAY,MAAM,QAAQ,KAAK,GAAG;AACnD,qBAAW,SAAS,SAAS,CAAC,GAAG;AAC/B,kBAAM,cACJ,OAAO,KAAK,MAAM,WAAW,EAAE,YAC/B,YAAO,OAAO,MAAM,WAAW,MAA/B,mBAAmC;AACrC,mBAAO;AAAA,cACL,OAAO,aAAAA,QAAM,KAAK,MAAM,EAAE,IACxB,cACI,KAAK,aAAAA,QAAM,MAAK,YAAO,OAAO,MAAM,WAAW,MAA/B,mBAAmC,EAAE,MACrD;AAAA,YAER;AAAA,UACF;AAAA,QACF,OAAO;AACL,iBAAO,cAAc,OAAO,GAAG,MAAM;AAAA,QAYvC;AAAA,MACF,WAAW,OAAO,UAAU,eAAe,UAAU,MAAM;AACzD,cAAM,YACJ,QAAQ,QAAQ,OAAO,UAAU,WAC7B,OAAO,cAAc,KAAK,IAC1B;AACN,eAAO,IAAI,KAAK,aAAAA,QAAM,KAAK,KAAK,GAAG,MAAM,WAAW;AAAA,MACtD;AAAA,IACF;AAAA,EACF;AAAA,EAEA,OAAO,gBAA+B,CAAC,SAAS,QAAQ,GAAG,SAAS,OAAO;AACzE,QAAI,MAAM,QAAQ,OAAO,GAAG;AAC1B,iBAAW,QAAQ,SAAS;AAC1B,YAAI,QAAQ,OAAO,SAAS,UAAU;AACpC,cAAI,MAAM,QAAQ,IAAI,KAAK,QAAQ;AACjC,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable no-console */\nimport 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 : ''\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 Logger.raw(`${indent}${item}`);\n }\n } else {\n let pos = 0;\n for (const [key, value] of Object.entries(content)) {\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 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;AACA,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,IAAI,KAAK,GAAG,gBAAgB;AAAA,EACjD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AAA,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;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.2.
|
|
24
|
+
const LIB_VERSION = "1.2.2-beta.0";
|
|
25
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
26
|
0 && (module.exports = {
|
|
27
27
|
LIB_VERSION
|
package/dist/version.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/version.ts"],
|
|
4
|
-
"sourcesContent": ["export const LIB_VERSION = \"1.2.
|
|
4
|
+
"sourcesContent": ["export const LIB_VERSION = \"1.2.2-beta.0\";\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.2.
|
|
3
|
+
"version": "1.2.2-beta.0",
|
|
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",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"jsonpath-mapper": "^1.1.0",
|
|
41
41
|
"keytar": "^7.9.0",
|
|
42
42
|
"lodash": "^4.17.21",
|
|
43
|
-
"migratortron": "^1.0.0-beta.
|
|
43
|
+
"migratortron": "^1.0.0-beta.51",
|
|
44
44
|
"nanospinner": "^1.1.0",
|
|
45
45
|
"node-fetch": "^2.6.7",
|
|
46
46
|
"parse-git-config": "^3.0.0",
|
package/src/commands/copy.ts
CHANGED
|
@@ -7,7 +7,9 @@ import {
|
|
|
7
7
|
entryId,
|
|
8
8
|
ignoreErrors,
|
|
9
9
|
mapContensisOpts,
|
|
10
|
+
noCache,
|
|
10
11
|
outputEntries,
|
|
12
|
+
saveEntries,
|
|
11
13
|
zenql,
|
|
12
14
|
} from './globalOptions';
|
|
13
15
|
|
|
@@ -36,16 +38,14 @@ export const makeCopyCommand = () => {
|
|
|
36
38
|
.addOption(concurrency)
|
|
37
39
|
.addOption(ignoreErrors)
|
|
38
40
|
.addOption(outputEntries)
|
|
41
|
+
.addOption(noCache)
|
|
39
42
|
.option(
|
|
40
43
|
'--search <phrase>',
|
|
41
44
|
'get entries with the search phrase, use quotes for multiple words'
|
|
42
45
|
)
|
|
43
46
|
.addOption(entryId)
|
|
44
47
|
.addOption(zenql)
|
|
45
|
-
.
|
|
46
|
-
'-s --save-entries',
|
|
47
|
-
"save the entries we're migrating instead of the migration preview when using --output option"
|
|
48
|
-
)
|
|
48
|
+
.addOption(saveEntries)
|
|
49
49
|
.usage('<contentTypeId> <fieldId> <destinationId> (all arguments required)')
|
|
50
50
|
.addHelpText(
|
|
51
51
|
'after',
|
package/src/commands/diff.ts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { cliCommand } from '~/services/ContensisCliService';
|
|
3
|
-
import { mapContensisOpts } from './globalOptions';
|
|
3
|
+
import { mapContensisOpts, noCache } from './globalOptions';
|
|
4
4
|
|
|
5
5
|
export const makeDiffCommand = () => {
|
|
6
|
-
const
|
|
6
|
+
const diff = new Command()
|
|
7
7
|
.command('diff')
|
|
8
8
|
.description('diff command')
|
|
9
9
|
.addHelpText('after', `\n`)
|
|
10
10
|
.showHelpAfterError(true)
|
|
11
11
|
.exitOverride();
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
diff
|
|
14
14
|
.command('models')
|
|
15
15
|
.description('differences with content models')
|
|
16
16
|
.argument(
|
|
17
17
|
'[model-ids...]',
|
|
18
18
|
'ids of any content types or components to diff (optional)'
|
|
19
19
|
)
|
|
20
|
+
.addOption(noCache)
|
|
20
21
|
.usage('[model-ids...]')
|
|
21
22
|
.addHelpText(
|
|
22
23
|
'after',
|
|
@@ -37,5 +38,5 @@ Example call:
|
|
|
37
38
|
);
|
|
38
39
|
});
|
|
39
40
|
|
|
40
|
-
return
|
|
41
|
+
return diff;
|
|
41
42
|
};
|
package/src/commands/get.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
delivery,
|
|
9
9
|
entryId,
|
|
10
10
|
mapContensisOpts,
|
|
11
|
+
noCache,
|
|
11
12
|
zenql,
|
|
12
13
|
} from './globalOptions';
|
|
13
14
|
|
|
@@ -121,6 +122,8 @@ Example call:
|
|
|
121
122
|
.command('model')
|
|
122
123
|
.description('get a content model')
|
|
123
124
|
.argument('<contentTypeId...>', 'ids of the content models to get')
|
|
125
|
+
.option('--required-by', 'shows the id(s) that created each dependency')
|
|
126
|
+
.addOption(noCache)
|
|
124
127
|
.addHelpText(
|
|
125
128
|
'after',
|
|
126
129
|
`
|
|
@@ -131,8 +134,9 @@ Example call:
|
|
|
131
134
|
.action(async (modelIds: string[], opts) => {
|
|
132
135
|
await cliCommand(
|
|
133
136
|
['get', 'model', modelIds.join(' ')],
|
|
134
|
-
opts
|
|
135
|
-
|
|
137
|
+
opts,
|
|
138
|
+
mapContensisOpts(opts)
|
|
139
|
+
).PrintContentModels(modelIds, opts.requiredBy);
|
|
136
140
|
});
|
|
137
141
|
|
|
138
142
|
program
|
|
@@ -43,6 +43,7 @@ export const mapContensisOpts = (opts: any = {}): MigrateRequest => ({
|
|
|
43
43
|
zenQL: opts.zenql,
|
|
44
44
|
transformGuids: !opts.preserveGuids,
|
|
45
45
|
ignoreErrors: opts.ignoreErrors,
|
|
46
|
+
noCache: !opts.cache,
|
|
46
47
|
concurrency: opts.concurrency ? Number(opts.concurrency) : undefined,
|
|
47
48
|
});
|
|
48
49
|
|
|
@@ -91,10 +92,10 @@ export const delivery = new Option(
|
|
|
91
92
|
'-delivery --delivery-api',
|
|
92
93
|
'use delivery api to get the entries'
|
|
93
94
|
);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
export const search = new Option(
|
|
96
|
+
'--search <phrase>',
|
|
97
|
+
'get entries with the search phrase, use quotes for multiple words'
|
|
98
|
+
);
|
|
98
99
|
export const zenql = new Option(
|
|
99
100
|
'-q --zenql <zenql>',
|
|
100
101
|
'get entries with a supplied ZenQL statement'
|
|
@@ -142,11 +143,21 @@ export const outputEntries = new Option(
|
|
|
142
143
|
.choices(['errors', 'changes', 'all'])
|
|
143
144
|
.default('errors');
|
|
144
145
|
|
|
146
|
+
export const saveEntries = new Option(
|
|
147
|
+
'-save --save-entries',
|
|
148
|
+
"save the entries we're migrating instead of the migration preview when using --output option"
|
|
149
|
+
);
|
|
150
|
+
|
|
145
151
|
export const concurrency = new Option(
|
|
146
152
|
'-conc --concurrency <concurrency>',
|
|
147
153
|
'the number of entries to load in parallel'
|
|
148
154
|
).default(2);
|
|
149
155
|
|
|
156
|
+
export const noCache = new Option(
|
|
157
|
+
'--no-cache',
|
|
158
|
+
'add this flag to ignore internal cache and rebuild all resources from scratch'
|
|
159
|
+
);
|
|
160
|
+
|
|
150
161
|
export const addConnectOptions = (program: Command) =>
|
|
151
162
|
program.addOption(alias.hideHelp()).addOption(project.hideHelp());
|
|
152
163
|
|
|
@@ -167,13 +178,6 @@ export const addImportOptions = (program: Command) => {
|
|
|
167
178
|
return program;
|
|
168
179
|
};
|
|
169
180
|
|
|
170
|
-
export const getEntryOptions = (command: Command) =>
|
|
171
|
-
command
|
|
172
|
-
.addOption(entryId)
|
|
173
|
-
.addOption(zenql)
|
|
174
|
-
.addOption(contentTypes)
|
|
175
|
-
.addOption(assetTypes);
|
|
176
|
-
|
|
177
181
|
export const addGlobalOptions = (program: Command) => {
|
|
178
182
|
for (const command of program.commands) {
|
|
179
183
|
addOutputAndFormatOptions(command);
|
package/src/commands/import.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { Command, Option } from 'commander';
|
|
2
2
|
import { cliCommand } from '~/services/ContensisCliService';
|
|
3
3
|
import {
|
|
4
|
+
assetTypes,
|
|
4
5
|
commit,
|
|
5
6
|
concurrency,
|
|
6
|
-
|
|
7
|
+
contentTypes,
|
|
8
|
+
entryId,
|
|
7
9
|
ignoreErrors,
|
|
8
10
|
mapContensisOpts,
|
|
11
|
+
noCache,
|
|
9
12
|
outputEntries,
|
|
13
|
+
saveEntries,
|
|
14
|
+
zenql,
|
|
10
15
|
} from './globalOptions';
|
|
11
16
|
|
|
12
17
|
export const makeImportCommand = () => {
|
|
@@ -21,6 +26,7 @@ export const makeImportCommand = () => {
|
|
|
21
26
|
.command('models')
|
|
22
27
|
.description('import complete content models')
|
|
23
28
|
.argument('[modelIds...]', 'ids of the content models to import (optional)')
|
|
29
|
+
.addOption(noCache)
|
|
24
30
|
.addOption(commit)
|
|
25
31
|
.addHelpText(
|
|
26
32
|
'after',
|
|
@@ -101,15 +107,17 @@ Example call:
|
|
|
101
107
|
);
|
|
102
108
|
});
|
|
103
109
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
program
|
|
111
|
+
.command('entries')
|
|
112
|
+
.description('import entries')
|
|
113
|
+
.argument(
|
|
114
|
+
'[search phrase]',
|
|
115
|
+
'get entries with the search phrase, use quotes for multiple words'
|
|
116
|
+
)
|
|
117
|
+
.addOption(entryId)
|
|
118
|
+
.addOption(zenql)
|
|
119
|
+
.addOption(contentTypes)
|
|
120
|
+
.addOption(assetTypes)
|
|
113
121
|
.addOption(commit)
|
|
114
122
|
.option(
|
|
115
123
|
'-preserve --preserve-guids',
|
|
@@ -118,6 +126,8 @@ Example call:
|
|
|
118
126
|
.addOption(concurrency)
|
|
119
127
|
.addOption(outputEntries)
|
|
120
128
|
.addOption(ignoreErrors)
|
|
129
|
+
.addOption(noCache)
|
|
130
|
+
.addOption(saveEntries)
|
|
121
131
|
.addHelpText(
|
|
122
132
|
'after',
|
|
123
133
|
`
|
|
@@ -135,6 +145,7 @@ Example call:
|
|
|
135
145
|
commit: opts.commit,
|
|
136
146
|
fromFile: opts.fromFile,
|
|
137
147
|
logOutput: opts.outputEntries,
|
|
148
|
+
saveEntries: opts.saveEntries,
|
|
138
149
|
});
|
|
139
150
|
});
|
|
140
151
|
|
package/src/commands/index.ts
CHANGED
|
@@ -58,14 +58,14 @@ const commands = () => {
|
|
|
58
58
|
addAuthenticationOptions(makeDevCommand())
|
|
59
59
|
).copyInheritedSettings(program)
|
|
60
60
|
);
|
|
61
|
-
program.addCommand(
|
|
62
|
-
addGlobalOptions(makeExecuteCommand()).copyInheritedSettings(program)
|
|
63
|
-
);
|
|
64
61
|
program.addCommand(
|
|
65
62
|
addGlobalOptions(addImportOptions(makeDiffCommand())).copyInheritedSettings(
|
|
66
63
|
program
|
|
67
64
|
)
|
|
68
65
|
);
|
|
66
|
+
program.addCommand(
|
|
67
|
+
addGlobalOptions(makeExecuteCommand()).copyInheritedSettings(program)
|
|
68
|
+
);
|
|
69
69
|
program.addCommand(
|
|
70
70
|
addGlobalOptions(makeGetCommand()).copyInheritedSettings(program)
|
|
71
71
|
);
|
package/src/commands/list.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { cliCommand } from '~/services/ContensisCliService';
|
|
3
|
+
import { mapContensisOpts, noCache } from './globalOptions';
|
|
3
4
|
|
|
4
5
|
export const makeListCommand = () => {
|
|
5
6
|
const list = new Command()
|
|
@@ -40,6 +41,7 @@ Example call:
|
|
|
40
41
|
list
|
|
41
42
|
.command('models')
|
|
42
43
|
.description('print list of content models')
|
|
44
|
+
.addOption(noCache)
|
|
43
45
|
.addHelpText(
|
|
44
46
|
'after',
|
|
45
47
|
`
|
|
@@ -48,7 +50,11 @@ Example call:
|
|
|
48
50
|
`
|
|
49
51
|
)
|
|
50
52
|
.action(async opts => {
|
|
51
|
-
await cliCommand(
|
|
53
|
+
await cliCommand(
|
|
54
|
+
['list', 'models'],
|
|
55
|
+
opts,
|
|
56
|
+
mapContensisOpts(opts)
|
|
57
|
+
).PrintContentModels();
|
|
52
58
|
});
|
|
53
59
|
|
|
54
60
|
list
|
|
@@ -1181,7 +1181,10 @@ class ContensisCli {
|
|
|
1181
1181
|
}
|
|
1182
1182
|
};
|
|
1183
1183
|
|
|
1184
|
-
PrintContentModels = async (
|
|
1184
|
+
PrintContentModels = async (
|
|
1185
|
+
modelIds: string[] = [],
|
|
1186
|
+
printRequiredBy?: boolean
|
|
1187
|
+
) => {
|
|
1185
1188
|
const { currentProject, log, messages } = this;
|
|
1186
1189
|
const contensis = await this.ConnectContensis();
|
|
1187
1190
|
if (contensis) {
|
|
@@ -1231,6 +1234,15 @@ class ContensisCli {
|
|
|
1231
1234
|
await this.HandleFormattingAndOutput(contentModelBackup, () => {
|
|
1232
1235
|
// print the content models to console
|
|
1233
1236
|
for (const model of returnModels) {
|
|
1237
|
+
if (!printRequiredBy) {
|
|
1238
|
+
// truncate parts of the output
|
|
1239
|
+
delete model.dependencyOf;
|
|
1240
|
+
if (model.dependencies?.contentTypes)
|
|
1241
|
+
model.dependencies.contentTypes.forEach(id => (id[1] = []));
|
|
1242
|
+
if (model.dependencies?.components)
|
|
1243
|
+
model.dependencies.components.forEach(id => (id[1] = []));
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1234
1246
|
log.raw('');
|
|
1235
1247
|
log.object(model);
|
|
1236
1248
|
}
|
|
@@ -1745,10 +1757,12 @@ class ContensisCli {
|
|
|
1745
1757
|
commit,
|
|
1746
1758
|
fromFile,
|
|
1747
1759
|
logOutput,
|
|
1760
|
+
saveEntries,
|
|
1748
1761
|
}: {
|
|
1749
1762
|
commit: boolean;
|
|
1750
1763
|
fromFile: string;
|
|
1751
1764
|
logOutput: string;
|
|
1765
|
+
saveEntries: boolean;
|
|
1752
1766
|
}) => {
|
|
1753
1767
|
const { currentEnv, currentProject, log, messages } = this;
|
|
1754
1768
|
|
|
@@ -1769,8 +1783,13 @@ class ContensisCli {
|
|
|
1769
1783
|
const [err, result] = await contensis.MigrateEntries();
|
|
1770
1784
|
|
|
1771
1785
|
if (err) logError(err);
|
|
1772
|
-
else
|
|
1773
|
-
|
|
1786
|
+
else {
|
|
1787
|
+
const output = saveEntries
|
|
1788
|
+
? contensis.content.targets[currentProject].migrateEntries?.map(
|
|
1789
|
+
me => me.finalEntry
|
|
1790
|
+
)
|
|
1791
|
+
: result;
|
|
1792
|
+
await this.HandleFormattingAndOutput(output, () => {
|
|
1774
1793
|
// print the migrateResult to console
|
|
1775
1794
|
printEntriesMigrateResult(this, result, {
|
|
1776
1795
|
showAll: logOutput === 'all',
|
|
@@ -1778,7 +1797,7 @@ class ContensisCli {
|
|
|
1778
1797
|
showChanged: logOutput === 'changes',
|
|
1779
1798
|
});
|
|
1780
1799
|
});
|
|
1781
|
-
|
|
1800
|
+
}
|
|
1782
1801
|
if (
|
|
1783
1802
|
!err &&
|
|
1784
1803
|
!result.errors?.length &&
|
package/src/util/logger.ts
CHANGED
|
@@ -192,8 +192,9 @@ export class Logger {
|
|
|
192
192
|
for (const item of content) {
|
|
193
193
|
if (item && typeof item === 'object') {
|
|
194
194
|
if (Array.isArray(item) && depth > 3)
|
|
195
|
-
|
|
196
|
-
|
|
195
|
+
if (item.length)
|
|
196
|
+
Logger.raw(chalk.grey(`${indent} [${item.join(', ')}]`));
|
|
197
|
+
else Logger.objectRecurse(item, depth + 1, `${indent} `);
|
|
197
198
|
} else Logger.raw(`${indent}${item}`);
|
|
198
199
|
}
|
|
199
200
|
} else {
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = "1.2.
|
|
1
|
+
export const LIB_VERSION = "1.2.2-beta.0";
|