contensis-cli 1.0.0-beta.85 → 1.0.0-beta.87

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.
@@ -48,7 +48,6 @@ import { diffLogStrings } from '~/util/diff';
48
48
  import { logError, Logger } from '~/util/logger';
49
49
  import { promiseDelay } from '~/util/timers';
50
50
 
51
-
52
51
  type OutputFormat = 'json' | 'csv' | 'xml';
53
52
 
54
53
  type OutputOptions = {
@@ -1725,6 +1724,32 @@ class ContensisCli {
1725
1724
  }
1726
1725
  };
1727
1726
 
1727
+ GetNodes = async (rootPath: string, depth = 0) => {
1728
+ const { currentProject, log, messages } = this;
1729
+ const contensis = await this.ConnectContensis();
1730
+
1731
+ if (contensis) {
1732
+ log.line();
1733
+ const [err] = await to(
1734
+ contensis.content.sourceRepo.nodes.GetNodes(rootPath, depth)
1735
+ );
1736
+ if (err) {
1737
+ log.error(messages.nodes.failedGet(currentProject), err);
1738
+ return;
1739
+ }
1740
+ const nodes = contensis.content.sourceRepo.nodes.tree;
1741
+
1742
+ log.success(messages.nodes.get(currentProject, rootPath, depth));
1743
+ this.HandleFormattingAndOutput(nodes, () => {
1744
+ // print the nodes to console
1745
+ log.object(nodes);
1746
+ });
1747
+ } else {
1748
+ log.warning(messages.models.noList(currentProject));
1749
+ log.help(messages.connect.tip());
1750
+ }
1751
+ };
1752
+
1728
1753
  PrintWebhookSubscriptions = async (subscriptionIdsOrNames?: string[]) => {
1729
1754
  const { currentEnv, log, messages } = this;
1730
1755
  const contensis = await this.ConnectContensis();
@@ -2307,7 +2332,7 @@ class ContensisCli {
2307
2332
 
2308
2333
  export const cliCommand = (
2309
2334
  commandArgs: string[],
2310
- outputOpts: OutputOptionsConstructorArg,
2335
+ outputOpts?: OutputOptionsConstructorArg,
2311
2336
  contensisOpts: Partial<MigrateRequest> = {}
2312
2337
  ) => {
2313
2338
  return new ContensisCli(['', '', ...commandArgs], outputOpts, contensisOpts);
package/src/shell.ts CHANGED
@@ -148,6 +148,7 @@ class ContensisShell {
148
148
  'get contenttype',
149
149
  'get component',
150
150
  'get entries',
151
+ 'get nodes',
151
152
  'get model',
152
153
  'get project',
153
154
  'get role',
@@ -224,7 +225,14 @@ class ContensisShell {
224
225
  } catch (ex: any) {
225
226
  const str = ex.toString();
226
227
  if (!str.includes('CommanderError'))
227
- logError(ex, `Shell ${ex.toString()}`);
228
+ logError(
229
+ ex,
230
+ `Shell ${
231
+ ex instanceof Error
232
+ ? ex.toString()
233
+ : JSON.stringify(ex, null, 2)
234
+ }`
235
+ );
228
236
  } finally {
229
237
  return this.contensisPrompt();
230
238
  }
@@ -8,7 +8,7 @@ import { isSysError, tryStringify } from '.';
8
8
  type LogMethod = (content: string) => void;
9
9
  type LogErrorMethod = (content: string, err?: any, newline?: string) => void;
10
10
  type LogJsonMethod = (content: any, depth?: number, indent?: string) => void;
11
- type LogJsonDepthMethod = (content: any, depth: number) => void;
11
+ type LogJsonDepthMethod = (content: any, depth?: number) => void;
12
12
  type LogArrayMethod = (contentArray: string[]) => void;
13
13
  type LogErrorFunc = (
14
14
  err: any,
@@ -41,9 +41,9 @@ export class Logger {
41
41
  const message = `${Logger.getPrefix()} ${Logger.errorText(
42
42
  `${Logger.isUserTerminal ? '❌' : '[ERROR]'} ${content}${
43
43
  err
44
- ? `\n\n${
44
+ ? `\n\n${Logger.infoText(
45
45
  isSysError(err) ? err.toString() : JSON.stringify(err, null, 2)
46
- }`
46
+ )}`
47
47
  : ''
48
48
  }`
49
49
  )}${newline}`;
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const LIB_VERSION = "1.0.0-beta.85";
1
+ export const LIB_VERSION = "1.0.0-beta.87";