contensis-cli 1.0.12-beta.2 → 1.0.12-beta.20
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/README.md +9 -9
- package/dist/commands/get.js +13 -1
- package/dist/commands/get.js.map +2 -2
- package/dist/commands/globalOptions.js +9 -10
- package/dist/commands/globalOptions.js.map +2 -2
- package/dist/commands/import.js +22 -12
- package/dist/commands/import.js.map +2 -2
- package/dist/commands/index.js +2 -2
- package/dist/commands/index.js.map +2 -2
- package/dist/commands/list.js +9 -0
- package/dist/commands/list.js.map +2 -2
- package/dist/commands/remove.js +13 -0
- package/dist/commands/remove.js.map +2 -2
- package/dist/localisation/en-GB.js +12 -4
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/mappers/DevInit-to-CIWorkflow.js +6 -8
- package/dist/mappers/DevInit-to-CIWorkflow.js.map +2 -2
- package/dist/mappers/DevInit-to-RolePermissions.js +4 -4
- package/dist/mappers/DevInit-to-RolePermissions.js.map +2 -2
- package/dist/providers/file-provider.js +5 -1
- package/dist/providers/file-provider.js.map +2 -2
- package/dist/services/ContensisAuthService.js.map +2 -2
- package/dist/services/ContensisCliService.js +158 -40
- package/dist/services/ContensisCliService.js.map +2 -2
- package/dist/services/ContensisDevService.js +51 -56
- package/dist/services/ContensisDevService.js.map +3 -3
- package/dist/shell.js +6 -0
- package/dist/shell.js.map +2 -2
- package/dist/util/console.printer.js +61 -52
- package/dist/util/console.printer.js.map +3 -3
- package/dist/util/csv.formatter.js +3 -11
- package/dist/util/csv.formatter.js.map +3 -3
- package/dist/util/diff.js +1 -1
- package/dist/util/diff.js.map +2 -2
- package/dist/util/error.js +36 -0
- package/dist/util/error.js.map +7 -0
- package/dist/util/find.js +10 -2
- package/dist/util/find.js.map +2 -2
- package/dist/util/git.js +1 -0
- package/dist/util/git.js.map +2 -2
- package/dist/util/json.formatter.js +35 -3
- package/dist/util/json.formatter.js.map +3 -3
- package/dist/util/logger.js +52 -9
- package/dist/util/logger.js.map +3 -3
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +4 -4
- package/src/commands/get.ts +19 -1
- package/src/commands/globalOptions.ts +9 -7
- package/src/commands/import.ts +35 -15
- package/src/commands/index.ts +2 -3
- package/src/commands/list.ts +15 -0
- package/src/commands/remove.ts +20 -0
- package/src/localisation/en-GB.ts +15 -5
- package/src/mappers/DevInit-to-CIWorkflow.ts +8 -8
- package/src/mappers/DevInit-to-RolePermissions.ts +5 -2
- package/src/models/Cache.d.ts +2 -1
- package/src/providers/file-provider.ts +5 -1
- package/src/services/ContensisAuthService.ts +1 -1
- package/src/services/ContensisCliService.ts +195 -55
- package/src/services/ContensisDevService.ts +76 -70
- package/src/shell.ts +8 -0
- package/src/util/console.printer.ts +151 -72
- package/src/util/csv.formatter.ts +1 -4
- package/src/util/diff.ts +1 -1
- package/src/util/error.ts +7 -0
- package/src/util/find.ts +13 -2
- package/src/util/git.ts +2 -1
- package/src/util/json.formatter.ts +32 -1
- package/src/util/logger.ts +90 -15
- package/src/version.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/util/json.formatter.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import { flatten, unflatten } from 'flat';\nimport cleaner from 'deep-cleaner';\n\n// Format a JSON object for a nice output\nexport const jsonFormatter = <T>(obj: T, fields?: string[]) =>\n JSON.stringify(limitFields(obj, fields), null, 2);\n\n// Flatten a JSON object such as an entry so there are no\n// nested object and the keys are presented like \"sys.version.versionNo\": \"1.0\"\nexport const flattenObject = (obj: any) => flatten(cleaner(obj, ['workflow']));\n\n// Will limit and sort an object's keys by an array of supplied fields\nexport const limitFields = (obj: any, fields?: string[]): any => {\n if (!fields) return obj;\n if (obj && Array.isArray(obj)) {\n const arr = [];\n for (const child of obj) arr.push(limitFields(child, fields));\n return arr;\n }\n\n if (obj && typeof obj === 'object') {\n const flattenedObj = flatten(obj) as any;\n const sortedObj = {} as any;\n for (const field of fields) {\n sortedObj[field] = flattenedObj[field];\n }\n\n return unflatten(sortedObj);\n }\n\n return obj;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmC;AACnC,0BAAoB;AAGb,MAAM,gBAAgB,CAAI,KAAQ,WACvC,KAAK,UAAU,YAAY,KAAK,MAAM,GAAG,MAAM,CAAC;AAI3C,MAAM,gBAAgB,CAAC,YAAa,yBAAQ,oBAAAA,SAAQ,KAAK,CAAC,UAAU,CAAC,CAAC;AAGtE,MAAM,cAAc,CAAC,KAAU,WAA2B;AAC/D,MAAI,CAAC;AAAQ,WAAO;AACpB,MAAI,OAAO,MAAM,QAAQ,GAAG,GAAG;AAC7B,UAAM,MAAM,CAAC;AACb,eAAW,SAAS;AAAK,UAAI,KAAK,YAAY,OAAO,MAAM,CAAC;AAC5D,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,OAAO,QAAQ,UAAU;AAClC,UAAM,mBAAe,qBAAQ,GAAG;AAChC,UAAM,YAAY,CAAC;AACnB,eAAW,SAAS,QAAQ;AAC1B,gBAAU,SAAS,aAAa;AAAA,IAClC;AAEA,eAAO,uBAAU,SAAS;AAAA,EAC5B;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": ["cleaner"]
|
|
7
7
|
}
|
package/dist/util/logger.js
CHANGED
|
@@ -25,6 +25,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
25
25
|
var logger_exports = {};
|
|
26
26
|
__export(logger_exports, {
|
|
27
27
|
Logger: () => Logger,
|
|
28
|
+
addNewLines: () => addNewLines,
|
|
28
29
|
logError: () => logError,
|
|
29
30
|
progress: () => progress
|
|
30
31
|
});
|
|
@@ -200,17 +201,30 @@ ${Logger.standardText(content)}`;
|
|
|
200
201
|
else
|
|
201
202
|
console.log(content);
|
|
202
203
|
};
|
|
203
|
-
static limits = (content, displayLength = 30) => {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
204
|
+
static limits = (content, displayLength = 30, consoleWidth = process.stdout.columns, logMethod = console.info) => {
|
|
205
|
+
if (consoleWidth) {
|
|
206
|
+
const contentArray = content.endsWith("\n") ? content.split("\n").slice(0, -1) : content.split("\n");
|
|
207
|
+
const contentLines = contentArray.slice(
|
|
208
|
+
0,
|
|
209
|
+
consoleWidth ? displayLength : void 0
|
|
210
|
+
);
|
|
211
|
+
for (const line of contentLines)
|
|
212
|
+
logMethod(
|
|
213
|
+
line.split("~n").map(
|
|
214
|
+
(l) => consoleWidth && (0, import_printable_characters.strlen)(l) > consoleWidth ? (0, import_printable_characters.first)(l, consoleWidth) : l
|
|
215
|
+
).join("\n")
|
|
216
|
+
);
|
|
217
|
+
} else {
|
|
218
|
+
logMethod(content.replace(import_printable_characters.ansiEscapeCodes, "").replaceAll("~n", "\n"));
|
|
219
|
+
}
|
|
210
220
|
const tableArray = content.split("\n");
|
|
211
221
|
if (consoleWidth && tableArray.length > displayLength)
|
|
212
|
-
console.info(
|
|
213
|
-
|
|
222
|
+
console.info(
|
|
223
|
+
`
|
|
224
|
+
`,
|
|
225
|
+
`- and ${tableArray.length - displayLength} more...
|
|
226
|
+
`
|
|
227
|
+
);
|
|
214
228
|
};
|
|
215
229
|
}
|
|
216
230
|
const logError = (err = new Error("Undefined error"), msg, level = "error") => {
|
|
@@ -231,6 +245,34 @@ const logError = (err = new Error("Undefined error"), msg, level = "error") => {
|
|
|
231
245
|
});
|
|
232
246
|
return null;
|
|
233
247
|
};
|
|
248
|
+
const addNewLines = (message = "", newLineSeparater = "\n", atPosition = process.stdout.columns) => {
|
|
249
|
+
if (message === "" || atPosition === 0) {
|
|
250
|
+
return "";
|
|
251
|
+
}
|
|
252
|
+
let result = "";
|
|
253
|
+
let lengthCounter = 0;
|
|
254
|
+
const partitioned = (0, import_printable_characters.partition)(message);
|
|
255
|
+
const addSeparater = () => {
|
|
256
|
+
if (lengthCounter >= atPosition) {
|
|
257
|
+
result += newLineSeparater;
|
|
258
|
+
lengthCounter = 0;
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
for (const [nonPrintable, printable] of partitioned) {
|
|
262
|
+
const textParts = Array.from(printable);
|
|
263
|
+
const text = textParts.splice(0, atPosition - lengthCounter);
|
|
264
|
+
result += nonPrintable + text.join("");
|
|
265
|
+
lengthCounter += text.length;
|
|
266
|
+
addSeparater();
|
|
267
|
+
while (textParts.length) {
|
|
268
|
+
const text2 = textParts.splice(0, atPosition - lengthCounter);
|
|
269
|
+
result += text2.join("");
|
|
270
|
+
lengthCounter += text2.length;
|
|
271
|
+
addSeparater();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return result;
|
|
275
|
+
};
|
|
234
276
|
const progress = {
|
|
235
277
|
current: { interrupt: (x) => {
|
|
236
278
|
} },
|
|
@@ -239,6 +281,7 @@ const progress = {
|
|
|
239
281
|
// Annotate the CommonJS export names for ESM import in node:
|
|
240
282
|
0 && (module.exports = {
|
|
241
283
|
Logger,
|
|
284
|
+
addNewLines,
|
|
242
285
|
logError,
|
|
243
286
|
progress
|
|
244
287
|
});
|
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 { ansiEscapeCodes, first, strlen } from 'printable-characters';\n// import ProgressBar from 'progress';\nimport { isSysError, tryStringify } from '.';\n\ntype LogMethod = (content: string) => void;\ntype LogErrorMethod = (content: string, err?: any, newline?: string) => 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, newline = '\\n') => {\n const message = `${Logger.getPrefix()} ${Logger.errorText(\n `${Logger.isUserTerminal ? '\u274C' : '[ERROR]'} ${content}${\n err\n ? `\\n\\n${Logger.infoText(\n isSysError(err) ? err.toString() : JSON.stringify(err, null, 2)\n )}`\n : ''\n }`\n )}${newline}`;\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 debug: LogMethod = content => {\n if (['true', '1'].includes(process.env.debug || '')) {\n const message = `${Logger.getPrefix()} ${\n Logger.isUserTerminal ? chalk.bgGrey(' \u2699 ') : '[DEBUG]'\n } ${Logger.infoText(content)}`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n }\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 let pos = 0;\n for (const [key, value] of Object.entries(content)) {\n const thisIndent =\n pos === 0 ? `${indent.substring(0, indent.length - 2)}- ` : indent;\n if (Array.isArray(value)) {\n if (value.length) Logger.raw(`${thisIndent}${chalk.bold.grey(key)}:`);\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(`${thisIndent}${chalk.bold.grey(key)}: ${value}`);\n }\n pos++;\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 static limits = (content: string, displayLength = 30) => {\n const consoleWidth = process.stdout.columns;\n console.info(\n consoleWidth\n ? content\n .split('\\n')\n .slice(0, consoleWidth ? displayLength : undefined)\n .map((line: string) =>\n consoleWidth && strlen(line) > consoleWidth\n ? first(line, consoleWidth)\n : line\n )\n .join('\\n')\n : content.replace(ansiEscapeCodes, '')\n );\n const tableArray = content.split('\\n');\n if (consoleWidth && tableArray.length > displayLength)\n console.info(`\\n`, `- and ${tableArray.length - displayLength} more...`);\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 (typeof error === 'string') {\n Logger.raw(`${Logger.infoText(error)}\\n`);\n return;\n }\n if ('stack' in error) Logger.raw(` ${Logger.infoText(error.stack)}\\n`);\n if ('data' in error)\n Logger.raw(` ${Logger.infoText(tryStringify(error.data))}\\n`);\n });\n //Logger.line();\n return null;\n};\n\nexport const progress = {\n current: { interrupt: (x: string) => {} },\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,
|
|
6
|
-
"names": ["dateFormat", "chalk", "deepCleaner"]
|
|
4
|
+
"sourcesContent": ["/* eslint-disable no-console */\nimport chalk from 'chalk';\nimport dateFormat from 'dateformat';\nimport deepCleaner from 'deep-cleaner';\nimport {\n ansiEscapeCodes,\n first,\n partition,\n strlen,\n} from 'printable-characters';\n// import ProgressBar from 'progress';\nimport { isSysError, tryStringify } from '.';\n\ntype LogMethod = (content: string) => void;\ntype LogErrorMethod = (content: string, err?: any, newline?: string) => 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, newline = '\\n') => {\n const message = `${Logger.getPrefix()} ${Logger.errorText(\n `${Logger.isUserTerminal ? '\u274C' : '[ERROR]'} ${content}${\n err\n ? `\\n\\n${Logger.infoText(\n isSysError(err) ? err.toString() : JSON.stringify(err, null, 2)\n )}`\n : ''\n }`\n )}${newline}`;\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 debug: LogMethod = content => {\n if (['true', '1'].includes(process.env.debug || '')) {\n const message = `${Logger.getPrefix()} ${\n Logger.isUserTerminal ? chalk.bgGrey(' \u2699 ') : '[DEBUG]'\n } ${Logger.infoText(content)}`;\n if (progress.active) progress.current.interrupt(message);\n else console.log(message);\n }\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 let pos = 0;\n for (const [key, value] of Object.entries(content)) {\n const thisIndent =\n pos === 0 ? `${indent.substring(0, indent.length - 2)}- ` : indent;\n if (Array.isArray(value)) {\n if (value.length) Logger.raw(`${thisIndent}${chalk.bold.grey(key)}:`);\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(`${thisIndent}${chalk.bold.grey(key)}: ${value}`);\n }\n pos++;\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 static limits = (\n content: string,\n displayLength = 30,\n consoleWidth = process.stdout.columns,\n logMethod: Function = console.info\n ) => {\n if (consoleWidth) {\n const contentArray = content.endsWith('\\n')\n ? content.split('\\n').slice(0, -1)\n : content.split('\\n');\n const contentLines = contentArray.slice(\n 0,\n consoleWidth ? displayLength : undefined\n );\n for (const line of contentLines)\n logMethod(\n line\n .split('~n')\n .map(l =>\n consoleWidth && strlen(l) > consoleWidth\n ? first(l, consoleWidth)\n : l\n )\n .join('\\n')\n );\n } else {\n logMethod(content.replace(ansiEscapeCodes, '').replaceAll('~n', '\\n'));\n }\n\n const tableArray = content.split('\\n');\n if (consoleWidth && tableArray.length > displayLength)\n console.info(\n `\\n`,\n `- and ${tableArray.length - displayLength} more...\\n`\n );\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 (typeof error === 'string') {\n Logger.raw(`${Logger.infoText(error)}\\n`);\n return;\n }\n if ('stack' in error) Logger.raw(` ${Logger.infoText(error.stack)}\\n`);\n if ('data' in error)\n Logger.raw(` ${Logger.infoText(tryStringify(error.data))}\\n`);\n });\n //Logger.line();\n return null;\n};\n\nexport const addNewLines = (\n message = '',\n newLineSeparater = '\\n',\n atPosition = process.stdout.columns\n) => {\n if (message === '' || atPosition === 0) {\n return '';\n }\n\n let result = '';\n let lengthCounter = 0;\n\n // Partition the message string into an array of\n // [nonPrintable, printable][]\n const partitioned = partition(message);\n const addSeparater = () => {\n // If line length counter has exceeded the console width\n // add a new line separater and reset the line length counter\n if (lengthCounter >= atPosition) {\n result += newLineSeparater;\n lengthCounter = 0;\n }\n };\n\n // Loop through the partitioned message parts\n for (const [nonPrintable, printable] of partitioned) {\n // Convert string to array as this will provide accurate\n // lengths and splicing methods with all unicode chars\n const textParts = Array.from(printable);\n // Splice the remaining allowable line length from the text parts array\n const text = textParts.splice(0, atPosition - lengthCounter);\n // In the first iteration append the non printable unicode chars\n // to the beginning of the spliced text\n result += nonPrintable + text.join('');\n // Keep a count of the current line length\n // as one line of output could span multiple \"partitions\"\n lengthCounter += text.length;\n addSeparater();\n\n // Handle any remaining text in this \"partition\"\n while (textParts.length) {\n // Splice the remaining allowable line length from the text parts array\n const text = textParts.splice(0, atPosition - lengthCounter);\n // Append the spliced text to the result\n result += text.join('');\n // Increase line length counter\n lengthCounter += text.length;\n addSeparater();\n }\n }\n return result;\n};\n\nexport const progress = {\n current: { interrupt: (x: string) => {} },\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;AAAA;AACA,mBAAkB;AAClB,wBAAuB;AACvB,0BAAwB;AACxB,kCAKO;AAEP,eAAyC;AAalC,MAAM,OAAO;A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EACT;AAEA,MAAI,SAAS;AACb,MAAI,gBAAgB;AAIpB,QAAM,kBAAc,uCAAU,OAAO;AACrC,QAAM,eAAe,MAAM;AAGzB,QAAI,iBAAiB,YAAY;AAC/B,gBAAU;AACV,sBAAgB;AAAA,IAClB;AAAA,EACF;AAGA,aAAW,CAAC,cAAc,SAAS,KAAK,aAAa;AAGnD,UAAM,YAAY,MAAM,KAAK,SAAS;AAEtC,UAAM,OAAO,UAAU,OAAO,GAAG,aAAa,aAAa;AAG3D,cAAU,eAAe,KAAK,KAAK,EAAE;AAGrC,qBAAiB,KAAK;AACtB,iBAAa;AAGb,WAAO,UAAU,QAAQ;AAEvB,YAAME,QAAO,UAAU,OAAO,GAAG,aAAa,aAAa;AAE3D,gBAAUA,MAAK,KAAK,EAAE;AAEtB,uBAAiBA,MAAK;AACtB,mBAAa;AAAA,IACf;AAAA,EACF;AACA,SAAO;AACT;AAEO,MAAM,WAAW;AAAA,EACtB,SAAS,EAAE,WAAW,CAAC,MAAc;AAAA,EAAC,EAAE;AAAA,EACxC,QAAQ;AASV;",
|
|
6
|
+
"names": ["dateFormat", "chalk", "deepCleaner", "text"]
|
|
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.12-beta.
|
|
24
|
+
const LIB_VERSION = "1.0.12-beta.20";
|
|
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.12-beta.
|
|
4
|
+
"sourcesContent": ["export const LIB_VERSION = \"1.0.12-beta.20\";\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "contensis-cli",
|
|
3
|
-
"version": "1.0.12-beta.
|
|
3
|
+
"version": "1.0.12-beta.20",
|
|
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
|
-
"repository": "https://github.com/contensis/
|
|
6
|
-
"homepage": "https://github.com/contensis/
|
|
5
|
+
"repository": "https://github.com/contensis/cli",
|
|
6
|
+
"homepage": "https://github.com/contensis/cli/tree/main/packages/contensis-cli#readme",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"bin": {
|
|
9
9
|
"contensis": "./cli.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"jsonpath-mapper": "^1.1.0",
|
|
41
41
|
"keytar": "^7.9.0",
|
|
42
42
|
"lodash": "^4.17.21",
|
|
43
|
-
"migratortron": "^1.0.0-beta.
|
|
43
|
+
"migratortron": "^1.0.0-beta.38",
|
|
44
44
|
"nanospinner": "^1.1.0",
|
|
45
45
|
"node-fetch": "^2.6.7",
|
|
46
46
|
"parse-git-config": "^3.0.0",
|
package/src/commands/get.ts
CHANGED
|
@@ -98,6 +98,24 @@ Example call:
|
|
|
98
98
|
).PrintWebhookSubscriptions(webhookNameOrId);
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
+
program
|
|
102
|
+
.command('workflow')
|
|
103
|
+
.description('get a workflow')
|
|
104
|
+
.argument('<workflowNameOrId>', 'id or name of the workflow to get')
|
|
105
|
+
.addHelpText(
|
|
106
|
+
'after',
|
|
107
|
+
`
|
|
108
|
+
Example call:
|
|
109
|
+
> get workflow "Approval workflow"
|
|
110
|
+
`
|
|
111
|
+
)
|
|
112
|
+
.action(async (workflowNameOrId: string, opts) => {
|
|
113
|
+
await cliCommand(
|
|
114
|
+
['get', 'workflow', workflowNameOrId],
|
|
115
|
+
opts
|
|
116
|
+
).PrintWorkflow(workflowNameOrId);
|
|
117
|
+
});
|
|
118
|
+
|
|
101
119
|
program
|
|
102
120
|
.command('model')
|
|
103
121
|
.description('get a content model')
|
|
@@ -245,7 +263,7 @@ Example call:
|
|
|
245
263
|
.option(
|
|
246
264
|
'-d --depth <depth>',
|
|
247
265
|
'get nodes with children to a specified depth',
|
|
248
|
-
'
|
|
266
|
+
'1'
|
|
249
267
|
)
|
|
250
268
|
.addHelpText(
|
|
251
269
|
'after',
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Command, Option } from 'commander';
|
|
2
2
|
import { url } from '~/util';
|
|
3
3
|
|
|
4
|
+
// Map various input options into a request to be processed
|
|
5
|
+
// by Migratortron / Contensis import library
|
|
4
6
|
export const mapContensisOpts = (opts: any = {}) => ({
|
|
5
7
|
source:
|
|
6
8
|
opts.sourceAlias || opts.sourceProjectId
|
|
@@ -35,6 +37,7 @@ export const mapContensisOpts = (opts: any = {}) => ({
|
|
|
35
37
|
: undefined,
|
|
36
38
|
zenQL: opts.zenql,
|
|
37
39
|
transformGuids: !opts.preserveGuids,
|
|
40
|
+
ignoreErrors: opts.ignoreErrors,
|
|
38
41
|
});
|
|
39
42
|
|
|
40
43
|
/* Output options */
|
|
@@ -113,6 +116,11 @@ export const commit = new Option(
|
|
|
113
116
|
'add this flag only after you have run a preview of the import and agree with the analysis'
|
|
114
117
|
).default(false);
|
|
115
118
|
|
|
119
|
+
export const ignoreErrors = new Option(
|
|
120
|
+
'-ignore --ignore-errors',
|
|
121
|
+
'commit the import ignoring any reported errors'
|
|
122
|
+
).default(false);
|
|
123
|
+
|
|
116
124
|
export const addConnectOptions = (program: Command) =>
|
|
117
125
|
program.addOption(alias.hideHelp()).addOption(project.hideHelp());
|
|
118
126
|
|
|
@@ -128,7 +136,7 @@ const addOutputAndFormatOptions = (program: Command) =>
|
|
|
128
136
|
|
|
129
137
|
export const addImportOptions = (program: Command) => {
|
|
130
138
|
for (const command of program.commands) {
|
|
131
|
-
command.addOption(
|
|
139
|
+
command.addOption(fromCms).addOption(fromProject).addOption(fromFile);
|
|
132
140
|
}
|
|
133
141
|
return program;
|
|
134
142
|
};
|
|
@@ -140,12 +148,6 @@ export const getEntryOptions = (command: Command) =>
|
|
|
140
148
|
.addOption(contentTypes)
|
|
141
149
|
.addOption(assetTypes);
|
|
142
150
|
|
|
143
|
-
export const addGetEntryOptions = (program: Command) => {
|
|
144
|
-
for (const command of program.commands) {
|
|
145
|
-
getEntryOptions(command);
|
|
146
|
-
}
|
|
147
|
-
return program;
|
|
148
|
-
};
|
|
149
151
|
export const addGlobalOptions = (program: Command) => {
|
|
150
152
|
for (const command of program.commands) {
|
|
151
153
|
addOutputAndFormatOptions(command);
|
package/src/commands/import.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Command, Option } from 'commander';
|
|
2
2
|
import { cliCommand } from '~/services/ContensisCliService';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
commit,
|
|
5
|
+
getEntryOptions,
|
|
6
|
+
ignoreErrors,
|
|
7
|
+
mapContensisOpts,
|
|
8
|
+
} from './globalOptions';
|
|
4
9
|
|
|
5
10
|
export const makeImportCommand = () => {
|
|
6
11
|
const program = new Command()
|
|
@@ -94,13 +99,15 @@ Example call:
|
|
|
94
99
|
);
|
|
95
100
|
});
|
|
96
101
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
getEntryOptions(
|
|
103
|
+
program
|
|
104
|
+
.command('entries')
|
|
105
|
+
.description('import entries')
|
|
106
|
+
.argument(
|
|
107
|
+
'[search phrase]',
|
|
108
|
+
'get entries with the search phrase, use quotes for multiple words'
|
|
109
|
+
)
|
|
110
|
+
)
|
|
104
111
|
.addOption(commit)
|
|
105
112
|
.option(
|
|
106
113
|
'-preserve --preserve-guids',
|
|
@@ -114,6 +121,7 @@ Example call:
|
|
|
114
121
|
.choices(['errors', 'changes', 'all'])
|
|
115
122
|
.default('errors')
|
|
116
123
|
)
|
|
124
|
+
.addOption(ignoreErrors)
|
|
117
125
|
.addHelpText(
|
|
118
126
|
'after',
|
|
119
127
|
`
|
|
@@ -137,32 +145,44 @@ Example call:
|
|
|
137
145
|
program
|
|
138
146
|
.command('nodes')
|
|
139
147
|
.description('import nodes')
|
|
148
|
+
.argument('[root]', 'import nodes from the specified path e.g. /blog', '/')
|
|
149
|
+
.option(
|
|
150
|
+
'-preserve --preserve-guids',
|
|
151
|
+
'include this flag when you are importing nodes that you have previously exported and wish to update'
|
|
152
|
+
)
|
|
153
|
+
.addOption(ignoreErrors)
|
|
140
154
|
.addOption(commit)
|
|
141
155
|
.addOption(
|
|
142
156
|
new Option(
|
|
143
|
-
'-
|
|
144
|
-
'how much detail to output from the
|
|
157
|
+
'-od --output-detail <outputDetail>',
|
|
158
|
+
'how much detail to output from the import'
|
|
145
159
|
)
|
|
146
160
|
.choices(['errors', 'changes', 'all'])
|
|
147
161
|
.default('errors')
|
|
148
162
|
)
|
|
163
|
+
.option(
|
|
164
|
+
'-ol --output-limit <outputLimit>',
|
|
165
|
+
'expand or limit the number of records output to the console',
|
|
166
|
+
'200'
|
|
167
|
+
)
|
|
149
168
|
.addHelpText(
|
|
150
169
|
'after',
|
|
151
170
|
`
|
|
152
171
|
Example call:
|
|
153
|
-
> import nodes --
|
|
154
|
-
> import nodes --
|
|
172
|
+
> import nodes /blog --source-alias example-alias --source-project-id example-project
|
|
173
|
+
> import nodes --from-file site-backup.json --preserve-guids
|
|
155
174
|
`
|
|
156
175
|
)
|
|
157
|
-
.action(async opts => {
|
|
176
|
+
.action(async (root: string, opts) => {
|
|
158
177
|
await cliCommand(
|
|
159
178
|
['import', 'nodes'],
|
|
160
179
|
opts,
|
|
161
|
-
mapContensisOpts({ ...opts })
|
|
180
|
+
mapContensisOpts({ paths: root.split(' '), ...opts })
|
|
162
181
|
).ImportNodes({
|
|
163
182
|
commit: opts.commit,
|
|
164
183
|
fromFile: opts.fromFile,
|
|
165
|
-
logOutput: opts.
|
|
184
|
+
logOutput: opts.outputDetail,
|
|
185
|
+
logLimit: Number(opts.outputLimit),
|
|
166
186
|
});
|
|
167
187
|
});
|
|
168
188
|
|
package/src/commands/index.ts
CHANGED
|
@@ -10,7 +10,6 @@ import { makeGetCommand } from './get';
|
|
|
10
10
|
import {
|
|
11
11
|
addAuthenticationOptions,
|
|
12
12
|
addConnectOptions,
|
|
13
|
-
addGetEntryOptions,
|
|
14
13
|
addGlobalOptions,
|
|
15
14
|
addImportOptions,
|
|
16
15
|
} from './globalOptions';
|
|
@@ -60,7 +59,7 @@ const commands = () => {
|
|
|
60
59
|
);
|
|
61
60
|
program.addCommand(
|
|
62
61
|
addGlobalOptions(
|
|
63
|
-
|
|
62
|
+
addImportOptions(makeDiffCommand())
|
|
64
63
|
).copyInheritedSettings(program)
|
|
65
64
|
);
|
|
66
65
|
program.addCommand(
|
|
@@ -68,7 +67,7 @@ const commands = () => {
|
|
|
68
67
|
);
|
|
69
68
|
program.addCommand(
|
|
70
69
|
addGlobalOptions(
|
|
71
|
-
|
|
70
|
+
addImportOptions(makeImportCommand())
|
|
72
71
|
).copyInheritedSettings(program)
|
|
73
72
|
);
|
|
74
73
|
program.addCommand(
|
package/src/commands/list.ts
CHANGED
|
@@ -160,5 +160,20 @@ Example call:
|
|
|
160
160
|
name ? [name] : id
|
|
161
161
|
);
|
|
162
162
|
});
|
|
163
|
+
|
|
164
|
+
list
|
|
165
|
+
.command('workflows')
|
|
166
|
+
.description('print list of workflow definitions')
|
|
167
|
+
.addHelpText(
|
|
168
|
+
'after',
|
|
169
|
+
`
|
|
170
|
+
Example call:
|
|
171
|
+
> list workflows
|
|
172
|
+
`
|
|
173
|
+
)
|
|
174
|
+
.action(async opts => {
|
|
175
|
+
await cliCommand(['list', 'workflows'], opts).PrintWorkflows();
|
|
176
|
+
});
|
|
177
|
+
|
|
163
178
|
return list;
|
|
164
179
|
};
|
package/src/commands/remove.ts
CHANGED
|
@@ -135,5 +135,25 @@ Example call:
|
|
|
135
135
|
}
|
|
136
136
|
});
|
|
137
137
|
|
|
138
|
+
remove
|
|
139
|
+
.command('nodes')
|
|
140
|
+
.description('delete nodes from the site view tree')
|
|
141
|
+
.argument('<root>', 'remove nodes from the specified path e.g. /blog or /')
|
|
142
|
+
.addOption(commit)
|
|
143
|
+
.addHelpText(
|
|
144
|
+
'after',
|
|
145
|
+
`
|
|
146
|
+
Example call:
|
|
147
|
+
> remove nodes /blog
|
|
148
|
+
`
|
|
149
|
+
)
|
|
150
|
+
.action(async (root: string, opts) => {
|
|
151
|
+
await cliCommand(
|
|
152
|
+
['remove', 'nodes', root],
|
|
153
|
+
opts,
|
|
154
|
+
mapContensisOpts({ paths: root.split(' '), ...opts })
|
|
155
|
+
).RemoveNodes(opts.commit);
|
|
156
|
+
});
|
|
157
|
+
|
|
138
158
|
return remove;
|
|
139
159
|
};
|
|
@@ -158,8 +158,8 @@ export const LogMessages = {
|
|
|
158
158
|
imported: (env: string, commit: boolean, count: number) =>
|
|
159
159
|
`[${env}] ${commit ? `Imported` : `Will import`} ${count} nodes`,
|
|
160
160
|
failedImport: (env: string) => `[${env}] Unable to import nodes`,
|
|
161
|
-
removed: (env: string, commit: boolean) =>
|
|
162
|
-
`[${env}] ${commit ? `Deleted` : `Will delete`} nodes`,
|
|
161
|
+
removed: (env: string, commit: boolean, root: string) =>
|
|
162
|
+
`[${env}] ${commit ? `Deleted` : `Will delete`} nodes at ${root}`,
|
|
163
163
|
failedRemove: (env: string) => `[${env}] Unable to delete nodes`,
|
|
164
164
|
notFound: (env: string) => `[${env}] Nodes were not found `,
|
|
165
165
|
commitTip: () => `Add --commit flag to commit the previewed changes`,
|
|
@@ -432,6 +432,13 @@ export const LogMessages = {
|
|
|
432
432
|
id
|
|
433
433
|
)}`,
|
|
434
434
|
},
|
|
435
|
+
workflows: {
|
|
436
|
+
list: (env: string) => `[${env}] Retrieved workflows`,
|
|
437
|
+
noList: (env: string) => `[${env}] Cannot retrieve workflows`,
|
|
438
|
+
noneExist: () => `No workflows found`,
|
|
439
|
+
failedGet: (env: string, name: string) =>
|
|
440
|
+
`[${env}] Unable to find workflow ${Logger.highlightText(name)}`,
|
|
441
|
+
},
|
|
435
442
|
devinit: {
|
|
436
443
|
intro: () => `Contensis developer environment initialisation`,
|
|
437
444
|
//`This will initialise your local working directory to develop with the current connected Contensis project`,
|
|
@@ -444,7 +451,7 @@ export const LogMessages = {
|
|
|
444
451
|
) =>
|
|
445
452
|
`
|
|
446
453
|
Project: ${Logger.standardText(name)}
|
|
447
|
-
- Home: ${Logger.standardText(
|
|
454
|
+
- Home: ${Logger.standardText(git.gitcwd())}
|
|
448
455
|
- Repository: ${Logger.standardText(git.home)}
|
|
449
456
|
- Block id: ${Logger.highlightText(blockId)}
|
|
450
457
|
|
|
@@ -544,9 +551,10 @@ export const LogMessages = {
|
|
|
544
551
|
} ${Logger.highlightText(`CONTENSIS_SHARED_SECRET`)}\n ${
|
|
545
552
|
git.type === 'github' ? `Secret:` : `Value:`
|
|
546
553
|
} ${Logger.standardText(secret)}`,
|
|
547
|
-
accessTokenFetch: () =>
|
|
554
|
+
accessTokenFetch: () =>
|
|
555
|
+
`Please wait, fetching Delivery API access token ⏳`,
|
|
548
556
|
accessTokenSuccess: (token: string) =>
|
|
549
|
-
`Successfully fetched Delivery API token
|
|
557
|
+
`Successfully fetched Delivery API token\n ${Logger.infoText(token)}`,
|
|
550
558
|
accessTokenFailed: () =>
|
|
551
559
|
`Something went wrong! If the problem persists, please contact our support team 🛟`,
|
|
552
560
|
accessTokenPermission: () =>
|
|
@@ -565,6 +573,8 @@ export const LogMessages = {
|
|
|
565
573
|
failed: () => `Contensis developer environment initialisation failed`,
|
|
566
574
|
dryRun: () =>
|
|
567
575
|
`Contensis developer environment initialisation dry run completed`,
|
|
576
|
+
dryRunKeyMessage: (dryRun: boolean) =>
|
|
577
|
+
dryRun ? '<< not created: dry-run >>' : undefined,
|
|
568
578
|
noChanges: () =>
|
|
569
579
|
`No changes were made to your project, run the command again without the ${Logger.highlightText(
|
|
570
580
|
'--dry-run'
|
|
@@ -102,12 +102,10 @@ const mapGitLabCIWorkflowContent = async (
|
|
|
102
102
|
alias: cli.currentEnv,
|
|
103
103
|
project_id: cli.currentProject,
|
|
104
104
|
client_id:
|
|
105
|
-
loc === 'env'
|
|
106
|
-
? cli.devinit?.credentials.clientId
|
|
107
|
-
: '$CONTENSIS_CLIENT_ID',
|
|
105
|
+
loc === 'env' ? cli.deployCredentials.clientId : '$CONTENSIS_CLIENT_ID',
|
|
108
106
|
shared_secret:
|
|
109
107
|
loc === 'env'
|
|
110
|
-
? cli.
|
|
108
|
+
? cli.deployCredentials.clientSecret
|
|
111
109
|
: '$CONTENSIS_SHARED_SECRET',
|
|
112
110
|
},
|
|
113
111
|
};
|
|
@@ -120,12 +118,14 @@ const mapGitLabCIWorkflowContent = async (
|
|
|
120
118
|
setWorkflowElement(
|
|
121
119
|
workflowDoc,
|
|
122
120
|
`variables.CONTENSIS_CLIENT_ID`,
|
|
123
|
-
|
|
121
|
+
cli.deployCredentials.clientId ||
|
|
122
|
+
cli.messages.devinit.dryRunKeyMessage(!!cli.command.options.dryRun)
|
|
124
123
|
);
|
|
125
124
|
setWorkflowElement(
|
|
126
125
|
workflowDoc,
|
|
127
126
|
`variables.CONTENSIS_CLIENT_SECRET`,
|
|
128
|
-
|
|
127
|
+
cli.deployCredentials.clientSecret ||
|
|
128
|
+
cli.messages.devinit.dryRunKeyMessage(!!cli.command.options.dryRun)
|
|
129
129
|
);
|
|
130
130
|
}
|
|
131
131
|
|
|
@@ -298,12 +298,12 @@ const mapGitHubActionCIWorkflowContent = async (
|
|
|
298
298
|
setWorkflowElement(
|
|
299
299
|
workflowDoc,
|
|
300
300
|
`env.CONTENSIS_CLIENT_ID`,
|
|
301
|
-
cli.
|
|
301
|
+
cli.deployCredentials.clientId
|
|
302
302
|
);
|
|
303
303
|
setWorkflowElement(
|
|
304
304
|
workflowDoc,
|
|
305
305
|
'env.CONTENSIS_SHARED_SECRET',
|
|
306
|
-
cli.
|
|
306
|
+
cli.deployCredentials.clientSecret
|
|
307
307
|
);
|
|
308
308
|
}
|
|
309
309
|
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { Role } from 'contensis-management-api/lib/models';
|
|
2
2
|
|
|
3
3
|
export const devKeyPermissions = {} as Partial<Role['permissions']>;
|
|
4
|
+
|
|
4
5
|
export const deployKeyPermissions = {
|
|
5
6
|
blocks: { actions: ['push', 'release', 'view'] },
|
|
6
7
|
} as Role['permissions'];
|
|
7
8
|
|
|
8
9
|
export const devKeyRole = (
|
|
9
10
|
keyName: string,
|
|
11
|
+
roleName: string,
|
|
10
12
|
description: string
|
|
11
13
|
): Partial<Role> => ({
|
|
12
|
-
name:
|
|
14
|
+
name: roleName,
|
|
13
15
|
description,
|
|
14
16
|
assignments: {
|
|
15
17
|
apiKeys: [keyName],
|
|
@@ -20,9 +22,10 @@ export const devKeyRole = (
|
|
|
20
22
|
|
|
21
23
|
export const deployKeyRole = (
|
|
22
24
|
keyName: string,
|
|
25
|
+
roleName: string,
|
|
23
26
|
description: string
|
|
24
27
|
): Partial<Role> => ({
|
|
25
|
-
name:
|
|
28
|
+
name: roleName,
|
|
26
29
|
description,
|
|
27
30
|
assignments: {
|
|
28
31
|
apiKeys: [keyName],
|