lukeautry / tsoa

Build OpenAPI-compliant REST APIs using TypeScript and Node
MIT License
3.45k stars 495 forks source link

Feature Request: Add support for glob negation as part of config.ignore #978

Open rosslavery opened 3 years ago

rosslavery commented 3 years ago

Sorting

Expected Behavior

Imagine models located as part of an external npm package. They are not all consumed by a codebase that needs or has knowledge of tsoa. For this reason it is not ideal to decorate each with @tsoamodel.

If a developer was able to specify multiple globs, including negations that are properly resolved, then we can support a configuration such as:

"ignore": [
    "**/node_modules/**",
    "!**/node_modules/some-models-package/**"
  ]

Where we ignore all node_modules except a whitelisted package.

Current Behavior

With the current ignore definition in the config, the globs are resolved by minimatch which are resolved in such a way that we return early if any match is detected. See here for relevant lines.

Possible Solution

By moving to a glob-matching package that supports multi-globs being resolved as an array rather than one-by-one (there are many options here), we can improve support for configuration ignore globs.

Breaking change?

Difficult to say. The behaviour of the ignore configuration would change. I would argue in a non-breaking way, but this may be up for debate :)

I am happy to create a PR that adds support for the above via a library such as multimatch.

WoH commented 3 years ago

Can we construct a case where this would actually be breaking?

I think this should be a good addition regardless, but we should push a major to err on the side of caution if there is such a case.