contensis-cli 1.0.0-beta.62 → 1.0.0-beta.64
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 +15 -0
- package/dist/commands/create.js.map +2 -2
- 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/remove.js +11 -0
- package/dist/commands/remove.js.map +2 -2
- package/dist/commands/set.js +98 -12
- package/dist/commands/set.js.map +2 -2
- package/dist/localisation/en-GB.js +18 -1
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/services/ContensisCliService.js +182 -4
- package/dist/services/ContensisCliService.js.map +2 -2
- package/dist/shell.js +14 -5
- package/dist/shell.js.map +2 -2
- package/dist/util/index.js +3 -0
- package/dist/util/index.js.map +2 -2
- package/dist/util/logger.js +12 -14
- package/dist/util/logger.js.map +3 -3
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +2 -2
- package/src/commands/create.ts +24 -0
- package/src/commands/get.ts +17 -0
- package/src/commands/list.ts +21 -0
- package/src/commands/remove.ts +16 -0
- package/src/commands/set.ts +134 -10
- package/src/localisation/en-GB.ts +23 -1
- package/src/services/ContensisCliService.ts +230 -7
- package/src/shell.ts +14 -5
- package/src/util/index.ts +3 -0
- package/src/util/logger.ts +26 -14
- package/src/version.ts +1 -1
package/dist/util/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/util/index.ts"],
|
|
4
|
-
"sourcesContent": ["import mergeWith from 'lodash/mergeWith';\nimport { Logger } from './logger';\nimport { LogMessages as enGB } from '../localisation/en-GB.js';\n\nexport const isSharedSecret = (str = '') =>\n str.length > 80 && str.split('-').length === 3 ? str : undefined;\n\nexport const isPassword = (str = '') =>\n !isSharedSecret(str) ? str : undefined;\n\nexport const tryParse = (str: string) => {\n try {\n return typeof str === 'object' ? str : JSON.parse(str);\n } catch (e) {\n return false;\n }\n};\n\nexport const isJson = (str: string) =>\n typeof str === 'object' || !!tryParse(str);\n\nexport const tryStringify = (obj: any) => {\n try {\n return typeof obj === 'object' ? JSON.stringify(obj) : obj;\n } catch (e) {\n return obj;\n }\n};\n\nexport const isUuid = (str: string) => {\n // Regular expression to check if string is a valid UUID\n const regexExp =\n /^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$/gi;\n\n return regexExp.test(str);\n};\n\nexport const url = (alias: string, project: string) => {\n const projectAndAlias =\n project && project.toLowerCase() !== 'website'\n ? `${project.toLowerCase()}-${alias}`\n : alias;\n return {\n api: `https://api-${alias}.cloud.contensis.com`,\n cms: `https://cms-${alias}.cloud.contensis.com`,\n liveWeb: `https://live-${projectAndAlias}.cloud.contensis.com`,\n previewWeb: `https://preview-${projectAndAlias}.cloud.contensis.com`,\n iisWeb: `https://iis-live-${projectAndAlias}.cloud.contensis.com`,\n iisPreviewWeb: `https://iis-preview-${projectAndAlias}.cloud.contensis.com`,\n };\n};\n\nexport const Logging = async (language = 'en-GB') => {\n const defaultMessages = enGB;\n // const { LogMessages: defaultMessages } = await import(\n // `../localisation/en-GB.js`\n // );\n let localisedMessages = defaultMessages;\n\n if (language === 'en-GB') {\n // Using a variable import e.g. `import(`../localisation/${language}.js`);`\n // does not play well with packaged executables\n // So we have to hard code the import for each language individually\n }\n return {\n messages: mergeWith(\n localisedMessages,\n defaultMessages,\n (v, s) => v || s\n ) as typeof defaultMessages,\n Log: Logger,\n };\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsB;AACtB,oBAAuB;AACvB,mBAAoC;AAE7B,MAAM,iBAAiB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';\nimport { LogMessages as enGB } from '../localisation/en-GB.js';\n\nexport const isSharedSecret = (str = '') =>\n str.length > 80 && str.split('-').length === 3 ? str : undefined;\n\nexport const isPassword = (str = '') =>\n !isSharedSecret(str) ? str : undefined;\n\nexport const tryParse = (str: string) => {\n try {\n return typeof str === 'object' ? str : JSON.parse(str);\n } catch (e) {\n return false;\n }\n};\n\nexport const isJson = (str: string) =>\n typeof str === 'object' || !!tryParse(str);\n\nexport const tryStringify = (obj: any) => {\n try {\n return typeof obj === 'object' ? JSON.stringify(obj) : obj;\n } catch (e) {\n return obj;\n }\n};\n\nexport const isSysError = (error: any): error is Error =>\n error?.message !== undefined && error.stack;\n\nexport const isUuid = (str: string) => {\n // Regular expression to check if string is a valid UUID\n const regexExp =\n /^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$/gi;\n\n return regexExp.test(str);\n};\n\nexport const url = (alias: string, project: string) => {\n const projectAndAlias =\n project && project.toLowerCase() !== 'website'\n ? `${project.toLowerCase()}-${alias}`\n : alias;\n return {\n api: `https://api-${alias}.cloud.contensis.com`,\n cms: `https://cms-${alias}.cloud.contensis.com`,\n liveWeb: `https://live-${projectAndAlias}.cloud.contensis.com`,\n previewWeb: `https://preview-${projectAndAlias}.cloud.contensis.com`,\n iisWeb: `https://iis-live-${projectAndAlias}.cloud.contensis.com`,\n iisPreviewWeb: `https://iis-preview-${projectAndAlias}.cloud.contensis.com`,\n };\n};\n\nexport const Logging = async (language = 'en-GB') => {\n const defaultMessages = enGB;\n // const { LogMessages: defaultMessages } = await import(\n // `../localisation/en-GB.js`\n // );\n let localisedMessages = defaultMessages;\n\n if (language === 'en-GB') {\n // Using a variable import e.g. `import(`../localisation/${language}.js`);`\n // does not play well with packaged executables\n // So we have to hard code the import for each language individually\n }\n return {\n messages: mergeWith(\n localisedMessages,\n defaultMessages,\n (v, s) => v || s\n ) as typeof defaultMess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AkB,aAAAA;AAIxB,MAAI,oBAAoB;AAExB,MAAI,aAAa,SAAS;AAAA,EAI1B;AACA,SAAO;AAAA,IACL,cAAU,iBAAAC;AAAA,MACR;AAAA,MACA;AAAA,MACA,CAAC,GAAG,MAAM,KAAK;AAAA,IACjB;AAAA,IACA,KAAK;AAAA,EACP;AACF;",
|
|
6
6
|
"names": ["enGB", "mergeWith"]
|
|
7
7
|
}
|
package/dist/util/logger.js
CHANGED
|
@@ -32,7 +32,6 @@ module.exports = __toCommonJS(logger_exports);
|
|
|
32
32
|
var import_chalk = __toESM(require("chalk"));
|
|
33
33
|
var import_dateformat = __toESM(require("dateformat"));
|
|
34
34
|
var import_deep_cleaner = __toESM(require("deep-cleaner"));
|
|
35
|
-
var import_progress = __toESM(require("progress"));
|
|
36
35
|
var import__ = require(".");
|
|
37
36
|
class Logger {
|
|
38
37
|
static isUserTerminal = !!process.stdout.columns;
|
|
@@ -57,7 +56,7 @@ class Logger {
|
|
|
57
56
|
const message = `${Logger.getPrefix()} ${Logger.errorText(
|
|
58
57
|
`${Logger.isUserTerminal ? "\u274C" : "[ERROR]"} ${content}${err ? `
|
|
59
58
|
|
|
60
|
-
${JSON.stringify(err, null, 2)}` : ""}`
|
|
59
|
+
${(0, import__.isSysError)(err) ? err.toString() : JSON.stringify(err, null, 2)}` : ""}`
|
|
61
60
|
)}${newline}`;
|
|
62
61
|
if (progress.active)
|
|
63
62
|
progress.current.interrupt(message);
|
|
@@ -114,7 +113,7 @@ ${Logger.standardText(content)}`;
|
|
|
114
113
|
static line = () => Logger.raw(` ${Logger.infoText(`-------------------------------------`)}`);
|
|
115
114
|
static object = (content) => {
|
|
116
115
|
var _a, _b, _c, _d, _e, _f;
|
|
117
|
-
for (const [key, value] of Object.entries(content)) {
|
|
116
|
+
for (const [key, value] of Object.entries(content || {})) {
|
|
118
117
|
if (value && typeof value === "object") {
|
|
119
118
|
Logger.raw(` ${import_chalk.default.bold.grey(key)}:`);
|
|
120
119
|
if (key === "fields" && Array.isArray(value)) {
|
|
@@ -156,15 +155,19 @@ ${Logger.standardText(content)}`;
|
|
|
156
155
|
} else
|
|
157
156
|
Logger.raw(`${indent}${item}`);
|
|
158
157
|
}
|
|
159
|
-
} else
|
|
158
|
+
} else {
|
|
159
|
+
let pos = 0;
|
|
160
160
|
for (const [key, value] of Object.entries(content)) {
|
|
161
161
|
if (Array.isArray(value)) {
|
|
162
|
+
const thisIndent = pos++ === 0 ? `${indent.substring(0, indent.length - 2)}- ` : indent;
|
|
163
|
+
if (value.length)
|
|
164
|
+
Logger.raw(`${thisIndent}${import_chalk.default.bold.grey(key)}:`);
|
|
162
165
|
for (const item of value) {
|
|
163
166
|
if (item && typeof item === "object") {
|
|
164
167
|
if (Array.isArray(item) && depth > 3)
|
|
165
168
|
Logger.raw(import_chalk.default.grey(`${indent} [${item.join(", ")}]`));
|
|
166
169
|
else
|
|
167
|
-
Logger.objectRecurse(item, depth + 1, `${indent}`);
|
|
170
|
+
Logger.objectRecurse(item, depth + 1, `${indent} `);
|
|
168
171
|
} else {
|
|
169
172
|
Logger.raw(`${indent} ${item}`);
|
|
170
173
|
}
|
|
@@ -176,6 +179,7 @@ ${Logger.standardText(content)}`;
|
|
|
176
179
|
Logger.raw(`${indent}${import_chalk.default.bold.grey(key)}: ${value}`);
|
|
177
180
|
}
|
|
178
181
|
}
|
|
182
|
+
}
|
|
179
183
|
};
|
|
180
184
|
static raw = (content) => {
|
|
181
185
|
if (progress.active)
|
|
@@ -196,15 +200,9 @@ const logError = (err = new Error("Undefined error"), msg, level = "error") => {
|
|
|
196
200
|
return null;
|
|
197
201
|
};
|
|
198
202
|
const progress = {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
current: new import_progress.default(`:bar`, {
|
|
203
|
-
complete: "=",
|
|
204
|
-
incomplete: " ",
|
|
205
|
-
width: 20,
|
|
206
|
-
total: 100
|
|
207
|
-
})
|
|
203
|
+
current: { interrupt: (x) => {
|
|
204
|
+
} },
|
|
205
|
+
active: false
|
|
208
206
|
};
|
|
209
207
|
// Annotate the CommonJS export names for ESM import in node:
|
|
210
208
|
0 && (module.exports = {
|
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';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,wBAAuB;AACvB,0BAAwB;
|
|
6
|
-
"names": ["dateFormat", "chalk", "deepCleaner"
|
|
4
|
+
"sourcesContent": ["/* eslint-disable no-console */\nimport chalk from 'chalk';\nimport dateFormat from 'dateformat';\nimport deepCleaner from 'deep-cleaner';\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${\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 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 if (Array.isArray(value)) {\n const thisIndent =\n pos++ === 0\n ? `${indent.substring(0, indent.length - 2)}- `\n : indent;\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(`${indent}${chalk.bold.grey(key)}: ${value}`);\n }\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 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": ";;;;;;;;;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C/D,CAAC;AAED,SAAO;AACT;AAEO,MAAM,WAAW;AAAA,EACtB,SAAS,EAAE,WAAW,CAAC,MAAc;AAAA,EAAC,EAAE;AAAA,EACxC,QAAQ;AASV;",
|
|
6
|
+
"names": ["dateFormat", "chalk", "deepCleaner"]
|
|
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.64";
|
|
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.64\";\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.64",
|
|
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.26",
|
|
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
|
@@ -2,6 +2,7 @@ import { Command } from 'commander';
|
|
|
2
2
|
import { Project } from 'contensis-core-api';
|
|
3
3
|
import { cliCommand } from '~/services/ContensisCliService';
|
|
4
4
|
import { shell } from '~/shell';
|
|
5
|
+
import { isUuid } from '~/util';
|
|
5
6
|
|
|
6
7
|
export const makeCreateCommand = () => {
|
|
7
8
|
const create = new Command()
|
|
@@ -47,6 +48,7 @@ export const makeCreateCommand = () => {
|
|
|
47
48
|
if (project) await shell().restart();
|
|
48
49
|
}
|
|
49
50
|
);
|
|
51
|
+
|
|
50
52
|
create
|
|
51
53
|
.command('key')
|
|
52
54
|
.description('create a new api key')
|
|
@@ -66,5 +68,27 @@ Example call:
|
|
|
66
68
|
);
|
|
67
69
|
});
|
|
68
70
|
|
|
71
|
+
create
|
|
72
|
+
.command('role')
|
|
73
|
+
.description('create a new role')
|
|
74
|
+
.argument('<"Role name">', 'the name of the role to create')
|
|
75
|
+
.argument('["Role description">', 'the description of the role')
|
|
76
|
+
.option('--disabled', 'do not enable the created role', false)
|
|
77
|
+
.addHelpText(
|
|
78
|
+
'after',
|
|
79
|
+
`
|
|
80
|
+
Example call:
|
|
81
|
+
> create role "My role" "This role is for testing" --disabled \n`
|
|
82
|
+
)
|
|
83
|
+
.action(async (roleName: string, description: string, opts) => {
|
|
84
|
+
await cliCommand(['create', 'role', roleName], opts).CreateRole({
|
|
85
|
+
name: roleName,
|
|
86
|
+
description,
|
|
87
|
+
enabled: !opts.disabled,
|
|
88
|
+
assignments: { apiKeys: [], groups: [], users: [] },
|
|
89
|
+
permissions: { contentTypes: [], entries: [] },
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
69
93
|
return create;
|
|
70
94
|
};
|
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/remove.ts
CHANGED
|
@@ -42,6 +42,22 @@ Example call:
|
|
|
42
42
|
await cliCommand(['remove', 'key', id], opts).RemoveApiKey(id);
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
+
remove
|
|
46
|
+
.command('role')
|
|
47
|
+
.description('remove a role')
|
|
48
|
+
.argument('<"Role name" or id>', 'the existing role name or id to delete')
|
|
49
|
+
.addHelpText(
|
|
50
|
+
'after',
|
|
51
|
+
`
|
|
52
|
+
Example call:
|
|
53
|
+
> remove role "My role"\n`
|
|
54
|
+
)
|
|
55
|
+
.action(async (roleNameOrId: string, opts) => {
|
|
56
|
+
await cliCommand(['remove', 'role', roleNameOrId], opts).RemoveRole(
|
|
57
|
+
roleNameOrId
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
|
|
45
61
|
remove
|
|
46
62
|
.command('components')
|
|
47
63
|
.description('delete components')
|
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,141 @@ 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
|
+
|
|
72
|
+
role
|
|
73
|
+
.command('name')
|
|
74
|
+
.description('update role name')
|
|
75
|
+
.argument('<"Role name">', 'update the existing role name')
|
|
76
|
+
.argument('<"New name">', 'the new name for the role')
|
|
77
|
+
.usage('<"Role name"> <"New name">')
|
|
78
|
+
.addHelpText(
|
|
79
|
+
'after',
|
|
80
|
+
`
|
|
81
|
+
Example call:
|
|
82
|
+
> set role name "Existing name" "New role name"\n`
|
|
83
|
+
)
|
|
84
|
+
.action(async (roleNameOrId: string, newName: string, opts) => {
|
|
85
|
+
await cliCommand(['set', 'role', 'name'], opts).UpdateRole(roleNameOrId, {
|
|
86
|
+
name: newName,
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
role
|
|
91
|
+
.command('description')
|
|
92
|
+
.description('update role description')
|
|
93
|
+
.argument('<"Role name" or id>', 'the existing role name or id to update')
|
|
94
|
+
.argument('<"New description">', 'the new description for the role')
|
|
95
|
+
.usage('<"Role name"> <"New description">')
|
|
96
|
+
.addHelpText(
|
|
97
|
+
'after',
|
|
98
|
+
`
|
|
99
|
+
Example call:
|
|
100
|
+
> set role description "Existing role" "New role description"\n`
|
|
101
|
+
)
|
|
102
|
+
.action(async (roleNameOrId: string, description: string, opts) => {
|
|
103
|
+
await cliCommand(['set', 'role', 'description'], opts).UpdateRole(
|
|
104
|
+
roleNameOrId,
|
|
105
|
+
{
|
|
106
|
+
description,
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
role
|
|
112
|
+
.command('enabled')
|
|
113
|
+
.description('enable or disable a role')
|
|
114
|
+
.argument('<"Role name" or id>', 'the existing role name or id to update')
|
|
115
|
+
.usage('<"Role name"> --disabled')
|
|
116
|
+
.option('--disabled', 'disable the role', false)
|
|
117
|
+
.addHelpText(
|
|
118
|
+
'after',
|
|
119
|
+
`
|
|
120
|
+
Example call:
|
|
121
|
+
> set role enabled "Existing role"\n
|
|
122
|
+
> set role enabled "Other role" --disabled\n`
|
|
123
|
+
)
|
|
124
|
+
.action(async (roleNameOrId: string, opts) => {
|
|
125
|
+
await cliCommand(
|
|
126
|
+
['set', 'role', opts.disabled ? 'disabled' : 'enabled'],
|
|
127
|
+
opts
|
|
128
|
+
).UpdateRole(roleNameOrId, {
|
|
129
|
+
enabled: !opts.disabled,
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
role
|
|
134
|
+
.command('assignments')
|
|
135
|
+
.description('assign users, groups or keys to a role')
|
|
136
|
+
.argument('<"Role name" or id>', 'the role name or id to update')
|
|
137
|
+
.option(
|
|
138
|
+
'-users --assign-users [assign-users...]',
|
|
139
|
+
'the user id(s) to assign'
|
|
140
|
+
)
|
|
141
|
+
.option(
|
|
142
|
+
'-groups --assign-groups [assign-groups...]',
|
|
143
|
+
'the groups name(s) to assign'
|
|
144
|
+
)
|
|
145
|
+
.option('-keys --assign-keys [assign-keys...]', 'the key name(s) to assign')
|
|
146
|
+
.addHelpText(
|
|
147
|
+
'after',
|
|
148
|
+
`
|
|
149
|
+
Example call:
|
|
150
|
+
> set role assignments "My role" --assign-users admin \n`
|
|
151
|
+
)
|
|
152
|
+
.action(async (roleNameOrId: string, opts) => {
|
|
153
|
+
await cliCommand(['set', 'role', 'assignments'], opts).UpdateRole(
|
|
154
|
+
roleNameOrId,
|
|
155
|
+
{
|
|
156
|
+
assignments: {
|
|
157
|
+
apiKeys: opts.assignKeys || undefined,
|
|
158
|
+
groups: opts.assignGroups || undefined,
|
|
159
|
+
users: opts.assignUsers || undefined,
|
|
160
|
+
},
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
role
|
|
166
|
+
.command('permissions')
|
|
167
|
+
.description('add entry permissions to a role')
|
|
168
|
+
.argument('<"Role name" or id>', 'the role name or id to update')
|
|
169
|
+
.option(
|
|
170
|
+
'-contenttypes, --content-type-ids [content-type-id...]',
|
|
171
|
+
'any content type ids to add permissions for'
|
|
172
|
+
)
|
|
173
|
+
.option(
|
|
174
|
+
'--entry-actions [entry-actions...]',
|
|
175
|
+
'the entry actions to add to the role permissions'
|
|
176
|
+
)
|
|
177
|
+
.option(
|
|
178
|
+
'--entry-languages [entry-languages...]',
|
|
179
|
+
'the entry languages to add to the role permissions'
|
|
180
|
+
)
|
|
181
|
+
.addHelpText(
|
|
182
|
+
'after',
|
|
183
|
+
`
|
|
184
|
+
Example call:
|
|
185
|
+
> set role permissions "My role" --content-type-id blogs -- \n`
|
|
186
|
+
)
|
|
187
|
+
.action(async (roleNameOrId: string, opts) => {
|
|
188
|
+
await cliCommand(['set', 'role', 'permissions'], opts).UpdateRole(
|
|
189
|
+
roleNameOrId,
|
|
190
|
+
{
|
|
191
|
+
permissions: {
|
|
192
|
+
entries: opts.contentTypeIds?.map((id: string) => ({
|
|
193
|
+
id,
|
|
194
|
+
actions: opts.entryActions || [],
|
|
195
|
+
languages: opts.entryLanguages || [],
|
|
196
|
+
})),
|
|
197
|
+
},
|
|
198
|
+
}
|
|
199
|
+
);
|
|
76
200
|
});
|
|
77
201
|
|
|
78
202
|
set
|
|
@@ -203,9 +203,11 @@ 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
|
+
tip: () =>
|
|
210
|
+
`Assign your new key to a role with "set role assignments", or create a new role with "create role"`,
|
|
209
211
|
failedCreate: (env: string, name: string) =>
|
|
210
212
|
`[${env}] Unable to create API key ${Logger.highlightText(name)}`,
|
|
211
213
|
removed: (env: string, id: string) =>
|
|
@@ -213,6 +215,26 @@ export const LogMessages = {
|
|
|
213
215
|
failedRemove: (env: string, id: string) =>
|
|
214
216
|
`[${env}] Unable to delete API key ${Logger.highlightText(id)}`,
|
|
215
217
|
},
|
|
218
|
+
roles: {
|
|
219
|
+
list: (env: string) => `[${env}] Retrieved roles`,
|
|
220
|
+
noList: (env: string) => `[${env}] Cannot retrieve roles`,
|
|
221
|
+
failedGet: (env: string, name: string) =>
|
|
222
|
+
`[${env}] Unable to find role ${Logger.highlightText(name)}`,
|
|
223
|
+
created: (env: string, name: string) =>
|
|
224
|
+
`[${env}] Created role ${Logger.highlightText(name)}`,
|
|
225
|
+
tip: () =>
|
|
226
|
+
`Give access to your role with "set role assignments", allow your role to do things with "set role permissions"`,
|
|
227
|
+
failedCreate: (env: string, name: string) =>
|
|
228
|
+
`[${env}] Unable to create role ${Logger.highlightText(name)}`,
|
|
229
|
+
setPayload: () => `Updating role with details\n`,
|
|
230
|
+
set: () => `Succesfully updated role\n`,
|
|
231
|
+
failedSet: (env: string, name: string) =>
|
|
232
|
+
`[${env}] Unable to update role ${Logger.highlightText(name)}`,
|
|
233
|
+
removed: (env: string, id: string) =>
|
|
234
|
+
`[${env}] Deleted role ${Logger.highlightText(id)}\n`,
|
|
235
|
+
failedRemove: (env: string, id: string) =>
|
|
236
|
+
`[${env}] Unable to delete role ${Logger.highlightText(id)}`,
|
|
237
|
+
},
|
|
216
238
|
blocks: {
|
|
217
239
|
runningStatus: (status: BlockRunningStatus | 'broken') => {
|
|
218
240
|
switch (status) {
|