contensis-cli 1.0.0-beta.38 → 1.0.0-beta.39
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/create.js +4 -2
- package/dist/commands/create.js.map +2 -2
- package/dist/commands/diff.js +57 -0
- package/dist/commands/diff.js.map +7 -0
- package/dist/commands/get.js +40 -11
- package/dist/commands/get.js.map +2 -2
- package/dist/commands/globalOptions.js +4 -3
- package/dist/commands/globalOptions.js.map +2 -2
- package/dist/commands/import.js +31 -5
- package/dist/commands/import.js.map +2 -2
- package/dist/commands/index.js +6 -0
- package/dist/commands/index.js.map +2 -2
- package/dist/commands/list.js +19 -8
- package/dist/commands/list.js.map +2 -2
- package/dist/commands/push.js +2 -1
- package/dist/commands/push.js.map +2 -2
- package/dist/commands/release.js +2 -1
- package/dist/commands/release.js.map +2 -2
- package/dist/commands/remove.js +6 -4
- package/dist/commands/remove.js.map +2 -2
- package/dist/commands/set.js +6 -3
- package/dist/commands/set.js.map +2 -2
- package/dist/localisation/en-GB.js +43 -24
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/providers/SessionCacheProvider.js +2 -2
- package/dist/providers/SessionCacheProvider.js.map +2 -2
- package/dist/services/ContensisCliService.js +240 -72
- package/dist/services/ContensisCliService.js.map +3 -3
- package/dist/shell.js +4 -1
- package/dist/shell.js.map +2 -2
- package/dist/util/console.printer.js +87 -4
- package/dist/util/console.printer.js.map +2 -2
- package/dist/util/logger.js +45 -13
- package/dist/util/logger.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/create.ts +2 -0
- package/src/commands/diff.ts +39 -0
- package/src/commands/get.ts +48 -4
- package/src/commands/globalOptions.ts +5 -4
- package/src/commands/import.ts +36 -2
- package/src/commands/index.ts +6 -0
- package/src/commands/list.ts +34 -9
- package/src/commands/push.ts +1 -0
- package/src/commands/release.ts +1 -0
- package/src/commands/remove.ts +4 -2
- package/src/commands/set.ts +3 -0
- package/src/localisation/en-GB.ts +58 -33
- package/src/providers/SessionCacheProvider.ts +3 -2
- package/src/services/ContensisCliService.ts +301 -84
- package/src/shell.ts +4 -2
- package/src/util/console.printer.ts +100 -3
- package/src/util/logger.ts +84 -15
- package/src/version.ts +1 -1
|
@@ -58,10 +58,8 @@ class ContensisCli {
|
|
|
58
58
|
session;
|
|
59
59
|
contensis;
|
|
60
60
|
contensisOpts;
|
|
61
|
-
contentTypes;
|
|
62
|
-
components;
|
|
63
61
|
currentProject;
|
|
64
|
-
|
|
62
|
+
sourceAlias;
|
|
65
63
|
targetEnv;
|
|
66
64
|
urls;
|
|
67
65
|
log = import_logger.Logger;
|
|
@@ -94,6 +92,18 @@ class ContensisCli {
|
|
|
94
92
|
};
|
|
95
93
|
}
|
|
96
94
|
}
|
|
95
|
+
get contentTypes() {
|
|
96
|
+
var _a;
|
|
97
|
+
return (_a = this.contensis) == null ? void 0 : _a.models.contentTypes();
|
|
98
|
+
}
|
|
99
|
+
get components() {
|
|
100
|
+
var _a;
|
|
101
|
+
return (_a = this.contensis) == null ? void 0 : _a.models.components();
|
|
102
|
+
}
|
|
103
|
+
get models() {
|
|
104
|
+
var _a;
|
|
105
|
+
return (_a = this.contensis) == null ? void 0 : _a.models.contentModels();
|
|
106
|
+
}
|
|
97
107
|
constructor(args, outputOpts, contensisOpts = {}) {
|
|
98
108
|
const [exe, script, verb = "", noun = "", ...restArgs] = args;
|
|
99
109
|
this.verb = verb == null ? void 0 : verb.toLowerCase();
|
|
@@ -119,7 +129,7 @@ class ContensisCli {
|
|
|
119
129
|
if (outputOpts == null ? void 0 : outputOpts.sharedSecret)
|
|
120
130
|
env.passwordFallback = outputOpts.sharedSecret;
|
|
121
131
|
this.currentProject = (env == null ? void 0 : env.currentProject) || "null";
|
|
122
|
-
this.
|
|
132
|
+
this.sourceAlias = (outputOpts == null ? void 0 : outputOpts.sourceAlias) || currentEnvironment;
|
|
123
133
|
if (currentEnvironment) {
|
|
124
134
|
this.urls = (0, import_util.url)(currentEnvironment, (env == null ? void 0 : env.currentProject) || "website");
|
|
125
135
|
}
|
|
@@ -220,20 +230,23 @@ class ContensisCli {
|
|
|
220
230
|
return this.contensis;
|
|
221
231
|
};
|
|
222
232
|
ConnectContensisImport = async ({
|
|
223
|
-
commit,
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
fileDataType
|
|
233
|
+
commit = false,
|
|
234
|
+
fromFile,
|
|
235
|
+
importDataType
|
|
227
236
|
}) => {
|
|
228
237
|
var _a, _b, _c, _d, _e, _f;
|
|
229
|
-
const
|
|
238
|
+
const source = fromFile ? "file" : "contensis";
|
|
239
|
+
const fileData = fromFile ? (0, import_file_provider.readJsonFile)(fromFile) || [] : [];
|
|
240
|
+
if (typeof fileData === "string")
|
|
241
|
+
throw new Error(`Import file format must be of type JSON`);
|
|
242
|
+
const { contensisOpts, currentEnv, env, log, messages, sourceAlias } = this;
|
|
230
243
|
const environments = this.cache.environments || {};
|
|
231
|
-
const sourceEnvironment = environments[
|
|
244
|
+
const sourceEnvironment = environments[sourceAlias || ""] || {};
|
|
232
245
|
const sourceCms = "source" in contensisOpts && contensisOpts.source || {};
|
|
233
246
|
const sourceUserId = sourceCms.clientId || sourceCms.username || sourceEnvironment.lastUserId;
|
|
234
247
|
const sourceProjectId = sourceCms.project || sourceEnvironment.currentProject || "website";
|
|
235
248
|
const isSourceGuidId = sourceUserId && (0, import_util.isUuid)(sourceUserId);
|
|
236
|
-
const sourceUrls = (0, import_util.url)(
|
|
249
|
+
const sourceUrls = (0, import_util.url)(sourceAlias || "", sourceProjectId);
|
|
237
250
|
const sourcePassword = sourceCms.sharedSecret || sourceCms.password || sourceEnvironment.passwordFallback;
|
|
238
251
|
const targetUserId = env == null ? void 0 : env.lastUserId;
|
|
239
252
|
const isTargetGuidId = targetUserId && (0, import_util.isUuid)(targetUserId);
|
|
@@ -241,7 +254,8 @@ class ContensisCli {
|
|
|
241
254
|
const sourceCredentials = await this.GetCredentials(
|
|
242
255
|
sourceUserId,
|
|
243
256
|
sourcePassword,
|
|
244
|
-
|
|
257
|
+
sourceAlias,
|
|
258
|
+
false
|
|
245
259
|
);
|
|
246
260
|
const cachedSourcePassword = (_a = sourceCredentials == null ? void 0 : sourceCredentials.current) == null ? void 0 : _a.password;
|
|
247
261
|
const targetCredentials = await this.GetCredentials(
|
|
@@ -250,7 +264,7 @@ class ContensisCli {
|
|
|
250
264
|
);
|
|
251
265
|
const cachedTargetPassword = (_b = targetCredentials == null ? void 0 : targetCredentials.current) == null ? void 0 : _b.password;
|
|
252
266
|
if (cachedSourcePassword && cachedTargetPassword) {
|
|
253
|
-
if (source === "file" ||
|
|
267
|
+
if (source === "file" || importDataType === "user-input") {
|
|
254
268
|
this.contensis = new import_migratortron.ContensisMigrationService(
|
|
255
269
|
{
|
|
256
270
|
concurrency: 3,
|
|
@@ -265,7 +279,7 @@ class ContensisCli {
|
|
|
265
279
|
targetProjects: [env.currentProject || ""],
|
|
266
280
|
assetHostname: (_d = this.urls) == null ? void 0 : _d.previewWeb
|
|
267
281
|
},
|
|
268
|
-
...
|
|
282
|
+
...importDataType ? { [importDataType]: fileData } : {}
|
|
269
283
|
},
|
|
270
284
|
!commit
|
|
271
285
|
);
|
|
@@ -305,8 +319,9 @@ class ContensisCli {
|
|
|
305
319
|
if (!targetUserId)
|
|
306
320
|
log.help(messages.connect.tip());
|
|
307
321
|
}
|
|
322
|
+
return this.contensis;
|
|
308
323
|
};
|
|
309
|
-
GetCredentials = async (userId, password, currentEnv = this.currentEnv) => {
|
|
324
|
+
GetCredentials = async (userId, password, currentEnv = this.currentEnv, saveCurrentEnv = true) => {
|
|
310
325
|
const { env, log, messages } = this;
|
|
311
326
|
if (userId) {
|
|
312
327
|
const [credentialError, credentials] = await new import_CredentialProvider.default(
|
|
@@ -324,7 +339,7 @@ class ContensisCli {
|
|
|
324
339
|
}
|
|
325
340
|
} else {
|
|
326
341
|
env.passwordFallback = void 0;
|
|
327
|
-
this.session.UpdateEnv(env, currentEnv);
|
|
342
|
+
this.session.UpdateEnv(env, currentEnv, saveCurrentEnv);
|
|
328
343
|
}
|
|
329
344
|
return credentials;
|
|
330
345
|
}
|
|
@@ -579,12 +594,131 @@ class ContensisCli {
|
|
|
579
594
|
if (!this.contensis)
|
|
580
595
|
err = await this.HydrateContensis();
|
|
581
596
|
if (err)
|
|
582
|
-
log.error(messages.
|
|
583
|
-
if (this.contensis)
|
|
584
|
-
|
|
585
|
-
|
|
597
|
+
log.error(messages.models.noList(currentProject));
|
|
598
|
+
if (!this.contensis)
|
|
599
|
+
log.warning(messages.models.noList(currentProject));
|
|
600
|
+
return this.contensis;
|
|
601
|
+
};
|
|
602
|
+
PrintContentModels = async (modelIds = []) => {
|
|
603
|
+
const { currentProject, log, messages } = this;
|
|
604
|
+
const contensis = await this.GetContentTypes();
|
|
605
|
+
if (contensis) {
|
|
606
|
+
const { models, contentTypes = [], components = [] } = this;
|
|
607
|
+
const returnModels = (modelIds == null ? void 0 : modelIds.length) ? models == null ? void 0 : models.filter(
|
|
608
|
+
(m) => modelIds.some((id) => id.toLowerCase() === m.id.toLowerCase())
|
|
609
|
+
) : void 0;
|
|
610
|
+
const contentTypeIds = Array.from(
|
|
611
|
+
/* @__PURE__ */ new Set([
|
|
612
|
+
...(returnModels || models || []).map((m) => m.id),
|
|
613
|
+
...(returnModels || models || []).map((m) => {
|
|
614
|
+
var _a, _b;
|
|
615
|
+
return ((_b = (_a = m.dependencies) == null ? void 0 : _a.contentTypes) == null ? void 0 : _b.map((c) => c[0])) || [];
|
|
616
|
+
}).flat()
|
|
617
|
+
])
|
|
618
|
+
);
|
|
619
|
+
const componentIds = Array.from(
|
|
620
|
+
new Set(
|
|
621
|
+
(returnModels || models || []).map((m) => {
|
|
622
|
+
var _a, _b;
|
|
623
|
+
return ((_b = (_a = m.dependencies) == null ? void 0 : _a.components) == null ? void 0 : _b.map((c) => c[0])) || [];
|
|
624
|
+
}).flat()
|
|
625
|
+
)
|
|
626
|
+
);
|
|
627
|
+
const contentModelBackup = [
|
|
628
|
+
...contentTypes.filter((c) => contentTypeIds.includes(c.id)),
|
|
629
|
+
...components.filter((c) => componentIds.includes(c.id))
|
|
630
|
+
];
|
|
631
|
+
if (Array.isArray(returnModels)) {
|
|
632
|
+
log.success(messages.models.list(currentProject));
|
|
633
|
+
this.HandleFormattingAndOutput(contentModelBackup, () => {
|
|
634
|
+
for (const model of returnModels) {
|
|
635
|
+
log.raw("");
|
|
636
|
+
log.object(model);
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
} else {
|
|
640
|
+
log.success(
|
|
641
|
+
messages.models.get(currentProject, (models == null ? void 0 : models.length.toString()) || "0")
|
|
642
|
+
);
|
|
643
|
+
this.HandleFormattingAndOutput(contentModelBackup, () => {
|
|
644
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
645
|
+
log.raw("");
|
|
646
|
+
for (const model of models || []) {
|
|
647
|
+
const components2 = ((_a = model.components) == null ? void 0 : _a.length) || 0;
|
|
648
|
+
const contentTypes2 = ((_b = model.contentTypes) == null ? void 0 : _b.length) || 0;
|
|
649
|
+
const dependencies = (((_d = (_c = model.dependencies) == null ? void 0 : _c.components) == null ? void 0 : _d.length) || 0) + (((_f = (_e = model.dependencies) == null ? void 0 : _e.contentTypes) == null ? void 0 : _f.length) || 0);
|
|
650
|
+
const dependencyOf = (((_h = (_g = model.dependencyOf) == null ? void 0 : _g.components) == null ? void 0 : _h.length) || 0) + (((_j = (_i = model.dependencyOf) == null ? void 0 : _i.contentTypes) == null ? void 0 : _j.length) || 0);
|
|
651
|
+
const hasAny = components2 + contentTypes2 + dependencies + dependencyOf;
|
|
652
|
+
log.raw(
|
|
653
|
+
` - ${log.highlightText(log.boldText(model.id))} ${hasAny ? log.infoText(
|
|
654
|
+
`{ ${components2 ? `components: ${components2}, ` : ""}${contentTypes2 ? `contentTypes: ${contentTypes2}, ` : ""}${dependencies ? `references: ${dependencies}, ` : ""}${dependencyOf ? `required by: ${dependencyOf}` : ""} }`
|
|
655
|
+
) : ""}`
|
|
656
|
+
);
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
log.raw("");
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
ImportContentModels = async ({
|
|
664
|
+
commit,
|
|
665
|
+
fromFile
|
|
666
|
+
}) => {
|
|
667
|
+
const { currentProject, log, messages } = this;
|
|
668
|
+
const fileData = fromFile ? (0, import_file_provider.readJsonFile)(fromFile) || [] : [];
|
|
669
|
+
if (typeof fileData === "string")
|
|
670
|
+
throw new Error(`Import file format must be of type JSON`);
|
|
671
|
+
const contensis = await this.ConnectContensisImport({
|
|
672
|
+
commit,
|
|
673
|
+
fromFile,
|
|
674
|
+
importDataType: "models"
|
|
675
|
+
});
|
|
676
|
+
if (contensis) {
|
|
677
|
+
log.line();
|
|
678
|
+
if (contensis.isPreview) {
|
|
679
|
+
console.log(log.successText(` -- IMPORT PREVIEW -- `));
|
|
680
|
+
} else {
|
|
681
|
+
console.log(log.warningText(` *** COMMITTING IMPORT *** `));
|
|
682
|
+
}
|
|
683
|
+
const [migrateErr, result] = await contensis.MigrateContentModels();
|
|
684
|
+
if (migrateErr)
|
|
685
|
+
(0, import_logger.logError)(migrateErr);
|
|
686
|
+
else
|
|
687
|
+
this.HandleFormattingAndOutput(result, () => {
|
|
688
|
+
if (!commit) {
|
|
689
|
+
log.raw(log.boldText(`
|
|
690
|
+
Content types:`));
|
|
691
|
+
if (!result.contentTypes)
|
|
692
|
+
log.info(`- None returned
|
|
693
|
+
`);
|
|
694
|
+
else
|
|
695
|
+
(0, import_console.printModelMigrationAnalysis)(this, result.contentTypes);
|
|
696
|
+
log.raw(log.boldText(`
|
|
697
|
+
Components:`));
|
|
698
|
+
if (!result.components)
|
|
699
|
+
log.info(`- None returned
|
|
700
|
+
`);
|
|
701
|
+
else
|
|
702
|
+
(0, import_console.printModelMigrationAnalysis)(this, result.components);
|
|
703
|
+
} else {
|
|
704
|
+
const migrateResult = result;
|
|
705
|
+
log.raw(log.boldText(`
|
|
706
|
+
Content types:`));
|
|
707
|
+
(0, import_console.printModelMigrationResult)(
|
|
708
|
+
this,
|
|
709
|
+
migrateResult[currentProject].contentTypes
|
|
710
|
+
);
|
|
711
|
+
log.raw(log.boldText(`
|
|
712
|
+
Components:`));
|
|
713
|
+
(0, import_console.printModelMigrationResult)(
|
|
714
|
+
this,
|
|
715
|
+
migrateResult[currentProject].components
|
|
716
|
+
);
|
|
717
|
+
}
|
|
718
|
+
});
|
|
586
719
|
} else {
|
|
587
|
-
log.warning(messages.
|
|
720
|
+
log.warning(messages.models.noList(currentProject));
|
|
721
|
+
log.help(messages.connect.tip());
|
|
588
722
|
}
|
|
589
723
|
};
|
|
590
724
|
PrintContentTypes = async () => {
|
|
@@ -630,15 +764,12 @@ class ContensisCli {
|
|
|
630
764
|
};
|
|
631
765
|
RemoveContentTypes = async (contentTypeIds, commit = false) => {
|
|
632
766
|
const { currentProject, log, messages } = this;
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
const [err, result] = await this.contensis.DeleteContentTypes(
|
|
640
|
-
contentTypeIds
|
|
641
|
-
);
|
|
767
|
+
const contensis = await this.ConnectContensisImport({
|
|
768
|
+
commit,
|
|
769
|
+
importDataType: "user-input"
|
|
770
|
+
});
|
|
771
|
+
if (contensis) {
|
|
772
|
+
const [err, result] = await contensis.DeleteContentTypes(contentTypeIds);
|
|
642
773
|
if (err) {
|
|
643
774
|
log.error(
|
|
644
775
|
messages.contenttypes.failedRemove(
|
|
@@ -652,7 +783,7 @@ class ContensisCli {
|
|
|
652
783
|
messages.contenttypes.removed(
|
|
653
784
|
currentProject,
|
|
654
785
|
contentTypeIds.join('", "'),
|
|
655
|
-
!
|
|
786
|
+
!contensis.isPreview
|
|
656
787
|
)
|
|
657
788
|
);
|
|
658
789
|
this.HandleFormattingAndOutput(
|
|
@@ -672,15 +803,15 @@ class ContensisCli {
|
|
|
672
803
|
throw new Error(`Import file format must be of type JSON`);
|
|
673
804
|
if (!Array.isArray(fileData))
|
|
674
805
|
fileData = [fileData];
|
|
675
|
-
await this.ConnectContensisImport({
|
|
806
|
+
const contensis = await this.ConnectContensisImport({
|
|
676
807
|
commit,
|
|
677
|
-
|
|
808
|
+
importDataType: fromFile ? "user-input" : void 0
|
|
678
809
|
});
|
|
679
|
-
if (
|
|
810
|
+
if (contensis) {
|
|
680
811
|
for (const contentType of fileData) {
|
|
681
812
|
contentType.projectId = currentProject;
|
|
682
813
|
delete contentType.uuid;
|
|
683
|
-
const [err, created, createStatus] = await
|
|
814
|
+
const [err, created, createStatus] = await contensis.models.targetRepos[currentProject].repo.UpsertContentType(false, contentType);
|
|
684
815
|
if (err)
|
|
685
816
|
log.error(err.message, err);
|
|
686
817
|
if (createStatus) {
|
|
@@ -697,6 +828,49 @@ class ContensisCli {
|
|
|
697
828
|
}
|
|
698
829
|
}
|
|
699
830
|
};
|
|
831
|
+
DiffModels = async ({
|
|
832
|
+
fromFile
|
|
833
|
+
}, modelIds = []) => {
|
|
834
|
+
const { log } = this;
|
|
835
|
+
let fileData = fromFile ? (0, import_file_provider.readJsonFile)(fromFile) || [] : [];
|
|
836
|
+
if (typeof fileData === "string")
|
|
837
|
+
throw new Error(`Import file format must be of type JSON`);
|
|
838
|
+
if (!Array.isArray(fileData))
|
|
839
|
+
fileData = [fileData];
|
|
840
|
+
const contensis = await this.ConnectContensisImport({
|
|
841
|
+
fromFile,
|
|
842
|
+
importDataType: "models"
|
|
843
|
+
});
|
|
844
|
+
if (contensis) {
|
|
845
|
+
const [err, result] = await (0, import_await_to_js.default)(
|
|
846
|
+
contensis.models.Diff(fileData.length ? fileData : modelIds)
|
|
847
|
+
);
|
|
848
|
+
if (err)
|
|
849
|
+
log.error(err.message, err);
|
|
850
|
+
if (result)
|
|
851
|
+
this.HandleFormattingAndOutput(result, () => {
|
|
852
|
+
var _a;
|
|
853
|
+
log.success(
|
|
854
|
+
`Queried models ${log.infoText(
|
|
855
|
+
`"${(_a = result.query.modelIds) == null ? void 0 : _a.join(", ")}"`
|
|
856
|
+
)}
|
|
857
|
+
`
|
|
858
|
+
);
|
|
859
|
+
log.raw(log.boldText(`Content types:`));
|
|
860
|
+
if (!result.contentTypes)
|
|
861
|
+
log.info(`- None returned
|
|
862
|
+
`);
|
|
863
|
+
else
|
|
864
|
+
(0, import_console.printModelMigrationAnalysis)(this, result.contentTypes);
|
|
865
|
+
log.raw(log.boldText(`Components:`));
|
|
866
|
+
if (!result.components)
|
|
867
|
+
log.info(`- None returned
|
|
868
|
+
`);
|
|
869
|
+
else
|
|
870
|
+
(0, import_console.printModelMigrationAnalysis)(this, result.components);
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
};
|
|
700
874
|
PrintComponents = async () => {
|
|
701
875
|
const { currentProject, log, messages } = this;
|
|
702
876
|
await this.GetContentTypes();
|
|
@@ -736,13 +910,12 @@ class ContensisCli {
|
|
|
736
910
|
};
|
|
737
911
|
RemoveComponents = async (componentIds, commit = false) => {
|
|
738
912
|
const { currentProject, log, messages } = this;
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
const [err, result] = await this.contensis.DeleteContentTypes(
|
|
913
|
+
const contensis = await this.ConnectContensisImport({
|
|
914
|
+
commit,
|
|
915
|
+
importDataType: "user-input"
|
|
916
|
+
});
|
|
917
|
+
if (contensis) {
|
|
918
|
+
const [err, result] = await contensis.DeleteContentTypes(
|
|
746
919
|
void 0,
|
|
747
920
|
componentIds
|
|
748
921
|
);
|
|
@@ -759,7 +932,7 @@ class ContensisCli {
|
|
|
759
932
|
messages.components.removed(
|
|
760
933
|
currentProject,
|
|
761
934
|
componentIds.join('", "'),
|
|
762
|
-
!
|
|
935
|
+
!contensis.isPreview
|
|
763
936
|
)
|
|
764
937
|
);
|
|
765
938
|
this.HandleFormattingAndOutput(
|
|
@@ -779,15 +952,15 @@ class ContensisCli {
|
|
|
779
952
|
throw new Error(`Import file format must be of type JSON`);
|
|
780
953
|
if (!Array.isArray(fileData))
|
|
781
954
|
fileData = [fileData];
|
|
782
|
-
await this.ConnectContensisImport({
|
|
955
|
+
const contensis = await this.ConnectContensisImport({
|
|
783
956
|
commit,
|
|
784
|
-
|
|
957
|
+
importDataType: fromFile ? "user-input" : void 0
|
|
785
958
|
});
|
|
786
|
-
if (
|
|
959
|
+
if (contensis) {
|
|
787
960
|
for (const component of fileData) {
|
|
788
961
|
component.projectId = currentProject;
|
|
789
962
|
delete component.uuid;
|
|
790
|
-
const [err, created, createStatus] = await
|
|
963
|
+
const [err, created, createStatus] = await contensis.models.targetRepos[currentProject].repo.UpsertComponent(false, component);
|
|
791
964
|
if (err)
|
|
792
965
|
log.error(err.message, err);
|
|
793
966
|
if (createStatus) {
|
|
@@ -807,18 +980,17 @@ class ContensisCli {
|
|
|
807
980
|
RemoveEntry = async (id, commit = false) => {
|
|
808
981
|
var _a, _b, _c;
|
|
809
982
|
const { currentEnv, log, messages } = this;
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
if (this.contensis.isPreview) {
|
|
983
|
+
const contensis = await this.ConnectContensisImport({
|
|
984
|
+
commit,
|
|
985
|
+
importDataType: "user-input"
|
|
986
|
+
});
|
|
987
|
+
if (contensis) {
|
|
988
|
+
if (contensis.isPreview) {
|
|
817
989
|
console.log(log.successText(` -- PREVIEW -- `));
|
|
818
990
|
} else {
|
|
819
991
|
console.log(log.warningText(` *** COMMITTING DELETE *** `));
|
|
820
992
|
}
|
|
821
|
-
const [err, result] = await
|
|
993
|
+
const [err, result] = await contensis.DeleteEntries();
|
|
822
994
|
if (result)
|
|
823
995
|
this.HandleFormattingAndOutput(result, () => {
|
|
824
996
|
(0, import_console.printMigrateResult)(this, result, { action: "delete" });
|
|
@@ -838,23 +1010,23 @@ class ContensisCli {
|
|
|
838
1010
|
withDependents = false
|
|
839
1011
|
}) => {
|
|
840
1012
|
const { currentProject, log, messages } = this;
|
|
841
|
-
await this.ConnectContensis();
|
|
842
|
-
if (
|
|
1013
|
+
const contensis = await this.ConnectContensis();
|
|
1014
|
+
if (contensis) {
|
|
843
1015
|
log.line();
|
|
844
|
-
const entries = await
|
|
1016
|
+
const entries = await contensis.GetEntries({ withDependents });
|
|
845
1017
|
this.HandleFormattingAndOutput(
|
|
846
1018
|
entries,
|
|
847
1019
|
() => {
|
|
848
|
-
var _a
|
|
1020
|
+
var _a;
|
|
849
1021
|
return (0, import_migratortron.logEntriesTable)(
|
|
850
1022
|
entries,
|
|
851
1023
|
currentProject,
|
|
852
|
-
(
|
|
1024
|
+
(_a = contensis.payload.query) == null ? void 0 : _a.fields
|
|
853
1025
|
);
|
|
854
1026
|
}
|
|
855
1027
|
);
|
|
856
1028
|
} else {
|
|
857
|
-
log.warning(messages.
|
|
1029
|
+
log.warning(messages.models.noList(currentProject));
|
|
858
1030
|
log.help(messages.connect.tip());
|
|
859
1031
|
}
|
|
860
1032
|
};
|
|
@@ -863,23 +1035,19 @@ class ContensisCli {
|
|
|
863
1035
|
fromFile
|
|
864
1036
|
}) => {
|
|
865
1037
|
const { currentProject, log, messages } = this;
|
|
866
|
-
const
|
|
867
|
-
if (typeof fileData === "string")
|
|
868
|
-
throw new Error(`Import file format must be of type JSON`);
|
|
869
|
-
await this.ConnectContensisImport({
|
|
1038
|
+
const contensis = await this.ConnectContensisImport({
|
|
870
1039
|
commit,
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
fileDataType: "entries"
|
|
1040
|
+
fromFile,
|
|
1041
|
+
importDataType: "entries"
|
|
874
1042
|
});
|
|
875
|
-
if (
|
|
1043
|
+
if (contensis) {
|
|
876
1044
|
log.line();
|
|
877
|
-
if (
|
|
1045
|
+
if (contensis.isPreview) {
|
|
878
1046
|
console.log(log.successText(` -- IMPORT PREVIEW -- `));
|
|
879
1047
|
} else {
|
|
880
1048
|
console.log(log.warningText(` *** COMMITTING IMPORT *** `));
|
|
881
1049
|
}
|
|
882
|
-
const [migrateErr, migrateResult] = await
|
|
1050
|
+
const [migrateErr, migrateResult] = await contensis.MigrateEntries();
|
|
883
1051
|
if (migrateErr)
|
|
884
1052
|
(0, import_logger.logError)(migrateErr);
|
|
885
1053
|
else
|
|
@@ -887,7 +1055,7 @@ class ContensisCli {
|
|
|
887
1055
|
(0, import_console.printMigrateResult)(this, migrateResult);
|
|
888
1056
|
});
|
|
889
1057
|
} else {
|
|
890
|
-
log.warning(messages.
|
|
1058
|
+
log.warning(messages.models.noList(currentProject));
|
|
891
1059
|
log.help(messages.connect.tip());
|
|
892
1060
|
}
|
|
893
1061
|
};
|