TD-332: Protos merging order (#7)

This commit is contained in:
Rinat Arsaev 2022-07-06 16:30:27 +03:00 committed by GitHub
parent 1629bface0
commit f0c895b98d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 9 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@vality/thrift-ts",
"version": "2.3.0",
"version": "2.3.1",
"description": "parse .thrift file to .d.ts",
"main": "./lib/index.js",
"scripts": {

View File

@ -9,16 +9,14 @@ export default class ServiceCompiler extends BaseCompiler {
public name: string,
public service: Service,
public includes: Includes,
options: CompileOptions
options: CompileOptions,
private filePath: string
) {
super(options);
}
getFileName(): string {
const { dir, name } = path.parse(
path.relative(this.options.dirPath, this.basename)
);
return `${path.join(dir, name)}-${path.basename(this.name, ".thrift")}`;
return `${this.filePath}-${path.basename(this.name, ".thrift")}`;
}
flush(): File {

View File

@ -103,7 +103,9 @@ export default () => {
}
let compiledFiles: File[] = [];
for (const fileDirOrPath of argv._) {
// argv._.reverse() affects the protocol merge order
// the first one on the list is more important
for (const fileDirOrPath of argv._.reverse()) {
const files = glob.sync(getFolderPath(fileDirOrPath));
console.log("Source:", fileDirOrPath);
const options: CompileOptions = {

View File

@ -35,7 +35,8 @@ class Compile extends BaseCompiler {
String(k),
services[k],
include,
options
options,
this.getFileName()
);
});
}
@ -98,8 +99,9 @@ class Compile extends BaseCompiler {
this.definition ? "_types.d.ts" : ".ts"
}`;
// TODO: ts-nocheck temporary solution for building projects with importing dependencies from the wrong protocol (may happen when merging protocols)
const content = prettier.format(
"// tslint:disable\n" + this.buffer.join(""),
"// @ts-nocheck\n" + "// tslint:disable\n" + this.buffer.join(""),
{ parser: "typescript" }
);