@extrahorizon/exh-cli 1.12.0-dev-136-7979670 → 1.12.0-dev-137-56e1ad4

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.
@@ -2,25 +2,28 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handler = exports.builder = exports.desc = exports.command = void 0;
4
4
  const chalk = require("chalk");
5
- const exh_1 = require("../../exh");
6
5
  const util_1 = require("../../helpers/util");
6
+ const templateRepository = require("../../repositories/templates");
7
7
  exports.command = 'list';
8
8
  exports.desc = 'List all templates';
9
9
  const builder = (yargs) => (0, util_1.epilogue)(yargs);
10
10
  exports.builder = builder;
11
11
  const handler = async function list({ isTTY }) {
12
- const templates = await (0, exh_1.getSdk)().templates.findAll();
13
- if (templates) {
14
- if (!templates.length) {
15
- console.log(chalk.red('No templates found'));
16
- return;
17
- }
18
- if (isTTY) {
19
- console.table(templates.map((c) => ({ Id: c.id, Name: c.name, Description: c.description || '<none>', 'Last updated': c.updateTimestamp.toISOString() })));
20
- }
21
- else {
22
- templates.forEach((f) => (console.log(f)));
23
- }
12
+ const templates = await templateRepository.findAll();
13
+ if (templates.length < 1) {
14
+ console.log(chalk.red('No templates found'));
15
+ return;
16
+ }
17
+ if (isTTY) {
18
+ console.table(templates.map(template => ({
19
+ Id: template.id,
20
+ Name: template.name,
21
+ Description: template.description || '<none>',
22
+ 'Last updated': template.updateTimestamp.toISOString(),
23
+ })));
24
+ }
25
+ else {
26
+ templates.forEach(template => console.log(template));
24
27
  }
25
28
  };
26
29
  exports.handler = handler;
@@ -1,3 +1,4 @@
1
1
  export declare function findByName(name: string): Promise<import("@extrahorizon/javascript-sdk").TemplateOut>;
2
2
  export declare function findById(id: string): Promise<import("@extrahorizon/javascript-sdk").TemplateOut>;
3
+ export declare function findAll(): Promise<import("@extrahorizon/javascript-sdk").TemplateOut[]>;
3
4
  export declare function remove(id: string): Promise<import("@extrahorizon/javascript-sdk").AffectedRecords>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.remove = exports.findById = exports.findByName = void 0;
3
+ exports.remove = exports.findAll = exports.findById = exports.findByName = void 0;
4
4
  const exh_1 = require("../exh");
5
5
  async function findByName(name) {
6
6
  return await (0, exh_1.getSdk)().templates.findByName(name);
@@ -10,6 +10,10 @@ async function findById(id) {
10
10
  return await (0, exh_1.getSdk)().templates.findById(id);
11
11
  }
12
12
  exports.findById = findById;
13
+ async function findAll() {
14
+ return await (0, exh_1.getSdk)().templates.findAll();
15
+ }
16
+ exports.findAll = findAll;
13
17
  async function remove(id) {
14
18
  return await (0, exh_1.getSdk)().templates.remove(id);
15
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@extrahorizon/exh-cli",
3
- "version": "1.12.0-dev-136-7979670",
3
+ "version": "1.12.0-dev-137-56e1ad4",
4
4
  "main": "build/index.js",
5
5
  "exports": "./build/index.js",
6
6
  "license": "MIT",