-
-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
497 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ coverage/ | |
.DS_Store | ||
npm-debug.log | ||
dist/ | ||
tsconfig.schema.json | ||
tsconfig.schemastore-schema.json |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env ts-node | ||
/* | ||
* Create a complete JSON schema for tsconfig.json | ||
* by merging the schemastore schema with our ts-node additions. | ||
* This merged schema can be submitted in a pull request to | ||
* SchemaStore. | ||
*/ | ||
|
||
import axios from 'axios'; | ||
import * as Path from 'path'; | ||
import * as fs from 'fs'; | ||
|
||
async function main() { | ||
/** schemastore definition */ | ||
const schemastoreSchema = (await axios.get( | ||
'https://schemastore.azurewebsites.net/schemas/json/tsconfig.json', | ||
{ responseType: "json" } | ||
)).data; | ||
|
||
/** ts-node schema auto-generated from ts-node source code */ | ||
const typescriptNodeSchema = require('../tsconfig.schema.json'); | ||
|
||
/** Patch ts-node stuff into the schemastore definition. */ | ||
const mergedSchema = { | ||
...schemastoreSchema, | ||
definitions: { | ||
...schemastoreSchema.definitions, | ||
tsNodeDefinition: { | ||
properties: { | ||
'ts-node': { | ||
...typescriptNodeSchema.definitions.TsConfigOptions, | ||
description: typescriptNodeSchema.definitions.TsConfigSchema.properties['ts-node'].description, | ||
properties: { | ||
...typescriptNodeSchema.definitions.TsConfigOptions.properties, | ||
compilerOptions: { | ||
...typescriptNodeSchema.definitions.TsConfigOptions.properties.compilerOptions, | ||
allOf: [{ | ||
$ref: '#/definitions/compilerOptionsDefinition/properties/compilerOptions' | ||
}] | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
}, | ||
allOf: [ | ||
...schemastoreSchema.allOf.slice(0, 4), | ||
{ "$ref": "#/definitions/tsNodeDefinition" }, | ||
...schemastoreSchema.allOf.slice(4), | ||
] | ||
}; | ||
fs.writeFileSync( | ||
Path.resolve(__dirname, '../tsconfig.schemastore-schema.json'), | ||
JSON.stringify(mergedSchema, null, 2) | ||
); | ||
} | ||
|
||
main(); |
Oops, something went wrong.