pgtyped
pgtyped copied to clipboard
Allow for multiple "srcDirs"
We have a monorepo and want to run PGTyped across different projects generating code for all of them.
We had thought to do this by simply setting the srcDir
to .
and then specifying multiple transforms each with a path to the subproject root dir. However since the pattern is constructed like this ${srcDir}/**/${pattern}
this doesn't allow multiple **'s.
For instance, say that we want to match like this
{
"transforms": [
{
"mode": "ts",
"include": "services/project-a/src/**/*.ts",
"emitTemplate": "{{dir}}/{{name}}.queries.ts"
},
{
"mode": "ts",
"include": "libs/npm/project-b/src/**/*.ts",
"emitTemplate": "{{dir}}/{{name}}.queries.ts"
}
],
"srcDir": ".",
"failOnError": true,
"db": {
}
}
Now instead the pattern will just glob every file in our root (including node_modules). I think there are several options to change this but trying to see what would be best from a non-breaking current behavior perspective.
My thought was to maybe check for **'s in the transform include pattern and switch behavior accordingly?
Hi @RXminuS, did you ever find solution for this? I have the same exact issue with a monorepo. I assumed that setting srcDir
to packages
and then just matching the includes to **/foo/*.sql
would work, but pgtyped
starts processing all the files, starting from .bin
files inside every node_modules folder.