-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathversion_script.sh
More file actions
executable file
·28 lines (23 loc) · 1.08 KB
/
version_script.sh
File metadata and controls
executable file
·28 lines (23 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
# This script updates package.json versions and internal dependency versions.
# It's needed until we upgrade to an npm version that does this for us
# (https://github.com/npm/cli/pull/4588).
if [ "$#" -ne 2 ]; then
echo "Usage: npm run version <old version> <new version>"
echo " E.g., npm run version 0.1.0 0.2.0"
exit 1
fi
# Update versions.
echo "Updating version fields"
grep -rl --exclude-dir={node_modules,.git} --include="package.json" "\"version\": \"$1\"" . | xargs sed -i "s/\"version\": \"$1\"/\"version\": \"$2\"/g"
# Update dependencies. $package loops over published packages.
publishedStr=$(jq -r '.workspaceLists.publish | @sh' package.json)
declare -a published="($publishedStr)"
for package in "${published[@]}"
do
echo "Updating dependencies on ${package}"
grep -rl --exclude-dir={node_modules,.git} --include="package.json" "\"@collabs/$package\": \"$1\"" . | xargs sed -i "s/\"@collabs\/$package\": \"$1\"/\"@collabs\/$package\": \"$2\"/g"
done
echo ""
echo "! Also update range versions if needed, e.g.:"
echo "! npm run version ^0.1.0 ^0.2.0"