contensis-cli 1.0.12-beta.5 → 1.0.12-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.
@@ -594,7 +594,7 @@ class ContensisCli {
594
594
  }
595
595
  }
596
596
  };
597
- CreateApiKey = async (name, description) => {
597
+ CreateApiKey = async (name, description = "") => {
598
598
  const { currentEnv, log, messages } = this;
599
599
  const contensis = await this.ConnectContensis();
600
600
  if (contensis) {
@@ -796,6 +796,78 @@ class ContensisCli {
796
796
  }
797
797
  }
798
798
  };
799
+ PrintWorkflows = async () => {
800
+ const { currentEnv, log, messages } = this;
801
+ const contensis = await this.ConnectContensis();
802
+ if (contensis) {
803
+ const [workflowsErr, workflows] = await contensis.content.sourceRepo.workflows.GetWorkflows();
804
+ if (Array.isArray(workflows)) {
805
+ log.success(messages.workflows.list(currentEnv));
806
+ if (!workflows.length)
807
+ log.help(messages.workflows.noneExist());
808
+ const stringFromLanguageObject = (o) => {
809
+ var _a;
810
+ return (_a = Object.values(o || {})) == null ? void 0 : _a[0];
811
+ };
812
+ this.HandleFormattingAndOutput(workflows, () => {
813
+ for (const {
814
+ id,
815
+ name,
816
+ description,
817
+ states,
818
+ eventGroups,
819
+ isSystem
820
+ } of workflows) {
821
+ const color = isSystem ? (s) => s : log.infoText;
822
+ console.log(
823
+ color(
824
+ ` - ${import_chalk.default.bold(
825
+ stringFromLanguageObject(name)
826
+ )} ${log.infoText(id)}`
827
+ )
828
+ );
829
+ if (description)
830
+ console.log(
831
+ log.infoText(` ${stringFromLanguageObject(description)}`)
832
+ );
833
+ if (isSystem === false)
834
+ console.log(` ${import_chalk.default.bold.grey("isSystem")}: false`);
835
+ if (states == null ? void 0 : states.length)
836
+ console.log(
837
+ ` ${import_chalk.default.bold.grey("states")}: ${states.map((state) => state.id).join(", ")}`
838
+ );
839
+ if (eventGroups == null ? void 0 : eventGroups.length)
840
+ console.log(
841
+ ` ${import_chalk.default.bold.grey("eventGroups")}: ${eventGroups.map((evtGrp) => evtGrp.id).join(", ")}`
842
+ );
843
+ }
844
+ });
845
+ }
846
+ if (workflowsErr) {
847
+ log.error(messages.workflows.noList(currentEnv));
848
+ log.error((0, import_json.jsonFormatter)(workflowsErr));
849
+ }
850
+ }
851
+ };
852
+ PrintWorkflow = async (workflowNameOrId) => {
853
+ const { currentEnv, log, messages } = this;
854
+ const contensis = await this.ConnectContensis();
855
+ if (contensis) {
856
+ const [workflowsErr, workflows] = await contensis.content.sourceRepo.workflows.GetWorkflows();
857
+ if (Array.isArray(workflows)) {
858
+ log.success(messages.workflows.list(currentEnv));
859
+ const workflow = (0, import_find.findByIdOrName)(workflows, workflowNameOrId);
860
+ if (workflow)
861
+ this.HandleFormattingAndOutput(workflow, log.object);
862
+ else
863
+ log.error(messages.workflows.failedGet(currentEnv, workflowNameOrId));
864
+ }
865
+ if (workflowsErr) {
866
+ log.error(messages.workflows.noList(currentEnv));
867
+ log.error((0, import_json.jsonFormatter)(workflowsErr));
868
+ }
869
+ }
870
+ };
799
871
  CreateProject = async (project) => {
800
872
  const { currentEnv, log, messages } = this;
801
873
  const contensis = await this.ConnectContensis();
@@ -1344,6 +1416,7 @@ Components:`));
1344
1416
  const root = contensis.nodes.sourceRepo.nodes.tree;
1345
1417
  log.success(messages.nodes.get(currentProject, rootPath, depth));
1346
1418
  this.HandleFormattingAndOutput(nodes, () => {
1419
+ log.object({ ...root, children: void 0, language: void 0 });
1347
1420
  (0, import_console.printNodeTreeOutput)(this, root);
1348
1421
  });
1349
1422
  } else {
@@ -1354,9 +1427,10 @@ Components:`));
1354
1427
  ImportNodes = async ({
1355
1428
  commit,
1356
1429
  fromFile,
1357
- logOutput
1430
+ logOutput,
1431
+ logLimit
1358
1432
  }) => {
1359
- var _a, _b, _c, _d, _e;
1433
+ var _a, _b, _c, _d, _e, _f, _g;
1360
1434
  const { currentEnv, currentProject, log, messages } = this;
1361
1435
  const contensis = await this.ConnectContensisImport({
1362
1436
  commit,
@@ -1371,39 +1445,42 @@ Components:`));
1371
1445
  console.log(log.warningText(` *** COMMITTING IMPORT *** `));
1372
1446
  }
1373
1447
  const [err, result] = await contensis.MigrateNodes();
1448
+ const migrateTree = contensis.nodes.targetRepos[currentProject].nodes.migrateNodesTreeView;
1374
1449
  if (err)
1375
- (0, import_logger.logError)(err);
1450
+ log.raw(``);
1376
1451
  else
1377
1452
  this.HandleFormattingAndOutput(result, () => {
1453
+ (0, import_console.printNodeTreeOutput)(this, migrateTree, logOutput, logLimit);
1378
1454
  (0, import_console.printNodesMigrateResult)(this, result, {
1379
1455
  showAll: logOutput === "all",
1380
1456
  showChanged: logOutput === "changes"
1381
1457
  });
1382
1458
  });
1383
- const nodesTotalCount = (_a = result == null ? void 0 : result.nodesToMigrate) == null ? void 0 : _a[currentProject].totalCount;
1459
+ const nodesMigrateCount = (_a = result == null ? void 0 : result.nodesToMigrate) == null ? void 0 : _a[currentProject].totalCount;
1384
1460
  const nodesCreated = ((_b = result == null ? void 0 : result.nodesResult) == null ? void 0 : _b["created"]) || 0;
1385
1461
  const nodesUpdated = ((_c = result == null ? void 0 : result.nodesResult) == null ? void 0 : _c["updated"]) || 0;
1386
- const noChange = ((_d = result == null ? void 0 : result.nodesToMigrate) == null ? void 0 : _d[currentProject]["no change"]) !== 0;
1387
- if (!err && (!((_e = result.errors) == null ? void 0 : _e.length) || this.contensisOpts.ignoreErrors) && (!commit && nodesTotalCount || commit && (nodesCreated || nodesUpdated))) {
1462
+ const nodesErrored = ((_d = result == null ? void 0 : result.nodesResult) == null ? void 0 : _d["errored"]) || 0;
1463
+ const noChanges = ((_e = result == null ? void 0 : result.nodesToMigrate) == null ? void 0 : _e[currentProject]["no change"]) && nodesMigrateCount === 0;
1464
+ if (!err && (!((_f = result.errors) == null ? void 0 : _f.length) || this.contensisOpts.ignoreErrors) && (!commit && nodesMigrateCount || commit && (nodesCreated || nodesUpdated || ((_g = result.errors) == null ? void 0 : _g.length)))) {
1388
1465
  let totalCount;
1389
1466
  if (commit) {
1390
1467
  let created = typeof nodesCreated === "number" ? nodesCreated : 0;
1391
1468
  let updated = typeof nodesUpdated === "number" ? nodesUpdated : 0;
1392
1469
  totalCount = created + updated;
1393
1470
  } else {
1394
- totalCount = typeof nodesTotalCount === "number" ? nodesTotalCount : 0;
1471
+ totalCount = typeof nodesMigrateCount === "number" ? nodesMigrateCount : 0;
1395
1472
  }
1396
1473
  log.success(messages.nodes.imported(currentEnv, commit, totalCount));
1474
+ log.raw(``);
1397
1475
  if (!commit) {
1398
- log.raw(``);
1399
1476
  log.help(messages.nodes.commitTip());
1400
1477
  }
1401
1478
  } else {
1402
- if (noChange) {
1479
+ if (noChanges && !err && !nodesErrored) {
1403
1480
  log.help(messages.nodes.noChange(currentEnv));
1404
1481
  } else {
1405
1482
  log.error(messages.nodes.failedImport(currentEnv), err);
1406
- if (!nodesTotalCount)
1483
+ if (!nodesMigrateCount)
1407
1484
  log.help(messages.nodes.notFound(currentEnv));
1408
1485
  }
1409
1486
  }