forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
align-version.sh
executable file
·39 lines (31 loc) · 1.28 KB
/
align-version.sh
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
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
#------------------------------------------------------------------------
# updates all package.json files to the version defined in lerna.json
# this is called when building inside our ci/cd system
#------------------------------------------------------------------------
set -euo pipefail
scriptdir=$(cd $(dirname $0) && pwd)
# is_private PACKAGE_JSON
#
# Return success if the package.json is private.
is_private() {
node -e "process.exitCode = require(require('path').resolve('$1')).private ? 0 : 1;"
}
export -f is_private
# go to repo root
cd ${scriptdir}/..
files="./package.json $(npx lerna ls -p -a | xargs -n1 -I@ echo @/package.json)"
${scriptdir}/align-version.js ${files}
# validation
marker=$(node -p "require('./scripts/resolve-version').marker.replace(/\./g, '\\\.')")
# Get a list of all package.json files. None of them shouldn contain 0.0.0 anymore.
# Exclude a couple of specific ones that we don't care about.
package_jsons=$(find . -name package.json |\
grep -v node_modules |\
grep -v .github/actions/prlinter/package.json)
# Filter out private packages
package_jsons=$(node ${scriptdir}/retain-public.js $package_jsons)
if grep -l "[^0-9]${marker}" $package_jsons; then
echo "ERROR: unexpected version marker ${marker} in a package.json file"
exit 1
fi