contensis-cli 1.0.0-beta.40 → 1.0.0-beta.42

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.
@@ -122,38 +122,17 @@ const printBlockVersion = ({ log, messages }, block, printOptions = {
122
122
  console.log("");
123
123
  };
124
124
  const printMigrateResult = ({ log, messages, contensis, currentProject }, migrateResult, { action = "import" } = {}) => {
125
- var _a, _b, _c, _d, _e, _f;
126
- console.log(``);
127
- if (action === "import") {
128
- for (const [projectId, contentTypeCounts] of Object.entries(
129
- migrateResult.entries || {}
130
- )) {
131
- console.log(
132
- `import from project ${log.highlightText(projectId)} to ${log.boldText(
133
- log.successText(currentProject)
134
- )}`
135
- );
136
- for (const [contentTypeId, count] of Object.entries(
137
- contentTypeCounts
138
- )) {
139
- const entriesToMigrate = (_b = (_a = migrateResult.entriesToMigrate) == null ? void 0 : _a[projectId]) == null ? void 0 : _b[contentTypeId];
140
- console.log(
141
- ` - ${contentTypeId === "totalCount" ? log.warningText(`${contentTypeId}: ${count}`) : log.helpText(`${contentTypeId}: ${count}`)} ${log.infoText`[existing: ${((((_d = (_c = migrateResult.existing) == null ? void 0 : _c[projectId]) == null ? void 0 : _d[contentTypeId]) || 0) / count * 100).toFixed(0)}%]`} [${typeof entriesToMigrate !== "number" ? `unchanged` : `to update`}: ${((typeof entriesToMigrate !== "number" ? (entriesToMigrate == null ? void 0 : entriesToMigrate["no change"]) || 0 : entriesToMigrate) / count * 100).toFixed(0)}%]`
142
- );
143
- }
144
- console.log(``);
145
- }
146
- }
147
- if ((contensis == null ? void 0 : contensis.isPreview) && ((_f = (_e = migrateResult.entriesToMigrate) == null ? void 0 : _e[currentProject]) == null ? void 0 : _f.totalCount) > 0 && !migrateResult.errors) {
148
- log.help(messages.entries.commitTip());
149
- }
125
+ var _a, _b;
126
+ if (Object.keys(migrateResult.entriesToMigrate.entryIds).length)
127
+ console.log(``);
150
128
  for (const [contentTypeId, entryRes] of Object.entries(
151
129
  migrateResult.entriesToMigrate.entryIds
152
130
  )) {
153
131
  for (const [originalId, entryStatus] of Object.entries(entryRes)) {
132
+ console.log(`${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`);
154
133
  console.log(
155
134
  log.infoText(
156
- `${originalId} [${Object.entries(entryStatus || {}).filter((x) => x[0] !== "entryTitle").map(([projectId, projectStatus]) => {
135
+ ` ${originalId} ${Object.entries(entryStatus || {}).filter((x) => x[0] !== "entryTitle").map(([projectId, projectStatus]) => {
157
136
  var _a2;
158
137
  const [targetGuid, { status }] = ((_a2 = Object.entries(
159
138
  projectStatus || {}
@@ -161,13 +140,10 @@ const printMigrateResult = ({ log, messages, contensis, currentProject }, migrat
161
140
  "",
162
141
  { x: { status: void 0 } }
163
142
  ];
164
- return `${messages.migrate.status(status)(
165
- `${projectId}: ${status}`
166
- )}${targetGuid !== originalId ? `-> ${targetGuid}` : ""}`;
167
- })}]`
143
+ return `${messages.migrate.status(status)(`${status}`)}${targetGuid !== originalId ? `-> ${targetGuid}` : ""}`;
144
+ })}`
168
145
  )
169
146
  );
170
- console.log(` ${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`);
171
147
  for (const [projectId, projectStatus] of Object.entries(
172
148
  entryStatus
173
149
  ).filter(([key]) => key !== "entryTitle")) {
@@ -178,15 +154,18 @@ const printMigrateResult = ({ log, messages, contensis, currentProject }, migrat
178
154
  log.error(error);
179
155
  if (diff) {
180
156
  console.log(
181
- ` ${messages.migrate.status(status)(status)} ${log.infoText(
182
- targetGuid
183
- )} ${log.infoText(contentTypeId)} ${log.infoText(projectId)}`
157
+ ` ${log.highlightText(`diff:`)} ${log.infoText(
158
+ highlightDiffText(diff)
159
+ )}
160
+ `
184
161
  );
185
- console.log(``);
186
- console.log(log.highlightText(diff));
187
162
  }
188
163
  }
189
164
  }
165
+ console.log(``);
166
+ }
167
+ 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
+ log.help(messages.entries.commitTip());
190
169
  }
191
170
  };
192
171
  const highlightDiffText = (str) => {
@@ -229,14 +208,14 @@ const printModelMigrationAnalysis = ({ log, messages }, result = {}) => {
229
208
  )}] v${projectDetails.versionNo}`
230
209
  );
231
210
  if (projectDetails.diff)
232
- diffOutput += ` ${log.highlightText(`diff:`)} ${log.infoText(
211
+ diffOutput += ` ${log.highlightText(`diff:`)} ${log.infoText(
233
212
  highlightDiffText(projectDetails.diff)
234
213
  )}
235
214
  `;
236
215
  if (projectDetails.error)
237
- errorOutput += ` ${log.highlightText(`error::`)} ${log.errorText(
238
- projectDetails.error
239
- )}`;
216
+ errorOutput += ` ${log.highlightText(
217
+ `error::`
218
+ )} ${log.errorText(projectDetails.error)}`;
240
219
  }
241
220
  }
242
221
  }
@@ -259,12 +238,27 @@ const printModelMigrationAnalysis = ({ log, messages }, result = {}) => {
259
238
  };
260
239
  const printModelMigrationResult = ({ log, messages }, result) => {
261
240
  for (const [status, ids] of Object.entries(result)) {
262
- if (ids == null ? void 0 : ids.length)
263
- log.raw(
264
- ` - ${status}: [ ${messages.migrate.models.result(status)(
265
- ids.join(", ")
266
- )} ]`
267
- );
241
+ if (ids == null ? void 0 : ids.length) {
242
+ if (status === "errors") {
243
+ const errors = ids;
244
+ log.raw(
245
+ ` - ${status}: [ ${messages.migrate.models.result(status)(
246
+ ids.map((id) => id[0]).join(", ")
247
+ )} ]
248
+ `
249
+ );
250
+ for (const [contentTypeId, error] of errors)
251
+ log.error(
252
+ `${log.highlightText(contentTypeId)}: ${error.message}`,
253
+ error
254
+ );
255
+ } else
256
+ log.raw(
257
+ ` - ${status}: [ ${messages.migrate.models.result(status)(
258
+ ids.join(", ")
259
+ )} ]`
260
+ );
261
+ }
268
262
  }
269
263
  };
270
264
  // Annotate the CommonJS export names for ESM import in node:
@@ -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 console.log(``);\n\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.successText(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 : log.helpText(`${contentTypeId}: ${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 console.log(``);\n }\n }\n if (\n contensis?.isPreview &&\n migrateResult.entriesToMigrate?.[currentProject]?.totalCount > 0 &&\n !migrateResult.errors\n ) {\n log.help(messages.entries.commitTip());\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(\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)(\n `${projectId}: ${status}`\n )}${targetGuid !== originalId ? `-> ${targetGuid}` : ''}`;\n })}]`\n )\n );\n console.log(` ${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`);\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 ` ${messages.migrate.status(status)(status)} ${log.infoText(\n targetGuid\n )} ${log.infoText(contentTypeId)} ${log.infoText(projectId)}`\n );\n console.log(``);\n console.log(log.highlightText(diff));\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(`error::`)} ${log.errorText(\n projectDetails.error\n )}`;\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 log.raw(\n ` - ${status}: [ ${messages.migrate.models.result(status)(\n ids.join(', ')\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,G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AAA,UACV,IAAI,OAAO,SAAS,QAAQ,SAAS,MAAM;AAAA,UAC3C,UAAU;AAAA,QACZ;AAAA,MACF;AAAA,IACF;AACA,QAAI;AAAY,cAAQ,IAAI,UAAU;AACtC,QAAI;AAAa,cAAQ,IAAI,WAAW;AAAA,EAC1C;AACF;AAKO,MAAM,4BAA4B,CACvC,EAAE,KAAK,SAAS,GAChB,WACG;AACH,aAAW,CAAC,QAAQ,GAAG,KAAK,OAAO,QAAQ,MAAM,GAG5C;AACH,QAAI,2BAAK;AACP,UAAI;AAAA,QACF,OAAO,aAAa,SAAS,QAAQ,OAAO,OAAO,MAAM;AAAA,UACvD,IAAI,KAAK,IAAI;AAAA,QACf;AAAA,MACF;AAAA,EACJ;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 { 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,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,IACN,cAAc,SAAS,OAAO;AAAA,MAC5B,MAAM,OAAO,SAAS,WAAW,MAAM,OAAO,QAAQ;AAAA,IACxD;AAAA,EACF;AACA,UAAQ;AAAA,IACN,iBAAiB,IAAI;AAAA,MACnB,MAAM,QAAQ,WACV,IAAI,WAAW,MAAM,QAAQ,QAAQ,MAAM,MAAM,QAAQ,eACzD;AAAA,IACN;AAAA,EACF;AACA,MAAI,MAAM,QAAQ;AAChB,YAAQ;AAAA,MACN,aAAa,IAAI;AAAA,QACf,IAAI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,IAAI,UAAU;AACtC,QAAI;AAAa,cAAQ,IAAI,WAAW;AAAA,EAC1C;AACF;AAKO,MAAM,4BAA4B,CACvC,EAAE,KAAK,SAAS,GAChB,WACG;AACH,aAAW,CAAC,QAAQ,GAAG,KAAK,OAAO,QAAQ,MAAM,GAG5C;AACH,QAAI,2BAAK,QAAQ;AACf,UAAI,WAAW,UAAU;AACvB,cAAM,SAAkC;AACxC,YAAI;AAAA,UACF,OAAO,aAAa,SAAS,QAAQ,OAAO,OAAO,MAAM;AAAA,YACvD,IAAI,IAAI,QAAM,GAAG,EAAE,EAAE,KAAK,IAAI;AAAA,UAChC;AAAA;AAAA,QACF;AACA,mBAAW,CAAC,eAAe,KAAK,KAAK;AACnC,cAAI;AAAA,YACF,GAAG,IAAI,cAAc,aAAa,MAAM,MAAM;AAAA,YAC9C;AAAA,UACF;AAAA,MACJ;AACE,YAAI;AAAA,UACF,OAAO,aAAa,SAAS,QAAQ,OAAO,OAAO,MAAM;AAAA,YACvD,IAAI,KAAK,IAAI;AAAA,UACf;AAAA,QACF;AAAA,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.40";
24
+ const LIB_VERSION = "1.0.0-beta.42";
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.40\";\n"],
4
+ "sourcesContent": ["export const LIB_VERSION = \"1.0.0-beta.42\";\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.40",
3
+ "version": "1.0.0-beta.42",
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.17",
38
+ "migratortron": "^1.0.0-beta.18",
39
39
  "node-fetch": "^2.6.7",
40
40
  "patch-package": "^6.4.7",
41
41
  "xml2js": "^0.4.23"
@@ -6,6 +6,7 @@ import { project } from './globalOptions';
6
6
  export const makeConnectCommand = () => {
7
7
  const connect = new Command()
8
8
  .command('connect')
9
+ .description('connect to a Contensis instance')
9
10
  .argument('<alias>', 'the Contensis Cloud alias to connect with')
10
11
  .addOption(project)
11
12
  .usage('<alias>')
@@ -1,28 +1,55 @@
1
1
  import { Command } from 'commander';
2
+ import { Project } from 'contensis-core-api';
2
3
  import { cliCommand } from '~/services/ContensisCliService';
3
4
  import { shell } from '~/shell';
4
5
 
5
6
  export const makeCreateCommand = () => {
6
7
  const create = new Command()
7
8
  .command('create')
9
+ .description('create command')
8
10
  .addHelpText('after', `\n`)
9
11
  .showHelpAfterError(true)
10
12
  .exitOverride();
11
13
 
12
14
  create
13
15
  .command('project')
16
+ .description('create a new project')
14
17
  .argument('<projectId>', 'the id of the project to create')
15
- .usage('<projectId>')
18
+ .argument('<name>', 'the name of the project to create')
19
+ .argument('[description]', 'optional description of the project')
20
+ .option(
21
+ '-l, --language',
22
+ 'the default language of the project to create',
23
+ 'en-GB'
24
+ )
25
+ .option(
26
+ '-langs, --supported-languages <langs...>',
27
+ 'space separated list of other supported languages'
28
+ )
29
+ .usage(
30
+ 'projectId "Project name" ["Description of project"] --language en-GB --supported-languages es-ES de-DE nl-NL'
31
+ )
16
32
  .addHelpText('after', `\n`)
17
- .action(async (projectId: string, opts: any) => {
18
- const project = await cliCommand(
19
- ['create', 'project', projectId],
20
- opts
21
- ).SetProject(projectId);
22
- if (project) await shell().restart();
23
- });
33
+ .action(
34
+ async (projectId: string, name: string, description = '', opts: any) => {
35
+ const createProject: Project = {
36
+ id: projectId,
37
+ name,
38
+ description,
39
+ primaryLanguage: opts.language,
40
+ supportedLanguages: opts.supportedLanguages || [],
41
+ };
42
+
43
+ const project = await cliCommand(
44
+ ['create', 'project', projectId],
45
+ opts
46
+ ).CreateProject(createProject);
47
+ if (project) await shell().restart();
48
+ }
49
+ );
24
50
  create
25
51
  .command('key')
52
+ .description('create a new api key')
26
53
  .argument('<"key name">', 'the name of the key to create')
27
54
  .argument('["description"]', 'provide a description for the key (optional)')
28
55
  .usage('<"key name"> ["description"] (both args in "double quotes")')
@@ -83,7 +83,7 @@ Example call:
83
83
  '[search phrase]',
84
84
  'get entries with the search phrase, use quotes for multiple words'
85
85
  )
86
- .option('-i --id <id...>', 'the entry id to get')
86
+ .option('-i --id <id...>', 'the entry id(s) to get')
87
87
  .option(
88
88
  '-d, --dependents',
89
89
  'find and return any dependencies of all found entries'
@@ -13,10 +13,10 @@ export const mapContensisOpts = (opts: any = {}) => ({
13
13
  : undefined,
14
14
  models: opts.modelIds,
15
15
  query:
16
- opts.id || opts.phrase || opts.fields
16
+ opts.id || opts.entryIds || opts.phrase || opts.fields
17
17
  ? {
18
18
  fields: opts.fields,
19
- includeIds: opts.id,
19
+ includeIds: opts.id || opts.entryIds,
20
20
  searchTerm: opts.phrase,
21
21
  }
22
22
  : undefined,
@@ -37,53 +37,53 @@ const format = new Option(
37
37
 
38
38
  /* Connect options */
39
39
  const alias = new Option(
40
- '-a --alias <alias>',
40
+ '-a, --alias <alias>',
41
41
  'the cloud CMS alias to connect your request with'
42
42
  );
43
43
 
44
44
  export const project = new Option(
45
- '-p --project-id <projectId>',
45
+ '-p, --project-id <projectId>',
46
46
  'the projectId to make your request with'
47
47
  );
48
48
 
49
49
  /* Authentication options */
50
50
  const user = new Option(
51
- '-u --user <user>',
51
+ '-u, --user <user>',
52
52
  'the username to authenticate your request with'
53
53
  );
54
54
  const password = new Option(
55
- '-pw --password <password>',
55
+ '-pw, --password <password>',
56
56
  'the password to use to login with (optional/insecure)'
57
57
  );
58
58
  const clientId = new Option(
59
- '-id --client-id <clientId>',
59
+ '-id, --client-id <clientId>',
60
60
  'the clientId to authenticate your request with'
61
61
  );
62
62
  const sharedSecret = new Option(
63
- '-s --shared-secret <sharedSecret>',
63
+ '-s, --shared-secret <sharedSecret>',
64
64
  'the shared secret to use when logging in with a client id'
65
65
  );
66
66
 
67
67
  /* Entry get options */
68
- const zenql = new Option(
68
+ export const zenql = new Option(
69
69
  '-q, --zenql <zenql>',
70
70
  'get entries with a supplied ZenQL statement'
71
71
  );
72
72
 
73
- const entryId = new Option('-i --id <id...>', 'the entry id to get');
73
+ export const entryId = new Option('-i --id <id...>', 'the entry id(s) to get');
74
74
 
75
75
  /* Import options */
76
76
  export const fromFile = new Option(
77
- '-file --from-file <fromFile>',
77
+ '-file, --from-file <fromFile>',
78
78
  'file path to import asset(s) from'
79
79
  );
80
80
 
81
81
  export const fromCms = new Option(
82
- '-source --source-alias <fromCms>',
82
+ '-source, --source-alias <fromCms>',
83
83
  'the cloud CMS alias to import asset(s) from'
84
84
  );
85
85
  export const fromProject = new Option(
86
- '-sp --source-project-id <fromProject>',
86
+ '-sp, --source-project-id <fromProject>',
87
87
  'the id of the Contensis project to import asset(s) from (Default: [last connected project])'
88
88
  );
89
89
 
@@ -6,12 +6,14 @@ import { commit, mapContensisOpts } from './globalOptions';
6
6
  export const makeImportCommand = () => {
7
7
  const program = new Command()
8
8
  .command('import')
9
+ .description('import command')
9
10
  .addHelpText('after', `\n`)
10
11
  .showHelpAfterError(true)
11
12
  .exitOverride();
12
13
 
13
14
  program
14
15
  .command('models')
16
+ .description('import complete content models')
15
17
  .argument('[modelIds...]', 'ids of the content models to import (optional)')
16
18
  .addOption(commit)
17
19
  .addHelpText(
@@ -35,8 +37,9 @@ Example call:
35
37
 
36
38
  program
37
39
  .command('contenttypes')
40
+ .description('import content types')
38
41
  .argument(
39
- '[contentTypeIds]',
42
+ '[contentTypeIds...]',
40
43
  'Optional list of API id(s) of the content type(s) to import'
41
44
  )
42
45
  .addOption(commit)
@@ -64,8 +67,9 @@ Example call:
64
67
 
65
68
  program
66
69
  .command('components')
70
+ .description('import components')
67
71
  .argument(
68
- '[componentIds]',
72
+ '[componentIds...]',
69
73
  'Optional list of API id(s) of the component(s) to import'
70
74
  )
71
75
  .addOption(commit)
@@ -93,6 +97,7 @@ Example call:
93
97
 
94
98
  program
95
99
  .command('entries')
100
+ .description('import entries')
96
101
  .argument(
97
102
  '[search phrase]',
98
103
  'get entries with the search phrase, use quotes for multiple words'
@@ -40,9 +40,7 @@ const commands = () => {
40
40
  )
41
41
  );
42
42
  program.addCommand(
43
- addGlobalOptions(
44
- addImportOptions(makeCreateCommand())
45
- ).copyInheritedSettings(program)
43
+ addGlobalOptions(makeCreateCommand()).copyInheritedSettings(program)
46
44
  );
47
45
  program.addCommand(
48
46
  addGlobalOptions(
@@ -5,13 +5,14 @@ import { shell } from '~/shell';
5
5
  export const makeLoginCommand = () => {
6
6
  const login = new Command()
7
7
  .command('login')
8
+ .description('login to a connected Contensis instance')
8
9
  .argument('<user/clientId>', 'the username to login with')
9
10
  .argument(
10
11
  '[password]',
11
12
  'the password to use to login with (optional/insecure)'
12
13
  )
13
14
  .option(
14
- '-s --shared-secret <sharedSecret>',
15
+ '-s, --shared-secret <sharedSecret>',
15
16
  'the shared secret to use when logging in with a client id'
16
17
  )
17
18
  .usage('<user/clientId> [password] [-s <sharedSecret>]')