Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: align-version script drops caret from dependencies it rewrites #27376

Merged
merged 3 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"@aws-cdk/pkglint": "0.0.0"
},
"peerDependencies": {
"aws-cdk-lib": "0.0.0",
"aws-cdk-lib": "^0.0.0",
"constructs": "^10.0.0"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-appconfig-alpha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
},
"homepage": "https://github.com/aws/aws-cdk",
"peerDependencies": {
"aws-cdk-lib": "0.0.0",
"aws-cdk-lib": "^0.0.0",
"constructs": "^10.0.0"
},
"separate-module": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/custom-resource-handlers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"repository": {
"url": "https://github.com/aws/aws-cdk.git",
"type": "git",
"directory": "packages/custom-resource-handlers"
"directory": "packages/@aws-cdk/custom-resource-handlers"
},
"keywords": [
"aws",
Expand Down
8 changes: 3 additions & 5 deletions scripts/align-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ for (const file of files) {
}

const version = packageVersionMap[pkg.name]
console.log(version);
pkg.version = version;

processSection(pkg.dependencies || { }, file);
Expand All @@ -41,13 +40,12 @@ for (const file of files) {
function processSection(section, file) {
for (const [ name, version ] of Object.entries(section)) {
if (version === marker || version === '^' + marker) {
const version = packageVersionMap[name];

if (!version) {
const newVersion = packageVersionMap[name];
if (!newVersion) {
throw new Error(`No package found ${name} within repository, which has version 0.0.0`);
}

section[name] = version.replace(marker, version);
section[name] = version.replace(marker, newVersion);
}
}
}
22 changes: 22 additions & 0 deletions tools/@aws-cdk/pkglint/lib/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1533,6 +1533,28 @@ export class ConstructsDependency extends ValidationRule {
}
}

/**
* Peer dependencies should be a range, not a point version, to maximize compatibility
*/
export class PeerDependencyRange extends ValidationRule {
public readonly name = 'peerdependency/range';

public validate(pkg: PackageJson) {
const packages = ['aws-cdk-lib'];
for (const [name, version] of Object.entries(pkg.peerDependencies)) {
if (packages.includes(name) && version.match(/^[0-9]/)) {
pkg.report({
ruleName: this.name,
message: `peerDependency on" ${name}" should be a range, not a point version: "${version}"`,
fix: () => {
pkg.addPeerDependency(name, '^' + version);
},
});
}
}
}
}

/**
* Do not announce new versions of AWS CDK modules in awscdk.io because it is very very spammy
* and actually causes the @awscdkio twitter account to be blocked.
Expand Down
Loading