@rushstack/rush-sdk 5.62.4 → 5.64.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.
Files changed (2) hide show
  1. package/dist/rush-lib.d.ts +437 -2
  2. package/package.json +9 -6
@@ -6,11 +6,17 @@
6
6
  /// <reference types="node" />
7
7
 
8
8
  import { AsyncSeriesHook } from 'tapable';
9
+ import { AsyncSeriesWaterfallHook } from 'tapable';
10
+ import type { CollatedWriter } from '@rushstack/stream-collator';
11
+ import type { CommandLineParameter } from '@rushstack/ts-command-line';
12
+ import { HookMap } from 'tapable';
9
13
  import { IPackageJson } from '@rushstack/node-core-library';
10
14
  import { ITerminal } from '@rushstack/node-core-library';
11
15
  import { ITerminalProvider } from '@rushstack/node-core-library';
12
16
  import { JsonObject } from '@rushstack/node-core-library';
13
17
  import { PackageNameParser } from '@rushstack/node-core-library';
18
+ import type { StdioSummarizer } from '@rushstack/terminal';
19
+ import { SyncHook } from 'tapable';
14
20
  import { Terminal } from '@rushstack/node-core-library';
15
21
 
16
22
  /**
@@ -129,6 +135,52 @@ export declare class ApprovedPackagesPolicy {
129
135
  get nonbrowserApprovedPackages(): ApprovedPackagesConfiguration;
130
136
  }
131
137
 
138
+ /**
139
+ * Use this class to load and save the "common/config/rush/build-cache.json" config file.
140
+ * This file provides configuration options for cached project build output.
141
+ * @beta
142
+ */
143
+ export declare class BuildCacheConfiguration {
144
+ private static _jsonSchema;
145
+ /**
146
+ * Indicates whether the build cache feature is enabled.
147
+ * Typically it is enabled in the build-cache.json config file.
148
+ */
149
+ readonly buildCacheEnabled: boolean;
150
+ /**
151
+ * Indicates whether or not writing to the cache is enabled.
152
+ */
153
+ cacheWriteEnabled: boolean;
154
+ /**
155
+ * Method to calculate the cache entry id for a project, phase, and project state.
156
+ */
157
+ readonly getCacheEntryId: GetCacheEntryIdFunction;
158
+ /**
159
+ * The provider for interacting with the local build cache.
160
+ */
161
+ readonly localCacheProvider: FileSystemBuildCacheProvider;
162
+ /**
163
+ * The provider for interacting with the cloud build cache, if configured.
164
+ */
165
+ readonly cloudCacheProvider: ICloudBuildCacheProvider | undefined;
166
+ private constructor();
167
+ /**
168
+ * Attempts to load the build-cache.json data from the standard file path `common/config/rush/build-cache.json`.
169
+ * If the file has not been created yet, then undefined is returned.
170
+ */
171
+ static tryLoadAsync(terminal: ITerminal, rushConfiguration: RushConfiguration, rushSession: RushSession): Promise<BuildCacheConfiguration | undefined>;
172
+ /**
173
+ * Loads the build-cache.json data from the standard file path `common/config/rush/build-cache.json`.
174
+ * If the file has not been created yet, or if the feature is not enabled, then an error is reported.
175
+ */
176
+ static loadAndRequireEnabledAsync(terminal: ITerminal, rushConfiguration: RushConfiguration, rushSession: RushSession): Promise<BuildCacheConfiguration>;
177
+ /**
178
+ * Gets the absolute path to the build-cache.json file in the specified rush workspace.
179
+ */
180
+ static getBuildCacheConfigFilePath(rushConfiguration: RushConfiguration): string;
181
+ private static _loadAsync;
182
+ }
183
+
132
184
  /**
133
185
  * Type of version bumps
134
186
  * @public
@@ -581,6 +633,34 @@ export declare class ExperimentsConfiguration {
581
633
  get configuration(): Readonly<IExperimentsJson>;
582
634
  }
583
635
 
636
+ /**
637
+ * A build cache provider using the local file system.
638
+ * Required by all cloud cache providers.
639
+ * @beta
640
+ */
641
+ export declare class FileSystemBuildCacheProvider {
642
+ private readonly _cacheFolderPath;
643
+ constructor(options: IFileSystemBuildCacheProviderOptions);
644
+ /**
645
+ * Returns the absolute disk path for the specified cache id.
646
+ */
647
+ getCacheEntryPath(cacheId: string): string;
648
+ /**
649
+ * Validates that the specified cache id exists on disk, and returns the path if it does.
650
+ */
651
+ tryGetCacheEntryPathByIdAsync(terminal: ITerminal, cacheId: string): Promise<string | undefined>;
652
+ /**
653
+ * Writes the specified buffer to the corresponding file system path for the cache id.
654
+ */
655
+ trySetCacheEntryBufferAsync(terminal: ITerminal, cacheId: string, entryBuffer: Buffer): Promise<string>;
656
+ }
657
+
658
+ /**
659
+ * Calculates the cache entry id string for an operation.
660
+ * @beta
661
+ */
662
+ export declare type GetCacheEntryIdFunction = (options: IGenerateCacheEntryIdOptions) => string;
663
+
584
664
  /**
585
665
  * Part of IRushConfigurationJson.
586
666
  */
@@ -658,6 +738,52 @@ export declare interface IConfigurationEnvironmentVariable {
658
738
  override?: boolean;
659
739
  }
660
740
 
741
+ /**
742
+ * Context used for creating operations to be executed.
743
+ * @alpha
744
+ */
745
+ export declare interface ICreateOperationsContext {
746
+ /**
747
+ * The configuration for the build cache, if the feature is enabled.
748
+ */
749
+ readonly buildCacheConfiguration: BuildCacheConfiguration | undefined;
750
+ /**
751
+ * The set of custom parameters for the executing command.
752
+ * Maps from the `longName` field in command-line.json to the parser configuration in ts-command-line.
753
+ */
754
+ readonly customParameters: ReadonlyMap<string, CommandLineParameter>;
755
+ /**
756
+ * If true, projects may read their output from cache or be skipped if already up to date.
757
+ * If false, neither of the above may occur, e.g. "rush rebuild"
758
+ */
759
+ readonly isIncrementalBuildAllowed: boolean;
760
+ /**
761
+ * If true, this is the initial run of the command.
762
+ * If false, this execution is in response to changes.
763
+ */
764
+ readonly isInitial: boolean;
765
+ /**
766
+ * If true, the command is running in watch mode.
767
+ */
768
+ readonly isWatch: boolean;
769
+ /**
770
+ * The set of phases selected for the current command execution.
771
+ */
772
+ readonly phaseSelection: ReadonlySet<IPhase>;
773
+ /**
774
+ * The current state of the repository
775
+ */
776
+ readonly projectChangeAnalyzer: ProjectChangeAnalyzer;
777
+ /**
778
+ * The set of Rush projects selected for the current command execution.
779
+ */
780
+ readonly projectSelection: ReadonlySet<RushConfigurationProject>;
781
+ /**
782
+ * The Rush configuration
783
+ */
784
+ readonly rushConfiguration: RushConfiguration;
785
+ }
786
+
661
787
  /**
662
788
  * @beta
663
789
  */
@@ -734,6 +860,40 @@ export declare interface IExperimentsJson {
734
860
  phasedCommands?: boolean;
735
861
  }
736
862
 
863
+ /**
864
+ * Options for creating a file system build cache provider.
865
+ * @beta
866
+ */
867
+ export declare interface IFileSystemBuildCacheProviderOptions {
868
+ /**
869
+ * The workspace Rush configuration
870
+ */
871
+ rushConfiguration: RushConfiguration;
872
+ /**
873
+ * The user Rush configuration
874
+ */
875
+ rushUserConfiguration: RushUserConfiguration;
876
+ }
877
+
878
+ /**
879
+ * Options for generating the cache id for an operation.
880
+ * @beta
881
+ */
882
+ export declare interface IGenerateCacheEntryIdOptions {
883
+ /**
884
+ * The name of the project
885
+ */
886
+ projectName: string;
887
+ /**
888
+ * The name of the phase
889
+ */
890
+ phaseName: string;
891
+ /**
892
+ * A hash of the input files
893
+ */
894
+ projectStateHash: string;
895
+ }
896
+
737
897
  /**
738
898
  * @beta
739
899
  */
@@ -753,6 +913,13 @@ export declare interface IGetChangedProjectsOptions {
753
913
  enableFiltering: boolean;
754
914
  }
755
915
 
916
+ /**
917
+ * Information about the currently executing global script command (as defined in command-line.json) provided to plugins.
918
+ * @beta
919
+ */
920
+ export declare interface IGlobalCommand extends IRushCommand {
921
+ }
922
+
756
923
  declare interface IIndividualVersionJson extends IVersionPolicyJson {
757
924
  lockedMajor?: number;
758
925
  }
@@ -861,6 +1028,89 @@ export declare class IndividualVersionPolicy extends VersionPolicy {
861
1028
  export declare interface _INpmOptionsJson extends IPackageManagerOptionsJsonBase {
862
1029
  }
863
1030
 
1031
+ /**
1032
+ * Options for constructing a new Operation.
1033
+ * @alpha
1034
+ */
1035
+ export declare interface IOperationOptions {
1036
+ /**
1037
+ * The Rush phase associated with this Operation, if any
1038
+ */
1039
+ phase?: IPhase | undefined;
1040
+ /**
1041
+ * The Rush project associated with this Operation, if any
1042
+ */
1043
+ project?: RushConfigurationProject | undefined;
1044
+ /**
1045
+ * When the scheduler is ready to process this `Operation`, the `runner` implements the actual work of
1046
+ * running the operation.
1047
+ */
1048
+ runner?: IOperationRunner | undefined;
1049
+ }
1050
+
1051
+ /**
1052
+ * The `Operation` class is a node in the dependency graph of work that needs to be scheduled by the
1053
+ * `OperationExecutionManager`. Each `Operation` has a `runner` member of type `IOperationRunner`, whose
1054
+ * implementation manages the actual process for running a single operation.
1055
+ *
1056
+ * @beta
1057
+ */
1058
+ export declare interface IOperationRunner {
1059
+ /**
1060
+ * Name of the operation, for logging.
1061
+ */
1062
+ readonly name: string;
1063
+ /**
1064
+ * This flag determines if the operation is allowed to be skipped if up to date.
1065
+ */
1066
+ isSkipAllowed: boolean;
1067
+ /**
1068
+ * Indicates that this runner's duration has meaning.
1069
+ */
1070
+ reportTiming: boolean;
1071
+ /**
1072
+ * Indicates that this runner is architectural and should not be reported on.
1073
+ */
1074
+ silent: boolean;
1075
+ /**
1076
+ * If set to true, a warning result should not make Rush exit with a nonzero
1077
+ * exit code
1078
+ */
1079
+ warningsAreAllowed: boolean;
1080
+ /**
1081
+ * Indicates if the output of this operation may be written to the cache
1082
+ */
1083
+ isCacheWriteAllowed: boolean;
1084
+ /**
1085
+ * Method to be executed for the operation.
1086
+ */
1087
+ executeAsync(context: IOperationRunnerContext): Promise<OperationStatus>;
1088
+ }
1089
+
1090
+ /**
1091
+ * Information passed to the executing `IOperationRunner`
1092
+ *
1093
+ * @beta
1094
+ */
1095
+ export declare interface IOperationRunnerContext {
1096
+ /**
1097
+ * The writer into which this `IOperationRunner` should write its logs.
1098
+ */
1099
+ collatedWriter: CollatedWriter;
1100
+ /**
1101
+ * If Rush was invoked with `--debug`
1102
+ */
1103
+ debugMode: boolean;
1104
+ /**
1105
+ * Defaults to `true`. Will be `false` if Rush was invoked with `--verbose`.
1106
+ */
1107
+ quietMode: boolean;
1108
+ /**
1109
+ * Object used to report a summary at the end of the Rush invocation.
1110
+ */
1111
+ stdioSummarizer: StdioSummarizer;
1112
+ }
1113
+
864
1114
  /**
865
1115
  * Options for the package manager.
866
1116
  * @public
@@ -872,6 +1122,59 @@ export declare interface IPackageManagerOptionsJsonBase {
872
1122
  environmentVariables?: IConfigurationEnvironment;
873
1123
  }
874
1124
 
1125
+ /**
1126
+ * Metadata about a phase.
1127
+ * @alpha
1128
+ */
1129
+ export declare interface IPhase {
1130
+ /**
1131
+ * The name of this phase.
1132
+ */
1133
+ name: string;
1134
+ /**
1135
+ * If set to "true," this this phase was generated from a bulk command, and
1136
+ * was not explicitly defined in the command-line.json file.
1137
+ */
1138
+ isSynthetic: boolean;
1139
+ /**
1140
+ * This property is used in the name of the filename for the logs generated by this
1141
+ * phase. This is a filesystem-safe version of the phase name. For example,
1142
+ * a phase with name "_phase:compile" has a `logFilenameIdentifier` of "_phase_compile".
1143
+ */
1144
+ logFilenameIdentifier: string;
1145
+ /**
1146
+ * The set of custom command line parameters that are relevant to this phase.
1147
+ */
1148
+ associatedParameters: Set<CommandLineParameter>;
1149
+ /**
1150
+ * The resolved dependencies of the phase
1151
+ */
1152
+ dependencies: {
1153
+ self: Set<IPhase>;
1154
+ upstream: Set<IPhase>;
1155
+ };
1156
+ /**
1157
+ * Normally Rush requires that each project's package.json has a \"scripts\" entry matching the phase name. To disable this check, set \"ignoreMissingScript\" to true.
1158
+ */
1159
+ ignoreMissingScript: boolean;
1160
+ /**
1161
+ * By default, Rush returns a nonzero exit code if errors or warnings occur during a command. If this option is set to \"true\", Rush will return a zero exit code if warnings occur during the execution of this phase.
1162
+ */
1163
+ allowWarningsOnSuccess: boolean;
1164
+ }
1165
+
1166
+ /**
1167
+ * Information about the currently executing phased script command (as defined in command-line.json, or default "build" or "rebuild") provided to plugins.
1168
+ * @beta
1169
+ */
1170
+ export declare interface IPhasedCommand extends IRushCommand {
1171
+ /**
1172
+ * Hooks into the execution of the current phased command
1173
+ * @alpha
1174
+ */
1175
+ readonly hooks: PhasedCommandHooks;
1176
+ }
1177
+
875
1178
  /**
876
1179
  * Part of IRushConfigurationJson.
877
1180
  * @internal
@@ -895,6 +1198,17 @@ export declare interface _IPnpmOptionsJson extends IPackageManagerOptionsJsonBas
895
1198
  useWorkspaces?: boolean;
896
1199
  }
897
1200
 
1201
+ /**
1202
+ * Information about the currently executing command provided to plugins.
1203
+ * @beta
1204
+ */
1205
+ export declare interface IRushCommand {
1206
+ /**
1207
+ * The name of this command, as seen on the command line
1208
+ */
1209
+ readonly actionName: string;
1210
+ }
1211
+
898
1212
  /**
899
1213
  * This represents the JSON data structure for the "rush.json" configuration file.
900
1214
  * See rush.schema.json for documentation.
@@ -1295,6 +1609,91 @@ export declare class NpmOptionsConfiguration extends PackageManagerOptionsConfig
1295
1609
  constructor(json: _INpmOptionsJson);
1296
1610
  }
1297
1611
 
1612
+ /**
1613
+ * The `Operation` class is a node in the dependency graph of work that needs to be scheduled by the
1614
+ * `OperationExecutionManager`. Each `Operation` has a `runner` member of type `IOperationRunner`, whose
1615
+ * implementation manages the actual process of running a single operation.
1616
+ *
1617
+ * The graph of `Operation` instances will be cloned into a separate execution graph after processing.
1618
+ *
1619
+ * @alpha
1620
+ */
1621
+ export declare class Operation {
1622
+ /**
1623
+ * The Rush phase associated with this Operation, if any
1624
+ */
1625
+ readonly associatedPhase: IPhase | undefined;
1626
+ /**
1627
+ * The Rush project associated with this Operation, if any
1628
+ */
1629
+ readonly associatedProject: RushConfigurationProject | undefined;
1630
+ /**
1631
+ * A set of all dependencies which must be executed before this operation is complete.
1632
+ */
1633
+ readonly dependencies: Set<Operation>;
1634
+ /**
1635
+ * When the scheduler is ready to process this `Operation`, the `runner` implements the actual work of
1636
+ * running the operation.
1637
+ */
1638
+ runner: IOperationRunner | undefined;
1639
+ /**
1640
+ * The weight for this operation. This scalar is the contribution of this operation to the
1641
+ * `criticalPathLength` calculation above. Modify to indicate the following:
1642
+ * - `weight` === 1: indicates that this operation has an average duration
1643
+ * - `weight` &gt; 1: indicates that this operation takes longer than average and so the scheduler
1644
+ * should try to favor starting it over other, shorter operations. An example might be an operation that
1645
+ * bundles an entire application and runs whole-program optimization.
1646
+ * - `weight` &lt; 1: indicates that this operation takes less time than average and so the scheduler
1647
+ * should favor other, longer operations over it. An example might be an operation to unpack a cached
1648
+ * output, or an operation using NullOperationRunner, which might use a value of 0.
1649
+ */
1650
+ weight: number;
1651
+ constructor(options?: IOperationOptions);
1652
+ /**
1653
+ * The name of this operation, for logging.
1654
+ */
1655
+ get name(): string | undefined;
1656
+ }
1657
+
1658
+ /**
1659
+ * Enumeration defining potential states of an operation
1660
+ * @beta
1661
+ */
1662
+ export declare enum OperationStatus {
1663
+ /**
1664
+ * The Operation is on the queue, ready to execute (but may be waiting for dependencies)
1665
+ */
1666
+ Ready = "READY",
1667
+ /**
1668
+ * The Operation is currently executing
1669
+ */
1670
+ Executing = "EXECUTING",
1671
+ /**
1672
+ * The Operation completed successfully and did not write to standard output
1673
+ */
1674
+ Success = "SUCCESS",
1675
+ /**
1676
+ * The Operation completed successfully, but wrote to standard output
1677
+ */
1678
+ SuccessWithWarning = "SUCCESS WITH WARNINGS",
1679
+ /**
1680
+ * The Operation was skipped via the legacy incremental build logic
1681
+ */
1682
+ Skipped = "SKIPPED",
1683
+ /**
1684
+ * The Operation had its outputs restored from the build cache
1685
+ */
1686
+ FromCache = "FROM CACHE",
1687
+ /**
1688
+ * The Operation failed
1689
+ */
1690
+ Failure = "FAILURE",
1691
+ /**
1692
+ * The Operation could not be executed because one or more of its dependencies failed
1693
+ */
1694
+ Blocked = "BLOCKED"
1695
+ }
1696
+
1298
1697
  /**
1299
1698
  * @public
1300
1699
  */
@@ -1408,6 +1807,24 @@ export declare abstract class PackageManagerOptionsConfigurationBase implements
1408
1807
  protected constructor(json: IPackageManagerOptionsJsonBase);
1409
1808
  }
1410
1809
 
1810
+ /**
1811
+ * Hooks into the execution process for phased commands
1812
+ * @alpha
1813
+ */
1814
+ export declare class PhasedCommandHooks {
1815
+ /**
1816
+ * Hook invoked to create operations for execution.
1817
+ * Use the context to distinguish between the initial run and phased runs.
1818
+ */
1819
+ readonly createOperations: AsyncSeriesWaterfallHook<[Set<Operation>, ICreateOperationsContext]>;
1820
+ /**
1821
+ * Hook invoked after a run has finished and the command is watching for changes.
1822
+ * May be used to display additional relevant data to the user.
1823
+ * Only relevant when running in watch mode.
1824
+ */
1825
+ readonly waitingForChanges: SyncHook<void>;
1826
+ }
1827
+
1411
1828
  /**
1412
1829
  * Options that are only used when the PNPM package manager is selected.
1413
1830
  *
@@ -2542,13 +2959,31 @@ export declare class _RushGlobalFolder {
2542
2959
  }
2543
2960
 
2544
2961
  /**
2962
+ * Hooks into the lifecycle of the Rush process invocation that plugins may tap into.
2963
+ *
2545
2964
  * @beta
2546
2965
  */
2547
2966
  export declare class RushLifecycleHooks {
2548
2967
  /**
2549
- * The hook to run when all rush plugins is initialized.
2968
+ * The hook to run before executing any Rush CLI Command.
2969
+ */
2970
+ initialize: AsyncSeriesHook<IRushCommand>;
2971
+ /**
2972
+ * The hook to run before executing any global Rush CLI Command (defined in command-line.json).
2973
+ */
2974
+ runAnyGlobalCustomCommand: AsyncSeriesHook<IGlobalCommand>;
2975
+ /**
2976
+ * A hook map to allow plugins to hook specific named global commands (defined in command-line.json) before execution.
2977
+ */
2978
+ runGlobalCustomCommand: HookMap<AsyncSeriesHook<IGlobalCommand>>;
2979
+ /**
2980
+ * The hook to run before executing any phased Rush CLI Command (defined in command-line.json, or the default "build" or "rebuild").
2981
+ */
2982
+ runAnyPhasedCommand: AsyncSeriesHook<IPhasedCommand>;
2983
+ /**
2984
+ * A hook map to allow plugins to hook specific named phased commands (defined in command-line.json) before execution.
2550
2985
  */
2551
- initialize: AsyncSeriesHook<void>;
2986
+ runPhasedCommand: HookMap<AsyncSeriesHook<IPhasedCommand>>;
2552
2987
  }
2553
2988
 
2554
2989
  declare class RushPluginsConfiguration {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/rush-sdk",
3
- "version": "5.62.4",
3
+ "version": "5.64.0",
4
4
  "description": "An API for interacting with the Rush engine",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,15 +12,18 @@
12
12
  "typings": "dist/rush-lib.d.ts",
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@rushstack/node-core-library": "3.45.0",
15
+ "@rushstack/node-core-library": "3.45.1",
16
16
  "@types/node-fetch": "1.6.9",
17
17
  "tapable": "2.2.1"
18
18
  },
19
19
  "devDependencies": {
20
- "@microsoft/rush-lib": "5.62.4",
21
- "@rushstack/eslint-config": "2.5.1",
22
- "@rushstack/heft": "0.44.2",
23
- "@rushstack/heft-node-rig": "1.8.0",
20
+ "@microsoft/rush-lib": "5.64.0",
21
+ "@rushstack/eslint-config": "2.5.2",
22
+ "@rushstack/heft": "0.44.5",
23
+ "@rushstack/heft-node-rig": "1.8.3",
24
+ "@rushstack/stream-collator": "4.0.160",
25
+ "@rushstack/ts-command-line": "4.10.7",
26
+ "@rushstack/terminal": "0.3.29",
24
27
  "@types/heft-jest": "1.0.1",
25
28
  "@types/semver": "7.3.5",
26
29
  "@types/webpack-env": "1.13.0"