@@ -5,14 +5,14 @@ import type { ChildProcess } from 'node:child_process';
55
66import { Async , Executable , JsonFile } from '@rushstack/node-core-library' ;
77import { ConsoleTerminalProvider , Terminal } from '@rushstack/terminal' ;
8- import { DependencyType , RushConfiguration } from '@microsoft/rush-lib' ;
8+ import { DependencyType , RushConfiguration , type CommonVersionsConfiguration } from '@microsoft/rush-lib' ;
99import { CommandLineAction } from '@rushstack/ts-command-line' ;
1010
11- export class BumpCyclicsAction extends CommandLineAction {
11+ export class BumpDecoupledLocalDependencies extends CommandLineAction {
1212 public constructor ( ) {
1313 super ( {
14- actionName : 'bump-cyclic -dependencies' ,
15- summary : 'Updates cyclic dependencies inside the repo.' ,
14+ actionName : 'bump-decoupled-local -dependencies' ,
15+ summary : 'Updates decoupled local dependencies inside the repo.' ,
1616 documentation : ''
1717 } ) ;
1818 }
@@ -46,20 +46,33 @@ export class BumpCyclicsAction extends CommandLineAction {
4646 terminal . writeLine ( ) ;
4747
4848 for ( const project of rushConfiguration . projects ) {
49+ const commonVersions : CommonVersionsConfiguration = project . subspace . getCommonVersions ( ) ;
50+
4951 for ( const cyclicDependencyProject of project . decoupledLocalDependencies ) {
50- const version : string = cyclicDependencyVersions . get ( cyclicDependencyProject ) ! ;
52+ const existingVersion : string | undefined =
53+ project . packageJson . dependencies ?. [ cyclicDependencyProject ] ??
54+ project . packageJson . devDependencies ?. [ cyclicDependencyProject ] ;
55+ if (
56+ existingVersion &&
57+ commonVersions . allowedAlternativeVersions . get ( cyclicDependencyProject ) ?. includes ( existingVersion )
58+ ) {
59+ // Skip if the existing version is allowed by common-versions.json
60+ continue ;
61+ }
62+
63+ const newVersion : string = cyclicDependencyVersions . get ( cyclicDependencyProject ) ! ;
5164 if ( project . packageJsonEditor . tryGetDependency ( cyclicDependencyProject ) ) {
5265 project . packageJsonEditor . addOrUpdateDependency (
5366 cyclicDependencyProject ,
54- version ,
67+ newVersion ,
5568 DependencyType . Regular
5669 ) ;
5770 }
5871
5972 if ( project . packageJsonEditor . tryGetDevDependency ( cyclicDependencyProject ) ) {
6073 project . packageJsonEditor . addOrUpdateDependency (
6174 cyclicDependencyProject ,
62- version ,
75+ newVersion ,
6376 DependencyType . Dev
6477 ) ;
6578 }
0 commit comments