contensis-cli 1.0.0-beta.38 → 1.0.0-beta.40
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 +4 -2
- 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/get.js +40 -11
- package/dist/commands/get.js.map +2 -2
- package/dist/commands/globalOptions.js +4 -3
- package/dist/commands/globalOptions.js.map +2 -2
- package/dist/commands/import.js +31 -5
- package/dist/commands/import.js.map +2 -2
- package/dist/commands/index.js +6 -0
- package/dist/commands/index.js.map +2 -2
- package/dist/commands/list.js +19 -8
- package/dist/commands/list.js.map +2 -2
- package/dist/commands/push.js +2 -1
- package/dist/commands/push.js.map +2 -2
- package/dist/commands/release.js +2 -1
- package/dist/commands/release.js.map +2 -2
- package/dist/commands/remove.js +6 -4
- package/dist/commands/remove.js.map +2 -2
- package/dist/commands/set.js +6 -3
- package/dist/commands/set.js.map +2 -2
- package/dist/localisation/en-GB.js +43 -24
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/providers/SessionCacheProvider.js +2 -2
- package/dist/providers/SessionCacheProvider.js.map +2 -2
- package/dist/providers/file-provider.js +1 -1
- package/dist/providers/file-provider.js.map +2 -2
- package/dist/services/ContensisCliService.js +240 -72
- package/dist/services/ContensisCliService.js.map +3 -3
- package/dist/shell.js +4 -1
- package/dist/shell.js.map +2 -2
- package/dist/util/console.printer.js +87 -4
- package/dist/util/console.printer.js.map +2 -2
- package/dist/util/logger.js +45 -13
- package/dist/util/logger.js.map +2 -2
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +2 -2
- package/src/commands/create.ts +2 -0
- package/src/commands/diff.ts +39 -0
- package/src/commands/get.ts +48 -4
- package/src/commands/globalOptions.ts +5 -4
- package/src/commands/import.ts +36 -2
- package/src/commands/index.ts +6 -0
- package/src/commands/list.ts +34 -9
- package/src/commands/push.ts +1 -0
- package/src/commands/release.ts +1 -0
- package/src/commands/remove.ts +4 -2
- package/src/commands/set.ts +3 -0
- package/src/localisation/en-GB.ts +58 -33
- package/src/providers/SessionCacheProvider.ts +3 -2
- package/src/providers/file-provider.ts +2 -1
- package/src/services/ContensisCliService.ts +301 -84
- package/src/shell.ts +4 -2
- package/src/util/console.printer.ts +100 -3
- package/src/util/logger.ts +84 -15
- package/src/version.ts +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
|
-
import { BlockVersion, MigrateStatus } from 'migratortron';
|
|
2
|
+
import { BlockVersion, MigrateModelsResult, MigrateStatus } from 'migratortron';
|
|
3
3
|
import ContensisCli from '~/services/ContensisCliService';
|
|
4
|
+
import { Logger } from './logger';
|
|
4
5
|
|
|
5
6
|
const formatDate = (date: Date | string, format = 'DD/MM/YYYY HH:mm') =>
|
|
6
7
|
dayjs(date).format(format);
|
|
@@ -173,7 +174,7 @@ export const printMigrateResult = (
|
|
|
173
174
|
'',
|
|
174
175
|
{ x: { status: undefined } },
|
|
175
176
|
];
|
|
176
|
-
return `${messages.
|
|
177
|
+
return `${messages.migrate.status(status)(
|
|
177
178
|
`${projectId}: ${status}`
|
|
178
179
|
)}${targetGuid !== originalId ? `-> ${targetGuid}` : ''}`;
|
|
179
180
|
})}]`
|
|
@@ -190,7 +191,7 @@ export const printMigrateResult = (
|
|
|
190
191
|
if (error) log.error(error);
|
|
191
192
|
if (diff) {
|
|
192
193
|
console.log(
|
|
193
|
-
` ${messages.
|
|
194
|
+
` ${messages.migrate.status(status)(status)} ${log.infoText(
|
|
194
195
|
targetGuid
|
|
195
196
|
)} ${log.infoText(contentTypeId)} ${log.infoText(projectId)}`
|
|
196
197
|
);
|
|
@@ -201,3 +202,99 @@ export const printMigrateResult = (
|
|
|
201
202
|
}
|
|
202
203
|
}
|
|
203
204
|
};
|
|
205
|
+
|
|
206
|
+
const highlightDiffText = (str: string) => {
|
|
207
|
+
const addedRegex = new RegExp(/<<\+>>(.*?)<<\/\+>>/, 'g');
|
|
208
|
+
const removedRegex = new RegExp(/<<->>(.*?)<<\/->>/, 'g');
|
|
209
|
+
return str
|
|
210
|
+
.replace(addedRegex, match => {
|
|
211
|
+
return Logger.successText(
|
|
212
|
+
match.replace(/<<\+>>/g, '<+>').replace(/<<\/\+>>/g, '</+>')
|
|
213
|
+
);
|
|
214
|
+
})
|
|
215
|
+
.replace(removedRegex, match => {
|
|
216
|
+
return Logger.errorText(
|
|
217
|
+
match.replace(/<<->>/g, '<->').replace(/<<\/->>/g, '</->')
|
|
218
|
+
);
|
|
219
|
+
});
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export const printModelMigrationAnalysis = (
|
|
223
|
+
{ log, messages }: ContensisCli,
|
|
224
|
+
result: any = {}
|
|
225
|
+
) => {
|
|
226
|
+
for (const [contentTypeId, model] of Object.entries(result) as [
|
|
227
|
+
string,
|
|
228
|
+
any
|
|
229
|
+
][]) {
|
|
230
|
+
let mainOutput = log.standardText(` - ${contentTypeId}`);
|
|
231
|
+
let extraOutput = '';
|
|
232
|
+
let errorOutput = '';
|
|
233
|
+
let diffOutput = '';
|
|
234
|
+
for (const [key, details] of Object.entries(model) as [string, any][]) {
|
|
235
|
+
if (key === 'dependencies') {
|
|
236
|
+
extraOutput += log.infoText(
|
|
237
|
+
` references: [${details?.join(', ')}]\n`
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
if (key === 'dependencyOf') {
|
|
241
|
+
extraOutput += log.infoText(
|
|
242
|
+
` required by: [${details?.join(', ')}]\n`
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
if (key === 'projects') {
|
|
246
|
+
for (const [projectId, projectDetails] of Object.entries(details) as [
|
|
247
|
+
string,
|
|
248
|
+
any
|
|
249
|
+
][]) {
|
|
250
|
+
mainOutput += log.infoText(
|
|
251
|
+
` [${messages.migrate.status(projectDetails.status)(
|
|
252
|
+
`${projectId}: ${projectDetails.status}`
|
|
253
|
+
)}] v${projectDetails.versionNo}`
|
|
254
|
+
);
|
|
255
|
+
if (projectDetails.diff)
|
|
256
|
+
diffOutput += ` ${log.highlightText(`diff:`)} ${log.infoText(
|
|
257
|
+
highlightDiffText(projectDetails.diff)
|
|
258
|
+
)}\n`;
|
|
259
|
+
if (projectDetails.error)
|
|
260
|
+
errorOutput += ` ${log.highlightText(`error::`)} ${log.errorText(
|
|
261
|
+
projectDetails.error
|
|
262
|
+
)}`;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
console.log(mainOutput);
|
|
267
|
+
if (extraOutput) {
|
|
268
|
+
const search = '\n';
|
|
269
|
+
const replace = '';
|
|
270
|
+
console.log(
|
|
271
|
+
extraOutput.replace(
|
|
272
|
+
new RegExp(search + '([^' + search + ']*)$'),
|
|
273
|
+
replace + '$1'
|
|
274
|
+
)
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
if (diffOutput) console.log(diffOutput);
|
|
278
|
+
if (errorOutput) console.log(errorOutput);
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
type MigrateResultSummary = MigrateModelsResult['']['contentTypes'];
|
|
283
|
+
type MigrateResultStatus = keyof MigrateResultSummary;
|
|
284
|
+
|
|
285
|
+
export const printModelMigrationResult = (
|
|
286
|
+
{ log, messages }: ContensisCli,
|
|
287
|
+
result: MigrateResultSummary
|
|
288
|
+
) => {
|
|
289
|
+
for (const [status, ids] of Object.entries(result) as [
|
|
290
|
+
MigrateResultStatus,
|
|
291
|
+
string[]
|
|
292
|
+
][]) {
|
|
293
|
+
if (ids?.length)
|
|
294
|
+
log.raw(
|
|
295
|
+
` - ${status}: [ ${messages.migrate.models.result(status)(
|
|
296
|
+
ids.join(', ')
|
|
297
|
+
)} ]`
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
};
|
package/src/util/logger.ts
CHANGED
|
@@ -7,7 +7,8 @@ import { tryStringify } from '.';
|
|
|
7
7
|
|
|
8
8
|
type LogMethod = (content: string) => void;
|
|
9
9
|
type LogErrorMethod = (content: string, err?: any) => void;
|
|
10
|
-
type LogJsonMethod = (content: any) => 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,
|
|
@@ -83,7 +84,7 @@ export class Logger {
|
|
|
83
84
|
else console.log(message);
|
|
84
85
|
progress.current.interrupt(message);
|
|
85
86
|
};
|
|
86
|
-
static json:
|
|
87
|
+
static json: LogJsonDepthMethod = (content, depth = 9) =>
|
|
87
88
|
console.dir(deepCleaner(content), { colors: true, depth });
|
|
88
89
|
static mixed: LogArrayMethod = contentArray =>
|
|
89
90
|
console.log(`${Logger.getPrefix()} ${contentArray.join(' ')}`);
|
|
@@ -97,7 +98,38 @@ export class Logger {
|
|
|
97
98
|
if (key === 'fields' && Array.isArray(value)) {
|
|
98
99
|
for (const field of value || []) {
|
|
99
100
|
Logger.raw(
|
|
100
|
-
` ${chalk.bold(field.id)}
|
|
101
|
+
` ${chalk.bold(field.id)}${
|
|
102
|
+
field.id === content.entryTitleField
|
|
103
|
+
? '**'
|
|
104
|
+
: field.validations.minCount?.value ||
|
|
105
|
+
typeof field.validations.required?.message !== 'undefined'
|
|
106
|
+
? '*'
|
|
107
|
+
: ''
|
|
108
|
+
}: ${chalk.grey(
|
|
109
|
+
`${field.dataType}${
|
|
110
|
+
field.dataFormat
|
|
111
|
+
? `<${
|
|
112
|
+
Array.isArray(
|
|
113
|
+
field.validations.allowedFieldTypes?.fields
|
|
114
|
+
)
|
|
115
|
+
? `composer[${field.validations.allowedFieldTypes.fields
|
|
116
|
+
.map((f: any) => f.id)
|
|
117
|
+
.join(' | ')}]`
|
|
118
|
+
: field.dataFormat
|
|
119
|
+
}${
|
|
120
|
+
field.dataFormat === 'entry'
|
|
121
|
+
? `, ${field.validations.allowedContentTypes.contentTypes.join(
|
|
122
|
+
' | '
|
|
123
|
+
)}`
|
|
124
|
+
: ''
|
|
125
|
+
}>`
|
|
126
|
+
: ''
|
|
127
|
+
}${
|
|
128
|
+
field.validations.maxLength?.value
|
|
129
|
+
? `(${field.validations.maxLength.value})`
|
|
130
|
+
: ''
|
|
131
|
+
}`
|
|
132
|
+
)}`
|
|
101
133
|
);
|
|
102
134
|
}
|
|
103
135
|
} else if (key === 'groups' && Array.isArray(value)) {
|
|
@@ -114,22 +146,59 @@ export class Logger {
|
|
|
114
146
|
);
|
|
115
147
|
}
|
|
116
148
|
} else {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
149
|
+
Logger.objectRecurse(value, 3, ' ');
|
|
150
|
+
// for (const [innerkey, innervalue] of Object.entries(value)) {
|
|
151
|
+
// if (innervalue && typeof innervalue === 'object') {
|
|
152
|
+
// Logger.raw(` ${chalk.bold.grey(innerkey)}:`);
|
|
153
|
+
// console.table(innervalue);
|
|
154
|
+
// } else if (
|
|
155
|
+
// typeof innervalue !== 'undefined' &&
|
|
156
|
+
// innervalue !== null
|
|
157
|
+
// ) {
|
|
158
|
+
// Logger.raw(` ${chalk.bold.grey(innerkey)}: ${innervalue}`);
|
|
159
|
+
// }
|
|
160
|
+
// }
|
|
161
|
+
}
|
|
162
|
+
} else if (typeof value !== 'undefined' && value !== null) {
|
|
163
|
+
const valueText =
|
|
164
|
+
key === 'id' && typeof value === 'string'
|
|
165
|
+
? Logger.highlightText(value)
|
|
166
|
+
: value;
|
|
167
|
+
Logger.raw(` ${chalk.bold.grey(key)}: ${valueText}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
static objectRecurse: LogJsonMethod = (content, depth = 3, indent = '') => {
|
|
173
|
+
if (Array.isArray(content)) {
|
|
174
|
+
for (const item of content) {
|
|
175
|
+
if (item && typeof item === 'object') {
|
|
176
|
+
if (Array.isArray(item) && depth > 3)
|
|
177
|
+
Logger.raw(chalk.grey(`${indent} [${item.join(', ')}]`));
|
|
178
|
+
else Logger.objectRecurse(item, depth + 1, `${indent} `);
|
|
179
|
+
} else Logger.raw(`${indent}${item}`);
|
|
180
|
+
}
|
|
181
|
+
} else
|
|
182
|
+
for (const [key, value] of Object.entries(content)) {
|
|
183
|
+
if (Array.isArray(value)) {
|
|
184
|
+
for (const item of value) {
|
|
185
|
+
if (item && typeof item === 'object') {
|
|
186
|
+
if (Array.isArray(item) && depth > 3)
|
|
187
|
+
Logger.raw(chalk.grey(`${indent} [${item.join(', ')}]`));
|
|
188
|
+
else Logger.objectRecurse(item, depth + 1, `${indent}`);
|
|
189
|
+
} else {
|
|
190
|
+
Logger.raw(`${indent} ${item}`);
|
|
126
191
|
}
|
|
127
192
|
}
|
|
193
|
+
} else if (value && typeof value === 'object') {
|
|
194
|
+
Logger.raw(`${indent}${chalk.bold.grey(key)}:`);
|
|
195
|
+
|
|
196
|
+
Logger.objectRecurse(value, depth + 1, `${indent} `);
|
|
197
|
+
// console.table(value);
|
|
198
|
+
} else if (typeof value !== 'undefined' && value !== null) {
|
|
199
|
+
Logger.raw(`${indent}${chalk.bold.grey(key)}: ${value}`);
|
|
128
200
|
}
|
|
129
|
-
} else if (typeof value !== 'undefined' || value !== null) {
|
|
130
|
-
Logger.raw(` ${chalk.bold.grey(key)}: ${value}`);
|
|
131
201
|
}
|
|
132
|
-
}
|
|
133
202
|
};
|
|
134
203
|
static raw: LogMethod = (content: string) => {
|
|
135
204
|
if (progress.active) progress.current.interrupt(content);
|
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.40";
|