feat: allow configuring custom includes for prune subcommand#10989
feat: allow configuring custom includes for prune subcommand#10989krinoid wants to merge 1 commit intovercel:mainfrom
Conversation
|
@krinoid is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
|
Note: I'm still learning Rust and I'm not familiar with the Turborepo codebase — I'm happy to completely refactor the feature, if needed, provided some guidance/feedback. The first question would be — is that a feature that you're willing to consider for adding to the Turborepo? I tried to explain my use-case and existing discussion indicates that others have similar problem. Let me know what you think. |
|
Hey, @krinoid, thanks for the PR. I'm curious, what is the use case where copy commands (e.g. |
@anthonyshew Fair question — RUN turbo prune <some-app> --docker
RUN cp packages/shared-types/some-script.sh out/json/packages/shared-types/ # needed in every Dockerfile
RUN pnpm installWhile you could argue that this is just copy & paste, it "leaks" some implementation details of RUN cp packages/shared-types/some-script.sh out/json/packages/shared-types/ in Let me know if is is an useful illustration of the problem. I'm happy to provide more details and answer any questions. To be clear, this is not a hypothetical scenario — I'm currently facing it in a monorepo with 50 apps and 100+ shared packages and it definitely increases the maintenance costs. I really like |
|
Hi @anthonyshew, could you help me understand if the current approach/API makes sense? I'd love to have this feature in the turborepo, as it would really simplify the monorepo I'm working in. Thanks. |
|
@tknickman let me know if this feature is something you'd consider in general. I'm happy to rework the code, so that it fits into your vision around config etc. |
|
Yes, this would be really helpful and avoid needing to mess around with post-scripts to copy over files to the pruned output directory. Such as copying over |
|
@anthonyshew @tknickman Hi, do you think it's something that you might consider for turbo? I'm open to adapt the approach/conventions, if needed — but if possible, I'd like to get a decision whether we could go forward with this feature. Otherwise I'll have to look for other solutions for my use-case. |
Description
Extended
turbo prunecommand andturbo.jsonconfig, so it's possible to specify additional fields that need to be copied during the prune operation. For example, it's possible to specify in the top-levelturbo.json:so that
README.mdof all pruned workspaces should be copied and ifshared-libraryis part of the prunned tree,shared-library/example.filewill also be copied.It should also be possible to specify prune includes in the workspace-level
turbo.json:Here the
includessupports workspace-relative paths.Motivation for this change
I have a use-case, where some of my workspaces have
postinstallscript performing some additional, required operations for a successful installation. By definition,postinstallis invoked directly afteryarn/npm/pnpm install. I useturbo prune --docker, so before I can invoke install I need to manually copy relevant files first. While that works at a smaller scale, when thispostinstallscript is part of a shared library used by many apps/other libraries in the monorepo, everyDockerfileneeds to manually copy these required files, which is annoying. Being able to configure that once in theturbo.jsonsimplifies that use-case.Related discussion: #7464
Testing Instructions