contensis-cli 1.0.0-beta.8 → 1.0.0-beta.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1146 -78
- package/dist/commands/connect.js +3 -3
- package/dist/commands/connect.js.map +2 -2
- package/dist/commands/create.js +45 -10
- package/dist/commands/create.js.map +2 -2
- package/dist/commands/diff.js +57 -0
- package/dist/commands/diff.js.map +7 -0
- package/dist/commands/execute.js +103 -0
- package/dist/commands/execute.js.map +7 -0
- package/dist/commands/get.js +107 -18
- package/dist/commands/get.js.map +2 -2
- package/dist/commands/globalOptions.js +22 -17
- package/dist/commands/globalOptions.js.map +2 -2
- package/dist/commands/import.js +46 -11
- package/dist/commands/import.js.map +2 -2
- package/dist/commands/index.js +16 -2
- package/dist/commands/index.js.map +2 -2
- package/dist/commands/list.js +53 -10
- package/dist/commands/list.js.map +2 -2
- package/dist/commands/login.js +3 -3
- package/dist/commands/login.js.map +2 -2
- package/dist/commands/push.js +9 -5
- package/dist/commands/push.js.map +2 -2
- package/dist/commands/remove.js +51 -8
- package/dist/commands/remove.js.map +2 -2
- package/dist/commands/set.js +139 -12
- package/dist/commands/set.js.map +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +2 -2
- package/dist/localisation/en-GB.js +193 -49
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/providers/CredentialProvider.js +36 -7
- package/dist/providers/CredentialProvider.js.map +3 -3
- package/dist/providers/SessionCacheProvider.js +21 -1
- package/dist/providers/SessionCacheProvider.js.map +2 -2
- package/dist/providers/file-provider.js +8 -4
- package/dist/providers/file-provider.js.map +3 -3
- package/dist/services/ContensisCliService.js +1092 -410
- package/dist/services/ContensisCliService.js.map +3 -3
- package/dist/shell.js +48 -14
- package/dist/shell.js.map +3 -3
- package/dist/util/console.printer.js +171 -55
- package/dist/util/console.printer.js.map +2 -2
- package/dist/util/diff.js +39 -0
- package/dist/util/diff.js.map +7 -0
- package/dist/util/index.js +8 -2
- package/dist/util/index.js.map +3 -3
- package/dist/util/logger.js +61 -29
- package/dist/util/logger.js.map +3 -3
- package/dist/util/timers.js +49 -0
- package/dist/util/timers.js.map +7 -0
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/esbuild.config.js +3 -1
- package/package.json +2 -2
- package/src/commands/connect.ts +3 -2
- package/src/commands/create.ts +61 -8
- package/src/commands/diff.ts +41 -0
- package/src/commands/execute.ts +117 -0
- package/src/commands/get.ts +150 -14
- package/src/commands/globalOptions.ts +18 -17
- package/src/commands/import.ts +57 -7
- package/src/commands/index.ts +16 -1
- package/src/commands/list.ts +85 -11
- package/src/commands/login.ts +3 -2
- package/src/commands/push.ts +10 -3
- package/src/commands/remove.ts +66 -4
- package/src/commands/set.ts +189 -9
- package/src/index.ts +1 -4
- package/src/localisation/en-GB.ts +269 -66
- package/src/providers/CredentialProvider.ts +39 -6
- package/src/providers/SessionCacheProvider.ts +29 -2
- package/src/providers/file-provider.ts +12 -4
- package/src/services/ContensisCliService.ts +1384 -484
- package/src/shell.ts +52 -15
- package/src/util/console.printer.ts +240 -78
- package/src/util/diff.ts +17 -0
- package/src/util/index.ts +16 -7
- package/src/util/logger.ts +111 -31
- package/src/util/timers.ts +24 -0
- package/src/version.ts +1 -1
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;
|
|
@@ -53,13 +52,12 @@ class Logger {
|
|
|
53
52
|
)} ${content}`;
|
|
54
53
|
console.log(message);
|
|
55
54
|
};
|
|
56
|
-
static error = (content, err) => {
|
|
55
|
+
static error = (content, err, newline = "\n") => {
|
|
57
56
|
const message = `${Logger.getPrefix()} ${Logger.errorText(
|
|
58
57
|
`${Logger.isUserTerminal ? "\u274C" : "[ERROR]"} ${content}${err ? `
|
|
59
58
|
|
|
60
|
-
${JSON.stringify(err, null, 2)}` : ""}`
|
|
61
|
-
)}
|
|
62
|
-
`;
|
|
59
|
+
${(0, import__.isSysError)(err) ? err.toString() : JSON.stringify(err, null, 2)}` : ""}`
|
|
60
|
+
)}${newline}`;
|
|
63
61
|
if (progress.active)
|
|
64
62
|
progress.current.interrupt(message);
|
|
65
63
|
else
|
|
@@ -114,35 +112,73 @@ ${Logger.standardText(content)}`;
|
|
|
114
112
|
static mixed = (contentArray) => console.log(`${Logger.getPrefix()} ${contentArray.join(" ")}`);
|
|
115
113
|
static line = () => Logger.raw(` ${Logger.infoText(`-------------------------------------`)}`);
|
|
116
114
|
static object = (content) => {
|
|
117
|
-
var _a, _b;
|
|
118
|
-
for (const [key, value] of Object.entries(content)) {
|
|
115
|
+
var _a, _b, _c, _d, _e, _f;
|
|
116
|
+
for (const [key, value] of Object.entries(content || {})) {
|
|
119
117
|
if (value && typeof value === "object") {
|
|
120
118
|
Logger.raw(` ${import_chalk.default.bold.grey(key)}:`);
|
|
121
119
|
if (key === "fields" && Array.isArray(value)) {
|
|
122
120
|
for (const field of value || []) {
|
|
123
121
|
Logger.raw(
|
|
124
|
-
` ${import_chalk.default.bold(field.id)}: ${import_chalk.default.grey(
|
|
122
|
+
` ${import_chalk.default.bold(field.id)}${field.id === content.entryTitleField ? "**" : ((_a = field.validations.minCount) == null ? void 0 : _a.value) || typeof ((_b = field.validations.required) == null ? void 0 : _b.message) !== "undefined" ? "*" : ""}: ${import_chalk.default.grey(
|
|
123
|
+
`${field.dataType}${field.dataFormat ? `<${Array.isArray(
|
|
124
|
+
(_c = field.validations.allowedFieldTypes) == null ? void 0 : _c.fields
|
|
125
|
+
) ? `composer[${field.validations.allowedFieldTypes.fields.map((f) => f.id).join(" | ")}]` : field.dataFormat}${field.dataFormat === "entry" ? `, ${field.validations.allowedContentTypes.contentTypes.join(
|
|
126
|
+
" | "
|
|
127
|
+
)}` : ""}>` : ""}${((_d = field.validations.maxLength) == null ? void 0 : _d.value) ? `(${field.validations.maxLength.value})` : ""}`
|
|
128
|
+
)}`
|
|
125
129
|
);
|
|
126
130
|
}
|
|
127
131
|
} else if (key === "groups" && Array.isArray(value)) {
|
|
128
132
|
for (const group of value || []) {
|
|
129
|
-
const description = Object.keys(group.description).length && ((
|
|
133
|
+
const description = Object.keys(group.description).length && ((_e = Object.values(group.description)) == null ? void 0 : _e[0]);
|
|
130
134
|
Logger.raw(
|
|
131
|
-
` ${import_chalk.default.bold(group.id)}${description ? `: ${import_chalk.default.grey((
|
|
135
|
+
` ${import_chalk.default.bold(group.id)}${description ? `: ${import_chalk.default.grey((_f = Object.values(group.description)) == null ? void 0 : _f[0])}` : ""}`
|
|
132
136
|
);
|
|
133
137
|
}
|
|
134
138
|
} else {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
Logger.objectRecurse(value, 3, " ");
|
|
140
|
+
}
|
|
141
|
+
} else if (typeof value !== "undefined" && value !== null) {
|
|
142
|
+
const valueText = key === "id" && typeof value === "string" ? Logger.highlightText(value) : value;
|
|
143
|
+
Logger.raw(` ${import_chalk.default.bold.grey(key)}: ${valueText}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
static objectRecurse = (content, depth = 3, indent = "") => {
|
|
148
|
+
if (Array.isArray(content)) {
|
|
149
|
+
for (const item of content) {
|
|
150
|
+
if (item && typeof item === "object") {
|
|
151
|
+
if (Array.isArray(item) && depth > 3)
|
|
152
|
+
Logger.raw(import_chalk.default.grey(`${indent} [${item.join(", ")}]`));
|
|
153
|
+
else
|
|
154
|
+
Logger.objectRecurse(item, depth + 1, `${indent} `);
|
|
155
|
+
} else
|
|
156
|
+
Logger.raw(`${indent}${item}`);
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
let pos = 0;
|
|
160
|
+
for (const [key, value] of Object.entries(content)) {
|
|
161
|
+
const thisIndent = pos === 0 ? `${indent.substring(0, indent.length - 2)}- ` : indent;
|
|
162
|
+
if (Array.isArray(value)) {
|
|
163
|
+
if (value.length)
|
|
164
|
+
Logger.raw(`${thisIndent}${import_chalk.default.bold.grey(key)}:`);
|
|
165
|
+
for (const item of value) {
|
|
166
|
+
if (item && typeof item === "object") {
|
|
167
|
+
if (Array.isArray(item) && depth > 3)
|
|
168
|
+
Logger.raw(import_chalk.default.grey(`${indent} [${item.join(", ")}]`));
|
|
169
|
+
else
|
|
170
|
+
Logger.objectRecurse(item, depth + 1, `${indent} `);
|
|
171
|
+
} else {
|
|
172
|
+
Logger.raw(`${indent} ${item}`);
|
|
141
173
|
}
|
|
142
174
|
}
|
|
175
|
+
} else if (value && typeof value === "object") {
|
|
176
|
+
Logger.raw(`${indent}${import_chalk.default.bold.grey(key)}:`);
|
|
177
|
+
Logger.objectRecurse(value, depth + 1, `${indent} `);
|
|
178
|
+
} else if (typeof value !== "undefined" && value !== null) {
|
|
179
|
+
Logger.raw(`${thisIndent}${import_chalk.default.bold.grey(key)}: ${value}`);
|
|
143
180
|
}
|
|
144
|
-
|
|
145
|
-
Logger.raw(` ${import_chalk.default.bold.grey(key)}: ${value}`);
|
|
181
|
+
pos++;
|
|
146
182
|
}
|
|
147
183
|
}
|
|
148
184
|
};
|
|
@@ -158,22 +194,18 @@ const logError = (err = new Error("Undefined error"), msg, level = "error") => {
|
|
|
158
194
|
Logger[level](msg || err.message || ((_a = err == null ? void 0 : err.data) == null ? void 0 : _a.message) || err.Message);
|
|
159
195
|
(Array.isArray(err) ? err : [err]).map((error) => {
|
|
160
196
|
if ("stack" in error)
|
|
161
|
-
Logger.raw(` ${Logger.infoText(error.stack)}
|
|
197
|
+
Logger.raw(` ${Logger.infoText(error.stack)}
|
|
198
|
+
`);
|
|
162
199
|
if ("data" in error)
|
|
163
|
-
Logger.raw(` ${Logger.infoText((0, import__.tryStringify)(error.data))}
|
|
200
|
+
Logger.raw(` ${Logger.infoText((0, import__.tryStringify)(error.data))}
|
|
201
|
+
`);
|
|
164
202
|
});
|
|
165
203
|
return null;
|
|
166
204
|
};
|
|
167
205
|
const progress = {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
current: new import_progress.default(`:bar`, {
|
|
172
|
-
complete: "=",
|
|
173
|
-
incomplete: " ",
|
|
174
|
-
width: 20,
|
|
175
|
-
total: 100
|
|
176
|
-
})
|
|
206
|
+
current: { interrupt: (x) => {
|
|
207
|
+
} },
|
|
208
|
+
active: false
|
|
177
209
|
};
|
|
178
210
|
// Annotate the CommonJS export names for ESM import in node:
|
|
179
211
|
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`);\n if ('data' in error)\n Logger.raw(` ${Logger.infoText(tryStringify(error.data))}\\n`);\n });\n //Logger.line();\n return null;\n};\n\nexport const progress = {\n current: { interrupt: (x: string) => {} },\n active: false,\n // done: () => new ProgressBar('', 0),\n // colours: { green: '\\u001b[42m \\u001b[0m', red: '\\u001b[41m \\u001b[0m' },\n // current: new ProgressBar(`:bar`, {\n // complete: '=',\n // incomplete: ' ',\n // width: 20,\n // total: 100,\n // }),\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,wBAAuB;AACvB,0BAAwB;AAExB,eAAyC;AAalC,MAAM,OAAO;AAAA,EAClB,OAAO,iBAAiB,CAAC,CAAC,QAAQ,OAAO;AAAA,EACzC,OAAO,YAAY,MAAM;AACvB,WAAO,OAAO,iBACV,OAAO,SAAS,OAAO,IACvB,QAAI,kBAAAA,SAAW,IAAI,KAAK,GAAG,gBAAgB;AAAA,EACjD;AAAA,EACA,OAAO,YAAY,aAAAC,QAAM,KAAK;AAAA,EAC9B,OAAO,cAAc,aAAAA,QAAM,QAAQ,QAAQ;AAAA,EAC3C,OAAO,cAAc,aAAAA,QAAM,QAAQ,OAAO;AAAA,EAC1C,OAAO,WAAW,aAAAA,QAAM;AAAA,EACxB,OAAO,gBAAgB,aAAAA,QAAM;AAAA,EAC7B,OAAO,WAAW,aAAAA,QAAM,QAAQ,MAAM;AAAA,EACtC,OAAO,eAAe,aAAAA,QAAM,QAAQ,OAAO;AAAA,EAC3C,OAAO,WAAW,aAAAA,QAAM;AAAA,EACxB,OAAO,WAAsB,aAAW;AACtC,UAAM,UAAU,GAAG,OAAO,UAAU,MAAM,OAAO;AAAA,MAC/C;AAAA,IACF,KAAK;A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,cAAQ,IAAI,OAAO;AAAA,EAC1B;AACF;AAEO,MAAM,WAAyB,CACpC,MAAM,IAAI,MAAM,iBAAiB,GACjC,KACA,QAAQ,YACL;AA9NL;AA+NE,SAAO,OAAO,OAAO,IAAI,aAAW,gCAAK,SAAL,mBAAW,YAAW,IAAI,OAAO;AACrE,GAAC,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,UAAoB;AAC1D,QAAI,WAAW;AAAO,aAAO,IAAI,KAAK,OAAO,SAAS,MAAM,KAAK;AAAA,CAAK;AACtE,QAAI,UAAU;AACZ,aAAO,IAAI,KAAK,OAAO,aAAS,uBAAa,MAAM,IAAI,CAAC;AAAA,CAAK;AAAA,EACjE,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
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var timers_exports = {};
|
|
20
|
+
__export(timers_exports, {
|
|
21
|
+
promiseDelay: () => promiseDelay
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(timers_exports);
|
|
24
|
+
const promiseDelay = (delay, value) => {
|
|
25
|
+
let timeout;
|
|
26
|
+
let _reject;
|
|
27
|
+
const wait = () => new Promise((resolve, reject) => {
|
|
28
|
+
_reject = reject;
|
|
29
|
+
timeout = setTimeout(resolve, delay, value);
|
|
30
|
+
});
|
|
31
|
+
const promise = wait();
|
|
32
|
+
return {
|
|
33
|
+
promise,
|
|
34
|
+
cancel() {
|
|
35
|
+
if (timeout) {
|
|
36
|
+
clearTimeout(timeout);
|
|
37
|
+
timeout = null;
|
|
38
|
+
_reject();
|
|
39
|
+
_reject = null;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
wait
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
promiseDelay
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=timers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/util/timers.ts"],
|
|
4
|
+
"sourcesContent": ["export const promiseDelay = (delay: number, value: any) => {\n let timeout: NodeJS.Timeout | null;\n let _reject: PromiseRejectionEvent['reason'];\n\n const wait = () =>\n new Promise((resolve, reject) => {\n _reject = reject;\n timeout = setTimeout(resolve, delay, value);\n });\n\n const promise = wait();\n return {\n promise,\n cancel() {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n _reject();\n _reject = null;\n }\n },\n wait,\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,eAAe,CAAC,OAAe,UAAe;AACzD,MAAI;AACJ,MAAI;AAEJ,QAAM,OAAO,MACX,IAAI,QAAQ,CAAC,SAAS,WAAW;AAC/B,cAAU;AACV,cAAU,WAAW,SAAS,OAAO,KAAK;AAAA,EAC5C,CAAC;AAEH,QAAM,UAAU,KAAK;AACrB,SAAO;AAAA,IACL;AAAA,IACA,SAAS;AACP,UAAI,SAAS;AACX,qBAAa,OAAO;AACpB,kBAAU;AACV,gBAAQ;AACR,kBAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
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.80";
|
|
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.80\";\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/esbuild.config.js
CHANGED
|
@@ -23,7 +23,9 @@ rimraf('./dist', () => {
|
|
|
23
23
|
platform: 'node',
|
|
24
24
|
format: 'cjs',
|
|
25
25
|
sourcemap: true,
|
|
26
|
-
|
|
26
|
+
// needs to be node12 to transform dynamic imports into requires
|
|
27
|
+
// so the bundles are compatible with the pkg exe builds
|
|
28
|
+
target: 'node12',
|
|
27
29
|
plugins: [globPlugin(), nodeExternalsPlugin()],
|
|
28
30
|
watch: watch && {
|
|
29
31
|
onRebuild(error) {
|
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.80",
|
|
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.30",
|
|
39
39
|
"node-fetch": "^2.6.7",
|
|
40
40
|
"patch-package": "^6.4.7",
|
|
41
41
|
"xml2js": "^0.4.23"
|
package/src/commands/connect.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { project } from './globalOptions';
|
|
|
6
6
|
export const makeConnectCommand = () => {
|
|
7
7
|
const connect = new Command()
|
|
8
8
|
.command('connect')
|
|
9
|
+
.description('connect to a Contensis instance')
|
|
9
10
|
.argument('<alias>', 'the Contensis Cloud alias to connect with')
|
|
10
11
|
.addOption(project)
|
|
11
12
|
.usage('<alias>')
|
|
@@ -16,8 +17,8 @@ Example call:
|
|
|
16
17
|
> connect example-dev`
|
|
17
18
|
)
|
|
18
19
|
.action(async (alias, opts) => {
|
|
19
|
-
await cliCommand(['connect', alias], opts).Connect(alias);
|
|
20
|
-
await shell().
|
|
20
|
+
await cliCommand(['connect', alias], { ...opts, alias }).Connect(alias);
|
|
21
|
+
await shell().restart();
|
|
21
22
|
});
|
|
22
23
|
return connect;
|
|
23
24
|
};
|
package/src/commands/create.ts
CHANGED
|
@@ -1,26 +1,57 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import { Project } from 'contensis-core-api';
|
|
2
3
|
import { cliCommand } from '~/services/ContensisCliService';
|
|
3
4
|
import { shell } from '~/shell';
|
|
5
|
+
import { isUuid } from '~/util';
|
|
4
6
|
|
|
5
7
|
export const makeCreateCommand = () => {
|
|
6
8
|
const create = new Command()
|
|
7
9
|
.command('create')
|
|
10
|
+
.description('create command')
|
|
11
|
+
.addHelpText('after', `\n`)
|
|
8
12
|
.showHelpAfterError(true)
|
|
9
13
|
.exitOverride();
|
|
10
14
|
|
|
11
15
|
create
|
|
12
16
|
.command('project')
|
|
17
|
+
.description('create a new project')
|
|
13
18
|
.argument('<projectId>', 'the id of the project to create')
|
|
14
|
-
.
|
|
15
|
-
.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
.argument('<name>', 'the name of the project to create')
|
|
20
|
+
.argument('[description]', 'optional description of the project')
|
|
21
|
+
.option(
|
|
22
|
+
'-l, --language',
|
|
23
|
+
'the default language of the project to create',
|
|
24
|
+
'en-GB'
|
|
25
|
+
)
|
|
26
|
+
.option(
|
|
27
|
+
'-langs, --supported-languages <langs...>',
|
|
28
|
+
'space separated list of other supported languages'
|
|
29
|
+
)
|
|
30
|
+
.usage(
|
|
31
|
+
'projectId "Project name" ["Description of project"] --language en-GB --supported-languages es-ES de-DE nl-NL'
|
|
32
|
+
)
|
|
33
|
+
.addHelpText('after', `\n`)
|
|
34
|
+
.action(
|
|
35
|
+
async (projectId: string, name: string, description = '', opts: any) => {
|
|
36
|
+
const createProject: Project = {
|
|
37
|
+
id: projectId,
|
|
38
|
+
name,
|
|
39
|
+
description,
|
|
40
|
+
primaryLanguage: opts.language,
|
|
41
|
+
supportedLanguages: opts.supportedLanguages || [],
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const project = await cliCommand(
|
|
45
|
+
['create', 'project', projectId],
|
|
46
|
+
opts
|
|
47
|
+
).CreateProject(createProject);
|
|
48
|
+
if (project) await shell().restart();
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
|
|
22
52
|
create
|
|
23
53
|
.command('key')
|
|
54
|
+
.description('create a new api key')
|
|
24
55
|
.argument('<"key name">', 'the name of the key to create')
|
|
25
56
|
.argument('["description"]', 'provide a description for the key (optional)')
|
|
26
57
|
.usage('<"key name"> ["description"] (both args in "double quotes")')
|
|
@@ -37,5 +68,27 @@ Example call:
|
|
|
37
68
|
);
|
|
38
69
|
});
|
|
39
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
|
+
|
|
40
93
|
return create;
|
|
41
94
|
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { cliCommand } from '~/services/ContensisCliService';
|
|
3
|
+
import { mapContensisOpts } from './globalOptions';
|
|
4
|
+
|
|
5
|
+
export const makeDiffCommand = () => {
|
|
6
|
+
const release = new Command()
|
|
7
|
+
.command('diff')
|
|
8
|
+
.description('diff command')
|
|
9
|
+
.addHelpText('after', `\n`)
|
|
10
|
+
.showHelpAfterError(true)
|
|
11
|
+
.exitOverride();
|
|
12
|
+
|
|
13
|
+
release
|
|
14
|
+
.command('models')
|
|
15
|
+
.description('differences with content models')
|
|
16
|
+
.argument(
|
|
17
|
+
'[model-ids...]',
|
|
18
|
+
'ids of any content types or components to diff (optional)'
|
|
19
|
+
)
|
|
20
|
+
.usage('[model-ids...]')
|
|
21
|
+
.addHelpText(
|
|
22
|
+
'after',
|
|
23
|
+
`
|
|
24
|
+
Example call:
|
|
25
|
+
> diff models blogPost\n`
|
|
26
|
+
)
|
|
27
|
+
.action(async (modelIds: string[] = [], opts) => {
|
|
28
|
+
await cliCommand(
|
|
29
|
+
['diff', 'models', modelIds.join(' ')],
|
|
30
|
+
opts,
|
|
31
|
+
mapContensisOpts({ modelIds, ...opts })
|
|
32
|
+
).DiffModels(
|
|
33
|
+
{
|
|
34
|
+
...opts,
|
|
35
|
+
},
|
|
36
|
+
modelIds
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return release;
|
|
41
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Argument, Command } from 'commander';
|
|
2
|
+
import { cliCommand } from '~/services/ContensisCliService';
|
|
3
|
+
import { addGlobalOptions } from './globalOptions';
|
|
4
|
+
|
|
5
|
+
export const makeExecuteCommand = () => {
|
|
6
|
+
const execute = new Command()
|
|
7
|
+
.command('execute')
|
|
8
|
+
.description('execute block actions')
|
|
9
|
+
.addHelpText('after', `\n`)
|
|
10
|
+
.showHelpAfterError(true)
|
|
11
|
+
.exitOverride();
|
|
12
|
+
|
|
13
|
+
const block = execute
|
|
14
|
+
.command('block')
|
|
15
|
+
.description('execute block command to invoke block actions');
|
|
16
|
+
|
|
17
|
+
const action = block
|
|
18
|
+
.command('action')
|
|
19
|
+
.description('execute block action command to invoke block actions');
|
|
20
|
+
|
|
21
|
+
const blockIdArg = new Argument(
|
|
22
|
+
'<block-id>',
|
|
23
|
+
'the name of the block to perform action with'
|
|
24
|
+
);
|
|
25
|
+
const blockVersionArg = new Argument(
|
|
26
|
+
'<version>',
|
|
27
|
+
'the block version to perform action with'
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
action
|
|
31
|
+
.command('release')
|
|
32
|
+
.description('release a block version')
|
|
33
|
+
.addArgument(blockIdArg)
|
|
34
|
+
.argument('[version]', blockVersionArg.description, 'latest')
|
|
35
|
+
.usage('[block-id> <version]')
|
|
36
|
+
.addHelpText(
|
|
37
|
+
'after',
|
|
38
|
+
`
|
|
39
|
+
Example call:
|
|
40
|
+
> execute block action release contensis-app
|
|
41
|
+
|
|
42
|
+
Note: block actions are executed on blocks deployed from a "main" or "master" branch\n`
|
|
43
|
+
)
|
|
44
|
+
.action(async (blockId: string, version: string, opts) => {
|
|
45
|
+
await cliCommand(
|
|
46
|
+
['execute', 'block', 'action', 'release', blockId],
|
|
47
|
+
opts
|
|
48
|
+
).ExecuteBlockAction('release', blockId, version);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
action
|
|
52
|
+
.command('makelive')
|
|
53
|
+
.description('make a block version live')
|
|
54
|
+
.addArgument(blockIdArg)
|
|
55
|
+
.addArgument(blockVersionArg)
|
|
56
|
+
.usage('<block-id> <version>')
|
|
57
|
+
.addHelpText(
|
|
58
|
+
'after',
|
|
59
|
+
`
|
|
60
|
+
Example call:
|
|
61
|
+
> execute block action makelive contensis-app 3
|
|
62
|
+
|
|
63
|
+
Note: block actions are executed on blocks deployed from a "main" or "master" branch\n`
|
|
64
|
+
)
|
|
65
|
+
.action(async (blockId: string, version: string, opts) => {
|
|
66
|
+
await cliCommand(
|
|
67
|
+
['execute', 'block', 'action', 'makelive', blockId],
|
|
68
|
+
opts
|
|
69
|
+
).ExecuteBlockAction('makeLive', blockId, version);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
action
|
|
73
|
+
.command('rollback')
|
|
74
|
+
.description('rollback a live block version to last live version')
|
|
75
|
+
.addArgument(blockIdArg)
|
|
76
|
+
.addArgument(blockVersionArg)
|
|
77
|
+
.usage('<block-id> <version>')
|
|
78
|
+
.addHelpText(
|
|
79
|
+
'after',
|
|
80
|
+
`
|
|
81
|
+
Example call:
|
|
82
|
+
> execute block action rollback contensis-app 3
|
|
83
|
+
|
|
84
|
+
Note: block actions are executed on blocks deployed from a "main" or "master" branch\n`
|
|
85
|
+
)
|
|
86
|
+
.action(async (blockId: string, version: string, opts) => {
|
|
87
|
+
await cliCommand(
|
|
88
|
+
['execute', 'block', 'action', 'rollback', blockId],
|
|
89
|
+
opts
|
|
90
|
+
).ExecuteBlockAction('rollback', blockId, version);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
action
|
|
94
|
+
.command('markasbroken')
|
|
95
|
+
.description('mark a block version as broken')
|
|
96
|
+
.addArgument(blockIdArg)
|
|
97
|
+
.addArgument(blockVersionArg)
|
|
98
|
+
.usage('<block-id> <version>')
|
|
99
|
+
.addHelpText(
|
|
100
|
+
'after',
|
|
101
|
+
`
|
|
102
|
+
Example call:
|
|
103
|
+
> execute block action markasbroken contensis-app 3
|
|
104
|
+
|
|
105
|
+
Note: block actions are executed on blocks deployed from a "main" or "master" branch\n`
|
|
106
|
+
)
|
|
107
|
+
.action(async (blockId: string, version: string, opts) => {
|
|
108
|
+
await cliCommand(
|
|
109
|
+
['execute', 'block', 'action', 'markasbroken', blockId],
|
|
110
|
+
opts
|
|
111
|
+
).ExecuteBlockAction('markAsBroken', blockId, version);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// Add global opts for inner sub-commands
|
|
115
|
+
addGlobalOptions(action);
|
|
116
|
+
return execute;
|
|
117
|
+
};
|