diff --git a/apps/rush-lib/src/api/Rush.ts b/apps/rush-lib/src/api/Rush.ts index 82907aea66f..fffe6533bcc 100644 --- a/apps/rush-lib/src/api/Rush.ts +++ b/apps/rush-lib/src/api/Rush.ts @@ -9,6 +9,7 @@ import { RushXCommandLine } from '../cli/RushXCommandLine'; import { CommandLineMigrationAdvisor } from '../cli/CommandLineMigrationAdvisor'; import { Utilities } from '../utilities/Utilities'; import { EnvironmentVariableNames } from './EnvironmentConfiguration'; +import { IBuiltInPluginConfiguration } from '../pluginFramework/PluginLoader/BuiltInPluginLoader'; /** * Options to pass to the rush "launch" functions. @@ -28,6 +29,13 @@ export interface ILaunchOptions { * with this version of Rush, so we shouldn't print a similar error. */ alreadyReportedNodeTooNewError?: boolean; + + /** + * Used to specify Rush plugins that are dependencies of the "\@microsoft/rush" package. + * + * @internal + */ + builtInPluginConfigurations?: IBuiltInPluginConfiguration[]; } /** @@ -66,7 +74,8 @@ export class Rush { Rush._assignRushInvokedFolder(); const parser: RushCommandLineParser = new RushCommandLineParser({ - alreadyReportedNodeTooNewError: options.alreadyReportedNodeTooNewError + alreadyReportedNodeTooNewError: options.alreadyReportedNodeTooNewError, + builtInPluginConfigurations: options.builtInPluginConfigurations }); parser.execute().catch(console.error); // CommandLineParser.execute() should never reject the promise } diff --git a/apps/rush-lib/src/api/RushPluginsConfiguration.ts b/apps/rush-lib/src/api/RushPluginsConfiguration.ts index e884d9f0519..8734ec7c1bf 100644 --- a/apps/rush-lib/src/api/RushPluginsConfiguration.ts +++ b/apps/rush-lib/src/api/RushPluginsConfiguration.ts @@ -4,6 +4,9 @@ import * as path from 'path'; import { FileSystem, JsonFile, JsonSchema } from '@rushstack/node-core-library'; +/** + * @internal + */ export interface IRushPluginConfigurationBase { packageName: string; pluginName: string; diff --git a/apps/rush-lib/src/cli/RushCommandLineParser.ts b/apps/rush-lib/src/cli/RushCommandLineParser.ts index 396ab5dd80a..678414b8ed4 100644 --- a/apps/rush-lib/src/cli/RushCommandLineParser.ts +++ b/apps/rush-lib/src/cli/RushCommandLineParser.ts @@ -53,6 +53,7 @@ import { SetupAction } from './actions/SetupAction'; import { ICustomCommandLineConfigurationInfo, PluginManager } from '../pluginFramework/PluginManager'; import { RushSession } from '../pluginFramework/RushSession'; import { PhasedScriptAction } from './scriptActions/PhasedScriptAction'; +import { IBuiltInPluginConfiguration } from '../pluginFramework/PluginLoader/BuiltInPluginLoader'; /** * Options for `RushCommandLineParser`. @@ -60,6 +61,7 @@ import { PhasedScriptAction } from './scriptActions/PhasedScriptAction'; export interface IRushCommandLineParserOptions { cwd: string; // Defaults to `cwd` alreadyReportedNodeTooNewError: boolean; + builtInPluginConfigurations: IBuiltInPluginConfiguration[]; } export class RushCommandLineParser extends CommandLineParser { @@ -118,7 +120,8 @@ export class RushCommandLineParser extends CommandLineParser { this.pluginManager = new PluginManager({ rushSession: this.rushSession, rushConfiguration: this.rushConfiguration, - terminal: this._terminal + terminal: this._terminal, + builtInPluginConfigurations: this._rushOptions.builtInPluginConfigurations }); this._populateActions(); @@ -188,7 +191,8 @@ export class RushCommandLineParser extends CommandLineParser { private _normalizeOptions(options: Partial): IRushCommandLineParserOptions { return { cwd: options.cwd || process.cwd(), - alreadyReportedNodeTooNewError: options.alreadyReportedNodeTooNewError || false + alreadyReportedNodeTooNewError: options.alreadyReportedNodeTooNewError || false, + builtInPluginConfigurations: options.builtInPluginConfigurations || [] }; } diff --git a/apps/rush-lib/src/index.ts b/apps/rush-lib/src/index.ts index 2170b7c97e6..28b7bfd7840 100644 --- a/apps/rush-lib/src/index.ts +++ b/apps/rush-lib/src/index.ts @@ -80,6 +80,8 @@ export { export { RushLifecycleHooks } from './pluginFramework/RushLifeCycle'; export { IRushPlugin } from './pluginFramework/IRushPlugin'; +export { IBuiltInPluginConfiguration as _IBuiltInPluginConfiguration } from './pluginFramework/PluginLoader/BuiltInPluginLoader'; +export { IRushPluginConfigurationBase as _IRushPluginConfigurationBase } from './api/RushPluginsConfiguration'; export { ILogger } from './pluginFramework/logging/Logger'; export { ICloudBuildCacheProvider } from './logic/buildCache/ICloudBuildCacheProvider'; diff --git a/apps/rush-lib/src/pluginFramework/PluginLoader/BuiltInPluginLoader.ts b/apps/rush-lib/src/pluginFramework/PluginLoader/BuiltInPluginLoader.ts index 50890be532c..3947936b74d 100644 --- a/apps/rush-lib/src/pluginFramework/PluginLoader/BuiltInPluginLoader.ts +++ b/apps/rush-lib/src/pluginFramework/PluginLoader/BuiltInPluginLoader.ts @@ -4,6 +4,9 @@ import { IRushPluginConfigurationBase } from '../../api/RushPluginsConfiguration'; import { IPluginLoaderOptions, PluginLoaderBase } from './PluginLoaderBase'; +/** + * @internal + */ export interface IBuiltInPluginConfiguration extends IRushPluginConfigurationBase { pluginPackageFolder: string; } diff --git a/apps/rush-lib/src/pluginFramework/PluginManager.ts b/apps/rush-lib/src/pluginFramework/PluginManager.ts index 042846de4f4..bb9683ebbdf 100644 --- a/apps/rush-lib/src/pluginFramework/PluginManager.ts +++ b/apps/rush-lib/src/pluginFramework/PluginManager.ts @@ -2,8 +2,8 @@ // See LICENSE in the project root for license information. import { FileSystem, Import, InternalError, ITerminal } from '@rushstack/node-core-library'; -import { CommandLineConfiguration } from '../api/CommandLineConfiguration'; +import { CommandLineConfiguration } from '../api/CommandLineConfiguration'; import { RushConfiguration } from '../api/RushConfiguration'; import { BuiltInPluginLoader, IBuiltInPluginConfiguration } from './PluginLoader/BuiltInPluginLoader'; import { IRushPlugin } from './IRushPlugin'; @@ -15,6 +15,7 @@ export interface IPluginManagerOptions { terminal: ITerminal; rushConfiguration: RushConfiguration; rushSession: RushSession; + builtInPluginConfigurations: IBuiltInPluginConfiguration[]; } export interface ICustomCommandLineConfigurationInfo { @@ -49,7 +50,7 @@ export class PluginManager { // The plugins have devDependencies on Rush, which would create a circular dependency in our local // workspace if we added them to rush-lib/package.json. Instead we put them in a special section // "publishOnlyDependencies" which gets moved into "dependencies" during publishing. - const builtInPluginConfigurations: IBuiltInPluginConfiguration[] = []; + const builtInPluginConfigurations: IBuiltInPluginConfiguration[] = options.builtInPluginConfigurations; const ownPackageJsonDependencies: Record = require('../../package.json').dependencies; function tryAddBuiltInPlugin(builtInPluginName: string): void { diff --git a/apps/rush/.npmignore b/apps/rush/.npmignore index 302dbc5b019..e9ef47eafb5 100644 --- a/apps/rush/.npmignore +++ b/apps/rush/.npmignore @@ -27,4 +27,6 @@ # DO NOT MODIFY THE TEMPLATE ABOVE THIS LINE #-------------------------------------------- +/lib/start-dev.* + # (Add your project-specific overrides here) \ No newline at end of file diff --git a/apps/rush/package.json b/apps/rush/package.json index 67b38783ebe..ba27e5d40f1 100644 --- a/apps/rush/package.json +++ b/apps/rush/package.json @@ -41,6 +41,8 @@ "@rushstack/eslint-config": "workspace:*", "@rushstack/heft": "workspace:*", "@rushstack/heft-node-rig": "workspace:*", + "@rushstack/rush-amazon-s3-build-cache-plugin": "workspace:*", + "@rushstack/rush-azure-storage-build-cache-plugin": "workspace:*", "@types/heft-jest": "1.0.1", "@types/node": "12.20.24", "@types/semver": "7.3.5" diff --git a/apps/rush/src/start-dev.ts b/apps/rush/src/start-dev.ts new file mode 100644 index 00000000000..d399d245e64 --- /dev/null +++ b/apps/rush/src/start-dev.ts @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +// This file is used during development to load the built-in plugins and to bypass +// some other checks + +import * as rushLib from '@microsoft/rush-lib'; +import { PackageJsonLookup, Import } from '@rushstack/node-core-library'; + +import { MinimalRushConfiguration } from './MinimalRushConfiguration'; +import { RushCommandSelector } from './RushCommandSelector'; + +const builtInPluginConfigurations: rushLib._IBuiltInPluginConfiguration[] = []; + +function includePlugin(pluginName: string): void { + const pluginPackageName: string = `@rushstack/${pluginName}`; + builtInPluginConfigurations.push({ + packageName: pluginPackageName, + pluginName: pluginName, + pluginPackageFolder: Import.resolvePackage({ + packageName: pluginPackageName, + baseFolderPath: __dirname + }) + }); +} + +includePlugin('rush-amazon-s3-build-cache-plugin'); +includePlugin('rush-azure-storage-build-cache-plugin'); + +// Load the configuration +const configuration: MinimalRushConfiguration | undefined = + MinimalRushConfiguration.loadFromDefaultLocation(); + +const currentPackageVersion: string = PackageJsonLookup.loadOwnPackageJson(__dirname).version; +RushCommandSelector.execute(currentPackageVersion, rushLib, { + isManaged: !!configuration, + alreadyReportedNodeTooNewError: false, + builtInPluginConfigurations +}); diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index e11ab44cdc6..1ac752fe9a5 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -191,6 +191,8 @@ importers: '@rushstack/heft': workspace:* '@rushstack/heft-node-rig': workspace:* '@rushstack/node-core-library': workspace:* + '@rushstack/rush-amazon-s3-build-cache-plugin': workspace:* + '@rushstack/rush-azure-storage-build-cache-plugin': workspace:* '@types/heft-jest': 1.0.1 '@types/node': 12.20.24 '@types/semver': 7.3.5 @@ -205,6 +207,8 @@ importers: '@rushstack/eslint-config': link:../../eslint/eslint-config '@rushstack/heft': link:../heft '@rushstack/heft-node-rig': link:../../rigs/heft-node-rig + '@rushstack/rush-amazon-s3-build-cache-plugin': link:../../rush-plugins/rush-amazon-s3-build-cache-plugin + '@rushstack/rush-azure-storage-build-cache-plugin': link:../../rush-plugins/rush-azure-storage-build-cache-plugin '@types/heft-jest': 1.0.1 '@types/node': 12.20.24 '@types/semver': 7.3.5 diff --git a/common/config/rush/repo-state.json b/common/config/rush/repo-state.json index c6cb1dd1999..a406b349950 100644 --- a/common/config/rush/repo-state.json +++ b/common/config/rush/repo-state.json @@ -1,5 +1,5 @@ // DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush. { - "pnpmShrinkwrapHash": "47aca98c44b4e322021c9f4f7f8bba4ddd58a905", + "pnpmShrinkwrapHash": "bb7c90e284febcc7531af0f4c81381fc194a5b6a", "preferredVersionsHash": "87aab8e8f0a6545cb9d0ea30194ba68279d285a8" } diff --git a/common/reviews/api/rush-lib.api.md b/common/reviews/api/rush-lib.api.md index cebfb4b4029..e1bc1006483 100644 --- a/common/reviews/api/rush-lib.api.md +++ b/common/reviews/api/rush-lib.api.md @@ -191,6 +191,12 @@ export class ExperimentsConfiguration { get configuration(): Readonly; } +// @internal (undocumented) +export interface _IBuiltInPluginConfiguration extends _IRushPluginConfigurationBase { + // (undocumented) + pluginPackageFolder: string; +} + // @beta (undocumented) export interface ICloudBuildCacheProvider { // (undocumented) @@ -263,6 +269,8 @@ export interface IGetChangedProjectsOptions { // @public export interface ILaunchOptions { alreadyReportedNodeTooNewError?: boolean; + // @internal + builtInPluginConfigurations?: _IBuiltInPluginConfiguration[]; isManaged: boolean; } @@ -311,6 +319,14 @@ export interface IRushPlugin { apply(rushSession: RushSession, rushConfiguration: RushConfiguration): void; } +// @internal (undocumented) +export interface _IRushPluginConfigurationBase { + // (undocumented) + packageName: string; + // (undocumented) + pluginName: string; +} + // @beta (undocumented) export interface IRushSessionOptions { // (undocumented)