@rushstack/rush-sdk 5.136.1 → 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.
@@ -13,6 +13,7 @@ import type { CollatedWriter } from '@rushstack/stream-collator';
13
13
  import type { CommandLineParameter } from '@rushstack/ts-command-line';
14
14
  import { CommandLineParameterKind } from '@rushstack/ts-command-line';
15
15
  import { HookMap } from 'tapable';
16
+ import { IFileDiffStatus } from '@rushstack/package-deps-hash';
16
17
  import { IPackageJson } from '@rushstack/node-core-library';
17
18
  import { IPrefixMatch } from '@rushstack/lookup-by-path';
18
19
  import { ITerminal } from '@rushstack/terminal';
@@ -164,6 +165,10 @@ export declare class BuildCacheConfiguration {
164
165
  * The provider for interacting with the cloud build cache, if configured.
165
166
  */
166
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;
167
172
  private constructor();
168
173
  /**
169
174
  * Attempts to load the build-cache.json data from the standard file path `common/config/rush/build-cache.json`.
@@ -964,6 +969,15 @@ export declare class _FlagFile<TState extends JsonObject = JsonObject> {
964
969
  */
965
970
  export declare type GetCacheEntryIdFunction = (options: IGenerateCacheEntryIdOptions) => string;
966
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
+
967
981
  /**
968
982
  * Part of IRushConfigurationJson.
969
983
  */
@@ -993,6 +1007,10 @@ declare interface IBaseBuildCacheJson {
993
1007
  * The token parser is in CacheEntryId.ts
994
1008
  */
995
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;
996
1014
  }
997
1015
 
998
1016
  /**
@@ -1341,11 +1359,10 @@ declare interface IEventHooksJson {
1341
1359
  */
1342
1360
  export declare interface IExecuteOperationsContext extends ICreateOperationsContext {
1343
1361
  /**
1344
- * The current state of the repository.
1345
- *
1346
- * 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.
1347
1364
  */
1348
- readonly projectChangeAnalyzer: ProjectChangeAnalyzer;
1365
+ readonly inputsSnapshot?: IInputsSnapshot;
1349
1366
  }
1350
1367
 
1351
1368
  /**
@@ -1521,6 +1538,40 @@ declare interface IIndividualVersionJson extends IVersionPolicyJson {
1521
1538
  lockedMajor?: number;
1522
1539
  }
1523
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
+
1524
1575
  /**
1525
1576
  * Options to pass to the rush "launch" functions.
1526
1577
  *
@@ -1688,6 +1739,10 @@ export declare interface IOperationExecutionResult {
1688
1739
  * it later (for example to re-print errors at end of execution).
1689
1740
  */
1690
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;
1691
1746
  /**
1692
1747
  * Object tracking execution timing.
1693
1748
  */
@@ -1704,6 +1759,10 @@ export declare interface IOperationExecutionResult {
1704
1759
  * The id of the runner which actually runs the building process in cobuild mode.
1705
1760
  */
1706
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;
1707
1766
  /**
1708
1767
  * The paths to the log files, if applicable.
1709
1768
  */
@@ -2130,15 +2189,6 @@ export declare interface IPnpmPeerDependencyRules {
2130
2189
 
2131
2190
  export { IPrefixMatch }
2132
2191
 
2133
- /**
2134
- * @internal
2135
- */
2136
- export declare interface _IRawRepoState {
2137
- projectState: Map<RushConfigurationProject, Map<string, string>> | undefined;
2138
- rootDir: string;
2139
- rawHashes: Map<string, string>;
2140
- }
2141
-
2142
2192
  /**
2143
2193
  * Information about the currently executing command provided to plugins.
2144
2194
  * @beta
@@ -2233,6 +2283,11 @@ declare interface IRushConfigurationJson {
2233
2283
  variants?: IRushVariantOptionsJson[];
2234
2284
  }
2235
2285
 
2286
+ /**
2287
+ * @beta
2288
+ */
2289
+ export declare type IRushConfigurationProjectForSnapshot = Pick<RushConfigurationProject, 'projectFolder' | 'projectRelativeFolder'>;
2290
+
2236
2291
  /**
2237
2292
  * This represents the JSON data object for a project entry in the rush.json configuration file.
2238
2293
  */
@@ -2724,6 +2779,12 @@ export declare class Operation {
2724
2779
  * the project configuration.
2725
2780
  */
2726
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;
2727
2788
  constructor(options: IOperationOptions);
2728
2789
  /**
2729
2790
  * The name of this operation, for logging.
@@ -2755,9 +2816,6 @@ export declare class _OperationMetadataManager {
2755
2816
  private readonly _logPath;
2756
2817
  private readonly _errorLogPath;
2757
2818
  private readonly _logChunksPath;
2758
- private readonly _relativeLogPath;
2759
- private readonly _relativeLogChunksPath;
2760
- private readonly _relativeErrorLogPath;
2761
2819
  constructor(options: _IOperationMetadataManagerOptions);
2762
2820
  /**
2763
2821
  * Returns the relative paths of the metadata files to project folder.
@@ -2766,7 +2824,7 @@ export declare class _OperationMetadataManager {
2766
2824
  * Example: `.rush/temp/operation/_phase_build/all.log`
2767
2825
  * Example: `.rush/temp/operation/_phase_build/error.log`
2768
2826
  */
2769
- get relativeFilepaths(): string[];
2827
+ get metadataFolderPath(): string;
2770
2828
  saveAsync({ durationInSeconds, cobuildContextId, cobuildRunnerId, logPath, errorLogPath, logChunksPath }: _IOperationMetadata): Promise<void>;
2771
2829
  tryRestoreAsync({ terminal, terminalProvider, errorLogPath }: {
2772
2830
  terminalProvider: ITerminalProvider;
@@ -3288,52 +3346,27 @@ export declare type PnpmStoreOptions = PnpmStoreLocation;
3288
3346
  * @beta
3289
3347
  */
3290
3348
  export declare class ProjectChangeAnalyzer {
3291
- /**
3292
- * UNINITIALIZED === we haven't looked
3293
- * undefined === data isn't available (i.e. - git isn't present)
3294
- */
3295
- private _data;
3296
- private readonly _filteredData;
3297
- private readonly _projectStateCache;
3298
3349
  private readonly _rushConfiguration;
3299
3350
  private readonly _git;
3300
3351
  constructor(rushConfiguration: RushConfiguration);
3301
3352
  /**
3302
- * Try to get a list of the specified project's dependencies and their hashes.
3303
- *
3304
- * @remarks
3305
- * If the data can't be generated (i.e. - if Git is not present) this returns undefined.
3306
- *
3307
- * @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.
3308
3356
  */
3309
- _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>>;
3310
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.
3311
3362
  * @internal
3312
3363
  */
3313
- _ensureInitializedAsync(terminal: ITerminal): Promise<_IRawRepoState | undefined>;
3364
+ _tryGetSnapshotProviderAsync(projectConfigurations: ReadonlyMap<RushConfigurationProject, RushProjectConfiguration>, terminal: ITerminal): Promise<GetInputsSnapshotAsyncFn | undefined>;
3314
3365
  /**
3315
- * The project state hash is calculated in the following way:
3316
- * - Project dependencies are collected (see ProjectChangeAnalyzer.getPackageDeps)
3317
- * - If project dependencies cannot be collected (i.e. - if Git isn't available),
3318
- * this function returns `undefined`
3319
- * - The (path separator normalized) repo-root-relative dependencies' file paths are sorted
3320
- * - A SHA1 hash is created and each (sorted) file path is fed into the hash and then its
3321
- * Git SHA is fed into the hash
3322
- * - A hex digest of the hash is returned
3323
- *
3324
3366
  * @internal
3325
3367
  */
3326
- _tryGetProjectStateHashAsync(project: RushConfigurationProject, terminal: ITerminal): Promise<string | undefined>;
3327
3368
  _filterProjectDataAsync<T>(project: RushConfigurationProject, unfilteredProjectData: Map<string, T>, rootDir: string, terminal: ITerminal): Promise<Map<string, T>>;
3328
- /**
3329
- * Gets a list of projects that have changed in the current state of the repo
3330
- * when compared to the specified branch, optionally taking the shrinkwrap and settings in
3331
- * the rush-project.json file into consideration.
3332
- */
3333
- getChangedProjectsAsync(options: IGetChangedProjectsOptions): Promise<Set<RushConfigurationProject>>;
3334
- private _getDataAsync;
3335
3369
  private _getIgnoreMatcherForProjectAsync;
3336
- private _getRepoDepsAsync;
3337
3370
  }
3338
3371
 
3339
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,6 +1,10 @@
1
+ import type { LookupByPath } from '@rushstack/lookup-by-path';
2
+ import { type IFileDiffStatus } from '@rushstack/package-deps-hash';
1
3
  import type { ITerminal } from '@rushstack/terminal';
2
4
  import type { RushConfiguration } from '../api/RushConfiguration';
5
+ import { RushProjectConfiguration } from '../api/RushProjectConfiguration';
3
6
  import type { RushConfigurationProject } from '../api/RushConfigurationProject';
7
+ import { type GetInputsSnapshotAsyncFn } from './incremental/InputsSnapshot';
4
8
  /**
5
9
  * @beta
6
10
  */
@@ -32,51 +36,26 @@ export interface IRawRepoState {
32
36
  * @beta
33
37
  */
34
38
  export declare class ProjectChangeAnalyzer {
35
- /**
36
- * UNINITIALIZED === we haven't looked
37
- * undefined === data isn't available (i.e. - git isn't present)
38
- */
39
- private _data;
40
- private readonly _filteredData;
41
- private readonly _projectStateCache;
42
39
  private readonly _rushConfiguration;
43
40
  private readonly _git;
44
41
  constructor(rushConfiguration: RushConfiguration);
45
42
  /**
46
- * Try to get a list of the specified project's dependencies and their hashes.
47
- *
48
- * @remarks
49
- * If the data can't be generated (i.e. - if Git is not present) this returns undefined.
50
- *
51
- * @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.
52
46
  */
53
- _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>>;
54
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.
55
52
  * @internal
56
53
  */
57
- _ensureInitializedAsync(terminal: ITerminal): Promise<IRawRepoState | undefined>;
54
+ _tryGetSnapshotProviderAsync(projectConfigurations: ReadonlyMap<RushConfigurationProject, RushProjectConfiguration>, terminal: ITerminal): Promise<GetInputsSnapshotAsyncFn | undefined>;
58
55
  /**
59
- * The project state hash is calculated in the following way:
60
- * - Project dependencies are collected (see ProjectChangeAnalyzer.getPackageDeps)
61
- * - If project dependencies cannot be collected (i.e. - if Git isn't available),
62
- * this function returns `undefined`
63
- * - The (path separator normalized) repo-root-relative dependencies' file paths are sorted
64
- * - A SHA1 hash is created and each (sorted) file path is fed into the hash and then its
65
- * Git SHA is fed into the hash
66
- * - A hex digest of the hash is returned
67
- *
68
56
  * @internal
69
57
  */
70
- _tryGetProjectStateHashAsync(project: RushConfigurationProject, terminal: ITerminal): Promise<string | undefined>;
71
58
  _filterProjectDataAsync<T>(project: RushConfigurationProject, unfilteredProjectData: Map<string, T>, rootDir: string, terminal: ITerminal): Promise<Map<string, T>>;
72
- /**
73
- * Gets a list of projects that have changed in the current state of the repo
74
- * when compared to the specified branch, optionally taking the shrinkwrap and settings in
75
- * the rush-project.json file into consideration.
76
- */
77
- getChangedProjectsAsync(options: IGetChangedProjectsOptions): Promise<Set<RushConfigurationProject>>;
78
- private _getDataAsync;
79
59
  private _getIgnoreMatcherForProjectAsync;
80
- private _getRepoDepsAsync;
81
60
  }
82
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.