File tree Expand file tree Collapse file tree 4 files changed +346
-1158
lines changed Expand file tree Collapse file tree 4 files changed +346
-1158
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env node
22
33const schema = require ( '../schema.json' ) ;
4+ const { compile } = require ( 'json-schema-to-typescript' ) ;
45const fs = require ( 'fs' ) ;
56const path = require ( 'path' ) ;
67const { promisify } = require ( 'util' ) ;
78const writeFile = promisify ( fs . writeFile ) ;
89const { ensureDir } = require ( 'fs-extra' ) ;
910const { listReleases} = require ( "@etclabscore/dl-github-releases" ) ;
10- const { quicktype } = require ( "quicktype" ) ;
1111
1212// errors if you try to run with $ref to draft 7 json schema
1313schema . definitions . schema . $ref = undefined ;
1414
15- const getQuickTypeSources = ( s ) => {
16- return [ {
17- kind : "schema" ,
18- name : "OpenRPC" ,
19- schema : JSON . stringify ( s ) ,
20- } ] ;
21- } ;
22-
2315const generateTypes = async ( s ) => {
24- const sources = getQuickTypeSources ( s ) ;
25- const result = await quicktype ( {
26- lang : "typescript" ,
27- leadingComments : undefined ,
28- rendererOptions : { "just-types" : true } ,
29- sources,
30- } ) ;
31- const ts = result . lines . join ( "\n" ) ;
16+ const ts = await compile ( s , "OpenRPC" ) ;
3217 const dir = path . resolve ( __dirname , "../build/src/" ) ;
3318 await ensureDir ( dir ) ;
3419 await writeFile ( `${ dir } /index.d.ts` , ts , "utf8" ) ;
You can’t perform that action at this time.
0 commit comments