feat(scripts): bump-pkg
This commit is contained in:
parent
564d53610a
commit
3b92dd0139
53
scripts/bump-pkg
Executable file
53
scripts/bump-pkg
Executable file
@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ $# -eq 0 ] || [ "$1" = "-h" ]
|
||||
then
|
||||
echo "Usage: $0 <package> <version>"
|
||||
exit
|
||||
fi
|
||||
|
||||
# move to the root repo dir
|
||||
cd "$(dirname "$(which "$0")")/.."
|
||||
|
||||
pkg=$1
|
||||
|
||||
case "$pkg" in
|
||||
@*/*)
|
||||
cd "$pkg"
|
||||
;;
|
||||
*)
|
||||
cd "packages/$pkg"
|
||||
esac
|
||||
|
||||
npm version "$2"
|
||||
|
||||
git add --patch
|
||||
|
||||
newVersion=$(node --eval 'console.log(require("./package.json").version)')
|
||||
|
||||
cd -
|
||||
|
||||
git grep -Flz "\"$pkg\":" '**/package.json' | xargs -0 node -e '
|
||||
const {readFileSync, writeFileSync} = require("fs")
|
||||
|
||||
const [, pkg, version, ...files] = process.argv
|
||||
|
||||
const updateDep = deps => {
|
||||
if (deps !== undefined && pkg in deps) {
|
||||
deps[pkg] = "^" + version
|
||||
}
|
||||
}
|
||||
|
||||
files.forEach(file => {
|
||||
const data = JSON.parse(readFileSync(file, "utf8"))
|
||||
updateDep(data.dependencies)
|
||||
updateDep(data.devDependencies)
|
||||
updateDep(data.peerDependencies)
|
||||
writeFileSync(file, JSON.stringify(data, null, 2) + "\n")
|
||||
})
|
||||
' "$pkg" "$newVersion"
|
||||
|
||||
git add --patch
|
||||
|
||||
git commit -m "feat($pkg): $newVersion"
|
||||
git tag $pkg-v$newVersion
|
Loading…
Reference in New Issue
Block a user