contensis-cli 1.0.0-beta.48 → 1.0.0-beta.49

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.
@@ -121,52 +121,98 @@ const printBlockVersion = ({ log, messages }, block, printOptions = {
121
121
  console.log(` staging url: ${log.infoText(block.stagingUrl)}`);
122
122
  console.log("");
123
123
  };
124
- const printMigrateResult = ({ log, messages, contensis, currentProject }, migrateResult, { action = "import" } = {}) => {
125
- var _a, _b;
124
+ const printMigrateResult = ({ log, messages, contensis, currentProject }, migrateResult, {
125
+ action = "import",
126
+ showDiff = false,
127
+ showAllEntries = false,
128
+ showChangedEntries = false
129
+ } = {}) => {
130
+ var _a, _b, _c, _d, _e, _f, _g;
126
131
  if (Object.keys(migrateResult.entriesToMigrate.entryIds).length)
127
132
  console.log(``);
128
133
  for (const [contentTypeId, entryRes] of Object.entries(
129
134
  migrateResult.entriesToMigrate.entryIds
130
135
  )) {
131
136
  for (const [originalId, entryStatus] of Object.entries(entryRes)) {
132
- console.log(`${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`);
133
- console.log(
134
- log.infoText(
135
- ` ${originalId} ${Object.entries(entryStatus || {}).filter((x) => x[0] !== "entryTitle").map(([projectId, projectStatus]) => {
136
- var _a2;
137
- const [targetGuid, { status }] = ((_a2 = Object.entries(
138
- projectStatus || {}
139
- )) == null ? void 0 : _a2[0]) || [
140
- "",
141
- { x: { status: void 0 } }
142
- ];
143
- return `${messages.migrate.status(status)(`${status}`)}${targetGuid !== originalId ? `-> ${targetGuid}` : ""}`;
144
- })}`
145
- )
146
- );
147
- for (const [projectId, projectStatus] of Object.entries(
148
- entryStatus
149
- ).filter(([key]) => key !== "entryTitle")) {
150
- const [targetGuid, { error, diff, status }] = Object.entries(
151
- projectStatus
152
- )[0];
153
- if (error)
154
- log.error(error);
155
- if (diff) {
156
- console.log(
157
- ` ${log.highlightText(`diff:`)} ${log.infoText(
158
- highlightDiffText(diff)
159
- )}
137
+ if (showAllEntries || showChangedEntries && Object.entries(
138
+ Object.entries(entryStatus[currentProject])[0]
139
+ )[1][1].status !== "no change") {
140
+ console.log(
141
+ log.infoText(
142
+ `${originalId} ${Object.entries(entryStatus || {}).filter((x) => x[0] !== "entryTitle").map(([projectId, projectStatus]) => {
143
+ var _a2;
144
+ const [targetGuid, { status }] = ((_a2 = Object.entries(
145
+ projectStatus || {}
146
+ )) == null ? void 0 : _a2[0]) || [
147
+ "",
148
+ { x: { status: void 0 } }
149
+ ];
150
+ return `${messages.migrate.status(status)(`${status}`)}${targetGuid !== originalId ? `-> ${targetGuid}` : ""}`;
151
+ })}`
152
+ ) + ` ${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`
153
+ );
154
+ for (const [projectId, projectStatus] of Object.entries(
155
+ entryStatus
156
+ ).filter(([key]) => key !== "entryTitle")) {
157
+ const [targetGuid, { error, diff, status }] = Object.entries(
158
+ projectStatus
159
+ )[0];
160
+ if (error)
161
+ log.error(error);
162
+ if (diff && showDiff) {
163
+ console.log(
164
+ ` ${log.highlightText(`diff:`)} ${log.infoText(
165
+ highlightDiffText(diff)
166
+ )}
160
167
  `
161
- );
168
+ );
169
+ }
162
170
  }
163
171
  }
164
172
  }
165
- console.log(``);
166
173
  }
174
+ console.log(``);
167
175
  if ((contensis == null ? void 0 : contensis.isPreview) && ((_b = (_a = migrateResult.entriesToMigrate) == null ? void 0 : _a[currentProject]) == null ? void 0 : _b.totalCount) > 0 && !migrateResult.errors) {
168
176
  log.help(messages.entries.commitTip());
169
177
  }
178
+ if (action === "import") {
179
+ for (const [projectId, contentTypeCounts] of Object.entries(
180
+ migrateResult.entries || {}
181
+ )) {
182
+ log.help(
183
+ `import from project ${log.highlightText(projectId)} to ${log.boldText(
184
+ log.warningText(currentProject)
185
+ )}`
186
+ );
187
+ for (const [contentTypeId, count] of Object.entries(
188
+ contentTypeCounts
189
+ )) {
190
+ const entriesToMigrate = (_d = (_c = migrateResult.entriesToMigrate) == null ? void 0 : _c[projectId]) == null ? void 0 : _d[contentTypeId];
191
+ const existingCount = ((_f = (_e = migrateResult.existing) == null ? void 0 : _e[projectId]) == null ? void 0 : _f[contentTypeId]) || 0;
192
+ const existingPercent = (existingCount / count * 100).toFixed(0);
193
+ const noChangeOrTotalEntriesCount = typeof entriesToMigrate !== "number" ? (entriesToMigrate == null ? void 0 : entriesToMigrate["no change"]) || 0 : entriesToMigrate;
194
+ const isTotalCountRow = contentTypeId === "totalCount";
195
+ const changedPercentage = (noChangeOrTotalEntriesCount / count * 100).toFixed(0);
196
+ const existingColor = existingPercent === "0" ? log.warningText : log.infoText;
197
+ const changedColor = isTotalCountRow ? log.helpText : changedPercentage === "100" ? log.successText : log.warningText;
198
+ console.log(
199
+ ` - ${isTotalCountRow ? log.highlightText(`${contentTypeId}: ${count}`) : `${contentTypeId}: ${log.helpText(count)}`}${changedPercentage === "100" ? "" : existingColor(
200
+ ` [existing: ${isTotalCountRow ? existingCount : `${existingPercent}%`}]`
201
+ )}${existingPercent === "0" ? "" : changedColor(
202
+ ` ${isTotalCountRow ? `[to change: ${noChangeOrTotalEntriesCount}]` : changedPercentage === "100" ? "up to date" : `[needs update: ${100 - Number(changedPercentage)}%]`}`
203
+ )}`
204
+ );
205
+ }
206
+ }
207
+ if ((_g = migrateResult.errors) == null ? void 0 : _g.length) {
208
+ console.log(
209
+ ` - ${log.errorText(`errors: ${migrateResult.errors.length}`)}
210
+ `
211
+ );
212
+ for (const error of migrateResult.errors)
213
+ log.error(error.message || error);
214
+ }
215
+ }
170
216
  };
171
217
  const highlightDiffText = (str) => {
172
218
  const addedRegex = new RegExp(/<<\+>>(.*?)<<\/\+>>/, "g");
@@ -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 { action = 'import' }: { action?: 'import' | 'delete' } = {}\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 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 )\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) {\n console.log(\n ` ${log.highlightText(`diff:`)} ${log.infoText(\n highlightDiffText(diff)\n )}\\n`\n );\n }\n }\n }\n console.log(``);\n }\n if (\n contensis?.isPreview &&\n migrateResult.entriesToMigrate?.[currentProject]?.totalCount > 0 &&\n !migrateResult.errors\n ) {\n log.help(messages.entries.commitTip());\n }\n\n // Needs work\n // if (action === 'import') {\n // for (const [projectId, contentTypeCounts] of Object.entries(\n // migrateResult.entries || {}\n // ) as [string, any][]) {\n // console.log(\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 entriesToMigrate =\n // migrateResult.entriesToMigrate?.[projectId]?.[contentTypeId];\n\n // console.log(\n // ` - ${\n // contentTypeId === 'totalCount'\n // ? log.warningText(`${contentTypeId}: ${count}`)\n // : `${contentTypeId}: ${log.helpText(count)}`\n // } ${log.infoText`[existing: ${(\n // ((migrateResult.existing?.[projectId]?.[contentTypeId] || 0) /\n // count) *\n // 100\n // ).toFixed(0)}%]`} [${\n // typeof entriesToMigrate !== 'number' ? `unchanged` : `to update`\n // }: ${(\n // ((typeof entriesToMigrate !== 'number'\n // ? entriesToMigrate?.['no change'] || 0\n // : entriesToMigrate) /\n // count) *\n // 100\n // ).toFixed(0)}%]`\n // );\n // }\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,SA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AAO,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, 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 entriesToMigrate =\n migrateResult.entriesToMigrate?.[projectId]?.[contentTypeId];\n const existingCount =\n migrateResult.existing?.[projectId]?.[contentTypeId] || 0;\n const existingPercent = ((existingCount / count) * 100).toFixed(0);\n const noChangeOrTotalEntriesCount =\n typeof entriesToMigrate !== 'number'\n ? entriesToMigrate?.['no change'] || 0\n : entriesToMigrate;\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,UAAQ;AAAA,IACN,KAAK,IAAI,aAAa,IAAI,MAAM,QAAQ,WAAW,KAAK,MAAM;AAAA,EAChE;AACA,UAAQ;AAAA,IAC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,IACJ;AAAA,EACF;AACF;",
6
6
  "names": ["dayjs", "_a"]
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.0.0-beta.48";
24
+ const LIB_VERSION = "1.0.0-beta.49";
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.48\";\n"],
4
+ "sourcesContent": ["export const LIB_VERSION = \"1.0.0-beta.49\";\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.48",
3
+ "version": "1.0.0-beta.49",
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",
@@ -35,7 +35,7 @@
35
35
  "jsonpath-mapper": "^1.1.0",
36
36
  "keytar": "^7.9.0",
37
37
  "lodash": "^4.17.21",
38
- "migratortron": "^1.0.0-beta.18",
38
+ "migratortron": "^1.0.0-beta.19",
39
39
  "node-fetch": "^2.6.7",
40
40
  "patch-package": "^6.4.7",
41
41
  "xml2js": "^0.4.23"
@@ -107,7 +107,17 @@ export const printBlockVersion = (
107
107
  export const printMigrateResult = (
108
108
  { log, messages, contensis, currentProject }: ContensisCli,
109
109
  migrateResult: any,
110
- { action = 'import' }: { action?: 'import' | 'delete' } = {}
110
+ {
111
+ action = 'import',
112
+ showDiff = false,
113
+ showAllEntries = false,
114
+ showChangedEntries = false,
115
+ }: {
116
+ action?: 'import' | 'delete';
117
+ showDiff?: boolean;
118
+ showAllEntries?: boolean;
119
+ showChangedEntries?: boolean;
120
+ } = {}
111
121
  ) => {
112
122
  if (Object.keys(migrateResult.entriesToMigrate.entryIds).length)
113
123
  console.log(``);
@@ -119,43 +129,53 @@ export const printMigrateResult = (
119
129
  string,
120
130
  any
121
131
  ][]) {
122
- console.log(`${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`);
123
- console.log(
124
- log.infoText(
125
- ` ${originalId} ${Object.entries(entryStatus || {})
126
- .filter(x => x[0] !== 'entryTitle')
127
- .map(([projectId, projectStatus]) => {
128
- const [targetGuid, { status }] = (Object.entries(
129
- projectStatus || {}
130
- )?.[0] as [string, { status: MigrateStatus }]) || [
131
- '',
132
- { x: { status: undefined } },
133
- ];
134
- return `${messages.migrate.status(status)(`${status}`)}${
135
- targetGuid !== originalId ? `-> ${targetGuid}` : ''
136
- }`;
137
- })}`
138
- )
139
- );
132
+ // console.log(`${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`);
133
+ if (
134
+ showAllEntries ||
135
+ (showChangedEntries &&
136
+ (
137
+ Object.entries(
138
+ Object.entries(entryStatus[currentProject])[0]
139
+ )[1][1] as any
140
+ ).status !== 'no change')
141
+ ) {
142
+ console.log(
143
+ log.infoText(
144
+ `${originalId} ${Object.entries(entryStatus || {})
145
+ .filter(x => x[0] !== 'entryTitle')
146
+ .map(([projectId, projectStatus]) => {
147
+ const [targetGuid, { status }] = (Object.entries(
148
+ projectStatus || {}
149
+ )?.[0] as [string, { status: MigrateStatus }]) || [
150
+ '',
151
+ { x: { status: undefined } },
152
+ ];
153
+ return `${messages.migrate.status(status)(`${status}`)}${
154
+ targetGuid !== originalId ? `-> ${targetGuid}` : ''
155
+ }`;
156
+ })}`
157
+ ) + ` ${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`
158
+ );
140
159
 
141
- for (const [projectId, projectStatus] of Object.entries(
142
- entryStatus
143
- ).filter(([key]) => key !== 'entryTitle') as [string, any][]) {
144
- const [targetGuid, { error, diff, status }] = Object.entries(
145
- projectStatus
146
- )[0] as [string, any];
147
- if (error) log.error(error);
148
- if (diff) {
149
- console.log(
150
- ` ${log.highlightText(`diff:`)} ${log.infoText(
151
- highlightDiffText(diff)
152
- )}\n`
153
- );
160
+ for (const [projectId, projectStatus] of Object.entries(
161
+ entryStatus
162
+ ).filter(([key]) => key !== 'entryTitle') as [string, any][]) {
163
+ const [targetGuid, { error, diff, status }] = Object.entries(
164
+ projectStatus
165
+ )[0] as [string, any];
166
+ if (error) log.error(error);
167
+ if (diff && showDiff) {
168
+ console.log(
169
+ ` ${log.highlightText(`diff:`)} ${log.infoText(
170
+ highlightDiffText(diff)
171
+ )}\n`
172
+ );
173
+ }
154
174
  }
155
175
  }
156
176
  }
157
- console.log(``);
158
177
  }
178
+ console.log(``);
159
179
  if (
160
180
  contensis?.isPreview &&
161
181
  migrateResult.entriesToMigrate?.[currentProject]?.totalCount > 0 &&
@@ -164,44 +184,80 @@ export const printMigrateResult = (
164
184
  log.help(messages.entries.commitTip());
165
185
  }
166
186
 
167
- // Needs work
168
- // if (action === 'import') {
169
- // for (const [projectId, contentTypeCounts] of Object.entries(
170
- // migrateResult.entries || {}
171
- // ) as [string, any][]) {
172
- // console.log(
173
- // `import from project ${log.highlightText(projectId)} to ${log.boldText(
174
- // log.warningText(currentProject)
175
- // )}`
176
- // );
177
- // for (const [contentTypeId, count] of Object.entries(
178
- // contentTypeCounts
179
- // ) as [string, number][]) {
180
- // const entriesToMigrate =
181
- // migrateResult.entriesToMigrate?.[projectId]?.[contentTypeId];
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 entriesToMigrate =
200
+ migrateResult.entriesToMigrate?.[projectId]?.[contentTypeId];
201
+ const existingCount =
202
+ migrateResult.existing?.[projectId]?.[contentTypeId] || 0;
203
+ const existingPercent = ((existingCount / count) * 100).toFixed(0);
204
+ const noChangeOrTotalEntriesCount =
205
+ typeof entriesToMigrate !== 'number'
206
+ ? entriesToMigrate?.['no change'] || 0
207
+ : entriesToMigrate;
208
+
209
+ const isTotalCountRow = contentTypeId === 'totalCount';
210
+
211
+ const changedPercentage = (
212
+ (noChangeOrTotalEntriesCount / count) *
213
+ 100
214
+ ).toFixed(0);
182
215
 
183
- // console.log(
184
- // ` - ${
185
- // contentTypeId === 'totalCount'
186
- // ? log.warningText(`${contentTypeId}: ${count}`)
187
- // : `${contentTypeId}: ${log.helpText(count)}`
188
- // } ${log.infoText`[existing: ${(
189
- // ((migrateResult.existing?.[projectId]?.[contentTypeId] || 0) /
190
- // count) *
191
- // 100
192
- // ).toFixed(0)}%]`} [${
193
- // typeof entriesToMigrate !== 'number' ? `unchanged` : `to update`
194
- // }: ${(
195
- // ((typeof entriesToMigrate !== 'number'
196
- // ? entriesToMigrate?.['no change'] || 0
197
- // : entriesToMigrate) /
198
- // count) *
199
- // 100
200
- // ).toFixed(0)}%]`
201
- // );
202
- // }
203
- // }
204
- // }
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;
223
+
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
+ console.log(
255
+ ` - ${log.errorText(`errors: ${migrateResult.errors.length}`)}\n`
256
+ );
257
+ for (const error of migrateResult.errors)
258
+ log.error(error.message || error);
259
+ }
260
+ }
205
261
  };
206
262
 
207
263
  const highlightDiffText = (str: string) => {
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const LIB_VERSION = "1.0.0-beta.48";
1
+ export const LIB_VERSION = "1.0.0-beta.49";