contensis-cli 1.0.0-beta.56 → 1.0.0-beta.57

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/util/console.printer.ts"],
4
- "sourcesContent": ["import dayjs from 'dayjs';\nimport { BlockVersion, MigrateModelsResult, MigrateStatus } from 'migratortron';\nimport ContensisCli from '~/services/ContensisCliService';\nimport { Logger } from './logger';\n\nconst formatDate = (date: Date | string, format = 'DD/MM/YYYY HH:mm') =>\n dayjs(date).format(format);\n\nexport const printBlockVersion = (\n { log, messages }: ContensisCli,\n block: BlockVersion,\n printOptions = {\n showSource: true,\n showStatus: true,\n showStaticPaths: true,\n showImage: true,\n }\n) => {\n console.log(\n ` ${log.standardText(`v${block.version.versionNo}`)} ${block.id}`\n );\n console.log(\n ` state: ${messages.blocks.runningStatus(\n block.status.broken ? 'broken' : block.status.running.global\n )}`\n );\n console.log(\n ` released: ${log.infoText(\n block.version.released\n ? `[${formatDate(block.version.released)}] ${block.version.releasedBy}`\n : 'no'\n )}`\n );\n if (block.version.madeLive)\n console.log(\n ` live: ${log.infoText(\n `[${formatDate(block.version.madeLive)}] ${block.version.madeLiveBy}`\n )}`\n );\n if (printOptions.showStatus) {\n console.log(` status:`);\n console.log(` deployment: ${log.infoText(block.status.deployment)}`);\n console.log(` workflow: ${log.infoText(block.status.workflow)}`);\n console.log(\n ` running status: ${messages.blocks.runningStatus(\n block.status.running.global\n )}`\n );\n console.log(` datacentres:`);\n console.log(\n ` hq: ${messages.blocks.runningStatus(\n block.status.running.dataCenters.hq\n )}`\n );\n console.log(\n ` london: ${messages.blocks.runningStatus(\n block.status.running.dataCenters.london\n )}`\n );\n console.log(\n ` manchester: ${messages.blocks.runningStatus(\n block.status.running.dataCenters.manchester\n )}`\n );\n }\n if (printOptions.showSource) {\n console.log(` source:`);\n console.log(` commit: ${log.helpText(block.source.commit.id)}`);\n console.log(\n ` message: ${log.infoText(\n block.source.commit.message\n ?.replaceAll('\\n', '\\\\n')\n .replaceAll('\\\\n\\\\n', '\\\\n')\n .replaceAll('\\\\n', '; ')\n )}`\n );\n console.log(\n ` committed: ${log.infoText(\n `[${formatDate(block.source.commit.dateTime)}] ${\n block.source.commit.authorEmail\n }`\n )}`\n );\n console.log(\n ` pushed: ${log.infoText(\n `[${formatDate(block.version.pushed)}] ${block.version.pushedBy}`\n )}`\n );\n console.log(` ${log.infoText(block.source.commit.commitUrl)}`);\n }\n if (printOptions.showImage) {\n console.log(` image:`);\n console.log(` uri: ${log.infoText(block.image.uri)}`);\n console.log(` tag: ${log.helpText(block.image.tag)}`);\n }\n if (printOptions.showStaticPaths) {\n if (block.staticPaths?.length) {\n console.log(` static paths:`);\n for (const path of block.staticPaths) console.log(` - ${path}`);\n }\n }\n if (block.stagingUrl)\n console.log(` staging url: ${log.infoText(block.stagingUrl)}`);\n console.log('');\n};\n\nexport const printMigrateResult = (\n { log, messages, contensis, currentProject }: ContensisCli,\n migrateResult: any,\n {\n action = 'import',\n showDiff = false,\n showAllEntries = false,\n showChangedEntries = false,\n }: {\n action?: 'import' | 'delete';\n showDiff?: boolean;\n showAllEntries?: boolean;\n showChangedEntries?: boolean;\n } = {}\n) => {\n if (Object.keys(migrateResult.entriesToMigrate.entryIds).length)\n console.log(``);\n\n for (const [contentTypeId, entryRes] of Object.entries(\n migrateResult.entriesToMigrate.entryIds\n ) as [string, any]) {\n for (const [originalId, entryStatus] of Object.entries(entryRes) as [\n string,\n any\n ][]) {\n // console.log(`${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`);\n if (\n showAllEntries ||\n (showChangedEntries &&\n (\n Object.entries(\n Object.entries(entryStatus[currentProject])[0]\n )[1][1] as any\n ).status !== 'no change')\n ) {\n console.log(\n log.infoText(\n `${originalId} ${Object.entries(entryStatus || {})\n .filter(x => x[0] !== 'entryTitle')\n .map(([projectId, projectStatus]) => {\n const [targetGuid, { status }] = (Object.entries(\n projectStatus || {}\n )?.[0] as [string, { status: MigrateStatus }]) || [\n '',\n { x: { status: undefined } },\n ];\n return `${messages.migrate.status(status)(`${status}`)}${\n targetGuid !== originalId ? `-> ${targetGuid}` : ''\n }`;\n })}`\n ) + ` ${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`\n );\n\n for (const [projectId, projectStatus] of Object.entries(\n entryStatus\n ).filter(([key]) => key !== 'entryTitle') as [string, any][]) {\n const [targetGuid, { error, diff, status }] = Object.entries(\n projectStatus\n )[0] as [string, any];\n if (error) log.error(error);\n if (diff && showDiff) {\n console.log(\n ` ${log.highlightText(`diff:`)} ${log.infoText(\n highlightDiffText(diff)\n )}\\n`\n );\n }\n }\n }\n }\n }\n console.log(``);\n if (\n contensis?.isPreview &&\n migrateResult.entriesToMigrate?.[currentProject]?.totalCount > 0 &&\n !migrateResult.errors\n ) {\n log.help(messages.entries.commitTip());\n }\n\n if (action === 'import') {\n for (const [projectId, contentTypeCounts] of Object.entries(\n migrateResult.entries || {}\n ) as [string, any][]) {\n log.help(\n `import from project ${log.highlightText(projectId)} to ${log.boldText(\n log.warningText(currentProject)\n )}`\n );\n for (const [contentTypeId, count] of Object.entries(\n contentTypeCounts\n ) as [string, number][]) {\n const migrateStatusAndCount =\n migrateResult.entriesToMigrate[currentProject][contentTypeId];\n const existingCount =\n migrateResult.existing?.[currentProject]?.[contentTypeId] || 0;\n const existingPercent = ((existingCount / count) * 100).toFixed(0);\n const noChangeOrTotalEntriesCount =\n typeof migrateStatusAndCount !== 'number'\n ? migrateStatusAndCount?.['no change'] || 0\n : migrateStatusAndCount;\n\n const isTotalCountRow = contentTypeId === 'totalCount';\n\n const changedPercentage = (\n (noChangeOrTotalEntriesCount / count) *\n 100\n ).toFixed(0);\n\n const existingColor =\n existingPercent === '0' ? log.warningText : log.infoText;\n const changedColor = isTotalCountRow\n ? log.helpText\n : changedPercentage === '100'\n ? log.successText\n : log.warningText;\n\n console.log(\n ` - ${\n isTotalCountRow\n ? log.highlightText(`${contentTypeId}: ${count}`)\n : `${contentTypeId}: ${log.helpText(count)}`\n }${\n changedPercentage === '100'\n ? ''\n : existingColor(\n ` [existing: ${\n isTotalCountRow ? existingCount : `${existingPercent}%`\n }]`\n )\n }${\n existingPercent === '0'\n ? ''\n : changedColor(\n ` ${\n isTotalCountRow\n ? `[to change: ${noChangeOrTotalEntriesCount}]`\n : changedPercentage === '100'\n ? 'up to date'\n : `[needs update: ${100 - Number(changedPercentage)}%]`\n }`\n )\n }`\n );\n }\n }\n if (migrateResult.errors?.length) {\n console.log(\n ` - ${log.errorText(`errors: ${migrateResult.errors.length}`)}\\n`\n );\n for (const error of migrateResult.errors)\n log.error(error.message || error);\n }\n }\n};\n\nconst highlightDiffText = (str: string) => {\n const addedRegex = new RegExp(/<<\\+>>(.*?)<<\\/\\+>>/, 'g');\n const removedRegex = new RegExp(/<<->>(.*?)<<\\/->>/, 'g');\n return str\n .replace(addedRegex, match => {\n return Logger.successText(\n match.replace(/<<\\+>>/g, '<+>').replace(/<<\\/\\+>>/g, '</+>')\n );\n })\n .replace(removedRegex, match => {\n return Logger.errorText(\n match.replace(/<<->>/g, '<->').replace(/<<\\/->>/g, '</->')\n );\n });\n};\n\nexport const printModelMigrationAnalysis = (\n { log, messages }: ContensisCli,\n result: any = {}\n) => {\n for (const [contentTypeId, model] of Object.entries(result) as [\n string,\n any\n ][]) {\n let mainOutput = log.standardText(` - ${contentTypeId}`);\n let extraOutput = '';\n let errorOutput = '';\n let diffOutput = '';\n for (const [key, details] of Object.entries(model) as [string, any][]) {\n if (key === 'dependencies') {\n extraOutput += log.infoText(\n ` references: [${details?.join(', ')}]\\n`\n );\n }\n if (key === 'dependencyOf') {\n extraOutput += log.infoText(\n ` required by: [${details?.join(', ')}]\\n`\n );\n }\n if (key === 'projects') {\n for (const [projectId, projectDetails] of Object.entries(details) as [\n string,\n any\n ][]) {\n mainOutput += log.infoText(\n ` [${messages.migrate.status(projectDetails.status)(\n `${projectId}: ${projectDetails.status}`\n )}] v${projectDetails.versionNo}`\n );\n if (projectDetails.diff)\n diffOutput += ` ${log.highlightText(`diff:`)} ${log.infoText(\n highlightDiffText(projectDetails.diff)\n )}\\n`;\n if (projectDetails.error)\n errorOutput += ` ${log.highlightText(\n `error::`\n )} ${log.errorText(projectDetails.error)}`;\n }\n }\n }\n console.log(mainOutput);\n if (extraOutput) {\n const search = '\\n';\n const replace = '';\n console.log(\n extraOutput.replace(\n new RegExp(search + '([^' + search + ']*)$'),\n replace + '$1'\n )\n );\n }\n if (diffOutput) console.log(diffOutput);\n if (errorOutput) console.log(errorOutput);\n }\n};\n\ntype MigrateResultSummary = MigrateModelsResult['']['contentTypes'];\ntype MigrateResultStatus = keyof MigrateResultSummary;\n\nexport const printModelMigrationResult = (\n { log, messages }: ContensisCli,\n result: MigrateResultSummary\n) => {\n for (const [status, ids] of Object.entries(result) as [\n MigrateResultStatus,\n string[]\n ][]) {\n if (ids?.length) {\n if (status === 'errors') {\n const errors: [string, MappedError][] = ids as any;\n log.raw(\n ` - ${status}: [ ${messages.migrate.models.result(status)(\n ids.map(id => id[0]).join(', ')\n )} ]\\n`\n );\n for (const [contentTypeId, error] of errors)\n log.error(\n `${log.highlightText(contentTypeId)}: ${error.message}`,\n error\n );\n } else\n log.raw(\n ` - ${status}: [ ${messages.migrate.models.result(status)(\n ids.join(', ')\n )} ]`\n );\n }\n }\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAGlB,oBAAuB;AAEvB,MAAM,aAAa,CAAC,MAAqB,SAAS,2BAChD,aAAAA,SAAM,IAAI,EAAE,OAAO,MAAM;AAEpB,MAAM,oBAAoB,CAC/B,EAAE,KAAK,SAAS,GAChB,OACA,eAAe;AAAA,EACb,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,WAAW;AACb,MACG;AAjBL;AAkBE,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AAa,SAAS,QAAQ,OAAO,OAAO,MAAM;AAAA,YACvD,IAAI,KAAK,IAAI;AAAA,UACf;AAAA,QACF;AAAA,IACJ;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import dayjs from 'dayjs';\nimport { BlockVersion, MigrateModelsResult, MigrateStatus } from 'migratortron';\nimport ContensisCli from '~/services/ContensisCliService';\nimport { Logger } from './logger';\n\nconst formatDate = (date: Date | string, format = 'DD/MM/YYYY HH:mm') =>\n dayjs(date).format(format);\n\nexport const printBlockVersion = (\n { log, messages }: ContensisCli,\n block: BlockVersion,\n printOptions = {\n showSource: true,\n showStatus: true,\n showStaticPaths: true,\n showImage: true,\n }\n) => {\n console.log(\n ` ${log.standardText(`v${block.version.versionNo}`)} ${block.id}`\n );\n console.log(\n ` state: ${messages.blocks.runningStatus(\n block.status.broken ? 'broken' : block.status.running.global\n )}`\n );\n console.log(\n ` released: ${log.infoText(\n block.version.released\n ? `[${formatDate(block.version.released)}] ${block.version.releasedBy}`\n : 'no'\n )}`\n );\n if (block.version.madeLive)\n console.log(\n ` live: ${log.infoText(\n `[${formatDate(block.version.madeLive)}] ${block.version.madeLiveBy}`\n )}`\n );\n if (printOptions.showStatus) {\n console.log(` status:`);\n console.log(` deployment: ${log.infoText(block.status.deployment)}`);\n console.log(` workflow: ${log.infoText(block.status.workflow)}`);\n console.log(\n ` running status: ${messages.blocks.runningStatus(\n block.status.running.global\n )}`\n );\n console.log(` datacentres:`);\n console.log(\n ` hq: ${messages.blocks.runningStatus(\n block.status.running.dataCenters.hq\n )}`\n );\n console.log(\n ` london: ${messages.blocks.runningStatus(\n block.status.running.dataCenters.london\n )}`\n );\n console.log(\n ` manchester: ${messages.blocks.runningStatus(\n block.status.running.dataCenters.manchester\n )}`\n );\n }\n if (printOptions.showSource) {\n console.log(` source:`);\n console.log(` commit: ${log.helpText(block.source.commit.id)}`);\n console.log(\n ` message: ${log.infoText(\n block.source.commit.message\n ?.replaceAll('\\n', '\\\\n')\n .replaceAll('\\\\n\\\\n', '\\\\n')\n .replaceAll('\\\\n', '; ')\n )}`\n );\n console.log(\n ` committed: ${log.infoText(\n `[${formatDate(block.source.commit.dateTime)}] ${\n block.source.commit.authorEmail\n }`\n )}`\n );\n console.log(\n ` pushed: ${log.infoText(\n `[${formatDate(block.version.pushed)}] ${block.version.pushedBy}`\n )}`\n );\n console.log(` ${log.infoText(block.source.commit.commitUrl)}`);\n }\n if (printOptions.showImage) {\n console.log(` image:`);\n console.log(` uri: ${log.infoText(block.image.uri)}`);\n console.log(` tag: ${log.helpText(block.image.tag)}`);\n }\n if (printOptions.showStaticPaths) {\n if (block.staticPaths?.length) {\n console.log(` static paths:`);\n for (const path of block.staticPaths) console.log(` - ${path}`);\n }\n }\n if (block.stagingUrl)\n console.log(` staging url: ${log.infoText(block.stagingUrl)}`);\n console.log('');\n};\n\nexport const printMigrateResult = (\n { log, messages, currentProject }: ContensisCli,\n migrateResult: any,\n {\n action = 'import',\n showDiff = false,\n showAllEntries = false,\n showChangedEntries = false,\n }: {\n action?: 'import' | 'delete';\n showDiff?: boolean;\n showAllEntries?: boolean;\n showChangedEntries?: boolean;\n } = {}\n) => {\n // if (Object.keys(migrateResult.entriesToMigrate.entryIds).length)\n console.log(``);\n\n for (const [contentTypeId, entryRes] of Object.entries(\n migrateResult.entriesToMigrate.entryIds\n ) as [string, any]) {\n for (const [originalId, entryStatus] of Object.entries(entryRes) as [\n string,\n any\n ][]) {\n // console.log(`${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`);\n if (\n showAllEntries ||\n (showChangedEntries &&\n (\n Object.entries(\n Object.entries(entryStatus[currentProject])[0]\n )[1][1] as any\n ).status !== 'no change')\n ) {\n console.log(\n log.infoText(\n `${originalId} ${Object.entries(entryStatus || {})\n .filter(x => x[0] !== 'entryTitle')\n .map(([projectId, projectStatus]) => {\n const [targetGuid, { status }] = (Object.entries(\n projectStatus || {}\n )?.[0] as [string, { status: MigrateStatus }]) || [\n '',\n { x: { status: undefined } },\n ];\n return `${messages.migrate.status(status)(`${status}`)}${\n targetGuid !== originalId ? `-> ${targetGuid}` : ''\n }`;\n })}`\n ) + ` ${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`\n );\n\n for (const [projectId, projectStatus] of Object.entries(\n entryStatus\n ).filter(([key]) => key !== 'entryTitle') as [string, any][]) {\n const [targetGuid, { error, diff, status }] = Object.entries(\n projectStatus\n )[0] as [string, any];\n if (error) log.error(error);\n if (diff && showDiff) {\n console.log(\n ` ${log.highlightText(`diff:`)} ${log.infoText(\n highlightDiffText(diff)\n )}\\n`\n );\n }\n }\n }\n }\n }\n if (showAllEntries || showChangedEntries) console.log(``);\n // if (\n // contensis?.isPreview &&\n // migrateResult.entriesToMigrate?.[currentProject]?.totalCount > 0 &&\n // !migrateResult.errors\n // ) {\n // log.help(messages.entries.commitTip());\n // }\n\n for (const [projectId, contentTypeCounts] of Object.entries(\n migrateResult.entries || {}\n ) as [string, any][]) {\n log.help(\n `${action} from project ${\n action === 'delete'\n ? log.warningText(currentProject)\n : `${log.highlightText(projectId)} to ${log.boldText(\n log.warningText(currentProject)\n )}`\n }`\n );\n for (const [contentTypeId, count] of Object.entries(contentTypeCounts) as [\n string,\n number\n ][]) {\n const migrateStatusAndCount =\n migrateResult.entriesToMigrate[currentProject][contentTypeId];\n const existingCount =\n migrateResult.existing?.[currentProject]?.[contentTypeId] || 0;\n const existingPercent = ((existingCount / count) * 100).toFixed(0);\n const noChangeOrTotalEntriesCount =\n typeof migrateStatusAndCount !== 'number'\n ? migrateStatusAndCount?.['no change'] || 0\n : migrateStatusAndCount;\n\n const isTotalCountRow = contentTypeId === 'totalCount';\n\n const changedPercentage = (\n (noChangeOrTotalEntriesCount / count) *\n 100\n ).toFixed(0);\n\n const existingColor =\n existingPercent === '0' ? log.warningText : log.infoText;\n const changedColor = isTotalCountRow\n ? log.helpText\n : changedPercentage === '100'\n ? log.successText\n : log.warningText;\n\n console.log(\n ` - ${\n isTotalCountRow\n ? log.highlightText(\n `${contentTypeId}: ${noChangeOrTotalEntriesCount}`\n )\n : `${contentTypeId}: ${log.helpText(count)}`\n }${\n changedPercentage === '100' || action === 'delete'\n ? ''\n : existingColor(\n ` [existing: ${\n isTotalCountRow ? existingCount : `${existingPercent}%`\n }]`\n )\n }${\n existingPercent === '0'\n ? ''\n : changedColor(\n ` ${\n isTotalCountRow\n ? `[to ${action}: ${noChangeOrTotalEntriesCount}]`\n : changedPercentage === '100'\n ? 'up to date'\n : `[needs update: ${100 - Number(changedPercentage)}%]`\n }`\n )\n }`\n );\n }\n }\n if (migrateResult.errors?.length) {\n console.log(\n ` - ${log.errorText(`errors: ${migrateResult.errors.length}`)}\\n`\n );\n for (const error of migrateResult.errors) log.error(error.message || error);\n }\n};\n\nconst highlightDiffText = (str: string) => {\n const addedRegex = new RegExp(/<<\\+>>(.*?)<<\\/\\+>>/, 'g');\n const removedRegex = new RegExp(/<<->>(.*?)<<\\/->>/, 'g');\n return str\n .replace(addedRegex, match => {\n return Logger.successText(\n match.replace(/<<\\+>>/g, '<+>').replace(/<<\\/\\+>>/g, '</+>')\n );\n })\n .replace(removedRegex, match => {\n return Logger.errorText(\n match.replace(/<<->>/g, '<->').replace(/<<\\/->>/g, '</->')\n );\n });\n};\n\nexport const printModelMigrationAnalysis = (\n { log, messages }: ContensisCli,\n result: any = {}\n) => {\n for (const [contentTypeId, model] of Object.entries(result) as [\n string,\n any\n ][]) {\n let mainOutput = log.standardText(` - ${contentTypeId}`);\n let extraOutput = '';\n let errorOutput = '';\n let diffOutput = '';\n for (const [key, details] of Object.entries(model) as [string, any][]) {\n if (key === 'dependencies') {\n extraOutput += log.infoText(\n ` references: [${details?.join(', ')}]\\n`\n );\n }\n if (key === 'dependencyOf') {\n extraOutput += log.infoText(\n ` required by: [${details?.join(', ')}]\\n`\n );\n }\n if (key === 'projects') {\n for (const [projectId, projectDetails] of Object.entries(details) as [\n string,\n any\n ][]) {\n mainOutput += log.infoText(\n ` [${messages.migrate.status(projectDetails.status)(\n `${projectId}: ${projectDetails.status}`\n )}] v${projectDetails.versionNo}`\n );\n if (projectDetails.diff)\n diffOutput += ` ${log.highlightText(`diff:`)} ${log.infoText(\n highlightDiffText(projectDetails.diff)\n )}\\n`;\n if (projectDetails.error)\n errorOutput += ` ${log.highlightText(\n `error::`\n )} ${log.errorText(projectDetails.error)}`;\n }\n }\n }\n console.log(mainOutput);\n if (extraOutput) {\n const search = '\\n';\n const replace = '';\n console.log(\n extraOutput.replace(\n new RegExp(search + '([^' + search + ']*)$'),\n replace + '$1'\n )\n );\n }\n if (diffOutput) console.log(diffOutput);\n if (errorOutput) console.log(errorOutput);\n }\n};\n\ntype MigrateResultSummary = MigrateModelsResult['']['contentTypes'];\ntype MigrateResultStatus = keyof MigrateResultSummary;\n\nexport const printModelMigrationResult = (\n { log, messages }: ContensisCli,\n result: MigrateResultSummary\n) => {\n for (const [status, ids] of Object.entries(result) as [\n MigrateResultStatus,\n string[]\n ][]) {\n if (ids?.length) {\n if (status === 'errors') {\n const errors: [string, MappedError][] = ids as any;\n log.raw(\n ` - ${status}: [ ${messages.migrate.models.result(status)(\n ids.map(id => id[0]).join(', ')\n )} ]\\n`\n );\n for (const [contentTypeId, error] of errors)\n log.error(\n `${log.highlightText(contentTypeId)}: ${error.message}`,\n error\n );\n } else\n log.raw(\n ` - ${status}: [ ${messages.migrate.models.result(status)(\n ids.join(', ')\n )} ]`\n );\n }\n }\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAGlB,oBAAuB;AAEvB,MAAM,aAAa,CAAC,MAAqB,SAAS,2BAChD,aAAAA,SAAM,IAAI,EAAE,OAAO,MAAM;AAEpB,MAAM,oBAAoB,CAC/B,EAAE,KAAK,SAAS,GAChB,OACA,eAAe;AAAA,EACb,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,WAAW;AACb,MACG;AAj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  }
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.0.0-beta.56";
24
+ const LIB_VERSION = "1.0.0-beta.57";
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.0.0-beta.56\";\n"],
4
+ "sourcesContent": ["export const LIB_VERSION = \"1.0.0-beta.57\";\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.0.0-beta.56",
3
+ "version": "1.0.0-beta.57",
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/node-cli",
6
6
  "homepage": "https://github.com/contensis/node-cli/tree/main/packages/contensis-cli#readme",
@@ -1,6 +1,5 @@
1
- import { Argument, Command } from 'commander';
1
+ import { Command, Option } from 'commander';
2
2
  import { cliCommand } from '~/services/ContensisCliService';
3
- import { url } from '~/util';
4
3
  import { commit, mapContensisOpts } from './globalOptions';
5
4
 
6
5
  export const makeImportCommand = () => {
@@ -107,6 +106,14 @@ Example call:
107
106
  '-preserve, --preserve-guids',
108
107
  'include this flag when you are importing entries that you have previously exported and wish to update'
109
108
  )
109
+ .addOption(
110
+ new Option(
111
+ '-oe, --output-entries <outputEntries>',
112
+ 'which details of the entries included in the import to output'
113
+ )
114
+ .choices(['errors', 'changes', 'all'])
115
+ .default('errors')
116
+ )
110
117
  .addHelpText(
111
118
  'after',
112
119
  `
@@ -119,7 +126,11 @@ Example call:
119
126
  ['import', 'entries'],
120
127
  opts,
121
128
  mapContensisOpts({ phrase, ...opts })
122
- ).ImportEntries({ commit: opts.commit, fromFile: opts.fromFile });
129
+ ).ImportEntries({
130
+ commit: opts.commit,
131
+ fromFile: opts.fromFile,
132
+ logOutput: opts.outputEntries,
133
+ });
123
134
  });
124
135
 
125
136
  return program;
@@ -1,6 +1,7 @@
1
1
  import { Command } from 'commander';
2
2
  import { cliCommand } from '~/services/ContensisCliService';
3
3
  import { shell } from '~/shell';
4
+ import { Logger } from '~/util/logger';
4
5
  import { commit, mapContensisOpts, zenql } from './globalOptions';
5
6
 
6
7
  export const makeRemoveCommand = () => {
@@ -81,5 +82,42 @@ Example call:
81
82
  ).RemoveContentTypes(id, opts.commit);
82
83
  });
83
84
 
85
+ const removeEntries = remove
86
+ .command('entries')
87
+ .description('delete entries')
88
+ .argument(
89
+ '[ids...]',
90
+ 'the entry id(s) to delete ...or add *** if you wish to delete all entries in all content types'
91
+ )
92
+ .addOption(zenql)
93
+ .addOption(commit)
94
+ .addHelpText(
95
+ 'after',
96
+ `
97
+ Example call:
98
+ > remove entries a1c25591-8c9b-50e2-96d8-f6c774fcf023 8df914cc-1da1-59d6-86e0-8ea4ebd99aaa
99
+ > remove entries --zenql "sys.contentTypeId = test"
100
+ `
101
+ )
102
+ .action(async (entryIds: string[], opts) => {
103
+ const removeAll = entryIds?.[0] === '***';
104
+
105
+ // Remove all asterisks from args
106
+ if (entryIds?.[0] && !entryIds[0].replace(/\*/g, '')) entryIds.pop();
107
+
108
+ const hasArgs = !!(entryIds?.length || opts.zenql || removeAll);
109
+ if (!hasArgs) {
110
+ Logger.help(
111
+ `Not enough arguments supplied\n\n${removeEntries.helpInformation()}`
112
+ );
113
+ } else {
114
+ await cliCommand(
115
+ ['remove', 'entries', entryIds.join(' ')],
116
+ opts,
117
+ mapContensisOpts({ entryIds, ...opts })
118
+ ).RemoveEntries(opts.commit);
119
+ }
120
+ });
121
+
84
122
  return remove;
85
123
  };
@@ -192,11 +192,14 @@ export const LogMessages = {
192
192
  `No Contensis environment set, connect to your Contensis cloud instance using "contensis connect {cms alias}"`,
193
193
  },
194
194
  entries: {
195
+ imported: (env: string, commit: boolean, count: number) =>
196
+ `[${env}] ${commit ? `Imported` : `Will import`} ${count} entries`,
197
+ failedImport: (env: string) => `[${env}] Unable to delete entries`,
195
198
  removed: (env: string, commit: boolean) =>
196
199
  `[${env}] ${commit ? `Deleted` : `Will delete`} entries`,
197
200
  failedRemove: (env: string) => `[${env}] Unable to delete entries`,
198
201
  notFound: (env: string) => `[${env}] Entries were not found`,
199
- commitTip: () => ` Add --commit flag to commit the previewed changes`,
202
+ commitTip: () => `Add --commit flag to commit the previewed changes`,
200
203
  },
201
204
  keys: {
202
205
  list: (env: string) => `[${env}] API keys:`,
@@ -1345,7 +1345,7 @@ class ContensisCli {
1345
1345
  };
1346
1346
 
1347
1347
  RemoveEntries = async (commit = false) => {
1348
- const { currentEnv, log, messages } = this;
1348
+ const { currentEnv, currentProject, log, messages } = this;
1349
1349
  const contensis = await this.ConnectContensisImport({
1350
1350
  commit,
1351
1351
  importDataType: 'user-input',
@@ -1361,19 +1361,24 @@ class ContensisCli {
1361
1361
  if (result)
1362
1362
  this.HandleFormattingAndOutput(result, () => {
1363
1363
  // print the migrateResult to console
1364
- printMigrateResult(this, result, { action: 'delete' });
1364
+ printMigrateResult(this, result, {
1365
+ action: 'delete',
1366
+ showAllEntries: true,
1367
+ });
1365
1368
  });
1366
1369
  if (
1367
1370
  !err &&
1368
- ((!commit &&
1369
- Object.values(result.entriesToMigrate)?.[0].totalCount > 0) ||
1371
+ ((!commit && result.entriesToMigrate[currentProject].totalCount) ||
1370
1372
  (commit && result.migrateResult?.deleted))
1371
1373
  ) {
1372
1374
  log.success(messages.entries.removed(currentEnv, commit));
1373
- if (!commit) log.help(messages.entries.commitTip());
1375
+ if (!commit) {
1376
+ log.raw(``);
1377
+ log.help(messages.entries.commitTip());
1378
+ }
1374
1379
  } else {
1375
1380
  log.error(messages.entries.failedRemove(currentEnv), err);
1376
- if (!Object.values(result.entriesToMigrate)?.[0].totalCount)
1381
+ if (!result.entriesToMigrate[currentProject].totalCount)
1377
1382
  log.help(messages.entries.notFound(currentEnv));
1378
1383
  }
1379
1384
  }
@@ -1407,11 +1412,13 @@ class ContensisCli {
1407
1412
  ImportEntries = async ({
1408
1413
  commit,
1409
1414
  fromFile,
1415
+ logOutput,
1410
1416
  }: {
1411
1417
  commit: boolean;
1412
1418
  fromFile: string;
1419
+ logOutput: string;
1413
1420
  }) => {
1414
- const { currentProject, log, messages } = this;
1421
+ const { currentEnv, currentProject, log, messages } = this;
1415
1422
 
1416
1423
  const contensis = await this.ConnectContensisImport({
1417
1424
  commit,
@@ -1427,14 +1434,43 @@ class ContensisCli {
1427
1434
  console.log(log.warningText(` *** COMMITTING IMPORT *** `));
1428
1435
  }
1429
1436
 
1430
- const [migrateErr, migrateResult] = await contensis.MigrateEntries();
1437
+ const [err, result] = await contensis.MigrateEntries();
1431
1438
 
1432
- if (migrateErr) logError(migrateErr);
1439
+ if (err) logError(err);
1433
1440
  else
1434
- this.HandleFormattingAndOutput(migrateResult, () => {
1441
+ this.HandleFormattingAndOutput(result, () => {
1435
1442
  // print the migrateResult to console
1436
- printMigrateResult(this, migrateResult);
1443
+ printMigrateResult(this, result, {
1444
+ showAllEntries: logOutput === 'all',
1445
+ showChangedEntries: logOutput === 'changes',
1446
+ });
1437
1447
  });
1448
+
1449
+ if (
1450
+ !err &&
1451
+ ((!commit && result.entriesToMigrate[currentProject].totalCount) ||
1452
+ (commit &&
1453
+ (result.migrateResult?.created || result.migrateResult?.updated)))
1454
+ ) {
1455
+ log.success(
1456
+ messages.entries.imported(
1457
+ currentEnv,
1458
+ commit,
1459
+ commit
1460
+ ? (result.migrateResult?.created || 0) +
1461
+ (result.migrateResult?.updated || 0)
1462
+ : result.entriesToMigrate[currentProject].totalCount
1463
+ )
1464
+ );
1465
+ if (!commit) {
1466
+ log.raw(``);
1467
+ log.help(messages.entries.commitTip());
1468
+ }
1469
+ } else {
1470
+ log.error(messages.entries.failedImport(currentEnv), err);
1471
+ if (!result.entriesToMigrate[currentProject].totalCount)
1472
+ log.help(messages.entries.notFound(currentEnv));
1473
+ }
1438
1474
  } else {
1439
1475
  log.warning(messages.models.noList(currentProject));
1440
1476
  log.help(messages.connect.tip());
@@ -105,7 +105,7 @@ export const printBlockVersion = (
105
105
  };
106
106
 
107
107
  export const printMigrateResult = (
108
- { log, messages, contensis, currentProject }: ContensisCli,
108
+ { log, messages, currentProject }: ContensisCli,
109
109
  migrateResult: any,
110
110
  {
111
111
  action = 'import',
@@ -119,8 +119,8 @@ export const printMigrateResult = (
119
119
  showChangedEntries?: boolean;
120
120
  } = {}
121
121
  ) => {
122
- if (Object.keys(migrateResult.entriesToMigrate.entryIds).length)
123
- console.log(``);
122
+ // if (Object.keys(migrateResult.entriesToMigrate.entryIds).length)
123
+ console.log(``);
124
124
 
125
125
  for (const [contentTypeId, entryRes] of Object.entries(
126
126
  migrateResult.entriesToMigrate.entryIds
@@ -175,89 +175,93 @@ export const printMigrateResult = (
175
175
  }
176
176
  }
177
177
  }
178
- console.log(``);
179
- if (
180
- contensis?.isPreview &&
181
- migrateResult.entriesToMigrate?.[currentProject]?.totalCount > 0 &&
182
- !migrateResult.errors
183
- ) {
184
- log.help(messages.entries.commitTip());
185
- }
178
+ if (showAllEntries || showChangedEntries) console.log(``);
179
+ // if (
180
+ // contensis?.isPreview &&
181
+ // migrateResult.entriesToMigrate?.[currentProject]?.totalCount > 0 &&
182
+ // !migrateResult.errors
183
+ // ) {
184
+ // log.help(messages.entries.commitTip());
185
+ // }
186
186
 
187
- if (action === 'import') {
188
- for (const [projectId, contentTypeCounts] of Object.entries(
189
- migrateResult.entries || {}
190
- ) as [string, any][]) {
191
- log.help(
192
- `import from project ${log.highlightText(projectId)} to ${log.boldText(
193
- log.warningText(currentProject)
194
- )}`
195
- );
196
- for (const [contentTypeId, count] of Object.entries(
197
- contentTypeCounts
198
- ) as [string, number][]) {
199
- const migrateStatusAndCount =
200
- migrateResult.entriesToMigrate[currentProject][contentTypeId];
201
- const existingCount =
202
- migrateResult.existing?.[currentProject]?.[contentTypeId] || 0;
203
- const existingPercent = ((existingCount / count) * 100).toFixed(0);
204
- const noChangeOrTotalEntriesCount =
205
- typeof migrateStatusAndCount !== 'number'
206
- ? migrateStatusAndCount?.['no change'] || 0
207
- : migrateStatusAndCount;
187
+ for (const [projectId, contentTypeCounts] of Object.entries(
188
+ migrateResult.entries || {}
189
+ ) as [string, any][]) {
190
+ log.help(
191
+ `${action} from project ${
192
+ action === 'delete'
193
+ ? log.warningText(currentProject)
194
+ : `${log.highlightText(projectId)} to ${log.boldText(
195
+ log.warningText(currentProject)
196
+ )}`
197
+ }`
198
+ );
199
+ for (const [contentTypeId, count] of Object.entries(contentTypeCounts) as [
200
+ string,
201
+ number
202
+ ][]) {
203
+ const migrateStatusAndCount =
204
+ migrateResult.entriesToMigrate[currentProject][contentTypeId];
205
+ const existingCount =
206
+ migrateResult.existing?.[currentProject]?.[contentTypeId] || 0;
207
+ const existingPercent = ((existingCount / count) * 100).toFixed(0);
208
+ const noChangeOrTotalEntriesCount =
209
+ typeof migrateStatusAndCount !== 'number'
210
+ ? migrateStatusAndCount?.['no change'] || 0
211
+ : migrateStatusAndCount;
208
212
 
209
- const isTotalCountRow = contentTypeId === 'totalCount';
213
+ const isTotalCountRow = contentTypeId === 'totalCount';
210
214
 
211
- const changedPercentage = (
212
- (noChangeOrTotalEntriesCount / count) *
213
- 100
214
- ).toFixed(0);
215
+ const changedPercentage = (
216
+ (noChangeOrTotalEntriesCount / count) *
217
+ 100
218
+ ).toFixed(0);
215
219
 
216
- const existingColor =
217
- existingPercent === '0' ? log.warningText : log.infoText;
218
- const changedColor = isTotalCountRow
219
- ? log.helpText
220
- : changedPercentage === '100'
221
- ? log.successText
222
- : log.warningText;
220
+ const existingColor =
221
+ existingPercent === '0' ? log.warningText : log.infoText;
222
+ const changedColor = isTotalCountRow
223
+ ? log.helpText
224
+ : changedPercentage === '100'
225
+ ? log.successText
226
+ : log.warningText;
223
227
 
224
- console.log(
225
- ` - ${
226
- isTotalCountRow
227
- ? log.highlightText(`${contentTypeId}: ${count}`)
228
- : `${contentTypeId}: ${log.helpText(count)}`
229
- }${
230
- changedPercentage === '100'
231
- ? ''
232
- : existingColor(
233
- ` [existing: ${
234
- isTotalCountRow ? existingCount : `${existingPercent}%`
235
- }]`
236
- )
237
- }${
238
- existingPercent === '0'
239
- ? ''
240
- : changedColor(
241
- ` ${
242
- isTotalCountRow
243
- ? `[to change: ${noChangeOrTotalEntriesCount}]`
244
- : changedPercentage === '100'
245
- ? 'up to date'
246
- : `[needs update: ${100 - Number(changedPercentage)}%]`
247
- }`
248
- )
249
- }`
250
- );
251
- }
252
- }
253
- if (migrateResult.errors?.length) {
254
228
  console.log(
255
- ` - ${log.errorText(`errors: ${migrateResult.errors.length}`)}\n`
229
+ ` - ${
230
+ isTotalCountRow
231
+ ? log.highlightText(
232
+ `${contentTypeId}: ${noChangeOrTotalEntriesCount}`
233
+ )
234
+ : `${contentTypeId}: ${log.helpText(count)}`
235
+ }${
236
+ changedPercentage === '100' || action === 'delete'
237
+ ? ''
238
+ : existingColor(
239
+ ` [existing: ${
240
+ isTotalCountRow ? existingCount : `${existingPercent}%`
241
+ }]`
242
+ )
243
+ }${
244
+ existingPercent === '0'
245
+ ? ''
246
+ : changedColor(
247
+ ` ${
248
+ isTotalCountRow
249
+ ? `[to ${action}: ${noChangeOrTotalEntriesCount}]`
250
+ : changedPercentage === '100'
251
+ ? 'up to date'
252
+ : `[needs update: ${100 - Number(changedPercentage)}%]`
253
+ }`
254
+ )
255
+ }`
256
256
  );
257
- for (const error of migrateResult.errors)
258
- log.error(error.message || error);
259
257
  }
260
258
  }
259
+ if (migrateResult.errors?.length) {
260
+ console.log(
261
+ ` - ${log.errorText(`errors: ${migrateResult.errors.length}`)}\n`
262
+ );
263
+ for (const error of migrateResult.errors) log.error(error.message || error);
264
+ }
261
265
  };
262
266
 
263
267
  const highlightDiffText = (str: string) => {
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const LIB_VERSION = "1.0.0-beta.56";
1
+ export const LIB_VERSION = "1.0.0-beta.57";