@extrahorizon/exh-cli 1.12.0-dev-138-3fed4c5 → 1.12.0-dev-139-711ee70

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.
@@ -12,6 +12,6 @@ export declare const builder: (yargs: any) => import("yargs").Argv<import("yargs
12
12
  };
13
13
  }>>;
14
14
  export declare const handler: ({ name, id }: {
15
- name: string;
16
- id: string;
15
+ name?: string;
16
+ id?: string;
17
17
  }) => Promise<void>;
@@ -2,8 +2,8 @@
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 = 'get';
8
8
  exports.desc = 'Fetch a template';
9
9
  const builder = (yargs) => (0, util_1.epilogue)(yargs).options({
@@ -23,16 +23,17 @@ const builder = (yargs) => (0, util_1.epilogue)(yargs).options({
23
23
  });
24
24
  exports.builder = builder;
25
25
  const handler = async function list({ name, id }) {
26
- try {
27
- const template = name ? await (0, exh_1.getSdk)().templates.findByName(name) : await (0, exh_1.getSdk)().templates.findById(id);
28
- if (!template) {
29
- console.log(chalk.red('Failed to get template!'));
30
- return;
31
- }
32
- console.log(JSON.stringify(template, null, 4));
26
+ let template;
27
+ if (name) {
28
+ template = await templateRepository.findByName(name);
33
29
  }
34
- catch (err) {
35
- console.log(chalk.red('Failed to get template', name));
30
+ else if (id) {
31
+ template = await templateRepository.findById(id);
36
32
  }
33
+ if (!template) {
34
+ console.log(chalk.red('Failed to get template!'));
35
+ return;
36
+ }
37
+ console.log(JSON.stringify(template, null, 4));
37
38
  };
38
39
  exports.handler = handler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@extrahorizon/exh-cli",
3
- "version": "1.12.0-dev-138-3fed4c5",
3
+ "version": "1.12.0-dev-139-711ee70",
4
4
  "main": "build/index.js",
5
5
  "exports": "./build/index.js",
6
6
  "license": "MIT",