Skip to content

Commit

Permalink
#28259 Making bump sdk script more generic to work with any packages …
Browse files Browse the repository at this point in the history
…and examples.
  • Loading branch information
dcolina committed Aug 29, 2024
1 parent 2d0adc9 commit e57bfac
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions core-web/bump-sdk-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ const updatePeerDependencies = (packageJsonPath, newVersion) => {
const packageJson = readJSON(packageJsonPath);
let updated = false;

if (packageJson.peerDependencies && packageJson.peerDependencies['@dotcms/client']) {
packageJson.peerDependencies['@dotcms/client'] = newVersion;
updated = true;
if (packageJson.peerDependencies) {
Object.keys(packageJson.peerDependencies).forEach((dep) => {
if (dep.startsWith('@dotcms/')) {
packageJson.peerDependencies[dep] = newVersion;
updated = true;
}
});
}

if (updated) {
Expand Down Expand Up @@ -90,14 +94,17 @@ sdkLibraries.forEach((lib) => {
}
});

// Step 4: Update dependencies in example projects
const sdkDependencies = {
'@dotcms/client': newVersion,
'@dotcms/angular': newVersion,
'@dotcms/react': newVersion,
'@dotcms/experiments': newVersion
};
// Step 4: Dynamically build the sdkDependencies object
const sdkDependencies = sdkLibraries.reduce((deps, lib) => {
const packageJsonPath = path.join(sdkDir, lib, 'package.json');
const packageJson = readJSON(packageJsonPath);
if (packageJson.name) {
deps[packageJson.name] = newVersion;
}
return deps;
}, {});

// Step 5: Update dependencies in example projects
const exampleProjects = fs
.readdirSync(examplesDir)
.filter((proj) => fs.existsSync(path.join(examplesDir, proj, 'package.json')));
Expand Down

0 comments on commit e57bfac

Please sign in to comment.