Skip to content

Commit

Permalink
For out-of-scope package, do not update its dependencies versions alo…
Browse files Browse the repository at this point in the history
…ng with its own version (#428)

* scope bump

* Change files
  • Loading branch information
xugao authored Oct 21, 2020
1 parent 0bd0031 commit d2c075b
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 7 deletions.
Empty file modified bin/beachball.js
100644 → 100755
Empty file.
8 changes: 8 additions & 0 deletions change/beachball-2020-10-21-10-49-12-bump-scoped-pkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "minor",
"comment": "For out-of-scope package, do not update its dependencies versions along with its own version.",
"packageName": "beachball",
"email": "[email protected]",
"dependentChangeType": "patch",
"date": "2020-10-21T17:49:12.375Z"
}
4 changes: 2 additions & 2 deletions src/__e2e__/bump.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ describe('version bumping', () => {
expect(changeFiles.length).toBe(1);
});

it('should not bump out-of-scope package even if dependency of the package has change', async () => {
it('should not bump out-of-scope package and its dependencies even if dependency of the package has change', async () => {
repositoryFactory = new MonoRepoFactory();
await repositoryFactory.create();
const repo = await repositoryFactory.cloneRepository();
Expand All @@ -504,7 +504,7 @@ describe('version bumping', () => {
const packageInfos = getPackageInfos(repo.rootPath);
expect(packageInfos['foo'].version).toBe('1.0.0');
expect(packageInfos['bar'].version).toBe('1.3.5');
expect(packageInfos['foo'].dependencies?.bar).toBe('^1.3.5');
expect(packageInfos['foo'].dependencies?.bar).toBe('^1.3.4');

const changeFiles = getChangeFiles(repo.rootPath);
expect(changeFiles.length).toBe(0);
Expand Down
4 changes: 2 additions & 2 deletions src/bump/bumpInPlace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { setDependentVersions } from './setDependentVersions';
*/
export function bumpInPlace(bumpInfo: BumpInfo, options: BeachballOptions) {
const { bumpDeps } = options;
const { packageInfos, packageChangeTypes, modifiedPackages } = bumpInfo;
const { packageInfos, scopedPackages, packageChangeTypes, modifiedPackages } = bumpInfo;
const changes = { ...packageChangeTypes };
// pass 1: figure out all the change types for all the packages taking into account the bumpDeps option and version groups
if (bumpDeps) {
Expand All @@ -32,7 +32,7 @@ export function bumpInPlace(bumpInfo: BumpInfo, options: BeachballOptions) {
});

// pass 3: Bump all the dependencies packages
const dependentModifiedPackages = setDependentVersions(packageInfos);
const dependentModifiedPackages = setDependentVersions(packageInfos, scopedPackages);
dependentModifiedPackages.forEach(pkg => modifiedPackages.add(pkg));

return bumpInfo;
Expand Down
6 changes: 5 additions & 1 deletion src/bump/setDependentVersions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { PackageInfos, PackageDeps } from '../types/PackageInfo';
import { bumpMinSemverRange } from './bumpMinSemverRange';

export function setDependentVersions(packageInfos: PackageInfos) {
export function setDependentVersions(packageInfos: PackageInfos, scopedPackages: Set<string>) {
const modifiedPackages = new Set<string>();
Object.keys(packageInfos).forEach(pkgName => {
if (!scopedPackages.has(pkgName)) {
return;
}

const info = packageInfos[pkgName];
['dependencies', 'devDependencies', 'peerDependencies'].forEach(depKind => {
const deps: PackageDeps | undefined = (info as any)[depKind];
Expand Down
2 changes: 1 addition & 1 deletion src/commands/canary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function canary(options: BeachballOptions) {
bumpInfo.packageInfos[pkg].version = newVersion;
}

setDependentVersions(bumpInfo.packageInfos);
setDependentVersions(bumpInfo.packageInfos, bumpInfo.scopedPackages);

await performBump(bumpInfo, options);

Expand Down
2 changes: 1 addition & 1 deletion src/commands/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export async function sync(options: BeachballOptions) {
}
}

const dependentModifiedPackages = setDependentVersions(packageInfos);
const dependentModifiedPackages = setDependentVersions(packageInfos, scopedPackages);
dependentModifiedPackages.forEach(pkg => modifiedPackages.add(pkg));

writePackageJson(modifiedPackages, packageInfos);
Expand Down

0 comments on commit d2c075b

Please sign in to comment.