Skip to content

Commit

Permalink
chore(scripts): use caret when updating aws-sdk peerDependencies (#6031)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored Apr 26, 2024
1 parent 2d46254 commit 0d54a05
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 45 deletions.
2 changes: 1 addition & 1 deletion clients/client-sso-oidc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
},
"license": "Apache-2.0",
"peerDependencies": {
"@aws-sdk/credential-provider-node": "^3.564.0"
"@aws-sdk/credential-provider-node": "*"
},
"browser": {
"./dist-es/runtimeConfig": "./dist-es/runtimeConfig.browser"
Expand Down
2 changes: 1 addition & 1 deletion clients/client-sts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
},
"license": "Apache-2.0",
"peerDependencies": {
"@aws-sdk/credential-provider-node": "^3.564.0"
"@aws-sdk/credential-provider-node": "*"
},
"browser": {
"./dist-es/runtimeConfig": "./dist-es/runtimeConfig.browser"
Expand Down
2 changes: 1 addition & 1 deletion lib/lib-dynamodb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"tslib": "^2.6.2"
},
"peerDependencies": {
"@aws-sdk/client-dynamodb": "^3.0.0"
"@aws-sdk/client-dynamodb": "*"
},
"devDependencies": {
"@aws-sdk/client-dynamodb": "*",
Expand Down
2 changes: 1 addition & 1 deletion lib/lib-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"tslib": "^2.6.2"
},
"peerDependencies": {
"@aws-sdk/client-s3": "^3.0.0"
"@aws-sdk/client-s3": "*"
},
"devDependencies": {
"@aws-sdk/client-s3": "*",
Expand Down
2 changes: 1 addition & 1 deletion packages/util-dynamodb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"typescript": "~4.9.5"
},
"peerDependencies": {
"@aws-sdk/client-dynamodb": "^3.0.0"
"@aws-sdk/client-dynamodb": "*"
},
"engines": {
"node": ">=14.0.0"
Expand Down
2 changes: 0 additions & 2 deletions scripts/update-versions/current.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// in dependencies/devDependencies/peerDependencies

import { getDepToCurrentVersionHash } from "./getDepToCurrentVersionHash.mjs";
import { runUpdatePeers } from "./peers.mjs";
import { updateVersions } from "./updateVersions.mjs";

updateVersions(getDepToCurrentVersionHash());
runUpdatePeers();
2 changes: 0 additions & 2 deletions scripts/update-versions/default.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// in dependencies/devDependencies/peerDependencies

import { getDepToDefaultVersionHash } from "./getDepToDefaultVersionHash.mjs";
import { runUpdatePeers } from "./peers.mjs";
import { updateVersions } from "./updateVersions.mjs";

updateVersions(getDepToDefaultVersionHash());
runUpdatePeers();
8 changes: 6 additions & 2 deletions scripts/update-versions/getUpdatedPackageJson.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
import { getUpdatedPackageJsonSection } from "./getUpdatedPackageJsonSection.mjs";

export const getUpdatedPackageJson = (packageJson, depToVersionHash) =>
["dependencies", "devDependencies"]
["dependencies", "devDependencies", "peerDependencies"]
.filter((sectionName) => sectionName in packageJson)
.reduce(
(acc, sectionName) => ({
...acc,
[sectionName]: getUpdatedPackageJsonSection(packageJson[sectionName], depToVersionHash),
[sectionName]: getUpdatedPackageJsonSection(
packageJson[sectionName],
depToVersionHash,
sectionName === "peerDependencies"
),
}),
packageJson
);
10 changes: 8 additions & 2 deletions scripts/update-versions/getUpdatedPackageJsonSection.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
// @ts-check
export const getUpdatedPackageJsonSection = (section, depToVersionHash) =>
export const getUpdatedPackageJsonSection = (section, depToVersionHash, isPeer = false) =>
Object.entries(section)
.filter(([key, value]) => key.startsWith("@aws-sdk/") && !value.startsWith("file:"))
.reduce((acc, [key, value]) => ({ ...acc, [key]: depToVersionHash[key] || value }), section);
.reduce((acc, [key]) => {
const newVersion = depToVersionHash[key];
if (newVersion) {
acc[key] = isPeer && newVersion !== "*" ? `^${newVersion}` : newVersion;
}
return acc;
}, section);
17 changes: 0 additions & 17 deletions scripts/update-versions/peers.mjs

This file was deleted.

15 changes: 0 additions & 15 deletions scripts/update-versions/updateVersions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,3 @@ export const updateVersions = (depToVersionHash) => {
writeFileSync(packageJsonPath, format(JSON.stringify(updatedPackageJson), { parser: "json-stringify" }));
});
};

export const updatePeerVersions = (depToVersionHash) => {
getWorkspacePaths().forEach((workspacePath) => {
const packageJsonPath = join(workspacePath, "package.json");
const packageJson = JSON.parse(readFileSync(packageJsonPath).toString());
if (packageJson.peerDependencies) {
for (const peer of Object.keys(packageJson.peerDependencies)) {
if (peer in depToVersionHash) {
packageJson.peerDependencies[peer] = depToVersionHash[peer];
}
}
}
writeFileSync(packageJsonPath, format(JSON.stringify(packageJson), { parser: "json-stringify" }));
});
};

0 comments on commit 0d54a05

Please sign in to comment.