Reputation: 21
Has anyone experienced how to add an existing NodeJS API to an existing (Angular) Nx Monrepo?
Unfortunately the manual doesn´t help me so much https://nx.dev/migration/manual
Upvotes: 2
Views: 1952
Reputation: 29660
Here is a solution that I wrote and used to import multiple repos into a single monorepo, under whatever subdirectories are wanted, while maintaining commit history:
I've also found two other scripts that look like they might work, but I haven't tried them:
Upvotes: 2
Reputation: 6250
The process of migrating a repo into your mono repo requires a few manual steps. I think there would not be a simpler way to do it.
Assuming your node project does not share files with your current monorepo, this should be the steps:
package.json
file (we will later merge it with the monorepo's one)git remote add node-repo <your git repo's node url>
pull
to make the node repo branches be available in the monorepogit pull
create a new branch 'merging-node-repo' on your monorepo.
merge the branch node-repo/to-monorepo
into your merging-node-repo
branch, preserving the history:
git merge node-repo/to-monorepo --allow-unrelated-histories
push your new branch (all the code and its history will now be listed in this new branch)
remove the remote node-repo
from your local monorepo configs
git remote rm node-repo
manually merge all the node repo's original package.json
file dependencies into the monorepo's one, and run npm install
from the monorepo. This way your package-lock.json
file is updated. Once you are done, create a commit and push it.
this last step is more tricky. You have now to manually update the monorepo's config files to allow nx to start managing it. This is where the link you had in your question might help. Once you are done, create a commit and push it.
With these steps you can then merge your merging-node-repo
branch into master.
I recommend you to create a separated nx workspace with a nodejs project on it. This helps you with having a baseline for all the necessary nx configurations and dependencies. You might want to make sure your project works via nx commands from this separated workspace; this way you will have a better chance of getting configurations of your monorepo right.
Hopefully this gets you started.
Upvotes: 2