Skip to content
Closed
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
69 changes: 43 additions & 26 deletions common/reviews/api/rush-lib.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@
import { AsyncParallelHook } from 'tapable';
import { AsyncSeriesHook } from 'tapable';
import { AsyncSeriesWaterfallHook } from 'tapable';
import type { CollatedWriter } from '@rushstack/stream-collator';
import type { CommandLineParameter } from '@rushstack/ts-command-line';
import { HookMap } from 'tapable';
import { IPackageJson } from '@rushstack/node-core-library';
import { ITerminal } from '@rushstack/node-core-library';
import { ITerminalProvider } from '@rushstack/node-core-library';
import { JsonObject } from '@rushstack/node-core-library';
import { PackageNameParser } from '@rushstack/node-core-library';
import type { StdioSummarizer } from '@rushstack/terminal';
import { SyncHook } from 'tapable';
import { Terminal } from '@rushstack/node-core-library';
import type { TerminalWritable } from '@rushstack/terminal';

// @public
export class ApprovedPackagesConfiguration {
Expand Down Expand Up @@ -264,7 +263,8 @@ export interface ICreateOperationsContext {
readonly isWatch: boolean;
readonly phaseSelection: ReadonlySet<IPhase>;
readonly projectChangeAnalyzer: ProjectChangeAnalyzer;
readonly projectSelection: ReadonlySet<RushConfigurationProject>;
// Warning: (ae-forgotten-export) The symbol "RushProjectConfiguration" needs to be exported by the entry point index.d.ts
readonly projectSelection: ReadonlyMap<RushConfigurationProject, RushProjectConfiguration | undefined>;
readonly projectsInUnknownState: ReadonlySet<RushConfigurationProject>;
readonly rushConfiguration: RushConfiguration;
}
Expand Down Expand Up @@ -315,12 +315,13 @@ export interface IFileSystemBuildCacheProviderOptions {
export interface IGenerateCacheEntryIdOptions {
phaseName: string;
projectName: string;
projectStateHash: string;
stateHash: string;
}

// @beta (undocumented)
export interface IGetChangedProjectsOptions {
enableFiltering: boolean;
// Warning: (ae-forgotten-export) The symbol "IProjectFileFilterMap" needs to be exported by the entry point index.d.ts
filters?: IProjectFileFilterMap;
includeExternalDependencies: boolean;
// (undocumented)
shouldFetch?: boolean;
Expand Down Expand Up @@ -374,22 +375,24 @@ export interface IOperationExecutionResult {
readonly error: Error | undefined;
readonly nonCachedDurationMs: number | undefined;
readonly status: OperationStatus;
readonly stdioSummarizer: StdioSummarizer;
readonly stopwatch: IStopwatchResult;
}

// @alpha
export interface IOperationOptions {
phase?: IPhase | undefined;
project?: RushConfigurationProject | undefined;
outputFolderNames?: ReadonlyArray<string> | undefined;
phase: IPhase;
// Warning: (ae-forgotten-export) The symbol "IOperationProcessor" needs to be exported by the entry point index.d.ts
processor?: IOperationProcessor | undefined;
project: RushConfigurationProject;
// Warning: (ae-forgotten-export) The symbol "IProjectFileFilter" needs to be exported by the entry point index.d.ts
projectFileFilter?: IProjectFileFilter | undefined;
runner?: IOperationRunner | undefined;
}

// @beta
export interface IOperationRunner {
executeAsync(context: IOperationRunnerContext): Promise<OperationStatus>;
isCacheWriteAllowed: boolean;
isSkipAllowed: boolean;
readonly name: string;
reportTiming: boolean;
silent: boolean;
Expand All @@ -398,27 +401,31 @@ export interface IOperationRunner {

// @beta
export interface IOperationRunnerContext {
collatedWriter: CollatedWriter;
debugMode: boolean;
// @internal
_operationStateFile?: _OperationStateFile;
// Warning: (ae-forgotten-export) The symbol "IOperationHashes" needs to be exported by the entry point index.d.ts
hashes: IOperationHashes | undefined;
isCacheReadAllowed: boolean;
isCacheWriteAllowed: boolean;
isSkipAllowed: boolean;
quietMode: boolean;
stdioSummarizer: StdioSummarizer;
stopwatch: IStopwatchResult;
terminal: ITerminal;
terminalWritable: TerminalWritable;
}

// @internal (undocumented)
export interface _IOperationStateFileOptions {
// (undocumented)
phase: IPhase;
// (undocumented)
rushProject: RushConfigurationProject;
filename: string;
}

// @internal (undocumented)
export interface _IOperationStateJson {
// (undocumented)
hashes: IOperationHashes | undefined;
// (undocumented)
nonCachedDurationMs: number;
// (undocumented)
status: OperationStatus;
}

// @public
Expand Down Expand Up @@ -575,6 +582,8 @@ export class LookupByPath<TItem> {
constructor(entries?: Iterable<[string, TItem]>, delimiter?: string);
readonly delimiter: string;
findChildPath(childPath: string): TItem | undefined;
// Warning: (ae-forgotten-export) The symbol "IPrefixMatch" needs to be exported by the entry point index.d.ts
findChildPathAndIndex(childPath: string): IPrefixMatch<TItem> | undefined;
findChildPathFromSegments(childPathSegments: Iterable<string>): TItem | undefined;
static iteratePathSegments(serializedPath: string, delimiter?: string): Iterable<string>;
setItem(serializedPath: string, value: TItem): this;
Expand All @@ -589,14 +598,20 @@ export class NpmOptionsConfiguration extends PackageManagerOptionsConfigurationB

// @alpha
export class Operation {
constructor(options?: IOperationOptions);
constructor(options: IOperationOptions);
addDependency(dependency: Operation): void;
readonly associatedPhase: IPhase | undefined;
readonly associatedProject: RushConfigurationProject | undefined;
readonly associatedPhase: IPhase;
readonly associatedProject: RushConfigurationProject;
readonly consumers: ReadonlySet<Operation>;
deleteDependency(dependency: Operation): void;
readonly dependencies: ReadonlySet<Operation>;
// (undocumented)
logFilePath: string | undefined;
readonly metadataFolderRelativePath: string;
get name(): string | undefined;
readonly outputFolderNames: ReadonlyArray<string>;
processor: IOperationProcessor | undefined;
readonly projectFileFilter: IProjectFileFilter | undefined;
runner: IOperationRunner | undefined;
weight: number;
}
Expand All @@ -605,7 +620,6 @@ export class Operation {
export class _OperationStateFile {
constructor(options: _IOperationStateFileOptions);
get filename(): string;
static getFilenameRelativeToProjectRoot(phase: IPhase): string;
// (undocumented)
get state(): _IOperationStateJson | undefined;
// (undocumented)
Expand Down Expand Up @@ -724,14 +738,17 @@ export class ProjectChangeAnalyzer {
// Warning: (ae-forgotten-export) The symbol "IRawRepoState" needs to be exported by the entry point index.d.ts
//
// @internal (undocumented)
_ensureInitialized(terminal: ITerminal): IRawRepoState | undefined;
_ensureInitialized(terminal: ITerminal): IRawRepoState;
// (undocumented)
_filterProjectDataAsync<T>(project: RushConfigurationProject, unfilteredProjectData: Map<string, T>, rootDir: string, terminal: ITerminal): Promise<Map<string, T>>;
_filterProjectData<T>(project: RushConfigurationProject, unfilteredProjectData: Map<string, T>, rootDir: string, fileFilter?: IProjectFileFilter): Map<string, T>;
getChangedProjects(options: IGetChangedProjectsOptions): Set<RushConfigurationProject>;
getChangedProjectsAsync(options: IGetChangedProjectsOptions): Promise<Set<RushConfigurationProject>>;
// @internal (undocumented)
_hashProjectDependencies(packageDeps: ReadonlyMap<string, string>): string;
// @internal
_tryGetProjectDependenciesAsync(project: RushConfigurationProject, terminal: ITerminal): Promise<Map<string, string> | undefined>;
_tryGetProjectDependencies(project: RushConfigurationProject, terminal: ITerminal, fileFilter?: IProjectFileFilter): ReadonlyMap<string, string> | undefined;
// @internal
_tryGetProjectStateHashAsync(project: RushConfigurationProject, terminal: ITerminal): Promise<string | undefined>;
_tryGetProjectStateHash(project: RushConfigurationProject, terminal: ITerminal, fileFilter?: IProjectFileFilter): string | undefined;
}

// @public
Expand Down
4 changes: 1 addition & 3 deletions libraries/rush-lib/src/cli/actions/ChangeAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,7 @@ export class ChangeAction extends BaseRushAction {
shouldFetch: !this._noFetchParameter.value,
// Lockfile evaluation will expand the set of projects that request change files
// Not enabling, since this would be a breaking change
includeExternalDependencies: false,
// Since install may not have happened, cannot read rush-project.json
enableFiltering: false
includeExternalDependencies: false
});
const projectHostMap: Map<RushConfigurationProject, string> = this._generateHostMap();

Expand Down
35 changes: 23 additions & 12 deletions libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as os from 'os';
import colors from 'colors/safe';
import type { AsyncSeriesHook } from 'tapable';

import { AlreadyReportedError, InternalError, ITerminal, Terminal } from '@rushstack/node-core-library';
import { AlreadyReportedError, Async, InternalError, ITerminal, Terminal } from '@rushstack/node-core-library';
import {
CommandLineFlagParameter,
CommandLineParameter,
Expand Down Expand Up @@ -38,6 +38,7 @@ import { IExecutionResult } from '../../logic/operations/IOperationExecutionResu
import { OperationResultSummarizerPlugin } from '../../logic/operations/OperationResultSummarizerPlugin';
import type { ITelemetryOperationResult } from '../../logic/Telemetry';
import { parseParallelism } from '../parsing/ParseParallelism';
import { RushProjectConfiguration } from '../../api/RushProjectConfiguration';

/**
* Constructor parameters for PhasedScriptAction.
Expand Down Expand Up @@ -293,6 +294,14 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> {

const changedProjectsOnly: boolean = !!this._changedProjectsOnly?.value;

const selectedProjects: Set<RushConfigurationProject> =
await this._selectionParameters.getSelectedProjectsAsync(terminal);

if (!selectedProjects.size) {
terminal.writeLine(colors.yellow(`The command line selection parameters did not match any projects.`));
return;
}

let buildCacheConfiguration: BuildCacheConfiguration | undefined;
if (!this._disableBuildCache) {
buildCacheConfiguration = await BuildCacheConfiguration.tryLoadAsync(
Expand All @@ -302,13 +311,15 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> {
);
}

const projectSelection: Set<RushConfigurationProject> =
await this._selectionParameters.getSelectedProjectsAsync(terminal);

if (!projectSelection.size) {
terminal.writeLine(colors.yellow(`The command line selection parameters did not match any projects.`));
return;
}
terminal.writeVerbose(`Loading rush-project.json files...`);
const projectSelection: Map<RushConfigurationProject, RushProjectConfiguration | undefined> = new Map();
await Async.forEachAsync(selectedProjects, async (project: RushConfigurationProject) => {
const projectConfiguration: RushProjectConfiguration | undefined =
await RushProjectConfiguration.tryLoadForProjectAsync(project, terminal);
projectSelection.set(project, projectConfiguration);
projectConfiguration?.validatePhaseConfiguration(this._initialPhases, terminal);
});
terminal.writeVerboseLine(`Loaded.`);

const isWatch: boolean = this._watchParameter?.value || this._alwaysWatch;

Expand All @@ -328,7 +339,7 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> {
phaseSelection: new Set(this._initialPhases),
projectChangeAnalyzer,
projectSelection,
projectsInUnknownState: projectSelection
projectsInUnknownState: selectedProjects
};

const executionManagerOptions: IOperationExecutionManagerOptions = {
Expand Down Expand Up @@ -397,7 +408,7 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> {

const phaseSelection: Set<IPhase> = new Set(this._watchPhases);

const { projectChangeAnalyzer: initialState, projectSelection: projectsToWatch } =
const { projectChangeAnalyzer: initialState, projectsInUnknownState: projectsToWatch } =
initialCreateOperationsContext;

// Use async import so that we don't pay the cost for sync builds
Expand Down Expand Up @@ -494,13 +505,13 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> {
executionManagerOptions
);

const { isInitial, isWatch } = options.createOperationsContext;
const { isInitial, isWatch, projectChangeAnalyzer } = options.createOperationsContext;

let success: boolean = false;
let result: IExecutionResult | undefined;

try {
result = await executionManager.executeAsync();
result = await executionManager.executeAsync(projectChangeAnalyzer);
success = result.status === OperationStatus.Success;

await this.hooks.afterExecuteOperations.promise(result, options.createOperationsContext);
Expand Down
Loading