contensis-cli 1.3.1-beta.0 → 1.3.1-beta.10
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 +78 -6
- package/dist/commands/copy.js +2 -2
- package/dist/commands/copy.js.map +2 -2
- package/dist/commands/create.js +1 -2
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/globalOptions.js +16 -4
- package/dist/commands/globalOptions.js.map +2 -2
- package/dist/commands/import.js +1 -1
- package/dist/commands/import.js.map +2 -2
- package/dist/commands/index.js +4 -2
- package/dist/commands/index.js.map +2 -2
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/login.js +1 -2
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/push.js +102 -10
- package/dist/commands/push.js.map +3 -3
- package/dist/commands/remove.js +15 -4
- package/dist/commands/remove.js.map +2 -2
- package/dist/commands/set.js +2 -4
- package/dist/commands/set.js.map +1 -1
- package/dist/commands/update.js +70 -0
- package/dist/commands/update.js.map +7 -0
- package/dist/factories/RequestHandlerFactory.js +12 -5
- package/dist/factories/RequestHandlerFactory.js.map +2 -2
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/localisation/en-GB.js +19 -2
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.js.map +1 -1
- package/dist/mappers/DevInit-to-CIWorkflow.js +11 -6
- package/dist/mappers/DevInit-to-CIWorkflow.js.map +1 -1
- package/dist/mappers/DevRequests-to-RequestHanderCliArgs.js +4 -2
- package/dist/mappers/DevRequests-to-RequestHanderCliArgs.js.map +1 -1
- package/dist/models/CliService.d.js.map +1 -1
- package/dist/providers/CredentialProvider.js +11 -4
- package/dist/providers/CredentialProvider.js.map +2 -2
- package/dist/providers/GitHubCliModuleProvider.js +8 -10
- package/dist/providers/GitHubCliModuleProvider.js.map +1 -1
- package/dist/providers/HttpProvider.js +5 -4
- package/dist/providers/HttpProvider.js.map +1 -1
- package/dist/providers/ManifestProvider.js +1 -4
- package/dist/providers/ManifestProvider.js.map +1 -1
- package/dist/providers/SessionCacheProvider.js +26 -8
- package/dist/providers/SessionCacheProvider.js.map +2 -2
- package/dist/providers/file-provider.js +13 -11
- package/dist/providers/file-provider.js.map +1 -1
- package/dist/services/ContensisAuthService.js +1 -2
- package/dist/services/ContensisAuthService.js.map +1 -1
- package/dist/services/ContensisCliService.js +194 -127
- package/dist/services/ContensisCliService.js.map +3 -3
- package/dist/services/ContensisDevService.js +15 -18
- package/dist/services/ContensisDevService.js.map +2 -2
- package/dist/services/ContensisRoleService.js +8 -10
- package/dist/services/ContensisRoleService.js.map +1 -1
- package/dist/shell.js +31 -15
- package/dist/shell.js.map +2 -2
- package/dist/util/api-ids.js.map +1 -1
- package/dist/util/console.printer.js +15 -17
- package/dist/util/console.printer.js.map +2 -2
- package/dist/util/csv.formatter.js +8 -15
- package/dist/util/csv.formatter.js.map +2 -2
- package/dist/util/diff.js +6 -4
- package/dist/util/diff.js.map +1 -1
- package/dist/util/dotenv.js +1 -2
- package/dist/util/dotenv.js.map +1 -1
- package/dist/util/error.js.map +1 -1
- package/dist/util/fetch.js +4 -0
- package/dist/util/fetch.js.map +1 -1
- package/dist/util/git.js +8 -8
- package/dist/util/git.js.map +1 -1
- package/dist/util/gitignore.js +4 -0
- package/dist/util/gitignore.js.map +1 -1
- package/dist/util/html.formatter.js +70 -0
- package/dist/util/html.formatter.js.map +7 -0
- package/dist/util/index.js +5 -1
- package/dist/util/index.js.map +2 -2
- package/dist/util/json.formatter.js +6 -4
- package/dist/util/json.formatter.js.map +1 -1
- package/dist/util/logger.js +47 -53
- package/dist/util/logger.js.map +2 -2
- package/dist/util/os.js +4 -0
- package/dist/util/os.js.map +1 -1
- package/dist/util/xml.formatter.js +4 -0
- package/dist/util/xml.formatter.js.map +1 -1
- package/dist/util/yaml.js +1 -2
- package/dist/util/yaml.js.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/esbuild.config.js +12 -16
- package/package.json +31 -32
- package/src/commands/copy.ts +3 -1
- package/src/commands/globalOptions.ts +10 -3
- package/src/commands/import.ts +2 -0
- package/src/commands/index.ts +4 -0
- package/src/commands/push.ts +125 -1
- package/src/commands/remove.ts +20 -0
- package/src/commands/update.ts +84 -0
- package/src/factories/RequestHandlerFactory.ts +1 -1
- package/src/localisation/en-GB.ts +16 -1
- package/src/models/CliService.d.ts +1 -1
- package/src/providers/CredentialProvider.ts +2 -2
- package/src/providers/SessionCacheProvider.ts +26 -2
- package/src/services/ContensisCliService.ts +187 -49
- package/src/services/ContensisDevService.ts +2 -2
- package/src/shell.ts +20 -9
- package/src/util/console.printer.ts +23 -19
- package/src/util/csv.formatter.ts +1 -1
- package/src/util/html.formatter.ts +52 -0
- package/src/util/index.ts +1 -1
- package/src/util/logger.ts +17 -16
- package/src/version.ts +1 -1
- package/tsconfig.json +1 -1
|
@@ -125,7 +125,7 @@ export const printEntriesMigrateResult = (
|
|
|
125
125
|
showAll = false,
|
|
126
126
|
showChanged = false,
|
|
127
127
|
}: {
|
|
128
|
-
action?: 'import' | 'delete';
|
|
128
|
+
action?: 'import' | 'update' | 'delete';
|
|
129
129
|
showDiff?: boolean;
|
|
130
130
|
showAll?: boolean;
|
|
131
131
|
showChanged?: boolean;
|
|
@@ -138,7 +138,7 @@ export const printEntriesMigrateResult = (
|
|
|
138
138
|
) as [string, any]) {
|
|
139
139
|
for (const [originalId, entryStatus] of Object.entries(entryRes) as [
|
|
140
140
|
string,
|
|
141
|
-
any
|
|
141
|
+
any,
|
|
142
142
|
][]) {
|
|
143
143
|
if (
|
|
144
144
|
showAll ||
|
|
@@ -191,17 +191,21 @@ export const printEntriesMigrateResult = (
|
|
|
191
191
|
migrateResult.entries || {}
|
|
192
192
|
) as [string, any][]) {
|
|
193
193
|
log.help(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
194
|
+
action === 'update'
|
|
195
|
+
? `update entries in project ${log.boldText(
|
|
196
|
+
log.warningText(currentProject)
|
|
197
|
+
)}`
|
|
198
|
+
: `${action}${
|
|
199
|
+
action === 'delete'
|
|
200
|
+
? ` from project ${log.warningText(currentProject)}`
|
|
201
|
+
: `${projectId ? ` from project ${log.highlightText(projectId)}` : ''} to ${log.boldText(
|
|
202
|
+
log.warningText(currentProject)
|
|
203
|
+
)}`
|
|
204
|
+
}`
|
|
201
205
|
);
|
|
202
206
|
for (const [contentTypeId, count] of Object.entries(contentTypeCounts) as [
|
|
203
207
|
string,
|
|
204
|
-
number
|
|
208
|
+
number,
|
|
205
209
|
][]) {
|
|
206
210
|
const isTotalCountRow = contentTypeId === 'totalCount';
|
|
207
211
|
const migrateStatusAndCount =
|
|
@@ -227,8 +231,8 @@ export const printEntriesMigrateResult = (
|
|
|
227
231
|
const changedColor = isTotalCountRow
|
|
228
232
|
? log.helpText
|
|
229
233
|
: changedPercentage === '100'
|
|
230
|
-
|
|
231
|
-
|
|
234
|
+
? log.successText
|
|
235
|
+
: log.warningText;
|
|
232
236
|
|
|
233
237
|
if (isTotalCountRow && 'nodes' in migrateResult) {
|
|
234
238
|
printNodesMigrateResult(service, migrateResult, {
|
|
@@ -257,8 +261,8 @@ export const printEntriesMigrateResult = (
|
|
|
257
261
|
isTotalCountRow
|
|
258
262
|
? `[to ${action}: ${noChangeOrTotalEntriesCount}]`
|
|
259
263
|
: changedPercentage === '100'
|
|
260
|
-
|
|
261
|
-
|
|
264
|
+
? 'up to date'
|
|
265
|
+
: `[needs update: ${100 - Number(changedPercentage)}%]`
|
|
262
266
|
}`
|
|
263
267
|
)
|
|
264
268
|
}`
|
|
@@ -391,7 +395,7 @@ export const printModelMigrationAnalysis = (
|
|
|
391
395
|
) => {
|
|
392
396
|
for (const [contentTypeId, model] of Object.entries(result) as [
|
|
393
397
|
string,
|
|
394
|
-
any
|
|
398
|
+
any,
|
|
395
399
|
][]) {
|
|
396
400
|
let mainOutput = log.standardText(
|
|
397
401
|
` - ${contentTypeId}${
|
|
@@ -415,7 +419,7 @@ export const printModelMigrationAnalysis = (
|
|
|
415
419
|
if (key === 'projects') {
|
|
416
420
|
for (const [projectId, projectDetails] of Object.entries(details) as [
|
|
417
421
|
string,
|
|
418
|
-
any
|
|
422
|
+
any,
|
|
419
423
|
][]) {
|
|
420
424
|
mainOutput += log.infoText(
|
|
421
425
|
` [${messages.migrate.status(projectDetails.status)(
|
|
@@ -460,7 +464,7 @@ export const printModelMigrationResult = (
|
|
|
460
464
|
) => {
|
|
461
465
|
for (const [status, ids] of Object.entries(result) as [
|
|
462
466
|
MigrateResultStatus,
|
|
463
|
-
string[]
|
|
467
|
+
string[],
|
|
464
468
|
][]) {
|
|
465
469
|
if (ids?.length) {
|
|
466
470
|
if (status === 'errors') {
|
|
@@ -555,8 +559,8 @@ export const printNodeTreeOutput = (
|
|
|
555
559
|
fullOutput || isRoot || !node.slug ? node.path : `/${node.slug}`
|
|
556
560
|
)
|
|
557
561
|
: fullOutput || isRoot || !node.slug
|
|
558
|
-
|
|
559
|
-
|
|
562
|
+
? node.path
|
|
563
|
+
: `/${node.slug}`
|
|
560
564
|
)}${node.entry ? ` ${log.helpText(node.entry.sys.contentTypeId)}` : ''}${
|
|
561
565
|
node.childCount ? ` +${node.childCount}` : ``
|
|
562
566
|
} ${'displayName' in node ? log.infoText(node.displayName) : ''}${
|
|
@@ -89,7 +89,7 @@ const determineMost = (chunk: string, items: string[]) => {
|
|
|
89
89
|
items.forEach(item => {
|
|
90
90
|
itemCount[item] = 0;
|
|
91
91
|
});
|
|
92
|
-
for (
|
|
92
|
+
for (let i = 0; i < chunk.length; i++) {
|
|
93
93
|
if (chunk[i] === '"') ignoreString = !ignoreString;
|
|
94
94
|
else if (!ignoreString && chunk[i] in itemCount) {
|
|
95
95
|
currValue = ++itemCount[chunk[i]];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { flattenObject } from './json.formatter';
|
|
2
|
+
|
|
3
|
+
export const htmlFormatter = <T>(entries: T | T[], isDoc = true) => {
|
|
4
|
+
// Flatten the passed in object
|
|
5
|
+
const flatEntries = [] as any[];
|
|
6
|
+
if (Array.isArray(entries))
|
|
7
|
+
for (const entry of entries) {
|
|
8
|
+
flatEntries.push(flattenObject(entry));
|
|
9
|
+
}
|
|
10
|
+
else flatEntries.push(flattenObject(entries));
|
|
11
|
+
|
|
12
|
+
// Parse the flattened object to csv
|
|
13
|
+
// const csv = stringify(flatEntries, { header: true });
|
|
14
|
+
// Create an exhaustive list of columns from the entries array
|
|
15
|
+
const columns = new Set<string>(flatEntries.map(e => Object.keys(e)).flat());
|
|
16
|
+
|
|
17
|
+
let table = `<table id="contensis-cli-table"><thead><tr>`;
|
|
18
|
+
for (const column of columns) {
|
|
19
|
+
table += `<td>${column}</td>`;
|
|
20
|
+
}
|
|
21
|
+
table += `</tr></thead><tbody>`;
|
|
22
|
+
for (const row of flatEntries) {
|
|
23
|
+
table += `<tr>`;
|
|
24
|
+
for (const column of columns) {
|
|
25
|
+
const val = row[column];
|
|
26
|
+
table += `<td>${typeof val === 'undefined' ? '' : val}</td>`;
|
|
27
|
+
}
|
|
28
|
+
table += `</tr>`;
|
|
29
|
+
}
|
|
30
|
+
table += `</tbody></table>`;
|
|
31
|
+
|
|
32
|
+
if (isDoc)
|
|
33
|
+
table = `<html><head>${headTag()}</head><body>${table}${scriptTag()}</body></html>`;
|
|
34
|
+
return table;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const headTag = () => {
|
|
38
|
+
return `<link rel="stylesheet" href="https://cdn.datatables.net/2.1.8/css/dataTables.dataTables.css" />
|
|
39
|
+
<script
|
|
40
|
+
src="https://code.jquery.com/jquery-3.7.1.slim.min.js"
|
|
41
|
+
integrity="sha256-kmHvs0B+OpCW5GVHUNjv9rOmY0IvSIRcf7zGUDTDQM8="
|
|
42
|
+
crossorigin="anonymous"></script>
|
|
43
|
+
<script src="https://cdn.datatables.net/2.1.8/js/dataTables.js"></script>`;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const scriptTag = () => {
|
|
47
|
+
return `<script>
|
|
48
|
+
let table = new DataTable('#contensis-cli-table', {
|
|
49
|
+
pageLength: 50
|
|
50
|
+
});
|
|
51
|
+
</script>`;
|
|
52
|
+
};
|
package/src/util/index.ts
CHANGED
|
@@ -58,7 +58,7 @@ export const Logging = async (language = 'en-GB') => {
|
|
|
58
58
|
// const { LogMessages: defaultMessages } = await import(
|
|
59
59
|
// `../localisation/en-GB.js`
|
|
60
60
|
// );
|
|
61
|
-
|
|
61
|
+
const localisedMessages = defaultMessages;
|
|
62
62
|
|
|
63
63
|
if (language === 'en-GB') {
|
|
64
64
|
// Using a variable import e.g. `import(`../localisation/${language}.js`);`
|
package/src/util/logger.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
1
|
import chalk from 'chalk';
|
|
3
2
|
import dateFormat from 'dateformat';
|
|
4
3
|
import deepCleaner from 'deep-cleaner';
|
|
@@ -56,10 +55,10 @@ export class Logger {
|
|
|
56
55
|
if (progress.active) progress.current.interrupt(message);
|
|
57
56
|
else console.log(message);
|
|
58
57
|
};
|
|
59
|
-
static warning: LogMethod = content => {
|
|
58
|
+
static warning: LogMethod = (content, newline = '\n') => {
|
|
60
59
|
const message = `${Logger.getPrefix()} ${Logger.warningText(
|
|
61
60
|
`${Logger.isUserTerminal ? '⚠️ ' : '[WARN]'} ${content}`
|
|
62
|
-
)}
|
|
61
|
+
)}${newline}`;
|
|
63
62
|
if (progress.active) progress.current.interrupt(message);
|
|
64
63
|
else console.log(message);
|
|
65
64
|
// }
|
|
@@ -120,9 +119,9 @@ export class Logger {
|
|
|
120
119
|
field.id === content.entryTitleField
|
|
121
120
|
? '**'
|
|
122
121
|
: field.validations.minCount?.value ||
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
typeof field.validations.required?.message !== 'undefined'
|
|
123
|
+
? '*'
|
|
124
|
+
: ''
|
|
126
125
|
}: ${chalk.grey(
|
|
127
126
|
`${field.dataType}${
|
|
128
127
|
field.dataFormat
|
|
@@ -203,16 +202,17 @@ export class Logger {
|
|
|
203
202
|
if (item.length)
|
|
204
203
|
Logger.raw(chalk.grey(`${indent} [${item.join(', ')}]`));
|
|
205
204
|
else Logger.objectRecurse(item, depth + 1, `${indent} `);
|
|
206
|
-
else
|
|
207
|
-
Array.isArray(item)
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
205
|
+
else {
|
|
206
|
+
if (Array.isArray(item))
|
|
207
|
+
Logger.raw(
|
|
208
|
+
`${indent}${chalk.grey(`[`)}${item.join(', ')}${chalk.grey(
|
|
209
|
+
`]`
|
|
210
|
+
)}`
|
|
211
|
+
);
|
|
212
|
+
else if (typeof item === 'object' && item)
|
|
213
|
+
Logger.objectRecurse(item, depth + 1, `${indent} `);
|
|
214
|
+
else Logger.raw(`${indent}${item}`);
|
|
215
|
+
}
|
|
216
216
|
} else Logger.raw(`${indent}${item}`);
|
|
217
217
|
}
|
|
218
218
|
} else {
|
|
@@ -253,6 +253,7 @@ export class Logger {
|
|
|
253
253
|
content: string,
|
|
254
254
|
displayLength = 30,
|
|
255
255
|
consoleWidth = process.stdout.columns,
|
|
256
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
256
257
|
logMethod: Function = console.info
|
|
257
258
|
) => {
|
|
258
259
|
if (consoleWidth) {
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = "1.3.1-beta.
|
|
1
|
+
export const LIB_VERSION = "1.3.1-beta.10";
|