contensis-cli 1.0.0-beta.9 → 1.0.0-beta.91
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/cli.js +3 -0
- 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/dev.js +75 -0
- package/dist/commands/dev.js.map +7 -0
- 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 +169 -32
- package/dist/commands/get.js.map +3 -3
- package/dist/commands/globalOptions.js +37 -12
- package/dist/commands/globalOptions.js.map +2 -2
- package/dist/commands/import.js +47 -12
- package/dist/commands/import.js.map +2 -2
- package/dist/commands/index.js +22 -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 +2 -2
- package/dist/commands/login.js.map +2 -2
- package/dist/commands/push.js +17 -13
- 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 +259 -49
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.js +56 -0
- package/dist/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.js.map +7 -0
- package/dist/mappers/DevInit-to-CIWorkflow.js +127 -0
- package/dist/mappers/DevInit-to-CIWorkflow.js.map +7 -0
- package/dist/mappers/DevInit-to-RolePermissions.js +54 -0
- package/dist/mappers/DevInit-to-RolePermissions.js.map +7 -0
- package/dist/mappers/DevRequests-to-RequestHanderSiteConfigYaml.js +56 -0
- package/dist/mappers/DevRequests-to-RequestHanderSiteConfigYaml.js.map +7 -0
- package/dist/models/CliService.d.js +17 -0
- package/dist/models/CliService.d.js.map +7 -0
- package/dist/models/DevService.d.js +17 -0
- package/dist/models/DevService.d.js.map +7 -0
- package/dist/providers/CredentialProvider.js +46 -14
- 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 +12 -6
- package/dist/providers/file-provider.js.map +3 -3
- package/dist/services/ContensisCliService.js +1148 -421
- package/dist/services/ContensisCliService.js.map +3 -3
- package/dist/services/ContensisDevService.js +309 -0
- package/dist/services/ContensisDevService.js.map +7 -0
- package/dist/services/ContensisRoleService.js +87 -0
- package/dist/services/ContensisRoleService.js.map +7 -0
- package/dist/shell.js +58 -18
- 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 +102 -0
- package/dist/util/diff.js.map +7 -0
- package/dist/util/dotenv.js +57 -0
- package/dist/util/dotenv.js.map +7 -0
- package/dist/util/find.js +31 -0
- package/dist/util/find.js.map +7 -0
- package/dist/util/git.js +126 -0
- package/dist/util/git.js.map +7 -0
- package/dist/util/index.js +8 -2
- package/dist/util/index.js.map +3 -3
- package/dist/util/logger.js +90 -29
- package/dist/util/logger.js.map +3 -3
- package/dist/util/os.js +39 -0
- package/dist/util/os.js.map +7 -0
- package/dist/util/timers.js +49 -0
- package/dist/util/timers.js.map +7 -0
- package/dist/util/yaml.js +45 -0
- package/dist/util/yaml.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 +12 -3
- package/src/commands/connect.ts +3 -2
- package/src/commands/create.ts +61 -8
- package/src/commands/dev.ts +69 -0
- package/src/commands/diff.ts +41 -0
- package/src/commands/execute.ts +117 -0
- package/src/commands/get.ts +242 -28
- package/src/commands/globalOptions.ts +42 -12
- package/src/commands/import.ts +58 -8
- package/src/commands/index.ts +22 -1
- package/src/commands/list.ts +85 -11
- package/src/commands/login.ts +2 -1
- package/src/commands/push.ts +18 -11
- 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 +374 -66
- package/src/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.ts +44 -0
- package/src/mappers/DevInit-to-CIWorkflow.ts +150 -0
- package/src/mappers/DevInit-to-RolePermissions.ts +33 -0
- package/src/mappers/DevRequests-to-RequestHanderSiteConfigYaml.ts +44 -0
- package/src/models/CliService.d.ts +36 -0
- package/src/models/DevService.d.ts +5 -0
- package/src/models/JsModules.d.ts +1 -0
- package/src/providers/CredentialProvider.ts +51 -18
- package/src/providers/SessionCacheProvider.ts +29 -2
- package/src/providers/file-provider.ts +17 -6
- package/src/services/ContensisCliService.ts +1458 -518
- package/src/services/ContensisDevService.ts +365 -0
- package/src/services/ContensisRoleService.ts +76 -0
- package/src/shell.ts +68 -18
- package/src/util/console.printer.ts +240 -78
- package/src/util/diff.ts +113 -0
- package/src/util/dotenv.ts +37 -0
- package/src/util/find.ts +8 -0
- package/src/util/git.ts +130 -0
- package/src/util/index.ts +16 -7
- package/src/util/logger.ts +145 -31
- package/src/util/os.ts +7 -0
- package/src/util/timers.ts +24 -0
- package/src/util/yaml.ts +13 -0
- package/src/version.ts +1 -1
package/src/util/logger.ts
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import dateFormat from 'dateformat';
|
|
4
4
|
import deepCleaner from 'deep-cleaner';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import { ansiEscapeCodes, first, strlen } from 'printable-characters';
|
|
6
|
+
// import ProgressBar from 'progress';
|
|
7
|
+
import { isSysError, tryStringify } from '.';
|
|
7
8
|
|
|
8
9
|
type LogMethod = (content: string) => void;
|
|
9
|
-
type LogErrorMethod = (content: string, err?: any) => void;
|
|
10
|
-
type LogJsonMethod = (content: any) => void;
|
|
10
|
+
type LogErrorMethod = (content: string, err?: any, newline?: string) => void;
|
|
11
|
+
type LogJsonMethod = (content: any, depth?: number, indent?: string) => void;
|
|
12
|
+
type LogJsonDepthMethod = (content: any, depth?: number) => void;
|
|
11
13
|
type LogArrayMethod = (contentArray: string[]) => void;
|
|
12
14
|
type LogErrorFunc = (
|
|
13
15
|
err: any,
|
|
@@ -36,12 +38,16 @@ export class Logger {
|
|
|
36
38
|
)} ${content}`;
|
|
37
39
|
console.log(message);
|
|
38
40
|
};
|
|
39
|
-
static error: LogErrorMethod = (content, err) => {
|
|
41
|
+
static error: LogErrorMethod = (content, err, newline = '\n') => {
|
|
40
42
|
const message = `${Logger.getPrefix()} ${Logger.errorText(
|
|
41
43
|
`${Logger.isUserTerminal ? '❌' : '[ERROR]'} ${content}${
|
|
42
|
-
err
|
|
44
|
+
err
|
|
45
|
+
? `\n\n${Logger.infoText(
|
|
46
|
+
isSysError(err) ? err.toString() : JSON.stringify(err, null, 2)
|
|
47
|
+
)}`
|
|
48
|
+
: ''
|
|
43
49
|
}`
|
|
44
|
-
)}
|
|
50
|
+
)}${newline}`;
|
|
45
51
|
if (progress.active) progress.current.interrupt(message);
|
|
46
52
|
else console.log(message);
|
|
47
53
|
};
|
|
@@ -83,7 +89,16 @@ export class Logger {
|
|
|
83
89
|
else console.log(message);
|
|
84
90
|
progress.current.interrupt(message);
|
|
85
91
|
};
|
|
86
|
-
static
|
|
92
|
+
static debug: LogMethod = content => {
|
|
93
|
+
if (['true', '1'].includes(process.env.debug || '')) {
|
|
94
|
+
const message = `${Logger.getPrefix()} ${
|
|
95
|
+
Logger.isUserTerminal ? chalk.bgGrey(' ⚙ ') : '[DEBUG]'
|
|
96
|
+
} ${Logger.infoText(content)}`;
|
|
97
|
+
if (progress.active) progress.current.interrupt(message);
|
|
98
|
+
else console.log(message);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
static json: LogJsonDepthMethod = (content, depth = 9) =>
|
|
87
102
|
console.dir(deepCleaner(content), { colors: true, depth });
|
|
88
103
|
static mixed: LogArrayMethod = contentArray =>
|
|
89
104
|
console.log(`${Logger.getPrefix()} ${contentArray.join(' ')}`);
|
|
@@ -91,13 +106,44 @@ export class Logger {
|
|
|
91
106
|
Logger.raw(` ${Logger.infoText(`-------------------------------------`)}`);
|
|
92
107
|
|
|
93
108
|
static object: LogJsonMethod = content => {
|
|
94
|
-
for (const [key, value] of Object.entries(content)) {
|
|
109
|
+
for (const [key, value] of Object.entries(content || {})) {
|
|
95
110
|
if (value && typeof value === 'object') {
|
|
96
111
|
Logger.raw(` ${chalk.bold.grey(key)}:`);
|
|
97
112
|
if (key === 'fields' && Array.isArray(value)) {
|
|
98
113
|
for (const field of value || []) {
|
|
99
114
|
Logger.raw(
|
|
100
|
-
` ${chalk.bold(field.id)}
|
|
115
|
+
` ${chalk.bold(field.id)}${
|
|
116
|
+
field.id === content.entryTitleField
|
|
117
|
+
? '**'
|
|
118
|
+
: field.validations.minCount?.value ||
|
|
119
|
+
typeof field.validations.required?.message !== 'undefined'
|
|
120
|
+
? '*'
|
|
121
|
+
: ''
|
|
122
|
+
}: ${chalk.grey(
|
|
123
|
+
`${field.dataType}${
|
|
124
|
+
field.dataFormat
|
|
125
|
+
? `<${
|
|
126
|
+
Array.isArray(
|
|
127
|
+
field.validations.allowedFieldTypes?.fields
|
|
128
|
+
)
|
|
129
|
+
? `composer[${field.validations.allowedFieldTypes.fields
|
|
130
|
+
.map((f: any) => f.id)
|
|
131
|
+
.join(' | ')}]`
|
|
132
|
+
: field.dataFormat
|
|
133
|
+
}${
|
|
134
|
+
field.dataFormat === 'entry'
|
|
135
|
+
? `, ${field.validations.allowedContentTypes.contentTypes.join(
|
|
136
|
+
' | '
|
|
137
|
+
)}`
|
|
138
|
+
: ''
|
|
139
|
+
}>`
|
|
140
|
+
: ''
|
|
141
|
+
}${
|
|
142
|
+
field.validations.maxLength?.value
|
|
143
|
+
? `(${field.validations.maxLength.value})`
|
|
144
|
+
: ''
|
|
145
|
+
}`
|
|
146
|
+
)}`
|
|
101
147
|
);
|
|
102
148
|
}
|
|
103
149
|
} else if (key === 'groups' && Array.isArray(value)) {
|
|
@@ -114,20 +160,63 @@ export class Logger {
|
|
|
114
160
|
);
|
|
115
161
|
}
|
|
116
162
|
} else {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
163
|
+
Logger.objectRecurse(value, 3, ' ');
|
|
164
|
+
// for (const [innerkey, innervalue] of Object.entries(value)) {
|
|
165
|
+
// if (innervalue && typeof innervalue === 'object') {
|
|
166
|
+
// Logger.raw(` ${chalk.bold.grey(innerkey)}:`);
|
|
167
|
+
// console.table(innervalue);
|
|
168
|
+
// } else if (
|
|
169
|
+
// typeof innervalue !== 'undefined' &&
|
|
170
|
+
// innervalue !== null
|
|
171
|
+
// ) {
|
|
172
|
+
// Logger.raw(` ${chalk.bold.grey(innerkey)}: ${innervalue}`);
|
|
173
|
+
// }
|
|
174
|
+
// }
|
|
175
|
+
}
|
|
176
|
+
} else if (typeof value !== 'undefined' && value !== null) {
|
|
177
|
+
const valueText =
|
|
178
|
+
key === 'id' && typeof value === 'string'
|
|
179
|
+
? Logger.highlightText(value)
|
|
180
|
+
: value;
|
|
181
|
+
Logger.raw(` ${chalk.bold.grey(key)}: ${valueText}`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
static objectRecurse: LogJsonMethod = (content, depth = 3, indent = '') => {
|
|
187
|
+
if (Array.isArray(content)) {
|
|
188
|
+
for (const item of content) {
|
|
189
|
+
if (item && typeof item === 'object') {
|
|
190
|
+
if (Array.isArray(item) && depth > 3)
|
|
191
|
+
Logger.raw(chalk.grey(`${indent} [${item.join(', ')}]`));
|
|
192
|
+
else Logger.objectRecurse(item, depth + 1, `${indent} `);
|
|
193
|
+
} else Logger.raw(`${indent}${item}`);
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
let pos = 0;
|
|
197
|
+
for (const [key, value] of Object.entries(content)) {
|
|
198
|
+
const thisIndent =
|
|
199
|
+
pos === 0 ? `${indent.substring(0, indent.length - 2)}- ` : indent;
|
|
200
|
+
if (Array.isArray(value)) {
|
|
201
|
+
if (value.length) Logger.raw(`${thisIndent}${chalk.bold.grey(key)}:`);
|
|
202
|
+
for (const item of value) {
|
|
203
|
+
if (item && typeof item === 'object') {
|
|
204
|
+
if (Array.isArray(item) && depth > 3)
|
|
205
|
+
Logger.raw(chalk.grey(`${indent} [${item.join(', ')}]`));
|
|
206
|
+
else Logger.objectRecurse(item, depth + 1, `${indent} `);
|
|
207
|
+
} else {
|
|
208
|
+
Logger.raw(`${indent} ${item}`);
|
|
126
209
|
}
|
|
127
210
|
}
|
|
211
|
+
} else if (value && typeof value === 'object') {
|
|
212
|
+
Logger.raw(`${indent}${chalk.bold.grey(key)}:`);
|
|
213
|
+
|
|
214
|
+
Logger.objectRecurse(value, depth + 1, `${indent} `);
|
|
215
|
+
// console.table(value);
|
|
216
|
+
} else if (typeof value !== 'undefined' && value !== null) {
|
|
217
|
+
Logger.raw(`${thisIndent}${chalk.bold.grey(key)}: ${value}`);
|
|
128
218
|
}
|
|
129
|
-
|
|
130
|
-
Logger.raw(` ${chalk.bold.grey(key)}: ${value}`);
|
|
219
|
+
pos++;
|
|
131
220
|
}
|
|
132
221
|
}
|
|
133
222
|
};
|
|
@@ -135,6 +224,26 @@ export class Logger {
|
|
|
135
224
|
if (progress.active) progress.current.interrupt(content);
|
|
136
225
|
else console.log(content);
|
|
137
226
|
};
|
|
227
|
+
|
|
228
|
+
static limits = (content: string, displayLength = 30) => {
|
|
229
|
+
const consoleWidth = process.stdout.columns;
|
|
230
|
+
console.info(
|
|
231
|
+
consoleWidth
|
|
232
|
+
? content
|
|
233
|
+
.split('\n')
|
|
234
|
+
.slice(0, consoleWidth ? displayLength : undefined)
|
|
235
|
+
.map((line: string) =>
|
|
236
|
+
consoleWidth && strlen(line) > consoleWidth
|
|
237
|
+
? first(line, consoleWidth)
|
|
238
|
+
: line
|
|
239
|
+
)
|
|
240
|
+
.join('\n')
|
|
241
|
+
: content.replace(ansiEscapeCodes, '')
|
|
242
|
+
);
|
|
243
|
+
const tableArray = content.split('\n');
|
|
244
|
+
if (consoleWidth && tableArray.length > displayLength)
|
|
245
|
+
console.info(`\n`, `- and ${tableArray.length - displayLength} more...`);
|
|
246
|
+
};
|
|
138
247
|
}
|
|
139
248
|
|
|
140
249
|
export const logError: LogErrorFunc = (
|
|
@@ -144,22 +253,27 @@ export const logError: LogErrorFunc = (
|
|
|
144
253
|
) => {
|
|
145
254
|
Logger[level](msg || err.message || err?.data?.message || err.Message);
|
|
146
255
|
(Array.isArray(err) ? err : [err]).map((error: AppError) => {
|
|
147
|
-
if ('
|
|
256
|
+
if (typeof error === 'string') {
|
|
257
|
+
Logger.raw(`${Logger.infoText(error)}\n`);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
if ('stack' in error) Logger.raw(` ${Logger.infoText(error.stack)}\n`);
|
|
148
261
|
if ('data' in error)
|
|
149
|
-
Logger.raw(` ${Logger.infoText(tryStringify(error.data))}`);
|
|
262
|
+
Logger.raw(` ${Logger.infoText(tryStringify(error.data))}\n`);
|
|
150
263
|
});
|
|
151
264
|
//Logger.line();
|
|
152
265
|
return null;
|
|
153
266
|
};
|
|
154
267
|
|
|
155
268
|
export const progress = {
|
|
269
|
+
current: { interrupt: (x: string) => {} },
|
|
156
270
|
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
|
-
}),
|
|
271
|
+
// done: () => new ProgressBar('', 0),
|
|
272
|
+
// colours: { green: '\u001b[42m \u001b[0m', red: '\u001b[41m \u001b[0m' },
|
|
273
|
+
// current: new ProgressBar(`:bar`, {
|
|
274
|
+
// complete: '=',
|
|
275
|
+
// incomplete: ' ',
|
|
276
|
+
// width: 20,
|
|
277
|
+
// total: 100,
|
|
278
|
+
// }),
|
|
165
279
|
};
|
package/src/util/os.ts
ADDED
|
@@ -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/util/yaml.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { validateWorkflow } from '@action-validator/core';
|
|
2
|
+
|
|
3
|
+
import { parse, parseDocument, stringify } from 'yaml';
|
|
4
|
+
|
|
5
|
+
export const parseYaml = parse;
|
|
6
|
+
export const parseYamlDocument = parseDocument;
|
|
7
|
+
export const stringifyYaml = stringify;
|
|
8
|
+
|
|
9
|
+
export const validateWorkflowYaml = (yaml: string) => {
|
|
10
|
+
const { actionType, errors } = validateWorkflow(yaml);
|
|
11
|
+
if (actionType && errors.length === 0) return true;
|
|
12
|
+
return errors;
|
|
13
|
+
};
|
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.91";
|