node.js – Update project CDK packages at once
You can parse the package.json
file in your pipeline and bump the cdk
specific packages to a specific version number with a bash script.
Note that the core/resource specific AWS CDK packages start with @aws-cdk
and the main AWS CDK package is named aws-cdk
.
You can use the script like this: cdk-bump.sh 1.128.0
cdk-bump.sh
#!/bin/bash
if [ $# -eq 0 ]
then
echo "No CDK version provided!"
exit 1
fi
GREEN=' 33[0;32m'
NC=' 33[0m'
tmp=$(mktemp)
for type in dependencies devDependencies; do
for key in $(jq ".$type | keys[]" package.json); do
if [[ $key == "@aws-cdk/* ]] || [[ $key == "aws-cdk" ]] ; then
jq ".$type.$key = "$1"" package.json > "$tmp" && mv "$tmp" package.json
fi
done
done
npm install
echo -e "${GREEN}CDK package versions bumped to version $1${NC}"
Read more here: Source link