@hyperweb/telescope 2.2.1 → 2.2.3

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.
package/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import type { ParsedArgs } from 'minimist';
2
+ export declare const cli: (argv: ParsedArgs) => Promise<void>;
package/cli.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cli = void 0;
4
+ const prompt_1 = require("./prompt");
5
+ const cmds_1 = require("./cmds");
6
+ const find_and_require_package_json_1 = require("find-and-require-package-json");
7
+ const pkg = (0, find_and_require_package_json_1.findAndRequirePackageJson)(__dirname);
8
+ const cli = async (argv) => {
9
+ if (argv.v || argv.version) {
10
+ console.log(pkg.version);
11
+ return;
12
+ }
13
+ console.log(`Telescope ${pkg.version}`);
14
+ const { cmd } = await (0, prompt_1.prompt)([
15
+ {
16
+ _: true,
17
+ type: 'fuzzy',
18
+ name: 'cmd',
19
+ message: 'what do you want to do?',
20
+ choices: Object.keys(cmds_1.Commands),
21
+ },
22
+ ], argv);
23
+ if (typeof cmds_1.Commands[cmd] === 'function') {
24
+ await cmds_1.Commands[cmd](argv);
25
+ }
26
+ else {
27
+ console.log('command not found.');
28
+ }
29
+ };
30
+ exports.cli = cli;
package/cmds.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ declare const Commands: {
2
+ generate: (argv: any) => Promise<any>;
3
+ install: (argv: any) => Promise<void>;
4
+ download: (argv: {
5
+ [key: string]: string | string[];
6
+ } | import("./protod/types").DownloadOptions) => Promise<any>;
7
+ transpile: (argv: {
8
+ [key: string]: string | string[];
9
+ }) => Promise<void>;
10
+ };
11
+ export { Commands };
package/cmds.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Commands = void 0;
7
+ const generate_1 = __importDefault(require("./commands/generate"));
8
+ const install_1 = __importDefault(require("./commands/install"));
9
+ const download_1 = __importDefault(require("./commands/download"));
10
+ const transpile_1 = __importDefault(require("./commands/transpile"));
11
+ const Commands = {
12
+ generate: generate_1.default,
13
+ install: install_1.default,
14
+ download: download_1.default,
15
+ transpile: transpile_1.default
16
+ };
17
+ exports.Commands = Commands;
package/esm/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import type { ParsedArgs } from 'minimist';
2
+ export declare const cli: (argv: ParsedArgs) => Promise<void>;
package/esm/cli.js ADDED
@@ -0,0 +1,26 @@
1
+ import { prompt } from './prompt';
2
+ import { Commands as commands } from './cmds';
3
+ import { findAndRequirePackageJson } from 'find-and-require-package-json';
4
+ const pkg = findAndRequirePackageJson(__dirname);
5
+ export const cli = async (argv) => {
6
+ if (argv.v || argv.version) {
7
+ console.log(pkg.version);
8
+ return;
9
+ }
10
+ console.log(`Telescope ${pkg.version}`);
11
+ const { cmd } = await prompt([
12
+ {
13
+ _: true,
14
+ type: 'fuzzy',
15
+ name: 'cmd',
16
+ message: 'what do you want to do?',
17
+ choices: Object.keys(commands),
18
+ },
19
+ ], argv);
20
+ if (typeof commands[cmd] === 'function') {
21
+ await commands[cmd](argv);
22
+ }
23
+ else {
24
+ console.log('command not found.');
25
+ }
26
+ };
package/esm/cmds.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ declare const Commands: {
2
+ generate: (argv: any) => Promise<any>;
3
+ install: (argv: any) => Promise<void>;
4
+ download: (argv: {
5
+ [key: string]: string | string[];
6
+ } | import("./protod/types").DownloadOptions) => Promise<any>;
7
+ transpile: (argv: {
8
+ [key: string]: string | string[];
9
+ }) => Promise<void>;
10
+ };
11
+ export { Commands };
package/esm/cmds.js ADDED
@@ -0,0 +1,11 @@
1
+ import _commands_generate from './commands/generate';
2
+ import _commands_install from './commands/install';
3
+ import _commands_download from './commands/download';
4
+ import _commands_transpile from './commands/transpile';
5
+ const Commands = {
6
+ generate: _commands_generate,
7
+ install: _commands_install,
8
+ download: _commands_download,
9
+ transpile: _commands_transpile
10
+ };
11
+ export { Commands };
package/esm/file.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/esm/file.js ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ import { prompt } from './prompt';
3
+ import { cli } from './cli';
4
+ import { readFileSync } from 'fs';
5
+ import minimist from 'minimist';
6
+ const argv = minimist(process.argv.slice(2));
7
+ const question = [
8
+ {
9
+ _: true,
10
+ type: 'string',
11
+ name: 'file',
12
+ message: 'file'
13
+ }
14
+ ];
15
+ (async () => {
16
+ const { file } = await prompt(question, argv);
17
+ const argvv = JSON.parse(readFileSync(file, 'utf-8'));
18
+ await cli(argvv);
19
+ })();
package/esm/prompt.d.ts CHANGED
@@ -1,3 +1,14 @@
1
- export function getFuzzySearch(list: any): (answers: any, input: any) => Promise<any>;
2
- export function getFuzzySearchNames(nameValueItemList: any): (answers: any, input: any) => Promise<any>;
3
- export function prompt(questions?: any[], argv?: {}): Promise<any>;
1
+ import { type InquirerQuestion } from 'inquirerer';
2
+ export declare const getFuzzySearch: (list: string[]) => (_answers: unknown, input?: string) => Promise<unknown>;
3
+ interface NameValueItem {
4
+ name: string;
5
+ value: unknown;
6
+ }
7
+ interface Question extends InquirerQuestion {
8
+ type?: string;
9
+ choices?: string[] | NameValueItem[];
10
+ source?: unknown;
11
+ }
12
+ export declare const getFuzzySearchNames: (nameValueItemList: NameValueItem[]) => (_answers: unknown, input?: string) => Promise<unknown>;
13
+ export declare const prompt: (questions?: Question[], argv?: unknown) => Promise<any>;
14
+ export {};
package/esm/prompt.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { filter } from 'fuzzy';
2
2
  import { prompt as inquirerer } from 'inquirerer';
3
3
  export const getFuzzySearch = (list) => {
4
- return (answers, input) => {
4
+ return (_answers, input) => {
5
5
  input = input || '';
6
6
  return new Promise(function (resolve) {
7
7
  setTimeout(function () {
@@ -14,14 +14,14 @@ export const getFuzzySearch = (list) => {
14
14
  };
15
15
  };
16
16
  export const getFuzzySearchNames = (nameValueItemList) => {
17
- const list = nameValueItemList.map(({ name, value }) => name);
18
- return (answers, input) => {
17
+ const list = nameValueItemList.map(({ name }) => name);
18
+ return (_answers, input) => {
19
19
  input = input || '';
20
20
  return new Promise(function (resolve) {
21
21
  setTimeout(function () {
22
22
  const fuzzyResult = filter(input, list);
23
23
  resolve(fuzzyResult.map(function (el) {
24
- return nameValueItemList.find(({ name, value }) => el.original == name);
24
+ return nameValueItemList.find(({ name }) => el.original == name);
25
25
  }));
26
26
  }, 25);
27
27
  });
@@ -35,7 +35,7 @@ const transform = (questions) => {
35
35
  return {
36
36
  ...q,
37
37
  type: 'autocomplete',
38
- source: getFuzzySearch(choices)
38
+ source: getFuzzySearch(choices),
39
39
  };
40
40
  }
41
41
  else if (q.type === 'fuzzy:objects') {
@@ -44,7 +44,7 @@ const transform = (questions) => {
44
44
  return {
45
45
  ...q,
46
46
  type: 'autocomplete',
47
- source: getFuzzySearchNames(choices)
47
+ source: getFuzzySearchNames(choices),
48
48
  };
49
49
  }
50
50
  else {
@@ -53,6 +53,6 @@ const transform = (questions) => {
53
53
  });
54
54
  };
55
55
  export const prompt = async (questions = [], argv = {}) => {
56
- questions = transform(questions);
57
- return await inquirerer(questions, argv);
56
+ const transformed = transform(questions);
57
+ return await inquirerer(transformed, argv);
58
58
  };
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import { cli } from './cli';
3
+ import minimist from 'minimist';
4
+ const argv = minimist(process.argv.slice(2), {
5
+ boolean: ['ssh']
6
+ });
7
+ (async () => {
8
+ await cli(argv);
9
+ })();
package/file.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/file.js ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const prompt_1 = require("./prompt");
8
+ const cli_1 = require("./cli");
9
+ const fs_1 = require("fs");
10
+ const minimist_1 = __importDefault(require("minimist"));
11
+ const argv = (0, minimist_1.default)(process.argv.slice(2));
12
+ const question = [
13
+ {
14
+ _: true,
15
+ type: 'string',
16
+ name: 'file',
17
+ message: 'file'
18
+ }
19
+ ];
20
+ (async () => {
21
+ const { file } = await (0, prompt_1.prompt)(question, argv);
22
+ const argvv = JSON.parse((0, fs_1.readFileSync)(file, 'utf-8'));
23
+ await (0, cli_1.cli)(argvv);
24
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperweb/telescope",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "description": "A TypeScript Transpiler for Cosmos Protobufs",
5
5
  "author": "Constructive <developers@constructive.io>",
6
6
  "homepage": "https://github.com/hyperweb-io/telescope",
@@ -59,6 +59,7 @@
59
59
  },
60
60
  "devDependencies": {
61
61
  "@keplr-wallet/unit": "^0.12.53",
62
+ "@types/minimist": "^1.2.5",
62
63
  "ast-stringify": "0.1.0",
63
64
  "cross-env": "^7.0.2",
64
65
  "makage": "^0.1.12",
@@ -92,5 +93,5 @@
92
93
  "shelljs": "^0.8.5",
93
94
  "yaml": "^2.3.4"
94
95
  },
95
- "gitHead": "92f1ea27a7622a640c91facc480d85fb1c58bc6b"
96
+ "gitHead": "e08c8868d293c6a15e31eb278f85cc8b33fe3d40"
96
97
  }
package/prompt.d.ts CHANGED
@@ -1,3 +1,14 @@
1
- export function getFuzzySearch(list: any): (answers: any, input: any) => Promise<any>;
2
- export function getFuzzySearchNames(nameValueItemList: any): (answers: any, input: any) => Promise<any>;
3
- export function prompt(questions?: any[], argv?: {}): Promise<any>;
1
+ import { type InquirerQuestion } from 'inquirerer';
2
+ export declare const getFuzzySearch: (list: string[]) => (_answers: unknown, input?: string) => Promise<unknown>;
3
+ interface NameValueItem {
4
+ name: string;
5
+ value: unknown;
6
+ }
7
+ interface Question extends InquirerQuestion {
8
+ type?: string;
9
+ choices?: string[] | NameValueItem[];
10
+ source?: unknown;
11
+ }
12
+ export declare const getFuzzySearchNames: (nameValueItemList: NameValueItem[]) => (_answers: unknown, input?: string) => Promise<unknown>;
13
+ export declare const prompt: (questions?: Question[], argv?: unknown) => Promise<any>;
14
+ export {};
package/prompt.js CHANGED
@@ -4,7 +4,7 @@ exports.prompt = exports.getFuzzySearchNames = exports.getFuzzySearch = void 0;
4
4
  const fuzzy_1 = require("fuzzy");
5
5
  const inquirerer_1 = require("inquirerer");
6
6
  const getFuzzySearch = (list) => {
7
- return (answers, input) => {
7
+ return (_answers, input) => {
8
8
  input = input || '';
9
9
  return new Promise(function (resolve) {
10
10
  setTimeout(function () {
@@ -18,14 +18,14 @@ const getFuzzySearch = (list) => {
18
18
  };
19
19
  exports.getFuzzySearch = getFuzzySearch;
20
20
  const getFuzzySearchNames = (nameValueItemList) => {
21
- const list = nameValueItemList.map(({ name, value }) => name);
22
- return (answers, input) => {
21
+ const list = nameValueItemList.map(({ name }) => name);
22
+ return (_answers, input) => {
23
23
  input = input || '';
24
24
  return new Promise(function (resolve) {
25
25
  setTimeout(function () {
26
26
  const fuzzyResult = (0, fuzzy_1.filter)(input, list);
27
27
  resolve(fuzzyResult.map(function (el) {
28
- return nameValueItemList.find(({ name, value }) => el.original == name);
28
+ return nameValueItemList.find(({ name }) => el.original == name);
29
29
  }));
30
30
  }, 25);
31
31
  });
@@ -40,7 +40,7 @@ const transform = (questions) => {
40
40
  return {
41
41
  ...q,
42
42
  type: 'autocomplete',
43
- source: (0, exports.getFuzzySearch)(choices)
43
+ source: (0, exports.getFuzzySearch)(choices),
44
44
  };
45
45
  }
46
46
  else if (q.type === 'fuzzy:objects') {
@@ -49,7 +49,7 @@ const transform = (questions) => {
49
49
  return {
50
50
  ...q,
51
51
  type: 'autocomplete',
52
- source: (0, exports.getFuzzySearchNames)(choices)
52
+ source: (0, exports.getFuzzySearchNames)(choices),
53
53
  };
54
54
  }
55
55
  else {
@@ -58,7 +58,7 @@ const transform = (questions) => {
58
58
  });
59
59
  };
60
60
  const prompt = async (questions = [], argv = {}) => {
61
- questions = transform(questions);
62
- return await (0, inquirerer_1.prompt)(questions, argv);
61
+ const transformed = transform(questions);
62
+ return await (0, inquirerer_1.prompt)(transformed, argv);
63
63
  };
64
64
  exports.prompt = prompt;
package/telescope.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/telescope.js ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const cli_1 = require("./cli");
8
+ const minimist_1 = __importDefault(require("minimist"));
9
+ const argv = (0, minimist_1.default)(process.argv.slice(2), {
10
+ boolean: ['ssh']
11
+ });
12
+ (async () => {
13
+ await (0, cli_1.cli)(argv);
14
+ })();