contensis-cli 1.0.0-beta.47 → 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.47";
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.47\";\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.47",
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"
@@ -5,12 +5,14 @@ import { mapContensisOpts } from './globalOptions';
5
5
  export const makeDiffCommand = () => {
6
6
  const release = new Command()
7
7
  .command('diff')
8
+ .description('diff command')
8
9
  .addHelpText('after', `\n`)
9
10
  .showHelpAfterError(true)
10
11
  .exitOverride();
11
12
 
12
13
  release
13
14
  .command('models')
15
+ .description('differences with content models')
14
16
  .argument(
15
17
  '[model-ids...]',
16
18
  'ids of any content types or components to diff (optional)'
@@ -11,7 +11,7 @@ export const makeGetCommand = () => {
11
11
 
12
12
  program
13
13
  .command('version')
14
- .description('Get current Contensis version')
14
+ .description('get current Contensis version')
15
15
  .addHelpText(
16
16
  'after',
17
17
  `
@@ -23,9 +23,26 @@ Example call:
23
23
  await cliCommand(['get', 'version'], opts).PrintContensisVersion();
24
24
  });
25
25
 
26
+ program
27
+ .command('project')
28
+ .description('get a project')
29
+ .argument('[projectId]', 'id of the project to get (default: current)')
30
+ .addHelpText(
31
+ 'after',
32
+ `
33
+ Example call:
34
+ > get project website
35
+ `
36
+ )
37
+ .action(async (projectId: string, opts) => {
38
+ await cliCommand(['get', 'project', projectId], opts).PrintProject(
39
+ projectId
40
+ );
41
+ });
42
+
26
43
  program
27
44
  .command('model')
28
- .description('Get a content model')
45
+ .description('get a content model')
29
46
  .argument('<contentTypeId...>', 'ids of the content models to get')
30
47
  .addHelpText(
31
48
  'after',
@@ -43,7 +60,7 @@ Example call:
43
60
 
44
61
  program
45
62
  .command('contenttype')
46
- .description('Get a content type')
63
+ .description('get a content type')
47
64
  .argument('<contentTypeId>', 'the API id of the content type to get')
48
65
  .addHelpText(
49
66
  'after',
@@ -61,7 +78,7 @@ Example call:
61
78
 
62
79
  program
63
80
  .command('component')
64
- .description('Get a component')
81
+ .description('get a component')
65
82
  .argument('<componentId>', 'the API id of the component to get')
66
83
  .addHelpText(
67
84
  'after',
@@ -78,7 +95,7 @@ Example call:
78
95
 
79
96
  program
80
97
  .command('entries')
81
- .description('Get entries')
98
+ .description('get entries')
82
99
  .argument(
83
100
  '[search phrase]',
84
101
  'get entries with the search phrase, use quotes for multiple words'
@@ -117,7 +134,7 @@ Example call:
117
134
 
118
135
  const block = program
119
136
  .command('block')
120
- .description('Get a block or block version')
137
+ .description('get a block or block version')
121
138
  .argument('[blockId]', 'the block to get version details for')
122
139
  .argument(
123
140
  '[branch]',
@@ -152,7 +169,7 @@ Example call:
152
169
 
153
170
  block
154
171
  .command('logs')
155
- .description('Get logs for a block')
172
+ .description('get logs for a block')
156
173
  .argument('[blockId]', 'the block to get version logs for')
157
174
  .argument(
158
175
  '[branch]',
@@ -4,6 +4,7 @@ import { cliCommand } from '~/services/ContensisCliService';
4
4
  export const makeListCommand = () => {
5
5
  const list = new Command()
6
6
  .command('list')
7
+ .description('list command')
7
8
  .addHelpText('after', `\n`)
8
9
  .showHelpAfterError(true)
9
10
  .exitOverride();
@@ -24,14 +25,14 @@ Example call:
24
25
 
25
26
  list
26
27
  .command('projects')
27
- .description('Print list of projects')
28
+ .description('print list of projects')
28
29
  .action(async opts => {
29
30
  await cliCommand(['list', 'projects'], opts).PrintProjects();
30
31
  });
31
32
 
32
33
  list
33
34
  .command('models')
34
- .description('Print list of content models')
35
+ .description('print list of content models')
35
36
  .addHelpText(
36
37
  'after',
37
38
  `
@@ -45,7 +46,7 @@ Example call:
45
46
 
46
47
  list
47
48
  .command('contenttypes')
48
- .description('Print list of content types')
49
+ .description('print list of content types')
49
50
  .addHelpText(
50
51
  'after',
51
52
  `
@@ -59,7 +60,7 @@ Example call:
59
60
 
60
61
  list
61
62
  .command('components')
62
- .description('Print list of components')
63
+ .description('print list of components')
63
64
  .addHelpText(
64
65
  'after',
65
66
  `
@@ -73,7 +74,7 @@ Example call:
73
74
 
74
75
  list
75
76
  .command('blocks')
76
- .description('Print list of content blocks')
77
+ .description('print list of content blocks')
77
78
  .addHelpText(
78
79
  'after',
79
80
  `
@@ -87,7 +88,7 @@ Example call:
87
88
 
88
89
  list
89
90
  .command('keys')
90
- .description('Print list of API keys')
91
+ .description('print list of API keys')
91
92
  .addHelpText(
92
93
  'after',
93
94
  `
@@ -101,7 +102,7 @@ Example call:
101
102
 
102
103
  list
103
104
  .command('webhooks')
104
- .description('Print list of webhooks')
105
+ .description('print list of webhooks')
105
106
  .argument('[name]', 'find webhooks matching the supplied name')
106
107
  .option('-i --id <id...>', 'the subscription id(s) to get')
107
108
  .addHelpText('after', `\n`)
@@ -6,12 +6,14 @@ import { cliCommand } from '~/services/ContensisCliService';
6
6
  export const makePushCommand = () => {
7
7
  const push = new Command()
8
8
  .command('push')
9
+ .description('push command')
9
10
  .addHelpText('after', `\n`)
10
11
  .showHelpAfterError(true)
11
12
  .exitOverride();
12
13
 
13
14
  push
14
15
  .command('block')
16
+ .description('push a block')
15
17
  .argument('<block-id>', 'the name of the block to push to')
16
18
  .argument(
17
19
  '<image uri:tag>',
@@ -4,12 +4,14 @@ import { cliCommand } from '~/services/ContensisCliService';
4
4
  export const makeReleaseCommand = () => {
5
5
  const release = new Command()
6
6
  .command('release')
7
+ .description('release command')
7
8
  .addHelpText('after', `\n`)
8
9
  .showHelpAfterError(true)
9
10
  .exitOverride();
10
11
 
11
12
  release
12
13
  .command('block')
14
+ .description('release a block version')
13
15
  .argument('<block-id>', 'the name of the block to release')
14
16
  .argument('<version>', 'the block version to release')
15
17
  .usage('<block-id> <version>')
@@ -1,17 +1,19 @@
1
1
  import { Command } from 'commander';
2
2
  import { cliCommand } from '~/services/ContensisCliService';
3
3
  import { shell } from '~/shell';
4
- import { commit, mapContensisOpts } from './globalOptions';
4
+ import { commit, mapContensisOpts, zenql } from './globalOptions';
5
5
 
6
6
  export const makeRemoveCommand = () => {
7
7
  const remove = new Command()
8
8
  .command('remove')
9
+ .description('remove command')
9
10
  .addHelpText('after', `\n`)
10
11
  .showHelpAfterError(true)
11
12
  .exitOverride();
12
13
 
13
14
  remove
14
15
  .command('project')
16
+ .description('remove an entire project')
15
17
  .argument('<projectId>', 'the project id to delete')
16
18
  .usage('<projectId>')
17
19
  .addHelpText('after', `\n`)
@@ -22,8 +24,10 @@ export const makeRemoveCommand = () => {
22
24
  ).SetProject(projectId);
23
25
  if (project) await shell().restart();
24
26
  });
27
+
25
28
  remove
26
29
  .command('key')
30
+ .description('remove api key')
27
31
  .argument('<id>', 'the id of the API key to delete')
28
32
  .usage('<id>')
29
33
  .addHelpText(
@@ -39,6 +43,7 @@ Example call:
39
43
 
40
44
  remove
41
45
  .command('components')
46
+ .description('delete components')
42
47
  .argument('<id...>', 'the id(s) of the components to delete')
43
48
  .addOption(commit)
44
49
  .usage('<id> [--commit]')
@@ -58,6 +63,7 @@ Example call:
58
63
 
59
64
  remove
60
65
  .command('contenttypes')
66
+ .description('delete content types')
61
67
  .argument('<id...>', 'the id(s) of the content types to delete')
62
68
  .addOption(commit)
63
69
  .usage('<id> [--commit]')
@@ -5,15 +5,22 @@ import { shell } from '~/shell';
5
5
  export const makeSetCommand = () => {
6
6
  const set = new Command()
7
7
  .command('set')
8
+ .description('set command')
8
9
  .addHelpText('after', `\n`)
9
10
  .showHelpAfterError(true)
10
11
  .exitOverride();
11
12
 
12
13
  const project = set
13
14
  .command('project')
15
+ .description('set current working project')
14
16
  .argument('<projectId>', 'the project id to work with')
15
17
  .usage('<projectId>')
16
- .addHelpText('after', `\n`)
18
+ .addHelpText(
19
+ 'after',
20
+ `
21
+ Example call:
22
+ > set project website\n`
23
+ )
17
24
  .action(async projectId => {
18
25
  const nextProjectId = cliCommand([
19
26
  'set',
@@ -25,6 +32,7 @@ export const makeSetCommand = () => {
25
32
 
26
33
  project
27
34
  .command('name')
35
+ .description('update project name')
28
36
  .argument('<"Project name">', 'update the current project name')
29
37
  .usage('<"Project name">')
30
38
  .addHelpText(
@@ -45,6 +53,7 @@ Example call:
45
53
 
46
54
  project
47
55
  .command('description')
56
+ .description('update project description')
48
57
  .argument(
49
58
  '<"Project description">',
50
59
  'update the current project description'
@@ -68,6 +77,7 @@ Example call:
68
77
 
69
78
  set
70
79
  .command('version')
80
+ .description('set content version')
71
81
  .addArgument(
72
82
  new Argument('<versionStatus>', 'content version status')
73
83
  .choices(['latest', 'published'])
@@ -643,6 +643,32 @@ class ContensisCli {
643
643
  }
644
644
  };
645
645
 
646
+ PrintProject = async (projectId = this.currentProject) => {
647
+ const { log, messages, session } = this;
648
+ const contensis = await this.ConnectContensis();
649
+
650
+ if (contensis) {
651
+ // Retrieve projects list for env
652
+ const [projectsErr, projects] = await to(
653
+ contensis.projects.GetSourceProjects()
654
+ );
655
+
656
+ const foundProject = projects?.find(
657
+ p => p.id.toLowerCase() === projectId.toLowerCase()
658
+ );
659
+
660
+ if (foundProject) {
661
+ log.raw('');
662
+ this.HandleFormattingAndOutput(foundProject, log.object);
663
+ }
664
+
665
+ if (projectsErr) {
666
+ log.error(messages.projects.noList());
667
+ log.error(projectsErr.message);
668
+ }
669
+ }
670
+ };
671
+
646
672
  SetProject = (projectId = 'website') => {
647
673
  const { env, log, messages, session } = this;
648
674
  let nextProjectId: string | undefined;
package/src/shell.ts CHANGED
@@ -143,6 +143,7 @@ class ContensisShell {
143
143
  'get component',
144
144
  'get entries',
145
145
  'get model',
146
+ 'get project',
146
147
  'get version',
147
148
  'import contenttypes',
148
149
  'import components',