forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: fix-peers and --skip-tests (aws#1155)
The fix-peer-deps script first needs to align existing peer-dependencies to their new bumped version and only then can add new peer-dependencies. Also, add support for "--skip-tests" in build.sh
- Loading branch information
Elad Ben-Israel
authored
Nov 13, 2018
1 parent
0cb1adf
commit 65821ac
Showing
3 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
lerna exec "$PWD/tools/cdk-build-tools/node_modules/.bin/jsii-fix-peers 2>/dev/null || true" | ||
|
||
if [ ! -f lerna.json ]; then | ||
echo "This script should be run from the root of the repo." | ||
exit 1 | ||
fi | ||
|
||
# first, we need to make sure that all existing peer dependencies are aligned to the "dependency" version | ||
find . -name package.json | grep -v node_modules | xargs node scripts/sync-peer-deps.js | ||
|
||
# must build first so .jsii is aligned | ||
/bin/bash ./build.sh --skip-tests | ||
|
||
# now, run jsii-fix-peers to add all missing peers based on the jsii spec | ||
lerna exec "$PWD/tools/cdk-build-tools/node_modules/.bin/jsii-fix-peers 2>/dev/null || true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// align versions of "peerDependencies" and "dependencies" for a given set of package.json files | ||
// usage: node sync-peer-deps.js package.json pacakge.json ... | ||
// | ||
const fs = require('fs'); | ||
|
||
for (const file of process.argv.splice(2)) { | ||
const pkg = JSON.parse(fs.readFileSync(file).toString()); | ||
const deps = pkg.dependencies || { }; | ||
let updated = false; | ||
if (pkg.peerDependencies) { | ||
for (const dep of Object.keys(pkg.peerDependencies)) { | ||
const version = deps[dep]; | ||
const peerVersion = pkg.peerDependencies[dep]; | ||
if (version && version !== peerVersion) { | ||
pkg.peerDependencies[dep] = version; | ||
updated = true; | ||
} | ||
} | ||
} | ||
if (updated) { | ||
console.log('updated:', file); | ||
fs.writeFileSync(file, JSON.stringify(pkg, undefined, 2)); | ||
} | ||
} |