nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.69k stars 2.37k forks source link

Allow globs pattern in target outputs #8593

Closed gsingh-ut closed 2 years ago

gsingh-ut commented 2 years ago

Description

Would like to be able to define glob like pattern in a projects target outputs

Motivation

Sometimes a project could depend on files that are defined at different locations

For example - Scenario where gql codegen is used to generate files next to the graphql file which are defined in different locations

Folder structure like: src/dir1/file1.graphl , src/dir2/file2.graphl and running gql:codegen result in generating src/dir1/file1.generated.ts and src/dir2/file2.generated.ts

Would like to be able to describe something like

"projects": {
        "project-name": {
            "root": "packages/project-name",
            "targets": {
                "build": {
                    "executor": "@nrwl/workspace:run-script",
                    "outputs": [
                        "packages/project-name/dist"
                    ],
                   "dependsOn: [
                   {
                     "target": "gql:codegen",
                     "projects": "self"
                    ],
                    "options": {
                        "script": "build"
                    }
                },
                "gql:codegen": {
                    "executor": "@nrwl/workspace:run-script",
                    "outputs": [
                        "src/**/*.generated.ts"
                    ],
                    "options": {
                        "script": "gql:codegen"
                    }
                }
            }
        },

Suggested Implementation

It could be another option something like allowGlobsInOutput: "true" inside project options or checking for output globs in the code that will allow to run the normal execution which checks for only specific files and folder if it's not passed (For ref: https://github.com/nrwl/nx/pull/3613/files) or when it's passed it will check for glob files as well. That way it will not affect a normal user but will also allow other users to use glob pattern if needed.

Alternate Implementation

Alternate to above situation is to pass file names manually which is ok if there are only few files but if there are too many files some files can easily be missed.

andersonba commented 2 years ago

Hey guys! Any updates here?

valerybugakov commented 2 years ago

Bumped into this issue too and would be happy to help fix it!

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.