Skip to content

Commit

Permalink
Update update-versions script to support peerDependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sw-joelmut committed Mar 22, 2022
1 parent d28d61f commit b6d9f4d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions libraries/botbuilder-repo-utils/src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface Package {

dependencies?: Record<string, string>;
devDependencies?: Record<string, string>;
peerDependencies?: Record<string, string>;

scripts?: Record<string, string>;
}
12 changes: 8 additions & 4 deletions libraries/botbuilder-repo-utils/src/updateVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ export const command = (argv: string[], quiet = false) => async (): Promise<Resu
// Read git commit sha if instructed (JSON.parse properly coerces strings to boolean)
const commitSha = JSON.parse(flags.git) ? await gitSha('HEAD') : undefined;

// Collect all non-private workspaces from the repo root. Returns workspaces with absolute paths.
const workspaces = await collectWorkspacePackages(repoRoot, packageFile.workspaces, { noPrivate: true });
// Collect all workspaces from the repo root. Returns workspaces with absolute paths.
const workspaces = await collectWorkspacePackages(repoRoot, packageFile.workspaces);

// Build an object mapping a package name to its new, updated version
const workspaceVersions = workspaces.reduce<Record<string, string>>(
(acc, { pkg }) => ({
...acc,
[pkg.name]: getPackageVersion(pkg, newVersion, {
[pkg.name]: getPackageVersion(pkg, pkg.private ? pkg.version : newVersion, {
buildLabel: flags.buildLabel,
commitSha,
date,
Expand All @@ -122,7 +122,7 @@ export const command = (argv: string[], quiet = false) => async (): Promise<Resu
return acc;
}, {});

// Rewrite package.json files by updating version as well as dependencies and devDependencies.
// Rewrite package.json files by updating version as well as dependencies, devDependencies and peerDependencies.
const results = await Promise.all<Result>(
workspaces.map(async ({ absPath, pkg }) => {
const newVersion = workspaceVersions[pkg.name];
Expand All @@ -142,6 +142,10 @@ export const command = (argv: string[], quiet = false) => async (): Promise<Resu
pkg.devDependencies = rewriteWithNewVersions(pkg.devDependencies);
}

if (pkg.peerDependencies) {
pkg.peerDependencies = rewriteWithNewVersions(pkg.peerDependencies);
}

try {
await writeJsonFile(absPath, pkg);
return success();
Expand Down

0 comments on commit b6d9f4d

Please sign in to comment.