contensis-cli 1.0.0-beta.63 → 1.0.0-beta.65
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 +12 -0
- package/dist/commands/get.js.map +2 -2
- package/dist/commands/list.js +1 -2
- 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 +41 -13
- package/dist/commands/set.js.map +2 -2
- package/dist/localisation/en-GB.js +14 -3
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/services/ContensisCliService.js +138 -33
- package/dist/services/ContensisCliService.js.map +3 -3
- package/dist/shell.js +7 -3
- 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 +13 -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 +18 -0
- package/src/commands/list.ts +1 -2
- package/src/commands/remove.ts +16 -0
- package/src/commands/set.ts +55 -13
- package/src/localisation/en-GB.ts +13 -3
- package/src/services/ContensisCliService.ts +170 -47
- package/src/shell.ts +7 -3
- package/src/util/index.ts +3 -0
- package/src/util/logger.ts +25 -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);
|
|
@@ -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
|
+
const thisIndent = pos === 0 ? `${indent.substring(0, indent.length - 2)}- ` : indent;
|
|
161
162
|
if (Array.isArray(value)) {
|
|
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
|
}
|
|
@@ -173,9 +176,11 @@ ${Logger.standardText(content)}`;
|
|
|
173
176
|
Logger.raw(`${indent}${import_chalk.default.bold.grey(key)}:`);
|
|
174
177
|
Logger.objectRecurse(value, depth + 1, `${indent} `);
|
|
175
178
|
} else if (typeof value !== "undefined" && value !== null) {
|
|
176
|
-
Logger.raw(`${
|
|
179
|
+
Logger.raw(`${thisIndent}${import_chalk.default.bold.grey(key)}: ${value}`);
|
|
177
180
|
}
|
|
181
|
+
pos++;
|
|
178
182
|
}
|
|
183
|
+
}
|
|
179
184
|
};
|
|
180
185
|
static raw = (content) => {
|
|
181
186
|
if (progress.active)
|
|
@@ -196,15 +201,9 @@ const logError = (err = new Error("Undefined error"), msg, level = "error") => {
|
|
|
196
201
|
return null;
|
|
197
202
|
};
|
|
198
203
|
const progress = {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
current: new import_progress.default(`:bar`, {
|
|
203
|
-
complete: "=",
|
|
204
|
-
incomplete: " ",
|
|
205
|
-
width: 20,
|
|
206
|
-
total: 100
|
|
207
|
-
})
|
|
204
|
+
current: { interrupt: (x) => {
|
|
205
|
+
} },
|
|
206
|
+
active: false
|
|
208
207
|
};
|
|
209
208
|
// Annotate the CommonJS export names for ESM import in node:
|
|
210
209
|
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 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\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": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,wBAAuB;AACvB,0BAAwB;AAExB,eAAyC;AAalC,MAAM,OAAO;AAAA,EAClB,OAAO,iBAAiB,CAAC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at", "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.65";
|
|
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.65\";\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.65",
|
|
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
|
@@ -57,6 +57,24 @@ Example call:
|
|
|
57
57
|
);
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
+
program
|
|
61
|
+
.command('webhook')
|
|
62
|
+
.description('get a webhook')
|
|
63
|
+
.argument('<webhookNameOrId...>', 'id or name of the webhook(s) to get')
|
|
64
|
+
.addHelpText(
|
|
65
|
+
'after',
|
|
66
|
+
`
|
|
67
|
+
Example call:
|
|
68
|
+
> get webhook "Slack notification"
|
|
69
|
+
`
|
|
70
|
+
)
|
|
71
|
+
.action(async (webhookNameOrId: string[], opts) => {
|
|
72
|
+
await cliCommand(
|
|
73
|
+
['get', 'webhook', webhookNameOrId.join(' ')],
|
|
74
|
+
opts
|
|
75
|
+
).PrintWebhookSubscriptions(webhookNameOrId);
|
|
76
|
+
});
|
|
77
|
+
|
|
60
78
|
program
|
|
61
79
|
.command('model')
|
|
62
80
|
.description('get a content model')
|
package/src/commands/list.ts
CHANGED
|
@@ -129,8 +129,7 @@ Example call:
|
|
|
129
129
|
.addHelpText('after', `\n`)
|
|
130
130
|
.action(async (name?: string, { id, ...opts }: any = {}) => {
|
|
131
131
|
await cliCommand(['list', 'webhooks'], opts).PrintWebhookSubscriptions(
|
|
132
|
-
id
|
|
133
|
-
name
|
|
132
|
+
name ? [name] : id
|
|
134
133
|
);
|
|
135
134
|
});
|
|
136
135
|
return list;
|
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
|
@@ -68,6 +68,7 @@ Example call:
|
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
const role = set.command('role').description('update a role');
|
|
71
|
+
|
|
71
72
|
role
|
|
72
73
|
.command('name')
|
|
73
74
|
.description('update role name')
|
|
@@ -86,9 +87,52 @@ Example call:
|
|
|
86
87
|
});
|
|
87
88
|
});
|
|
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
|
+
|
|
89
133
|
role
|
|
90
134
|
.command('assignments')
|
|
91
|
-
.description('
|
|
135
|
+
.description('assign users, groups or keys to a role')
|
|
92
136
|
.argument('<"Role name" or id>', 'the role name or id to update')
|
|
93
137
|
.option(
|
|
94
138
|
'-users --assign-users [assign-users...]',
|
|
@@ -120,21 +164,19 @@ Example call:
|
|
|
120
164
|
|
|
121
165
|
role
|
|
122
166
|
.command('permissions')
|
|
123
|
-
.description('
|
|
167
|
+
.description('add entry permissions to a role')
|
|
124
168
|
.argument('<"Role name" or id>', 'the role name or id to update')
|
|
125
169
|
.option(
|
|
126
|
-
'-
|
|
127
|
-
'
|
|
170
|
+
'-contenttypes, --content-type-ids [content-type-id...]',
|
|
171
|
+
'any content type ids to add permissions for'
|
|
128
172
|
)
|
|
129
173
|
.option(
|
|
130
|
-
'
|
|
131
|
-
'the entry actions to add to the role permissions'
|
|
132
|
-
'*'
|
|
174
|
+
'--entry-actions [entry-actions...]',
|
|
175
|
+
'the entry actions to add to the role permissions'
|
|
133
176
|
)
|
|
134
177
|
.option(
|
|
135
|
-
'
|
|
136
|
-
'the entry languages to add to the role permissions'
|
|
137
|
-
'*'
|
|
178
|
+
'--entry-languages [entry-languages...]',
|
|
179
|
+
'the entry languages to add to the role permissions'
|
|
138
180
|
)
|
|
139
181
|
.addHelpText(
|
|
140
182
|
'after',
|
|
@@ -147,10 +189,10 @@ Example call:
|
|
|
147
189
|
roleNameOrId,
|
|
148
190
|
{
|
|
149
191
|
permissions: {
|
|
150
|
-
entries: opts.
|
|
192
|
+
entries: opts.contentTypeIds?.map((id: string) => ({
|
|
151
193
|
id,
|
|
152
|
-
actions: opts.entryActions,
|
|
153
|
-
languages: opts.entryLanguages,
|
|
194
|
+
actions: opts.entryActions || [],
|
|
195
|
+
languages: opts.entryLanguages || [],
|
|
154
196
|
})),
|
|
155
197
|
},
|
|
156
198
|
}
|
|
@@ -206,6 +206,8 @@ export const LogMessages = {
|
|
|
206
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) =>
|
|
@@ -214,16 +216,23 @@ export const LogMessages = {
|
|
|
214
216
|
`[${env}] Unable to delete API key ${Logger.highlightText(id)}`,
|
|
215
217
|
},
|
|
216
218
|
roles: {
|
|
217
|
-
list: (env: string) => `[${env}] Retrieved roles
|
|
219
|
+
list: (env: string) => `[${env}] Retrieved roles`,
|
|
218
220
|
noList: (env: string) => `[${env}] Cannot retrieve roles`,
|
|
221
|
+
noneExist: () => `Create a role with "create role"`,
|
|
219
222
|
failedGet: (env: string, name: string) =>
|
|
220
223
|
`[${env}] Unable to find role ${Logger.highlightText(name)}`,
|
|
221
224
|
created: (env: string, name: string) =>
|
|
222
|
-
`[${env}] Created role ${Logger.highlightText(name)}`,
|
|
225
|
+
`[${env}] Created role ${Logger.highlightText(name)}\n`,
|
|
226
|
+
tip: () =>
|
|
227
|
+
`Give access to your role with "set role assignments", allow your role to do things with "set role permissions"`,
|
|
223
228
|
failedCreate: (env: string, name: string) =>
|
|
224
229
|
`[${env}] Unable to create role ${Logger.highlightText(name)}`,
|
|
230
|
+
setPayload: () => `Updating role with details\n`,
|
|
231
|
+
set: () => `Succesfully updated role\n`,
|
|
232
|
+
failedSet: (env: string, name: string) =>
|
|
233
|
+
`[${env}] Unable to update role ${Logger.highlightText(name)}`,
|
|
225
234
|
removed: (env: string, id: string) =>
|
|
226
|
-
`[${env}] Deleted role ${Logger.highlightText(id)}`,
|
|
235
|
+
`[${env}] Deleted role ${Logger.highlightText(id)}\n`,
|
|
227
236
|
failedRemove: (env: string, id: string) =>
|
|
228
237
|
`[${env}] Unable to delete role ${Logger.highlightText(id)}`,
|
|
229
238
|
},
|
|
@@ -290,6 +299,7 @@ export const LogMessages = {
|
|
|
290
299
|
webhooks: {
|
|
291
300
|
list: (env: string) => `[${env}] Webhook subscriptions:`,
|
|
292
301
|
noList: (env: string) => `[${env}] Cannot retrieve webhook subscriptions`,
|
|
302
|
+
noneExist: () => `No webhook subscriptions exist`,
|
|
293
303
|
created: (env: string, name: string) =>
|
|
294
304
|
`[${env}] Created Webhook subscription ${Logger.highlightText(name)}`,
|
|
295
305
|
failedCreate: (env: string, name: string) =>
|