contensis-cli 1.2.2-beta.8 → 1.3.0
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/CHANGELOG.md +53 -0
- package/README.md +22 -4
- package/dist/commands/get.js +23 -3
- package/dist/commands/get.js.map +2 -2
- package/dist/commands/globalOptions.js +14 -1
- package/dist/commands/globalOptions.js.map +2 -2
- package/dist/commands/import.js +7 -1
- package/dist/commands/import.js.map +2 -2
- package/dist/commands/list.js +2 -2
- package/dist/commands/list.js.map +2 -2
- package/dist/commands/push.js +1 -1
- package/dist/commands/push.js.map +1 -1
- package/dist/services/ContensisCliService.js +135 -81
- package/dist/services/ContensisCliService.js.map +3 -3
- package/dist/shell.js +2 -2
- package/dist/shell.js.map +2 -2
- package/dist/util/console.printer.js +5 -4
- package/dist/util/console.printer.js.map +2 -2
- package/dist/util/csv.formatter.js +26 -6
- package/dist/util/csv.formatter.js.map +2 -2
- package/dist/util/json.formatter.js +2 -2
- package/dist/util/json.formatter.js.map +2 -2
- package/dist/util/logger.js +14 -4
- package/dist/util/logger.js.map +2 -2
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +3 -2
- package/src/commands/get.ts +38 -3
- package/src/commands/globalOptions.ts +13 -2
- package/src/commands/import.ts +8 -0
- package/src/commands/list.ts +3 -2
- package/src/commands/push.ts +1 -1
- package/src/services/ContensisCliService.ts +163 -96
- package/src/shell.ts +5 -3
- package/src/util/console.printer.ts +9 -3
- package/src/util/csv.formatter.ts +24 -8
- package/src/util/json.formatter.ts +4 -2
- package/src/util/logger.ts +19 -0
- package/src/version.ts +1 -1
|
@@ -34,6 +34,7 @@ var import_fs = __toESM(require("fs"));
|
|
|
34
34
|
var import_inquirer = __toESM(require("inquirer"));
|
|
35
35
|
var import_node_fetch = __toESM(require("node-fetch"));
|
|
36
36
|
var import_path = __toESM(require("path"));
|
|
37
|
+
var import_rfdc = __toESM(require("rfdc"));
|
|
37
38
|
var import_migratortron = require("migratortron");
|
|
38
39
|
var import_ContensisAuthService = __toESM(require("./ContensisAuthService"));
|
|
39
40
|
var import_en_GB = require("../localisation/en-GB");
|
|
@@ -920,7 +921,7 @@ class ContensisCli {
|
|
|
920
921
|
}
|
|
921
922
|
}
|
|
922
923
|
};
|
|
923
|
-
PrintContentModels = async (modelIds = [],
|
|
924
|
+
PrintContentModels = async (modelIds = [], opts) => {
|
|
924
925
|
const { currentProject, log, messages } = this;
|
|
925
926
|
const contensis = await this.ConnectContensis();
|
|
926
927
|
if (contensis) {
|
|
@@ -930,70 +931,81 @@ class ContensisCli {
|
|
|
930
931
|
const returnModels = (modelIds == null ? void 0 : modelIds.length) ? models == null ? void 0 : models.filter(
|
|
931
932
|
(m) => modelIds.some((id) => id.toLowerCase() === m.id.toLowerCase())
|
|
932
933
|
) : void 0;
|
|
933
|
-
const
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
934
|
+
const exportResources = [];
|
|
935
|
+
if (opts.export) {
|
|
936
|
+
const contentTypeIds = Array.from(
|
|
937
|
+
/* @__PURE__ */ new Set([
|
|
938
|
+
...(returnModels || models || []).map((m) => m.id),
|
|
939
|
+
...(returnModels || models || []).map((m) => {
|
|
940
|
+
var _a, _b;
|
|
941
|
+
return ((_b = (_a = m.dependencies) == null ? void 0 : _a.contentTypes) == null ? void 0 : _b.map((c) => c[0])) || [];
|
|
942
|
+
}).flat()
|
|
943
|
+
])
|
|
944
|
+
);
|
|
945
|
+
const componentIds = Array.from(
|
|
946
|
+
new Set(
|
|
947
|
+
(returnModels || models || []).map((m) => {
|
|
948
|
+
var _a, _b;
|
|
949
|
+
return ((_b = (_a = m.dependencies) == null ? void 0 : _a.components) == null ? void 0 : _b.map((c) => c[0])) || [];
|
|
950
|
+
}).flat()
|
|
951
|
+
)
|
|
952
|
+
);
|
|
953
|
+
exportResources.push(
|
|
954
|
+
...contentTypes.filter(
|
|
955
|
+
(c) => contentTypeIds.map((i) => i.toLowerCase()).includes(c.id.toLowerCase())
|
|
956
|
+
),
|
|
957
|
+
...components.filter(
|
|
958
|
+
(c) => componentIds.map((i) => i.toLowerCase()).includes(c.id.toLowerCase())
|
|
959
|
+
)
|
|
960
|
+
);
|
|
961
|
+
}
|
|
958
962
|
if (Array.isArray(returnModels)) {
|
|
959
963
|
log.success(messages.models.list(currentProject));
|
|
960
|
-
await this.HandleFormattingAndOutput(
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
964
|
+
await this.HandleFormattingAndOutput(
|
|
965
|
+
opts.export ? exportResources : returnModels,
|
|
966
|
+
() => {
|
|
967
|
+
var _a, _b;
|
|
968
|
+
for (const model of returnModels) {
|
|
969
|
+
const draft = (0, import_rfdc.default)()(model);
|
|
970
|
+
if (!opts.requiredBy) {
|
|
971
|
+
delete draft.dependencyOf;
|
|
972
|
+
if ((_a = draft.dependencies) == null ? void 0 : _a.contentTypes)
|
|
973
|
+
draft.dependencies.contentTypes.forEach((id) => id.pop());
|
|
974
|
+
if ((_b = draft.dependencies) == null ? void 0 : _b.components)
|
|
975
|
+
draft.dependencies.components.forEach((id) => id.pop());
|
|
976
|
+
}
|
|
977
|
+
log.raw("");
|
|
978
|
+
log.object(draft);
|
|
969
979
|
}
|
|
970
980
|
log.raw("");
|
|
971
|
-
log.object(model);
|
|
972
981
|
}
|
|
973
|
-
|
|
974
|
-
});
|
|
982
|
+
);
|
|
975
983
|
} else {
|
|
976
984
|
log.success(
|
|
977
985
|
messages.models.get(currentProject, (models == null ? void 0 : models.length.toString()) || "0")
|
|
978
986
|
);
|
|
979
987
|
log.raw("");
|
|
980
988
|
if (models == null ? void 0 : models.length) {
|
|
981
|
-
await this.HandleFormattingAndOutput(
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
989
|
+
await this.HandleFormattingAndOutput(
|
|
990
|
+
opts.export ? exportResources : models,
|
|
991
|
+
() => {
|
|
992
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
993
|
+
for (const model of models) {
|
|
994
|
+
const components2 = ((_a = model.components) == null ? void 0 : _a.length) || 0;
|
|
995
|
+
const contentTypes2 = ((_b = model.contentTypes) == null ? void 0 : _b.length) || 0;
|
|
996
|
+
const defaults = (((_c = model.defaults) == null ? void 0 : _c.length) || 0) + (((_d = model.nodes) == null ? void 0 : _d.length) || 0);
|
|
997
|
+
const dependencies = (((_f = (_e = model.dependencies) == null ? void 0 : _e.components) == null ? void 0 : _f.length) || 0) + (((_h = (_g = model.dependencies) == null ? void 0 : _g.contentTypes) == null ? void 0 : _h.length) || 0);
|
|
998
|
+
const dependencyOf = (((_j = (_i = model.dependencyOf) == null ? void 0 : _i.components) == null ? void 0 : _j.length) || 0) + (((_l = (_k = model.dependencyOf) == null ? void 0 : _k.contentTypes) == null ? void 0 : _l.length) || 0);
|
|
999
|
+
const hasAny = components2 + contentTypes2 + dependencies + dependencyOf;
|
|
1000
|
+
log.raw(
|
|
1001
|
+
` - ${log.highlightText(log.boldText(model.id))} ${hasAny ? log.infoText(
|
|
1002
|
+
`{ ${components2 ? `components: ${components2}, ` : ""}${contentTypes2 ? `contentTypes: ${contentTypes2}, ` : ""}${defaults ? `defaults: ${defaults}, ` : ""}${dependencies ? `references: ${dependencies}, ` : ""}${dependencyOf ? `required by: ${dependencyOf}` : ""} }`
|
|
1003
|
+
) : ""}`
|
|
1004
|
+
);
|
|
1005
|
+
}
|
|
1006
|
+
log.raw("");
|
|
994
1007
|
}
|
|
995
|
-
|
|
996
|
-
});
|
|
1008
|
+
);
|
|
997
1009
|
}
|
|
998
1010
|
}
|
|
999
1011
|
}
|
|
@@ -1023,7 +1035,7 @@ class ContensisCli {
|
|
|
1023
1035
|
(0, import_logger.logError)(migrateErr);
|
|
1024
1036
|
else
|
|
1025
1037
|
await this.HandleFormattingAndOutput(result, () => {
|
|
1026
|
-
if (!
|
|
1038
|
+
if (!result.committed) {
|
|
1027
1039
|
log.raw(log.boldText(`
|
|
1028
1040
|
Content types:`));
|
|
1029
1041
|
if (!result.contentTypes)
|
|
@@ -1038,20 +1050,59 @@ Components:`));
|
|
|
1038
1050
|
`);
|
|
1039
1051
|
else
|
|
1040
1052
|
(0, import_console.printModelMigrationAnalysis)(this, result.components);
|
|
1053
|
+
if (Object.keys(result.defaults).length) {
|
|
1054
|
+
log.raw(log.boldText(`
|
|
1055
|
+
Defaults:`));
|
|
1056
|
+
(0, import_console.printModelMigrationAnalysis)(this, result.defaults);
|
|
1057
|
+
}
|
|
1058
|
+
if (Object.keys(result.nodes).length) {
|
|
1059
|
+
log.raw(log.boldText(`
|
|
1060
|
+
Nodes:`));
|
|
1061
|
+
(0, import_console.printModelMigrationAnalysis)(this, result.nodes);
|
|
1062
|
+
}
|
|
1063
|
+
if (result.errors) {
|
|
1064
|
+
log.raw(log.boldText(`
|
|
1065
|
+
Errors:`));
|
|
1066
|
+
log.object(result.errors);
|
|
1067
|
+
}
|
|
1041
1068
|
} else {
|
|
1042
|
-
const
|
|
1069
|
+
const { modelsResult = {} } = result;
|
|
1043
1070
|
log.raw(log.boldText(`
|
|
1044
1071
|
Content types:`));
|
|
1045
1072
|
(0, import_console.printModelMigrationResult)(
|
|
1046
1073
|
this,
|
|
1047
|
-
|
|
1074
|
+
modelsResult[currentProject].contentTypes
|
|
1048
1075
|
);
|
|
1049
|
-
|
|
1076
|
+
if (Object.values(modelsResult[currentProject].components).some(
|
|
1077
|
+
(r) => r.length > 0
|
|
1078
|
+
)) {
|
|
1079
|
+
log.raw(log.boldText(`
|
|
1050
1080
|
Components:`));
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1081
|
+
(0, import_console.printModelMigrationResult)(
|
|
1082
|
+
this,
|
|
1083
|
+
modelsResult[currentProject].components
|
|
1084
|
+
);
|
|
1085
|
+
}
|
|
1086
|
+
if (Object.values(modelsResult[currentProject].defaults).some(
|
|
1087
|
+
(r) => r.length > 0
|
|
1088
|
+
)) {
|
|
1089
|
+
log.raw(log.boldText(`
|
|
1090
|
+
Defaults:`));
|
|
1091
|
+
(0, import_console.printModelMigrationResult)(
|
|
1092
|
+
this,
|
|
1093
|
+
modelsResult[currentProject].defaults
|
|
1094
|
+
);
|
|
1095
|
+
}
|
|
1096
|
+
if (Object.values(modelsResult[currentProject].nodes).some(
|
|
1097
|
+
(r) => r.length > 0
|
|
1098
|
+
)) {
|
|
1099
|
+
log.raw(log.boldText(`
|
|
1100
|
+
Nodes:`));
|
|
1101
|
+
(0, import_console.printModelMigrationResult)(
|
|
1102
|
+
this,
|
|
1103
|
+
modelsResult[currentProject].nodes
|
|
1104
|
+
);
|
|
1105
|
+
}
|
|
1055
1106
|
}
|
|
1056
1107
|
});
|
|
1057
1108
|
} else {
|
|
@@ -1199,18 +1250,21 @@ Components:`));
|
|
|
1199
1250
|
)}
|
|
1200
1251
|
`
|
|
1201
1252
|
);
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1253
|
+
if (result.committed === false) {
|
|
1254
|
+
log.raw(log.boldText(`Content types:`));
|
|
1255
|
+
if (!result.contentTypes)
|
|
1256
|
+
log.info(`- None returned
|
|
1205
1257
|
`);
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1258
|
+
else
|
|
1259
|
+
(0, import_console.printModelMigrationAnalysis)(this, result.contentTypes);
|
|
1260
|
+
log.raw(log.boldText(`
|
|
1261
|
+
Components:`));
|
|
1262
|
+
if (!result.components)
|
|
1263
|
+
log.info(`- None returned
|
|
1211
1264
|
`);
|
|
1212
|
-
|
|
1213
|
-
|
|
1265
|
+
else
|
|
1266
|
+
(0, import_console.printModelMigrationAnalysis)(this, result.components);
|
|
1267
|
+
}
|
|
1214
1268
|
});
|
|
1215
1269
|
}
|
|
1216
1270
|
};
|
|
@@ -1361,7 +1415,7 @@ Components:`));
|
|
|
1361
1415
|
};
|
|
1362
1416
|
GetEntries = async ({
|
|
1363
1417
|
withDependents = false
|
|
1364
|
-
}) => {
|
|
1418
|
+
} = {}) => {
|
|
1365
1419
|
const { currentProject, log, messages } = this;
|
|
1366
1420
|
const contensis = await this.ConnectContensis();
|
|
1367
1421
|
if (contensis) {
|
|
@@ -1389,7 +1443,7 @@ Components:`));
|
|
|
1389
1443
|
logOutput,
|
|
1390
1444
|
saveEntries
|
|
1391
1445
|
}) => {
|
|
1392
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1446
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1393
1447
|
const { currentEnv, currentProject, log, messages } = this;
|
|
1394
1448
|
const contensis = await this.ConnectContensisImport({
|
|
1395
1449
|
commit,
|
|
@@ -1407,8 +1461,8 @@ Components:`));
|
|
|
1407
1461
|
if (err)
|
|
1408
1462
|
(0, import_logger.logError)(err);
|
|
1409
1463
|
else {
|
|
1410
|
-
const {
|
|
1411
|
-
const output = saveEntries ?
|
|
1464
|
+
const { entries, nodes } = contensis.content.targets[currentProject];
|
|
1465
|
+
const output = saveEntries ? (_a = entries.migrate) == null ? void 0 : _a.map((me) => me.toJSON()) : result;
|
|
1412
1466
|
await this.HandleFormattingAndOutput(output, () => {
|
|
1413
1467
|
(0, import_console.printEntriesMigrateResult)(this, result, {
|
|
1414
1468
|
showAll: logOutput === "all",
|
|
@@ -1427,13 +1481,13 @@ Components:`));
|
|
|
1427
1481
|
);
|
|
1428
1482
|
});
|
|
1429
1483
|
}
|
|
1430
|
-
if (!err && !((
|
|
1484
|
+
if (!err && !((_b = result.errors) == null ? void 0 : _b.length) && (!commit && result.entriesToMigrate[currentProject].totalCount || commit && (((_c = result.migrateResult) == null ? void 0 : _c.created) || ((_d = result.migrateResult) == null ? void 0 : _d.updated)))) {
|
|
1431
1485
|
log.success(
|
|
1432
1486
|
messages.entries.imported(
|
|
1433
1487
|
currentEnv,
|
|
1434
1488
|
commit,
|
|
1435
|
-
commit ? (((
|
|
1436
|
-
commit ? (((
|
|
1489
|
+
commit ? (((_e = result.migrateResult) == null ? void 0 : _e.created) || 0) + (((_f = result.migrateResult) == null ? void 0 : _f.updated) || 0) : result.entriesToMigrate[currentProject].totalCount,
|
|
1490
|
+
commit ? (((_g = result.nodesResult) == null ? void 0 : _g.created) || 0) + (((_h = result.nodesResult) == null ? void 0 : _h.updated) || 0) : ((_i = result.nodesToMigrate) == null ? void 0 : _i[currentProject].totalCount) || 0
|
|
1437
1491
|
)
|
|
1438
1492
|
);
|
|
1439
1493
|
if (!commit) {
|
|
@@ -1442,7 +1496,7 @@ Components:`));
|
|
|
1442
1496
|
}
|
|
1443
1497
|
} else {
|
|
1444
1498
|
log.error(messages.entries.failedImport(currentEnv), err);
|
|
1445
|
-
if (!((
|
|
1499
|
+
if (!((_k = (_j = result == null ? void 0 : result.entriesToMigrate) == null ? void 0 : _j[currentProject]) == null ? void 0 : _k.totalCount))
|
|
1446
1500
|
log.help(messages.entries.notFound(currentEnv));
|
|
1447
1501
|
}
|
|
1448
1502
|
} else {
|
|
@@ -1476,8 +1530,8 @@ Components:`));
|
|
|
1476
1530
|
if (err)
|
|
1477
1531
|
(0, import_logger.logError)(err);
|
|
1478
1532
|
if (result) {
|
|
1479
|
-
const output = saveEntries ? (_a = contensis.content.copy.targets[currentProject].
|
|
1480
|
-
(me) => me.
|
|
1533
|
+
const output = saveEntries ? (_a = contensis.content.copy.targets[currentProject].entries.migrate) == null ? void 0 : _a.map(
|
|
1534
|
+
(me) => me.toJSON()
|
|
1481
1535
|
) : result;
|
|
1482
1536
|
await this.HandleFormattingAndOutput(output, () => {
|
|
1483
1537
|
(0, import_console.printEntriesMigrateResult)(this, result, {
|