Skip to content

Commit

Permalink
Merge pull request #133 from open-rpc/fix/build
Browse files Browse the repository at this point in the history
fix: build should contain generated schema
  • Loading branch information
BelfordZ authored Jun 11, 2019
2 parents f4ff336 + 84a392b commit ec8042b
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ const {listReleases} = require("@etclabscore/dl-github-releases");
// errors if you try to run with $ref to draft 7 json schema
schema.definitions.schema.$ref = undefined;

const generateTypes = async () => {
const ts = await compile(schema, 'OpenRPC');
const dir = path.resolve(__dirname, '../build/src/');
const generateTypes = async (s) => {
const ts = await compile(s, "OpenRPC");
const dir = path.resolve(__dirname, "../build/src/");
await ensureDir(dir);
await writeFile(`${dir}/index.d.ts`, ts, 'utf8');
await writeFile(`${dir}/index.d.ts`, ts, "utf8");

console.log('Generating types complete!');
console.log("Generating types complete!");
};

const setOpenRPCVersionEnum = async (s) => {
Expand All @@ -28,7 +28,15 @@ const setOpenRPCVersionEnum = async (s) => {

const build = async () => {
const withVersionEnum = await setOpenRPCVersionEnum(schema);

await generateTypes(withVersionEnum);

const dir = path.resolve(__dirname, "../build/");
await ensureDir(dir);

await writeFile(`${dir}/schema.json`, JSON.stringify(withVersionEnum, undefined, " "));

console.log("Finished building");
};

module.exports = {setOpenRPCVersionEnum};
Expand Down

0 comments on commit ec8042b

Please sign in to comment.