Skip to content

Commit

Permalink
chore: re-enable using current pkg versions for api compat checks
Browse files Browse the repository at this point in the history
This was originally added in commit
3dd21b9.

However, the script fails during a bump build when the package version
in lerna.json is ahead of the latest published in NPM. This was worked
around by turning this feature off -
09a1f33.

Re-enable this feature and handle version in lerna.json may be ahead of
NPM.
  • Loading branch information
Niranjan Jayakar committed Jun 8, 2020
1 parent f5ebacd commit 3fe5631
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ echo "==========================================================================
echo "building..."
time lerna run $bail --stream $runtarget || fail

DOWNLOAD_LATEST=true /bin/bash scripts/check-api-compatibility.sh
/bin/bash scripts/check-api-compatibility.sh

touch $BUILD_INDICATOR
11 changes: 8 additions & 3 deletions scripts/check-api-compatibility.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ package_name() {
#
# Doesn't use 'npm view' as that is slow. Direct curl'ing npmjs is better
package_exists_on_npm() {
curl -I 2>/dev/null https://registry.npmjs.org/$1 | head -n 1 | grep 200 >/dev/null
pkg=$1
ver=$2 # optional
curl -I 2>/dev/null https://registry.npmjs.org/$pkg/$ver | head -n 1 | grep 200 >/dev/null
}


Expand Down Expand Up @@ -53,10 +55,13 @@ if ! ${SKIP_DOWNLOAD:-false}; then
existing_names=$(echo "$jsii_package_dirs" | xargs -n1 -P4 -I {} bash -c 'dirs_to_existing_names "$@"' _ {})
echo " Done." >&2

if ! ${DOWNLOAD_LATEST:-false}; then
current_version=$(node -p 'require("./lerna.json").version')
current_version=$(node -p 'require("./lerna.json").version')
echo "Current version in lerna.json is $current_version"
if ! ${DOWNLOAD_LATEST:-false} && package_exists_on_npm aws-cdk $current_version; then
echo "Using package version ${current_version} as baseline"
existing_names=$(echo "$existing_names" | sed -e "s/$/@$current_version/")
else
echo "However, using the latest version from NPM as the baseline"
fi

rm -rf $tmpdir
Expand Down

0 comments on commit 3fe5631

Please sign in to comment.