@chain-registry/workflows 1.26.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/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/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # @chain-registry/workflows
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/workflows"><img height="20" src="https://img.shields.io/github/package-json/v/cosmology-tech/chain-registry?filename=packages%2Fworkflows%2Fpackage.json"></a>
13
+ </p>
14
+
15
+ TODO
16
+
17
+
18
+ ## Related
19
+
20
+ Checkout these related projects:
21
+
22
+ * [@cosmology/telescope](https://github.com/cosmology-tech/telescope) Your Frontend Companion for Building with TypeScript with Cosmos SDK Modules.
23
+ * [@cosmwasm/ts-codegen](https://github.com/CosmWasm/ts-codegen) Convert your CosmWasm smart contracts into dev-friendly TypeScript classes.
24
+ * [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.
25
+ * [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.
26
+ * [create-cosmos-app](https://github.com/cosmology-tech/create-cosmos-app) Set up a modern Cosmos app by running one command.
27
+ * [interchain-ui](https://github.com/cosmology-tech/interchain-ui) The Interchain Design System, empowering developers with a flexible, easy-to-use UI kit.
28
+ * [starship](https://github.com/cosmology-tech/starship) Unified Testing and Development for the Interchain.
29
+
30
+ ## Credits
31
+
32
+ 🛠 Built by Cosmology — if you like our tools, please consider delegating to [our validator ⚛️](https://cosmology.zone/validator)
33
+
34
+
35
+ ## Disclaimer
36
+
37
+ AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
38
+
39
+ 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.
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,39 @@
1
+ # @chain-registry/workflows
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/workflows"><img height="20" src="https://img.shields.io/github/package-json/v/cosmology-tech/chain-registry?filename=packages%2Fworkflows%2Fpackage.json"></a>
13
+ </p>
14
+
15
+ TODO
16
+
17
+
18
+ ## Related
19
+
20
+ Checkout these related projects:
21
+
22
+ * [@cosmology/telescope](https://github.com/cosmology-tech/telescope) Your Frontend Companion for Building with TypeScript with Cosmos SDK Modules.
23
+ * [@cosmwasm/ts-codegen](https://github.com/CosmWasm/ts-codegen) Convert your CosmWasm smart contracts into dev-friendly TypeScript classes.
24
+ * [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.
25
+ * [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.
26
+ * [create-cosmos-app](https://github.com/cosmology-tech/create-cosmos-app) Set up a modern Cosmos app by running one command.
27
+ * [interchain-ui](https://github.com/cosmology-tech/interchain-ui) The Interchain Design System, empowering developers with a flexible, easy-to-use UI kit.
28
+ * [starship](https://github.com/cosmology-tech/starship) Unified Testing and Development for the Interchain.
29
+
30
+ ## Credits
31
+
32
+ 🛠 Built by Cosmology — if you like our tools, please consider delegating to [our validator ⚛️](https://cosmology.zone/validator)
33
+
34
+
35
+ ## Disclaimer
36
+
37
+ AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
38
+
39
+ 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,49 @@
1
+ {
2
+ "name": "@chain-registry/workflows",
3
+ "version": "1.26.3",
4
+ "description": "Chain Registry Workflows",
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
+ "publishConfig": {
12
+ "access": "public",
13
+ "directory": "dist"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/cosmology-tech/chain-registry"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/cosmology-tech/chain-registry/issues"
21
+ },
22
+ "scripts": {
23
+ "copy": "copyfiles -f LICENSE README.md package.json dist",
24
+ "clean": "del dist/**",
25
+ "prepare": "npm run build",
26
+ "build": "npm run clean; tsc; tsc -p tsconfig.esm.json; npm run copy",
27
+ "test": "jest",
28
+ "test:watch": "jest --watch"
29
+ },
30
+ "devDependencies": {
31
+ "@types/sha.js": "^2.4.0",
32
+ "strfy-js": "^2.2.2"
33
+ },
34
+ "dependencies": {
35
+ "@chain-registry/types": "^0.25.3",
36
+ "bignumber.js": "9.1.1",
37
+ "file-ts": "^0.7.15",
38
+ "minimatch": "^9.0.4",
39
+ "schema-typescript": "^0.2.4",
40
+ "sha.js": "^2.4.11",
41
+ "strfy-js": "^2.2.2"
42
+ },
43
+ "keywords": [
44
+ "chain-registry",
45
+ "web3",
46
+ "cosmos",
47
+ "interchain"
48
+ ]
49
+ }
@@ -0,0 +1,36 @@
1
+ import { sync as glob } from "glob";
2
+ import { basename, dirname, join, relative } from "path";
3
+ export const NON_INFO_DIRS = [
4
+ '_memo_keys',
5
+ '_scripts',
6
+ '_template',
7
+ '.github'
8
+ ];
9
+ const REG_DIR = 'chain-registry/chain-registry';
10
+ export const registryDir = join(__dirname, `/../../../packages/${REG_DIR}`);
11
+ // Helper function to filter and map file paths
12
+ function filterAndMapFiles(paths) {
13
+ return paths.filter(path => {
14
+ const relativePath = path.split(REG_DIR)[1];
15
+ const dir = basename(dirname(relativePath));
16
+ return !NON_INFO_DIRS.includes(dir);
17
+ }).map(path => {
18
+ const relativePath = path.split(REG_DIR)[1];
19
+ return {
20
+ filepath: relativePath,
21
+ origpath: relative(process.cwd(), path)
22
+ };
23
+ });
24
+ }
25
+ // Glob patterns for different JSON files
26
+ const globPatterns = {
27
+ chains: `${registryDir}/**/chain.json`,
28
+ assetLists: `${registryDir}/**/assetlist.json`,
29
+ ibcInfo: `${registryDir}/**/_IBC/*-*.json`,
30
+ schemas: `${registryDir}/*.schema.json`
31
+ };
32
+ // Using the helper function to process files
33
+ export const chains = filterAndMapFiles(glob(globPatterns.chains));
34
+ export const assetLists = filterAndMapFiles(glob(globPatterns.assetLists));
35
+ export const ibcInfo = filterAndMapFiles(glob(globPatterns.ibcInfo));
36
+ export const schemas = glob(globPatterns.schemas);
package/esm/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './fixtures';
2
+ export * from './schema-typescript';
@@ -0,0 +1,71 @@
1
+ import { basename, dirname, join } from 'path';
2
+ import { generateTypeScript } from 'schema-typescript';
3
+ // Default titles for certain schemas
4
+ // TODO create issue in cosmos/chain-registry
5
+ const DEFAULT_TITLES = {
6
+ 'ibc_data.schema.json': 'IBCData',
7
+ 'chain.schema.json': 'Chain',
8
+ 'assetlist.schema.json': 'AssetList',
9
+ 'versions.schema.json': 'Versions',
10
+ 'memo_keys.schema.json': 'MemoKeys',
11
+ };
12
+ export class SchemaTypeGenerator {
13
+ outputDir;
14
+ writeFs;
15
+ readFs;
16
+ schemas;
17
+ schemaTSOptions;
18
+ supportedSchemas;
19
+ constructor(options) {
20
+ this.outputDir = options.outputDir;
21
+ this.writeFs = options.writeFs;
22
+ this.readFs = options.readFs;
23
+ this.schemas = options.schemas;
24
+ this.supportedSchemas = new Set(options.supportedSchemas || []);
25
+ }
26
+ updateSchemaTitle(schema, schemaFile) {
27
+ const filename = basename(schemaFile);
28
+ if (DEFAULT_TITLES[filename]) {
29
+ schema.title = DEFAULT_TITLES[filename];
30
+ }
31
+ }
32
+ isSchemaSupported(filePath) {
33
+ if (this.supportedSchemas.size === 0)
34
+ return true; // If no filter is provided, process all files
35
+ const filename = basename(filePath);
36
+ return this.supportedSchemas.has(filename);
37
+ }
38
+ generateTypes() {
39
+ this.schemas.forEach(schemaFile => {
40
+ if (this.isSchemaSupported(schemaFile)) {
41
+ try {
42
+ const schema = this.readJsonFile(schemaFile);
43
+ this.updateSchemaTitle(schema, schemaFile);
44
+ const result = this.generateTypeScript(schema);
45
+ const filename = this.getOutputFilename(schemaFile);
46
+ this.ensureDirExists(filename);
47
+ this.writeFile(filename, result);
48
+ }
49
+ catch (e) {
50
+ console.log({ schemaFile });
51
+ }
52
+ }
53
+ });
54
+ }
55
+ readJsonFile(filePath) {
56
+ return JSON.parse(this.readFs.readFileSync(filePath, 'utf-8'));
57
+ }
58
+ generateTypeScript(schema) {
59
+ return generateTypeScript(schema, this.schemaTSOptions);
60
+ }
61
+ getOutputFilename(schemaFile) {
62
+ const filename = basename(schemaFile);
63
+ return join(this.outputDir, filename.replace(/.json$/, '.ts'));
64
+ }
65
+ ensureDirExists(filePath) {
66
+ this.writeFs.mkdirpSync(dirname(filePath));
67
+ }
68
+ writeFile(filePath, content) {
69
+ this.writeFs.writeFileSync(filePath, content);
70
+ }
71
+ }
package/fixtures.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ export declare const NON_INFO_DIRS: string[];
2
+ export declare const registryDir: string;
3
+ interface FilePathInfo {
4
+ filepath: string;
5
+ origpath: string;
6
+ }
7
+ export declare const chains: FilePathInfo[];
8
+ export declare const assetLists: FilePathInfo[];
9
+ export declare const ibcInfo: FilePathInfo[];
10
+ export declare const schemas: string[];
11
+ export {};
package/fixtures.js ADDED
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.schemas = exports.ibcInfo = exports.assetLists = exports.chains = exports.registryDir = exports.NON_INFO_DIRS = void 0;
4
+ const glob_1 = require("glob");
5
+ const path_1 = require("path");
6
+ exports.NON_INFO_DIRS = [
7
+ '_memo_keys',
8
+ '_scripts',
9
+ '_template',
10
+ '.github'
11
+ ];
12
+ const REG_DIR = 'chain-registry/chain-registry';
13
+ exports.registryDir = (0, path_1.join)(__dirname, `/../../../packages/${REG_DIR}`);
14
+ // Helper function to filter and map file paths
15
+ function filterAndMapFiles(paths) {
16
+ return paths.filter(path => {
17
+ const relativePath = path.split(REG_DIR)[1];
18
+ const dir = (0, path_1.basename)((0, path_1.dirname)(relativePath));
19
+ return !exports.NON_INFO_DIRS.includes(dir);
20
+ }).map(path => {
21
+ const relativePath = path.split(REG_DIR)[1];
22
+ return {
23
+ filepath: relativePath,
24
+ origpath: (0, path_1.relative)(process.cwd(), path)
25
+ };
26
+ });
27
+ }
28
+ // Glob patterns for different JSON files
29
+ const globPatterns = {
30
+ chains: `${exports.registryDir}/**/chain.json`,
31
+ assetLists: `${exports.registryDir}/**/assetlist.json`,
32
+ ibcInfo: `${exports.registryDir}/**/_IBC/*-*.json`,
33
+ schemas: `${exports.registryDir}/*.schema.json`
34
+ };
35
+ // Using the helper function to process files
36
+ exports.chains = filterAndMapFiles((0, glob_1.sync)(globPatterns.chains));
37
+ exports.assetLists = filterAndMapFiles((0, glob_1.sync)(globPatterns.assetLists));
38
+ exports.ibcInfo = filterAndMapFiles((0, glob_1.sync)(globPatterns.ibcInfo));
39
+ exports.schemas = (0, glob_1.sync)(globPatterns.schemas);
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './fixtures';
2
+ export * from './schema-typescript';
package/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./fixtures"), exports);
18
+ __exportStar(require("./schema-typescript"), exports);
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@chain-registry/workflows",
3
+ "version": "1.26.3",
4
+ "description": "Chain Registry Workflows",
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
+ "publishConfig": {
12
+ "access": "public",
13
+ "directory": "dist"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/cosmology-tech/chain-registry"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/cosmology-tech/chain-registry/issues"
21
+ },
22
+ "scripts": {
23
+ "copy": "copyfiles -f LICENSE README.md package.json dist",
24
+ "clean": "del dist/**",
25
+ "prepare": "npm run build",
26
+ "build": "npm run clean; tsc; tsc -p tsconfig.esm.json; npm run copy",
27
+ "test": "jest",
28
+ "test:watch": "jest --watch"
29
+ },
30
+ "devDependencies": {
31
+ "@types/sha.js": "^2.4.0",
32
+ "strfy-js": "^2.2.2"
33
+ },
34
+ "dependencies": {
35
+ "@chain-registry/types": "^0.25.3",
36
+ "bignumber.js": "9.1.1",
37
+ "file-ts": "^0.7.15",
38
+ "minimatch": "^9.0.4",
39
+ "schema-typescript": "^0.2.4",
40
+ "sha.js": "^2.4.11",
41
+ "strfy-js": "^2.2.2"
42
+ },
43
+ "keywords": [
44
+ "chain-registry",
45
+ "web3",
46
+ "cosmos",
47
+ "interchain"
48
+ ]
49
+ }
@@ -0,0 +1,31 @@
1
+ import { SchemaTSOptions } from 'schema-typescript';
2
+ export interface FileSystem {
3
+ readFileSync(path: string, encoding: string): string;
4
+ writeFileSync(path: string, data: string): void;
5
+ mkdirpSync(path: string): void;
6
+ }
7
+ export interface SchemaTypeGeneratorOptions {
8
+ outputDir: string;
9
+ schemaTSOptions: Partial<SchemaTSOptions>;
10
+ readFs: FileSystem;
11
+ writeFs: FileSystem;
12
+ schemas: string[];
13
+ supportedSchemas?: string[];
14
+ }
15
+ export declare class SchemaTypeGenerator {
16
+ private outputDir;
17
+ private writeFs;
18
+ private readFs;
19
+ private schemas;
20
+ private schemaTSOptions;
21
+ private supportedSchemas;
22
+ constructor(options: SchemaTypeGeneratorOptions);
23
+ private updateSchemaTitle;
24
+ private isSchemaSupported;
25
+ generateTypes(): void;
26
+ private readJsonFile;
27
+ private generateTypeScript;
28
+ private getOutputFilename;
29
+ private ensureDirExists;
30
+ private writeFile;
31
+ }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaTypeGenerator = void 0;
4
+ const path_1 = require("path");
5
+ const schema_typescript_1 = require("schema-typescript");
6
+ // Default titles for certain schemas
7
+ // TODO create issue in cosmos/chain-registry
8
+ const DEFAULT_TITLES = {
9
+ 'ibc_data.schema.json': 'IBCData',
10
+ 'chain.schema.json': 'Chain',
11
+ 'assetlist.schema.json': 'AssetList',
12
+ 'versions.schema.json': 'Versions',
13
+ 'memo_keys.schema.json': 'MemoKeys',
14
+ };
15
+ class SchemaTypeGenerator {
16
+ outputDir;
17
+ writeFs;
18
+ readFs;
19
+ schemas;
20
+ schemaTSOptions;
21
+ supportedSchemas;
22
+ constructor(options) {
23
+ this.outputDir = options.outputDir;
24
+ this.writeFs = options.writeFs;
25
+ this.readFs = options.readFs;
26
+ this.schemas = options.schemas;
27
+ this.supportedSchemas = new Set(options.supportedSchemas || []);
28
+ }
29
+ updateSchemaTitle(schema, schemaFile) {
30
+ const filename = (0, path_1.basename)(schemaFile);
31
+ if (DEFAULT_TITLES[filename]) {
32
+ schema.title = DEFAULT_TITLES[filename];
33
+ }
34
+ }
35
+ isSchemaSupported(filePath) {
36
+ if (this.supportedSchemas.size === 0)
37
+ return true; // If no filter is provided, process all files
38
+ const filename = (0, path_1.basename)(filePath);
39
+ return this.supportedSchemas.has(filename);
40
+ }
41
+ generateTypes() {
42
+ this.schemas.forEach(schemaFile => {
43
+ if (this.isSchemaSupported(schemaFile)) {
44
+ try {
45
+ const schema = this.readJsonFile(schemaFile);
46
+ this.updateSchemaTitle(schema, schemaFile);
47
+ const result = this.generateTypeScript(schema);
48
+ const filename = this.getOutputFilename(schemaFile);
49
+ this.ensureDirExists(filename);
50
+ this.writeFile(filename, result);
51
+ }
52
+ catch (e) {
53
+ console.log({ schemaFile });
54
+ }
55
+ }
56
+ });
57
+ }
58
+ readJsonFile(filePath) {
59
+ return JSON.parse(this.readFs.readFileSync(filePath, 'utf-8'));
60
+ }
61
+ generateTypeScript(schema) {
62
+ return (0, schema_typescript_1.generateTypeScript)(schema, this.schemaTSOptions);
63
+ }
64
+ getOutputFilename(schemaFile) {
65
+ const filename = (0, path_1.basename)(schemaFile);
66
+ return (0, path_1.join)(this.outputDir, filename.replace(/.json$/, '.ts'));
67
+ }
68
+ ensureDirExists(filePath) {
69
+ this.writeFs.mkdirpSync((0, path_1.dirname)(filePath));
70
+ }
71
+ writeFile(filePath, content) {
72
+ this.writeFs.writeFileSync(filePath, content);
73
+ }
74
+ }
75
+ exports.SchemaTypeGenerator = SchemaTypeGenerator;