@@ -195,53 +195,12 @@ export class RushCommandLineParser extends CommandLineParser {
195195 }
196196
197197 private _addDefaultBuildActions ( commandLineConfiguration ?: CommandLineConfiguration ) : void {
198- if ( ! this . tryGetAction ( 'build' ) ) {
199- // always create a build and a rebuild command
200- this . addAction ( new BulkScriptAction ( {
201- actionName : 'build' ,
202- summary : '(EXPERIMENTAL) Build all projects that haven\'t been built, or have changed since they were last '
203- + 'built.' ,
204- documentation : 'This command is similar to "rush rebuild", except that "rush build" performs'
205- + ' an incremental build. In other words, it only builds projects whose source files have changed'
206- + ' since the last successful build. The analysis requires a Git working tree, and only considers'
207- + ' source files that are tracked by Git and whose path is under the project folder. (For more details'
208- + ' about this algorithm, see the documentation for the "package-deps-hash" NPM package.) The incremental'
209- + ' build state is tracked in a per-project folder called ".rush/temp" which should NOT be added to Git. The'
210- + ' build command is tracked by the "arguments" field in the "package-deps_build.json" file contained'
211- + ' therein; a full rebuild is forced whenever the command has changed (e.g. "--production" or not).' ,
212- parser : this ,
213- commandLineConfiguration : commandLineConfiguration ,
214-
215- enableParallelism : true ,
216- ignoreMissingScript : false ,
217- ignoreDependencyOrder : false ,
218- incremental : true ,
219- allowWarningsInSuccessfulBuild : false
220- } ) ) ;
198+ if ( ! this . tryGetAction ( RushConstants . buildCommandName ) ) {
199+ this . _addCommandLineConfigAction ( commandLineConfiguration , CommandLineConfiguration . defaultBuildCommandJson ) ;
221200 }
222201
223- if ( ! this . tryGetAction ( 'rebuild' ) ) {
224- this . addAction ( new BulkScriptAction ( {
225- actionName : 'rebuild' ,
226- // To remain compatible with existing repos, `rebuild` defaults to calling the `build` command in each repo.
227- commandToRun : 'build' ,
228- summary : 'Clean and rebuild the entire set of projects' ,
229- documentation : 'This command assumes that the package.json file for each project contains'
230- + ' a "scripts" entry for "npm run build" that performs a full clean build.'
231- + ' Rush invokes this script to build each project that is registered in rush.json.'
232- + ' Projects are built in parallel where possible, but always respecting the dependency'
233- + ' graph for locally linked projects. The number of simultaneous processes will be'
234- + ' based on the number of machine cores unless overridden by the --parallelism flag.'
235- + ' (For an incremental build, see "rush build" instead of "rush rebuild".)' ,
236- parser : this ,
237- commandLineConfiguration : commandLineConfiguration ,
238-
239- enableParallelism : true ,
240- ignoreMissingScript : false ,
241- ignoreDependencyOrder : false ,
242- incremental : false ,
243- allowWarningsInSuccessfulBuild : false
244- } ) ) ;
202+ if ( ! this . tryGetAction ( RushConstants . rebuildCommandName ) ) {
203+ this . _addCommandLineConfigAction ( commandLineConfiguration , CommandLineConfiguration . defaultRebuildCommandJson ) ;
245204 }
246205 }
247206
@@ -252,48 +211,61 @@ export class RushCommandLineParser extends CommandLineParser {
252211
253212 // Register each custom command
254213 for ( const command of commandLineConfiguration . commands ) {
255- if ( this . tryGetAction ( command . name ) ) {
256- throw new Error ( `${ RushConstants . commandLineFilename } defines a command "${ command . name } "`
257- + ` using a name that already exists` ) ;
258- }
214+ this . _addCommandLineConfigAction ( commandLineConfiguration , command ) ;
215+ }
216+ }
259217
260- this . _validateCommandLineConfigCommand ( command ) ;
261-
262- switch ( command . commandKind ) {
263- case 'bulk' :
264- this . addAction ( new BulkScriptAction ( {
265- actionName : command . name ,
266- summary : command . summary ,
267- documentation : command . description || command . summary ,
268- safeForSimultaneousRushProcesses : command . safeForSimultaneousRushProcesses ,
269-
270- parser : this ,
271- commandLineConfiguration : commandLineConfiguration ,
272-
273- enableParallelism : command . enableParallelism ,
274- ignoreMissingScript : command . ignoreMissingScript || false ,
275- ignoreDependencyOrder : command . ignoreDependencyOrder || false ,
276- incremental : command . incremental || false ,
277- allowWarningsInSuccessfulBuild : ! ! command . allowWarningsInSuccessfulBuild
278- } ) ) ;
279- break ;
280- case 'global' :
281- this . addAction ( new GlobalScriptAction ( {
282- actionName : command . name ,
283- summary : command . summary ,
284- documentation : command . description || command . summary ,
285- safeForSimultaneousRushProcesses : command . safeForSimultaneousRushProcesses ,
286-
287- parser : this ,
288- commandLineConfiguration : commandLineConfiguration ,
289-
290- shellCommand : command . shellCommand
291- } ) ) ;
292- break ;
293- default :
294- throw new Error ( `${ RushConstants . commandLineFilename } defines a command "${ command ! . name } "`
295- + ` using an unsupported command kind "${ command ! . commandKind } "` ) ;
296- }
218+ private _addCommandLineConfigAction (
219+ commandLineConfiguration : CommandLineConfiguration | undefined ,
220+ command : CommandJson
221+ ) : void {
222+ if ( this . tryGetAction ( command . name ) ) {
223+ throw new Error ( `${ RushConstants . commandLineFilename } defines a command "${ command . name } "`
224+ + ` using a name that already exists` ) ;
225+ }
226+
227+ this . _validateCommandLineConfigCommand ( command ) ;
228+
229+ switch ( command . commandKind ) {
230+ case RushConstants . bulkCommandKind :
231+ this . addAction ( new BulkScriptAction ( {
232+ actionName : command . name ,
233+
234+ // The rush rebuild and rush build command invoke the same NPM script because they share the same
235+ // package-deps-hash state.
236+ commandToRun : command . name === RushConstants . rebuildCommandName ? 'build' : undefined ,
237+
238+ summary : command . summary ,
239+ documentation : command . description || command . summary ,
240+ safeForSimultaneousRushProcesses : command . safeForSimultaneousRushProcesses ,
241+
242+ parser : this ,
243+ commandLineConfiguration : commandLineConfiguration ,
244+
245+ enableParallelism : command . enableParallelism ,
246+ ignoreMissingScript : command . ignoreMissingScript || false ,
247+ ignoreDependencyOrder : command . ignoreDependencyOrder || false ,
248+ incremental : command . incremental || false ,
249+ allowWarningsInSuccessfulBuild : ! ! command . allowWarningsInSuccessfulBuild
250+ } ) ) ;
251+ break ;
252+
253+ case RushConstants . globalCommandKind :
254+ this . addAction ( new GlobalScriptAction ( {
255+ actionName : command . name ,
256+ summary : command . summary ,
257+ documentation : command . description || command . summary ,
258+ safeForSimultaneousRushProcesses : command . safeForSimultaneousRushProcesses ,
259+
260+ parser : this ,
261+ commandLineConfiguration : commandLineConfiguration ,
262+
263+ shellCommand : command . shellCommand
264+ } ) ) ;
265+ break ;
266+ default :
267+ throw new Error ( `${ RushConstants . commandLineFilename } defines a command "${ command ! . name } "`
268+ + ` using an unsupported command kind "${ command ! . commandKind } "` ) ;
297269 }
298270 }
299271
@@ -321,13 +293,14 @@ export class RushCommandLineParser extends CommandLineParser {
321293
322294 private _validateCommandLineConfigCommand ( command : CommandJson ) : void {
323295 // There are some restrictions on the 'build' and 'rebuild' commands.
324- if ( command . name !== 'build' && command . name !== 'rebuild' ) {
296+ if ( command . name !== RushConstants . buildCommandName && command . name !== RushConstants . rebuildCommandName ) {
325297 return ;
326298 }
327299
328- if ( command . commandKind === 'global' ) {
300+ if ( command . commandKind === RushConstants . globalCommandKind ) {
329301 throw new Error ( `${ RushConstants . commandLineFilename } defines a command "${ command . name } " using ` +
330- `the command kind "global". This command can only be designated as a command kind "bulk".` ) ;
302+ `the command kind "${ RushConstants . globalCommandKind } ". This command can only be designated as a command ` +
303+ `kind "${ RushConstants . bulkCommandKind } ".` ) ;
331304 }
332305 if ( command . safeForSimultaneousRushProcesses ) {
333306 throw new Error ( `${ RushConstants . commandLineFilename } defines a command "${ command . name } " using ` +
0 commit comments