Comments (16)
In the case of child projects, I think it would generally be preferable to only trigger the release workflow for a child project if there are changes to the child project directory using the push.paths option.
#3252 handled this in a different way, basically the release workflow always runs, but stops short if no changes are present. I think if your idea works, it would be even better.
from projen.
Trigger Path Configuration
This seems like a good additional thing we should do! In more traditional monorepo setup, I tend to not use this because I find that only looking at the workspace directory often isn't enough to identify changes to a workspace. However here with the quite strictly separated projects, it seems like a good fit. Definitely as a configurable option, probably even as a default. (If some one is going to look at this, please do two PRs: One for supporting it optionally and one to change the default).
from projen.
Install Directory Issues
These are great findings, thank you!
#3208 forced the
Install dependencies
step to be executed in the parent project directory and didn't provide a configuration to override that behavior. @dkershner6 I'm curious about the reason for that decision and if you have any additional context about the manner you envision that working in application? When a child node project is created in a sub-directory withprojen
, it initializes the sub-directory with its ownpackage.json
and dependencies. So before the child project can be compiled, the install command needs to be run in the child project directory - not the parent directory. Or am I missing something about how this is supposed to be setup?
TBH we might need both. I thought the root install is required so we can run projen properly.
Furthermore, by default
projen
automatically adds itself as a dependency to the child project (in addition to the parent project) - leading to two different copies of theprojen
package being present.
Is there a strong reason whyprojen
defaults to installing itself in child project directories? In the event thatrelease: true
is set on a child project, can we change the default behavior or at least call out that gotcha in the docs somehow?
Yeah that's likely not needed and can be fixed.
This can lead to some weird behavior such as
instanceof
checks returningfalse
whentrue
is expected. e.g. #3208 added this line:
100% There's a work around to use symbols instead, which we probably need to implement on all components.
from projen.
Fwiw, I think the way I originally setup my repo with multiple projects was not quite right; I was not using workspaces, so the sub-project dependencies were not installed unless
yarn install
was run inside the sub-project directory. However, usingworkspaces
, runningyarn install
inside the root directory now installs dependencies for both the root project and all sub-projects (workspaces). So installing at the root only, may still make the most sense.
This was my thought process, that near everyone would be using monorepos or workspaces (yarn, npm, pnpm all work this way), so it made sense to be opinionated.
from projen.
Closing since I think I've effectively addressed the discussed issues in my two linked PRs
from projen.
@dkershner6 I'm curious about the reason for that decision and if you have any additional context about the manner you envision that working in application?
I don't think I actually changed anything about how root projects interact with subprojects, I just made it so that they can be released.
I re-thought about this, and you likely meant in the release workflow. The reason for that is because installing dependencies from the root is usually required in monorepos. You can even see discussion about deleting install entirely from subprojects in other discussions. Putting in an option wouldn't be hard, but release is already very option heavy.
So before the child project can be compiled, the install command needs to be run in the child project directory - not the parent directory. Or am I missing something about how this is supposed to be setup?
Just to add, I haven't experienced this, but perhaps it is a package manager or monorepo thing. I use pnpm with NX.
from projen.
I re-thought about this, and you likely meant in the release workflow. The reason for that is because installing dependencies from the root is usually required in monorepos. You can even see discussion about deleting install entirely from subprojects in other discussions. Putting in an option wouldn't be hard, but release is already very option heavy.
Perhaps you are referring to #450. I see what you mean. I'll be interested to see the direction that projen goes for the monorepo use case.
In the meantime, thoughts on making the determineInstallWorkingDirectory
protected
instead of private
so its logic can be overridden?
from projen.
This can lead to some weird behavior such as
instanceof
checks returningfalse
whentrue
is expected. e.g. #3208 added this line:100% There's a work around to use symbols instead, which we probably need to implement on all components.
That's probably a good idea as it was very frustrating to debug until I realized why it was happening.
from projen.
I re-thought about this, and you likely meant in the release workflow. The reason for that is because installing dependencies from the root is usually required in monorepos. You can even see discussion about deleting install entirely from subprojects in other discussions. Putting in an option wouldn't be hard, but release is already very option heavy.
Perhaps you are referring to #450. I see what you mean. I'll be interested to see the direction that projen goes for the monorepo use case. In the meantime, thoughts on making the
determineInstallWorkingDirectory
protected
instead ofprivate
so its logic can be overridden?
Works for me.
from projen.
In the meantime, thoughts on making the
determineInstallWorkingDirectory
protected
instead ofprivate
so its logic can be overridden?
This is not a temporary compromise. If it can be overriden by inheritance, it's effectively also part of the public API. I'd rather iterate on the proper public API.
If your main goal is to just make this work for now, you can always access the private property and use @ts-ignore
.
Plus you can use the low level object file APIs to manipulate the workflow file directly.
from projen.
Maybe installing at the root was conceptually the wrong approach.
We have two problems to solve here:
- Bootstrapping so projen can run
- Install everything that is needed to release the subproject
I'm not super sure about the former. However for the latter, the responsibility probably should be with the subproject, which totally can decide to just delegate the installation to the root project.
from projen.
However for the latter, the responsibility probably should be with the subproject, which totally can decide to just delegate the installation to the root project.
For my curiosity, what would the best path to go about this? I am assuming there is a better way than exec("cd ../../../"...
from projen.
Fwiw, I think the way I originally setup my repo with multiple projects was not quite right; I was not using workspaces, so the sub-project dependencies were not installed unless yarn install
was run inside the sub-project directory. However, using workspaces
, running yarn install
inside the root directory now installs dependencies for both the root project and all sub-projects (workspaces).
So installing at the root only, may still make the most sense.
from projen.
However for the latter, the responsibility probably should be with the subproject, which totally can decide to just delegate the installation to the root project.
For my curiosity, what would the best path to go about this? I am assuming there is a better way than
exec("cd ../../../"...
I'd use the cwd
option for that. But essentially, yes that's it.
I think personally would as this anyway, since with yarn workspaces you normally don't want yarn install to be run in the workspace directory.
from projen.
This was my thought process, that near everyone would be using monorepos or workspaces (yarn, npm, pnpm all work this way), so it made sense to be opinionated.
And that's probably still okay. But given that this doesn't happen automatically at the moment, we'll need to look at making this more flexible.
from projen.
I'd use the cwd option for that. But essentially, yes that's it.
I had to use Typescript projects in monorepos that didn't have a build tool, in that case we just used
const gitRoot = execSync("git rev-parse --show-toplevel").toString().trimEnd()
and wherever needed:
foo.writeTo(path.join(gitRoot,".github","workflows", ...)
altho this fails when the directory hasn't initialised git
yet.
from projen.
Related Issues (20)
- Publishing v0.80.17 to Maven Central failed HOT 1
- Should `args` be returned by the task --inspect CLI command? HOT 1
- Error when using `NodePackageManager.BUN` with `NodejsFunction` HOT 5
- Update actions due to node v16 deprecation notice: codecov/codecov-action HOT 1
- gitlab build workflow HOT 1
- Rerunning projen cannot proceed due to existing license. HOT 10
- integ tests on private cdk lib fail since two days - ideas how to debug welcome HOT 6
- NpmConfig uses package 'ini' which adds CRLF on Windows HOT 1
- packaging fails when cdk.out dir is significant in size HOT 9
- Export util modules HOT 9
- Unable to ignore lines for coverage in projen project HOT 1
- `npx projen new jsii --package-manager npm` fails due to peer dependency issue HOT 2
- Publish to CodeArtifact fails for Nuget packages HOT 2
- github issue template
- Publishing v0.81.11 to PyPI failed HOT 1
- Generated source code for LambdaFunction where `edgeLambda: true` is incorrect HOT 3
- Release tags wrong commit HOT 1
- !reference tag in gitlab job scripts will be rendered in quotes
- typeRoots is missing in TypescriptConfigOptions
- moduleDetection is missing in TypescriptConfigOptions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from projen.