Skip to content

Commit

Permalink
fix: incorrect peerDependency on "constructs" (#13255)
Browse files Browse the repository at this point in the history
Both `@monocdk-experiment/assert` and `aws-cdk-lib` had an outdated peer
dependency declaration against `construct` (at `^3.0.4` when the code
actually depends on features introduced as recently as `^3.2.0`). This
corrects the declaration accordingly.

Additionally, fixes the pack prerequisite check for .NET to accept
.NET 5.0 as a valid provider for .NET Core 3.1 (because it is).


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
RomainMuller authored Feb 25, 2021
1 parent 778ea27 commit 17244af
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/@monocdk-experiment/assert/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@aws-cdk/cloudformation-diff": "0.0.0"
},
"peerDependencies": {
"constructs": "^3.0.4",
"constructs": "^3.2.0",
"jest": "^26.6.3",
"monocdk": "^0.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
"ubergen": "0.0.0"
},
"peerDependencies": {
"constructs": "^3.0.4"
"constructs": "^3.2.0"
},
"homepage": "https://github.com/aws/aws-cdk",
"engines": {
Expand Down
12 changes: 6 additions & 6 deletions scripts/check-pack-prerequisites.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ app_v=$(${app} -version 2>&1)
echo -e "Checking javac version... \c"
# 1.8
if [ $(echo $app_v | grep -c -E "1\.8\.[0-9].*") -eq 1 ]
then
then
echo "Ok"
else
# 11 or 14 or 15
if [ $(echo $app_v | grep -c -E "1[145]\.[0-9]\.[0-9].*") -eq 1 ]
then
then
echo "Ok"
else
wrong_version
Expand All @@ -73,7 +73,7 @@ check_which $app $app_min
app_v=$(${app} --version)
echo -e "Checking mvn version... \c"
if [ $(echo $app_v | grep -c -E "3\.[6789]\.[0-9].*") -eq 1 ]
then
then
echo "Ok"
else
wrong_version
Expand All @@ -85,8 +85,8 @@ app_min="3.1.0"
check_which $app $app_min
app_v=$(${app} --version)
echo -e "Checking $app version... \c"
if [ $(echo $app_v | grep -c -E "3\.1\.[0-9].*") -eq 1 ]
then
if [ $(echo $app_v | grep -c -E "3\.1\.[0-9].*|[4-9]\..*") -eq 1 ]
then
echo "Ok"
else
wrong_version
Expand All @@ -99,7 +99,7 @@ check_which $app $app_min
app_v=$(${app} --version)
echo -e "Checking $app version... \c"
if [ $(echo $app_v | grep -c -E "3\.[6789]\.[0-9].*") -eq 1 ]
then
then
echo "Ok"
else
wrong_version
Expand Down
32 changes: 32 additions & 0 deletions tools/pkglint/lib/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,38 @@ export class NoPeerDependenciesMonocdk extends ValidationRule {
}
}

/**
* Validates that the same version of `constructs` is used wherever a dependency
* is specified, so that they must all be udpated at the same time (through an
* update to this rule).
*
* Note: v1 and v2 use different versions respectively.
*/
export class ConstructsVersion extends ValidationRule {
public readonly name = 'deps/constructs';
private readonly expectedRange = cdkMajorVersion() === 2
? '10.0.0-pre.5'
: '^3.2.0';

public validate(pkg: PackageJson) {
const toCheck = new Array<string>();

if ('constructs' in pkg.dependencies) {
toCheck.push('dependencies');
}
if ('constructs' in pkg.devDependencies) {
toCheck.push('devDependencies');
}
if ('constructs' in pkg.peerDependencies) {
toCheck.push('peerDependencies');
}

for (const cfg of toCheck) {
expectJSON(this.name, pkg, `${cfg}.constructs`, this.expectedRange);
}
}
}

/**
* JSII Java package is required and must look sane
*/
Expand Down

0 comments on commit 17244af

Please sign in to comment.