@chain-registry/cli 1.28.0 → 1.30.0
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/README.md +4 -2
- package/commands/index.js +6 -0
- package/commands/validate/index.js +29 -2
- package/esm/commands/index.js +6 -0
- package/esm/commands/validate/index.js +29 -2
- package/esm/help.js +65 -0
- package/help.d.ts +1 -0
- package/help.js +72 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -71,8 +71,10 @@ chain-registry validate
|
|
|
71
71
|
|
|
72
72
|
Options:
|
|
73
73
|
|
|
74
|
-
- `--
|
|
75
|
-
- `--
|
|
74
|
+
- `--registryDir`: Path to the chain registry directory (required).
|
|
75
|
+
- `--useStrict`: Enables strict mode in the schema validation process, ensuring that only explicitly permitted properties are present in the data (default: false).
|
|
76
|
+
- `--allErrors`: Configures the validator to return all errors found during validation instead of stopping at the first error (default: true).
|
|
77
|
+
- `--useDefaults`: Applies default values defined in the schema during validation, filling in missing data as needed (default: true).
|
|
76
78
|
|
|
77
79
|
### Codegen
|
|
78
80
|
|
package/commands/index.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.commands = void 0;
|
|
|
4
4
|
const codegen_1 = require("./codegen");
|
|
5
5
|
const info_1 = require("./info");
|
|
6
6
|
const validate_1 = require("./validate");
|
|
7
|
+
const help_1 = require("../help");
|
|
7
8
|
const commands = async (argv, prompter, _options) => {
|
|
8
9
|
let command;
|
|
9
10
|
if (argv._.length > 0) {
|
|
@@ -12,6 +13,11 @@ const commands = async (argv, prompter, _options) => {
|
|
|
12
13
|
if (command) {
|
|
13
14
|
argv.command = command;
|
|
14
15
|
}
|
|
16
|
+
if (command === 'help') {
|
|
17
|
+
const usage = (0, help_1.getUsage)();
|
|
18
|
+
console.log(usage);
|
|
19
|
+
process.exit(0);
|
|
20
|
+
}
|
|
15
21
|
const questions = [
|
|
16
22
|
{
|
|
17
23
|
type: 'autocomplete',
|
|
@@ -8,7 +8,29 @@ const commands = async (argv, prompter, _options) => {
|
|
|
8
8
|
{
|
|
9
9
|
type: 'text',
|
|
10
10
|
name: 'registryDir',
|
|
11
|
-
message: 'provide a registryDir:'
|
|
11
|
+
message: 'provide a registryDir:',
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
type: 'confirm',
|
|
16
|
+
name: 'useStrict',
|
|
17
|
+
required: true,
|
|
18
|
+
useDefault: true,
|
|
19
|
+
default: false
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: 'confirm',
|
|
23
|
+
name: 'allErrors',
|
|
24
|
+
required: true,
|
|
25
|
+
useDefault: true,
|
|
26
|
+
default: true
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: 'confirm',
|
|
30
|
+
name: 'useDefaults',
|
|
31
|
+
required: true,
|
|
32
|
+
useDefault: true,
|
|
33
|
+
default: true
|
|
12
34
|
}
|
|
13
35
|
]);
|
|
14
36
|
if (!(0, fs_1.existsSync)(argv.registryDir)) {
|
|
@@ -16,7 +38,12 @@ const commands = async (argv, prompter, _options) => {
|
|
|
16
38
|
throw new Error('bad registry path!');
|
|
17
39
|
}
|
|
18
40
|
const registry = new workflows_1.Registry(argv.registryDir);
|
|
19
|
-
const
|
|
41
|
+
const { allErrors, useDefaults, useStrict } = argv;
|
|
42
|
+
const validator = new workflows_1.SchemaValidator(registry, {
|
|
43
|
+
allErrors,
|
|
44
|
+
useDefaults,
|
|
45
|
+
useStrict
|
|
46
|
+
});
|
|
20
47
|
validator.validateAllData(true);
|
|
21
48
|
return argv;
|
|
22
49
|
};
|
package/esm/commands/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { commands as codegen } from './codegen';
|
|
2
2
|
import { commands as info } from './info';
|
|
3
3
|
import { commands as validate } from './validate';
|
|
4
|
+
import { getUsage } from '../help';
|
|
4
5
|
export const commands = async (argv, prompter, _options) => {
|
|
5
6
|
let command;
|
|
6
7
|
if (argv._.length > 0) {
|
|
@@ -9,6 +10,11 @@ export const commands = async (argv, prompter, _options) => {
|
|
|
9
10
|
if (command) {
|
|
10
11
|
argv.command = command;
|
|
11
12
|
}
|
|
13
|
+
if (command === 'help') {
|
|
14
|
+
const usage = getUsage();
|
|
15
|
+
console.log(usage);
|
|
16
|
+
process.exit(0);
|
|
17
|
+
}
|
|
12
18
|
const questions = [
|
|
13
19
|
{
|
|
14
20
|
type: 'autocomplete',
|
|
@@ -5,7 +5,29 @@ export const commands = async (argv, prompter, _options) => {
|
|
|
5
5
|
{
|
|
6
6
|
type: 'text',
|
|
7
7
|
name: 'registryDir',
|
|
8
|
-
message: 'provide a registryDir:'
|
|
8
|
+
message: 'provide a registryDir:',
|
|
9
|
+
required: true,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
type: 'confirm',
|
|
13
|
+
name: 'useStrict',
|
|
14
|
+
required: true,
|
|
15
|
+
useDefault: true,
|
|
16
|
+
default: false
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
type: 'confirm',
|
|
20
|
+
name: 'allErrors',
|
|
21
|
+
required: true,
|
|
22
|
+
useDefault: true,
|
|
23
|
+
default: true
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: 'confirm',
|
|
27
|
+
name: 'useDefaults',
|
|
28
|
+
required: true,
|
|
29
|
+
useDefault: true,
|
|
30
|
+
default: true
|
|
9
31
|
}
|
|
10
32
|
]);
|
|
11
33
|
if (!existsSync(argv.registryDir)) {
|
|
@@ -13,7 +35,12 @@ export const commands = async (argv, prompter, _options) => {
|
|
|
13
35
|
throw new Error('bad registry path!');
|
|
14
36
|
}
|
|
15
37
|
const registry = new Registry(argv.registryDir);
|
|
16
|
-
const
|
|
38
|
+
const { allErrors, useDefaults, useStrict } = argv;
|
|
39
|
+
const validator = new SchemaValidator(registry, {
|
|
40
|
+
allErrors,
|
|
41
|
+
useDefaults,
|
|
42
|
+
useStrict
|
|
43
|
+
});
|
|
17
44
|
validator.validateAllData(true);
|
|
18
45
|
return argv;
|
|
19
46
|
};
|
package/esm/help.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
export function getUsage() {
|
|
3
|
+
const header = chalk.white.bold;
|
|
4
|
+
const command = chalk.blue.bold;
|
|
5
|
+
const option = chalk.gray.italic;
|
|
6
|
+
const description = chalk.white;
|
|
7
|
+
const normal = chalk.white;
|
|
8
|
+
return `
|
|
9
|
+
${header('NAME')}
|
|
10
|
+
${command('chain-registry')} - command line interface for interacting with the Chain Registry
|
|
11
|
+
|
|
12
|
+
${header('SYNOPSIS')}
|
|
13
|
+
${command('chain-registry')} ${option('[command]')} ${option('[options]')}
|
|
14
|
+
|
|
15
|
+
${header('DESCRIPTION')}
|
|
16
|
+
${description('The chain-registry CLI is designed to interact with the Chain Registry, allowing users to fetch information, validate data, and generate TypeScript interfaces directly from JSON schemas.')}
|
|
17
|
+
|
|
18
|
+
${header('COMMANDS')}
|
|
19
|
+
${command('info')}
|
|
20
|
+
${normal('Fetch and display information about entities in the chain registry.')}
|
|
21
|
+
${option('--registryDir <path>')}
|
|
22
|
+
${normal('Specifies the path to the chain registry directory.')}
|
|
23
|
+
${command('validate')}
|
|
24
|
+
${normal('Validate the data in the registry against the provided JSON schemas.')}
|
|
25
|
+
${option('--registryDir <path>')}
|
|
26
|
+
${normal('Specifies the path to the chain registry directory.')}
|
|
27
|
+
${option('--useStrict')}
|
|
28
|
+
${normal('Enables strict mode in the schema validation process.')}
|
|
29
|
+
${option('--allErrors')}
|
|
30
|
+
${normal('Return all errors found during validation.')}
|
|
31
|
+
${option('--useDefaults')}
|
|
32
|
+
${normal('Applies default values during validation.')}
|
|
33
|
+
${command('codegen')}
|
|
34
|
+
${normal('Generate TypeScript interfaces for the registry.')}
|
|
35
|
+
${option('--outputDir <path>')}
|
|
36
|
+
${normal('Specifies the directory to output the generated TypeScript files.')}
|
|
37
|
+
${option('--registryDir <path>')}
|
|
38
|
+
${normal('Specifies the path to the chain registry directory.')}
|
|
39
|
+
${option('--strictTypeSafety')}
|
|
40
|
+
${normal('Enables strict TypeScript type definitions.')}
|
|
41
|
+
${option('--useCamelCase')}
|
|
42
|
+
${normal('Converts JSON schema properties to camelCase in the generated TypeScript files.')}
|
|
43
|
+
|
|
44
|
+
${header('EXAMPLES')}
|
|
45
|
+
${command('chain-registry info --registryDir /path/to/registry')}
|
|
46
|
+
${normal('Displays information about the chains in the specified registry directory.')}
|
|
47
|
+
${command('chain-registry validate --registryDir /path/to/registry --useStrict')}
|
|
48
|
+
${normal('Validates the registry data located in the specified directory with strict schema checks.')}
|
|
49
|
+
${command('chain-registry codegen --outputDir ./src --registryDir /path/to/registry')}
|
|
50
|
+
${normal('Generates TypeScript interfaces in the ./src directory based on the schemas in the specified registry directory.')}
|
|
51
|
+
|
|
52
|
+
${header('SEE ALSO')}
|
|
53
|
+
${command('@chain-registry/workflows,')}
|
|
54
|
+
${command('chain-registry')}
|
|
55
|
+
|
|
56
|
+
${header('AUTHOR')}
|
|
57
|
+
${normal('Written by Dan Lynch.')}
|
|
58
|
+
|
|
59
|
+
${header('REPORTING BUGS')}
|
|
60
|
+
${normal('Report bugs at')} ${chalk.underline('https://github.com/cosmology-tech/chain-registry/issues')}
|
|
61
|
+
|
|
62
|
+
${header('COPYRIGHT')}
|
|
63
|
+
${normal('Copyright 2024 Interweb, Inc. Licensed under MIT.')}
|
|
64
|
+
`.trim();
|
|
65
|
+
}
|
package/help.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getUsage(): string;
|
package/help.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
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.getUsage = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
function getUsage() {
|
|
9
|
+
const header = chalk_1.default.white.bold;
|
|
10
|
+
const command = chalk_1.default.blue.bold;
|
|
11
|
+
const option = chalk_1.default.gray.italic;
|
|
12
|
+
const description = chalk_1.default.white;
|
|
13
|
+
const normal = chalk_1.default.white;
|
|
14
|
+
return `
|
|
15
|
+
${header('NAME')}
|
|
16
|
+
${command('chain-registry')} - command line interface for interacting with the Chain Registry
|
|
17
|
+
|
|
18
|
+
${header('SYNOPSIS')}
|
|
19
|
+
${command('chain-registry')} ${option('[command]')} ${option('[options]')}
|
|
20
|
+
|
|
21
|
+
${header('DESCRIPTION')}
|
|
22
|
+
${description('The chain-registry CLI is designed to interact with the Chain Registry, allowing users to fetch information, validate data, and generate TypeScript interfaces directly from JSON schemas.')}
|
|
23
|
+
|
|
24
|
+
${header('COMMANDS')}
|
|
25
|
+
${command('info')}
|
|
26
|
+
${normal('Fetch and display information about entities in the chain registry.')}
|
|
27
|
+
${option('--registryDir <path>')}
|
|
28
|
+
${normal('Specifies the path to the chain registry directory.')}
|
|
29
|
+
${command('validate')}
|
|
30
|
+
${normal('Validate the data in the registry against the provided JSON schemas.')}
|
|
31
|
+
${option('--registryDir <path>')}
|
|
32
|
+
${normal('Specifies the path to the chain registry directory.')}
|
|
33
|
+
${option('--useStrict')}
|
|
34
|
+
${normal('Enables strict mode in the schema validation process.')}
|
|
35
|
+
${option('--allErrors')}
|
|
36
|
+
${normal('Return all errors found during validation.')}
|
|
37
|
+
${option('--useDefaults')}
|
|
38
|
+
${normal('Applies default values during validation.')}
|
|
39
|
+
${command('codegen')}
|
|
40
|
+
${normal('Generate TypeScript interfaces for the registry.')}
|
|
41
|
+
${option('--outputDir <path>')}
|
|
42
|
+
${normal('Specifies the directory to output the generated TypeScript files.')}
|
|
43
|
+
${option('--registryDir <path>')}
|
|
44
|
+
${normal('Specifies the path to the chain registry directory.')}
|
|
45
|
+
${option('--strictTypeSafety')}
|
|
46
|
+
${normal('Enables strict TypeScript type definitions.')}
|
|
47
|
+
${option('--useCamelCase')}
|
|
48
|
+
${normal('Converts JSON schema properties to camelCase in the generated TypeScript files.')}
|
|
49
|
+
|
|
50
|
+
${header('EXAMPLES')}
|
|
51
|
+
${command('chain-registry info --registryDir /path/to/registry')}
|
|
52
|
+
${normal('Displays information about the chains in the specified registry directory.')}
|
|
53
|
+
${command('chain-registry validate --registryDir /path/to/registry --useStrict')}
|
|
54
|
+
${normal('Validates the registry data located in the specified directory with strict schema checks.')}
|
|
55
|
+
${command('chain-registry codegen --outputDir ./src --registryDir /path/to/registry')}
|
|
56
|
+
${normal('Generates TypeScript interfaces in the ./src directory based on the schemas in the specified registry directory.')}
|
|
57
|
+
|
|
58
|
+
${header('SEE ALSO')}
|
|
59
|
+
${command('@chain-registry/workflows,')}
|
|
60
|
+
${command('chain-registry')}
|
|
61
|
+
|
|
62
|
+
${header('AUTHOR')}
|
|
63
|
+
${normal('Written by Dan Lynch.')}
|
|
64
|
+
|
|
65
|
+
${header('REPORTING BUGS')}
|
|
66
|
+
${normal('Report bugs at')} ${chalk_1.default.underline('https://github.com/cosmology-tech/chain-registry/issues')}
|
|
67
|
+
|
|
68
|
+
${header('COPYRIGHT')}
|
|
69
|
+
${normal('Copyright 2024 Interweb, Inc. Licensed under MIT.')}
|
|
70
|
+
`.trim();
|
|
71
|
+
}
|
|
72
|
+
exports.getUsage = getUsage;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chain-registry/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.30.0",
|
|
4
4
|
"description": "Chain Registry CLI",
|
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/cosmology-tech/chain-registry",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"test:watch": "jest --watch"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@chain-registry/interfaces": "^0.
|
|
37
|
-
"@chain-registry/workflows": "^1.
|
|
36
|
+
"@chain-registry/interfaces": "^0.29.0",
|
|
37
|
+
"@chain-registry/workflows": "^1.30.0",
|
|
38
38
|
"chalk": "^4.1.0",
|
|
39
39
|
"deepmerge": "^4.3.1",
|
|
40
40
|
"inquirerer": "1.8.0",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"strfy-js": "^2.2.2"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "a8e191a74bad94ab2c1a9c05eec1bb9a4a044d3d"
|
|
54
54
|
}
|