Open tunnckoCore opened 6 years ago
Hey @olstenlarck, Thanks for raising the issue.
I don't think we should ever update dependencies in package.json automatically as it might create confusion ( user may confuse why did package json update on install ? ).
I agree documentation is missing. We are working on the new website with all the documentation - https://github.com/boltpkg/website/tree/docusaurus
It won't be confusion. What confusion?
user may confuse why did package json update on install ?
It will not touch the packages' package.json, it will just copy each dependency from each pacakge into the roots' package.json. And even more, it isn't needed to call the install command - just copy paste.
Say we have mono repo with packages/foo
, packages/bar
and packages/qux
. Qux will have 3 dependencies - Foo, Bar and lets say execa
. Bar will have chalk
and pify
. Foo will have eslint
and prettier
.
So what Bolt can do first is to collect all deps - execa
, chalk
, prettier
, Foo and Bar, exclude those that are from the monorepo and just put the rest into the root package.json. And after that start the install
.
It's acceptable to have updates on the root package.json, because it will be updated anyway when you call manually bolt w [name] add
for each dependency.
I think it would be better to copy them into a temporary file other than the package json.
Otherwise, pushing to git after install would result in changes being saved to the root package.json that aren't desirable.
For example, I keep only globally used dev dependencies (i.e. jest, typescript, typedoc, lint-staged, eslint, prettier) in the root package.jsn, and have multiple workspaces/worktrees in the monorepo that DO NOT share dependencies.
I figured out that Bolt needs to install each dependency for each project seprately, using bolt like
bolt w @hela/cli add <deps for that package> bolt w @hela/core add <deps for that package> bolt w @hela/dargs add <deps for that package> bolt w @hela/config-tunnckocore add <deps for that package>
I just came across this bootstrapping manual work and jq
was handy, e.g.,
jq -r '.dependencies | to_entries[] | "\(.key)@\(.value)"' packages/cli/package.json | xargs bolt w @hella/cli add
jq -r '.devDependencies | to_entries[] | "\(.key)@\(.value)"' packages/cli/package.json | xargs bolt w @hella/cli add --dev
bolt install
problemDetailed description
I have fresh monorepo with 4 packages in it. Link to it https://github.com/olstenlarck/hela/tree/v3-major.
Basic assumption is to just run
bolt install
in the project root and everything to be installed and linked. But it errors with that it can't link external dependencies of the each project.I figured out that Bolt needs to install each dependency for each project seprately, using
bolt
likeSo it adds all of them to the root
dependencies
and once they are there, then cleaning all of the packages' node_modules (e.g.rm -rf packages/cli/node_modules
) and runningbolt install
on the root - everything works without errors.I can understand why this is needed. But first, there is no docs for this. And second, it would be better before doing anything and the install, to scan each package deps in the defined workpaces, add then add them to the project root and after that start the install process.
This will simplify the manual process that i've done.
So
bolt install
should act like that:Oh, okey, workspaces is
packages/*
, i'm going to scan each package deps - there ispackages/core
with two deps in itspackage.json
- I'm going to add them asdependencies
to the project root (e.g.bolw w @hela/core <found deps>
). Okey, there ispackages/cli
with 3 dependencies, one of which is thepackages/core
- i'm going to add them to the project root, except the package frompackages/core
. Okey, i'm done, i'll runbolt install
now.