File tree Expand file tree Collapse file tree 3 files changed +1171
-4
lines changed Expand file tree Collapse file tree 3 files changed +1171
-4
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' ) ;
54const fs = require ( 'fs' ) ;
65const path = require ( 'path' ) ;
76const { promisify } = require ( 'util' ) ;
87const writeFile = promisify ( fs . writeFile ) ;
98const { ensureDir } = require ( 'fs-extra' ) ;
109const { 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+
1523const generateTypes = async ( s ) => {
16- const ts = await compile ( s , "OpenRPC" ) ;
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" ) ;
1732 const dir = path . resolve ( __dirname , "../build/src/" ) ;
1833 await ensureDir ( dir ) ;
1934 await writeFile ( `${ dir } /index.d.ts` , ts , "utf8" ) ;
You can’t perform that action at this time.
0 commit comments