IMP-23: Create TS defs (#10)

This commit is contained in:
Rinat Arsaev 2022-03-05 18:55:18 +03:00 committed by GitHub
parent 8044689f3b
commit e63646409d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 10 deletions

View File

@ -3,6 +3,6 @@
<component name="PrettierConfiguration">
<option name="myRunOnSave" value="true" />
<option name="myRunOnReformat" value="true" />
<option name="myFilesPattern" value="{**/*,*}.{js,ts,jsx,tsx,yml,yaml,md}" />
<option name="myFilesPattern" value="{**/*,*}.{js,ts,jsx,tsx,yml,yaml,md,json}" />
</component>
</project>

View File

@ -16,7 +16,7 @@ async function execWithLog(cmd, cwd = process.cwd()) {
console.log(stdout);
res(stdout);
} else {
// console.error(error);
console.error(error);
console.error(stderr);
rej(error);
}
@ -53,10 +53,7 @@ async function genModel(paths, outputPath) {
async function genMetadata(paths, outputPath) {
await execWithLog(
`thrift-ts ${paths.join(' ')} -o ${path.join(
outputPath,
'metadata.json'
)} --json --pack --prettify`
`thrift-ts ${paths.join(' ')} -o ${path.join(outputPath, 'metadata.json')} --json`
);
}
@ -108,6 +105,12 @@ async function codegenAll() {
genModel([PROTO_PATH, ...depsPaths], DIST_PATH),
genMetadata([PROTO_PATH, ...depsPaths], DIST_PATH),
]);
await execWithLog(
`tsc ${path.join(
DIST_PATH,
'*.ts'
)} --skipLibCheck --target es2015 --lib es2021 --moduleResolution node --declaration`
);
}
module.exports = codegenAll;

18
package-lock.json generated
View File

@ -10,6 +10,7 @@
"license": "Apache-2.0",
"dependencies": {
"@vality/thrift-ts": "^2.2.2-e258b9a.0",
"typescript": "^4.6.2",
"yargs": "^17.3.1"
},
"bin": {
@ -795,6 +796,18 @@
"resolved": "https://registry.npmjs.org/thrift-parser/-/thrift-parser-0.4.2.tgz",
"integrity": "sha1-lHKac3nOA+AL6+Odocvze70zhjs="
},
"node_modules/typescript": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.2.tgz",
"integrity": "sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=4.2.0"
}
},
"node_modules/which": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
@ -1431,6 +1444,11 @@
"resolved": "https://registry.npmjs.org/thrift-parser/-/thrift-parser-0.4.2.tgz",
"integrity": "sha1-lHKac3nOA+AL6+Odocvze70zhjs="
},
"typescript": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.2.tgz",
"integrity": "sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg=="
},
"which": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",

View File

@ -17,6 +17,7 @@
},
"dependencies": {
"@vality/thrift-ts": "^2.2.2-e258b9a.0",
"typescript": "^4.6.2",
"yargs": "^17.3.1"
},
"devDependencies": {

View File

@ -1,6 +1,4 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>valitydev/.github:renovate-config"
]
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["local>valitydev/.github:renovate-config"]
}