contensis-cli 1.3.1-beta.0 → 1.3.1-beta.10

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.
Files changed (112) hide show
  1. package/README.md +78 -6
  2. package/dist/commands/copy.js +2 -2
  3. package/dist/commands/copy.js.map +2 -2
  4. package/dist/commands/create.js +1 -2
  5. package/dist/commands/create.js.map +1 -1
  6. package/dist/commands/globalOptions.js +16 -4
  7. package/dist/commands/globalOptions.js.map +2 -2
  8. package/dist/commands/import.js +1 -1
  9. package/dist/commands/import.js.map +2 -2
  10. package/dist/commands/index.js +4 -2
  11. package/dist/commands/index.js.map +2 -2
  12. package/dist/commands/list.js.map +1 -1
  13. package/dist/commands/login.js +1 -2
  14. package/dist/commands/login.js.map +1 -1
  15. package/dist/commands/push.js +102 -10
  16. package/dist/commands/push.js.map +3 -3
  17. package/dist/commands/remove.js +15 -4
  18. package/dist/commands/remove.js.map +2 -2
  19. package/dist/commands/set.js +2 -4
  20. package/dist/commands/set.js.map +1 -1
  21. package/dist/commands/update.js +70 -0
  22. package/dist/commands/update.js.map +7 -0
  23. package/dist/factories/RequestHandlerFactory.js +12 -5
  24. package/dist/factories/RequestHandlerFactory.js.map +2 -2
  25. package/dist/index.js +4 -0
  26. package/dist/index.js.map +1 -1
  27. package/dist/localisation/en-GB.js +19 -2
  28. package/dist/localisation/en-GB.js.map +2 -2
  29. package/dist/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.js.map +1 -1
  30. package/dist/mappers/DevInit-to-CIWorkflow.js +11 -6
  31. package/dist/mappers/DevInit-to-CIWorkflow.js.map +1 -1
  32. package/dist/mappers/DevRequests-to-RequestHanderCliArgs.js +4 -2
  33. package/dist/mappers/DevRequests-to-RequestHanderCliArgs.js.map +1 -1
  34. package/dist/models/CliService.d.js.map +1 -1
  35. package/dist/providers/CredentialProvider.js +11 -4
  36. package/dist/providers/CredentialProvider.js.map +2 -2
  37. package/dist/providers/GitHubCliModuleProvider.js +8 -10
  38. package/dist/providers/GitHubCliModuleProvider.js.map +1 -1
  39. package/dist/providers/HttpProvider.js +5 -4
  40. package/dist/providers/HttpProvider.js.map +1 -1
  41. package/dist/providers/ManifestProvider.js +1 -4
  42. package/dist/providers/ManifestProvider.js.map +1 -1
  43. package/dist/providers/SessionCacheProvider.js +26 -8
  44. package/dist/providers/SessionCacheProvider.js.map +2 -2
  45. package/dist/providers/file-provider.js +13 -11
  46. package/dist/providers/file-provider.js.map +1 -1
  47. package/dist/services/ContensisAuthService.js +1 -2
  48. package/dist/services/ContensisAuthService.js.map +1 -1
  49. package/dist/services/ContensisCliService.js +194 -127
  50. package/dist/services/ContensisCliService.js.map +3 -3
  51. package/dist/services/ContensisDevService.js +15 -18
  52. package/dist/services/ContensisDevService.js.map +2 -2
  53. package/dist/services/ContensisRoleService.js +8 -10
  54. package/dist/services/ContensisRoleService.js.map +1 -1
  55. package/dist/shell.js +31 -15
  56. package/dist/shell.js.map +2 -2
  57. package/dist/util/api-ids.js.map +1 -1
  58. package/dist/util/console.printer.js +15 -17
  59. package/dist/util/console.printer.js.map +2 -2
  60. package/dist/util/csv.formatter.js +8 -15
  61. package/dist/util/csv.formatter.js.map +2 -2
  62. package/dist/util/diff.js +6 -4
  63. package/dist/util/diff.js.map +1 -1
  64. package/dist/util/dotenv.js +1 -2
  65. package/dist/util/dotenv.js.map +1 -1
  66. package/dist/util/error.js.map +1 -1
  67. package/dist/util/fetch.js +4 -0
  68. package/dist/util/fetch.js.map +1 -1
  69. package/dist/util/git.js +8 -8
  70. package/dist/util/git.js.map +1 -1
  71. package/dist/util/gitignore.js +4 -0
  72. package/dist/util/gitignore.js.map +1 -1
  73. package/dist/util/html.formatter.js +70 -0
  74. package/dist/util/html.formatter.js.map +7 -0
  75. package/dist/util/index.js +5 -1
  76. package/dist/util/index.js.map +2 -2
  77. package/dist/util/json.formatter.js +6 -4
  78. package/dist/util/json.formatter.js.map +1 -1
  79. package/dist/util/logger.js +47 -53
  80. package/dist/util/logger.js.map +2 -2
  81. package/dist/util/os.js +4 -0
  82. package/dist/util/os.js.map +1 -1
  83. package/dist/util/xml.formatter.js +4 -0
  84. package/dist/util/xml.formatter.js.map +1 -1
  85. package/dist/util/yaml.js +1 -2
  86. package/dist/util/yaml.js.map +1 -1
  87. package/dist/version.js +1 -1
  88. package/dist/version.js.map +1 -1
  89. package/esbuild.config.js +12 -16
  90. package/package.json +31 -32
  91. package/src/commands/copy.ts +3 -1
  92. package/src/commands/globalOptions.ts +10 -3
  93. package/src/commands/import.ts +2 -0
  94. package/src/commands/index.ts +4 -0
  95. package/src/commands/push.ts +125 -1
  96. package/src/commands/remove.ts +20 -0
  97. package/src/commands/update.ts +84 -0
  98. package/src/factories/RequestHandlerFactory.ts +1 -1
  99. package/src/localisation/en-GB.ts +16 -1
  100. package/src/models/CliService.d.ts +1 -1
  101. package/src/providers/CredentialProvider.ts +2 -2
  102. package/src/providers/SessionCacheProvider.ts +26 -2
  103. package/src/services/ContensisCliService.ts +187 -49
  104. package/src/services/ContensisDevService.ts +2 -2
  105. package/src/shell.ts +20 -9
  106. package/src/util/console.printer.ts +23 -19
  107. package/src/util/csv.formatter.ts +1 -1
  108. package/src/util/html.formatter.ts +52 -0
  109. package/src/util/index.ts +1 -1
  110. package/src/util/logger.ts +17 -16
  111. package/src/version.ts +1 -1
  112. package/tsconfig.json +1 -1
@@ -18,6 +18,10 @@ var __copyProps = (to2, from, except, desc) => {
18
18
  return to2;
19
19
  };
20
20
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
25
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
26
  mod
23
27
  ));
@@ -45,6 +49,7 @@ var import_util = require("../util");
45
49
  var import_api_ids = require("../util/api-ids");
46
50
  var import_console = require("../util/console.printer");
47
51
  var import_csv = require("../util/csv.formatter");
52
+ var import_html = require("../util/html.formatter");
48
53
  var import_json = require("../util/json.formatter");
49
54
  var import_xml = require("../util/xml.formatter");
50
55
  var import_debug = require("../util/debug");
@@ -88,9 +93,8 @@ class ContensisCli {
88
93
  get env() {
89
94
  const currentEnvironment = this.currentEnv;
90
95
  const environments = this.cache.environments || {};
91
- if (!currentEnvironment)
92
- return {};
93
- else if (!!environments[currentEnvironment])
96
+ if (!currentEnvironment) return {};
97
+ else if (environments[currentEnvironment])
94
98
  return environments[currentEnvironment];
95
99
  else {
96
100
  return {
@@ -121,21 +125,16 @@ class ContensisCli {
121
125
  const environments = this.cache.environments || {};
122
126
  this.currentEnv = currentEnvironment;
123
127
  const env = this.env;
124
- if (outputOpts == null ? void 0 : outputOpts.projectId)
125
- env.currentProject = outputOpts.projectId;
126
- if (outputOpts == null ? void 0 : outputOpts.user)
127
- env.lastUserId = outputOpts.user;
128
- if (outputOpts == null ? void 0 : outputOpts.password)
129
- env.passwordFallback = outputOpts.password;
130
- if (outputOpts == null ? void 0 : outputOpts.clientId)
131
- env.lastUserId = outputOpts.clientId;
128
+ if (outputOpts == null ? void 0 : outputOpts.projectId) env.currentProject = outputOpts.projectId;
129
+ if (outputOpts == null ? void 0 : outputOpts.user) env.lastUserId = outputOpts.user;
130
+ if (outputOpts == null ? void 0 : outputOpts.password) env.passwordFallback = outputOpts.password;
131
+ if (outputOpts == null ? void 0 : outputOpts.clientId) env.lastUserId = outputOpts.clientId;
132
132
  if (outputOpts == null ? void 0 : outputOpts.sharedSecret)
133
133
  if (outputOpts.sharedSecret.startsWith("-"))
134
134
  throw new Error(
135
135
  `Shared secret option provided a value of ${outputOpts.sharedSecret}`
136
136
  );
137
- else
138
- env.passwordFallback = outputOpts.sharedSecret;
137
+ else env.passwordFallback = outputOpts.sharedSecret;
139
138
  this.currentProject = (env == null ? void 0 : env.currentProject) || "null";
140
139
  this.sourceAlias = (outputOpts == null ? void 0 : outputOpts.sourceAlias) || currentEnvironment;
141
140
  if (currentEnvironment) {
@@ -144,7 +143,7 @@ class ContensisCli {
144
143
  this.command = {
145
144
  commandText,
146
145
  options: outputOpts,
147
- createdDate: new Date().toISOString(),
146
+ createdDate: (/* @__PURE__ */ new Date()).toISOString(),
148
147
  invokedBy: env == null ? void 0 : env.lastUserId
149
148
  };
150
149
  if (currentEnvironment) {
@@ -162,7 +161,7 @@ class ContensisCli {
162
161
  PrintEnvironments = async () => {
163
162
  const { log, messages } = this;
164
163
  const { currentEnvironment, environments = {} } = this.cache;
165
- const envKeys = Object.keys(environments);
164
+ const envKeys = Object.keys(environments).sort();
166
165
  log.success(messages.envs.found(envKeys.length));
167
166
  await this.HandleFormattingAndOutput(envKeys, () => {
168
167
  for (const env of envKeys) {
@@ -173,6 +172,30 @@ class ContensisCli {
173
172
  log.help(messages.envs.tip());
174
173
  }
175
174
  };
175
+ RemoveEnvironment = async (env) => {
176
+ const { log, messages, session } = this;
177
+ const { currentEnvironment, environments = {} } = this.cache;
178
+ const envKeys = Object.keys(environments);
179
+ log.success(messages.envs.found(envKeys.length));
180
+ if (environments[env]) {
181
+ session.RemoveEnv(env);
182
+ const lastUserId = environments[env].lastUserId;
183
+ if (lastUserId) {
184
+ const [err, credentials] = await new import_CredentialProvider.default({
185
+ userId: environments[env].lastUserId,
186
+ alias: env
187
+ }).Init();
188
+ if (!err && credentials) await credentials.Delete();
189
+ }
190
+ log.success(messages.envs.removed(env));
191
+ await this.HandleFormattingAndOutput(environments[env], () => log.line());
192
+ } else {
193
+ log.warning(messages.envs.notFound(env));
194
+ }
195
+ const nextCurrentEnv = currentEnvironment === env ? void 0 : currentEnvironment;
196
+ if (envKeys.length === 0 || !nextCurrentEnv) log.help(messages.envs.tip());
197
+ return nextCurrentEnv;
198
+ };
176
199
  Connect = async (environment) => {
177
200
  var _a;
178
201
  const { log, messages, session } = this;
@@ -230,10 +253,8 @@ class ContensisCli {
230
253
  );
231
254
  }
232
255
  } else {
233
- if (!currentEnv)
234
- log.help(messages.connect.help());
235
- if (!userId)
236
- log.help(messages.connect.tip());
256
+ if (!currentEnv) log.help(messages.connect.help());
257
+ if (!userId) log.help(messages.connect.tip());
237
258
  }
238
259
  }
239
260
  return this.contensis;
@@ -241,11 +262,12 @@ class ContensisCli {
241
262
  ConnectContensisImport = async ({
242
263
  commit = false,
243
264
  fromFile,
244
- importDataType
265
+ importDataType,
266
+ importData
245
267
  }) => {
246
268
  var _a, _b, _c, _d, _e, _f;
247
- const source = fromFile ? "file" : "contensis";
248
- const fileData = fromFile ? await (0, import_file_provider.readFileAsJSON)(fromFile) || [] : [];
269
+ const source = fromFile || importData ? "file" : "contensis";
270
+ const fileData = importData || (fromFile ? await (0, import_file_provider.readFileAsJSON)(fromFile) || [] : []);
249
271
  if (typeof fileData === "string")
250
272
  throw new Error(`Import file format must be of type JSON`);
251
273
  const { contensisOpts, currentEnv, env, log, messages, sourceAlias } = this;
@@ -322,10 +344,8 @@ class ContensisCli {
322
344
  }
323
345
  }
324
346
  } else {
325
- if (!currentEnv)
326
- log.help(messages.connect.help());
327
- if (!targetUserId)
328
- log.help(messages.connect.tip());
347
+ if (!currentEnv) log.help(messages.connect.help());
348
+ if (!targetUserId) log.help(messages.connect.tip());
329
349
  }
330
350
  return this.contensis;
331
351
  };
@@ -367,7 +387,7 @@ class ContensisCli {
367
387
  let inputPassword = password || sharedSecret;
368
388
  if (!inputPassword)
369
389
  inputPassword = (0, import_util.isSharedSecret)(this.env.passwordFallback) || (0, import_util.isPassword)(this.env.passwordFallback) || "";
370
- const { log, messages } = this;
390
+ const { messages } = this;
371
391
  if (userId) {
372
392
  const { currentEnv, env } = this;
373
393
  if (currentEnv) {
@@ -401,10 +421,8 @@ class ContensisCli {
401
421
  env.lastUserId = userId;
402
422
  env.passwordFallback = credentials.remarks.secure !== true ? (_d = credentials.current) == null ? void 0 : _d.password : void 0;
403
423
  this.session.UpdateEnv(env);
404
- if (inputPassword)
405
- await credentials.Save(inputPassword);
406
- if (sharedSecret)
407
- await credentials.Save(sharedSecret);
424
+ if (inputPassword) await credentials.Save(inputPassword);
425
+ if (sharedSecret) await credentials.Save(sharedSecret);
408
426
  if (!silent) {
409
427
  import_logger.Logger.success(messages.login.success(currentEnv, userId));
410
428
  await this.PrintProjects();
@@ -460,7 +478,7 @@ class ContensisCli {
460
478
  const contensis = await this.ConnectContensis();
461
479
  if (contensis) {
462
480
  const [error, token] = await (0, import_await_to_js.default)(
463
- contensis.content.sourceRepo.repo.BearerToken()
481
+ contensis.content.source.repo.BearerToken()
464
482
  );
465
483
  if (token) {
466
484
  await this.HandleFormattingAndOutput(
@@ -497,6 +515,7 @@ class ContensisCli {
497
515
  try {
498
516
  color = import_chalk.default.keyword(project.color);
499
517
  } catch (ex) {
518
+ import_logger.Logger.debug(`${ex}`);
500
519
  color = import_chalk.default.white;
501
520
  }
502
521
  console.log(
@@ -518,7 +537,7 @@ class ContensisCli {
518
537
  }
519
538
  };
520
539
  PrintProject = async (projectId = this.currentProject) => {
521
- const { log, messages, session } = this;
540
+ const { log, messages } = this;
522
541
  const contensis = await this.ConnectContensis();
523
542
  if (contensis) {
524
543
  const [projectsErr, projects] = await (0, import_await_to_js.default)(
@@ -636,7 +655,7 @@ class ContensisCli {
636
655
  const { currentEnv, log, messages } = this;
637
656
  const contensis = await this.ConnectContensis({ commit: true });
638
657
  if (contensis) {
639
- const [err, key] = await contensis.apiKeys.RemoveKey(id);
658
+ const [err] = await contensis.apiKeys.RemoveKey(id);
640
659
  if (!err) {
641
660
  log.success(messages.keys.removed(currentEnv, id));
642
661
  console.log("");
@@ -652,8 +671,7 @@ class ContensisCli {
652
671
  const [rolesErr, roles] = await (0, import_await_to_js.default)(contensis.roles.GetRoles());
653
672
  if (Array.isArray(roles)) {
654
673
  log.success(messages.roles.list(currentEnv));
655
- if (!roles.length)
656
- log.help(messages.roles.noneExist());
674
+ if (!roles.length) log.help(messages.roles.noneExist());
657
675
  await this.HandleFormattingAndOutput(roles, () => {
658
676
  var _a, _b, _c, _d, _e;
659
677
  for (const {
@@ -666,8 +684,7 @@ class ContensisCli {
666
684
  } of roles) {
667
685
  const color = enabled ? (s) => s : log.infoText;
668
686
  console.log(color(` - ${import_chalk.default.bold(name)} ${log.infoText(id)}`));
669
- if (description)
670
- console.log(log.infoText(` ${description}`));
687
+ if (description) console.log(log.infoText(` ${description}`));
671
688
  if (enabled === false)
672
689
  console.log(` ${import_chalk.default.bold.grey("enabled")}: false`);
673
690
  if ((_a = assignments.groups) == null ? void 0 : _a.length)
@@ -722,10 +739,8 @@ class ContensisCli {
722
739
  if (Array.isArray(roles)) {
723
740
  log.success(messages.roles.list(currentEnv));
724
741
  const role = (0, import_find.findByIdOrName)(roles, roleNameOrId);
725
- if (role)
726
- await this.HandleFormattingAndOutput(role, log.object);
727
- else
728
- log.error(messages.roles.failedGet(currentEnv, roleNameOrId));
742
+ if (role) await this.HandleFormattingAndOutput(role, log.object);
743
+ else log.error(messages.roles.failedGet(currentEnv, roleNameOrId));
729
744
  }
730
745
  if (rolesErr) {
731
746
  log.error(messages.roles.noList(currentEnv));
@@ -798,8 +813,7 @@ class ContensisCli {
798
813
  const [deleteErr] = await contensis.roles.RemoveRole(existingRole.id);
799
814
  if (deleteErr)
800
815
  log.error(messages.roles.failedRemove(currentEnv, roleNameOrId));
801
- else
802
- log.success(messages.roles.removed(currentEnv, roleNameOrId));
816
+ else log.success(messages.roles.removed(currentEnv, roleNameOrId));
803
817
  } else {
804
818
  log.error(messages.roles.failedGet(currentEnv, roleNameOrId));
805
819
  }
@@ -814,11 +828,10 @@ class ContensisCli {
814
828
  const { currentEnv, log, messages } = this;
815
829
  const contensis = await this.ConnectContensis();
816
830
  if (contensis) {
817
- const [workflowsErr, workflows] = await contensis.content.sourceRepo.workflows.GetWorkflows();
831
+ const [workflowsErr, workflows] = await contensis.content.source.workflows.GetWorkflows();
818
832
  if (Array.isArray(workflows)) {
819
833
  log.success(messages.workflows.list(currentEnv));
820
- if (!workflows.length)
821
- log.help(messages.workflows.noneExist());
834
+ if (!workflows.length) log.help(messages.workflows.noneExist());
822
835
  const stringFromLanguageObject = (o) => {
823
836
  var _a;
824
837
  return (_a = Object.values(o || {})) == null ? void 0 : _a[0];
@@ -867,7 +880,7 @@ class ContensisCli {
867
880
  const { currentEnv, log, messages } = this;
868
881
  const contensis = await this.ConnectContensis();
869
882
  if (contensis) {
870
- const [workflowsErr, workflows] = await contensis.content.sourceRepo.workflows.GetWorkflows();
883
+ const [workflowsErr, workflows] = await contensis.content.source.workflows.GetWorkflows();
871
884
  if (Array.isArray(workflows)) {
872
885
  log.success(messages.workflows.list(currentEnv));
873
886
  const workflow = (0, import_find.findByIdOrName)(workflows, workflowNameOrId);
@@ -1026,30 +1039,25 @@ class ContensisCli {
1026
1039
  if (contensis) {
1027
1040
  log.line();
1028
1041
  if (contensis.isPreview) {
1029
- console.log(log.successText(` -- IMPORT PREVIEW -- `));
1042
+ log.success(messages.migrate.preview());
1030
1043
  } else {
1031
- console.log(log.warningText(` *** COMMITTING IMPORT *** `));
1044
+ log.warning(messages.migrate.commit());
1032
1045
  }
1033
1046
  const [migrateErr, result] = await contensis.MigrateContentModels();
1034
- if (migrateErr)
1035
- (0, import_logger.logError)(migrateErr);
1047
+ if (migrateErr) (0, import_logger.logError)(migrateErr);
1036
1048
  else
1037
1049
  await this.HandleFormattingAndOutput(result, () => {
1038
1050
  if (!result.committed) {
1039
1051
  log.raw(log.boldText(`
1040
1052
  Content types:`));
1041
- if (!result.contentTypes)
1042
- log.info(`- None returned
1053
+ if (!result.contentTypes) log.info(`- None returned
1043
1054
  `);
1044
- else
1045
- (0, import_console.printModelMigrationAnalysis)(this, result.contentTypes);
1055
+ else (0, import_console.printModelMigrationAnalysis)(this, result.contentTypes);
1046
1056
  log.raw(log.boldText(`
1047
1057
  Components:`));
1048
- if (!result.components)
1049
- log.info(`- None returned
1058
+ if (!result.components) log.info(`- None returned
1050
1059
  `);
1051
- else
1052
- (0, import_console.printModelMigrationAnalysis)(this, result.components);
1060
+ else (0, import_console.printModelMigrationAnalysis)(this, result.components);
1053
1061
  if (result.defaults && Object.keys(result.defaults).length) {
1054
1062
  log.raw(log.boldText(`
1055
1063
  Defaults:`));
@@ -1156,6 +1164,7 @@ Nodes:`));
1156
1164
  const contensis = await this.ConnectContensisImport({
1157
1165
  commit,
1158
1166
  importDataType: "user-input"
1167
+ // 'user-input' import type does not require a source cms
1159
1168
  });
1160
1169
  if (contensis) {
1161
1170
  const [err, result] = await contensis.DeleteContentTypes(contentTypeIds);
@@ -1187,8 +1196,7 @@ Nodes:`));
1187
1196
  let fileData = fromFile ? await (0, import_file_provider.readFileAsJSON)(fromFile) || [] : [];
1188
1197
  if (typeof fileData === "string")
1189
1198
  throw new Error(`Import file format must be of type JSON`);
1190
- if (!Array.isArray(fileData))
1191
- fileData = [fileData];
1199
+ if (!Array.isArray(fileData)) fileData = [fileData];
1192
1200
  const contensis = await this.ConnectContensisImport({
1193
1201
  commit,
1194
1202
  importDataType: fromFile ? "user-input" : void 0
@@ -1198,9 +1206,8 @@ Nodes:`));
1198
1206
  for (const contentType of fileData) {
1199
1207
  contentType.projectId = currentProject;
1200
1208
  delete contentType.uuid;
1201
- const [err, created, createStatus] = await contensis.models.targetRepos[currentProject].repo.UpsertContentType(false, contentType);
1202
- if (err)
1203
- log.error(err.message, err);
1209
+ const [err, , createStatus] = await contensis.models.targets[currentProject].repo.UpsertContentType(false, contentType);
1210
+ if (err) log.error(err.message, err);
1204
1211
  if (createStatus) {
1205
1212
  log.success(
1206
1213
  messages.contenttypes.created(
@@ -1229,8 +1236,7 @@ Nodes:`));
1229
1236
  let fileData = fromFile ? await (0, import_file_provider.readFileAsJSON)(fromFile) || [] : [];
1230
1237
  if (typeof fileData === "string")
1231
1238
  throw new Error(`Import file format must be of type JSON`);
1232
- if (!Array.isArray(fileData))
1233
- fileData = [fileData];
1239
+ if (!Array.isArray(fileData)) fileData = [fileData];
1234
1240
  const contensis = await this.ConnectContensisImport({
1235
1241
  fromFile,
1236
1242
  importDataType: "models"
@@ -1239,8 +1245,7 @@ Nodes:`));
1239
1245
  const [err, result] = await (0, import_await_to_js.default)(
1240
1246
  contensis.models.Diff(fileData.length ? fileData : modelIds)
1241
1247
  );
1242
- if (err)
1243
- log.error(err.message, err);
1248
+ if (err) log.error(err.message, err);
1244
1249
  if (result)
1245
1250
  await this.HandleFormattingAndOutput(result, () => {
1246
1251
  var _a;
@@ -1252,18 +1257,14 @@ Nodes:`));
1252
1257
  );
1253
1258
  if (result.committed === false) {
1254
1259
  log.raw(log.boldText(`Content types:`));
1255
- if (!result.contentTypes)
1256
- log.info(`- None returned
1260
+ if (!result.contentTypes) log.info(`- None returned
1257
1261
  `);
1258
- else
1259
- (0, import_console.printModelMigrationAnalysis)(this, result.contentTypes);
1262
+ else (0, import_console.printModelMigrationAnalysis)(this, result.contentTypes);
1260
1263
  log.raw(log.boldText(`
1261
1264
  Components:`));
1262
- if (!result.components)
1263
- log.info(`- None returned
1265
+ if (!result.components) log.info(`- None returned
1264
1266
  `);
1265
- else
1266
- (0, import_console.printModelMigrationAnalysis)(this, result.components);
1267
+ else (0, import_console.printModelMigrationAnalysis)(this, result.components);
1267
1268
  }
1268
1269
  });
1269
1270
  }
@@ -1310,6 +1311,7 @@ Components:`));
1310
1311
  const contensis = await this.ConnectContensisImport({
1311
1312
  commit,
1312
1313
  importDataType: "user-input"
1314
+ // 'user-input' import type does not require a source cms
1313
1315
  });
1314
1316
  if (contensis) {
1315
1317
  const [err, result] = await contensis.DeleteContentTypes(
@@ -1344,8 +1346,7 @@ Components:`));
1344
1346
  let fileData = fromFile ? await (0, import_file_provider.readFileAsJSON)(fromFile) || [] : [];
1345
1347
  if (typeof fileData === "string")
1346
1348
  throw new Error(`Import file format must be of type JSON`);
1347
- if (!Array.isArray(fileData))
1348
- fileData = [fileData];
1349
+ if (!Array.isArray(fileData)) fileData = [fileData];
1349
1350
  const contensis = await this.ConnectContensisImport({
1350
1351
  commit,
1351
1352
  importDataType: fromFile ? "user-input" : void 0
@@ -1355,9 +1356,8 @@ Components:`));
1355
1356
  for (const component of fileData) {
1356
1357
  component.projectId = currentProject;
1357
1358
  delete component.uuid;
1358
- const [err, created, createStatus] = await contensis.models.targetRepos[currentProject].repo.UpsertComponent(false, component);
1359
- if (err)
1360
- log.error(err.message, err);
1359
+ const [err, , createStatus] = await contensis.models.targets[currentProject].repo.UpsertComponent(false, component);
1360
+ if (err) log.error(err.message, err);
1361
1361
  if (createStatus) {
1362
1362
  log.success(
1363
1363
  messages.components.created(
@@ -1385,6 +1385,7 @@ Components:`));
1385
1385
  const contensis = await this.ConnectContensisImport({
1386
1386
  commit,
1387
1387
  importDataType: "user-input"
1388
+ // 'user-input' import type does not require a source cms
1388
1389
  });
1389
1390
  if (contensis) {
1390
1391
  if (contensis.isPreview) {
@@ -1421,17 +1422,22 @@ Components:`));
1421
1422
  if (contensis) {
1422
1423
  log.line();
1423
1424
  const entries = await contensis.GetEntries({ withDependents });
1424
- await this.HandleFormattingAndOutput(
1425
- entries,
1426
- () => {
1427
- var _a;
1428
- return (0, import_migratortron.logEntitiesTable)({
1429
- entries,
1425
+ const nodes = contensis.content.source.nodes.raw;
1426
+ const combinedOutput = [...entries, ...nodes];
1427
+ await this.HandleFormattingAndOutput(combinedOutput, () => {
1428
+ var _a, _b;
1429
+ (0, import_migratortron.logEntitiesTable)({
1430
+ entries,
1431
+ projectId: currentProject,
1432
+ fields: (_a = contensis.payload.query) == null ? void 0 : _a.fields
1433
+ });
1434
+ if (nodes.length)
1435
+ (0, import_migratortron.logEntitiesTable)({
1436
+ nodes,
1430
1437
  projectId: currentProject,
1431
- fields: (_a = contensis.payload.query) == null ? void 0 : _a.fields
1438
+ fields: (_b = contensis.payload.query) == null ? void 0 : _b.fields
1432
1439
  });
1433
- }
1434
- );
1440
+ });
1435
1441
  } else {
1436
1442
  log.warning(messages.models.noList(currentProject));
1437
1443
  log.help(messages.connect.tip());
@@ -1441,35 +1447,42 @@ Components:`));
1441
1447
  commit,
1442
1448
  fromFile,
1443
1449
  logOutput,
1444
- saveEntries
1450
+ saveEntries,
1451
+ data
1445
1452
  }) => {
1446
1453
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
1447
1454
  const { currentEnv, currentProject, log, messages } = this;
1448
1455
  const contensis = await this.ConnectContensisImport({
1449
1456
  commit,
1450
1457
  fromFile,
1451
- importDataType: "entries"
1458
+ importDataType: "entries",
1459
+ importData: data
1452
1460
  });
1453
1461
  if (contensis) {
1454
1462
  log.line();
1455
1463
  if (contensis.isPreview) {
1456
- console.log(log.successText(` -- IMPORT PREVIEW -- `));
1464
+ log.success(messages.migrate.preview());
1457
1465
  } else {
1458
- console.log(log.warningText(` *** COMMITTING IMPORT *** `));
1466
+ log.warning(messages.migrate.commit());
1459
1467
  }
1460
1468
  const [err, result] = await contensis.MigrateEntries();
1461
- if (err)
1462
- (0, import_logger.logError)(err);
1469
+ if (err) (0, import_logger.logError)(err);
1463
1470
  else {
1464
1471
  const { entries, nodes } = contensis.content.targets[currentProject];
1465
- const output = saveEntries ? (_a = entries.migrate) == null ? void 0 : _a.map((me) => me.toJSON()) : result;
1472
+ const output = saveEntries ? (
1473
+ // include entries and dependent nodes when saving entries
1474
+ [
1475
+ ((_a = entries.migrate) == null ? void 0 : _a.map((me) => me.toJSON())) || [],
1476
+ nodes.migrateNodes.map((mn) => mn.node)
1477
+ ].flat()
1478
+ ) : result;
1466
1479
  await this.HandleFormattingAndOutput(output, () => {
1467
1480
  (0, import_console.printEntriesMigrateResult)(this, result, {
1468
1481
  showAll: logOutput === "all",
1469
1482
  showDiff: logOutput === "all" || logOutput === "changes",
1470
1483
  showChanged: logOutput === "changes"
1471
1484
  });
1472
- if (["all", "changes"].includes(logOutput))
1485
+ if (["all", "changes"].includes(logOutput) && nodes.migrateNodes.length)
1473
1486
  (0, import_console.printNodeTreeOutput)(
1474
1487
  this,
1475
1488
  {
@@ -1520,15 +1533,14 @@ Components:`));
1520
1533
  if (contensis) {
1521
1534
  log.line();
1522
1535
  if (contensis.isPreview) {
1523
- console.log(log.successText(` -- IMPORT PREVIEW -- `));
1536
+ log.success(messages.migrate.preview());
1524
1537
  } else {
1525
- console.log(log.warningText(` *** COMMITTING IMPORT *** `));
1538
+ log.warning(messages.migrate.commit());
1526
1539
  }
1527
1540
  const [err, result] = await (0, import_await_to_js.default)(
1528
1541
  contensis.content.copy.MigrateFieldContent()
1529
1542
  );
1530
- if (err)
1531
- (0, import_logger.logError)(err);
1543
+ if (err) (0, import_logger.logError)(err);
1532
1544
  if (result) {
1533
1545
  const output = saveEntries ? (_a = contensis.content.copy.targets[currentProject].entries.migrate) == null ? void 0 : _a.map(
1534
1546
  (me) => me.toJSON()
@@ -1563,6 +1575,63 @@ Components:`));
1563
1575
  log.help(messages.connect.tip());
1564
1576
  }
1565
1577
  };
1578
+ UpdateEntryField = async ({
1579
+ commit,
1580
+ fromFile,
1581
+ logOutput,
1582
+ saveEntries
1583
+ }) => {
1584
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1585
+ const { currentEnv, currentProject, log, messages } = this;
1586
+ const contensis = await this.ConnectContensisImport({
1587
+ commit,
1588
+ fromFile,
1589
+ importDataType: "entries"
1590
+ });
1591
+ if (contensis) {
1592
+ log.line();
1593
+ if (contensis.isPreview) {
1594
+ log.success(messages.entries.update.preview());
1595
+ } else {
1596
+ log.warning(messages.entries.update.commit());
1597
+ }
1598
+ const [err, result] = await (0, import_await_to_js.default)(
1599
+ contensis.content.update.UpdateFieldContent()
1600
+ );
1601
+ if (err) (0, import_logger.logError)(err);
1602
+ if (result) {
1603
+ const output = saveEntries ? (_a = contensis.content.update.targets[currentProject].entries.migrate) == null ? void 0 : _a.map((me) => me.toJSON()) : result;
1604
+ await this.HandleFormattingAndOutput(output, () => {
1605
+ (0, import_console.printEntriesMigrateResult)(this, result, {
1606
+ action: "update",
1607
+ showAll: logOutput === "all",
1608
+ showDiff: logOutput === "all" || logOutput === "changes",
1609
+ showChanged: logOutput === "changes"
1610
+ });
1611
+ });
1612
+ }
1613
+ if (result && !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)))) {
1614
+ log.success(
1615
+ messages.entries.update.success(
1616
+ currentEnv,
1617
+ commit,
1618
+ commit ? (((_e = result.migrateResult) == null ? void 0 : _e.created) || 0) + (((_f = result.migrateResult) == null ? void 0 : _f.updated) || 0) : result.entriesToMigrate[currentProject].totalCount
1619
+ )
1620
+ );
1621
+ if (!commit) {
1622
+ log.raw(``);
1623
+ log.help(messages.entries.commitTip());
1624
+ }
1625
+ } else {
1626
+ log.error(messages.entries.update.failed(currentEnv), err);
1627
+ if (!((_h = (_g = result == null ? void 0 : result.entriesToMigrate) == null ? void 0 : _g[currentProject]) == null ? void 0 : _h.totalCount))
1628
+ log.help(messages.entries.notFound(currentEnv));
1629
+ }
1630
+ } else {
1631
+ log.warning(messages.models.noList(currentProject));
1632
+ log.help(messages.connect.tip());
1633
+ }
1634
+ };
1566
1635
  GetNodes = async (rootPath, depth = 0) => {
1567
1636
  const { currentProject, log, messages } = this;
1568
1637
  const contensis = await this.ConnectContensis();
@@ -1573,7 +1642,7 @@ Components:`));
1573
1642
  log.error(messages.nodes.failedGet(currentProject), err);
1574
1643
  return;
1575
1644
  }
1576
- const root = contensis.nodes.sourceRepo.nodes.tree;
1645
+ const root = contensis.nodes.source.nodes.tree;
1577
1646
  log.success(messages.nodes.get(currentProject, rootPath, depth));
1578
1647
  await this.HandleFormattingAndOutput(nodes, () => {
1579
1648
  log.object({ ...root, children: void 0, language: void 0 });
@@ -1600,16 +1669,15 @@ Components:`));
1600
1669
  if (contensis) {
1601
1670
  log.line();
1602
1671
  if (contensis.isPreview) {
1603
- console.log(log.successText(` -- IMPORT PREVIEW -- `));
1672
+ log.success(messages.migrate.preview());
1604
1673
  } else {
1605
- console.log(log.warningText(` *** COMMITTING IMPORT *** `));
1674
+ log.warning(messages.migrate.commit());
1606
1675
  }
1607
1676
  const [err, result] = await contensis.MigrateNodes();
1608
- if (err)
1609
- log.raw(``);
1677
+ if (err) log.raw(``);
1610
1678
  else
1611
1679
  await this.HandleFormattingAndOutput(result, () => {
1612
- const migrateTree = contensis.nodes.targetRepos[currentProject].nodes.migrateNodesTreeView;
1680
+ const migrateTree = contensis.nodes.targets[currentProject].nodes.migrateNodesTreeView;
1613
1681
  (0, import_console.printNodeTreeOutput)(this, migrateTree, logOutput, logLimit);
1614
1682
  (0, import_console.printNodesMigrateResult)(this, result, {
1615
1683
  showAll: logOutput === "all",
@@ -1624,8 +1692,8 @@ Components:`));
1624
1692
  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)))) {
1625
1693
  let totalCount;
1626
1694
  if (commit) {
1627
- let created = typeof nodesCreated === "number" ? nodesCreated : 0;
1628
- let updated = typeof nodesUpdated === "number" ? nodesUpdated : 0;
1695
+ const created = typeof nodesCreated === "number" ? nodesCreated : 0;
1696
+ const updated = typeof nodesUpdated === "number" ? nodesUpdated : 0;
1629
1697
  totalCount = created + updated;
1630
1698
  } else {
1631
1699
  totalCount = typeof nodesMigrateCount === "number" ? nodesMigrateCount : 0;
@@ -1640,8 +1708,7 @@ Components:`));
1640
1708
  log.help(messages.nodes.noChange(currentEnv));
1641
1709
  } else {
1642
1710
  log.error(messages.nodes.failedImport(currentEnv), err);
1643
- if (!nodesMigrateCount)
1644
- log.help(messages.nodes.notFound(currentEnv));
1711
+ if (!nodesMigrateCount) log.help(messages.nodes.notFound(currentEnv));
1645
1712
  }
1646
1713
  }
1647
1714
  } else {
@@ -1655,6 +1722,7 @@ Components:`));
1655
1722
  const contensis = await this.ConnectContensisImport({
1656
1723
  commit,
1657
1724
  importDataType: "user-input"
1725
+ // 'user-input' import type does not require a source cms
1658
1726
  });
1659
1727
  if (contensis) {
1660
1728
  if (contensis.isPreview) {
@@ -1667,7 +1735,7 @@ Components:`));
1667
1735
  await this.HandleFormattingAndOutput(result, () => {
1668
1736
  (0, import_console.printNodeTreeOutput)(
1669
1737
  this,
1670
- contensis.nodes.targetRepos[currentProject].nodes.migrateNodesTreeView
1738
+ contensis.nodes.targets[currentProject].nodes.migrateNodesTreeView
1671
1739
  );
1672
1740
  });
1673
1741
  }
@@ -1703,8 +1771,7 @@ Components:`));
1703
1771
  ) : webhooks;
1704
1772
  if (Array.isArray(filteredResults)) {
1705
1773
  log.success(messages.webhooks.list(currentEnv));
1706
- if (!(webhooks == null ? void 0 : webhooks.length))
1707
- log.warning(messages.webhooks.noneExist());
1774
+ if (!(webhooks == null ? void 0 : webhooks.length)) log.warning(messages.webhooks.noneExist());
1708
1775
  else {
1709
1776
  await this.HandleFormattingAndOutput(filteredResults, () => {
1710
1777
  for (const {
@@ -1724,8 +1791,7 @@ Components:`));
1724
1791
  ` ${import_chalk.default.bold.white`- ${name}`} ${id} [${(version.modified || version.created).toString().substring(0, 10)} ${version.modifiedBy || version.createdBy}]`
1725
1792
  )
1726
1793
  );
1727
- if (description)
1728
- console.log(log.infoText` ${description}`);
1794
+ if (description) console.log(log.infoText` ${description}`);
1729
1795
  console.log(` ${log.infoText`[${method}]`} ${url2}`);
1730
1796
  if (headers && Object.keys(headers).length) {
1731
1797
  console.log(` ${log.infoText`headers`}:`);
@@ -1853,9 +1919,7 @@ Components:`));
1853
1919
  console.log((0, import_json.jsonFormatter)(block));
1854
1920
  const contensis = await this.ConnectContensis();
1855
1921
  if (contensis) {
1856
- const [err, blockVersion] = await contensis.blocks.PushBlockVersion(
1857
- block
1858
- );
1922
+ const [err, blockVersion] = await contensis.blocks.PushBlockVersion(block);
1859
1923
  if (!err) {
1860
1924
  log.success(
1861
1925
  messages.blocks.pushed(
@@ -1893,8 +1957,7 @@ Components:`));
1893
1957
  blockVersionNo = `${(_a = blockVersions == null ? void 0 : blockVersions[0]) == null ? void 0 : _a.version.versionNo}`;
1894
1958
  if (!Number.isNaN(blockVersionNo) && Number(blockVersionNo) > 0)
1895
1959
  return [null, blockVersionNo];
1896
- else
1897
- throw new Error(`'${blockVersionNo}' is not a valid version number`);
1960
+ else throw new Error(`'${blockVersionNo}' is not a valid version number`);
1898
1961
  } catch (parseVersionEx) {
1899
1962
  log.info(
1900
1963
  `Request for blockId: ${blockId}, branch: ${branch}, version: latest`
@@ -1912,9 +1975,7 @@ Components:`));
1912
1975
  if (contensis) {
1913
1976
  let actionOnBlockVersion = version;
1914
1977
  if (action === "release" && version === "latest") {
1915
- const [getErr, blockVersion2] = await this.GetLatestBlockVersion(
1916
- blockId
1917
- );
1978
+ const [getErr, blockVersion2] = await this.GetLatestBlockVersion(blockId);
1918
1979
  if (getErr) {
1919
1980
  throw new Error(
1920
1981
  `${messages.blocks.noList(
@@ -1997,7 +2058,7 @@ Components:`));
1997
2058
  );
1998
2059
  stopFollowing();
1999
2060
  });
2000
- let delay = (0, import_timers.promiseDelay)(5 * 1e3, null);
2061
+ const delay = (0, import_timers.promiseDelay)(5 * 1e3, null);
2001
2062
  const stopFollowing = () => {
2002
2063
  following = false;
2003
2064
  delay.cancel();
@@ -2078,6 +2139,7 @@ Components:`));
2078
2139
  }
2079
2140
  }
2080
2141
  };
2142
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2081
2143
  PrintRenderers = async (rendererId) => {
2082
2144
  const { currentEnv, env, log, messages } = this;
2083
2145
  const contensis = await this.ConnectContensis();
@@ -2126,6 +2188,9 @@ Components:`));
2126
2188
  } else if (format === "csv") {
2127
2189
  log.raw("");
2128
2190
  log.raw(log.infoText(await (0, import_csv.csvFormatter)((0, import_json.limitFields)(obj, fields))));
2191
+ } else if (format === "html") {
2192
+ log.raw("");
2193
+ log.raw(log.infoText((0, import_html.htmlFormatter)((0, import_json.limitFields)(obj, fields))));
2129
2194
  } else if (format === "xml") {
2130
2195
  log.raw("");
2131
2196
  log.raw(log.infoText((0, import_xml.xmlFormatter)((0, import_json.limitFields)(obj, fields))));
@@ -2139,6 +2204,8 @@ Components:`));
2139
2204
  const isText = !(0, import_util.tryParse)(obj) && typeof obj === "string";
2140
2205
  if (format === "csv") {
2141
2206
  writeString = await (0, import_csv.csvFormatter)((0, import_json.limitFields)(obj, fields));
2207
+ } else if (format === "html") {
2208
+ writeString = (0, import_html.htmlFormatter)((0, import_json.limitFields)(obj, fields));
2142
2209
  } else if (format === "xml") {
2143
2210
  writeString = (0, import_xml.xmlFormatter)((0, import_json.limitFields)(obj, fields));
2144
2211
  } else