Last active
August 5, 2022 11:46
-
-
Save nhhockeyplayer/4a96e273aaee70f95792637bb5dc2802 to your computer and use it in GitHub Desktop.
sh-deploy-all-nrwl-nx-libs-from-root-dist-folder.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ROOT_DIR=$(pwd) | |
cd "$ROOT_DIR/dist/libs" | |
recurseAndDeploy() { | |
if [[ -f package.json ]]; # target case, unwind | |
then | |
npm publish --registry https://registry.npmjs.org --no-git-tag-version --no-push --yes | |
return; | |
else | |
for LIBRARY in */; do | |
cd $LIBRARY; | |
echo PUBLISHING "$LIBRARY" | |
recurseAndDeploy; # recursion | |
cd .. | |
done | |
fi | |
} | |
for DIR in */; do | |
recurseAndDeploy; # recursion | |
done | |
cd .. | |
cd .. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
say you have 50 libs you want to deploy in one sweep
If you have a @nrwl/nx monorepo, this gist will function from your root dir and navigate into your dist folder and traverse all child directories in your libs folder publishing every library it encounters where a libary's resident package.json lives
this is one way to deploy ALL nx libs to your registry in one hit/sweep
this gist could be rigged in a scripts folder under tools and triggered from a custom deploy task within your project
OR
it could be run as a root package.json npm script
"deploy": "source ./tools/scripts/deploy.sh",
use at your own discretion
terminal cmd line usage is as follows