diff --git a/common/config/subspaces/default/common-versions.json b/common/config/subspaces/default/common-versions.json index 67948f39642..bcaa4198eb5 100644 --- a/common/config/subspaces/default/common-versions.json +++ b/common/config/subspaces/default/common-versions.json @@ -143,6 +143,10 @@ "@rushstack/eslint-config": [ // This is used by the ESLint 7 build tests "3.7.1" + ], + "@rushstack/set-webpack-public-path-plugin": [ + // This is used by the webpack 4 localization plugin tests + "^4.1.16" ] } } diff --git a/repo-scripts/repo-toolbox/src/ToolboxCommandLine.ts b/repo-scripts/repo-toolbox/src/cli/ToolboxCommandLine.ts similarity index 65% rename from repo-scripts/repo-toolbox/src/ToolboxCommandLine.ts rename to repo-scripts/repo-toolbox/src/cli/ToolboxCommandLine.ts index 475a4b48aa9..eb384cdb761 100644 --- a/repo-scripts/repo-toolbox/src/ToolboxCommandLine.ts +++ b/repo-scripts/repo-toolbox/src/cli/ToolboxCommandLine.ts @@ -3,9 +3,9 @@ import { CommandLineParser } from '@rushstack/ts-command-line'; -import { ReadmeAction } from './ReadmeAction'; -import { RecordVersionsAction } from './RecordVersionsAction'; -import { BumpCyclicsAction } from './BumpCyclicsAction'; +import { ReadmeAction } from './actions/ReadmeAction'; +import { RecordVersionsAction } from './actions/RecordVersionsAction'; +import { BumpDecoupledLocalDependencies } from './actions/BumpDecoupledLocalDependencies'; export class ToolboxCommandLine extends CommandLineParser { public constructor() { @@ -16,6 +16,6 @@ export class ToolboxCommandLine extends CommandLineParser { this.addAction(new ReadmeAction()); this.addAction(new RecordVersionsAction()); - this.addAction(new BumpCyclicsAction()); + this.addAction(new BumpDecoupledLocalDependencies()); } } diff --git a/repo-scripts/repo-toolbox/src/BumpCyclicsAction.ts b/repo-scripts/repo-toolbox/src/cli/actions/BumpDecoupledLocalDependencies.ts similarity index 78% rename from repo-scripts/repo-toolbox/src/BumpCyclicsAction.ts rename to repo-scripts/repo-toolbox/src/cli/actions/BumpDecoupledLocalDependencies.ts index 2c43ef5874f..b2f10b83de8 100644 --- a/repo-scripts/repo-toolbox/src/BumpCyclicsAction.ts +++ b/repo-scripts/repo-toolbox/src/cli/actions/BumpDecoupledLocalDependencies.ts @@ -5,14 +5,14 @@ import type { ChildProcess } from 'node:child_process'; import { Async, Executable, JsonFile } from '@rushstack/node-core-library'; import { ConsoleTerminalProvider, Terminal } from '@rushstack/terminal'; -import { DependencyType, RushConfiguration } from '@microsoft/rush-lib'; +import { DependencyType, RushConfiguration, type CommonVersionsConfiguration } from '@microsoft/rush-lib'; import { CommandLineAction } from '@rushstack/ts-command-line'; -export class BumpCyclicsAction extends CommandLineAction { +export class BumpDecoupledLocalDependencies extends CommandLineAction { public constructor() { super({ - actionName: 'bump-cyclic-dependencies', - summary: 'Updates cyclic dependencies inside the repo.', + actionName: 'bump-decoupled-local-dependencies', + summary: 'Updates decoupled local dependencies inside the repo.', documentation: '' }); } @@ -46,12 +46,25 @@ export class BumpCyclicsAction extends CommandLineAction { terminal.writeLine(); for (const project of rushConfiguration.projects) { + const commonVersions: CommonVersionsConfiguration = project.subspace.getCommonVersions(); + for (const cyclicDependencyProject of project.decoupledLocalDependencies) { - const version: string = cyclicDependencyVersions.get(cyclicDependencyProject)!; + const existingVersion: string | undefined = + project.packageJson.dependencies?.[cyclicDependencyProject] ?? + project.packageJson.devDependencies?.[cyclicDependencyProject]; + if ( + existingVersion && + commonVersions.allowedAlternativeVersions.get(cyclicDependencyProject)?.includes(existingVersion) + ) { + // Skip if the existing version is allowed by common-versions.json + continue; + } + + const newVersion: string = cyclicDependencyVersions.get(cyclicDependencyProject)!; if (project.packageJsonEditor.tryGetDependency(cyclicDependencyProject)) { project.packageJsonEditor.addOrUpdateDependency( cyclicDependencyProject, - version, + newVersion, DependencyType.Regular ); } @@ -59,7 +72,7 @@ export class BumpCyclicsAction extends CommandLineAction { if (project.packageJsonEditor.tryGetDevDependency(cyclicDependencyProject)) { project.packageJsonEditor.addOrUpdateDependency( cyclicDependencyProject, - version, + newVersion, DependencyType.Dev ); } diff --git a/repo-scripts/repo-toolbox/src/ReadmeAction.ts b/repo-scripts/repo-toolbox/src/cli/actions/ReadmeAction.ts similarity index 100% rename from repo-scripts/repo-toolbox/src/ReadmeAction.ts rename to repo-scripts/repo-toolbox/src/cli/actions/ReadmeAction.ts diff --git a/repo-scripts/repo-toolbox/src/RecordVersionsAction.ts b/repo-scripts/repo-toolbox/src/cli/actions/RecordVersionsAction.ts similarity index 100% rename from repo-scripts/repo-toolbox/src/RecordVersionsAction.ts rename to repo-scripts/repo-toolbox/src/cli/actions/RecordVersionsAction.ts diff --git a/repo-scripts/repo-toolbox/src/start.ts b/repo-scripts/repo-toolbox/src/start.ts index aaab695092f..11b0e4064c4 100644 --- a/repo-scripts/repo-toolbox/src/start.ts +++ b/repo-scripts/repo-toolbox/src/start.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. -import { ToolboxCommandLine } from './ToolboxCommandLine'; +import { ToolboxCommandLine } from './cli/ToolboxCommandLine'; // eslint-disable-next-line no-console console.log('repo-toolbox\n');