-
Notifications
You must be signed in to change notification settings - Fork 379
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: introduce CompositeProject #289
Conversation
export class SubProjectComponent extends Component { | ||
constructor(project: Project, private readonly options: SubProjectComponentOptions) { | ||
super(project); | ||
} |
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.
Maybe we could also offer access to the parent root then for .github stuff etc
@hoegertn I was thinking that there's a design decision to be made about how a project can know the parent root so that it knows the right place to put the .github stuff. Given that a sub-project is instantiated before it knows that it's a sub-project, it seems to me that there's a need to inform the sub-project of that. I could call back to the project to inform it here, for instance.
I'm starting to wonder if I like |
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.
Looks promising!
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.
Please add composite-project.ts
to index.ts
src/composite-project.ts
Outdated
* ] | ||
* ``` | ||
*/ | ||
projects?: CompositeProjectChild[]; |
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.
projects?: CompositeProjectChild[]; | |
readonly projects?: CompositeProjectChild[]; |
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.
A couple of minor tweaks and we are ready
Co-authored-by: Elad Ben-Israel <benisrae@amazon.com>
@eladb Cool. The changes you requested are in now. |
@eladb It looks like the build broke in master because after a version bump, NodeProject is looking for the not-yet-released projen version in npm during the tests. I'll see if I can figure out how to work around this. |
… bump (#300) This should fix the build in master when bumping versions after #289. `NodeProject` in the tests wanted to pull the not-yet-released projen packages after the bump. This fix addresses the issue by changing the tests not to depend on any project type that needs to know Projen's version.
Introduce an optional `parent` option to `Project` and `outdir` 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 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. Additional APIs introduced in this change are `project.files` and `project.findFile(path)` which can be used to inspect the project's contents. `findFile()` can find files in projects and subprojects. 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.
Am I allowed to cheer for a PR? 😛 🎉 |
Introduces a
CompositeProject
type that allows multiple projects to be added with a relative directory and synthesized into a single tree.See also #284