contensis-cli 1.0.0-beta.38 → 1.0.0-beta.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/create.js +4 -2
- package/dist/commands/create.js.map +2 -2
- package/dist/commands/diff.js +57 -0
- package/dist/commands/diff.js.map +7 -0
- package/dist/commands/get.js +40 -11
- package/dist/commands/get.js.map +2 -2
- package/dist/commands/globalOptions.js +4 -3
- package/dist/commands/globalOptions.js.map +2 -2
- package/dist/commands/import.js +31 -5
- package/dist/commands/import.js.map +2 -2
- package/dist/commands/index.js +6 -0
- package/dist/commands/index.js.map +2 -2
- package/dist/commands/list.js +19 -8
- package/dist/commands/list.js.map +2 -2
- package/dist/commands/push.js +2 -1
- package/dist/commands/push.js.map +2 -2
- package/dist/commands/release.js +2 -1
- package/dist/commands/release.js.map +2 -2
- package/dist/commands/remove.js +6 -4
- package/dist/commands/remove.js.map +2 -2
- package/dist/commands/set.js +6 -3
- package/dist/commands/set.js.map +2 -2
- package/dist/localisation/en-GB.js +43 -24
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/providers/SessionCacheProvider.js +2 -2
- package/dist/providers/SessionCacheProvider.js.map +2 -2
- package/dist/services/ContensisCliService.js +240 -72
- package/dist/services/ContensisCliService.js.map +3 -3
- package/dist/shell.js +4 -1
- package/dist/shell.js.map +2 -2
- package/dist/util/console.printer.js +87 -4
- package/dist/util/console.printer.js.map +2 -2
- package/dist/util/logger.js +45 -13
- package/dist/util/logger.js.map +2 -2
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +2 -2
- package/src/commands/create.ts +2 -0
- package/src/commands/diff.ts +39 -0
- package/src/commands/get.ts +48 -4
- package/src/commands/globalOptions.ts +5 -4
- package/src/commands/import.ts +36 -2
- package/src/commands/index.ts +6 -0
- package/src/commands/list.ts +34 -9
- package/src/commands/push.ts +1 -0
- package/src/commands/release.ts +1 -0
- package/src/commands/remove.ts +4 -2
- package/src/commands/set.ts +3 -0
- package/src/localisation/en-GB.ts +58 -33
- package/src/providers/SessionCacheProvider.ts +3 -2
- package/src/services/ContensisCliService.ts +301 -84
- package/src/shell.ts +4 -2
- package/src/util/console.printer.ts +100 -3
- package/src/util/logger.ts +84 -15
- package/src/version.ts +1 -1
|
@@ -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, MigrateStatus } from 'migratortron';\nimport ContensisCli from '~/services/ContensisCliService';\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.
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;
|
|
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,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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ED
|
@@ -114,37 +114,69 @@ ${Logger.standardText(content)}`;
|
|
|
114
114
|
static mixed = (contentArray) => console.log(`${Logger.getPrefix()} ${contentArray.join(" ")}`);
|
|
115
115
|
static line = () => Logger.raw(` ${Logger.infoText(`-------------------------------------`)}`);
|
|
116
116
|
static object = (content) => {
|
|
117
|
-
var _a, _b;
|
|
117
|
+
var _a, _b, _c, _d, _e, _f;
|
|
118
118
|
for (const [key, value] of Object.entries(content)) {
|
|
119
119
|
if (value && typeof value === "object") {
|
|
120
120
|
Logger.raw(` ${import_chalk.default.bold.grey(key)}:`);
|
|
121
121
|
if (key === "fields" && Array.isArray(value)) {
|
|
122
122
|
for (const field of value || []) {
|
|
123
123
|
Logger.raw(
|
|
124
|
-
` ${import_chalk.default.bold(field.id)}: ${import_chalk.default.grey(
|
|
124
|
+
` ${import_chalk.default.bold(field.id)}${field.id === content.entryTitleField ? "**" : ((_a = field.validations.minCount) == null ? void 0 : _a.value) || typeof ((_b = field.validations.required) == null ? void 0 : _b.message) !== "undefined" ? "*" : ""}: ${import_chalk.default.grey(
|
|
125
|
+
`${field.dataType}${field.dataFormat ? `<${Array.isArray(
|
|
126
|
+
(_c = field.validations.allowedFieldTypes) == null ? void 0 : _c.fields
|
|
127
|
+
) ? `composer[${field.validations.allowedFieldTypes.fields.map((f) => f.id).join(" | ")}]` : field.dataFormat}${field.dataFormat === "entry" ? `, ${field.validations.allowedContentTypes.contentTypes.join(
|
|
128
|
+
" | "
|
|
129
|
+
)}` : ""}>` : ""}${((_d = field.validations.maxLength) == null ? void 0 : _d.value) ? `(${field.validations.maxLength.value})` : ""}`
|
|
130
|
+
)}`
|
|
125
131
|
);
|
|
126
132
|
}
|
|
127
133
|
} else if (key === "groups" && Array.isArray(value)) {
|
|
128
134
|
for (const group of value || []) {
|
|
129
|
-
const description = Object.keys(group.description).length && ((
|
|
135
|
+
const description = Object.keys(group.description).length && ((_e = Object.values(group.description)) == null ? void 0 : _e[0]);
|
|
130
136
|
Logger.raw(
|
|
131
|
-
` ${import_chalk.default.bold(group.id)}${description ? `: ${import_chalk.default.grey((
|
|
137
|
+
` ${import_chalk.default.bold(group.id)}${description ? `: ${import_chalk.default.grey((_f = Object.values(group.description)) == null ? void 0 : _f[0])}` : ""}`
|
|
132
138
|
);
|
|
133
139
|
}
|
|
134
140
|
} else {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
+
Logger.objectRecurse(value, 3, " ");
|
|
142
|
+
}
|
|
143
|
+
} else if (typeof value !== "undefined" && value !== null) {
|
|
144
|
+
const valueText = key === "id" && typeof value === "string" ? Logger.highlightText(value) : value;
|
|
145
|
+
Logger.raw(` ${import_chalk.default.bold.grey(key)}: ${valueText}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
static objectRecurse = (content, depth = 3, indent = "") => {
|
|
150
|
+
if (Array.isArray(content)) {
|
|
151
|
+
for (const item of content) {
|
|
152
|
+
if (item && typeof item === "object") {
|
|
153
|
+
if (Array.isArray(item) && depth > 3)
|
|
154
|
+
Logger.raw(import_chalk.default.grey(`${indent} [${item.join(", ")}]`));
|
|
155
|
+
else
|
|
156
|
+
Logger.objectRecurse(item, depth + 1, `${indent} `);
|
|
157
|
+
} else
|
|
158
|
+
Logger.raw(`${indent}${item}`);
|
|
159
|
+
}
|
|
160
|
+
} else
|
|
161
|
+
for (const [key, value] of Object.entries(content)) {
|
|
162
|
+
if (Array.isArray(value)) {
|
|
163
|
+
for (const item of value) {
|
|
164
|
+
if (item && typeof item === "object") {
|
|
165
|
+
if (Array.isArray(item) && depth > 3)
|
|
166
|
+
Logger.raw(import_chalk.default.grey(`${indent} [${item.join(", ")}]`));
|
|
167
|
+
else
|
|
168
|
+
Logger.objectRecurse(item, depth + 1, `${indent}`);
|
|
169
|
+
} else {
|
|
170
|
+
Logger.raw(`${indent} ${item}`);
|
|
141
171
|
}
|
|
142
172
|
}
|
|
173
|
+
} else if (value && typeof value === "object") {
|
|
174
|
+
Logger.raw(`${indent}${import_chalk.default.bold.grey(key)}:`);
|
|
175
|
+
Logger.objectRecurse(value, depth + 1, `${indent} `);
|
|
176
|
+
} else if (typeof value !== "undefined" && value !== null) {
|
|
177
|
+
Logger.raw(`${indent}${import_chalk.default.bold.grey(key)}: ${value}`);
|
|
143
178
|
}
|
|
144
|
-
} else if (typeof value !== "undefined" || value !== null) {
|
|
145
|
-
Logger.raw(` ${import_chalk.default.bold.grey(key)}: ${value}`);
|
|
146
179
|
}
|
|
147
|
-
}
|
|
148
180
|
};
|
|
149
181
|
static raw = (content) => {
|
|
150
182
|
if (progress.active)
|
package/dist/util/logger.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/util/logger.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable no-console */\nimport chalk from 'chalk';\nimport dateFormat from 'dateformat';\nimport deepCleaner from 'deep-cleaner';\nimport ProgressBar from 'progress';\nimport { tryStringify } from '.';\n\ntype LogMethod = (content: string) => void;\ntype LogErrorMethod = (content: string, err?: any) => void;\ntype LogJsonMethod = (content: any) => void;\ntype LogArrayMethod = (contentArray: string[]) => void;\ntype LogErrorFunc = (\n err: any,\n msg?: string,\n level?: 'error' | 'critical'\n) => void;\n\nexport class Logger {\n static isUserTerminal = !!process.stdout.columns;\n static getPrefix = () => {\n return Logger.isUserTerminal\n ? Logger.infoText(`[cli]`)\n : `[${dateFormat(new Date(), 'dd/mm HH:MM:ss')}]`;\n };\n static errorText = chalk.bold.red;\n static warningText = chalk.keyword('orange');\n static successText = chalk.keyword('green');\n static helpText = chalk.blue;\n static highlightText = chalk.yellow;\n static infoText = chalk.keyword('grey');\n static standardText = chalk.keyword('white');\n static boldText = chalk.bold;\n static critical: LogMethod = content => {\n const message = `${Logger.getPrefix()} ${Logger.errorText(\n '[CRITICAL]'\n )} ${content}`;\n console.log(message);\n };\n static error: LogErrorMethod = (content, err) => {\n const message = `${Logger.getPrefix()} ${Logger.errorText(\n `${Logger.isUserTerminal ? '\u274C' : '[ERROR]'} ${content}${\n err ? `\\n\\n${JSON.stringify(err, null, 2)}` : ''\n }`\n )}\\n`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n };\n static warning: LogMethod = content => {\n // if (process.env.DEBUG === 'true') {\n const message = `${Logger.getPrefix()} ${Logger.warningText(\n `${Logger.isUserTerminal ? '\u26A0\uFE0F ' : '[WARN]'} ${content}`\n )}\\n`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n // }\n };\n static success: LogMethod = content => {\n const message = `${Logger.getPrefix()} ${Logger.successText(\n `${Logger.isUserTerminal ? '\u2705' : '[OK]'} ${content}`\n )}`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n };\n static info: LogMethod = content => {\n const message = `${Logger.getPrefix()} ${\n Logger.isUserTerminal ? chalk.bgCyan(' \u2139 ') : '[INFO]'\n } ${Logger.infoText(content)}`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n };\n static help: LogMethod = content => {\n const message = `${Logger.getPrefix()} ${chalk.blue(\n `${Logger.isUserTerminal ? '\u23E9' : '[HELP]'} ${content}`\n )}\\n`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n };\n static standard: LogMethod = content => {\n const message = `${Logger.getPrefix()} ${\n Logger.isUserTerminal ? '\u25FB\uFE0F' : '[STD]'\n } \\n${Logger.standardText(content)}`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n progress.current.interrupt(message);\n };\n static json:
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,wBAAuB;AACvB,0BAAwB;AACxB,sBAAwB;AACxB,eAA6B;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable no-console */\nimport chalk from 'chalk';\nimport dateFormat from 'dateformat';\nimport deepCleaner from 'deep-cleaner';\nimport ProgressBar from 'progress';\nimport { tryStringify } from '.';\n\ntype LogMethod = (content: string) => void;\ntype LogErrorMethod = (content: string, err?: any) => void;\ntype LogJsonMethod = (content: any, depth?: number, indent?: string) => void;\ntype LogJsonDepthMethod = (content: any, depth: number) => void;\ntype LogArrayMethod = (contentArray: string[]) => void;\ntype LogErrorFunc = (\n err: any,\n msg?: string,\n level?: 'error' | 'critical'\n) => void;\n\nexport class Logger {\n static isUserTerminal = !!process.stdout.columns;\n static getPrefix = () => {\n return Logger.isUserTerminal\n ? Logger.infoText(`[cli]`)\n : `[${dateFormat(new Date(), 'dd/mm HH:MM:ss')}]`;\n };\n static errorText = chalk.bold.red;\n static warningText = chalk.keyword('orange');\n static successText = chalk.keyword('green');\n static helpText = chalk.blue;\n static highlightText = chalk.yellow;\n static infoText = chalk.keyword('grey');\n static standardText = chalk.keyword('white');\n static boldText = chalk.bold;\n static critical: LogMethod = content => {\n const message = `${Logger.getPrefix()} ${Logger.errorText(\n '[CRITICAL]'\n )} ${content}`;\n console.log(message);\n };\n static error: LogErrorMethod = (content, err) => {\n const message = `${Logger.getPrefix()} ${Logger.errorText(\n `${Logger.isUserTerminal ? '\u274C' : '[ERROR]'} ${content}${\n err ? `\\n\\n${JSON.stringify(err, null, 2)}` : ''\n }`\n )}\\n`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n };\n static warning: LogMethod = content => {\n // if (process.env.DEBUG === 'true') {\n const message = `${Logger.getPrefix()} ${Logger.warningText(\n `${Logger.isUserTerminal ? '\u26A0\uFE0F ' : '[WARN]'} ${content}`\n )}\\n`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n // }\n };\n static success: LogMethod = content => {\n const message = `${Logger.getPrefix()} ${Logger.successText(\n `${Logger.isUserTerminal ? '\u2705' : '[OK]'} ${content}`\n )}`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n };\n static info: LogMethod = content => {\n const message = `${Logger.getPrefix()} ${\n Logger.isUserTerminal ? chalk.bgCyan(' \u2139 ') : '[INFO]'\n } ${Logger.infoText(content)}`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n };\n static help: LogMethod = content => {\n const message = `${Logger.getPrefix()} ${chalk.blue(\n `${Logger.isUserTerminal ? '\u23E9' : '[HELP]'} ${content}`\n )}\\n`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n };\n static standard: LogMethod = content => {\n const message = `${Logger.getPrefix()} ${\n Logger.isUserTerminal ? '\u25FB\uFE0F' : '[STD]'\n } \\n${Logger.standardText(content)}`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n progress.current.interrupt(message);\n };\n static json: LogJsonDepthMethod = (content, depth = 9) =>\n console.dir(deepCleaner(content), { colors: true, depth });\n static mixed: LogArrayMethod = contentArray =>\n console.log(`${Logger.getPrefix()} ${contentArray.join(' ')}`);\n static line = () =>\n Logger.raw(` ${Logger.infoText(`-------------------------------------`)}`);\n\n static object: LogJsonMethod = content => {\n for (const [key, value] of Object.entries(content)) {\n if (value && typeof value === 'object') {\n Logger.raw(` ${chalk.bold.grey(key)}:`);\n if (key === 'fields' && Array.isArray(value)) {\n for (const field of value || []) {\n Logger.raw(\n ` ${chalk.bold(field.id)}${\n field.id === content.entryTitleField\n ? '**'\n : field.validations.minCount?.value ||\n typeof field.validations.required?.message !== 'undefined'\n ? '*'\n : ''\n }: ${chalk.grey(\n `${field.dataType}${\n field.dataFormat\n ? `<${\n Array.isArray(\n field.validations.allowedFieldTypes?.fields\n )\n ? `composer[${field.validations.allowedFieldTypes.fields\n .map((f: any) => f.id)\n .join(' | ')}]`\n : field.dataFormat\n }${\n field.dataFormat === 'entry'\n ? `, ${field.validations.allowedContentTypes.contentTypes.join(\n ' | '\n )}`\n : ''\n }>`\n : ''\n }${\n field.validations.maxLength?.value\n ? `(${field.validations.maxLength.value})`\n : ''\n }`\n )}`\n );\n }\n } else if (key === 'groups' && Array.isArray(value)) {\n for (const group of value || []) {\n const description =\n Object.keys(group.description).length &&\n Object.values(group.description)?.[0];\n Logger.raw(\n ` ${chalk.bold(group.id)}${\n description\n ? `: ${chalk.grey(Object.values(group.description)?.[0])}`\n : ''\n }`\n );\n }\n } else {\n Logger.objectRecurse(value, 3, ' ');\n // for (const [innerkey, innervalue] of Object.entries(value)) {\n // if (innervalue && typeof innervalue === 'object') {\n // Logger.raw(` ${chalk.bold.grey(innerkey)}:`);\n // console.table(innervalue);\n // } else if (\n // typeof innervalue !== 'undefined' &&\n // innervalue !== null\n // ) {\n // Logger.raw(` ${chalk.bold.grey(innerkey)}: ${innervalue}`);\n // }\n // }\n }\n } else if (typeof value !== 'undefined' && value !== null) {\n const valueText =\n key === 'id' && typeof value === 'string'\n ? Logger.highlightText(value)\n : value;\n Logger.raw(` ${chalk.bold.grey(key)}: ${valueText}`);\n }\n }\n };\n\n static objectRecurse: LogJsonMethod = (content, depth = 3, indent = '') => {\n if (Array.isArray(content)) {\n for (const item of content) {\n if (item && typeof item === 'object') {\n if (Array.isArray(item) && depth > 3)\n Logger.raw(chalk.grey(`${indent} [${item.join(', ')}]`));\n else Logger.objectRecurse(item, depth + 1, `${indent} `);\n } else Logger.raw(`${indent}${item}`);\n }\n } else\n for (const [key, value] of Object.entries(content)) {\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item && typeof item === 'object') {\n if (Array.isArray(item) && depth > 3)\n Logger.raw(chalk.grey(`${indent} [${item.join(', ')}]`));\n else Logger.objectRecurse(item, depth + 1, `${indent}`);\n } else {\n Logger.raw(`${indent} ${item}`);\n }\n }\n } else if (value && typeof value === 'object') {\n Logger.raw(`${indent}${chalk.bold.grey(key)}:`);\n\n Logger.objectRecurse(value, depth + 1, `${indent} `);\n // console.table(value);\n } else if (typeof value !== 'undefined' && value !== null) {\n Logger.raw(`${indent}${chalk.bold.grey(key)}: ${value}`);\n }\n }\n };\n static raw: LogMethod = (content: string) => {\n if (progress.active) progress.current.interrupt(content);\n else console.log(content);\n };\n}\n\nexport const logError: LogErrorFunc = (\n err = new Error('Undefined error'),\n msg,\n level = 'error'\n) => {\n Logger[level](msg || err.message || err?.data?.message || err.Message);\n (Array.isArray(err) ? err : [err]).map((error: AppError) => {\n if ('stack' in error) Logger.raw(` ${Logger.infoText(error.stack)}`);\n if ('data' in error)\n Logger.raw(` ${Logger.infoText(tryStringify(error.data))}`);\n });\n //Logger.line();\n return null;\n};\n\nexport const progress = {\n active: false,\n done: () => new ProgressBar('', 0),\n colours: { green: '\\u001b[42m \\u001b[0m', red: '\\u001b[41m \\u001b[0m' },\n current: new ProgressBar(`:bar`, {\n complete: '=',\n incomplete: ' ',\n width: 20,\n total: 100,\n }),\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,wBAAuB;AACvB,0BAAwB;AACxB,sBAAwB;AACxB,eAA6B;AAatB,MAAM,OAAO;AAAA,EAClB,OAAO,iBAAiB,CAAC,CAAC,QAAQ,OAAO;AAAA,EACzC,OAAO,YAAY,MAAM;AACvB,WAAO,OAAO,iBACV,OAAO,SAAS,OAAO,IACvB,QAAI,kBAAAA,SAAW,IAAI,KAAK,GAAG,gBAAgB;AAAA,EACjD;AAAA,EACA,OAAO,YAAY,aAAAC,QAAM,KAAK;AAAA,EAC9B,OAAO,cAAc,aAAAA,QAAM,QAAQ,QAAQ;AAAA,EAC3C,OAAO,cAAc,aAAAA,QAAM,QAAQ,OAAO;AAAA,EAC1C,OAAO,WAAW,aAAAA,QAAM;AAAA,EACxB,OAAO,gBAAgB,aAAAA,QAAM;AAAA,EAC7B,OAAO,WAAW,aAAAA,QAAM,QAAQ,MAAM;AAAA,EACtC,OAAO,eAAe,aAAAA,QAAM,QAAQ,OAAO;AAAA,EAC3C,OAAO,WAAW,aAAAA,QAAM;AAAA,EACxB,OAAO,WAAsB,aAAW;AACtC,UAAM,UAAU,GAAG,OAAO,UAAU,MAAM,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I,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,UAAoB;AAC1D,QAAI,WAAW;AAAO,aAAO,IAAI,KAAK,OAAO,SAAS,MAAM,KAAK,GAAG;AACpE,QAAI,UAAU;AACZ,aAAO,IAAI,KAAK,OAAO,aAAS,uBAAa,MAAM,IAAI,CAAC,GAAG;AAAA,EAC/D,CAAC;AAED,SAAO;AACT;AAEO,MAAM,WAAW;AAAA,EACtB,QAAQ;AAAA,EACR,MAAM,MAAM,IAAI,gBAAAE,QAAY,IAAI,CAAC;AAAA,EACjC,SAAS,EAAE,OAAO,oBAAwB,KAAK,mBAAuB;AAAA,EACtE,SAAS,IAAI,gBAAAA,QAAY,QAAQ;AAAA,IAC/B,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,OAAO;AAAA,EACT,CAAC;AACH;",
|
|
6
6
|
"names": ["dateFormat", "chalk", "deepCleaner", "ProgressBar"]
|
|
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.
|
|
24
|
+
const LIB_VERSION = "1.0.0-beta.39";
|
|
25
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
26
|
0 && (module.exports = {
|
|
27
27
|
LIB_VERSION
|
package/dist/version.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/version.ts"],
|
|
4
|
-
"sourcesContent": ["export const LIB_VERSION = \"1.0.0-beta.
|
|
4
|
+
"sourcesContent": ["export const LIB_VERSION = \"1.0.0-beta.39\";\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.
|
|
3
|
+
"version": "1.0.0-beta.39",
|
|
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.
|
|
38
|
+
"migratortron": "^1.0.0-beta.17",
|
|
39
39
|
"node-fetch": "^2.6.7",
|
|
40
40
|
"patch-package": "^6.4.7",
|
|
41
41
|
"xml2js": "^0.4.23"
|
package/src/commands/create.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { shell } from '~/shell';
|
|
|
5
5
|
export const makeCreateCommand = () => {
|
|
6
6
|
const create = new Command()
|
|
7
7
|
.command('create')
|
|
8
|
+
.addHelpText('after', `\n`)
|
|
8
9
|
.showHelpAfterError(true)
|
|
9
10
|
.exitOverride();
|
|
10
11
|
|
|
@@ -12,6 +13,7 @@ export const makeCreateCommand = () => {
|
|
|
12
13
|
.command('project')
|
|
13
14
|
.argument('<projectId>', 'the id of the project to create')
|
|
14
15
|
.usage('<projectId>')
|
|
16
|
+
.addHelpText('after', `\n`)
|
|
15
17
|
.action(async (projectId: string, opts: any) => {
|
|
16
18
|
const project = await cliCommand(
|
|
17
19
|
['create', 'project', projectId],
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { cliCommand } from '~/services/ContensisCliService';
|
|
3
|
+
import { mapContensisOpts } from './globalOptions';
|
|
4
|
+
|
|
5
|
+
export const makeDiffCommand = () => {
|
|
6
|
+
const release = new Command()
|
|
7
|
+
.command('diff')
|
|
8
|
+
.addHelpText('after', `\n`)
|
|
9
|
+
.showHelpAfterError(true)
|
|
10
|
+
.exitOverride();
|
|
11
|
+
|
|
12
|
+
release
|
|
13
|
+
.command('models')
|
|
14
|
+
.argument(
|
|
15
|
+
'[model-ids...]',
|
|
16
|
+
'ids of any content types or components to diff (optional)'
|
|
17
|
+
)
|
|
18
|
+
.usage('[model-ids...]')
|
|
19
|
+
.addHelpText(
|
|
20
|
+
'after',
|
|
21
|
+
`
|
|
22
|
+
Example call:
|
|
23
|
+
> diff models blogPost\n`
|
|
24
|
+
)
|
|
25
|
+
.action(async (modelIds: string[] = [], opts) => {
|
|
26
|
+
await cliCommand(
|
|
27
|
+
['diff', 'models', modelIds.join(' ')],
|
|
28
|
+
opts,
|
|
29
|
+
mapContensisOpts({ modelIds, ...opts })
|
|
30
|
+
).DiffModels(
|
|
31
|
+
{
|
|
32
|
+
...opts,
|
|
33
|
+
},
|
|
34
|
+
modelIds
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return release;
|
|
39
|
+
};
|
package/src/commands/get.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { mapContensisOpts } from './globalOptions';
|
|
|
5
5
|
export const makeGetCommand = () => {
|
|
6
6
|
const program = new Command()
|
|
7
7
|
.command('get')
|
|
8
|
+
.addHelpText('after', `\n`)
|
|
8
9
|
.showHelpAfterError(true)
|
|
9
10
|
.exitOverride();
|
|
10
11
|
|
|
@@ -22,8 +23,27 @@ Example call:
|
|
|
22
23
|
await cliCommand(['get', 'version'], opts).PrintContensisVersion();
|
|
23
24
|
});
|
|
24
25
|
|
|
26
|
+
program
|
|
27
|
+
.command('model')
|
|
28
|
+
.description('Get a content model')
|
|
29
|
+
.argument('<contentTypeId...>', 'ids of the content models to get')
|
|
30
|
+
.addHelpText(
|
|
31
|
+
'after',
|
|
32
|
+
`
|
|
33
|
+
Example call:
|
|
34
|
+
> get model podcast podcastLinks
|
|
35
|
+
`
|
|
36
|
+
)
|
|
37
|
+
.action(async (modelIds: string[], opts) => {
|
|
38
|
+
await cliCommand(
|
|
39
|
+
['get', 'model', modelIds.join(' ')],
|
|
40
|
+
opts
|
|
41
|
+
).PrintContentModels(modelIds);
|
|
42
|
+
});
|
|
43
|
+
|
|
25
44
|
program
|
|
26
45
|
.command('contenttype')
|
|
46
|
+
.description('Get a content type')
|
|
27
47
|
.argument('<contentTypeId>', 'the API id of the content type to get')
|
|
28
48
|
.addHelpText(
|
|
29
49
|
'after',
|
|
@@ -33,12 +53,15 @@ Example call:
|
|
|
33
53
|
`
|
|
34
54
|
)
|
|
35
55
|
.action(async (contentTypeId: string, opts) => {
|
|
36
|
-
await cliCommand(
|
|
37
|
-
contentTypeId
|
|
38
|
-
|
|
56
|
+
await cliCommand(
|
|
57
|
+
['get', 'contenttype', contentTypeId],
|
|
58
|
+
opts
|
|
59
|
+
).PrintContentType(contentTypeId);
|
|
39
60
|
});
|
|
61
|
+
|
|
40
62
|
program
|
|
41
63
|
.command('component')
|
|
64
|
+
.description('Get a component')
|
|
42
65
|
.argument('<componentId>', 'the API id of the component to get')
|
|
43
66
|
.addHelpText(
|
|
44
67
|
'after',
|
|
@@ -48,10 +71,14 @@ Example call:
|
|
|
48
71
|
`
|
|
49
72
|
)
|
|
50
73
|
.action(async (componentId: string, opts) => {
|
|
51
|
-
await cliCommand(['get', 'component'], opts).PrintComponent(
|
|
74
|
+
await cliCommand(['get', 'component', componentId], opts).PrintComponent(
|
|
75
|
+
componentId
|
|
76
|
+
);
|
|
52
77
|
});
|
|
78
|
+
|
|
53
79
|
program
|
|
54
80
|
.command('entries')
|
|
81
|
+
.description('Get entries')
|
|
55
82
|
.argument(
|
|
56
83
|
'[search phrase]',
|
|
57
84
|
'get entries with the search phrase, use quotes for multiple words'
|
|
@@ -90,6 +117,7 @@ Example call:
|
|
|
90
117
|
|
|
91
118
|
const block = program
|
|
92
119
|
.command('block')
|
|
120
|
+
.description('Get a block or block version')
|
|
93
121
|
.argument('[blockId]', 'the block to get version details for')
|
|
94
122
|
.argument(
|
|
95
123
|
'[branch]',
|
|
@@ -100,6 +128,13 @@ Example call:
|
|
|
100
128
|
'[version]',
|
|
101
129
|
'get a specific version of the block pushed to the specified branch'
|
|
102
130
|
)
|
|
131
|
+
.addHelpText(
|
|
132
|
+
'after',
|
|
133
|
+
`
|
|
134
|
+
Example call:
|
|
135
|
+
> get block contensis-website master latest
|
|
136
|
+
`
|
|
137
|
+
)
|
|
103
138
|
.action(async (blockId: string, branch: string, version: string, opts) => {
|
|
104
139
|
await cliCommand(['get', 'block'], opts).PrintBlockVersions(
|
|
105
140
|
blockId,
|
|
@@ -117,6 +152,7 @@ Example call:
|
|
|
117
152
|
|
|
118
153
|
block
|
|
119
154
|
.command('logs')
|
|
155
|
+
.description('Get logs for a block')
|
|
120
156
|
.argument('[blockId]', 'the block to get version logs for')
|
|
121
157
|
.argument(
|
|
122
158
|
'[branch]',
|
|
@@ -130,6 +166,14 @@ Example call:
|
|
|
130
166
|
)
|
|
131
167
|
.addArgument(dataCenter)
|
|
132
168
|
.usage('get block logs [blockId] [branch] [version] [dataCenter]')
|
|
169
|
+
.addHelpText(
|
|
170
|
+
'after',
|
|
171
|
+
`
|
|
172
|
+
Example call:
|
|
173
|
+
> get block logs contensis-website master
|
|
174
|
+
> get block logs contensis-website master latest london
|
|
175
|
+
`
|
|
176
|
+
)
|
|
133
177
|
.action(
|
|
134
178
|
async (
|
|
135
179
|
blockId: string,
|
|
@@ -3,14 +3,15 @@ import { url } from '~/util';
|
|
|
3
3
|
|
|
4
4
|
export const mapContensisOpts = (opts: any = {}) => ({
|
|
5
5
|
source:
|
|
6
|
-
opts.
|
|
6
|
+
opts.sourceAlias || opts.sourceProjectId
|
|
7
7
|
? {
|
|
8
|
-
url: opts.
|
|
9
|
-
? url(opts.
|
|
8
|
+
url: opts.sourceAlias
|
|
9
|
+
? url(opts.sourceAlias, 'website').cms
|
|
10
10
|
: (undefined as any),
|
|
11
11
|
project: opts.sourceProjectId || (undefined as any),
|
|
12
12
|
}
|
|
13
13
|
: undefined,
|
|
14
|
+
models: opts.modelIds,
|
|
14
15
|
query:
|
|
15
16
|
opts.id || opts.phrase || opts.fields
|
|
16
17
|
? {
|
|
@@ -88,7 +89,7 @@ export const fromProject = new Option(
|
|
|
88
89
|
|
|
89
90
|
export const commit = new Option(
|
|
90
91
|
'--commit',
|
|
91
|
-
'
|
|
92
|
+
'add this flag only after you have run a preview of the import and agree with the analysis'
|
|
92
93
|
).default(false);
|
|
93
94
|
|
|
94
95
|
export const addConnectOptions = (program: Command) =>
|
package/src/commands/import.ts
CHANGED
|
@@ -6,15 +6,40 @@ import { commit, mapContensisOpts } from './globalOptions';
|
|
|
6
6
|
export const makeImportCommand = () => {
|
|
7
7
|
const program = new Command()
|
|
8
8
|
.command('import')
|
|
9
|
+
.addHelpText('after', `\n`)
|
|
9
10
|
.showHelpAfterError(true)
|
|
10
11
|
.exitOverride();
|
|
11
12
|
|
|
13
|
+
program
|
|
14
|
+
.command('models')
|
|
15
|
+
.argument('[modelIds...]', 'ids of the content models to import (optional)')
|
|
16
|
+
.addOption(commit)
|
|
17
|
+
.addHelpText(
|
|
18
|
+
'after',
|
|
19
|
+
`
|
|
20
|
+
Example call:
|
|
21
|
+
> import models blogPost --from-file contentmodels-backup.json
|
|
22
|
+
> import models --source-alias example-dev
|
|
23
|
+
`
|
|
24
|
+
)
|
|
25
|
+
.action(async (modelIds: string[], opts) => {
|
|
26
|
+
await cliCommand(
|
|
27
|
+
['import', 'models', modelIds.join(' ')],
|
|
28
|
+
opts,
|
|
29
|
+
mapContensisOpts({ modelIds, ...opts })
|
|
30
|
+
).ImportContentModels({
|
|
31
|
+
fromFile: opts.fromFile,
|
|
32
|
+
commit: opts.commit,
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
12
36
|
program
|
|
13
37
|
.command('contenttypes')
|
|
14
38
|
.argument(
|
|
15
39
|
'[contentTypeIds]',
|
|
16
40
|
'Optional list of API id(s) of the content type(s) to import'
|
|
17
41
|
)
|
|
42
|
+
.addOption(commit)
|
|
18
43
|
.addHelpText(
|
|
19
44
|
'after',
|
|
20
45
|
`
|
|
@@ -24,7 +49,11 @@ Example call:
|
|
|
24
49
|
`
|
|
25
50
|
)
|
|
26
51
|
.action(async (contentTypeIds: string[], opts) => {
|
|
27
|
-
await cliCommand(
|
|
52
|
+
await cliCommand(
|
|
53
|
+
['import', 'contenttypes'],
|
|
54
|
+
opts,
|
|
55
|
+
mapContensisOpts({ contentTypeIds, ...opts })
|
|
56
|
+
).ImportContentTypes(
|
|
28
57
|
{
|
|
29
58
|
fromFile: opts.fromFile,
|
|
30
59
|
commit: opts.commit,
|
|
@@ -39,6 +68,7 @@ Example call:
|
|
|
39
68
|
'[componentIds]',
|
|
40
69
|
'Optional list of API id(s) of the component(s) to import'
|
|
41
70
|
)
|
|
71
|
+
.addOption(commit)
|
|
42
72
|
.addHelpText(
|
|
43
73
|
'after',
|
|
44
74
|
`
|
|
@@ -48,7 +78,11 @@ Example call:
|
|
|
48
78
|
`
|
|
49
79
|
)
|
|
50
80
|
.action(async (componentIds: string[], opts) => {
|
|
51
|
-
await cliCommand(
|
|
81
|
+
await cliCommand(
|
|
82
|
+
['import', 'component'],
|
|
83
|
+
opts,
|
|
84
|
+
mapContensisOpts({ componentIds, ...opts })
|
|
85
|
+
).ImportComponents(
|
|
52
86
|
{
|
|
53
87
|
fromFile: opts.fromFile,
|
|
54
88
|
commit: opts.commit,
|
package/src/commands/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Logger } from '~/util/logger';
|
|
|
3
3
|
import { LIB_VERSION } from '~/version';
|
|
4
4
|
import { makeConnectCommand } from './connect';
|
|
5
5
|
import { makeCreateCommand } from './create';
|
|
6
|
+
import { makeDiffCommand } from './diff';
|
|
6
7
|
import { makeGetCommand } from './get';
|
|
7
8
|
import {
|
|
8
9
|
addAuthenticationOptions,
|
|
@@ -43,6 +44,11 @@ const commands = () => {
|
|
|
43
44
|
addImportOptions(makeCreateCommand())
|
|
44
45
|
).copyInheritedSettings(program)
|
|
45
46
|
);
|
|
47
|
+
program.addCommand(
|
|
48
|
+
addGlobalOptions(
|
|
49
|
+
addGetEntryOptions(addImportOptions(makeDiffCommand()))
|
|
50
|
+
).copyInheritedSettings(program)
|
|
51
|
+
);
|
|
46
52
|
program.addCommand(
|
|
47
53
|
addGlobalOptions(makeGetCommand()).copyInheritedSettings(program)
|
|
48
54
|
);
|