contensis-cli 1.0.0-beta.8 → 1.0.0-beta.81
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/src/util/logger.ts
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import dateFormat from 'dateformat';
|
|
4
4
|
import deepCleaner from 'deep-cleaner';
|
|
5
|
-
import ProgressBar from 'progress';
|
|
6
|
-
import { tryStringify } from '.';
|
|
5
|
+
// import ProgressBar from 'progress';
|
|
6
|
+
import { isSysError, tryStringify } from '.';
|
|
7
7
|
|
|
8
8
|
type LogMethod = (content: string) => void;
|
|
9
|
-
type LogErrorMethod = (content: string, err?: any) => void;
|
|
10
|
-
type LogJsonMethod = (content: any) => void;
|
|
9
|
+
type LogErrorMethod = (content: string, err?: any, newline?: string) => void;
|
|
10
|
+
type LogJsonMethod = (content: any, depth?: number, indent?: string) => void;
|
|
11
|
+
type LogJsonDepthMethod = (content: any, depth: number) => void;
|
|
11
12
|
type LogArrayMethod = (contentArray: string[]) => void;
|
|
12
13
|
type LogErrorFunc = (
|
|
13
14
|
err: any,
|
|
@@ -36,12 +37,16 @@ export class Logger {
|
|
|
36
37
|
)} ${content}`;
|
|
37
38
|
console.log(message);
|
|
38
39
|
};
|
|
39
|
-
static error: LogErrorMethod = (content, err) => {
|
|
40
|
+
static error: LogErrorMethod = (content, err, newline = '\n') => {
|
|
40
41
|
const message = `${Logger.getPrefix()} ${Logger.errorText(
|
|
41
42
|
`${Logger.isUserTerminal ? '❌' : '[ERROR]'} ${content}${
|
|
42
|
-
err
|
|
43
|
+
err
|
|
44
|
+
? `\n\n${
|
|
45
|
+
isSysError(err) ? err.toString() : JSON.stringify(err, null, 2)
|
|
46
|
+
}`
|
|
47
|
+
: ''
|
|
43
48
|
}`
|
|
44
|
-
)}
|
|
49
|
+
)}${newline}`;
|
|
45
50
|
if (progress.active) progress.current.interrupt(message);
|
|
46
51
|
else console.log(message);
|
|
47
52
|
};
|
|
@@ -83,7 +88,7 @@ export class Logger {
|
|
|
83
88
|
else console.log(message);
|
|
84
89
|
progress.current.interrupt(message);
|
|
85
90
|
};
|
|
86
|
-
static json:
|
|
91
|
+
static json: LogJsonDepthMethod = (content, depth = 9) =>
|
|
87
92
|
console.dir(deepCleaner(content), { colors: true, depth });
|
|
88
93
|
static mixed: LogArrayMethod = contentArray =>
|
|
89
94
|
console.log(`${Logger.getPrefix()} ${contentArray.join(' ')}`);
|
|
@@ -91,13 +96,44 @@ export class Logger {
|
|
|
91
96
|
Logger.raw(` ${Logger.infoText(`-------------------------------------`)}`);
|
|
92
97
|
|
|
93
98
|
static object: LogJsonMethod = content => {
|
|
94
|
-
for (const [key, value] of Object.entries(content)) {
|
|
99
|
+
for (const [key, value] of Object.entries(content || {})) {
|
|
95
100
|
if (value && typeof value === 'object') {
|
|
96
101
|
Logger.raw(` ${chalk.bold.grey(key)}:`);
|
|
97
102
|
if (key === 'fields' && Array.isArray(value)) {
|
|
98
103
|
for (const field of value || []) {
|
|
99
104
|
Logger.raw(
|
|
100
|
-
` ${chalk.bold(field.id)}
|
|
105
|
+
` ${chalk.bold(field.id)}${
|
|
106
|
+
field.id === content.entryTitleField
|
|
107
|
+
? '**'
|
|
108
|
+
: field.validations.minCount?.value ||
|
|
109
|
+
typeof field.validations.required?.message !== 'undefined'
|
|
110
|
+
? '*'
|
|
111
|
+
: ''
|
|
112
|
+
}: ${chalk.grey(
|
|
113
|
+
`${field.dataType}${
|
|
114
|
+
field.dataFormat
|
|
115
|
+
? `<${
|
|
116
|
+
Array.isArray(
|
|
117
|
+
field.validations.allowedFieldTypes?.fields
|
|
118
|
+
)
|
|
119
|
+
? `composer[${field.validations.allowedFieldTypes.fields
|
|
120
|
+
.map((f: any) => f.id)
|
|
121
|
+
.join(' | ')}]`
|
|
122
|
+
: field.dataFormat
|
|
123
|
+
}${
|
|
124
|
+
field.dataFormat === 'entry'
|
|
125
|
+
? `, ${field.validations.allowedContentTypes.contentTypes.join(
|
|
126
|
+
' | '
|
|
127
|
+
)}`
|
|
128
|
+
: ''
|
|
129
|
+
}>`
|
|
130
|
+
: ''
|
|
131
|
+
}${
|
|
132
|
+
field.validations.maxLength?.value
|
|
133
|
+
? `(${field.validations.maxLength.value})`
|
|
134
|
+
: ''
|
|
135
|
+
}`
|
|
136
|
+
)}`
|
|
101
137
|
);
|
|
102
138
|
}
|
|
103
139
|
} else if (key === 'groups' && Array.isArray(value)) {
|
|
@@ -114,20 +150,63 @@ export class Logger {
|
|
|
114
150
|
);
|
|
115
151
|
}
|
|
116
152
|
} else {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
153
|
+
Logger.objectRecurse(value, 3, ' ');
|
|
154
|
+
// for (const [innerkey, innervalue] of Object.entries(value)) {
|
|
155
|
+
// if (innervalue && typeof innervalue === 'object') {
|
|
156
|
+
// Logger.raw(` ${chalk.bold.grey(innerkey)}:`);
|
|
157
|
+
// console.table(innervalue);
|
|
158
|
+
// } else if (
|
|
159
|
+
// typeof innervalue !== 'undefined' &&
|
|
160
|
+
// innervalue !== null
|
|
161
|
+
// ) {
|
|
162
|
+
// Logger.raw(` ${chalk.bold.grey(innerkey)}: ${innervalue}`);
|
|
163
|
+
// }
|
|
164
|
+
// }
|
|
165
|
+
}
|
|
166
|
+
} else if (typeof value !== 'undefined' && value !== null) {
|
|
167
|
+
const valueText =
|
|
168
|
+
key === 'id' && typeof value === 'string'
|
|
169
|
+
? Logger.highlightText(value)
|
|
170
|
+
: value;
|
|
171
|
+
Logger.raw(` ${chalk.bold.grey(key)}: ${valueText}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
static objectRecurse: LogJsonMethod = (content, depth = 3, indent = '') => {
|
|
177
|
+
if (Array.isArray(content)) {
|
|
178
|
+
for (const item of content) {
|
|
179
|
+
if (item && typeof item === 'object') {
|
|
180
|
+
if (Array.isArray(item) && depth > 3)
|
|
181
|
+
Logger.raw(chalk.grey(`${indent} [${item.join(', ')}]`));
|
|
182
|
+
else Logger.objectRecurse(item, depth + 1, `${indent} `);
|
|
183
|
+
} else Logger.raw(`${indent}${item}`);
|
|
184
|
+
}
|
|
185
|
+
} else {
|
|
186
|
+
let pos = 0;
|
|
187
|
+
for (const [key, value] of Object.entries(content)) {
|
|
188
|
+
const thisIndent =
|
|
189
|
+
pos === 0 ? `${indent.substring(0, indent.length - 2)}- ` : indent;
|
|
190
|
+
if (Array.isArray(value)) {
|
|
191
|
+
if (value.length) Logger.raw(`${thisIndent}${chalk.bold.grey(key)}:`);
|
|
192
|
+
for (const item of value) {
|
|
193
|
+
if (item && typeof item === 'object') {
|
|
194
|
+
if (Array.isArray(item) && depth > 3)
|
|
195
|
+
Logger.raw(chalk.grey(`${indent} [${item.join(', ')}]`));
|
|
196
|
+
else Logger.objectRecurse(item, depth + 1, `${indent} `);
|
|
197
|
+
} else {
|
|
198
|
+
Logger.raw(`${indent} ${item}`);
|
|
126
199
|
}
|
|
127
200
|
}
|
|
201
|
+
} else if (value && typeof value === 'object') {
|
|
202
|
+
Logger.raw(`${indent}${chalk.bold.grey(key)}:`);
|
|
203
|
+
|
|
204
|
+
Logger.objectRecurse(value, depth + 1, `${indent} `);
|
|
205
|
+
// console.table(value);
|
|
206
|
+
} else if (typeof value !== 'undefined' && value !== null) {
|
|
207
|
+
Logger.raw(`${thisIndent}${chalk.bold.grey(key)}: ${value}`);
|
|
128
208
|
}
|
|
129
|
-
|
|
130
|
-
Logger.raw(` ${chalk.bold.grey(key)}: ${value}`);
|
|
209
|
+
pos++;
|
|
131
210
|
}
|
|
132
211
|
}
|
|
133
212
|
};
|
|
@@ -144,22 +223,23 @@ export const logError: LogErrorFunc = (
|
|
|
144
223
|
) => {
|
|
145
224
|
Logger[level](msg || err.message || err?.data?.message || err.Message);
|
|
146
225
|
(Array.isArray(err) ? err : [err]).map((error: AppError) => {
|
|
147
|
-
if ('stack' in error) Logger.raw(` ${Logger.infoText(error.stack)}`);
|
|
226
|
+
if ('stack' in error) Logger.raw(` ${Logger.infoText(error.stack)}\n`);
|
|
148
227
|
if ('data' in error)
|
|
149
|
-
Logger.raw(` ${Logger.infoText(tryStringify(error.data))}`);
|
|
228
|
+
Logger.raw(` ${Logger.infoText(tryStringify(error.data))}\n`);
|
|
150
229
|
});
|
|
151
230
|
//Logger.line();
|
|
152
231
|
return null;
|
|
153
232
|
};
|
|
154
233
|
|
|
155
234
|
export const progress = {
|
|
235
|
+
current: { interrupt: (x: string) => {} },
|
|
156
236
|
active: false,
|
|
157
|
-
done: () => new ProgressBar('', 0),
|
|
158
|
-
colours: { green: '\u001b[42m \u001b[0m', red: '\u001b[41m \u001b[0m' },
|
|
159
|
-
current: new ProgressBar(`:bar`, {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}),
|
|
237
|
+
// done: () => new ProgressBar('', 0),
|
|
238
|
+
// colours: { green: '\u001b[42m \u001b[0m', red: '\u001b[41m \u001b[0m' },
|
|
239
|
+
// current: new ProgressBar(`:bar`, {
|
|
240
|
+
// complete: '=',
|
|
241
|
+
// incomplete: ' ',
|
|
242
|
+
// width: 20,
|
|
243
|
+
// total: 100,
|
|
244
|
+
// }),
|
|
165
245
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const promiseDelay = (delay: number, value: any) => {
|
|
2
|
+
let timeout: NodeJS.Timeout | null;
|
|
3
|
+
let _reject: PromiseRejectionEvent['reason'];
|
|
4
|
+
|
|
5
|
+
const wait = () =>
|
|
6
|
+
new Promise((resolve, reject) => {
|
|
7
|
+
_reject = reject;
|
|
8
|
+
timeout = setTimeout(resolve, delay, value);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const promise = wait();
|
|
12
|
+
return {
|
|
13
|
+
promise,
|
|
14
|
+
cancel() {
|
|
15
|
+
if (timeout) {
|
|
16
|
+
clearTimeout(timeout);
|
|
17
|
+
timeout = null;
|
|
18
|
+
_reject();
|
|
19
|
+
_reject = null;
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
wait,
|
|
23
|
+
};
|
|
24
|
+
};
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = "1.0.0-beta.
|
|
1
|
+
export const LIB_VERSION = "1.0.0-beta.81";
|