Skip to content

Commit

Permalink
chore: Add NPM duplicate dependency check to canaries (#11333)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimblanc authored May 4, 2023
1 parent f7c8974 commit 50cb189
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2512,7 +2512,10 @@ orbs:
no_output_timeout: 2m
- run-with-retry:
label: Install AmplifyJS
command: npm i -S aws-amplify && npm i -g wait-on serve
command: |
npm i -S aws-amplify
npm i -g wait-on serve
~/amplify-js/.circleci/duplicates-npm.sh
- run:
name: Call Amplify library in code
command: |
Expand Down
17 changes: 17 additions & 0 deletions .circleci/duplicates-npm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

# This script detects duplicated Amplify dependencies in the dependency graph (with NPM)
duplicatedDependencies=$(
npm ls -all 2>/dev/null | \
grep -o -e '@\?aws-amplify[^ ]*' | \
sort | uniq | \
sed -E 's/^(@?[^@]+).*$/\1/g' | \
uniq -d | sort
)

if [ ! "$duplicatedDependencies" ]; then
echo "No duplicated Amplify dependencies detected."
else
echo "Duplicated Amplify dependencies detected: $duplicatedDependencies"
false
fi
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"bootstrap": "lerna bootstrap",
"test": "lerna run test --stream",
"test:size": "lerna run test:size",
"test:duplicates": "./scripts/duplicates.sh",
"test:duplicates": "./scripts/duplicates-yarn.sh",
"cypress": "lerna run cypress",
"cypress:open": "lerna run cypress:open",
"coverage": "codecov || exit 0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/duplicates.sh → scripts/duplicates-yarn.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# This script detects duplicated Amplify dependencies in the dependency graph
# This script detects duplicated Amplify dependencies in the dependency graph (with Yarn)
duplicatedDependencies=$(
yarn list --pattern amplify |
grep -o -e '@\?aws-amplify[^ ]*' |
Expand Down

0 comments on commit 50cb189

Please sign in to comment.