contensis-cli 1.4.1 → 1.4.2-beta.1
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 +360 -1
- package/dist/commands/create.js +83 -2
- package/dist/commands/create.js.map +2 -2
- package/dist/commands/get.js +33 -1
- package/dist/commands/get.js.map +2 -2
- package/dist/commands/import.js +62 -0
- package/dist/commands/import.js.map +2 -2
- package/dist/commands/list.js +48 -1
- package/dist/commands/list.js.map +2 -2
- package/dist/commands/remove.js +50 -1
- package/dist/commands/remove.js.map +2 -2
- package/dist/localisation/en-GB.js +38 -8
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/providers/HttpProvider.js +4 -4
- package/dist/providers/HttpProvider.js.map +2 -2
- package/dist/providers/ManifestProvider.js +2 -2
- package/dist/providers/ManifestProvider.js.map +2 -2
- package/dist/providers/SessionCacheProvider.js +6 -3
- package/dist/providers/SessionCacheProvider.js.map +2 -2
- package/dist/providers/file-provider.js +2 -2
- package/dist/providers/file-provider.js.map +2 -2
- package/dist/services/ContensisCliService.js +370 -22
- package/dist/services/ContensisCliService.js.map +3 -3
- package/dist/shell.js +14 -1
- package/dist/shell.js.map +2 -2
- package/dist/util/assert.js +62 -0
- package/dist/util/assert.js.map +7 -0
- package/dist/util/index.js +11 -36
- package/dist/util/index.js.map +2 -2
- package/dist/util/logger.js +17 -6
- 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 -3
- package/src/commands/create.ts +118 -0
- package/src/commands/get.ts +48 -1
- package/src/commands/import.ts +86 -0
- package/src/commands/list.ts +80 -1
- package/src/commands/remove.ts +91 -1
- package/src/localisation/en-GB.ts +62 -9
- package/src/models/Cache.d.ts +2 -1
- package/src/providers/HttpProvider.ts +1 -1
- package/src/providers/ManifestProvider.ts +1 -1
- package/src/providers/SessionCacheProvider.ts +6 -1
- package/src/providers/file-provider.ts +1 -1
- package/src/services/ContensisCliService.ts +480 -24
- package/src/shell.ts +14 -1
- package/src/util/assert.ts +35 -0
- package/src/util/index.ts +15 -36
- package/src/util/logger.ts +18 -6
- package/src/version.ts +1 -1
|
@@ -47,6 +47,7 @@ var import_SessionCacheProvider = __toESM(require("../providers/SessionCacheProv
|
|
|
47
47
|
var import_CredentialProvider = __toESM(require("../providers/CredentialProvider"));
|
|
48
48
|
var import_util = require("../util");
|
|
49
49
|
var import_api_ids = require("../util/api-ids");
|
|
50
|
+
var import_assert = require("../util/assert");
|
|
50
51
|
var import_console = require("../util/console.printer");
|
|
51
52
|
var import_csv = require("../util/csv.formatter");
|
|
52
53
|
var import_html = require("../util/html.formatter");
|
|
@@ -226,7 +227,7 @@ class ContensisCli {
|
|
|
226
227
|
if (!this.contensis) {
|
|
227
228
|
const { contensisOpts, currentEnv, env, log, messages } = this;
|
|
228
229
|
const userId = env == null ? void 0 : env.lastUserId;
|
|
229
|
-
const isGuidId = userId && (0,
|
|
230
|
+
const isGuidId = userId && (0, import_assert.isUuid)(userId);
|
|
230
231
|
if (currentEnv && userId) {
|
|
231
232
|
const credentials = await this.GetCredentials(
|
|
232
233
|
userId,
|
|
@@ -263,10 +264,11 @@ class ContensisCli {
|
|
|
263
264
|
commit = false,
|
|
264
265
|
fromFile,
|
|
265
266
|
importDataType,
|
|
266
|
-
importData
|
|
267
|
+
importData,
|
|
268
|
+
mixedData
|
|
267
269
|
}) => {
|
|
268
270
|
var _a, _b, _c, _d, _e, _f;
|
|
269
|
-
const source = fromFile || importData ? "file" : "contensis";
|
|
271
|
+
const source = fromFile || importData || mixedData ? "file" : "contensis";
|
|
270
272
|
const fileData = importData || (fromFile ? await (0, import_file_provider.readFileAsJSON)(fromFile) || [] : []);
|
|
271
273
|
if (typeof fileData === "string")
|
|
272
274
|
throw new Error(`Import file format must be of type JSON`);
|
|
@@ -276,11 +278,11 @@ class ContensisCli {
|
|
|
276
278
|
const sourceCms = "source" in contensisOpts && contensisOpts.source || {};
|
|
277
279
|
const sourceUserId = sourceCms.clientId || sourceCms.username || sourceEnvironment.lastUserId;
|
|
278
280
|
const sourceProjectId = sourceCms.project || sourceEnvironment.currentProject || "website";
|
|
279
|
-
const isSourceGuidId = sourceUserId && (0,
|
|
281
|
+
const isSourceGuidId = sourceUserId && (0, import_assert.isUuid)(sourceUserId);
|
|
280
282
|
const sourceUrls = (0, import_util.url)(sourceAlias || "", sourceProjectId);
|
|
281
283
|
const sourcePassword = sourceCms.sharedSecret || sourceCms.password || sourceEnvironment.passwordFallback;
|
|
282
284
|
const targetUserId = env == null ? void 0 : env.lastUserId;
|
|
283
|
-
const isTargetGuidId = targetUserId && (0,
|
|
285
|
+
const isTargetGuidId = targetUserId && (0, import_assert.isUuid)(targetUserId);
|
|
284
286
|
if (sourceUserId && currentEnv && targetUserId) {
|
|
285
287
|
const sourceCredentials = await this.GetCredentials(
|
|
286
288
|
sourceUserId,
|
|
@@ -298,7 +300,7 @@ class ContensisCli {
|
|
|
298
300
|
if (source === "file" || importDataType === "user-input") {
|
|
299
301
|
this.contensis = new import_migratortron.ContensisMigrationService(
|
|
300
302
|
{
|
|
301
|
-
concurrency:
|
|
303
|
+
concurrency: 2,
|
|
302
304
|
outputProgress: true,
|
|
303
305
|
...contensisOpts,
|
|
304
306
|
target: {
|
|
@@ -310,14 +312,15 @@ class ContensisCli {
|
|
|
310
312
|
targetProjects: [env.currentProject || ""],
|
|
311
313
|
assetHostname: (_d = this.urls) == null ? void 0 : _d.previewWeb
|
|
312
314
|
},
|
|
313
|
-
...importDataType ? { [importDataType]: fileData } : {}
|
|
315
|
+
...importDataType ? { [importDataType]: fileData } : {},
|
|
316
|
+
...mixedData || {}
|
|
314
317
|
},
|
|
315
318
|
!commit
|
|
316
319
|
);
|
|
317
320
|
} else if (source === "contensis") {
|
|
318
321
|
this.contensis = new import_migratortron.ContensisMigrationService(
|
|
319
322
|
{
|
|
320
|
-
concurrency:
|
|
323
|
+
concurrency: 2,
|
|
321
324
|
outputProgress: true,
|
|
322
325
|
...contensisOpts,
|
|
323
326
|
source: {
|
|
@@ -386,15 +389,15 @@ class ContensisCli {
|
|
|
386
389
|
var _a, _b, _c, _d;
|
|
387
390
|
let inputPassword = password || sharedSecret;
|
|
388
391
|
if (!inputPassword)
|
|
389
|
-
inputPassword = (0,
|
|
392
|
+
inputPassword = (0, import_assert.isSharedSecret)(this.env.passwordFallback) || (0, import_assert.isPassword)(this.env.passwordFallback) || "";
|
|
390
393
|
const { messages } = this;
|
|
391
394
|
if (userId) {
|
|
392
395
|
const { currentEnv, env } = this;
|
|
393
396
|
if (currentEnv) {
|
|
394
397
|
const credentials = await this.GetCredentials(userId, inputPassword);
|
|
395
398
|
if (credentials) {
|
|
396
|
-
const cachedPassword = (0,
|
|
397
|
-
const cachedSecret = (0,
|
|
399
|
+
const cachedPassword = (0, import_assert.isPassword)((_a = credentials.current) == null ? void 0 : _a.password);
|
|
400
|
+
const cachedSecret = (0, import_assert.isSharedSecret)((_b = credentials.current) == null ? void 0 : _b.password);
|
|
398
401
|
if (!cachedPassword && !cachedSecret && promptPassword) {
|
|
399
402
|
({ inputPassword } = await import_inquirer.default.prompt([
|
|
400
403
|
{
|
|
@@ -502,7 +505,10 @@ class ContensisCli {
|
|
|
502
505
|
if (Array.isArray(projects)) {
|
|
503
506
|
const nextCurrentProject = currentProject && currentProject !== "null" ? currentProject : projects.some((p) => p.id === "website") ? "website" : void 0;
|
|
504
507
|
session.UpdateEnv({
|
|
505
|
-
projects: projects.map((p) =>
|
|
508
|
+
projects: projects.map((p) => ({
|
|
509
|
+
id: p.id,
|
|
510
|
+
primaryLanguage: p.primaryLanguage
|
|
511
|
+
})),
|
|
506
512
|
currentProject: nextCurrentProject
|
|
507
513
|
});
|
|
508
514
|
log.success(messages.projects.list());
|
|
@@ -557,12 +563,13 @@ class ContensisCli {
|
|
|
557
563
|
}
|
|
558
564
|
};
|
|
559
565
|
SetProject = (projectId = "website") => {
|
|
566
|
+
var _a;
|
|
560
567
|
const { env, log, messages, session } = this;
|
|
561
568
|
let nextProjectId;
|
|
562
569
|
if ((env == null ? void 0 : env.projects.length) > 0 && (env == null ? void 0 : env.lastUserId)) {
|
|
563
|
-
nextProjectId = env.projects.find(
|
|
564
|
-
(p) => p.toLowerCase() === projectId.toLowerCase()
|
|
565
|
-
);
|
|
570
|
+
nextProjectId = (_a = env.projects.find(
|
|
571
|
+
(p) => p.id.toLowerCase() === projectId.toLowerCase()
|
|
572
|
+
)) == null ? void 0 : _a.id;
|
|
566
573
|
if (nextProjectId) {
|
|
567
574
|
env.currentProject = nextProjectId;
|
|
568
575
|
session.UpdateEnv(env);
|
|
@@ -719,7 +726,10 @@ class ContensisCli {
|
|
|
719
726
|
` ${import_chalk.default.bold.grey(
|
|
720
727
|
"contentTypes"
|
|
721
728
|
)}: ${permissions.contentTypes.map(
|
|
722
|
-
(p) =>
|
|
729
|
+
(p) => {
|
|
730
|
+
var _a2, _b2;
|
|
731
|
+
return `${p.id} [${(_a2 = p.actions) == null ? void 0 : _a2.join(",")}] ${((_b2 = p.languages) == null ? void 0 : _b2.join(" ")) || ""}`;
|
|
732
|
+
}
|
|
723
733
|
).join(", ")}`
|
|
724
734
|
);
|
|
725
735
|
}
|
|
@@ -805,6 +815,12 @@ class ContensisCli {
|
|
|
805
815
|
const { currentEnv, log, messages } = this;
|
|
806
816
|
const contensis = await this.ConnectContensis();
|
|
807
817
|
if (contensis) {
|
|
818
|
+
log.line();
|
|
819
|
+
if (contensis.isPreview) {
|
|
820
|
+
log.success(messages.migrate.preview());
|
|
821
|
+
} else {
|
|
822
|
+
log.warning(messages.migrate.commit());
|
|
823
|
+
}
|
|
808
824
|
const [rolesErr, roles] = await (0, import_await_to_js.default)(contensis.roles.GetRoles());
|
|
809
825
|
if (Array.isArray(roles)) {
|
|
810
826
|
log.success(messages.roles.list(currentEnv));
|
|
@@ -824,6 +840,337 @@ class ContensisCli {
|
|
|
824
840
|
}
|
|
825
841
|
}
|
|
826
842
|
};
|
|
843
|
+
PrintTagGroup = async (groupId) => {
|
|
844
|
+
const { currentEnv, log, messages } = this;
|
|
845
|
+
const contensis = await this.ConnectContensis();
|
|
846
|
+
if (contensis) {
|
|
847
|
+
const [groupsErr, groups] = await contensis.tags.GetTagGroups({
|
|
848
|
+
id: groupId
|
|
849
|
+
});
|
|
850
|
+
if (Array.isArray(groups)) {
|
|
851
|
+
log.success(messages.taggroups.list(currentEnv, groups.length));
|
|
852
|
+
if (groups.length)
|
|
853
|
+
await this.HandleFormattingAndOutput(groups[0], () => {
|
|
854
|
+
log.raw("");
|
|
855
|
+
log.object(groups[0]);
|
|
856
|
+
});
|
|
857
|
+
else log.error(messages.taggroups.failedGet(currentEnv, groupId));
|
|
858
|
+
}
|
|
859
|
+
if (groupsErr)
|
|
860
|
+
log.error(messages.taggroups.noList(currentEnv), groupsErr);
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
PrintTagGroups = async (query) => {
|
|
864
|
+
const { currentEnv, log, messages } = this;
|
|
865
|
+
const contensis = await this.ConnectContensis();
|
|
866
|
+
if (contensis) {
|
|
867
|
+
const [groupsErr, groups] = await contensis.tags.GetTagGroups({
|
|
868
|
+
q: query
|
|
869
|
+
});
|
|
870
|
+
if (Array.isArray(groups)) {
|
|
871
|
+
log.success(messages.taggroups.list(currentEnv, groups.length));
|
|
872
|
+
if (!groups.length) log.help(messages.taggroups.noneExist());
|
|
873
|
+
await this.HandleFormattingAndOutput(groups, () => {
|
|
874
|
+
for (const { version, ...group } of groups) {
|
|
875
|
+
log.raw("");
|
|
876
|
+
log.object(group);
|
|
877
|
+
}
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
if (groupsErr)
|
|
881
|
+
log.error(messages.taggroups.noList(currentEnv), groupsErr);
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
ImportTagGroups = async ({
|
|
885
|
+
commit,
|
|
886
|
+
fromFile,
|
|
887
|
+
getBy,
|
|
888
|
+
data,
|
|
889
|
+
tags,
|
|
890
|
+
save
|
|
891
|
+
}) => {
|
|
892
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
893
|
+
const { currentEnv, currentProject, log, messages } = this;
|
|
894
|
+
const contensis = await this.ConnectContensisImport({
|
|
895
|
+
commit,
|
|
896
|
+
fromFile,
|
|
897
|
+
importDataType: tags ? "user-input" : "tagGroups",
|
|
898
|
+
mixedData: {
|
|
899
|
+
tagGroups: data,
|
|
900
|
+
tags
|
|
901
|
+
}
|
|
902
|
+
});
|
|
903
|
+
if (contensis) {
|
|
904
|
+
log.line();
|
|
905
|
+
if (contensis.isPreview) {
|
|
906
|
+
log.success(messages.migrate.preview());
|
|
907
|
+
} else {
|
|
908
|
+
log.warning(messages.migrate.commit());
|
|
909
|
+
}
|
|
910
|
+
const method = (tags == null ? void 0 : tags.length) ? contensis.tags.MigrateTags : contensis.tags.MigrateTagGroups;
|
|
911
|
+
const [err, result] = await (0, import_await_to_js.default)(method(getBy));
|
|
912
|
+
if (err) (0, import_logger.logError)(err);
|
|
913
|
+
else {
|
|
914
|
+
const { tags: tags2 } = contensis.content.targets[currentProject];
|
|
915
|
+
await this.HandleFormattingAndOutput(
|
|
916
|
+
save ? [
|
|
917
|
+
...tags2.migrateGroups.map((g) => g.toJSON()),
|
|
918
|
+
...tags2.migrateTags.map((t) => t.toJSON())
|
|
919
|
+
] : result,
|
|
920
|
+
() => {
|
|
921
|
+
}
|
|
922
|
+
);
|
|
923
|
+
}
|
|
924
|
+
const tagsToMigrate = ((_b = (_a = result == null ? void 0 : result.tagsToMigrate) == null ? void 0 : _a[currentProject]) == null ? void 0 : _b.totalCount) || 0;
|
|
925
|
+
const groupsToMigrate = ((_d = (_c = result == null ? void 0 : result.groupsToMigrate) == null ? void 0 : _c[currentProject]) == null ? void 0 : _d.totalCount) || 0;
|
|
926
|
+
const tagsCommitted = (((_e = result == null ? void 0 : result.tagsResult) == null ? void 0 : _e.created) || 0) + (((_f = result == null ? void 0 : result.tagsResult) == null ? void 0 : _f.updated) || 0);
|
|
927
|
+
const groupsCommitted = (((_g = result == null ? void 0 : result.groupsResult) == null ? void 0 : _g.created) || 0) + (((_h = result == null ? void 0 : result.groupsResult) == null ? void 0 : _h.updated) || 0);
|
|
928
|
+
if (!err && !((_i = result.errors) == null ? void 0 : _i.length) && (!commit && tagsToMigrate + groupsToMigrate || commit && tagsCommitted + groupsCommitted)) {
|
|
929
|
+
log.success(
|
|
930
|
+
messages.taggroups.imported(
|
|
931
|
+
currentEnv,
|
|
932
|
+
commit,
|
|
933
|
+
commit ? groupsCommitted : groupsToMigrate,
|
|
934
|
+
commit ? tagsCommitted : tagsToMigrate
|
|
935
|
+
)
|
|
936
|
+
);
|
|
937
|
+
if (!commit) {
|
|
938
|
+
log.raw(``);
|
|
939
|
+
log.help(messages.migrate.commitTip());
|
|
940
|
+
}
|
|
941
|
+
} else {
|
|
942
|
+
log.error(
|
|
943
|
+
messages.taggroups.failedCreate(currentEnv, data == null ? void 0 : data[0].name),
|
|
944
|
+
err
|
|
945
|
+
);
|
|
946
|
+
}
|
|
947
|
+
if (tagsCommitted)
|
|
948
|
+
log.success(messages.tags.imported(currentEnv, commit, tagsCommitted));
|
|
949
|
+
} else {
|
|
950
|
+
log.warning(messages.models.noList(currentProject));
|
|
951
|
+
log.help(messages.connect.tip());
|
|
952
|
+
}
|
|
953
|
+
};
|
|
954
|
+
RemoveTagGroup = async (groupId, commit = false) => {
|
|
955
|
+
var _a;
|
|
956
|
+
const { currentEnv, currentProject, log, messages } = this;
|
|
957
|
+
const contensis = await this.ConnectContensisImport({
|
|
958
|
+
commit
|
|
959
|
+
});
|
|
960
|
+
if (contensis) {
|
|
961
|
+
log.line();
|
|
962
|
+
if (contensis.isPreview) {
|
|
963
|
+
log.success(messages.migrate.preview("DELETE"));
|
|
964
|
+
} else {
|
|
965
|
+
log.warning(messages.migrate.commit("DELETE"));
|
|
966
|
+
}
|
|
967
|
+
const result = await contensis.tags.DeleteTagGroups({ id: groupId });
|
|
968
|
+
await this.HandleFormattingAndOutput(result, () => {
|
|
969
|
+
var _a2;
|
|
970
|
+
log.raw("");
|
|
971
|
+
log.object((_a2 = result.existing[currentProject].groups) == null ? void 0 : _a2[0]);
|
|
972
|
+
});
|
|
973
|
+
if ((_a = result.errors) == null ? void 0 : _a.length) {
|
|
974
|
+
log.error(
|
|
975
|
+
messages.taggroups.failedRemove(currentEnv, groupId),
|
|
976
|
+
result.errors[0]
|
|
977
|
+
);
|
|
978
|
+
} else {
|
|
979
|
+
log.success(
|
|
980
|
+
messages.taggroups.removed(currentEnv, groupId, !contensis.isPreview)
|
|
981
|
+
);
|
|
982
|
+
if (!commit) {
|
|
983
|
+
log.raw(``);
|
|
984
|
+
log.help(messages.migrate.commitTip());
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
};
|
|
989
|
+
PrintTag = async (getBy, withDependents = false) => {
|
|
990
|
+
const { currentEnv, log, messages } = this;
|
|
991
|
+
const contensis = await this.ConnectContensis();
|
|
992
|
+
if (contensis) {
|
|
993
|
+
const [tagsErr, result] = await contensis.tags.GetTags(getBy, {
|
|
994
|
+
withDependents
|
|
995
|
+
});
|
|
996
|
+
if (Array.isArray(result)) {
|
|
997
|
+
let tags = [];
|
|
998
|
+
const groups = [];
|
|
999
|
+
if (withDependents) (0, import_util.splitTagsAndGroups)(result, tags, groups);
|
|
1000
|
+
else tags = result;
|
|
1001
|
+
log.success(messages.tags.list(currentEnv, tags.length));
|
|
1002
|
+
if (tags)
|
|
1003
|
+
await this.HandleFormattingAndOutput(result, () => {
|
|
1004
|
+
for (const tag of tags) {
|
|
1005
|
+
log.raw("");
|
|
1006
|
+
log.object(tag);
|
|
1007
|
+
}
|
|
1008
|
+
if (groups.length) {
|
|
1009
|
+
log.raw("");
|
|
1010
|
+
log.success(messages.taggroups.list(currentEnv, groups.length));
|
|
1011
|
+
for (const group of groups) {
|
|
1012
|
+
log.raw("");
|
|
1013
|
+
log.object(group);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
});
|
|
1017
|
+
else log.error(messages.tags.failedGet(currentEnv));
|
|
1018
|
+
}
|
|
1019
|
+
if (tagsErr) log.error(messages.tags.noList(currentEnv), tagsErr);
|
|
1020
|
+
}
|
|
1021
|
+
};
|
|
1022
|
+
PrintTags = async (getBy, withDependents = false) => {
|
|
1023
|
+
const { currentEnv, log, messages } = this;
|
|
1024
|
+
const contensis = await this.ConnectContensis();
|
|
1025
|
+
if (contensis) {
|
|
1026
|
+
const [tagsErr, result] = await contensis.tags.GetTags(getBy, {
|
|
1027
|
+
withDependents
|
|
1028
|
+
});
|
|
1029
|
+
if (Array.isArray(result)) {
|
|
1030
|
+
let tags = [];
|
|
1031
|
+
const groups = [];
|
|
1032
|
+
if (withDependents) (0, import_util.splitTagsAndGroups)(result, tags, groups);
|
|
1033
|
+
else tags = result;
|
|
1034
|
+
log.success(messages.tags.list(currentEnv, tags.length));
|
|
1035
|
+
if (!tags.length) log.help(messages.tags.noneExist());
|
|
1036
|
+
await this.HandleFormattingAndOutput(result, () => {
|
|
1037
|
+
for (const { version, ...tag } of tags) {
|
|
1038
|
+
log.raw("");
|
|
1039
|
+
log.object(tag);
|
|
1040
|
+
}
|
|
1041
|
+
if (groups.length) {
|
|
1042
|
+
log.raw("");
|
|
1043
|
+
log.success(messages.taggroups.list(currentEnv, groups.length));
|
|
1044
|
+
for (const { version, ...group } of groups) {
|
|
1045
|
+
log.raw("");
|
|
1046
|
+
log.object(group);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
if (tagsErr) log.error(messages.tags.noList(currentEnv), tagsErr);
|
|
1052
|
+
}
|
|
1053
|
+
};
|
|
1054
|
+
ImportTags = async ({
|
|
1055
|
+
commit,
|
|
1056
|
+
fromFile,
|
|
1057
|
+
getBy,
|
|
1058
|
+
data,
|
|
1059
|
+
save
|
|
1060
|
+
}) => {
|
|
1061
|
+
var _a, _b, _c, _d, _e;
|
|
1062
|
+
const { currentEnv, currentProject, log, messages } = this;
|
|
1063
|
+
const mixedData = { tags: [], tagGroups: [] };
|
|
1064
|
+
if (data) {
|
|
1065
|
+
mixedData.tags = data;
|
|
1066
|
+
mixedData.tagGroups = [...new Set(data.map((t) => t.groupId))].map(
|
|
1067
|
+
(id) => ({
|
|
1068
|
+
id
|
|
1069
|
+
})
|
|
1070
|
+
);
|
|
1071
|
+
}
|
|
1072
|
+
if (fromFile) {
|
|
1073
|
+
const fileData = fromFile ? await (0, import_file_provider.readFileAsJSON)(fromFile) || [] : [];
|
|
1074
|
+
(0, import_util.splitTagsAndGroups)(fileData, mixedData.tags, mixedData.tagGroups);
|
|
1075
|
+
}
|
|
1076
|
+
const contensis = await this.ConnectContensisImport({
|
|
1077
|
+
commit,
|
|
1078
|
+
importDataType: "tags",
|
|
1079
|
+
mixedData
|
|
1080
|
+
});
|
|
1081
|
+
if (contensis) {
|
|
1082
|
+
log.line();
|
|
1083
|
+
if (contensis.isPreview) {
|
|
1084
|
+
log.success(messages.migrate.preview());
|
|
1085
|
+
} else {
|
|
1086
|
+
log.warning(messages.migrate.commit());
|
|
1087
|
+
}
|
|
1088
|
+
contensis.payload.tags = data;
|
|
1089
|
+
const [err, result] = await (0, import_await_to_js.default)(contensis.tags.MigrateTags(getBy));
|
|
1090
|
+
if (err) (0, import_logger.logError)(err);
|
|
1091
|
+
else {
|
|
1092
|
+
const { tags } = contensis.content.targets[currentProject];
|
|
1093
|
+
await this.HandleFormattingAndOutput(
|
|
1094
|
+
save ? [
|
|
1095
|
+
...tags.migrateGroups.map((g) => g.toJSON()),
|
|
1096
|
+
...tags.migrateTags.map((t) => t.toJSON())
|
|
1097
|
+
] : result,
|
|
1098
|
+
() => {
|
|
1099
|
+
}
|
|
1100
|
+
);
|
|
1101
|
+
}
|
|
1102
|
+
if (!err && !((_a = result.errors) == null ? void 0 : _a.length) && (!commit && result.tagsToMigrate[currentProject].totalCount || commit && (((_b = result.tagsResult) == null ? void 0 : _b.created) || ((_c = result.tagsResult) == null ? void 0 : _c.updated)))) {
|
|
1103
|
+
log.success(
|
|
1104
|
+
messages.tags.imported(
|
|
1105
|
+
currentEnv,
|
|
1106
|
+
commit,
|
|
1107
|
+
commit ? (((_d = result.tagsResult) == null ? void 0 : _d.created) || 0) + (((_e = result.tagsResult) == null ? void 0 : _e.updated) || 0) : result.tagsToMigrate[currentProject].totalCount
|
|
1108
|
+
)
|
|
1109
|
+
);
|
|
1110
|
+
if (!commit) {
|
|
1111
|
+
log.raw(``);
|
|
1112
|
+
log.help(messages.migrate.commitTip());
|
|
1113
|
+
}
|
|
1114
|
+
} else {
|
|
1115
|
+
log.error(
|
|
1116
|
+
messages.tags.failedCreate(
|
|
1117
|
+
currentEnv,
|
|
1118
|
+
(data == null ? void 0 : data.length) === 1 ? data == null ? void 0 : data[0].label["en-GB"] : void 0
|
|
1119
|
+
),
|
|
1120
|
+
err
|
|
1121
|
+
);
|
|
1122
|
+
}
|
|
1123
|
+
} else {
|
|
1124
|
+
log.warning(messages.models.noList(currentProject));
|
|
1125
|
+
log.help(messages.connect.tip());
|
|
1126
|
+
}
|
|
1127
|
+
};
|
|
1128
|
+
RemoveTags = async (getBy, commit = false) => {
|
|
1129
|
+
var _a, _b;
|
|
1130
|
+
const { currentEnv, currentProject, log, messages } = this;
|
|
1131
|
+
this.contensisOpts.concurrency = 1;
|
|
1132
|
+
const contensis = await this.ConnectContensisImport({
|
|
1133
|
+
commit,
|
|
1134
|
+
importDataType: "user-input"
|
|
1135
|
+
// 'user-input' import type does not require a source cms
|
|
1136
|
+
});
|
|
1137
|
+
if (contensis) {
|
|
1138
|
+
log.line();
|
|
1139
|
+
if (contensis.isPreview) {
|
|
1140
|
+
log.success(messages.migrate.preview("DELETE"));
|
|
1141
|
+
} else {
|
|
1142
|
+
log.warning(messages.migrate.commit("DELETE"));
|
|
1143
|
+
}
|
|
1144
|
+
const result = await contensis.tags.DeleteTags(getBy);
|
|
1145
|
+
const deleted = (commit ? (_a = result.tagsResult) == null ? void 0 : _a.deleted : result.tagsToMigrate[currentProject].delete) || 0;
|
|
1146
|
+
await this.HandleFormattingAndOutput(result, () => {
|
|
1147
|
+
const tags = result.existing[currentProject].tags;
|
|
1148
|
+
for (const { version, ...tag } of tags || []) {
|
|
1149
|
+
const { status, error } = result.tagsToMigrate.tagIds[tag.groupId][tag.id][currentProject];
|
|
1150
|
+
log.raw("");
|
|
1151
|
+
log.object({
|
|
1152
|
+
...tag,
|
|
1153
|
+
status,
|
|
1154
|
+
error
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
});
|
|
1158
|
+
if ((_b = result.errors) == null ? void 0 : _b.length) {
|
|
1159
|
+
log.error(
|
|
1160
|
+
messages.tags.failedRemove(currentEnv, result.errors.length),
|
|
1161
|
+
result.errors
|
|
1162
|
+
);
|
|
1163
|
+
} else {
|
|
1164
|
+
log.success(
|
|
1165
|
+
messages.tags.removed(currentEnv, deleted, !contensis.isPreview)
|
|
1166
|
+
);
|
|
1167
|
+
if (!commit && deleted) {
|
|
1168
|
+
log.raw(``);
|
|
1169
|
+
log.help(messages.migrate.commitTip());
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
827
1174
|
PrintWorkflows = async () => {
|
|
828
1175
|
const { currentEnv, log, messages } = this;
|
|
829
1176
|
const contensis = await this.ConnectContensis();
|
|
@@ -1382,6 +1729,7 @@ Components:`));
|
|
|
1382
1729
|
RemoveEntries = async (commit = false) => {
|
|
1383
1730
|
var _a, _b, _c;
|
|
1384
1731
|
const { currentEnv, currentProject, log, messages } = this;
|
|
1732
|
+
this.contensisOpts.concurrency = 1;
|
|
1385
1733
|
const contensis = await this.ConnectContensisImport({
|
|
1386
1734
|
commit,
|
|
1387
1735
|
importDataType: "user-input"
|
|
@@ -1405,7 +1753,7 @@ Components:`));
|
|
|
1405
1753
|
log.success(messages.entries.removed(currentEnv, commit));
|
|
1406
1754
|
if (!commit) {
|
|
1407
1755
|
log.raw(``);
|
|
1408
|
-
log.help(messages.
|
|
1756
|
+
log.help(messages.migrate.commitTip());
|
|
1409
1757
|
}
|
|
1410
1758
|
} else {
|
|
1411
1759
|
log.error(messages.entries.failedRemove(currentEnv), err);
|
|
@@ -1505,7 +1853,7 @@ Components:`));
|
|
|
1505
1853
|
);
|
|
1506
1854
|
if (!commit) {
|
|
1507
1855
|
log.raw(``);
|
|
1508
|
-
log.help(messages.
|
|
1856
|
+
log.help(messages.migrate.commitTip());
|
|
1509
1857
|
}
|
|
1510
1858
|
} else {
|
|
1511
1859
|
log.error(messages.entries.failedImport(currentEnv), err);
|
|
@@ -1563,7 +1911,7 @@ Components:`));
|
|
|
1563
1911
|
);
|
|
1564
1912
|
if (!commit) {
|
|
1565
1913
|
log.raw(``);
|
|
1566
|
-
log.help(messages.
|
|
1914
|
+
log.help(messages.migrate.commitTip());
|
|
1567
1915
|
}
|
|
1568
1916
|
} else {
|
|
1569
1917
|
log.error(messages.entries.failedImport(currentEnv), err);
|
|
@@ -1620,7 +1968,7 @@ Components:`));
|
|
|
1620
1968
|
);
|
|
1621
1969
|
if (!commit) {
|
|
1622
1970
|
log.raw(``);
|
|
1623
|
-
log.help(messages.
|
|
1971
|
+
log.help(messages.migrate.commitTip());
|
|
1624
1972
|
}
|
|
1625
1973
|
} else {
|
|
1626
1974
|
log.error(messages.entries.update.failed(currentEnv), err);
|
|
@@ -1963,7 +2311,7 @@ Components:`));
|
|
|
1963
2311
|
`Request for blockId: ${blockId}, branch: ${branch}, version: latest`
|
|
1964
2312
|
);
|
|
1965
2313
|
log.info(
|
|
1966
|
-
`Get block versions response was: ${(0,
|
|
2314
|
+
`Get block versions response was: ${(0, import_assert.tryStringify)(blockVersions)}`
|
|
1967
2315
|
);
|
|
1968
2316
|
log.error(messages.blocks.failedParsingVersion());
|
|
1969
2317
|
return [parseVersionEx, void 0];
|
|
@@ -2201,7 +2549,7 @@ Components:`));
|
|
|
2201
2549
|
log.raw("");
|
|
2202
2550
|
if (output) {
|
|
2203
2551
|
let writeString = "";
|
|
2204
|
-
const isText = !(0,
|
|
2552
|
+
const isText = !(0, import_assert.tryParse)(obj) && typeof obj === "string";
|
|
2205
2553
|
if (format === "csv") {
|
|
2206
2554
|
writeString = await (0, import_csv.csvFormatter)((0, import_json.limitFields)(obj, fields));
|
|
2207
2555
|
} else if (format === "html") {
|