-
Notifications
You must be signed in to change notification settings - Fork 380
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
feat: subprojects #332
feat: subprojects #332
Conversation
Introduce an optional `parent` option to `Project` and `outdir` to allow implementing project trees. The `CompositeProject` approach has a limitation in which projects could not query who is their parent (because potentially a child can be added at any time). Also, it technically allowed the same child project to be added to multiple parents. This change also moves `outdir` from the various `synth()` methods to `ProjectOptions`. This early-binding approach is also more in-line with how CDK code is written, whereas during initialization it is possible to reason about the full synthesis context. BREAKING CHANGE: The `CompositeProject` and `ProjectComponent` classes have been superseded by subprojects in order to allow safely accessing the parent project during subproject initialization phase. Use `new Project({ parent, outdir })` to define this relationship. * The various `synth()` methods no longer accept an `outdir`. Instead, specify `outdir` in the project options.
@misterjoshua would love to hear what you think about this. I've decided that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eladb I love the structural approach you've taken here.
As-is, the code satisfies my original use case. I have left a few comments in the review - nothing too serious. :)
While reviewing, I was thinking that this approach opens up a future where a component in the root project could visit (like CDK aspects) all composed projects. Such a component might collect things like CI-agnostic build and test commands. At synth time, such a component could pop them in a github workflow, bitbucket pipeline, circle config, or whatever.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Echoing @misterjoshua 's comments, this looks good! 👍
Also if you could confirm that the projen CLI doesn't error when you run it in the root directory of a folder with nested projects (to avoid bringing back a bug like #323) that would be great. I believe the current behavior for node projects is that running yarn projen
in a given directory will print out all of the commands for that project, as well as commands for any of its subprojects.
Also ensure that files do not override each other globally.
Verified @Chriscbr |
Introduce an optional
parent
option toProject
andoutdir
to allow implementing project trees.The
CompositeProject
approach which was introduced in #289 has a limitation in which projects could not query who is their parent (because potentially a child can be added at any time). Also, it technically allowed the same child project to be added to multiple parents. Therefore, these classes are no longer available.This change also moves
outdir
from the varioussynth()
methods toProjectOptions
.This early-binding approach is also more in-line with how CDK code is written, whereas during initialization it is possible to reason about the full synthesis context.
Additional APIs introduced in this change are
project.files
andproject.findFile(path)
which can be used to inspect the project's contents.findFile()
can find files in projects and subprojects.BREAKING CHANGE: The
CompositeProject
andProjectComponent
classes have been superseded by subprojects in order to allow safely accessing the parent project during subproject initialization phase. Usenew Project({ parent, outdir })
to define this relationship.synth()
methods no longer accept anoutdir
. Instead, specifyoutdir
in the project options.