contensis-cli 1.0.0-beta.61 → 1.0.0-beta.63
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/get.js +11 -0
- package/dist/commands/get.js.map +2 -2
- package/dist/commands/list.js +16 -1
- package/dist/commands/list.js.map +2 -2
- package/dist/commands/set.js +70 -12
- package/dist/commands/set.js.map +2 -2
- package/dist/localisation/en-GB.js +10 -1
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/services/ContensisCliService.js +113 -0
- package/dist/services/ContensisCliService.js.map +2 -2
- package/dist/shell.js +7 -2
- package/dist/shell.js.map +2 -2
- package/dist/util/logger.js +1 -1
- 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/get.ts +17 -0
- package/src/commands/list.ts +21 -0
- package/src/commands/set.ts +92 -10
- package/src/localisation/en-GB.ts +15 -1
- package/src/services/ContensisCliService.ts +145 -1
- package/src/shell.ts +7 -2
- package/src/util/logger.ts +1 -1
- package/src/version.ts +1 -1
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, 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${JSON.stringify(err, null, 2)}` : ''\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 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: '\\u001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xB,aAAS,QAAQ,UAAU,OAAO;AAAA,EACpC;AAAA,EACA,OAAO,OAA2B,CAAC,SAAS,QAAQ,MAClD,QAAQ,QAAI,oBAAAC,SAAY,OAAO,GAAG,EAAE,QAAQ,MAAM,MAAM,CAAC;AAAA,EAC3D,OAAO,QAAwB,kBAC7B,QAAQ,IAAI,GAAG,OAAO,UAAU,KAAK,aAAa,KAAK,GAAG,GAAG;AAAA,EAC/D,OAAO,OAAO,MACZ,OAAO,IAAI,KAAK,OAAO,SAAS,uCAAuC,GAAG;AAAA,EAE5E,OAAO,SAAwB,aAAW;AA7F5C;AA8FI,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,
|
|
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, 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${JSON.stringify(err, null, 2)}` : ''\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 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,O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
|
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.63";
|
|
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.63\";\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.63",
|
|
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.25",
|
|
39
39
|
"node-fetch": "^2.6.7",
|
|
40
40
|
"patch-package": "^6.4.7",
|
|
41
41
|
"xml2js": "^0.4.23"
|
package/src/commands/get.ts
CHANGED
|
@@ -40,6 +40,23 @@ Example call:
|
|
|
40
40
|
);
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
+
program
|
|
44
|
+
.command('role')
|
|
45
|
+
.description('get a role')
|
|
46
|
+
.argument('<roleNameOrId>', 'id or name of the role to get')
|
|
47
|
+
.addHelpText(
|
|
48
|
+
'after',
|
|
49
|
+
`
|
|
50
|
+
Example call:
|
|
51
|
+
> get role "entry admin"
|
|
52
|
+
`
|
|
53
|
+
)
|
|
54
|
+
.action(async (roleNameOrId: string, opts) => {
|
|
55
|
+
await cliCommand(['get', 'role', roleNameOrId], opts).PrintRole(
|
|
56
|
+
roleNameOrId
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
|
|
43
60
|
program
|
|
44
61
|
.command('model')
|
|
45
62
|
.description('get a content model')
|
package/src/commands/list.ts
CHANGED
|
@@ -26,6 +26,13 @@ Example call:
|
|
|
26
26
|
list
|
|
27
27
|
.command('projects')
|
|
28
28
|
.description('print list of projects')
|
|
29
|
+
.addHelpText(
|
|
30
|
+
'after',
|
|
31
|
+
`
|
|
32
|
+
Example call:
|
|
33
|
+
> list projects
|
|
34
|
+
`
|
|
35
|
+
)
|
|
29
36
|
.action(async opts => {
|
|
30
37
|
await cliCommand(['list', 'projects'], opts).PrintProjects();
|
|
31
38
|
});
|
|
@@ -100,6 +107,20 @@ Example call:
|
|
|
100
107
|
await cliCommand(['list', 'keys'], opts).PrintApiKeys();
|
|
101
108
|
});
|
|
102
109
|
|
|
110
|
+
list
|
|
111
|
+
.command('roles')
|
|
112
|
+
.description('print list of roles')
|
|
113
|
+
.addHelpText(
|
|
114
|
+
'after',
|
|
115
|
+
`
|
|
116
|
+
Example call:
|
|
117
|
+
> list roles
|
|
118
|
+
`
|
|
119
|
+
)
|
|
120
|
+
.action(async opts => {
|
|
121
|
+
await cliCommand(['list', 'roles'], opts).PrintRoles();
|
|
122
|
+
});
|
|
123
|
+
|
|
103
124
|
list
|
|
104
125
|
.command('webhooks')
|
|
105
126
|
.description('print list of webhooks')
|
package/src/commands/set.ts
CHANGED
|
@@ -42,13 +42,9 @@ Example call:
|
|
|
42
42
|
> set project name "Project name"\n`
|
|
43
43
|
)
|
|
44
44
|
.action(async (name: string, opts) => {
|
|
45
|
-
|
|
46
|
-
['set', 'project', 'name'],
|
|
47
|
-
opts
|
|
48
|
-
).UpdateProject({
|
|
45
|
+
await cliCommand(['set', 'project', 'name'], opts).UpdateProject({
|
|
49
46
|
name,
|
|
50
47
|
});
|
|
51
|
-
if (success) await shell().restart();
|
|
52
48
|
});
|
|
53
49
|
|
|
54
50
|
project
|
|
@@ -66,13 +62,99 @@ Example call:
|
|
|
66
62
|
> set project description "Description of project"\n`
|
|
67
63
|
)
|
|
68
64
|
.action(async (description: string, opts) => {
|
|
69
|
-
|
|
70
|
-
['set', 'project', 'description'],
|
|
71
|
-
opts
|
|
72
|
-
).UpdateProject({
|
|
65
|
+
await cliCommand(['set', 'project', 'description'], opts).UpdateProject({
|
|
73
66
|
description,
|
|
74
67
|
});
|
|
75
|
-
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const role = set.command('role').description('update a role');
|
|
71
|
+
role
|
|
72
|
+
.command('name')
|
|
73
|
+
.description('update role name')
|
|
74
|
+
.argument('<"Role name">', 'update the existing role name')
|
|
75
|
+
.argument('<"New name">', 'the new name for the role')
|
|
76
|
+
.usage('<"Role name"> <"New name">')
|
|
77
|
+
.addHelpText(
|
|
78
|
+
'after',
|
|
79
|
+
`
|
|
80
|
+
Example call:
|
|
81
|
+
> set role name "Existing name" "New role name"\n`
|
|
82
|
+
)
|
|
83
|
+
.action(async (roleNameOrId: string, newName: string, opts) => {
|
|
84
|
+
await cliCommand(['set', 'role', 'name'], opts).UpdateRole(roleNameOrId, {
|
|
85
|
+
name: newName,
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
role
|
|
90
|
+
.command('assignments')
|
|
91
|
+
.description('update role assignments')
|
|
92
|
+
.argument('<"Role name" or id>', 'the role name or id to update')
|
|
93
|
+
.option(
|
|
94
|
+
'-users --assign-users [assign-users...]',
|
|
95
|
+
'the user id(s) to assign'
|
|
96
|
+
)
|
|
97
|
+
.option(
|
|
98
|
+
'-groups --assign-groups [assign-groups...]',
|
|
99
|
+
'the groups name(s) to assign'
|
|
100
|
+
)
|
|
101
|
+
.option('-keys --assign-keys [assign-keys...]', 'the key name(s) to assign')
|
|
102
|
+
.addHelpText(
|
|
103
|
+
'after',
|
|
104
|
+
`
|
|
105
|
+
Example call:
|
|
106
|
+
> set role assignments "My role" --assign-users admin \n`
|
|
107
|
+
)
|
|
108
|
+
.action(async (roleNameOrId: string, opts) => {
|
|
109
|
+
await cliCommand(['set', 'role', 'assignments'], opts).UpdateRole(
|
|
110
|
+
roleNameOrId,
|
|
111
|
+
{
|
|
112
|
+
assignments: {
|
|
113
|
+
apiKeys: opts.assignKeys || undefined,
|
|
114
|
+
groups: opts.assignGroups || undefined,
|
|
115
|
+
users: opts.assignUsers || undefined,
|
|
116
|
+
},
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
role
|
|
122
|
+
.command('permissions')
|
|
123
|
+
.description('update role permissions')
|
|
124
|
+
.argument('<"Role name" or id>', 'the role name or id to update')
|
|
125
|
+
.option(
|
|
126
|
+
'-contenttype --content-type-id [content-type-id...]',
|
|
127
|
+
'the content type id to add permissions for'
|
|
128
|
+
)
|
|
129
|
+
.option(
|
|
130
|
+
'-actions --entry-actions [entry-actions...]',
|
|
131
|
+
'the entry actions to add to the role permissions',
|
|
132
|
+
'*'
|
|
133
|
+
)
|
|
134
|
+
.option(
|
|
135
|
+
'-languages --entry-languages [entry-languages...]',
|
|
136
|
+
'the entry languages to add to the role permissions',
|
|
137
|
+
'*'
|
|
138
|
+
)
|
|
139
|
+
.addHelpText(
|
|
140
|
+
'after',
|
|
141
|
+
`
|
|
142
|
+
Example call:
|
|
143
|
+
> set role permissions "My role" --content-type-id blogs -- \n`
|
|
144
|
+
)
|
|
145
|
+
.action(async (roleNameOrId: string, opts) => {
|
|
146
|
+
await cliCommand(['set', 'role', 'permissions'], opts).UpdateRole(
|
|
147
|
+
roleNameOrId,
|
|
148
|
+
{
|
|
149
|
+
permissions: {
|
|
150
|
+
entries: opts.contentTypeId?.map((id: string) => ({
|
|
151
|
+
id,
|
|
152
|
+
actions: opts.entryActions,
|
|
153
|
+
languages: opts.entryLanguages,
|
|
154
|
+
})),
|
|
155
|
+
},
|
|
156
|
+
}
|
|
157
|
+
);
|
|
76
158
|
});
|
|
77
159
|
|
|
78
160
|
set
|
|
@@ -203,7 +203,7 @@ export const LogMessages = {
|
|
|
203
203
|
},
|
|
204
204
|
keys: {
|
|
205
205
|
list: (env: string) => `[${env}] API keys:`,
|
|
206
|
-
noList: (env: string) => `[${env}] Cannot retrieve API`,
|
|
206
|
+
noList: (env: string) => `[${env}] Cannot retrieve API keys`,
|
|
207
207
|
created: (env: string, name: string) =>
|
|
208
208
|
`[${env}] Created API key ${Logger.highlightText(name)}`,
|
|
209
209
|
failedCreate: (env: string, name: string) =>
|
|
@@ -213,6 +213,20 @@ export const LogMessages = {
|
|
|
213
213
|
failedRemove: (env: string, id: string) =>
|
|
214
214
|
`[${env}] Unable to delete API key ${Logger.highlightText(id)}`,
|
|
215
215
|
},
|
|
216
|
+
roles: {
|
|
217
|
+
list: (env: string) => `[${env}] Retrieved roles:`,
|
|
218
|
+
noList: (env: string) => `[${env}] Cannot retrieve roles`,
|
|
219
|
+
failedGet: (env: string, name: string) =>
|
|
220
|
+
`[${env}] Unable to find role ${Logger.highlightText(name)}`,
|
|
221
|
+
created: (env: string, name: string) =>
|
|
222
|
+
`[${env}] Created role ${Logger.highlightText(name)}`,
|
|
223
|
+
failedCreate: (env: string, name: string) =>
|
|
224
|
+
`[${env}] Unable to create role ${Logger.highlightText(name)}`,
|
|
225
|
+
removed: (env: string, id: string) =>
|
|
226
|
+
`[${env}] Deleted role ${Logger.highlightText(id)}`,
|
|
227
|
+
failedRemove: (env: string, id: string) =>
|
|
228
|
+
`[${env}] Unable to delete role ${Logger.highlightText(id)}`,
|
|
229
|
+
},
|
|
216
230
|
blocks: {
|
|
217
231
|
runningStatus: (status: BlockRunningStatus | 'broken') => {
|
|
218
232
|
switch (status) {
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
Model,
|
|
22
22
|
MigrateModelsResult,
|
|
23
23
|
} from 'migratortron';
|
|
24
|
-
import { Entry } from 'contensis-management-api/lib/models';
|
|
24
|
+
import { Entry, Role } from 'contensis-management-api/lib/models';
|
|
25
25
|
|
|
26
26
|
import { csvFormatter } from '~/util/csv.formatter';
|
|
27
27
|
import { xmlFormatter } from '~/util/xml.formatter';
|
|
@@ -785,6 +785,150 @@ class ContensisCli {
|
|
|
785
785
|
}
|
|
786
786
|
};
|
|
787
787
|
|
|
788
|
+
PrintRoles = async () => {
|
|
789
|
+
const { currentEnv, log, messages } = this;
|
|
790
|
+
const contensis = await this.ConnectContensis();
|
|
791
|
+
|
|
792
|
+
if (contensis) {
|
|
793
|
+
// Retrieve roles list for env
|
|
794
|
+
const [rolesErr, roles] = await to(contensis.roles.GetRoles());
|
|
795
|
+
|
|
796
|
+
if (Array.isArray(roles)) {
|
|
797
|
+
log.success(messages.roles.list(currentEnv));
|
|
798
|
+
this.HandleFormattingAndOutput(roles, () => {
|
|
799
|
+
// print the roles to console
|
|
800
|
+
for (const {
|
|
801
|
+
id,
|
|
802
|
+
name,
|
|
803
|
+
description,
|
|
804
|
+
enabled,
|
|
805
|
+
assignments,
|
|
806
|
+
permissions,
|
|
807
|
+
} of roles) {
|
|
808
|
+
const color = enabled ? (s: string) => s : log.infoText;
|
|
809
|
+
|
|
810
|
+
console.log(color(` - ${name} ${log.infoText(id)}`));
|
|
811
|
+
if (description) console.log(log.infoText(` ${description}`));
|
|
812
|
+
|
|
813
|
+
if (assignments.groups?.length)
|
|
814
|
+
console.log(
|
|
815
|
+
` ${chalk.bold.grey('groups')}: ${assignments.groups.join(
|
|
816
|
+
', '
|
|
817
|
+
)}`
|
|
818
|
+
);
|
|
819
|
+
if (assignments.users?.length)
|
|
820
|
+
console.log(
|
|
821
|
+
` ${chalk.bold.grey('users')}: ${assignments.users.join(
|
|
822
|
+
', '
|
|
823
|
+
)}`
|
|
824
|
+
);
|
|
825
|
+
if (assignments.apiKeys?.length)
|
|
826
|
+
console.log(
|
|
827
|
+
` ${chalk.bold.grey('keys')}: ${assignments.apiKeys.join(
|
|
828
|
+
', '
|
|
829
|
+
)}`
|
|
830
|
+
);
|
|
831
|
+
|
|
832
|
+
if (permissions.entries?.length) {
|
|
833
|
+
console.log(` ${chalk.bold.grey('entries')}:`);
|
|
834
|
+
for (const p of permissions.entries)
|
|
835
|
+
console.log(
|
|
836
|
+
` ${p.id}: ${log.infoText(
|
|
837
|
+
p.actions.length > 2
|
|
838
|
+
? p.actions.length
|
|
839
|
+
: p.actions.join(', ')
|
|
840
|
+
)}`
|
|
841
|
+
);
|
|
842
|
+
}
|
|
843
|
+
if (permissions.contentTypes?.length)
|
|
844
|
+
console.log(
|
|
845
|
+
` ${chalk.bold.grey(
|
|
846
|
+
'contentTypes'
|
|
847
|
+
)}: ${permissions.contentTypes
|
|
848
|
+
.map(
|
|
849
|
+
p =>
|
|
850
|
+
`${p.id} [${p.actions.join(',')}] ${p.languages.join(
|
|
851
|
+
' '
|
|
852
|
+
)}`
|
|
853
|
+
)
|
|
854
|
+
.join(', ')}`
|
|
855
|
+
);
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
if (rolesErr) {
|
|
861
|
+
log.error(messages.roles.noList(currentEnv));
|
|
862
|
+
log.error(jsonFormatter(rolesErr));
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
|
|
867
|
+
PrintRole = async (roleNameOrId: string) => {
|
|
868
|
+
const { currentEnv, log, messages } = this;
|
|
869
|
+
const contensis = await this.ConnectContensis();
|
|
870
|
+
|
|
871
|
+
if (contensis) {
|
|
872
|
+
// Retrieve roles list for env
|
|
873
|
+
const [rolesErr, roles] = await to(contensis.roles.GetRoles());
|
|
874
|
+
|
|
875
|
+
if (Array.isArray(roles)) {
|
|
876
|
+
log.success(messages.roles.list(currentEnv));
|
|
877
|
+
|
|
878
|
+
const role =
|
|
879
|
+
roles.find(
|
|
880
|
+
r =>
|
|
881
|
+
r.id === roleNameOrId ||
|
|
882
|
+
r.name.toLowerCase() === roleNameOrId.toLowerCase()
|
|
883
|
+
) ||
|
|
884
|
+
roles.find(r =>
|
|
885
|
+
r.name.toLowerCase().includes(roleNameOrId.toLowerCase())
|
|
886
|
+
);
|
|
887
|
+
|
|
888
|
+
if (role) this.HandleFormattingAndOutput(role, log.object);
|
|
889
|
+
else log.error(messages.roles.failedGet(currentEnv, roleNameOrId));
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
if (rolesErr) {
|
|
893
|
+
log.error(messages.roles.noList(currentEnv));
|
|
894
|
+
log.error(jsonFormatter(rolesErr));
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
};
|
|
898
|
+
|
|
899
|
+
UpdateRole = async (roleNameOrId: string, role: Partial<Role>) => {
|
|
900
|
+
const { currentEnv, log, messages } = this;
|
|
901
|
+
const contensis = await this.ConnectContensis();
|
|
902
|
+
|
|
903
|
+
if (contensis) {
|
|
904
|
+
// Retrieve roles list for env
|
|
905
|
+
const [rolesErr, roles] = await to(contensis.roles.GetRoles());
|
|
906
|
+
|
|
907
|
+
if (Array.isArray(roles)) {
|
|
908
|
+
log.success(messages.roles.list(currentEnv));
|
|
909
|
+
|
|
910
|
+
const existingRole = roles.find(
|
|
911
|
+
r =>
|
|
912
|
+
r.id === roleNameOrId ||
|
|
913
|
+
r.name.toLowerCase() === roleNameOrId.toLowerCase()
|
|
914
|
+
);
|
|
915
|
+
if (existingRole) {
|
|
916
|
+
const rolesService = contensis.roles.sourceRepo.roles;
|
|
917
|
+
|
|
918
|
+
await rolesService.UpdateRole(existingRole.id, role);
|
|
919
|
+
} else {
|
|
920
|
+
//Role not exist
|
|
921
|
+
}
|
|
922
|
+
this.HandleFormattingAndOutput(role, log.object);
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
if (rolesErr) {
|
|
926
|
+
log.error(messages.roles.noList(currentEnv));
|
|
927
|
+
log.error(jsonFormatter(rolesErr));
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
};
|
|
931
|
+
|
|
788
932
|
CreateProject = async (project: Project) => {
|
|
789
933
|
const { currentEnv, log, messages } = this;
|
|
790
934
|
const contensis = await this.ConnectContensis();
|
package/src/shell.ts
CHANGED
|
@@ -136,6 +136,7 @@ class ContensisShell {
|
|
|
136
136
|
if (userId)
|
|
137
137
|
availableCommands.push(
|
|
138
138
|
'create project',
|
|
139
|
+
'create role',
|
|
139
140
|
'diff models',
|
|
140
141
|
'get block',
|
|
141
142
|
'get block logs',
|
|
@@ -144,6 +145,7 @@ class ContensisShell {
|
|
|
144
145
|
'get entries',
|
|
145
146
|
'get model',
|
|
146
147
|
'get project',
|
|
148
|
+
'get role',
|
|
147
149
|
'get version',
|
|
148
150
|
'import contenttypes',
|
|
149
151
|
'import components',
|
|
@@ -152,8 +154,9 @@ class ContensisShell {
|
|
|
152
154
|
'list blocks',
|
|
153
155
|
'list contenttypes',
|
|
154
156
|
'list components',
|
|
155
|
-
'list models',
|
|
156
157
|
'list keys',
|
|
158
|
+
'list models',
|
|
159
|
+
'list roles',
|
|
157
160
|
'list webhooks',
|
|
158
161
|
'create key',
|
|
159
162
|
'push block',
|
|
@@ -163,7 +166,9 @@ class ContensisShell {
|
|
|
163
166
|
'remove contenttypes',
|
|
164
167
|
'remove components',
|
|
165
168
|
'set project name',
|
|
166
|
-
'set project description'
|
|
169
|
+
'set project description',
|
|
170
|
+
'set role assignments',
|
|
171
|
+
'set role permissions'
|
|
167
172
|
);
|
|
168
173
|
|
|
169
174
|
const prompt = inquirer.createPromptModule();
|
package/src/util/logger.ts
CHANGED
|
@@ -92,7 +92,7 @@ export class Logger {
|
|
|
92
92
|
Logger.raw(` ${Logger.infoText(`-------------------------------------`)}`);
|
|
93
93
|
|
|
94
94
|
static object: LogJsonMethod = content => {
|
|
95
|
-
for (const [key, value] of Object.entries(content)) {
|
|
95
|
+
for (const [key, value] of Object.entries(content || {})) {
|
|
96
96
|
if (value && typeof value === 'object') {
|
|
97
97
|
Logger.raw(` ${chalk.bold.grey(key)}:`);
|
|
98
98
|
if (key === 'fields' && Array.isArray(value)) {
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = "1.0.0-beta.
|
|
1
|
+
export const LIB_VERSION = "1.0.0-beta.63";
|