@@ -117,30 +117,31 @@ export class RushCommandLineParser extends CommandLineParser {
117117 }
118118
119119 private _populateScriptActions ( ) : void {
120- if ( ! this . rushConfiguration ) {
121- return ;
122- }
120+ let commandLineConfiguration : CommandLineConfiguration | undefined = undefined ;
123121
124- const commandLineConfigFile : string = path . join (
125- this . rushConfiguration . commonRushConfigFolder , RushConstants . commandLineFilename
126- ) ;
127- const commandLineConfiguration : CommandLineConfiguration
128- = CommandLineConfiguration . loadFromFileOrDefault ( commandLineConfigFile ) ;
122+ // If there is not a rush.json file, we still want "build" and "rebuild" to appear in the
123+ // command-line help
124+ if ( this . rushConfiguration ) {
125+ const commandLineConfigFile : string = path . join (
126+ this . rushConfiguration . commonRushConfigFolder , RushConstants . commandLineFilename
127+ ) ;
129128
130- const documentationForBuild : string = 'The Rush build command assumes that the package.json file for each'
131- + ' project contains a "scripts" entry for "npm run build". It invokes'
132- + ' this commands to build each project. Projects are built in parallel where'
133- + ' possible, but always respecting the dependency graph for locally linked projects.'
134- + ' The number of simultaneous processes will be based on the number of machine cores'
135- + ' unless overridden by the --parallelism flag.' ;
129+ commandLineConfiguration = CommandLineConfiguration . loadFromFileOrDefault ( commandLineConfigFile ) ;
130+ }
136131
137132 // always create a build and a rebuild command
138133 this . addAction ( new BulkScriptAction ( {
139134 actionName : 'build' ,
140135 summary : '(EXPERIMENTAL) Build all projects that haven\'t been built, or have changed since they were last '
141136 + 'built.' ,
142- documentation : documentationForBuild ,
143-
137+ documentation : 'This command is similar to "rush rebuild", except that "rush build" performs'
138+ + ' an incremental build. In other words, it only builds projects whose source files have'
139+ + ' changed since the last successful build. The analysis requires a Git working tree, and'
140+ + ' only considers source files that are tracked by Git and whose path is under the project folder.'
141+ + ' (For more details about this algorithm, see the documentation for the "package-deps-hash"'
142+ + ' NPM package.) The incremental build state is tracked in a file "package-deps.json" which should'
143+ + ' NOT be added to Git. The build command is tracked by the "arguments" field in this JSON file;'
144+ + ' a full rebuild is forced whenever the command has changed (e.g. "--production" or not).' ,
144145 parser : this ,
145146 commandLineConfiguration : commandLineConfiguration ,
146147
@@ -151,15 +152,25 @@ export class RushCommandLineParser extends CommandLineParser {
151152 this . addAction ( new BulkScriptAction ( {
152153 actionName : 'rebuild' ,
153154 summary : 'Clean and rebuild the entire set of projects' ,
154- documentation : documentationForBuild ,
155-
155+ documentation : 'This command assumes that the package.json file for each project contains'
156+ + ' a "scripts" entry for "npm run build" that performs a full clean build.'
157+ + ' Rush invokes this script to build each project that is registered in rush.json.'
158+ + ' Projects are built in parallel where possible, but always respecting the dependency'
159+ + ' graph for locally linked projects. The number of simultaneous processes will be'
160+ + ' based on the number of machine cores unless overridden by the --parallelism flag.'
161+ + ' (For an incremental build, see "rush build" instead of "rush rebuild".)' ,
156162 parser : this ,
157163 commandLineConfiguration : commandLineConfiguration ,
158164
159165 enableParallelism : true ,
160166 ignoreMissingScript : false
161167 } ) ) ;
162168
169+ if ( ! commandLineConfiguration ) {
170+ // If there is not a rush.json file, so don't attempt to define custom commands/parameters
171+ return ;
172+ }
173+
163174 // Register each custom command
164175 for ( const command of commandLineConfiguration . commands ) {
165176 if ( this . tryGetAction ( command . name ) ) {
0 commit comments