@chain-registry/cli 1.30.5 → 1.30.6
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 +1 -1
- package/cli.js +0 -0
- package/commands/codegen/index.js +5 -3
- package/commands/index.js +1 -1
- package/dist/LICENSE +21 -0
- package/dist/README.md +115 -0
- package/dist/package.json +50 -0
- package/esm/cli.js +0 -0
- package/esm/commands/codegen/index.js +5 -3
- package/esm/commands/index.js +1 -1
- package/esm/help.js +1 -1
- package/esm/utils.js +10 -0
- package/help.js +1 -1
- package/package.json +2 -6
- package/utils.d.ts +1 -0
- package/utils.js +12 -1
package/README.md
CHANGED
|
@@ -89,7 +89,7 @@ Options:
|
|
|
89
89
|
- `--outputDir`: Directory to output the generated TypeScript files.
|
|
90
90
|
- `--registryDir`: Path to the chain registry directory.
|
|
91
91
|
- `--strictTypeSafety`: Enables strict TypeScript type definitions.
|
|
92
|
-
- `--
|
|
92
|
+
- `--camelCase`: Converts JSON schema properties to camelCase in the generated TypeScript files.
|
|
93
93
|
|
|
94
94
|
## Related
|
|
95
95
|
|
package/cli.js
CHANGED
|
File without changes
|
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.commands = void 0;
|
|
4
4
|
const workflows_1 = require("@chain-registry/workflows");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
6
7
|
const commands = async (argv, prompter, _options) => {
|
|
7
|
-
const { registryDir, outputDir, strictTypeSafety,
|
|
8
|
+
const { registryDir, outputDir, strictTypeSafety, camelCase } = await prompter.prompt(argv, [
|
|
8
9
|
{
|
|
9
10
|
type: 'text',
|
|
10
11
|
name: 'registryDir',
|
|
@@ -23,7 +24,7 @@ const commands = async (argv, prompter, _options) => {
|
|
|
23
24
|
},
|
|
24
25
|
{
|
|
25
26
|
type: 'confirm',
|
|
26
|
-
name: '
|
|
27
|
+
name: 'camelCase',
|
|
27
28
|
default: true,
|
|
28
29
|
useDefault: false
|
|
29
30
|
}
|
|
@@ -38,7 +39,8 @@ const commands = async (argv, prompter, _options) => {
|
|
|
38
39
|
registry,
|
|
39
40
|
schemaTSOptions: {
|
|
40
41
|
strictTypeSafety,
|
|
41
|
-
|
|
42
|
+
camelCase,
|
|
43
|
+
camelCaseFn: utils_1.toCamelCase
|
|
42
44
|
}
|
|
43
45
|
});
|
|
44
46
|
generator.generateTypes();
|
package/commands/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.commands = void 0;
|
|
4
|
+
const help_1 = require("../help");
|
|
4
5
|
const codegen_1 = require("./codegen");
|
|
5
6
|
const info_1 = require("./info");
|
|
6
7
|
const validate_1 = require("./validate");
|
|
7
|
-
const help_1 = require("../help");
|
|
8
8
|
const commands = async (argv, prompter, _options) => {
|
|
9
9
|
let command;
|
|
10
10
|
if (argv._.length > 0) {
|
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Dan Lynch <pyramation@gmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# @chain-registry/cli
|
|
2
|
+
|
|
3
|
+
<p align="center" width="100%">
|
|
4
|
+
<img height="90" src="https://user-images.githubusercontent.com/545047/190171475-b416f99e-2831-4786-9ba3-a7ff4d95b0d3.svg" />
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center" width="100%">
|
|
8
|
+
<a href="https://github.com/cosmology-tech/chain-registry/actions/workflows/run-tests.yml">
|
|
9
|
+
<img height="20" src="https://github.com/cosmology-tech/chain-registry/actions/workflows/run-tests.yml/badge.svg" />
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://github.com/cosmology-tech/chain-registry/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
|
|
12
|
+
<a href="https://www.npmjs.com/package/@chain-registry/cli"><img height="20" src="https://img.shields.io/github/package-json/v/cosmology-tech/chain-registry?filename=workflows%2Fcli%2Fpackage.json"></a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
The `@chain-registry/cli` is a powerful command-line interface designed to interact with the Chain Registry, allowing users to fetch information, validate data, and generate TypeScript interfaces directly from JSON schemas.
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
🔍 **Info**: Retrieve detailed information about chains, assets, and asset lists.
|
|
20
|
+
|
|
21
|
+
✅ **Validate**: Check the integrity and validity of the registry data against its schemas.
|
|
22
|
+
|
|
23
|
+
🛠️ **Codegen**: Generate TypeScript definitions for use in development, ensuring type safety and adherence to the schema definitions.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
To get started with `@chain-registry/cli`, install it via npm or yarn:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
npm install @chain-registry/cli
|
|
31
|
+
# or
|
|
32
|
+
yarn add @chain-registry/cli
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Table of Contents
|
|
36
|
+
|
|
37
|
+
- [Features](#features)
|
|
38
|
+
- [Installation](#installation)
|
|
39
|
+
- [Command Details](#command-details)
|
|
40
|
+
- [Info](#info)
|
|
41
|
+
- [Validate](#validate)
|
|
42
|
+
- [Codegen](#codegen)
|
|
43
|
+
- [Related Projects](#related)
|
|
44
|
+
- [Credits](#credits)
|
|
45
|
+
- [Disclaimer](#disclaimer)
|
|
46
|
+
|
|
47
|
+
## Command Details
|
|
48
|
+
|
|
49
|
+
### Info
|
|
50
|
+
|
|
51
|
+
Fetch and display information about entities in the chain registry:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
chain-registry info
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Options:
|
|
58
|
+
|
|
59
|
+
- `chain`: Fetch information specific to a chain.
|
|
60
|
+
- `asset-list`: Fetch asset lists associated with a specific chain.
|
|
61
|
+
- `asset`: Fetch detailed information about a specific asset.
|
|
62
|
+
- `--registryDir`: Path to the chain registry directory.
|
|
63
|
+
|
|
64
|
+
### Validate
|
|
65
|
+
|
|
66
|
+
Validate the data in the registry against the provided JSON schemas:
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
chain-registry validate
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Options:
|
|
73
|
+
|
|
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).
|
|
78
|
+
|
|
79
|
+
### Codegen
|
|
80
|
+
|
|
81
|
+
Generate TypeScript interfaces for the registry:
|
|
82
|
+
|
|
83
|
+
```sh
|
|
84
|
+
chain-registry codegen --outputDir ./src --registryDir /path/to/registry
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Options:
|
|
88
|
+
|
|
89
|
+
- `--outputDir`: Directory to output the generated TypeScript files.
|
|
90
|
+
- `--registryDir`: Path to the chain registry directory.
|
|
91
|
+
- `--strictTypeSafety`: Enables strict TypeScript type definitions.
|
|
92
|
+
- `--camelCase`: Converts JSON schema properties to camelCase in the generated TypeScript files.
|
|
93
|
+
|
|
94
|
+
## Related
|
|
95
|
+
|
|
96
|
+
Checkout these related projects:
|
|
97
|
+
|
|
98
|
+
* [@cosmology/telescope](https://github.com/cosmology-tech/telescope) Your Frontend Companion for Building with TypeScript with Cosmos SDK Modules.
|
|
99
|
+
* [@cosmwasm/ts-codegen](https://github.com/CosmWasm/ts-codegen) Convert your CosmWasm smart contracts into dev-friendly TypeScript classes.
|
|
100
|
+
* [chain-registry](https://github.com/cosmology-tech/chain-registry) Everything from token symbols, logos, and IBC denominations for all assets you want to support in your application.
|
|
101
|
+
* [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit) Experience the convenience of connecting with a variety of web3 wallets through a single, streamlined interface.
|
|
102
|
+
* [create-cosmos-app](https://github.com/cosmology-tech/create-cosmos-app) Set up a modern Cosmos app by running one command.
|
|
103
|
+
* [interchain-ui](https://github.com/cosmology-tech/interchain-ui) The Interchain Design System, empowering developers with a flexible, easy-to-use UI kit.
|
|
104
|
+
* [starship](https://github.com/cosmology-tech/starship) Unified Testing and Development for the Interchain.
|
|
105
|
+
|
|
106
|
+
## Credits
|
|
107
|
+
|
|
108
|
+
🛠 Built by Cosmology — if you like our tools, please consider delegating to [our validator ⚛️](https://cosmology.zone/validator)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
## Disclaimer
|
|
112
|
+
|
|
113
|
+
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
|
|
114
|
+
|
|
115
|
+
No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chain-registry/cli",
|
|
3
|
+
"version": "1.30.6",
|
|
4
|
+
"description": "Chain Registry CLI",
|
|
5
|
+
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
6
|
+
"homepage": "https://github.com/cosmology-tech/chain-registry",
|
|
7
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"module": "esm/index.js",
|
|
10
|
+
"types": "index.d.ts",
|
|
11
|
+
"bin": {
|
|
12
|
+
"registry": "cli.js",
|
|
13
|
+
"chain-registry": "cli.js"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public",
|
|
17
|
+
"directory": "dist"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/cosmology-tech/chain-registry"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/cosmology-tech/chain-registry/issues"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"copy": "copyfiles -f LICENSE README.md package.json dist",
|
|
28
|
+
"clean": "del dist/**",
|
|
29
|
+
"prepare": "npm run build",
|
|
30
|
+
"build": "npm run clean; tsc; tsc -p tsconfig.esm.json; npm run copy",
|
|
31
|
+
"dev": "ts-node src/cli",
|
|
32
|
+
"test": "jest",
|
|
33
|
+
"test:watch": "jest --watch"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@chain-registry/interfaces": "^0.29.5",
|
|
37
|
+
"@chain-registry/workflows": "^1.30.5",
|
|
38
|
+
"chalk": "^4.1.0",
|
|
39
|
+
"deepmerge": "^4.3.1",
|
|
40
|
+
"inquirerer": "1.8.0",
|
|
41
|
+
"minimist": "^1.2.8"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"cli",
|
|
45
|
+
"chain-registry",
|
|
46
|
+
"web3",
|
|
47
|
+
"cosmos",
|
|
48
|
+
"interchain"
|
|
49
|
+
]
|
|
50
|
+
}
|
package/esm/cli.js
CHANGED
|
File without changes
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Registry, SchemaTypeGenerator } from '@chain-registry/workflows';
|
|
2
2
|
import { existsSync } from 'fs';
|
|
3
|
+
import { toCamelCase } from '../../utils';
|
|
3
4
|
export const commands = async (argv, prompter, _options) => {
|
|
4
|
-
const { registryDir, outputDir, strictTypeSafety,
|
|
5
|
+
const { registryDir, outputDir, strictTypeSafety, camelCase } = await prompter.prompt(argv, [
|
|
5
6
|
{
|
|
6
7
|
type: 'text',
|
|
7
8
|
name: 'registryDir',
|
|
@@ -20,7 +21,7 @@ export const commands = async (argv, prompter, _options) => {
|
|
|
20
21
|
},
|
|
21
22
|
{
|
|
22
23
|
type: 'confirm',
|
|
23
|
-
name: '
|
|
24
|
+
name: 'camelCase',
|
|
24
25
|
default: true,
|
|
25
26
|
useDefault: false
|
|
26
27
|
}
|
|
@@ -35,7 +36,8 @@ export const commands = async (argv, prompter, _options) => {
|
|
|
35
36
|
registry,
|
|
36
37
|
schemaTSOptions: {
|
|
37
38
|
strictTypeSafety,
|
|
38
|
-
|
|
39
|
+
camelCase,
|
|
40
|
+
camelCaseFn: toCamelCase
|
|
39
41
|
}
|
|
40
42
|
});
|
|
41
43
|
generator.generateTypes();
|
package/esm/commands/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { getUsage } from '../help';
|
|
1
2
|
import { commands as codegen } from './codegen';
|
|
2
3
|
import { commands as info } from './info';
|
|
3
4
|
import { commands as validate } from './validate';
|
|
4
|
-
import { getUsage } from '../help';
|
|
5
5
|
export const commands = async (argv, prompter, _options) => {
|
|
6
6
|
let command;
|
|
7
7
|
if (argv._.length > 0) {
|
package/esm/help.js
CHANGED
|
@@ -38,7 +38,7 @@ ${header('COMMANDS')}
|
|
|
38
38
|
${normal('Specifies the path to the chain registry directory.')}
|
|
39
39
|
${option('--strictTypeSafety')}
|
|
40
40
|
${normal('Enables strict TypeScript type definitions.')}
|
|
41
|
-
${option('--
|
|
41
|
+
${option('--camelCase')}
|
|
42
42
|
${normal('Converts JSON schema properties to camelCase in the generated TypeScript files.')}
|
|
43
43
|
|
|
44
44
|
${header('EXAMPLES')}
|
package/esm/utils.js
CHANGED
|
@@ -10,3 +10,13 @@ export function getVersion() {
|
|
|
10
10
|
const pkg = readAndParsePackageJson();
|
|
11
11
|
return pkg.version;
|
|
12
12
|
}
|
|
13
|
+
// MARKED AS NOT DRY
|
|
14
|
+
export function toCamelCase(key) {
|
|
15
|
+
return key
|
|
16
|
+
// First, remove all leading non-alphabet characters except $
|
|
17
|
+
.replace(/^[^a-zA-Z$]+/, '')
|
|
18
|
+
// Convert what follows a separator into upper case
|
|
19
|
+
.replace(/[-_\s]+(.)?/g, (_, c) => c ? c.toUpperCase() : '')
|
|
20
|
+
// Ensure the first character of the result is always lowercase
|
|
21
|
+
.replace(/^./, (c) => c.toLowerCase());
|
|
22
|
+
}
|
package/help.js
CHANGED
|
@@ -44,7 +44,7 @@ ${header('COMMANDS')}
|
|
|
44
44
|
${normal('Specifies the path to the chain registry directory.')}
|
|
45
45
|
${option('--strictTypeSafety')}
|
|
46
46
|
${normal('Enables strict TypeScript type definitions.')}
|
|
47
|
-
${option('--
|
|
47
|
+
${option('--camelCase')}
|
|
48
48
|
${normal('Converts JSON schema properties to camelCase in the generated TypeScript files.')}
|
|
49
49
|
|
|
50
50
|
${header('EXAMPLES')}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chain-registry/cli",
|
|
3
|
-
"version": "1.30.
|
|
3
|
+
"version": "1.30.6",
|
|
4
4
|
"description": "Chain Registry CLI",
|
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/cosmology-tech/chain-registry",
|
|
@@ -46,9 +46,5 @@
|
|
|
46
46
|
"web3",
|
|
47
47
|
"cosmos",
|
|
48
48
|
"interchain"
|
|
49
|
-
]
|
|
50
|
-
"devDependencies": {
|
|
51
|
-
"strfy-js": "^2.2.2"
|
|
52
|
-
},
|
|
53
|
-
"gitHead": "63df544ec7e864f893bdc7a4605a1666ca292da3"
|
|
49
|
+
]
|
|
54
50
|
}
|
package/utils.d.ts
CHANGED
package/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getVersion = exports.displayVersion = void 0;
|
|
6
|
+
exports.toCamelCase = exports.getVersion = exports.displayVersion = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const package_1 = require("./package");
|
|
9
9
|
// Function to display the version information
|
|
@@ -18,3 +18,14 @@ function getVersion() {
|
|
|
18
18
|
return pkg.version;
|
|
19
19
|
}
|
|
20
20
|
exports.getVersion = getVersion;
|
|
21
|
+
// MARKED AS NOT DRY
|
|
22
|
+
function toCamelCase(key) {
|
|
23
|
+
return key
|
|
24
|
+
// First, remove all leading non-alphabet characters except $
|
|
25
|
+
.replace(/^[^a-zA-Z$]+/, '')
|
|
26
|
+
// Convert what follows a separator into upper case
|
|
27
|
+
.replace(/[-_\s]+(.)?/g, (_, c) => c ? c.toUpperCase() : '')
|
|
28
|
+
// Ensure the first character of the result is always lowercase
|
|
29
|
+
.replace(/^./, (c) => c.toLowerCase());
|
|
30
|
+
}
|
|
31
|
+
exports.toCamelCase = toCamelCase;
|