Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for wildcards in deno task #26944

Open
bartlomieju opened this issue Nov 19, 2024 · 3 comments
Open

Add support for wildcards in deno task #26944

bartlomieju opened this issue Nov 19, 2024 · 3 comments
Labels
feat new feature (which has been agreed to/accepted) task runner related to deno task
Milestone

Comments

@bartlomieju
Copy link
Member

It would be great if one could do deno task build:* to run all tasks that start with build:.

Eg:

{
    "tasks": {
        "build:frontend": "...",
        "build:server": "...",
        "build:queue": "...",
        "serve": "..."
    }
}

running deno task build:* would match build:frontend, build:server and build:queue and run them all in parallel.

Somewhat related to #26462

@bartlomieju bartlomieju added feat new feature (which has been agreed to/accepted) task runner related to deno task labels Nov 19, 2024
@justinfagnani
Copy link

fwiw, we found that we didn't need this so much in Wireit since you usually have a plain build task that depends on the others:

{
    "tasks": {
        "build": {
          "dependencies": ["build:frontend", "build:server", "build:queue"]
        },
        "build:frontend": "...",
        "build:server": "...",
        "build:queue": "...",
        "serve": "..."
    }
}

One case where we have wanted some wildcard like functionality is in running the same script in a monorepo dependencies instead of having to list each dependency out again in the Wireit config. ie, the "build" script for A runs the "build" script for B, C, and D, automatically if those are local monorepo dependencies with "build" scripts:

So instead of:

packages/a/package.json

{
  "tasks": {
    "build": {
      "dependencies": ["../b:build", "../c:build", "../d:build"]
    }
  }
}

you'd have:
packages/a/package.json

{
  "tasks": {
    "build": {
      "dependencies": [
        {
          "script": "build",
          "packages": "dependencies"
        }
      ]
    }
  }
}

See google/wireit#23

@bartlomieju
Copy link
Member Author

Thanks for comment @justinfagnani. Would something like this work for you?

{
    "tasks": {
        "build": {
            "command": "...",
            "dependencies": ["./packages/*:<task_name>"]
        }
    }
}

That way we don't have to develop two separate features - just need to accept wildcards in "cross-package" dependencies.

@bartlomieju bartlomieju added this to the 2.2.0 milestone Nov 22, 2024
@justinfagnani
Copy link

@bartlomieju

Thanks for comment @justinfagnani. Would something like this work for you?

note that I'm not a potential user here, I'm just relaying my experience with Wireit :)

{
    "tasks": {
        "build": {
            "command": "...",
            "dependencies": ["./packages/*:<task_name>"]
        }
    }
}

That way we don't have to develop two separate features - just need to accept wildcards in "cross-package" dependencies.

This is semantically differently than running scripts in dependencies. Here you're saying to run scripts in every package under packages/*. What the proposed new Wireit dependency type is saying to do is run the script in local dependencies or the current package.

The more complete example config would be:

{
  "tasks": {
    "build": {
      "dependencies": [
        {
          "script": "build",
          "packages": "dependencies"
        }
      ]
    }
  },
  "dependencies": {
    "@foo/b": "^1.0.0",
    "@foo/c": "^1.0.0",
    "@foo/d": "^1.0.0"
  }
}

Where @foo/{a,b,c} are all packages in the local monorepo. This would not run the build script in packages/e, etc.

Running scripts in dependencies has been the main use case for wildcard-like functionality, because without that feature the config has to repeat data already in package dependencies. I would personally suggest starting with that rather than a general wildcard feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat new feature (which has been agreed to/accepted) task runner related to deno task
Projects
None yet
Development

No branches or pull requests

2 participants