Skip to content

Instantly share code, notes, and snippets.

@Frikki
Last active July 17, 2018 12:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Frikki/ab893c3e5d9747fed9be827fec8ce56d to your computer and use it in GitHub Desktop.
Save Frikki/ab893c3e5d9747fed9be827fec8ce56d to your computer and use it in GitHub Desktop.
Monorepo setup with yarn + lerna
{
"lerna": "2.11.0",
"version": "independent",
"npmClient": "yarn",
"useWorkspaces": true,
"command": {
"publish": {
"allowBranch": "master"
}
}
}
{
"private": true,
"scripts": {
"bootstrap": "lerna bootstrap",
"test": "lerna run test",
"prepare": "lerna run prepare",
"clean": "rimraf packages/**/lib",
"distclean": "lerna clean --yes && yarn clean",
"build:libs": "yarn clean && yarn prepare",
"bump": "lerna publish --exact --skip-npm",
"release": "yarn bump && git push --follow-tags && scripts/release"
},
"workspaces": [
"packages/*"
],
"devDependencies": {
"lerna": "^2.11.0",
"rimraf": "^2.6.2"
}
}
#!/bin/bash
set -e
echo "📦 Publishing latest release..."
# Note: try-publish should exit cleanly if it detects a duplicate.
# published version
$(npm bin)/lerna exec --concurrency 1 -- $(pwd)/scripts/try-publish
#!/bin/bash
set -e
# pwd
package=$(jq -r .name package.json)
version=$(jq -r .version package.json)
published=$(yarn info $package version) || published="N/A"
if [[ "$version" = "$published" ]]; then
echo "⚠️ $package@$version is already published!"
else
echo "📦 Publishing: $package@$version (published: $published)"
yarn publish --non-interactive --new-version $version
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment