@rushstack/rush-sdk 5.137.0 → 5.138.0-pr4476.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -165,6 +165,10 @@ export declare class BuildCacheConfiguration {
165
165
  * The provider for interacting with the cloud build cache, if configured.
166
166
  */
167
167
  readonly cloudCacheProvider: ICloudBuildCacheProvider | undefined;
168
+ /**
169
+ * An optional salt to inject during calculation of the cache key. This can be used to invalidate the cache for all projects when the salt changes.
170
+ */
171
+ readonly cacheHashSalt: string | undefined;
168
172
  private constructor();
169
173
  /**
170
174
  * Attempts to load the build-cache.json data from the standard file path `common/config/rush/build-cache.json`.
@@ -965,6 +969,15 @@ export declare class _FlagFile<TState extends JsonObject = JsonObject> {
965
969
  */
966
970
  export declare type GetCacheEntryIdFunction = (options: IGenerateCacheEntryIdOptions) => string;
967
971
 
972
+ /**
973
+ * Function that computes a new snapshot of the current state of the repository as of the current moment.
974
+ * Rush-level configuration state will have been bound during creation of the function.
975
+ * Captures the state of the environment, tracked files, and additional files.
976
+ *
977
+ * @beta
978
+ */
979
+ export declare type GetInputsSnapshotAsyncFn = () => Promise<IInputsSnapshot | undefined>;
980
+
968
981
  /**
969
982
  * Part of IRushConfigurationJson.
970
983
  */
@@ -994,6 +1007,10 @@ declare interface IBaseBuildCacheJson {
994
1007
  * The token parser is in CacheEntryId.ts
995
1008
  */
996
1009
  cacheEntryNamePattern?: string;
1010
+ /**
1011
+ * An optional salt to inject during calculation of the cache key. This can be used to invalidate the cache for all projects when the salt changes.
1012
+ */
1013
+ cacheHashSalt?: string;
997
1014
  }
998
1015
 
999
1016
  /**
@@ -1342,11 +1359,10 @@ declare interface IEventHooksJson {
1342
1359
  */
1343
1360
  export declare interface IExecuteOperationsContext extends ICreateOperationsContext {
1344
1361
  /**
1345
- * The current state of the repository.
1346
- *
1347
- * Note that this is not defined during the initial operation creation.
1362
+ * The current state of the repository, if available.
1363
+ * Not part of the creation context to avoid the overhead of Git calls when initializing the graph.
1348
1364
  */
1349
- readonly projectChangeAnalyzer: ProjectChangeAnalyzer;
1365
+ readonly inputsSnapshot?: IInputsSnapshot;
1350
1366
  }
1351
1367
 
1352
1368
  /**
@@ -1522,6 +1538,40 @@ declare interface IIndividualVersionJson extends IVersionPolicyJson {
1522
1538
  lockedMajor?: number;
1523
1539
  }
1524
1540
 
1541
+ /**
1542
+ * Represents a synchronously-queryable in-memory snapshot of the state of the inputs to a Rush repository.
1543
+ *
1544
+ * The methods on this interface are idempotent and will return the same result regardless of when they are executed.
1545
+ * @beta
1546
+ */
1547
+ export declare interface IInputsSnapshot {
1548
+ /**
1549
+ * The raw hashes of all tracked files in the repository.
1550
+ */
1551
+ readonly hashes: ReadonlyMap<string, string>;
1552
+ /**
1553
+ * The directory that all paths in `hashes` are relative to.
1554
+ */
1555
+ readonly rootDirectory: string;
1556
+ /**
1557
+ * Gets the map of file paths to Git hashes that will be used to compute the local state hash of the operation.
1558
+ * Exposed separately from the final state hash to facilitate detailed change detection.
1559
+ *
1560
+ * @param project - The Rush project to get hashes for
1561
+ * @param operationName - The name of the operation (phase) to get hashes for. If omitted, returns a default set for the project, as used for bulk commands.
1562
+ * @returns A map of file name to Git hash. For local files paths will be relative. Configured additional files may be absolute paths.
1563
+ */
1564
+ getTrackedFileHashesForOperation(project: IRushConfigurationProjectForSnapshot, operationName?: string): ReadonlyMap<string, string>;
1565
+ /**
1566
+ * Gets the state hash for the files owned by this operation, including the resolutions of package.json dependencies. This will later be combined with the hash of
1567
+ * the command being executed and the final hashes of the operation's dependencies to compute the final hash for the operation.
1568
+ * @param project - The Rush project to compute the state hash for
1569
+ * @param operationName - The name of the operation (phase) to get hashes for. If omitted, returns a generic hash for the whole project, as used for bulk commands.
1570
+ * @returns The local state hash for the project. This is a hash of the environment, the project's tracked files, and any additional files.
1571
+ */
1572
+ getOperationOwnStateHash(project: IRushConfigurationProjectForSnapshot, operationName?: string): string;
1573
+ }
1574
+
1525
1575
  /**
1526
1576
  * Options to pass to the rush "launch" functions.
1527
1577
  *
@@ -1689,6 +1739,10 @@ export declare interface IOperationExecutionResult {
1689
1739
  * it later (for example to re-print errors at end of execution).
1690
1740
  */
1691
1741
  readonly error: Error | undefined;
1742
+ /**
1743
+ * If this operation is only present in the graph to maintain dependency relationships, this flag will be set to true.
1744
+ */
1745
+ readonly silent: boolean;
1692
1746
  /**
1693
1747
  * Object tracking execution timing.
1694
1748
  */
@@ -1705,6 +1759,10 @@ export declare interface IOperationExecutionResult {
1705
1759
  * The id of the runner which actually runs the building process in cobuild mode.
1706
1760
  */
1707
1761
  readonly cobuildRunnerId: string | undefined;
1762
+ /**
1763
+ * The relative path to the folder that contains operation metadata. This folder will be automatically included in cache entries.
1764
+ */
1765
+ readonly metadataFolderPath: string | undefined;
1708
1766
  /**
1709
1767
  * The paths to the log files, if applicable.
1710
1768
  */
@@ -2131,15 +2189,6 @@ export declare interface IPnpmPeerDependencyRules {
2131
2189
 
2132
2190
  export { IPrefixMatch }
2133
2191
 
2134
- /**
2135
- * @internal
2136
- */
2137
- export declare interface _IRawRepoState {
2138
- projectState: Map<RushConfigurationProject, Map<string, string>> | undefined;
2139
- rootDir: string;
2140
- rawHashes: Map<string, string>;
2141
- }
2142
-
2143
2192
  /**
2144
2193
  * Information about the currently executing command provided to plugins.
2145
2194
  * @beta
@@ -2234,6 +2283,11 @@ declare interface IRushConfigurationJson {
2234
2283
  variants?: IRushVariantOptionsJson[];
2235
2284
  }
2236
2285
 
2286
+ /**
2287
+ * @beta
2288
+ */
2289
+ export declare type IRushConfigurationProjectForSnapshot = Pick<RushConfigurationProject, 'projectFolder' | 'projectRelativeFolder'>;
2290
+
2237
2291
  /**
2238
2292
  * This represents the JSON data object for a project entry in the rush.json configuration file.
2239
2293
  */
@@ -2725,6 +2779,12 @@ export declare class Operation {
2725
2779
  * the project configuration.
2726
2780
  */
2727
2781
  settings: IOperationSettings | undefined;
2782
+ /**
2783
+ * If set to false, this operation will be skipped during evaluation (return OperationStatus.Skipped).
2784
+ * This is useful for plugins to alter the scope of the operation graph across executions,
2785
+ * e.g. to enable or disable unit test execution, or to include or exclude dependencies.
2786
+ */
2787
+ enabled: boolean;
2728
2788
  constructor(options: IOperationOptions);
2729
2789
  /**
2730
2790
  * The name of this operation, for logging.
@@ -2756,9 +2816,6 @@ export declare class _OperationMetadataManager {
2756
2816
  private readonly _logPath;
2757
2817
  private readonly _errorLogPath;
2758
2818
  private readonly _logChunksPath;
2759
- private readonly _relativeLogPath;
2760
- private readonly _relativeLogChunksPath;
2761
- private readonly _relativeErrorLogPath;
2762
2819
  constructor(options: _IOperationMetadataManagerOptions);
2763
2820
  /**
2764
2821
  * Returns the relative paths of the metadata files to project folder.
@@ -2767,7 +2824,7 @@ export declare class _OperationMetadataManager {
2767
2824
  * Example: `.rush/temp/operation/_phase_build/all.log`
2768
2825
  * Example: `.rush/temp/operation/_phase_build/error.log`
2769
2826
  */
2770
- get relativeFilepaths(): string[];
2827
+ get metadataFolderPath(): string;
2771
2828
  saveAsync({ durationInSeconds, cobuildContextId, cobuildRunnerId, logPath, errorLogPath, logChunksPath }: _IOperationMetadata): Promise<void>;
2772
2829
  tryRestoreAsync({ terminal, terminalProvider, errorLogPath }: {
2773
2830
  terminalProvider: ITerminalProvider;
@@ -3289,53 +3346,27 @@ export declare type PnpmStoreOptions = PnpmStoreLocation;
3289
3346
  * @beta
3290
3347
  */
3291
3348
  export declare class ProjectChangeAnalyzer {
3292
- /**
3293
- * UNINITIALIZED === we haven't looked
3294
- * undefined === data isn't available (i.e. - git isn't present)
3295
- */
3296
- private _data;
3297
- private readonly _filteredData;
3298
- private readonly _projectStateCache;
3299
3349
  private readonly _rushConfiguration;
3300
3350
  private readonly _git;
3301
3351
  constructor(rushConfiguration: RushConfiguration);
3302
3352
  /**
3303
- * Try to get a list of the specified project's dependencies and their hashes.
3304
- *
3305
- * @remarks
3306
- * If the data can't be generated (i.e. - if Git is not present) this returns undefined.
3307
- *
3308
- * @internal
3353
+ * Gets a list of projects that have changed in the current state of the repo
3354
+ * when compared to the specified branch, optionally taking the shrinkwrap and settings in
3355
+ * the rush-project.json file into consideration.
3309
3356
  */
3310
- _tryGetProjectDependenciesAsync(project: RushConfigurationProject, terminal: ITerminal): Promise<Map<string, string> | undefined>;
3357
+ getChangedProjectsAsync(options: IGetChangedProjectsOptions): Promise<Set<RushConfigurationProject>>;
3358
+ protected getChangesByProject(lookup: LookupByPath<RushConfigurationProject>, changedFiles: Map<string, IFileDiffStatus>): Map<RushConfigurationProject, Map<string, IFileDiffStatus>>;
3311
3359
  /**
3360
+ * Gets a snapshot of the input state of the Rush workspace that can be queried for incremental
3361
+ * build operations and use by the build cache.
3312
3362
  * @internal
3313
3363
  */
3314
- _ensureInitializedAsync(terminal: ITerminal): Promise<_IRawRepoState | undefined>;
3364
+ _tryGetSnapshotProviderAsync(projectConfigurations: ReadonlyMap<RushConfigurationProject, RushProjectConfiguration>, terminal: ITerminal): Promise<GetInputsSnapshotAsyncFn | undefined>;
3315
3365
  /**
3316
- * The project state hash is calculated in the following way:
3317
- * - Project dependencies are collected (see ProjectChangeAnalyzer.getPackageDeps)
3318
- * - If project dependencies cannot be collected (i.e. - if Git isn't available),
3319
- * this function returns `undefined`
3320
- * - The (path separator normalized) repo-root-relative dependencies' file paths are sorted
3321
- * - A SHA1 hash is created and each (sorted) file path is fed into the hash and then its
3322
- * Git SHA is fed into the hash
3323
- * - A hex digest of the hash is returned
3324
- *
3325
3366
  * @internal
3326
3367
  */
3327
- _tryGetProjectStateHashAsync(project: RushConfigurationProject, terminal: ITerminal): Promise<string | undefined>;
3328
3368
  _filterProjectDataAsync<T>(project: RushConfigurationProject, unfilteredProjectData: Map<string, T>, rootDir: string, terminal: ITerminal): Promise<Map<string, T>>;
3329
- /**
3330
- * Gets a list of projects that have changed in the current state of the repo
3331
- * when compared to the specified branch, optionally taking the shrinkwrap and settings in
3332
- * the rush-project.json file into consideration.
3333
- */
3334
- getChangedProjectsAsync(options: IGetChangedProjectsOptions): Promise<Set<RushConfigurationProject>>;
3335
- protected getChangesByProject(lookup: LookupByPath<RushConfigurationProject>, changedFiles: Map<string, IFileDiffStatus>): Map<RushConfigurationProject, Map<string, IFileDiffStatus>>;
3336
- private _getDataAsync;
3337
3369
  private _getIgnoreMatcherForProjectAsync;
3338
- private _getRepoDepsAsync;
3339
3370
  }
3340
3371
 
3341
3372
  /**
@@ -26,6 +26,10 @@ export interface IBaseBuildCacheJson {
26
26
  * The token parser is in CacheEntryId.ts
27
27
  */
28
28
  cacheEntryNamePattern?: string;
29
+ /**
30
+ * An optional salt to inject during calculation of the cache key. This can be used to invalidate the cache for all projects when the salt changes.
31
+ */
32
+ cacheHashSalt?: string;
29
33
  }
30
34
  /**
31
35
  * @public
@@ -72,6 +76,10 @@ export declare class BuildCacheConfiguration {
72
76
  * The provider for interacting with the cloud build cache, if configured.
73
77
  */
74
78
  readonly cloudCacheProvider: ICloudBuildCacheProvider | undefined;
79
+ /**
80
+ * An optional salt to inject during calculation of the cache key. This can be used to invalidate the cache for all projects when the salt changes.
81
+ */
82
+ readonly cacheHashSalt: string | undefined;
75
83
  private constructor();
76
84
  /**
77
85
  * Attempts to load the build-cache.json data from the standard file path `common/config/rush/build-cache.json`.
package/lib/index.d.ts CHANGED
@@ -36,7 +36,8 @@ export { type ILaunchOptions, Rush } from './api/Rush';
36
36
  export { RushInternals as _RushInternals } from './api/RushInternals';
37
37
  export { ExperimentsConfiguration, type IExperimentsJson } from './api/ExperimentsConfiguration';
38
38
  export { CustomTipsConfiguration, CustomTipId, type ICustomTipsJson, type ICustomTipInfo, type ICustomTipItemJson, CustomTipSeverity, CustomTipType } from './api/CustomTipsConfiguration';
39
- export { ProjectChangeAnalyzer, type IGetChangedProjectsOptions, type IRawRepoState as _IRawRepoState } from './logic/ProjectChangeAnalyzer';
39
+ export { ProjectChangeAnalyzer, type IGetChangedProjectsOptions } from './logic/ProjectChangeAnalyzer';
40
+ export type { IInputsSnapshot, GetInputsSnapshotAsyncFn as GetInputsSnapshotAsyncFn, IRushConfigurationProjectForSnapshot } from './logic/incremental/InputsSnapshot';
40
41
  export type { IOperationRunner, IOperationRunnerContext } from './logic/operations/IOperationRunner';
41
42
  export type { IExecutionResult, IOperationExecutionResult } from './logic/operations/IOperationExecutionResult';
42
43
  export { type IOperationOptions, Operation } from './logic/operations/Operation';
@@ -1,8 +1,10 @@
1
+ import type { LookupByPath } from '@rushstack/lookup-by-path';
1
2
  import { type IFileDiffStatus } from '@rushstack/package-deps-hash';
2
3
  import type { ITerminal } from '@rushstack/terminal';
3
4
  import type { RushConfiguration } from '../api/RushConfiguration';
5
+ import { RushProjectConfiguration } from '../api/RushProjectConfiguration';
4
6
  import type { RushConfigurationProject } from '../api/RushConfigurationProject';
5
- import type { LookupByPath } from '@rushstack/lookup-by-path';
7
+ import { type GetInputsSnapshotAsyncFn } from './incremental/InputsSnapshot';
6
8
  /**
7
9
  * @beta
8
10
  */
@@ -34,52 +36,26 @@ export interface IRawRepoState {
34
36
  * @beta
35
37
  */
36
38
  export declare class ProjectChangeAnalyzer {
37
- /**
38
- * UNINITIALIZED === we haven't looked
39
- * undefined === data isn't available (i.e. - git isn't present)
40
- */
41
- private _data;
42
- private readonly _filteredData;
43
- private readonly _projectStateCache;
44
39
  private readonly _rushConfiguration;
45
40
  private readonly _git;
46
41
  constructor(rushConfiguration: RushConfiguration);
47
42
  /**
48
- * Try to get a list of the specified project's dependencies and their hashes.
49
- *
50
- * @remarks
51
- * If the data can't be generated (i.e. - if Git is not present) this returns undefined.
52
- *
53
- * @internal
43
+ * Gets a list of projects that have changed in the current state of the repo
44
+ * when compared to the specified branch, optionally taking the shrinkwrap and settings in
45
+ * the rush-project.json file into consideration.
54
46
  */
55
- _tryGetProjectDependenciesAsync(project: RushConfigurationProject, terminal: ITerminal): Promise<Map<string, string> | undefined>;
47
+ getChangedProjectsAsync(options: IGetChangedProjectsOptions): Promise<Set<RushConfigurationProject>>;
48
+ protected getChangesByProject(lookup: LookupByPath<RushConfigurationProject>, changedFiles: Map<string, IFileDiffStatus>): Map<RushConfigurationProject, Map<string, IFileDiffStatus>>;
56
49
  /**
50
+ * Gets a snapshot of the input state of the Rush workspace that can be queried for incremental
51
+ * build operations and use by the build cache.
57
52
  * @internal
58
53
  */
59
- _ensureInitializedAsync(terminal: ITerminal): Promise<IRawRepoState | undefined>;
54
+ _tryGetSnapshotProviderAsync(projectConfigurations: ReadonlyMap<RushConfigurationProject, RushProjectConfiguration>, terminal: ITerminal): Promise<GetInputsSnapshotAsyncFn | undefined>;
60
55
  /**
61
- * The project state hash is calculated in the following way:
62
- * - Project dependencies are collected (see ProjectChangeAnalyzer.getPackageDeps)
63
- * - If project dependencies cannot be collected (i.e. - if Git isn't available),
64
- * this function returns `undefined`
65
- * - The (path separator normalized) repo-root-relative dependencies' file paths are sorted
66
- * - A SHA1 hash is created and each (sorted) file path is fed into the hash and then its
67
- * Git SHA is fed into the hash
68
- * - A hex digest of the hash is returned
69
- *
70
56
  * @internal
71
57
  */
72
- _tryGetProjectStateHashAsync(project: RushConfigurationProject, terminal: ITerminal): Promise<string | undefined>;
73
58
  _filterProjectDataAsync<T>(project: RushConfigurationProject, unfilteredProjectData: Map<string, T>, rootDir: string, terminal: ITerminal): Promise<Map<string, T>>;
74
- /**
75
- * Gets a list of projects that have changed in the current state of the repo
76
- * when compared to the specified branch, optionally taking the shrinkwrap and settings in
77
- * the rush-project.json file into consideration.
78
- */
79
- getChangedProjectsAsync(options: IGetChangedProjectsOptions): Promise<Set<RushConfigurationProject>>;
80
- protected getChangesByProject(lookup: LookupByPath<RushConfigurationProject>, changedFiles: Map<string, IFileDiffStatus>): Map<RushConfigurationProject, Map<string, IFileDiffStatus>>;
81
- private _getDataAsync;
82
59
  private _getIgnoreMatcherForProjectAsync;
83
- private _getRepoDepsAsync;
84
60
  }
85
61
  //# sourceMappingURL=ProjectChangeAnalyzer.d.ts.map
@@ -1,23 +1,33 @@
1
1
  import type { ITerminal } from '@rushstack/terminal';
2
2
  import type { RushConfigurationProject } from '../../api/RushConfigurationProject';
3
- import type { ProjectChangeAnalyzer } from '../ProjectChangeAnalyzer';
4
3
  import type { BuildCacheConfiguration } from '../../api/BuildCacheConfiguration';
5
4
  export interface IProjectBuildCacheOptions {
5
+ /**
6
+ * The repo-wide configuration for the build cache.
7
+ */
6
8
  buildCacheConfiguration: BuildCacheConfiguration;
9
+ /**
10
+ * The project to be cached.
11
+ */
7
12
  project: RushConfigurationProject;
13
+ /**
14
+ * Value from rush-project.json
15
+ */
8
16
  projectOutputFolderNames: ReadonlyArray<string>;
9
- additionalProjectOutputFilePaths?: ReadonlyArray<string>;
10
- additionalContext?: Record<string, string>;
11
- configHash: string;
12
- projectChangeAnalyzer: ProjectChangeAnalyzer;
17
+ /**
18
+ * The hash of all relevant inputs and configuration that uniquely identifies this execution.
19
+ */
20
+ operationStateHash: string;
21
+ /**
22
+ * The terminal to use for logging.
23
+ */
13
24
  terminal: ITerminal;
25
+ /**
26
+ * The name of the phase that is being cached.
27
+ */
14
28
  phaseName: string;
15
29
  }
16
30
  export declare class ProjectBuildCache {
17
- /**
18
- * null === we haven't tried to initialize yet
19
- * undefined === unable to initialize
20
- */
21
31
  private static _tarUtilityPromise;
22
32
  private readonly _project;
23
33
  private readonly _localBuildCacheProvider;
@@ -25,12 +35,11 @@ export declare class ProjectBuildCache {
25
35
  private readonly _buildCacheEnabled;
26
36
  private readonly _cacheWriteEnabled;
27
37
  private readonly _projectOutputFolderNames;
28
- private readonly _additionalProjectOutputFilePaths;
29
- private _cacheId;
38
+ private readonly _cacheId;
30
39
  private constructor();
31
40
  private static _tryGetTarUtility;
32
41
  get cacheId(): string | undefined;
33
- static tryGetProjectBuildCacheAsync(options: IProjectBuildCacheOptions): Promise<ProjectBuildCache | undefined>;
42
+ static getProjectBuildCache(options: IProjectBuildCacheOptions): ProjectBuildCache;
34
43
  tryRestoreFromCacheAsync(terminal: ITerminal, specifiedCacheId?: string): Promise<boolean>;
35
44
  trySetCacheEntryAsync(terminal: ITerminal, specifiedCacheId?: string): Promise<boolean>;
36
45
  /**
@@ -40,6 +49,6 @@ export declare class ProjectBuildCache {
40
49
  */
41
50
  private _tryCollectPathsToCacheAsync;
42
51
  private _getTarLogFilePath;
43
- private static _getCacheIdAsync;
52
+ private static _getCacheId;
44
53
  }
45
54
  //# sourceMappingURL=ProjectBuildCache.d.ts.map
@@ -0,0 +1,149 @@
1
+ import { type IReadonlyLookupByPath } from '@rushstack/lookup-by-path';
2
+ import type { RushConfigurationProject } from '../../api/RushConfigurationProject';
3
+ import type { RushProjectConfiguration } from '../../api/RushProjectConfiguration';
4
+ /**
5
+ * @beta
6
+ */
7
+ export type IRushConfigurationProjectForSnapshot = Pick<RushConfigurationProject, 'projectFolder' | 'projectRelativeFolder'>;
8
+ /**
9
+ * @internal
10
+ */
11
+ export interface IInputsSnapshotProjectMetadata {
12
+ /**
13
+ * The contents of rush-project.json for the project, if available
14
+ */
15
+ projectConfig?: RushProjectConfiguration;
16
+ /**
17
+ * A map of operation name to additional files that should be included in the hash for that operation.
18
+ */
19
+ additionalFilesByOperationName?: ReadonlyMap<string, ReadonlySet<string>>;
20
+ }
21
+ export type IRushSnapshotProjectMetadataMap = ReadonlyMap<IRushConfigurationProjectForSnapshot, IInputsSnapshotProjectMetadata>;
22
+ /**
23
+ * Function that computes a new snapshot of the current state of the repository as of the current moment.
24
+ * Rush-level configuration state will have been bound during creation of the function.
25
+ * Captures the state of the environment, tracked files, and additional files.
26
+ *
27
+ * @beta
28
+ */
29
+ export type GetInputsSnapshotAsyncFn = () => Promise<IInputsSnapshot | undefined>;
30
+ /**
31
+ * The parameters for constructing an {@link InputsSnapshot}.
32
+ * @internal
33
+ */
34
+ export interface IInputsSnapshotParameters {
35
+ /**
36
+ * Hashes for files selected by `dependsOnAdditionalFiles`.
37
+ * Separated out to prevent being auto-assigned to a project.
38
+ */
39
+ additionalHashes?: ReadonlyMap<string, string>;
40
+ /**
41
+ * The environment to use for `dependsOnEnvVars`. By default performs a snapshot of process.env upon construction.
42
+ * @defaultValue \{ ...process.env \}
43
+ */
44
+ environment?: Record<string, string | undefined>;
45
+ /**
46
+ * File paths (keys into additionalHashes or hashes) to be included as part of every operation's dependencies.
47
+ */
48
+ globalAdditionalFiles?: Iterable<string>;
49
+ /**
50
+ * The hashes of all tracked files in the repository.
51
+ */
52
+ hashes: ReadonlyMap<string, string>;
53
+ /**
54
+ * Optimized lookup engine used to route `hashes` to individual projects.
55
+ */
56
+ lookupByPath: IReadonlyLookupByPath<IRushConfigurationProjectForSnapshot>;
57
+ /**
58
+ * Metadata for each project.
59
+ */
60
+ projectMap: IRushSnapshotProjectMetadataMap;
61
+ /**
62
+ * The directory that all relative paths are relative to.
63
+ */
64
+ rootDir: string;
65
+ }
66
+ /**
67
+ * Represents a synchronously-queryable in-memory snapshot of the state of the inputs to a Rush repository.
68
+ *
69
+ * The methods on this interface are idempotent and will return the same result regardless of when they are executed.
70
+ * @beta
71
+ */
72
+ export interface IInputsSnapshot {
73
+ /**
74
+ * The raw hashes of all tracked files in the repository.
75
+ */
76
+ readonly hashes: ReadonlyMap<string, string>;
77
+ /**
78
+ * The directory that all paths in `hashes` are relative to.
79
+ */
80
+ readonly rootDirectory: string;
81
+ /**
82
+ * Gets the map of file paths to Git hashes that will be used to compute the local state hash of the operation.
83
+ * Exposed separately from the final state hash to facilitate detailed change detection.
84
+ *
85
+ * @param project - The Rush project to get hashes for
86
+ * @param operationName - The name of the operation (phase) to get hashes for. If omitted, returns a default set for the project, as used for bulk commands.
87
+ * @returns A map of file name to Git hash. For local files paths will be relative. Configured additional files may be absolute paths.
88
+ */
89
+ getTrackedFileHashesForOperation(project: IRushConfigurationProjectForSnapshot, operationName?: string): ReadonlyMap<string, string>;
90
+ /**
91
+ * Gets the state hash for the files owned by this operation, including the resolutions of package.json dependencies. This will later be combined with the hash of
92
+ * the command being executed and the final hashes of the operation's dependencies to compute the final hash for the operation.
93
+ * @param project - The Rush project to compute the state hash for
94
+ * @param operationName - The name of the operation (phase) to get hashes for. If omitted, returns a generic hash for the whole project, as used for bulk commands.
95
+ * @returns The local state hash for the project. This is a hash of the environment, the project's tracked files, and any additional files.
96
+ */
97
+ getOperationOwnStateHash(project: IRushConfigurationProjectForSnapshot, operationName?: string): string;
98
+ }
99
+ /**
100
+ * Represents a synchronously-queryable in-memory snapshot of the state of the inputs to a Rush repository.
101
+ * Any asynchronous work needs to be performed by the caller and the results passed to the constructor.
102
+ *
103
+ * @remarks
104
+ * All operations on this class will return the same result regardless of when they are executed.
105
+ *
106
+ * @internal
107
+ */
108
+ export declare class InputsSnapshot implements IInputsSnapshot {
109
+ /**
110
+ * {@inheritdoc IInputsSnapshot.hashes}
111
+ */
112
+ readonly hashes: ReadonlyMap<string, string>;
113
+ /**
114
+ * {@inheritdoc IInputsSnapshot.rootDirectory}
115
+ */
116
+ readonly rootDirectory: string;
117
+ /**
118
+ * The metadata for each project. This is a superset of the information in `projectMap` and includes caching of queries.
119
+ */
120
+ private readonly _projectMetadataMap;
121
+ /**
122
+ * Hashes of files to be included in all result sets.
123
+ */
124
+ private readonly _globalAdditionalHashes;
125
+ /**
126
+ * Hashes for files selected by `dependsOnAdditionalFiles`.
127
+ */
128
+ private readonly _additionalHashes;
129
+ /**
130
+ * The environment to use for `dependsOnEnvVars`.
131
+ */
132
+ private readonly _environment;
133
+ /**
134
+ *
135
+ * @param params - The parameters for the snapshot
136
+ * @internal
137
+ */
138
+ constructor(params: IInputsSnapshotParameters);
139
+ /**
140
+ * {@inheritdoc}
141
+ */
142
+ getTrackedFileHashesForOperation(project: IRushConfigurationProjectForSnapshot, operationName?: string): ReadonlyMap<string, string>;
143
+ /**
144
+ * {@inheritdoc}
145
+ */
146
+ getOperationOwnStateHash(project: IRushConfigurationProjectForSnapshot, operationName?: string): string;
147
+ private _resolveHashes;
148
+ }
149
+ //# sourceMappingURL=InputsSnapshot.d.ts.map
@@ -1 +1 @@
1
- module.exports = require("../../../lib-shim/index")._rushSdk_loadInternalModule("logic/buildCache/getHashesForGlobsAsync");
1
+ module.exports = require("../../../lib-shim/index")._rushSdk_loadInternalModule("logic/incremental/InputsSnapshot");
@@ -1,13 +1,11 @@
1
1
  import { type TerminalWritable, type ITerminal } from '@rushstack/terminal';
2
2
  import { CobuildLock } from '../cobuild/CobuildLock';
3
3
  import { ProjectBuildCache } from '../buildCache/ProjectBuildCache';
4
- import { type IOperationSettings } from '../../api/RushProjectConfiguration';
5
4
  import type { CobuildConfiguration } from '../../api/CobuildConfiguration';
6
5
  import { DisjointSet } from '../cobuild/DisjointSet';
7
6
  import { PeriodicCallback } from './PeriodicCallback';
8
7
  import type { Operation } from './Operation';
9
8
  import type { IPhasedCommandPlugin, PhasedCommandHooks } from '../../pluginFramework/PhasedCommandHooks';
10
- import type { ProjectChangeAnalyzer } from '../ProjectChangeAnalyzer';
11
9
  import type { BuildCacheConfiguration } from '../../api/BuildCacheConfiguration';
12
10
  export interface IProjectDeps {
13
11
  files: {
@@ -18,10 +16,10 @@ export interface IProjectDeps {
18
16
  export interface IOperationBuildCacheContext {
19
17
  isCacheWriteAllowed: boolean;
20
18
  isCacheReadAllowed: boolean;
21
- projectChangeAnalyzer: ProjectChangeAnalyzer;
22
- projectBuildCache: ProjectBuildCache | undefined;
19
+ stateHash: string;
20
+ operationBuildCache: ProjectBuildCache | undefined;
23
21
  cacheDisabledReason: string | undefined;
24
- operationSettings: IOperationSettings | undefined;
22
+ outputFolderNames: ReadonlyArray<string>;
25
23
  cobuildLock: CobuildLock | undefined;
26
24
  cobuildClusterId: string | undefined;
27
25
  buildCacheTerminal: ITerminal | undefined;
@@ -43,7 +41,7 @@ export declare class CacheableOperationPlugin implements IPhasedCommandPlugin {
43
41
  apply(hooks: PhasedCommandHooks): void;
44
42
  private _getBuildCacheContextByOperation;
45
43
  private _getBuildCacheContextByOperationOrThrow;
46
- private _tryGetProjectBuildCacheAsync;
44
+ private _tryGetProjectBuildCache;
47
45
  private _tryGetLogOnlyProjectBuildCacheAsync;
48
46
  private _tryGetCobuildLockAsync;
49
47
  private _createBuildCacheTerminalAsync;
@@ -24,6 +24,10 @@ export interface IOperationExecutionResult {
24
24
  * it later (for example to re-print errors at end of execution).
25
25
  */
26
26
  readonly error: Error | undefined;
27
+ /**
28
+ * If this operation is only present in the graph to maintain dependency relationships, this flag will be set to true.
29
+ */
30
+ readonly silent: boolean;
27
31
  /**
28
32
  * Object tracking execution timing.
29
33
  */
@@ -40,6 +44,10 @@ export interface IOperationExecutionResult {
40
44
  * The id of the runner which actually runs the building process in cobuild mode.
41
45
  */
42
46
  readonly cobuildRunnerId: string | undefined;
47
+ /**
48
+ * The relative path to the folder that contains operation metadata. This folder will be automatically included in cache entries.
49
+ */
50
+ readonly metadataFolderPath: string | undefined;
43
51
  /**
44
52
  * The paths to the log files, if applicable.
45
53
  */
@@ -83,6 +83,12 @@ export declare class Operation {
83
83
  * the project configuration.
84
84
  */
85
85
  settings: IOperationSettings | undefined;
86
+ /**
87
+ * If set to false, this operation will be skipped during evaluation (return OperationStatus.Skipped).
88
+ * This is useful for plugins to alter the scope of the operation graph across executions,
89
+ * e.g. to enable or disable unit test execution, or to include or exclude dependencies.
90
+ */
91
+ enabled: boolean;
86
92
  constructor(options: IOperationOptions);
87
93
  /**
88
94
  * The name of this operation, for logging.
@@ -8,6 +8,7 @@ import { OperationMetadataManager } from './OperationMetadataManager';
8
8
  import type { IPhase } from '../../api/CommandLineConfiguration';
9
9
  import type { RushConfigurationProject } from '../../api/RushConfigurationProject';
10
10
  import { type ILogFilePaths } from './ProjectLogWritable';
11
+ import type { IOperationExecutionResult } from './IOperationExecutionResult';
11
12
  export interface IOperationExecutionRecordContext {
12
13
  streamCollator: StreamCollator;
13
14
  onOperationStatusChanged?: (record: OperationExecutionRecord) => void;
@@ -19,7 +20,7 @@ export interface IOperationExecutionRecordContext {
19
20
  *
20
21
  * @internal
21
22
  */
22
- export declare class OperationExecutionRecord implements IOperationRunnerContext {
23
+ export declare class OperationExecutionRecord implements IOperationRunnerContext, IOperationExecutionResult {
23
24
  /**
24
25
  * The associated operation.
25
26
  */
@@ -87,6 +88,7 @@ export declare class OperationExecutionRecord implements IOperationRunnerContext
87
88
  get collatedWriter(): CollatedWriter;
88
89
  get nonCachedDurationMs(): number | undefined;
89
90
  get cobuildRunnerId(): string | undefined;
91
+ get metadataFolderPath(): string | undefined;
90
92
  get isTerminal(): boolean;
91
93
  /**
92
94
  * The current execution status of an operation. Operations start in the 'ready' state,
@@ -96,6 +98,7 @@ export declare class OperationExecutionRecord implements IOperationRunnerContext
96
98
  */
97
99
  get status(): OperationStatus;
98
100
  set status(newStatus: OperationStatus);
101
+ get silent(): boolean;
99
102
  /**
100
103
  * {@inheritdoc IOperationRunnerContext.runWithTerminalAsync}
101
104
  */
@@ -37,9 +37,6 @@ export declare class OperationMetadataManager {
37
37
  private readonly _logPath;
38
38
  private readonly _errorLogPath;
39
39
  private readonly _logChunksPath;
40
- private readonly _relativeLogPath;
41
- private readonly _relativeLogChunksPath;
42
- private readonly _relativeErrorLogPath;
43
40
  constructor(options: IOperationMetadataManagerOptions);
44
41
  /**
45
42
  * Returns the relative paths of the metadata files to project folder.
@@ -48,7 +45,7 @@ export declare class OperationMetadataManager {
48
45
  * Example: `.rush/temp/operation/_phase_build/all.log`
49
46
  * Example: `.rush/temp/operation/_phase_build/error.log`
50
47
  */
51
- get relativeFilepaths(): string[];
48
+ get metadataFolderPath(): string;
52
49
  saveAsync({ durationInSeconds, cobuildContextId, cobuildRunnerId, logPath, errorLogPath, logChunksPath }: IOperationMetaData): Promise<void>;
53
50
  tryRestoreAsync({ terminal, terminalProvider, errorLogPath }: {
54
51
  terminalProvider: ITerminalProvider;
@@ -8,6 +8,7 @@ export interface IOperationRunnerOptions {
8
8
  rushProject: RushConfigurationProject;
9
9
  rushConfiguration: RushConfiguration;
10
10
  commandToRun: string;
11
+ commandForHash: string;
11
12
  displayName: string;
12
13
  phase: IPhase;
13
14
  environment?: IEnvironment;
@@ -24,6 +25,7 @@ export declare class ShellOperationRunner implements IOperationRunner {
24
25
  readonly cacheable: boolean;
25
26
  readonly warningsAreAllowed: boolean;
26
27
  private readonly _commandToRun;
28
+ private readonly _commandForHash;
27
29
  private readonly _rushProject;
28
30
  private readonly _rushConfiguration;
29
31
  private readonly _environment?;
@@ -16,8 +16,9 @@ export declare function initializeShellOperationRunner(options: {
16
16
  displayName: string;
17
17
  rushConfiguration: RushConfiguration;
18
18
  commandToRun: string | undefined;
19
+ commandForHash?: string;
20
+ customParameterValues: ReadonlyArray<string>;
19
21
  }): IOperationRunner;
20
- export declare function getScriptToRun(rushProject: RushConfigurationProject, commandToRun: string, shellCommand: string | undefined): string | undefined;
21
22
  /**
22
23
  * Memoizer for custom parameter values by phase
23
24
  * @returns A function that returns the custom parameter values for a given phase
@@ -5,13 +5,13 @@ import type { IPhase } from '../api/CommandLineConfiguration';
5
5
  import type { RushConfiguration } from '../api/RushConfiguration';
6
6
  import type { RushConfigurationProject } from '../api/RushConfigurationProject';
7
7
  import type { Operation } from '../logic/operations/Operation';
8
- import type { ProjectChangeAnalyzer } from '../logic/ProjectChangeAnalyzer';
9
8
  import type { IExecutionResult, IOperationExecutionResult } from '../logic/operations/IOperationExecutionResult';
10
9
  import type { CobuildConfiguration } from '../api/CobuildConfiguration';
11
10
  import type { RushProjectConfiguration } from '../api/RushProjectConfiguration';
12
11
  import type { IOperationRunnerContext } from '../logic/operations/IOperationRunner';
13
12
  import type { ITelemetryData } from '../logic/Telemetry';
14
13
  import type { OperationStatus } from '../logic/operations/OperationStatus';
14
+ import type { IInputsSnapshot } from '../logic/incremental/InputsSnapshot';
15
15
  /**
16
16
  * A plugin that interacts with a phased commands.
17
17
  * @alpha
@@ -92,11 +92,10 @@ export interface ICreateOperationsContext {
92
92
  */
93
93
  export interface IExecuteOperationsContext extends ICreateOperationsContext {
94
94
  /**
95
- * The current state of the repository.
96
- *
97
- * Note that this is not defined during the initial operation creation.
95
+ * The current state of the repository, if available.
96
+ * Not part of the creation context to avoid the overhead of Git calls when initializing the graph.
98
97
  */
99
- readonly projectChangeAnalyzer: ProjectChangeAnalyzer;
98
+ readonly inputsSnapshot?: IInputsSnapshot;
100
99
  }
101
100
  /**
102
101
  * Hooks into the execution process for phased commands
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/rush-sdk",
3
- "version": "5.137.0",
3
+ "version": "5.138.0-pr4476.0",
4
4
  "description": "An API for interacting with the Rush engine",
5
5
  "repository": {
6
6
  "type": "git",
@@ -45,11 +45,11 @@
45
45
  "@types/webpack-env": "1.18.0",
46
46
  "webpack": "~5.95.0",
47
47
  "@rushstack/heft": "0.68.2",
48
- "@microsoft/rush-lib": "5.137.0",
49
- "@rushstack/stream-collator": "4.1.70",
50
48
  "local-node-rig": "1.0.0",
49
+ "@microsoft/rush-lib": "5.138.0-pr4476.0",
51
50
  "@rushstack/heft-webpack5-plugin": "0.11.0",
52
51
  "@rushstack/ts-command-line": "4.22.8",
52
+ "@rushstack/stream-collator": "4.1.70",
53
53
  "@rushstack/webpack-preserve-dynamic-require-plugin": "0.11.69"
54
54
  },
55
55
  "scripts": {
@@ -1,3 +0,0 @@
1
- import type { IRawRepoState } from '../ProjectChangeAnalyzer';
2
- export declare function getHashesForGlobsAsync(globPatterns: Iterable<string>, packagePath: string, repoState: IRawRepoState | undefined): Promise<Map<string, string>>;
3
- //# sourceMappingURL=getHashesForGlobsAsync.d.ts.map