contensis-cli 1.3.1-beta.1 → 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 +77 -5
- package/dist/commands/copy.js +2 -2
- package/dist/commands/copy.js.map +2 -2
- package/dist/commands/globalOptions.js +13 -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 -0
- package/dist/commands/index.js.map +2 -2
- package/dist/commands/push.js +89 -0
- package/dist/commands/push.js.map +3 -3
- package/dist/commands/remove.js +13 -0
- package/dist/commands/remove.js.map +2 -2
- package/dist/commands/update.js +70 -0
- package/dist/commands/update.js.map +7 -0
- package/dist/localisation/en-GB.js +11 -1
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/models/CliService.d.js.map +1 -1
- package/dist/providers/CredentialProvider.js.map +2 -2
- package/dist/providers/SessionCacheProvider.js +18 -0
- package/dist/providers/SessionCacheProvider.js.map +2 -2
- package/dist/services/ContensisCliService.js +139 -45
- package/dist/services/ContensisCliService.js.map +3 -3
- package/dist/shell.js +21 -9
- package/dist/shell.js.map +2 -2
- package/dist/util/console.printer.js +3 -1
- package/dist/util/console.printer.js.map +2 -2
- package/dist/util/html.formatter.js +70 -0
- package/dist/util/html.formatter.js.map +7 -0
- package/dist/util/logger.js +2 -3
- package/dist/util/logger.js.map +2 -2
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/esbuild.config.js +3 -3
- package/package.json +28 -29
- 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/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 +255 -104
- package/src/shell.ts +20 -9
- package/src/util/console.printer.ts +23 -19
- package/src/util/html.formatter.ts +52 -0
- package/src/util/logger.ts +2 -2
- package/src/version.ts +1 -1
|
@@ -50,6 +50,7 @@ import {
|
|
|
50
50
|
printNodesMigrateResult,
|
|
51
51
|
} from '~/util/console.printer';
|
|
52
52
|
import { csvFormatter } from '~/util/csv.formatter';
|
|
53
|
+
import { htmlFormatter } from '~/util/html.formatter';
|
|
53
54
|
import { jsonFormatter, limitFields } from '~/util/json.formatter';
|
|
54
55
|
import { xmlFormatter } from '~/util/xml.formatter';
|
|
55
56
|
import { isDebug } from '~/util/debug';
|
|
@@ -107,7 +108,7 @@ class ContensisCli {
|
|
|
107
108
|
const environments = this.cache.environments || {};
|
|
108
109
|
|
|
109
110
|
if (!currentEnvironment) return {} as EnvironmentCache;
|
|
110
|
-
else if (
|
|
111
|
+
else if (environments[currentEnvironment])
|
|
111
112
|
return environments[currentEnvironment];
|
|
112
113
|
else {
|
|
113
114
|
return {
|
|
@@ -132,8 +133,9 @@ class ContensisCli {
|
|
|
132
133
|
this.noun = noun?.toLowerCase();
|
|
133
134
|
this.thirdArg = restArgs?.[0];
|
|
134
135
|
|
|
135
|
-
const commandText = `${this.verb} ${this.noun} ${
|
|
136
|
-
|
|
136
|
+
const commandText = `${this.verb} ${this.noun} ${
|
|
137
|
+
restArgs ? restArgs.join(' ') : ''
|
|
138
|
+
}`.trim();
|
|
137
139
|
|
|
138
140
|
this.session = new SessionCacheProvider();
|
|
139
141
|
|
|
@@ -198,7 +200,7 @@ class ContensisCli {
|
|
|
198
200
|
PrintEnvironments = async () => {
|
|
199
201
|
const { log, messages } = this;
|
|
200
202
|
const { currentEnvironment, environments = {} } = this.cache;
|
|
201
|
-
const envKeys = Object.keys(environments);
|
|
203
|
+
const envKeys = Object.keys(environments).sort();
|
|
202
204
|
log.success(messages.envs.found(envKeys.length));
|
|
203
205
|
await this.HandleFormattingAndOutput(envKeys, () => {
|
|
204
206
|
// print the envKeys to console
|
|
@@ -211,6 +213,38 @@ class ContensisCli {
|
|
|
211
213
|
}
|
|
212
214
|
};
|
|
213
215
|
|
|
216
|
+
RemoveEnvironment = async (env: string) => {
|
|
217
|
+
const { log, messages, session } = this;
|
|
218
|
+
const { currentEnvironment, environments = {} } = this.cache;
|
|
219
|
+
const envKeys = Object.keys(environments);
|
|
220
|
+
log.success(messages.envs.found(envKeys.length));
|
|
221
|
+
if (environments[env]) {
|
|
222
|
+
// remove env from cache
|
|
223
|
+
session.RemoveEnv(env);
|
|
224
|
+
// remove credentials
|
|
225
|
+
const lastUserId = environments[env].lastUserId;
|
|
226
|
+
if (lastUserId) {
|
|
227
|
+
const [err, credentials] = await new CredentialProvider({
|
|
228
|
+
userId: environments[env].lastUserId,
|
|
229
|
+
alias: env,
|
|
230
|
+
}).Init();
|
|
231
|
+
if (!err && credentials) await credentials.Delete();
|
|
232
|
+
}
|
|
233
|
+
log.success(messages.envs.removed(env));
|
|
234
|
+
// support the output and format options - exporting the history for the
|
|
235
|
+
// removed alias
|
|
236
|
+
await this.HandleFormattingAndOutput(environments[env], () => log.line());
|
|
237
|
+
} else {
|
|
238
|
+
log.warning(messages.envs.notFound(env));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const nextCurrentEnv =
|
|
242
|
+
currentEnvironment === env ? undefined : currentEnvironment;
|
|
243
|
+
if (envKeys.length === 0 || !nextCurrentEnv) log.help(messages.envs.tip());
|
|
244
|
+
|
|
245
|
+
return nextCurrentEnv;
|
|
246
|
+
};
|
|
247
|
+
|
|
214
248
|
Connect = async (environment: string) => {
|
|
215
249
|
const { log, messages, session } = this;
|
|
216
250
|
|
|
@@ -291,20 +325,24 @@ class ContensisCli {
|
|
|
291
325
|
commit = false,
|
|
292
326
|
fromFile,
|
|
293
327
|
importDataType,
|
|
328
|
+
importData,
|
|
294
329
|
}: {
|
|
295
330
|
commit?: boolean;
|
|
296
331
|
fromFile?: string;
|
|
297
332
|
importDataType?:
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
333
|
+
| 'entries'
|
|
334
|
+
| 'contentTypes'
|
|
335
|
+
| 'components'
|
|
336
|
+
| 'models'
|
|
337
|
+
| 'nodes'
|
|
338
|
+
| 'user-input';
|
|
339
|
+
importData?: any[];
|
|
304
340
|
}) => {
|
|
305
|
-
const source: 'contensis' | 'file' =
|
|
341
|
+
const source: 'contensis' | 'file' =
|
|
342
|
+
fromFile || importData ? 'file' : 'contensis';
|
|
306
343
|
|
|
307
|
-
const fileData =
|
|
344
|
+
const fileData =
|
|
345
|
+
importData || (fromFile ? (await readFileAsJSON(fromFile)) || [] : []);
|
|
308
346
|
|
|
309
347
|
if (typeof fileData === 'string')
|
|
310
348
|
throw new Error(`Import file format must be of type JSON`);
|
|
@@ -589,7 +627,7 @@ class ContensisCli {
|
|
|
589
627
|
if (contensis) {
|
|
590
628
|
// Retrieve token for env
|
|
591
629
|
const [error, token] = await to(
|
|
592
|
-
contensis.content.
|
|
630
|
+
contensis.content.source.repo.BearerToken()
|
|
593
631
|
);
|
|
594
632
|
if (token) {
|
|
595
633
|
// Print bearer token to console
|
|
@@ -645,9 +683,10 @@ class ContensisCli {
|
|
|
645
683
|
color = chalk.white;
|
|
646
684
|
}
|
|
647
685
|
console.log(
|
|
648
|
-
`${
|
|
649
|
-
|
|
650
|
-
|
|
686
|
+
`${
|
|
687
|
+
nextCurrentProject === project.id
|
|
688
|
+
? `>> ${log.boldText(color(project.id))}`
|
|
689
|
+
: ` ${color(project.id)}`
|
|
651
690
|
} ${log.infoText(
|
|
652
691
|
`[${project.supportedLanguages
|
|
653
692
|
.map(l =>
|
|
@@ -762,7 +801,8 @@ class ContensisCli {
|
|
|
762
801
|
modifiedBy,
|
|
763
802
|
} of apiKeys) {
|
|
764
803
|
console.log(
|
|
765
|
-
` - ${name}${
|
|
804
|
+
` - ${name}${
|
|
805
|
+
description ? ` (${description})` : ''
|
|
766
806
|
} [${dateModified.toString().substring(0, 10)} ${modifiedBy}]`
|
|
767
807
|
);
|
|
768
808
|
console.log(` ${id}`);
|
|
@@ -1039,7 +1079,7 @@ class ContensisCli {
|
|
|
1039
1079
|
if (contensis) {
|
|
1040
1080
|
// Retrieve workflows list for env
|
|
1041
1081
|
const [workflowsErr, workflows] =
|
|
1042
|
-
await contensis.content.
|
|
1082
|
+
await contensis.content.source.workflows.GetWorkflows();
|
|
1043
1083
|
|
|
1044
1084
|
if (Array.isArray(workflows)) {
|
|
1045
1085
|
log.success(messages.workflows.list(currentEnv));
|
|
@@ -1105,7 +1145,7 @@ class ContensisCli {
|
|
|
1105
1145
|
if (contensis) {
|
|
1106
1146
|
// Retrieve workflows list for env
|
|
1107
1147
|
const [workflowsErr, workflows] =
|
|
1108
|
-
await contensis.content.
|
|
1148
|
+
await contensis.content.source.workflows.GetWorkflows();
|
|
1109
1149
|
|
|
1110
1150
|
if (Array.isArray(workflows)) {
|
|
1111
1151
|
log.success(messages.workflows.list(currentEnv));
|
|
@@ -1191,8 +1231,8 @@ class ContensisCli {
|
|
|
1191
1231
|
// Models to output to console
|
|
1192
1232
|
const returnModels = modelIds?.length
|
|
1193
1233
|
? models?.filter((m: Model) =>
|
|
1194
|
-
|
|
1195
|
-
|
|
1234
|
+
modelIds.some(id => id.toLowerCase() === m.id.toLowerCase())
|
|
1235
|
+
)
|
|
1196
1236
|
: undefined;
|
|
1197
1237
|
const exportResources: (ContentType | Component)[] = [];
|
|
1198
1238
|
|
|
@@ -1278,17 +1318,22 @@ class ContensisCli {
|
|
|
1278
1318
|
const hasAny =
|
|
1279
1319
|
components + contentTypes + dependencies + dependencyOf;
|
|
1280
1320
|
log.raw(
|
|
1281
|
-
` - ${log.highlightText(log.boldText(model.id))} ${
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1321
|
+
` - ${log.highlightText(log.boldText(model.id))} ${
|
|
1322
|
+
hasAny
|
|
1323
|
+
? log.infoText(
|
|
1324
|
+
`{ ${
|
|
1325
|
+
components ? `components: ${components}, ` : ''
|
|
1326
|
+
}${
|
|
1327
|
+
contentTypes
|
|
1328
|
+
? `contentTypes: ${contentTypes}, `
|
|
1329
|
+
: ''
|
|
1330
|
+
}${defaults ? `defaults: ${defaults}, ` : ''}${
|
|
1331
|
+
dependencies ? `references: ${dependencies}, ` : ''
|
|
1332
|
+
}${
|
|
1333
|
+
dependencyOf ? `required by: ${dependencyOf}` : ''
|
|
1334
|
+
} }`
|
|
1335
|
+
)
|
|
1336
|
+
: ''
|
|
1292
1337
|
}`
|
|
1293
1338
|
);
|
|
1294
1339
|
}
|
|
@@ -1324,9 +1369,9 @@ class ContensisCli {
|
|
|
1324
1369
|
if (contensis) {
|
|
1325
1370
|
log.line();
|
|
1326
1371
|
if (contensis.isPreview) {
|
|
1327
|
-
|
|
1372
|
+
log.success(messages.migrate.preview());
|
|
1328
1373
|
} else {
|
|
1329
|
-
|
|
1374
|
+
log.warning(messages.migrate.commit());
|
|
1330
1375
|
}
|
|
1331
1376
|
|
|
1332
1377
|
const [migrateErr, result] = await contensis.MigrateContentModels();
|
|
@@ -1419,7 +1464,8 @@ class ContensisCli {
|
|
|
1419
1464
|
for (const contentType of contentTypes) {
|
|
1420
1465
|
const fieldsLength = contentType.fields?.length || 0;
|
|
1421
1466
|
console.log(
|
|
1422
|
-
` - ${contentType.id} [${fieldsLength} field${
|
|
1467
|
+
` - ${contentType.id} [${fieldsLength} field${
|
|
1468
|
+
fieldsLength !== 1 ? 's' : ''
|
|
1423
1469
|
}]`
|
|
1424
1470
|
);
|
|
1425
1471
|
}
|
|
@@ -1518,10 +1564,9 @@ class ContensisCli {
|
|
|
1518
1564
|
contentType.projectId = currentProject;
|
|
1519
1565
|
delete contentType.uuid;
|
|
1520
1566
|
|
|
1521
|
-
const [err, , createStatus] =
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
].repo.UpsertContentType(false, contentType);
|
|
1567
|
+
const [err, , createStatus] = await contensis.models.targets[
|
|
1568
|
+
currentProject
|
|
1569
|
+
].repo.UpsertContentType(false, contentType);
|
|
1525
1570
|
|
|
1526
1571
|
if (err) log.error(err.message, err);
|
|
1527
1572
|
if (createStatus) {
|
|
@@ -1533,7 +1578,7 @@ class ContensisCli {
|
|
|
1533
1578
|
)
|
|
1534
1579
|
);
|
|
1535
1580
|
// print the content type to console
|
|
1536
|
-
await this.HandleFormattingAndOutput(contentType, () => {
|
|
1581
|
+
await this.HandleFormattingAndOutput(contentType, () => {});
|
|
1537
1582
|
}
|
|
1538
1583
|
}
|
|
1539
1584
|
else {
|
|
@@ -1611,7 +1656,8 @@ class ContensisCli {
|
|
|
1611
1656
|
for (const component of components) {
|
|
1612
1657
|
const fieldsLength = component.fields?.length || 0;
|
|
1613
1658
|
console.log(
|
|
1614
|
-
` - ${component.id} [${fieldsLength} field${
|
|
1659
|
+
` - ${component.id} [${fieldsLength} field${
|
|
1660
|
+
fieldsLength !== 1 ? 's' : ''
|
|
1615
1661
|
}]`
|
|
1616
1662
|
);
|
|
1617
1663
|
}
|
|
@@ -1709,10 +1755,9 @@ class ContensisCli {
|
|
|
1709
1755
|
component.projectId = currentProject;
|
|
1710
1756
|
delete component.uuid;
|
|
1711
1757
|
|
|
1712
|
-
const [err, , createStatus] =
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
].repo.UpsertComponent(false, component);
|
|
1758
|
+
const [err, , createStatus] = await contensis.models.targets[
|
|
1759
|
+
currentProject
|
|
1760
|
+
].repo.UpsertComponent(false, component);
|
|
1716
1761
|
|
|
1717
1762
|
if (err) log.error(err.message, err);
|
|
1718
1763
|
if (createStatus) {
|
|
@@ -1724,7 +1769,7 @@ class ContensisCli {
|
|
|
1724
1769
|
)
|
|
1725
1770
|
);
|
|
1726
1771
|
// print the component to console
|
|
1727
|
-
await this.HandleFormattingAndOutput(component, () => {
|
|
1772
|
+
await this.HandleFormattingAndOutput(component, () => {});
|
|
1728
1773
|
}
|
|
1729
1774
|
}
|
|
1730
1775
|
else {
|
|
@@ -1793,15 +1838,23 @@ class ContensisCli {
|
|
|
1793
1838
|
// Add a full sys.uri to asset entries
|
|
1794
1839
|
// Add sys.metadata.exportCms
|
|
1795
1840
|
// Add sys.metadata.exportProjectId
|
|
1841
|
+
const nodes = contensis.content.source.nodes.raw;
|
|
1842
|
+
const combinedOutput = [...entries, ...nodes];
|
|
1796
1843
|
|
|
1797
|
-
await this.HandleFormattingAndOutput(
|
|
1844
|
+
await this.HandleFormattingAndOutput(combinedOutput, () => {
|
|
1798
1845
|
// print the entries to console
|
|
1799
1846
|
logEntitiesTable({
|
|
1800
1847
|
entries,
|
|
1801
1848
|
projectId: currentProject,
|
|
1802
1849
|
fields: contensis.payload.query?.fields,
|
|
1803
|
-
})
|
|
1804
|
-
|
|
1850
|
+
});
|
|
1851
|
+
if (nodes.length)
|
|
1852
|
+
logEntitiesTable({
|
|
1853
|
+
nodes,
|
|
1854
|
+
projectId: currentProject,
|
|
1855
|
+
fields: contensis.payload.query?.fields,
|
|
1856
|
+
});
|
|
1857
|
+
});
|
|
1805
1858
|
} else {
|
|
1806
1859
|
log.warning(messages.models.noList(currentProject));
|
|
1807
1860
|
log.help(messages.connect.tip());
|
|
@@ -1813,11 +1866,13 @@ class ContensisCli {
|
|
|
1813
1866
|
fromFile,
|
|
1814
1867
|
logOutput,
|
|
1815
1868
|
saveEntries,
|
|
1869
|
+
data,
|
|
1816
1870
|
}: {
|
|
1817
1871
|
commit: boolean;
|
|
1818
|
-
fromFile
|
|
1872
|
+
fromFile?: string;
|
|
1819
1873
|
logOutput: string;
|
|
1820
1874
|
saveEntries: boolean;
|
|
1875
|
+
data?: any[];
|
|
1821
1876
|
}) => {
|
|
1822
1877
|
const { currentEnv, currentProject, log, messages } = this;
|
|
1823
1878
|
|
|
@@ -1825,14 +1880,15 @@ class ContensisCli {
|
|
|
1825
1880
|
commit,
|
|
1826
1881
|
fromFile,
|
|
1827
1882
|
importDataType: 'entries',
|
|
1883
|
+
importData: data,
|
|
1828
1884
|
});
|
|
1829
1885
|
|
|
1830
1886
|
if (contensis) {
|
|
1831
1887
|
log.line();
|
|
1832
1888
|
if (contensis.isPreview) {
|
|
1833
|
-
|
|
1889
|
+
log.success(messages.migrate.preview());
|
|
1834
1890
|
} else {
|
|
1835
|
-
|
|
1891
|
+
log.warning(messages.migrate.commit());
|
|
1836
1892
|
}
|
|
1837
1893
|
|
|
1838
1894
|
const [err, result] = await contensis.MigrateEntries();
|
|
@@ -1842,7 +1898,11 @@ class ContensisCli {
|
|
|
1842
1898
|
const { entries, nodes } = contensis.content.targets[currentProject];
|
|
1843
1899
|
|
|
1844
1900
|
const output = saveEntries
|
|
1845
|
-
? entries
|
|
1901
|
+
? // include entries and dependent nodes when saving entries
|
|
1902
|
+
[
|
|
1903
|
+
entries.migrate?.map(me => me.toJSON()) || [],
|
|
1904
|
+
nodes.migrateNodes.map(mn => mn.node),
|
|
1905
|
+
].flat()
|
|
1846
1906
|
: result;
|
|
1847
1907
|
await this.HandleFormattingAndOutput(output, () => {
|
|
1848
1908
|
// print the migrateResult to console
|
|
@@ -1851,7 +1911,10 @@ class ContensisCli {
|
|
|
1851
1911
|
showDiff: logOutput === 'all' || logOutput === 'changes',
|
|
1852
1912
|
showChanged: logOutput === 'changes',
|
|
1853
1913
|
});
|
|
1854
|
-
if (
|
|
1914
|
+
if (
|
|
1915
|
+
['all', 'changes'].includes(logOutput) &&
|
|
1916
|
+
nodes.migrateNodes.length
|
|
1917
|
+
)
|
|
1855
1918
|
printNodeTreeOutput(
|
|
1856
1919
|
this,
|
|
1857
1920
|
{
|
|
@@ -1876,13 +1939,13 @@ class ContensisCli {
|
|
|
1876
1939
|
commit,
|
|
1877
1940
|
commit
|
|
1878
1941
|
? (result.migrateResult?.created || 0) +
|
|
1879
|
-
|
|
1942
|
+
(result.migrateResult?.updated || 0)
|
|
1880
1943
|
: result.entriesToMigrate[currentProject].totalCount,
|
|
1881
1944
|
commit
|
|
1882
1945
|
? (result.nodesResult?.created || 0) +
|
|
1883
|
-
|
|
1946
|
+
(result.nodesResult?.updated || 0)
|
|
1884
1947
|
: (result.nodesToMigrate?.[currentProject]
|
|
1885
|
-
|
|
1948
|
+
.totalCount as number) || 0
|
|
1886
1949
|
)
|
|
1887
1950
|
);
|
|
1888
1951
|
if (!commit) {
|
|
@@ -1922,9 +1985,9 @@ class ContensisCli {
|
|
|
1922
1985
|
if (contensis) {
|
|
1923
1986
|
log.line();
|
|
1924
1987
|
if (contensis.isPreview) {
|
|
1925
|
-
|
|
1988
|
+
log.success(messages.migrate.preview());
|
|
1926
1989
|
} else {
|
|
1927
|
-
|
|
1990
|
+
log.warning(messages.migrate.commit());
|
|
1928
1991
|
}
|
|
1929
1992
|
|
|
1930
1993
|
const [err, result] = await to(
|
|
@@ -1935,8 +1998,8 @@ class ContensisCli {
|
|
|
1935
1998
|
if (result) {
|
|
1936
1999
|
const output = saveEntries
|
|
1937
2000
|
? contensis.content.copy.targets[currentProject].entries.migrate?.map(
|
|
1938
|
-
|
|
1939
|
-
|
|
2001
|
+
me => me.toJSON()
|
|
2002
|
+
)
|
|
1940
2003
|
: result;
|
|
1941
2004
|
await this.HandleFormattingAndOutput(output, () => {
|
|
1942
2005
|
// print the migrateResult to console
|
|
@@ -1962,7 +2025,7 @@ class ContensisCli {
|
|
|
1962
2025
|
commit,
|
|
1963
2026
|
commit
|
|
1964
2027
|
? (result.migrateResult?.created || 0) +
|
|
1965
|
-
|
|
2028
|
+
(result.migrateResult?.updated || 0)
|
|
1966
2029
|
: result.entriesToMigrate[currentProject].totalCount
|
|
1967
2030
|
)
|
|
1968
2031
|
);
|
|
@@ -1981,6 +2044,87 @@ class ContensisCli {
|
|
|
1981
2044
|
}
|
|
1982
2045
|
};
|
|
1983
2046
|
|
|
2047
|
+
UpdateEntryField = async ({
|
|
2048
|
+
commit,
|
|
2049
|
+
fromFile,
|
|
2050
|
+
logOutput,
|
|
2051
|
+
saveEntries,
|
|
2052
|
+
}: {
|
|
2053
|
+
commit: boolean;
|
|
2054
|
+
fromFile: string;
|
|
2055
|
+
logOutput: string;
|
|
2056
|
+
saveEntries: boolean;
|
|
2057
|
+
}) => {
|
|
2058
|
+
const { currentEnv, currentProject, log, messages } = this;
|
|
2059
|
+
|
|
2060
|
+
const contensis = await this.ConnectContensisImport({
|
|
2061
|
+
commit,
|
|
2062
|
+
fromFile,
|
|
2063
|
+
importDataType: 'entries',
|
|
2064
|
+
});
|
|
2065
|
+
|
|
2066
|
+
if (contensis) {
|
|
2067
|
+
log.line();
|
|
2068
|
+
if (contensis.isPreview) {
|
|
2069
|
+
log.success(messages.entries.update.preview());
|
|
2070
|
+
} else {
|
|
2071
|
+
log.warning(messages.entries.update.commit());
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2074
|
+
const [err, result] = await to(
|
|
2075
|
+
contensis.content.update.UpdateFieldContent()
|
|
2076
|
+
);
|
|
2077
|
+
|
|
2078
|
+
if (err) logError(err);
|
|
2079
|
+
if (result) {
|
|
2080
|
+
const output = saveEntries
|
|
2081
|
+
? contensis.content.update.targets[
|
|
2082
|
+
currentProject
|
|
2083
|
+
].entries.migrate?.map(me => me.toJSON())
|
|
2084
|
+
: result;
|
|
2085
|
+
await this.HandleFormattingAndOutput(output, () => {
|
|
2086
|
+
// print the migrateResult to console
|
|
2087
|
+
printEntriesMigrateResult(this, result, {
|
|
2088
|
+
action: 'update',
|
|
2089
|
+
showAll: logOutput === 'all',
|
|
2090
|
+
showDiff: logOutput === 'all' || logOutput === 'changes',
|
|
2091
|
+
showChanged: logOutput === 'changes',
|
|
2092
|
+
});
|
|
2093
|
+
});
|
|
2094
|
+
}
|
|
2095
|
+
|
|
2096
|
+
if (
|
|
2097
|
+
result &&
|
|
2098
|
+
!err &&
|
|
2099
|
+
!result.errors?.length &&
|
|
2100
|
+
((!commit && result.entriesToMigrate[currentProject].totalCount) ||
|
|
2101
|
+
(commit &&
|
|
2102
|
+
(result.migrateResult?.created || result.migrateResult?.updated)))
|
|
2103
|
+
) {
|
|
2104
|
+
log.success(
|
|
2105
|
+
messages.entries.update.success(
|
|
2106
|
+
currentEnv,
|
|
2107
|
+
commit,
|
|
2108
|
+
commit
|
|
2109
|
+
? (result.migrateResult?.created || 0) +
|
|
2110
|
+
(result.migrateResult?.updated || 0)
|
|
2111
|
+
: result.entriesToMigrate[currentProject].totalCount
|
|
2112
|
+
)
|
|
2113
|
+
);
|
|
2114
|
+
if (!commit) {
|
|
2115
|
+
log.raw(``);
|
|
2116
|
+
log.help(messages.entries.commitTip());
|
|
2117
|
+
}
|
|
2118
|
+
} else {
|
|
2119
|
+
log.error(messages.entries.update.failed(currentEnv), err);
|
|
2120
|
+
if (!result?.entriesToMigrate?.[currentProject]?.totalCount)
|
|
2121
|
+
log.help(messages.entries.notFound(currentEnv));
|
|
2122
|
+
}
|
|
2123
|
+
} else {
|
|
2124
|
+
log.warning(messages.models.noList(currentProject));
|
|
2125
|
+
log.help(messages.connect.tip());
|
|
2126
|
+
}
|
|
2127
|
+
};
|
|
1984
2128
|
GetNodes = async (rootPath: string, depth = 0) => {
|
|
1985
2129
|
const { currentProject, log, messages } = this;
|
|
1986
2130
|
const contensis = await this.ConnectContensis();
|
|
@@ -1992,7 +2136,7 @@ class ContensisCli {
|
|
|
1992
2136
|
log.error(messages.nodes.failedGet(currentProject), err);
|
|
1993
2137
|
return;
|
|
1994
2138
|
}
|
|
1995
|
-
const root = contensis.nodes.
|
|
2139
|
+
const root = contensis.nodes.source.nodes.tree;
|
|
1996
2140
|
|
|
1997
2141
|
log.success(messages.nodes.get(currentProject, rootPath, depth));
|
|
1998
2142
|
|
|
@@ -2029,9 +2173,9 @@ class ContensisCli {
|
|
|
2029
2173
|
if (contensis) {
|
|
2030
2174
|
log.line();
|
|
2031
2175
|
if (contensis.isPreview) {
|
|
2032
|
-
|
|
2176
|
+
log.success(messages.migrate.preview());
|
|
2033
2177
|
} else {
|
|
2034
|
-
|
|
2178
|
+
log.warning(messages.migrate.commit());
|
|
2035
2179
|
}
|
|
2036
2180
|
|
|
2037
2181
|
const [err, result] = await contensis.MigrateNodes();
|
|
@@ -2041,8 +2185,7 @@ class ContensisCli {
|
|
|
2041
2185
|
await this.HandleFormattingAndOutput(result, () => {
|
|
2042
2186
|
// print the migrateResult to console
|
|
2043
2187
|
const migrateTree =
|
|
2044
|
-
contensis.nodes.
|
|
2045
|
-
.migrateNodesTreeView;
|
|
2188
|
+
contensis.nodes.targets[currentProject].nodes.migrateNodesTreeView;
|
|
2046
2189
|
printNodeTreeOutput(this, migrateTree, logOutput, logLimit);
|
|
2047
2190
|
printNodesMigrateResult(this, result, {
|
|
2048
2191
|
showAll: logOutput === 'all',
|
|
@@ -2114,8 +2257,7 @@ class ContensisCli {
|
|
|
2114
2257
|
// print the migrateResult to console
|
|
2115
2258
|
printNodeTreeOutput(
|
|
2116
2259
|
this,
|
|
2117
|
-
contensis.nodes.
|
|
2118
|
-
.migrateNodesTreeView
|
|
2260
|
+
contensis.nodes.targets[currentProject].nodes.migrateNodesTreeView
|
|
2119
2261
|
);
|
|
2120
2262
|
// printNodesMigrateResult(this, result, {
|
|
2121
2263
|
// action: 'delete',
|
|
@@ -2153,14 +2295,14 @@ class ContensisCli {
|
|
|
2153
2295
|
|
|
2154
2296
|
const filteredResults = subscriptionIdsOrNames?.length
|
|
2155
2297
|
? webhooks?.filter(
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2298
|
+
w =>
|
|
2299
|
+
subscriptionIdsOrNames?.some(idname =>
|
|
2300
|
+
w.name?.toLowerCase().includes(idname.toLowerCase())
|
|
2301
|
+
) ||
|
|
2302
|
+
subscriptionIdsOrNames?.some(
|
|
2303
|
+
id => id.toLowerCase() === w.id.toLowerCase()
|
|
2304
|
+
)
|
|
2305
|
+
)
|
|
2164
2306
|
: webhooks;
|
|
2165
2307
|
|
|
2166
2308
|
if (Array.isArray(filteredResults)) {
|
|
@@ -2187,7 +2329,8 @@ class ContensisCli {
|
|
|
2187
2329
|
version.modified || version.created
|
|
2188
2330
|
)
|
|
2189
2331
|
.toString()
|
|
2190
|
-
.substring(0, 10)} ${
|
|
2332
|
+
.substring(0, 10)} ${
|
|
2333
|
+
version.modifiedBy || version.createdBy
|
|
2191
2334
|
}]`
|
|
2192
2335
|
)
|
|
2193
2336
|
);
|
|
@@ -2256,12 +2399,14 @@ class ContensisCli {
|
|
|
2256
2399
|
versionsSinceLive,
|
|
2257
2400
|
} of blocks) {
|
|
2258
2401
|
console.log(
|
|
2259
|
-
` - ${id}${description ? ` (${description})` : ''}${
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2402
|
+
` - ${id}${description ? ` (${description})` : ''}${
|
|
2403
|
+
madeLive
|
|
2404
|
+
? ` [${madeLive.toString().substring(0, 10)} v${liveVersion}]`
|
|
2405
|
+
: ''
|
|
2406
|
+
}${
|
|
2407
|
+
versionsSinceLive
|
|
2408
|
+
? log.warningText(` +${versionsSinceLive}`)
|
|
2409
|
+
: ''
|
|
2265
2410
|
}`
|
|
2266
2411
|
);
|
|
2267
2412
|
for (const branch of branches)
|
|
@@ -2326,11 +2471,11 @@ class ContensisCli {
|
|
|
2326
2471
|
block,
|
|
2327
2472
|
!version
|
|
2328
2473
|
? {
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2474
|
+
showImage: false,
|
|
2475
|
+
showSource: true,
|
|
2476
|
+
showStaticPaths: false,
|
|
2477
|
+
showStatus: false,
|
|
2478
|
+
}
|
|
2334
2479
|
: undefined
|
|
2335
2480
|
);
|
|
2336
2481
|
});
|
|
@@ -2357,9 +2502,8 @@ class ContensisCli {
|
|
|
2357
2502
|
const contensis = await this.ConnectContensis();
|
|
2358
2503
|
if (contensis) {
|
|
2359
2504
|
// Push new block version
|
|
2360
|
-
const [err, blockVersion] =
|
|
2361
|
-
block
|
|
2362
|
-
);
|
|
2505
|
+
const [err, blockVersion] =
|
|
2506
|
+
await contensis.blocks.PushBlockVersion(block);
|
|
2363
2507
|
if (!err) {
|
|
2364
2508
|
log.success(
|
|
2365
2509
|
messages.blocks.pushed(
|
|
@@ -2436,9 +2580,8 @@ class ContensisCli {
|
|
|
2436
2580
|
|
|
2437
2581
|
// If action is release and version is latest, find the latest version number
|
|
2438
2582
|
if (action === 'release' && version === 'latest') {
|
|
2439
|
-
const [getErr, blockVersion] =
|
|
2440
|
-
blockId
|
|
2441
|
-
);
|
|
2583
|
+
const [getErr, blockVersion] =
|
|
2584
|
+
await this.GetLatestBlockVersion(blockId);
|
|
2442
2585
|
|
|
2443
2586
|
if (getErr) {
|
|
2444
2587
|
// Log error getting latest block version no
|
|
@@ -2525,7 +2668,8 @@ class ContensisCli {
|
|
|
2525
2668
|
await this.HandleFormattingAndOutput(renderLogs, () => {
|
|
2526
2669
|
// print the logs to console
|
|
2527
2670
|
console.log(
|
|
2528
|
-
` - ${blockId} ${branch} ${
|
|
2671
|
+
` - ${blockId} ${branch} ${
|
|
2672
|
+
Number(version) ? `v${version}` : version
|
|
2529
2673
|
} ${dataCenter ? `[${dataCenter}]` : ''}`
|
|
2530
2674
|
);
|
|
2531
2675
|
log.line();
|
|
@@ -2578,11 +2722,11 @@ class ContensisCli {
|
|
|
2578
2722
|
|
|
2579
2723
|
const [lastErr, lastLogs] = following
|
|
2580
2724
|
? await contensis.blocks.GetBlockLogs({
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2725
|
+
blockId,
|
|
2726
|
+
branchId: branch,
|
|
2727
|
+
version,
|
|
2728
|
+
dataCenter,
|
|
2729
|
+
})
|
|
2586
2730
|
: [null, null];
|
|
2587
2731
|
|
|
2588
2732
|
if (lastLogs) {
|
|
@@ -2630,7 +2774,8 @@ class ContensisCli {
|
|
|
2630
2774
|
log.success(messages.proxies.list(currentEnv, env.currentProject));
|
|
2631
2775
|
for (const { id, name, description, endpoints, version } of proxies) {
|
|
2632
2776
|
console.log(
|
|
2633
|
-
` - ${name} [${
|
|
2777
|
+
` - ${name} [${
|
|
2778
|
+
version.versionNo
|
|
2634
2779
|
}] ${id} ${log.infoText`${description}`}`
|
|
2635
2780
|
);
|
|
2636
2781
|
for (const [language, endpoint] of Object.entries(
|
|
@@ -2684,8 +2829,9 @@ class ContensisCli {
|
|
|
2684
2829
|
for (const rule of rules)
|
|
2685
2830
|
if (rule.return)
|
|
2686
2831
|
console.log(
|
|
2687
|
-
log.infoText` ${
|
|
2688
|
-
|
|
2832
|
+
log.infoText` ${
|
|
2833
|
+
rule.return.endpointId ? 'endpointId' : 'blockId'
|
|
2834
|
+
}: ${rule.return.endpointId || rule.return.blockId}`
|
|
2689
2835
|
);
|
|
2690
2836
|
}
|
|
2691
2837
|
});
|
|
@@ -2709,6 +2855,9 @@ class ContensisCli {
|
|
|
2709
2855
|
} else if (format === 'csv') {
|
|
2710
2856
|
log.raw('');
|
|
2711
2857
|
log.raw(log.infoText(await csvFormatter(limitFields(obj, fields))));
|
|
2858
|
+
} else if (format === 'html') {
|
|
2859
|
+
log.raw('');
|
|
2860
|
+
log.raw(log.infoText(htmlFormatter(limitFields(obj, fields))));
|
|
2712
2861
|
} else if (format === 'xml') {
|
|
2713
2862
|
log.raw('');
|
|
2714
2863
|
log.raw(log.infoText(xmlFormatter(limitFields(obj, fields))));
|
|
@@ -2723,6 +2872,8 @@ class ContensisCli {
|
|
|
2723
2872
|
const isText = !tryParse(obj) && typeof obj === 'string';
|
|
2724
2873
|
if (format === 'csv') {
|
|
2725
2874
|
writeString = await csvFormatter(limitFields(obj, fields));
|
|
2875
|
+
} else if (format === 'html') {
|
|
2876
|
+
writeString = htmlFormatter(limitFields(obj, fields));
|
|
2726
2877
|
} else if (format === 'xml') {
|
|
2727
2878
|
writeString = xmlFormatter(limitFields(obj, fields));
|
|
2728
2879
|
} else
|