@@ -15,25 +15,49 @@ async function main() {
1515 const schemastoreSchema = await getSchemastoreSchema ( ) ;
1616
1717 /** ts-node schema auto-generated from ts-node source code */
18- const typescriptNodeSchema = require ( '../tsconfig.schema.json' ) ;
18+ const originalTsNodeSchema = require ( '../tsconfig.schema.json' ) ;
19+ // Apply this prefix to the names of all ts-node-generated definitions
20+ const tsnodeDefinitionPrefix = 'tsNode' ;
21+ let tsNodeSchema : any = JSON . parse (
22+ JSON . stringify ( originalTsNodeSchema ) . replace (
23+ / # \/ d e f i n i t i o n s \/ / g,
24+ `#/definitions/${ tsnodeDefinitionPrefix } `
25+ )
26+ ) ;
27+ tsNodeSchema . definitions = Object . fromEntries (
28+ Object . entries ( tsNodeSchema . definitions ) . map ( ( [ key , value ] ) => [
29+ `${ tsnodeDefinitionPrefix } ${ key } ` ,
30+ value ,
31+ ] )
32+ ) ;
33+ // console.dir(tsNodeSchema, {
34+ // depth: Infinity
35+ // });
1936
2037 /** Patch ts-node stuff into the schemastore definition. */
2138 const mergedSchema = {
2239 ...schemastoreSchema ,
2340 definitions : {
24- ...schemastoreSchema . definitions ,
41+ ...Object . fromEntries (
42+ Object . entries ( schemastoreSchema . definitions ) . filter (
43+ ( [ key ] ) => ! key . startsWith ( tsnodeDefinitionPrefix )
44+ )
45+ ) ,
46+ ...tsNodeSchema . definitions ,
47+ tsNodeTsConfigOptions : undefined ,
48+ tsNodeTsConfigSchema : undefined ,
2549 tsNodeDefinition : {
2650 properties : {
2751 'ts-node' : {
28- ...typescriptNodeSchema . definitions . TsConfigOptions ,
52+ ...tsNodeSchema . definitions . tsNodeTsConfigOptions ,
2953 description :
30- typescriptNodeSchema . definitions . TsConfigSchema . properties [
54+ tsNodeSchema . definitions . tsNodeTsConfigSchema . properties [
3155 'ts-node'
3256 ] . description ,
3357 properties : {
34- ...typescriptNodeSchema . definitions . TsConfigOptions . properties ,
58+ ...tsNodeSchema . definitions . tsNodeTsConfigOptions . properties ,
3559 compilerOptions : {
36- ...typescriptNodeSchema . definitions . TsConfigOptions . properties
60+ ...tsNodeSchema . definitions . tsNodeTsConfigOptions . properties
3761 . compilerOptions ,
3862 allOf : [
3963 {
@@ -46,14 +70,16 @@ async function main() {
4670 } ,
4771 } ,
4872 } ,
49- allOf : [
50- // Splice into the allOf array at a spot that looks good. Does not affect
51- // behavior of the schema, but looks nicer if we want to submit as a PR to schemastore.
52- ...schemastoreSchema . allOf . slice ( 0 , 4 ) ,
53- { $ref : '#/definitions/tsNodeDefinition' } ,
54- ...schemastoreSchema . allOf . slice ( 4 ) ,
55- ] ,
5673 } ;
74+ // Splice into the allOf array at a spot that looks good. Does not affect
75+ // behavior of the schema, but looks nicer if we want to submit as a PR to schemastore.
76+ mergedSchema . allOf = mergedSchema . allOf . filter (
77+ ( item : any ) => ! item . $ref ?. includes ( 'tsNode' )
78+ ) ;
79+ mergedSchema . allOf . splice ( mergedSchema . allOf . length - 1 , 0 , {
80+ $ref : '#/definitions/tsNodeDefinition' ,
81+ } ) ;
82+
5783 writeFileSync (
5884 resolve ( __dirname , '../tsconfig.schemastore-schema.json' ) ,
5985 JSON . stringify ( mergedSchema , null , 2 )
0 commit comments