Skip to content

Create rush-resolver-cache-plugin #4892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ These GitHub repositories provide supplementary resources for Rush Stack:
| [/rush-plugins/rush-azure-storage-build-cache-plugin](./rush-plugins/rush-azure-storage-build-cache-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-azure-storage-build-cache-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-azure-storage-build-cache-plugin) | | [@rushstack/rush-azure-storage-build-cache-plugin](https://www.npmjs.com/package/@rushstack/rush-azure-storage-build-cache-plugin) |
| [/rush-plugins/rush-http-build-cache-plugin](./rush-plugins/rush-http-build-cache-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-http-build-cache-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-http-build-cache-plugin) | | [@rushstack/rush-http-build-cache-plugin](https://www.npmjs.com/package/@rushstack/rush-http-build-cache-plugin) |
| [/rush-plugins/rush-redis-cobuild-plugin](./rush-plugins/rush-redis-cobuild-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-redis-cobuild-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-redis-cobuild-plugin) | | [@rushstack/rush-redis-cobuild-plugin](https://www.npmjs.com/package/@rushstack/rush-redis-cobuild-plugin) |
| [/rush-plugins/rush-resolver-cache-plugin](./rush-plugins/rush-resolver-cache-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-resolver-cache-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-resolver-cache-plugin) | | [@rushstack/rush-resolver-cache-plugin](https://www.npmjs.com/package/@rushstack/rush-resolver-cache-plugin) |
| [/rush-plugins/rush-serve-plugin](./rush-plugins/rush-serve-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-serve-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-serve-plugin) | | [@rushstack/rush-serve-plugin](https://www.npmjs.com/package/@rushstack/rush-serve-plugin) |
| [/webpack/hashed-folder-copy-plugin](./webpack/hashed-folder-copy-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fhashed-folder-copy-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Fhashed-folder-copy-plugin) | [changelog](./webpack/hashed-folder-copy-plugin/CHANGELOG.md) | [@rushstack/hashed-folder-copy-plugin](https://www.npmjs.com/package/@rushstack/hashed-folder-copy-plugin) |
| [/webpack/loader-load-themed-styles](./webpack/loader-load-themed-styles/) | [![npm version](https://badge.fury.io/js/%40microsoft%2Floader-load-themed-styles.svg)](https://badge.fury.io/js/%40microsoft%2Floader-load-themed-styles) | [changelog](./webpack/loader-load-themed-styles/CHANGELOG.md) | [@microsoft/loader-load-themed-styles](https://www.npmjs.com/package/@microsoft/loader-load-themed-styles) |
Expand Down
7 changes: 6 additions & 1 deletion build-tests-subspace/rush-lib-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@
"@rushstack/eslint-config": "workspace:*",
"@rushstack/heft": "workspace:*",
"@types/node": "18.17.15",
"local-node-rig": "workspace:*"
"eslint": "~8.57.0",
"local-node-rig": "workspace:*",
"typescript": "~5.4.2"
},
"dependenciesMeta": {
"@microsoft/rush-lib": {
"injected": true
},
"@rushstack/eslint-config": {
"injected": true
},
"@rushstack/terminal": {
"injected": true
},
Expand Down
7 changes: 6 additions & 1 deletion build-tests-subspace/rush-sdk-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@
"@rushstack/eslint-config": "workspace:*",
"@rushstack/heft": "workspace:*",
"@types/node": "18.17.15",
"local-node-rig": "workspace:*"
"eslint": "~8.57.0",
"local-node-rig": "workspace:*",
"typescript": "~5.4.2"
},
"dependenciesMeta": {
"@microsoft/rush-lib": {
"injected": true
},
"@rushstack/eslint-config": {
"injected": true
},
"@rushstack/rush-sdk": {
"injected": true
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Add `afterInstall` plugin hook, which runs after any install finishes.",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
8 changes: 8 additions & 0 deletions common/config/rush/nonbrowser-approved-packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@
"name": "@rushstack/rush-redis-cobuild-plugin",
"allowedCategories": [ "tests" ]
},
{
"name": "@rushstack/rush-resolver-cache-plugin",
"allowedCategories": [ "libraries" ]
},
{
"name": "@rushstack/rush-sdk",
"allowedCategories": [ "libraries", "tests", "vscode-extensions" ]
Expand Down Expand Up @@ -290,6 +294,10 @@
"name": "@rushstack/webpack-preserve-dynamic-require-plugin",
"allowedCategories": [ "libraries", "vscode-extensions" ]
},
{
"name": "@rushstack/webpack-workspace-resolve-plugin",
"allowedCategories": [ "libraries" ]
},
{
"name": "@rushstack/webpack4-localization-plugin",
"allowedCategories": [ "tests" ]
Expand Down
48 changes: 32 additions & 16 deletions common/config/subspaces/build-tests-subspace/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
{
"pnpmShrinkwrapHash": "d6b1ce506a173cc0f198bbab8f6bb322eb8b6889",
"pnpmShrinkwrapHash": "1ecf2af7374b58143367470c7de41e0fdea42488",
"preferredVersionsHash": "ce857ea0536b894ec8f346aaea08cfd85a5af648",
"packageJsonInjectedDependenciesHash": "e120d817d8c972401ab79549dd270a1ff8beed7f"
"packageJsonInjectedDependenciesHash": "8aa35461d7c050f5de780154b4584a6261955a98"
}
28 changes: 28 additions & 0 deletions common/config/subspaces/default/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion common/reviews/api/rush-lib.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,8 @@ export class _RushInternals {

// @beta
export class RushLifecycleHooks {
readonly beforeInstall: AsyncSeriesHook<IGlobalCommand>;
readonly afterInstall: AsyncSeriesHook<[IRushCommand, Subspace]>;
readonly beforeInstall: AsyncSeriesHook<[IGlobalCommand, Subspace]>;
readonly flushTelemetry: AsyncParallelHook<[ReadonlyArray<ITelemetryData>]>;
readonly initialize: AsyncSeriesHook<IRushCommand>;
readonly runAnyGlobalCustomCommand: AsyncSeriesHook<IGlobalCommand>;
Expand Down
22 changes: 22 additions & 0 deletions common/reviews/api/rush-resolver-cache-plugin.api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## API Report File for "@rushstack/rush-resolver-cache-plugin"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

import type { IRushPlugin } from '@rushstack/rush-sdk';
import type { RushConfiguration } from '@rushstack/rush-sdk';
import type { RushSession } from '@rushstack/rush-sdk';

// @beta
class RushResolverCachePlugin implements IRushPlugin {
// (undocumented)
apply(rushSession: RushSession, rushConfiguration: RushConfiguration): void;
// (undocumented)
readonly pluginName: 'RushResolverCachePlugin';
}
export default RushResolverCachePlugin;

// (No @packageDocumentation comment for this package)

```
5 changes: 4 additions & 1 deletion libraries/rush-lib/src/cli/actions/InstallAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { IInstallManagerOptions } from '../../logic/base/BaseInstallManager
import type { RushCommandLineParser } from '../RushCommandLineParser';
import { SelectionParameterSet } from '../parsing/SelectionParameterSet';
import type { RushConfigurationProject } from '../../api/RushConfigurationProject';
import type { Subspace } from '../../api/Subspace';

export class InstallAction extends BaseInstallAction {
private readonly _checkOnlyParameter: CommandLineFlagParameter;
Expand Down Expand Up @@ -80,7 +81,9 @@ export class InstallAction extends BaseInstallAction {
(await this._selectionParameters?.getPnpmFilterArgumentValuesAsync(this._terminal)) ?? [],
checkOnly: this._checkOnlyParameter.value,
resolutionOnly: this._resolutionOnlyParameter?.value,
beforeInstallAsync: () => this.rushSession.hooks.beforeInstall.promise(this),
beforeInstallAsync: (subspace: Subspace) =>
this.rushSession.hooks.beforeInstall.promise(this, subspace),
afterInstallAsync: (subspace: Subspace) => this.rushSession.hooks.afterInstall.promise(this, subspace),
terminal: this._terminal
};
}
Expand Down
5 changes: 4 additions & 1 deletion libraries/rush-lib/src/cli/actions/UpdateAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { IInstallManagerOptions } from '../../logic/base/BaseInstallManager
import type { RushCommandLineParser } from '../RushCommandLineParser';
import { SelectionParameterSet } from '../parsing/SelectionParameterSet';
import type { RushConfigurationProject } from '../../api/RushConfigurationProject';
import type { Subspace } from '../../api/Subspace';

export class UpdateAction extends BaseInstallAction {
private readonly _fullParameter: CommandLineFlagParameter;
Expand Down Expand Up @@ -102,7 +103,9 @@ export class UpdateAction extends BaseInstallAction {
pnpmFilterArgumentValues:
(await this._selectionParameters?.getPnpmFilterArgumentValuesAsync(this._terminal)) ?? [],
checkOnly: false,
beforeInstallAsync: () => this.rushSession.hooks.beforeInstall.promise(this),
beforeInstallAsync: (subspace: Subspace) =>
this.rushSession.hooks.beforeInstall.promise(this, subspace),
afterInstallAsync: (subspace: Subspace) => this.rushSession.hooks.afterInstall.promise(this, subspace),
terminal: this._terminal
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type {
CommandLineStringParameter
} from '@rushstack/ts-command-line';

import type { Subspace } from '../../api/Subspace';
import type { IPhasedCommand } from '../../pluginFramework/RushLifeCycle';
import {
PhasedCommandHooks,
Expand Down Expand Up @@ -297,7 +298,10 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> {
terminal: this._terminal,
rushConfiguration: this.rushConfiguration,
rushGlobalFolder: this.rushGlobalFolder,
isDebug: this.parser.isDebug
isDebug: this.parser.isDebug,
beforeInstallAsync: (subspace: Subspace) =>
this.rushSession.hooks.beforeInstall.promise(this, subspace),
afterInstallAsync: (subspace: Subspace) => this.rushSession.hooks.afterInstall.promise(this, subspace)
});
}

Expand Down
8 changes: 7 additions & 1 deletion libraries/rush-lib/src/logic/base/BaseInstallManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export abstract class BaseInstallManager {

// Give plugins an opportunity to act before invoking the installation process
if (this.options.beforeInstallAsync !== undefined) {
await this.options.beforeInstallAsync();
await this.options.beforeInstallAsync(subspace);
}

await Promise.all([
Expand Down Expand Up @@ -344,9 +344,15 @@ export abstract class BaseInstallManager {

// Perform any post-install work the install manager requires
await this.postInstallAsync(subspace);

// Create the marker file to indicate a successful install
await commonTempInstallFlag.createAsync();

// Give plugins an opportunity to act after a successful install
if (this.options.afterInstallAsync !== undefined) {
await this.options.afterInstallAsync(subspace);
}

// eslint-disable-next-line no-console
console.log('');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ export interface IInstallManagerOptions {
/**
* Callback to invoke between preparing the common/temp folder and running installation.
*/
beforeInstallAsync?: () => Promise<void>;
beforeInstallAsync?: (subspace: Subspace) => Promise<void>;

/**
* Callback to invoke after a successful installation.
*/
afterInstallAsync?: (subspace: Subspace) => Promise<void>;

/**
* The specific subspace to install.
Expand Down
Loading
Loading