Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revert bad changes #147

Merged
merged 2 commits into from Jul 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 2 additions & 17 deletions bin/build.js
@@ -1,34 +1,19 @@
#!/usr/bin/env node

const schema = require('../schema.json');
const { compile } = require('json-schema-to-typescript');
const fs = require('fs');
const path = require('path');
const { promisify } = require('util');
const writeFile = promisify(fs.writeFile);
const { ensureDir } = require('fs-extra');
const {listReleases} = require("@etclabscore/dl-github-releases");
const { quicktype } = require("quicktype");

// errors if you try to run with $ref to draft 7 json schema
schema.definitions.schema.$ref = undefined;

const getQuickTypeSources = (s) => {
return [{
kind: "schema",
name: "OpenRPC",
schema: JSON.stringify(s),
}];
};

const generateTypes = async (s) => {
const sources = getQuickTypeSources(s);
const result = await quicktype({
lang: "typescript",
leadingComments: undefined,
rendererOptions: { "just-types": true },
sources,
});
const ts = result.lines.join("\n");
const ts = await compile(s, "OpenRPC");
const dir = path.resolve(__dirname, "../build/src/");
await ensureDir(dir);
await writeFile(`${dir}/index.d.ts`, ts, "utf8");
Expand Down