contensis-cli 1.5.1-beta.5 → 1.5.1-beta.7
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/get.js +9 -3
- package/dist/commands/get.js.map +2 -2
- package/dist/commands/globalOptions.js +8 -1
- package/dist/commands/globalOptions.js.map +2 -2
- package/dist/commands/import.js +2 -2
- package/dist/commands/import.js.map +2 -2
- package/dist/localisation/en-GB.js +4 -2
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/services/ContensisCliService.js +69 -24
- package/dist/services/ContensisCliService.js.map +3 -3
- package/dist/util/index.js +10 -0
- package/dist/util/index.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/get.ts +10 -3
- package/src/commands/globalOptions.ts +11 -0
- package/src/commands/import.ts +4 -1
- package/src/localisation/en-GB.ts +2 -0
- package/src/services/ContensisCliService.ts +102 -27
- package/src/util/index.ts +14 -0
- package/src/version.ts +1 -1
|
@@ -121,7 +121,7 @@ class ContensisCli {
|
|
|
121
121
|
);
|
|
122
122
|
}
|
|
123
123
|
this.format = outputOpts == null ? void 0 : outputOpts.format;
|
|
124
|
-
this.output = (outputOpts == null ? void 0 : outputOpts.output)
|
|
124
|
+
this.output = (outputOpts == null ? void 0 : outputOpts.output) ? import_path.default.isAbsolute(outputOpts.output) ? outputOpts.output : import_path.default.join(process.cwd(), outputOpts.output) : void 0;
|
|
125
125
|
const currentEnvironment = (outputOpts == null ? void 0 : outputOpts.alias) || this.currentEnv;
|
|
126
126
|
const environments = this.cache.environments || {};
|
|
127
127
|
this.currentEnv = currentEnvironment;
|
|
@@ -1058,7 +1058,7 @@ class ContensisCli {
|
|
|
1058
1058
|
data,
|
|
1059
1059
|
save
|
|
1060
1060
|
}) => {
|
|
1061
|
-
var _a, _b, _c, _d, _e;
|
|
1061
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1062
1062
|
const { currentEnv, currentProject, log, messages } = this;
|
|
1063
1063
|
const mixedData = { tags: [], tagGroups: [] };
|
|
1064
1064
|
if (data) {
|
|
@@ -1112,13 +1112,18 @@ class ContensisCli {
|
|
|
1112
1112
|
log.help(messages.migrate.commitTip());
|
|
1113
1113
|
}
|
|
1114
1114
|
} else {
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1115
|
+
const noChanges = ((_g = (_f = result == null ? void 0 : result.tagsToMigrate) == null ? void 0 : _f[currentProject]) == null ? void 0 : _g["no change"]) && result.tagsToMigrate[currentProject].totalCount === 0 && result.groupsToMigrate[currentProject].totalCount === 0;
|
|
1116
|
+
if (noChanges && !err && !((_h = result.errors) == null ? void 0 : _h.length)) {
|
|
1117
|
+
log.help(messages.tags.noChange(currentEnv));
|
|
1118
|
+
} else {
|
|
1119
|
+
log.error(
|
|
1120
|
+
messages.tags.failedCreate(
|
|
1121
|
+
currentEnv,
|
|
1122
|
+
(data == null ? void 0 : data.length) === 1 ? data == null ? void 0 : data[0].label["en-GB"] : void 0
|
|
1123
|
+
),
|
|
1124
|
+
err
|
|
1125
|
+
);
|
|
1126
|
+
}
|
|
1122
1127
|
}
|
|
1123
1128
|
} else {
|
|
1124
1129
|
log.warning(messages.models.noList(currentProject));
|
|
@@ -1288,6 +1293,7 @@ class ContensisCli {
|
|
|
1288
1293
|
const models = await contensis.models.contentModels();
|
|
1289
1294
|
const contentTypes = await contensis.models.contentTypes();
|
|
1290
1295
|
const components = await contensis.models.components();
|
|
1296
|
+
const tagGroups = await contensis.models.tagGroups();
|
|
1291
1297
|
const returnModels = (modelIds == null ? void 0 : modelIds.length) ? models == null ? void 0 : models.filter(
|
|
1292
1298
|
(m) => modelIds.some((id) => id.toLowerCase() === m.id.toLowerCase())
|
|
1293
1299
|
) : void 0;
|
|
@@ -1310,12 +1316,23 @@ class ContensisCli {
|
|
|
1310
1316
|
}).flat()
|
|
1311
1317
|
)
|
|
1312
1318
|
);
|
|
1319
|
+
const tagGroupIds = Array.from(
|
|
1320
|
+
new Set(
|
|
1321
|
+
(returnModels || models || []).map((m) => {
|
|
1322
|
+
var _a, _b;
|
|
1323
|
+
return ((_b = (_a = m.dependencies) == null ? void 0 : _a.tagGroups) == null ? void 0 : _b.map((g) => g[0])) || [];
|
|
1324
|
+
}).flat()
|
|
1325
|
+
)
|
|
1326
|
+
);
|
|
1313
1327
|
exportResources.push(
|
|
1314
1328
|
...contentTypes.filter(
|
|
1315
1329
|
(c) => contentTypeIds.map((i) => i.toLowerCase()).includes(c.id.toLowerCase())
|
|
1316
1330
|
),
|
|
1317
1331
|
...components.filter(
|
|
1318
1332
|
(c) => componentIds.map((i) => i.toLowerCase()).includes(c.id.toLowerCase())
|
|
1333
|
+
),
|
|
1334
|
+
...tagGroups.filter(
|
|
1335
|
+
(g) => tagGroupIds.map((i) => i.toLowerCase()).includes(g.id.toLowerCase())
|
|
1319
1336
|
)
|
|
1320
1337
|
);
|
|
1321
1338
|
}
|
|
@@ -1349,17 +1366,18 @@ class ContensisCli {
|
|
|
1349
1366
|
await this.HandleFormattingAndOutput(
|
|
1350
1367
|
opts.export ? exportResources : models,
|
|
1351
1368
|
() => {
|
|
1352
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
1369
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
1353
1370
|
for (const model of models) {
|
|
1354
1371
|
const components2 = ((_a = model.components) == null ? void 0 : _a.length) || 0;
|
|
1355
1372
|
const contentTypes2 = ((_b = model.contentTypes) == null ? void 0 : _b.length) || 0;
|
|
1356
|
-
const
|
|
1357
|
-
const
|
|
1358
|
-
const
|
|
1359
|
-
const
|
|
1373
|
+
const tagGroups2 = ((_c = model.tagGroups) == null ? void 0 : _c.length) || 0;
|
|
1374
|
+
const defaults = (((_d = model.defaults) == null ? void 0 : _d.length) || 0) + (((_e = model.nodes) == null ? void 0 : _e.length) || 0);
|
|
1375
|
+
const dependencies = (((_g = (_f = model.dependencies) == null ? void 0 : _f.components) == null ? void 0 : _g.length) || 0) + (((_i = (_h = model.dependencies) == null ? void 0 : _h.contentTypes) == null ? void 0 : _i.length) || 0) + (((_k = (_j = model.dependencies) == null ? void 0 : _j.tagGroups) == null ? void 0 : _k.length) || 0);
|
|
1376
|
+
const dependencyOf = (((_m = (_l = model.dependencyOf) == null ? void 0 : _l.components) == null ? void 0 : _m.length) || 0) + (((_o = (_n = model.dependencyOf) == null ? void 0 : _n.contentTypes) == null ? void 0 : _o.length) || 0);
|
|
1377
|
+
const hasAny = components2 + contentTypes2 + tagGroups2 + dependencies + dependencyOf;
|
|
1360
1378
|
log.raw(
|
|
1361
1379
|
` - ${log.highlightText(log.boldText(model.id))} ${hasAny ? log.infoText(
|
|
1362
|
-
`{ ${components2 ? `components: ${components2}, ` : ""}${contentTypes2 ? `contentTypes: ${contentTypes2}, ` : ""}${defaults ? `defaults: ${defaults}, ` : ""}${dependencies ? `references: ${dependencies}, ` : ""}${dependencyOf ? `required by: ${dependencyOf}` : ""} }`
|
|
1380
|
+
`{ ${components2 ? `components: ${components2}, ` : ""}${contentTypes2 ? `contentTypes: ${contentTypes2}, ` : ""}${tagGroups2 ? `tagGroups: ${tagGroups2}, ` : ""}${defaults ? `defaults: ${defaults}, ` : ""}${dependencies ? `references: ${dependencies}, ` : ""}${dependencyOf ? `required by: ${dependencyOf}` : ""} }`
|
|
1363
1381
|
) : ""}`
|
|
1364
1382
|
);
|
|
1365
1383
|
}
|
|
@@ -1375,13 +1393,14 @@ class ContensisCli {
|
|
|
1375
1393
|
fromFile
|
|
1376
1394
|
}) => {
|
|
1377
1395
|
const { currentProject, log, messages } = this;
|
|
1378
|
-
const
|
|
1379
|
-
if (
|
|
1380
|
-
|
|
1396
|
+
const mixedData = { models: [], tagGroups: [] };
|
|
1397
|
+
if (fromFile) {
|
|
1398
|
+
const fileData = fromFile ? await (0, import_file_provider.readFileAsJSON)(fromFile) || [] : [];
|
|
1399
|
+
(0, import_util.splitTagGroupsInModels)(fileData, mixedData.models, mixedData.tagGroups);
|
|
1400
|
+
}
|
|
1381
1401
|
const contensis = await this.ConnectContensisImport({
|
|
1382
1402
|
commit,
|
|
1383
|
-
|
|
1384
|
-
importDataType: "models"
|
|
1403
|
+
mixedData: mixedData.models.length ? mixedData : void 0
|
|
1385
1404
|
});
|
|
1386
1405
|
if (contensis) {
|
|
1387
1406
|
log.line();
|
|
@@ -1405,6 +1424,11 @@ Components:`));
|
|
|
1405
1424
|
if (!result.components) log.info(`- None returned
|
|
1406
1425
|
`);
|
|
1407
1426
|
else (0, import_console.printModelMigrationAnalysis)(this, result.components);
|
|
1427
|
+
if (result.tagGroups && Object.keys(result.tagGroups).length) {
|
|
1428
|
+
log.raw(log.boldText(`
|
|
1429
|
+
Tag Groups:`));
|
|
1430
|
+
(0, import_console.printModelMigrationAnalysis)(this, result.tagGroups);
|
|
1431
|
+
}
|
|
1408
1432
|
if (result.defaults && Object.keys(result.defaults).length) {
|
|
1409
1433
|
log.raw(log.boldText(`
|
|
1410
1434
|
Defaults:`));
|
|
@@ -1438,6 +1462,16 @@ Components:`));
|
|
|
1438
1462
|
modelsResult[currentProject].components
|
|
1439
1463
|
);
|
|
1440
1464
|
}
|
|
1465
|
+
if (Object.values(modelsResult[currentProject].tagGroups || {}).some(
|
|
1466
|
+
(r) => r.length > 0
|
|
1467
|
+
)) {
|
|
1468
|
+
log.raw(log.boldText(`
|
|
1469
|
+
Tag Groups:`));
|
|
1470
|
+
(0, import_console.printModelMigrationResult)(
|
|
1471
|
+
this,
|
|
1472
|
+
modelsResult[currentProject].tagGroups
|
|
1473
|
+
);
|
|
1474
|
+
}
|
|
1441
1475
|
if (Object.values(modelsResult[currentProject].defaults || {}).some(
|
|
1442
1476
|
(r) => r.length > 0
|
|
1443
1477
|
)) {
|
|
@@ -1532,6 +1566,7 @@ Nodes:`));
|
|
|
1532
1566
|
)
|
|
1533
1567
|
);
|
|
1534
1568
|
await this.HandleFormattingAndOutput(result, log.object);
|
|
1569
|
+
if (!commit) log.help(messages.migrate.commitTip());
|
|
1535
1570
|
}
|
|
1536
1571
|
}
|
|
1537
1572
|
};
|
|
@@ -1574,6 +1609,7 @@ Nodes:`));
|
|
|
1574
1609
|
);
|
|
1575
1610
|
await this.HandleFormattingAndOutput(result, log.object);
|
|
1576
1611
|
}
|
|
1612
|
+
if (!commit) log.help(messages.migrate.commitTip());
|
|
1577
1613
|
}
|
|
1578
1614
|
};
|
|
1579
1615
|
DiffModels = async ({
|
|
@@ -1682,6 +1718,7 @@ Components:`));
|
|
|
1682
1718
|
)
|
|
1683
1719
|
);
|
|
1684
1720
|
await this.HandleFormattingAndOutput(result, log.object);
|
|
1721
|
+
if (!commit) log.help(messages.migrate.commitTip());
|
|
1685
1722
|
}
|
|
1686
1723
|
}
|
|
1687
1724
|
};
|
|
@@ -1724,6 +1761,7 @@ Components:`));
|
|
|
1724
1761
|
);
|
|
1725
1762
|
await this.HandleFormattingAndOutput(result, log.object);
|
|
1726
1763
|
}
|
|
1764
|
+
if (!commit) log.help(messages.migrate.commitTip());
|
|
1727
1765
|
}
|
|
1728
1766
|
};
|
|
1729
1767
|
RemoveEntries = async (commit = false) => {
|
|
@@ -1798,7 +1836,7 @@ Components:`));
|
|
|
1798
1836
|
saveEntries,
|
|
1799
1837
|
data
|
|
1800
1838
|
}) => {
|
|
1801
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1839
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
1802
1840
|
const { currentEnv, currentProject, log, messages } = this;
|
|
1803
1841
|
const contensis = await this.ConnectContensisImport({
|
|
1804
1842
|
commit,
|
|
@@ -1856,9 +1894,16 @@ Components:`));
|
|
|
1856
1894
|
log.help(messages.migrate.commitTip());
|
|
1857
1895
|
}
|
|
1858
1896
|
} else {
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1897
|
+
const noChanges = Object.values((_j = result == null ? void 0 : result.entriesToMigrate) == null ? void 0 : _j[currentProject]).every(
|
|
1898
|
+
(status) => typeof status === "number" || (status["no change"] || 0) > 0
|
|
1899
|
+
) && result.entriesToMigrate[currentProject].totalCount === 0;
|
|
1900
|
+
if (noChanges && !err && !((_k = result == null ? void 0 : result.migrateResult) == null ? void 0 : _k.errors) && !((_l = result == null ? void 0 : result.nodesResult) == null ? void 0 : _l.errors)) {
|
|
1901
|
+
log.help(messages.entries.noChange(currentEnv));
|
|
1902
|
+
} else {
|
|
1903
|
+
log.error(messages.entries.failedImport(currentEnv), err);
|
|
1904
|
+
if (!((_n = (_m = result == null ? void 0 : result.entriesToMigrate) == null ? void 0 : _m[currentProject]) == null ? void 0 : _n.totalCount))
|
|
1905
|
+
log.help(messages.entries.notFound(currentEnv));
|
|
1906
|
+
}
|
|
1862
1907
|
}
|
|
1863
1908
|
} else {
|
|
1864
1909
|
log.warning(messages.models.noList(currentProject));
|