@rushstack/rush-sdk 5.63.1 → 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 +391 -0
  2. package/package.json +7 -4
@@ -6,12 +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';
9
12
  import { HookMap } from 'tapable';
10
13
  import { IPackageJson } from '@rushstack/node-core-library';
11
14
  import { ITerminal } from '@rushstack/node-core-library';
12
15
  import { ITerminalProvider } from '@rushstack/node-core-library';
13
16
  import { JsonObject } from '@rushstack/node-core-library';
14
17
  import { PackageNameParser } from '@rushstack/node-core-library';
18
+ import type { StdioSummarizer } from '@rushstack/terminal';
19
+ import { SyncHook } from 'tapable';
15
20
  import { Terminal } from '@rushstack/node-core-library';
16
21
 
17
22
  /**
@@ -130,6 +135,52 @@ export declare class ApprovedPackagesPolicy {
130
135
  get nonbrowserApprovedPackages(): ApprovedPackagesConfiguration;
131
136
  }
132
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
+
133
184
  /**
134
185
  * Type of version bumps
135
186
  * @public
@@ -582,6 +633,34 @@ export declare class ExperimentsConfiguration {
582
633
  get configuration(): Readonly<IExperimentsJson>;
583
634
  }
584
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
+
585
664
  /**
586
665
  * Part of IRushConfigurationJson.
587
666
  */
@@ -659,6 +738,52 @@ export declare interface IConfigurationEnvironmentVariable {
659
738
  override?: boolean;
660
739
  }
661
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
+
662
787
  /**
663
788
  * @beta
664
789
  */
@@ -735,6 +860,40 @@ export declare interface IExperimentsJson {
735
860
  phasedCommands?: boolean;
736
861
  }
737
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
+
738
897
  /**
739
898
  * @beta
740
899
  */
@@ -869,6 +1028,89 @@ export declare class IndividualVersionPolicy extends VersionPolicy {
869
1028
  export declare interface _INpmOptionsJson extends IPackageManagerOptionsJsonBase {
870
1029
  }
871
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
+
872
1114
  /**
873
1115
  * Options for the package manager.
874
1116
  * @public
@@ -880,11 +1122,57 @@ export declare interface IPackageManagerOptionsJsonBase {
880
1122
  environmentVariables?: IConfigurationEnvironment;
881
1123
  }
882
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
+
883
1166
  /**
884
1167
  * Information about the currently executing phased script command (as defined in command-line.json, or default "build" or "rebuild") provided to plugins.
885
1168
  * @beta
886
1169
  */
887
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;
888
1176
  }
889
1177
 
890
1178
  /**
@@ -1321,6 +1609,91 @@ export declare class NpmOptionsConfiguration extends PackageManagerOptionsConfig
1321
1609
  constructor(json: _INpmOptionsJson);
1322
1610
  }
1323
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
+
1324
1697
  /**
1325
1698
  * @public
1326
1699
  */
@@ -1434,6 +1807,24 @@ export declare abstract class PackageManagerOptionsConfigurationBase implements
1434
1807
  protected constructor(json: IPackageManagerOptionsJsonBase);
1435
1808
  }
1436
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
+
1437
1828
  /**
1438
1829
  * Options that are only used when the PNPM package manager is selected.
1439
1830
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/rush-sdk",
3
- "version": "5.63.1",
3
+ "version": "5.64.0",
4
4
  "description": "An API for interacting with the Rush engine",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,10 +17,13 @@
17
17
  "tapable": "2.2.1"
18
18
  },
19
19
  "devDependencies": {
20
- "@microsoft/rush-lib": "5.63.1",
20
+ "@microsoft/rush-lib": "5.64.0",
21
21
  "@rushstack/eslint-config": "2.5.2",
22
- "@rushstack/heft": "0.44.4",
23
- "@rushstack/heft-node-rig": "1.8.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"