Javascript SDK of WoopChain protocol
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sdk/scripts/typings/schema.ts

50 lines
1.3 KiB

import * as fs from 'fs';
import * as path from 'path';
// tslint:disable-next-line: no-implicit-dependencies
import * as schemas from 'typescript-json-schema';
import { packages } from '../packagesTs';
import tsConfig from '../../tsconfig.base.json';
const outputs = process.argv.slice(2)[0].split(',');
const rootPath = path.resolve(__dirname, '../..');
const includesPath = path.join(rootPath, 'includes');
const packagesPath = path.join(rootPath, 'packages');
async function generateSchemas() {
packages
// @ts-ignore
.filter((pkg) => {
return (
8 months ago
pkg !== 'woop-' &&
outputs.indexOf(pkg.replace('woop-', '')) !== -1
);
})
.forEach((pkg) => {
const pkgPath = path.join(packagesPath, pkg);
const pkgSrc = path.join(pkgPath, 'src');
const settings = {
ref: false,
};
// tslint:disable-next-line: no-shadowed-variable
const tsConfig: schemas.CompilerOptions = {
lib: ['es2015'],
};
const prog = schemas.getProgramFromFiles(
[path.resolve(path.join(pkgSrc, 'types.ts'))],
tsConfig,
);
const schema = schemas.generateSchema(prog, '*', settings);
// fs.writeFileSync(
// path.join(pkgPath, 'test', 'schema.json'),
// JSON.stringify(schema, undefined, 2),
// );
});
}
generateSchemas();