contensis-cli 1.0.0-beta.39 → 1.0.0-beta.41
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/connect.js +1 -1
- package/dist/commands/connect.js.map +2 -2
- package/dist/commands/create.js +29 -11
- package/dist/commands/create.js.map +2 -2
- package/dist/commands/get.js +1 -1
- package/dist/commands/get.js.map +2 -2
- package/dist/commands/globalOptions.js +18 -14
- package/dist/commands/globalOptions.js.map +2 -2
- package/dist/commands/import.js +7 -7
- package/dist/commands/import.js.map +2 -2
- package/dist/commands/index.js +1 -3
- package/dist/commands/index.js.map +2 -2
- package/dist/commands/login.js +2 -2
- package/dist/commands/login.js.map +2 -2
- package/dist/localisation/en-GB.js +63 -37
- package/dist/localisation/en-GB.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 +78 -25
- package/dist/services/ContensisCliService.js.map +3 -3
- package/dist/shell.js +5 -2
- package/dist/shell.js.map +2 -2
- package/dist/util/console.printer.js +40 -46
- package/dist/util/console.printer.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/connect.ts +1 -0
- package/src/commands/create.ts +35 -8
- package/src/commands/get.ts +1 -1
- package/src/commands/globalOptions.ts +13 -13
- package/src/commands/import.ts +7 -2
- package/src/commands/index.ts +1 -3
- package/src/commands/login.ts +2 -1
- package/src/localisation/en-GB.ts +78 -38
- package/src/providers/file-provider.ts +2 -1
- package/src/services/ContensisCliService.ts +115 -43
- package/src/shell.ts +5 -2
- package/src/util/console.printer.ts +82 -67
- package/src/version.ts +1 -1
|
@@ -93,10 +93,20 @@ export const LogMessages = {
|
|
|
93
93
|
projects: {
|
|
94
94
|
list: () => `Available projects:`,
|
|
95
95
|
noList: () => `Cannot retrieve projects list`,
|
|
96
|
-
set: (projectId: string) =>
|
|
97
|
-
|
|
96
|
+
set: (projectId: string) =>
|
|
97
|
+
`Current project is set to ${Logger.highlightText(projectId)}`,
|
|
98
|
+
failedSet: (projectId: string) =>
|
|
99
|
+
`Project ${Logger.highlightText(projectId)} not found`,
|
|
98
100
|
tip: () =>
|
|
99
101
|
`You need to set your current working project with "set project {projectId}"`,
|
|
102
|
+
created: (env: string, id: string) =>
|
|
103
|
+
`[${env}] Created project ${Logger.highlightText(id)}`,
|
|
104
|
+
failedCreate: (env: string, id: string) =>
|
|
105
|
+
`[${env}] Unable to create project ${Logger.highlightText(id)}`,
|
|
106
|
+
updated: (env: string, id: string) =>
|
|
107
|
+
`[${env}] Updated project ${Logger.highlightText(id)}`,
|
|
108
|
+
failedUpdate: (env: string, id: string) =>
|
|
109
|
+
`[${env}] Unable to update project ${Logger.highlightText(id)}`,
|
|
100
110
|
},
|
|
101
111
|
migrate: {
|
|
102
112
|
models: {
|
|
@@ -132,38 +142,46 @@ export const LogMessages = {
|
|
|
132
142
|
},
|
|
133
143
|
},
|
|
134
144
|
models: {
|
|
135
|
-
list: (projectId: string) =>
|
|
145
|
+
list: (projectId: string) =>
|
|
146
|
+
`Content models in ${Logger.highlightText(projectId)}:`,
|
|
136
147
|
noList: (projectId: string) =>
|
|
137
148
|
`[${projectId}] Cannot retrieve content models`,
|
|
138
149
|
get: (projectId: string, id: string) =>
|
|
139
150
|
`[${projectId}] Content models ${Logger.infoText(`[ ${id} ]`)}`,
|
|
140
151
|
failedGet: (projectId: string, id: string) =>
|
|
141
|
-
`[${projectId}] Unable to get content models
|
|
152
|
+
`[${projectId}] Unable to get content models ${Logger.highlightText(id)}`,
|
|
142
153
|
},
|
|
143
154
|
contenttypes: {
|
|
144
|
-
list: (projectId: string) =>
|
|
155
|
+
list: (projectId: string) =>
|
|
156
|
+
`Content types in ${Logger.highlightText(projectId)}:`,
|
|
145
157
|
get: (projectId: string, id: string) =>
|
|
146
|
-
`[${projectId}] Content type
|
|
158
|
+
`[${projectId}] Content type ${Logger.highlightText(id)}`,
|
|
147
159
|
failedGet: (projectId: string, id: string) =>
|
|
148
|
-
`[${projectId}] Unable to get content type
|
|
160
|
+
`[${projectId}] Unable to get content type ${Logger.highlightText(id)}`,
|
|
149
161
|
created: (projectId: string, id: string, status?: string) =>
|
|
150
|
-
`[${projectId}] Content type ${status}d
|
|
162
|
+
`[${projectId}] Content type ${status}d ${Logger.highlightText(id)}`,
|
|
151
163
|
removed: (env: string, id: string, commit: boolean) =>
|
|
152
|
-
`[${env}] ${
|
|
164
|
+
`[${env}] ${
|
|
165
|
+
commit ? `Deleted` : `Will delete`
|
|
166
|
+
} content type ${Logger.highlightText(id)}`,
|
|
153
167
|
failedRemove: (env: string, id: string) =>
|
|
154
|
-
`[${env}] Unable to delete content type
|
|
168
|
+
`[${env}] Unable to delete content type ${Logger.highlightText(id)}`,
|
|
155
169
|
},
|
|
156
170
|
components: {
|
|
157
|
-
list: (projectId: string) =>
|
|
158
|
-
|
|
171
|
+
list: (projectId: string) =>
|
|
172
|
+
`Components in ${Logger.highlightText(projectId)}:`,
|
|
173
|
+
get: (projectId: string, id: string) =>
|
|
174
|
+
`[${projectId}] Component ${Logger.highlightText(id)}`,
|
|
159
175
|
failedGet: (projectId: string, id: string) =>
|
|
160
|
-
`[${projectId}] Unable to get component
|
|
176
|
+
`[${projectId}] Unable to get component ${Logger.highlightText(id)}`,
|
|
161
177
|
created: (projectId: string, id: string, status?: string) =>
|
|
162
|
-
`[${projectId}] Component ${status}d
|
|
178
|
+
`[${projectId}] Component ${status}d ${Logger.highlightText(id)}`,
|
|
163
179
|
removed: (env: string, id: string, commit: boolean) =>
|
|
164
|
-
`[${env}] ${
|
|
180
|
+
`[${env}] ${
|
|
181
|
+
commit ? `Deleted` : `Will delete`
|
|
182
|
+
} component ${Logger.highlightText(id)}`,
|
|
165
183
|
failedRemove: (env: string, id: string) =>
|
|
166
|
-
`[${env}] Unable to delete component
|
|
184
|
+
`[${env}] Unable to delete component ${Logger.highlightText(id)}`,
|
|
167
185
|
},
|
|
168
186
|
version: {
|
|
169
187
|
set: (env: string, versionStatus: string) =>
|
|
@@ -174,23 +192,23 @@ export const LogMessages = {
|
|
|
174
192
|
`No Contensis environment set, connect to your Contensis cloud instance using "contensis connect {cms alias}"`,
|
|
175
193
|
},
|
|
176
194
|
entries: {
|
|
177
|
-
removed: (env: string,
|
|
178
|
-
`[${env}] ${commit ? `Deleted` : `Will delete`}
|
|
179
|
-
failedRemove: (env: string
|
|
180
|
-
|
|
181
|
-
notFound: (id: string) => `Entry "${id}" not found`,
|
|
195
|
+
removed: (env: string, commit: boolean) =>
|
|
196
|
+
`[${env}] ${commit ? `Deleted` : `Will delete`} entries`,
|
|
197
|
+
failedRemove: (env: string) => `[${env}] Unable to delete entries`,
|
|
198
|
+
notFound: (env: string) => `[${env}] Entries were not found`,
|
|
182
199
|
commitTip: () => ` Add --commit flag to commit the previewed changes`,
|
|
183
200
|
},
|
|
184
201
|
keys: {
|
|
185
202
|
list: (env: string) => `[${env}] API keys:`,
|
|
186
203
|
noList: (env: string) => `[${env}] Cannot retrieve API`,
|
|
187
204
|
created: (env: string, name: string) =>
|
|
188
|
-
`[${env}] Created API key
|
|
205
|
+
`[${env}] Created API key ${Logger.highlightText(name)}`,
|
|
189
206
|
failedCreate: (env: string, name: string) =>
|
|
190
|
-
`[${env}] Unable to create API key
|
|
191
|
-
removed: (env: string, id: string) =>
|
|
207
|
+
`[${env}] Unable to create API key ${Logger.highlightText(name)}`,
|
|
208
|
+
removed: (env: string, id: string) =>
|
|
209
|
+
`[${env}] Deleted API key ${Logger.highlightText(id)}`,
|
|
192
210
|
failedRemove: (env: string, id: string) =>
|
|
193
|
-
`[${env}] Unable to delete API key
|
|
211
|
+
`[${env}] Unable to delete API key ${Logger.highlightText(id)}`,
|
|
194
212
|
},
|
|
195
213
|
blocks: {
|
|
196
214
|
runningStatus: (status: BlockRunningStatus | 'broken') => {
|
|
@@ -216,34 +234,56 @@ export const LogMessages = {
|
|
|
216
234
|
noList: (env: string, projectId?: string) =>
|
|
217
235
|
`[${env}] Cannot retrieve blocks in project ${projectId}`,
|
|
218
236
|
getLogs: (id: string, branch: string, env: string, projectId?: string) =>
|
|
219
|
-
`[${env}] Requesting logs from block
|
|
237
|
+
`[${env}] Requesting logs from block ${Logger.highlightText(
|
|
238
|
+
id
|
|
239
|
+
)} in branch ${branch} in project ${projectId}`,
|
|
220
240
|
failedGetLogs: (id: string, env: string, projectId?: string) =>
|
|
221
|
-
`[${env}] Unable to fetch block logs for
|
|
241
|
+
`[${env}] Unable to fetch block logs for ${Logger.highlightText(
|
|
242
|
+
id
|
|
243
|
+
)} in project ${projectId}`,
|
|
222
244
|
tryPush: (id: string, branch: string, env: string, projectId?: string) =>
|
|
223
|
-
`[${env}] Request to push block
|
|
245
|
+
`[${env}] Request to push block ${Logger.highlightText(
|
|
246
|
+
id
|
|
247
|
+
)} in branch ${branch} in project ${projectId}`,
|
|
224
248
|
pushed: (id: string, branch: string, env: string, projectId?: string) =>
|
|
225
|
-
`[${env}] Pushed block
|
|
249
|
+
`[${env}] Pushed block ${Logger.highlightText(
|
|
250
|
+
id
|
|
251
|
+
)} in branch ${branch} in project ${projectId}`,
|
|
226
252
|
failedPush: (id: string, env: string, projectId?: string) =>
|
|
227
|
-
`[${env}] Unable to push block
|
|
253
|
+
`[${env}] Unable to push block ${Logger.highlightText(
|
|
254
|
+
id
|
|
255
|
+
)} in project ${projectId}`,
|
|
228
256
|
released: (id: string, env: string, projectId?: string) =>
|
|
229
|
-
`[${env}] Released block
|
|
257
|
+
`[${env}] Released block ${Logger.highlightText(
|
|
258
|
+
id
|
|
259
|
+
)} in project ${projectId}`,
|
|
230
260
|
failedRelease: (id: string, env: string, projectId?: string) =>
|
|
231
|
-
`[${env}] Unable to release block
|
|
261
|
+
`[${env}] Unable to release block ${Logger.highlightText(
|
|
262
|
+
id
|
|
263
|
+
)} in project ${projectId}`,
|
|
232
264
|
deleted: (id: string, env: string, projectId?: string) =>
|
|
233
|
-
`[${env}] Deleted block
|
|
265
|
+
`[${env}] Deleted block ${Logger.highlightText(
|
|
266
|
+
id
|
|
267
|
+
)} in project ${projectId}`,
|
|
234
268
|
failedDelete: (id: string, env: string, projectId?: string) =>
|
|
235
|
-
`[${env}] Unable to delete block
|
|
269
|
+
`[${env}] Unable to delete block ${Logger.highlightText(
|
|
270
|
+
id
|
|
271
|
+
)} in project ${projectId}`,
|
|
236
272
|
},
|
|
237
273
|
webhooks: {
|
|
238
274
|
list: (env: string) => `[${env}] Webhook subscriptions:`,
|
|
239
275
|
noList: (env: string) => `[${env}] Cannot retrieve webhook subscriptions`,
|
|
240
276
|
created: (env: string, name: string) =>
|
|
241
|
-
`[${env}] Created Webhook subscription
|
|
277
|
+
`[${env}] Created Webhook subscription ${Logger.highlightText(name)}`,
|
|
242
278
|
failedCreate: (env: string, name: string) =>
|
|
243
|
-
`[${env}] Unable to create Webhook subscription
|
|
279
|
+
`[${env}] Unable to create Webhook subscription ${Logger.highlightText(
|
|
280
|
+
name
|
|
281
|
+
)}`,
|
|
244
282
|
deleted: (env: string, id: string) =>
|
|
245
|
-
`[${env}] Deleted Webhook subscription
|
|
283
|
+
`[${env}] Deleted Webhook subscription ${Logger.highlightText(id)}`,
|
|
246
284
|
failedDelete: (env: string, id: string) =>
|
|
247
|
-
`[${env}] Unable to delete Webhook subscription
|
|
285
|
+
`[${env}] Unable to delete Webhook subscription ${Logger.highlightText(
|
|
286
|
+
id
|
|
287
|
+
)}`,
|
|
248
288
|
},
|
|
249
289
|
};
|
|
@@ -69,4 +69,5 @@ export const checkDir = (filePath: string) => {
|
|
|
69
69
|
fs.mkdirSync(directoryPath, { recursive: true });
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
export const localPath = (filePath: string) =>
|
|
72
|
+
export const localPath = (filePath: string) =>
|
|
73
|
+
path.isAbsolute(filePath) ? filePath : path.join(appRoot, filePath);
|
|
@@ -3,7 +3,8 @@ import path from 'path';
|
|
|
3
3
|
import fetch from 'node-fetch';
|
|
4
4
|
import inquirer from 'inquirer';
|
|
5
5
|
import to from 'await-to-js';
|
|
6
|
-
import
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import { Component, ContentType, Project } from 'contensis-core-api';
|
|
7
8
|
import { isPassword, isSharedSecret, isUuid, url } from '~/util';
|
|
8
9
|
import SessionCacheProvider from '../providers/SessionCacheProvider';
|
|
9
10
|
import ContensisAuthService from './ContensisAuthService';
|
|
@@ -371,8 +372,7 @@ class ContensisCli {
|
|
|
371
372
|
},
|
|
372
373
|
!commit
|
|
373
374
|
);
|
|
374
|
-
}
|
|
375
|
-
if (source === 'contensis') {
|
|
375
|
+
} else if (source === 'contensis') {
|
|
376
376
|
this.contensis = new ContensisMigrationService(
|
|
377
377
|
{
|
|
378
378
|
concurrency: 3,
|
|
@@ -414,7 +414,7 @@ class ContensisCli {
|
|
|
414
414
|
currentEnv = this.currentEnv,
|
|
415
415
|
saveCurrentEnv = true
|
|
416
416
|
): Promise<CredentialProvider | undefined> => {
|
|
417
|
-
const {
|
|
417
|
+
const { log, messages } = this;
|
|
418
418
|
if (userId) {
|
|
419
419
|
const [credentialError, credentials] = await new CredentialProvider(
|
|
420
420
|
{ userId, alias: currentEnv },
|
|
@@ -433,6 +433,7 @@ class ContensisCli {
|
|
|
433
433
|
insecurePasswordWarningShown = true;
|
|
434
434
|
}
|
|
435
435
|
} else {
|
|
436
|
+
const env = this.cache.environments[currentEnv];
|
|
436
437
|
env.passwordFallback = undefined;
|
|
437
438
|
this.session.UpdateEnv(env, currentEnv, saveCurrentEnv);
|
|
438
439
|
}
|
|
@@ -602,13 +603,31 @@ class ContensisCli {
|
|
|
602
603
|
});
|
|
603
604
|
|
|
604
605
|
log.success(messages.projects.list());
|
|
606
|
+
log.raw('');
|
|
607
|
+
|
|
605
608
|
this.HandleFormattingAndOutput(projects, () => {
|
|
606
609
|
// print the projects to console
|
|
607
|
-
for (const project of projects)
|
|
610
|
+
for (const project of projects.sort((a, b) =>
|
|
611
|
+
a.id.localeCompare(b.id)
|
|
612
|
+
)) {
|
|
613
|
+
let color;
|
|
614
|
+
try {
|
|
615
|
+
color = chalk.keyword((project as any).color);
|
|
616
|
+
} catch (ex) {
|
|
617
|
+
color = chalk.white;
|
|
618
|
+
}
|
|
608
619
|
console.log(
|
|
609
|
-
|
|
610
|
-
project.
|
|
611
|
-
|
|
620
|
+
`${
|
|
621
|
+
nextCurrentProject === project.id
|
|
622
|
+
? `>> ${log.boldText(color(project.id))}`
|
|
623
|
+
: ` ${color(project.id)}`
|
|
624
|
+
} ${log.infoText(
|
|
625
|
+
`[${project.supportedLanguages
|
|
626
|
+
.map(l =>
|
|
627
|
+
l === project.primaryLanguage ? `*${log.boldText(l)}` : l
|
|
628
|
+
)
|
|
629
|
+
.join(' ')}]`
|
|
630
|
+
)}`
|
|
612
631
|
);
|
|
613
632
|
}
|
|
614
633
|
});
|
|
@@ -635,6 +654,7 @@ class ContensisCli {
|
|
|
635
654
|
env.currentProject = nextProjectId;
|
|
636
655
|
session.UpdateEnv(env);
|
|
637
656
|
log.success(messages.projects.set(projectId));
|
|
657
|
+
log.raw('');
|
|
638
658
|
} else {
|
|
639
659
|
log.error(messages.projects.failedSet(projectId));
|
|
640
660
|
}
|
|
@@ -766,6 +786,54 @@ class ContensisCli {
|
|
|
766
786
|
}
|
|
767
787
|
};
|
|
768
788
|
|
|
789
|
+
CreateProject = async (project: Project) => {
|
|
790
|
+
const { currentEnv, log, messages } = this;
|
|
791
|
+
const contensis = await this.ConnectContensis();
|
|
792
|
+
|
|
793
|
+
if (contensis) {
|
|
794
|
+
const [err, created] = await contensis.projects.CreateProject(project);
|
|
795
|
+
|
|
796
|
+
if (created) {
|
|
797
|
+
log.success(messages.projects.created(currentEnv, project.id));
|
|
798
|
+
|
|
799
|
+
this.HandleFormattingAndOutput(created, () => {
|
|
800
|
+
// set the CLI project to the newly created project
|
|
801
|
+
this.SetProject(project.id);
|
|
802
|
+
// print all the projects to console
|
|
803
|
+
this.PrintProjects();
|
|
804
|
+
});
|
|
805
|
+
return project.id;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
if (err) {
|
|
809
|
+
log.error(messages.projects.failedCreate(currentEnv, project.id), err);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
};
|
|
813
|
+
|
|
814
|
+
UpdateProject = async (project: Project) => {
|
|
815
|
+
const { currentEnv, log, messages } = this;
|
|
816
|
+
const contensis = await this.ConnectContensis();
|
|
817
|
+
|
|
818
|
+
if (contensis) {
|
|
819
|
+
const [err, updated] = await contensis.projects.UpdateProject(project);
|
|
820
|
+
|
|
821
|
+
if (updated) {
|
|
822
|
+
log.success(messages.projects.updated(currentEnv, project.id));
|
|
823
|
+
|
|
824
|
+
this.HandleFormattingAndOutput(updated, () => {
|
|
825
|
+
// print the projects to console
|
|
826
|
+
this.PrintProjects();
|
|
827
|
+
});
|
|
828
|
+
return project.id;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
if (err) {
|
|
832
|
+
log.error(messages.projects.failedUpdate(currentEnv, project.id), err);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
|
|
769
837
|
GetContentTypes = async () => {
|
|
770
838
|
const { currentProject, log, messages } = this;
|
|
771
839
|
let err;
|
|
@@ -824,43 +892,47 @@ class ContensisCli {
|
|
|
824
892
|
log.raw('');
|
|
825
893
|
log.object(model);
|
|
826
894
|
}
|
|
895
|
+
log.raw('');
|
|
827
896
|
});
|
|
828
897
|
} else {
|
|
829
898
|
log.success(
|
|
830
899
|
messages.models.get(currentProject, models?.length.toString() || '0')
|
|
831
900
|
);
|
|
832
|
-
this.HandleFormattingAndOutput(contentModelBackup, () => {
|
|
833
|
-
// print the content models s#qto console
|
|
834
|
-
log.raw('');
|
|
835
|
-
for (const model of models || []) {
|
|
836
|
-
const components = model.components?.length || 0;
|
|
837
|
-
const contentTypes = model.contentTypes?.length || 0;
|
|
838
|
-
const dependencies =
|
|
839
|
-
(model.dependencies?.components?.length || 0) +
|
|
840
|
-
(model.dependencies?.contentTypes?.length || 0);
|
|
841
|
-
const dependencyOf =
|
|
842
|
-
(model.dependencyOf?.components?.length || 0) +
|
|
843
|
-
(model.dependencyOf?.contentTypes?.length || 0);
|
|
844
|
-
|
|
845
|
-
const hasAny =
|
|
846
|
-
components + contentTypes + dependencies + dependencyOf;
|
|
847
|
-
log.raw(
|
|
848
|
-
` - ${log.highlightText(log.boldText(model.id))} ${
|
|
849
|
-
hasAny
|
|
850
|
-
? log.infoText(
|
|
851
|
-
`{ ${components ? `components: ${components}, ` : ''}${
|
|
852
|
-
contentTypes ? `contentTypes: ${contentTypes}, ` : ''
|
|
853
|
-
}${dependencies ? `references: ${dependencies}, ` : ''}${
|
|
854
|
-
dependencyOf ? `required by: ${dependencyOf}` : ''
|
|
855
|
-
} }`
|
|
856
|
-
)
|
|
857
|
-
: ''
|
|
858
|
-
}`
|
|
859
|
-
);
|
|
860
|
-
}
|
|
861
|
-
});
|
|
862
|
-
|
|
863
901
|
log.raw('');
|
|
902
|
+
if (models?.length) {
|
|
903
|
+
this.HandleFormattingAndOutput(contentModelBackup, () => {
|
|
904
|
+
// print the content models s#qto console
|
|
905
|
+
for (const model of models) {
|
|
906
|
+
const components = model.components?.length || 0;
|
|
907
|
+
const contentTypes = model.contentTypes?.length || 0;
|
|
908
|
+
const dependencies =
|
|
909
|
+
(model.dependencies?.components?.length || 0) +
|
|
910
|
+
(model.dependencies?.contentTypes?.length || 0);
|
|
911
|
+
const dependencyOf =
|
|
912
|
+
(model.dependencyOf?.components?.length || 0) +
|
|
913
|
+
(model.dependencyOf?.contentTypes?.length || 0);
|
|
914
|
+
|
|
915
|
+
const hasAny =
|
|
916
|
+
components + contentTypes + dependencies + dependencyOf;
|
|
917
|
+
log.raw(
|
|
918
|
+
` - ${log.highlightText(log.boldText(model.id))} ${
|
|
919
|
+
hasAny
|
|
920
|
+
? log.infoText(
|
|
921
|
+
`{ ${components ? `components: ${components}, ` : ''}${
|
|
922
|
+
contentTypes ? `contentTypes: ${contentTypes}, ` : ''
|
|
923
|
+
}${
|
|
924
|
+
dependencies ? `references: ${dependencies}, ` : ''
|
|
925
|
+
}${
|
|
926
|
+
dependencyOf ? `required by: ${dependencyOf}` : ''
|
|
927
|
+
} }`
|
|
928
|
+
)
|
|
929
|
+
: ''
|
|
930
|
+
}`
|
|
931
|
+
);
|
|
932
|
+
}
|
|
933
|
+
log.raw('');
|
|
934
|
+
});
|
|
935
|
+
}
|
|
864
936
|
}
|
|
865
937
|
}
|
|
866
938
|
};
|
|
@@ -1242,7 +1314,7 @@ class ContensisCli {
|
|
|
1242
1314
|
}
|
|
1243
1315
|
};
|
|
1244
1316
|
|
|
1245
|
-
|
|
1317
|
+
RemoveEntries = async (commit = false) => {
|
|
1246
1318
|
const { currentEnv, log, messages } = this;
|
|
1247
1319
|
const contensis = await this.ConnectContensisImport({
|
|
1248
1320
|
commit,
|
|
@@ -1267,12 +1339,12 @@ class ContensisCli {
|
|
|
1267
1339
|
Object.values(result.entriesToMigrate)?.[0].totalCount > 0) ||
|
|
1268
1340
|
(commit && result.migrateResult?.deleted))
|
|
1269
1341
|
) {
|
|
1270
|
-
log.success(messages.entries.removed(currentEnv,
|
|
1342
|
+
log.success(messages.entries.removed(currentEnv, commit));
|
|
1271
1343
|
if (!commit) log.help(messages.entries.commitTip());
|
|
1272
1344
|
} else {
|
|
1273
|
-
log.error(messages.entries.failedRemove(currentEnv
|
|
1345
|
+
log.error(messages.entries.failedRemove(currentEnv), err);
|
|
1274
1346
|
if (!Object.values(result.entriesToMigrate)?.[0].totalCount)
|
|
1275
|
-
log.help(messages.entries.notFound(
|
|
1347
|
+
log.help(messages.entries.notFound(currentEnv));
|
|
1276
1348
|
}
|
|
1277
1349
|
}
|
|
1278
1350
|
};
|
package/src/shell.ts
CHANGED
|
@@ -135,6 +135,7 @@ class ContensisShell {
|
|
|
135
135
|
availableCommands.push('login', 'list projects', 'set project');
|
|
136
136
|
if (userId)
|
|
137
137
|
availableCommands.push(
|
|
138
|
+
'create project',
|
|
138
139
|
'diff models',
|
|
139
140
|
'get block',
|
|
140
141
|
'get block logs',
|
|
@@ -157,9 +158,11 @@ class ContensisShell {
|
|
|
157
158
|
'push block',
|
|
158
159
|
'release block',
|
|
159
160
|
'remove key',
|
|
160
|
-
'remove
|
|
161
|
+
'remove entries',
|
|
161
162
|
'remove contenttypes',
|
|
162
|
-
'remove components'
|
|
163
|
+
'remove components',
|
|
164
|
+
'set project name',
|
|
165
|
+
'set project description'
|
|
163
166
|
);
|
|
164
167
|
|
|
165
168
|
const prompt = inquirer.createPromptModule();
|
|
@@ -109,53 +109,9 @@ export const printMigrateResult = (
|
|
|
109
109
|
migrateResult: any,
|
|
110
110
|
{ action = 'import' }: { action?: 'import' | 'delete' } = {}
|
|
111
111
|
) => {
|
|
112
|
-
|
|
112
|
+
if (Object.keys(migrateResult.entriesToMigrate.entryIds).length)
|
|
113
|
+
console.log(``);
|
|
113
114
|
|
|
114
|
-
if (action === 'import') {
|
|
115
|
-
for (const [projectId, contentTypeCounts] of Object.entries(
|
|
116
|
-
migrateResult.entries || {}
|
|
117
|
-
) as [string, any][]) {
|
|
118
|
-
console.log(
|
|
119
|
-
`import from project ${log.highlightText(projectId)} to ${log.boldText(
|
|
120
|
-
log.successText(currentProject)
|
|
121
|
-
)}`
|
|
122
|
-
);
|
|
123
|
-
for (const [contentTypeId, count] of Object.entries(
|
|
124
|
-
contentTypeCounts
|
|
125
|
-
) as [string, number][]) {
|
|
126
|
-
const entriesToMigrate =
|
|
127
|
-
migrateResult.entriesToMigrate?.[projectId]?.[contentTypeId];
|
|
128
|
-
|
|
129
|
-
console.log(
|
|
130
|
-
` - ${
|
|
131
|
-
contentTypeId === 'totalCount'
|
|
132
|
-
? log.warningText(`${contentTypeId}: ${count}`)
|
|
133
|
-
: log.helpText(`${contentTypeId}: ${count}`)
|
|
134
|
-
} ${log.infoText`[existing: ${(
|
|
135
|
-
((migrateResult.existing?.[projectId]?.[contentTypeId] || 0) /
|
|
136
|
-
count) *
|
|
137
|
-
100
|
|
138
|
-
).toFixed(0)}%]`} [${
|
|
139
|
-
typeof entriesToMigrate !== 'number' ? `unchanged` : `to update`
|
|
140
|
-
}: ${(
|
|
141
|
-
((typeof entriesToMigrate !== 'number'
|
|
142
|
-
? entriesToMigrate?.['no change'] || 0
|
|
143
|
-
: entriesToMigrate) /
|
|
144
|
-
count) *
|
|
145
|
-
100
|
|
146
|
-
).toFixed(0)}%]`
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
console.log(``);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
if (
|
|
153
|
-
contensis?.isPreview &&
|
|
154
|
-
migrateResult.entriesToMigrate?.[currentProject]?.totalCount > 0 &&
|
|
155
|
-
!migrateResult.errors
|
|
156
|
-
) {
|
|
157
|
-
log.help(messages.entries.commitTip());
|
|
158
|
-
}
|
|
159
115
|
for (const [contentTypeId, entryRes] of Object.entries(
|
|
160
116
|
migrateResult.entriesToMigrate.entryIds
|
|
161
117
|
) as [string, any]) {
|
|
@@ -163,9 +119,10 @@ export const printMigrateResult = (
|
|
|
163
119
|
string,
|
|
164
120
|
any
|
|
165
121
|
][]) {
|
|
122
|
+
console.log(`${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`);
|
|
166
123
|
console.log(
|
|
167
124
|
log.infoText(
|
|
168
|
-
|
|
125
|
+
` ${originalId} ${Object.entries(entryStatus || {})
|
|
169
126
|
.filter(x => x[0] !== 'entryTitle')
|
|
170
127
|
.map(([projectId, projectStatus]) => {
|
|
171
128
|
const [targetGuid, { status }] = (Object.entries(
|
|
@@ -174,13 +131,12 @@ export const printMigrateResult = (
|
|
|
174
131
|
'',
|
|
175
132
|
{ x: { status: undefined } },
|
|
176
133
|
];
|
|
177
|
-
return `${messages.migrate.status(status)(
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
})}
|
|
134
|
+
return `${messages.migrate.status(status)(`${status}`)}${
|
|
135
|
+
targetGuid !== originalId ? `-> ${targetGuid}` : ''
|
|
136
|
+
}`;
|
|
137
|
+
})}`
|
|
181
138
|
)
|
|
182
139
|
);
|
|
183
|
-
console.log(` ${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`);
|
|
184
140
|
|
|
185
141
|
for (const [projectId, projectStatus] of Object.entries(
|
|
186
142
|
entryStatus
|
|
@@ -191,16 +147,61 @@ export const printMigrateResult = (
|
|
|
191
147
|
if (error) log.error(error);
|
|
192
148
|
if (diff) {
|
|
193
149
|
console.log(
|
|
194
|
-
`
|
|
195
|
-
|
|
196
|
-
)}
|
|
150
|
+
` ${log.highlightText(`diff:`)} ${log.infoText(
|
|
151
|
+
highlightDiffText(diff)
|
|
152
|
+
)}\n`
|
|
197
153
|
);
|
|
198
|
-
console.log(``);
|
|
199
|
-
console.log(log.highlightText(diff));
|
|
200
154
|
}
|
|
201
155
|
}
|
|
202
156
|
}
|
|
157
|
+
console.log(``);
|
|
203
158
|
}
|
|
159
|
+
if (
|
|
160
|
+
contensis?.isPreview &&
|
|
161
|
+
migrateResult.entriesToMigrate?.[currentProject]?.totalCount > 0 &&
|
|
162
|
+
!migrateResult.errors
|
|
163
|
+
) {
|
|
164
|
+
log.help(messages.entries.commitTip());
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Needs work
|
|
168
|
+
// if (action === 'import') {
|
|
169
|
+
// for (const [projectId, contentTypeCounts] of Object.entries(
|
|
170
|
+
// migrateResult.entries || {}
|
|
171
|
+
// ) as [string, any][]) {
|
|
172
|
+
// console.log(
|
|
173
|
+
// `import from project ${log.highlightText(projectId)} to ${log.boldText(
|
|
174
|
+
// log.warningText(currentProject)
|
|
175
|
+
// )}`
|
|
176
|
+
// );
|
|
177
|
+
// for (const [contentTypeId, count] of Object.entries(
|
|
178
|
+
// contentTypeCounts
|
|
179
|
+
// ) as [string, number][]) {
|
|
180
|
+
// const entriesToMigrate =
|
|
181
|
+
// migrateResult.entriesToMigrate?.[projectId]?.[contentTypeId];
|
|
182
|
+
|
|
183
|
+
// console.log(
|
|
184
|
+
// ` - ${
|
|
185
|
+
// contentTypeId === 'totalCount'
|
|
186
|
+
// ? log.warningText(`${contentTypeId}: ${count}`)
|
|
187
|
+
// : `${contentTypeId}: ${log.helpText(count)}`
|
|
188
|
+
// } ${log.infoText`[existing: ${(
|
|
189
|
+
// ((migrateResult.existing?.[projectId]?.[contentTypeId] || 0) /
|
|
190
|
+
// count) *
|
|
191
|
+
// 100
|
|
192
|
+
// ).toFixed(0)}%]`} [${
|
|
193
|
+
// typeof entriesToMigrate !== 'number' ? `unchanged` : `to update`
|
|
194
|
+
// }: ${(
|
|
195
|
+
// ((typeof entriesToMigrate !== 'number'
|
|
196
|
+
// ? entriesToMigrate?.['no change'] || 0
|
|
197
|
+
// : entriesToMigrate) /
|
|
198
|
+
// count) *
|
|
199
|
+
// 100
|
|
200
|
+
// ).toFixed(0)}%]`
|
|
201
|
+
// );
|
|
202
|
+
// }
|
|
203
|
+
// }
|
|
204
|
+
// }
|
|
204
205
|
};
|
|
205
206
|
|
|
206
207
|
const highlightDiffText = (str: string) => {
|
|
@@ -253,13 +254,13 @@ export const printModelMigrationAnalysis = (
|
|
|
253
254
|
)}] v${projectDetails.versionNo}`
|
|
254
255
|
);
|
|
255
256
|
if (projectDetails.diff)
|
|
256
|
-
diffOutput += `
|
|
257
|
+
diffOutput += ` ${log.highlightText(`diff:`)} ${log.infoText(
|
|
257
258
|
highlightDiffText(projectDetails.diff)
|
|
258
259
|
)}\n`;
|
|
259
260
|
if (projectDetails.error)
|
|
260
|
-
errorOutput += `
|
|
261
|
-
|
|
262
|
-
)}`;
|
|
261
|
+
errorOutput += ` ${log.highlightText(
|
|
262
|
+
`error::`
|
|
263
|
+
)} ${log.errorText(projectDetails.error)}`;
|
|
263
264
|
}
|
|
264
265
|
}
|
|
265
266
|
}
|
|
@@ -290,11 +291,25 @@ export const printModelMigrationResult = (
|
|
|
290
291
|
MigrateResultStatus,
|
|
291
292
|
string[]
|
|
292
293
|
][]) {
|
|
293
|
-
if (ids?.length)
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
294
|
+
if (ids?.length) {
|
|
295
|
+
if (status === 'errors') {
|
|
296
|
+
const errors: [string, MappedError][] = ids as any;
|
|
297
|
+
log.raw(
|
|
298
|
+
` - ${status}: [ ${messages.migrate.models.result(status)(
|
|
299
|
+
ids.map(id => id[0]).join(', ')
|
|
300
|
+
)} ]\n`
|
|
301
|
+
);
|
|
302
|
+
for (const [contentTypeId, error] of errors)
|
|
303
|
+
log.error(
|
|
304
|
+
`${log.highlightText(contentTypeId)}: ${error.message}`,
|
|
305
|
+
error
|
|
306
|
+
);
|
|
307
|
+
} else
|
|
308
|
+
log.raw(
|
|
309
|
+
` - ${status}: [ ${messages.migrate.models.result(status)(
|
|
310
|
+
ids.join(', ')
|
|
311
|
+
)} ]`
|
|
312
|
+
);
|
|
313
|
+
}
|
|
299
314
|
}
|
|
300
315
|
};
|
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.41";
|