@@ -10,32 +10,26 @@ import {
1010} from '../../index' ;
1111
1212import {
13- CommandLineParameter ,
1413 CommandLineFlagParameter ,
1514 CommandLineStringParameter ,
1615 CommandLineStringListParameter ,
1716 CommandLineParameterKind
1817} from '@microsoft/ts-command-line' ;
1918
20- import { BaseRushAction , IRushCommandLineActionOptions } from '../actions/BaseRushAction' ;
2119import { SetupChecks } from '../../logic/SetupChecks' ;
2220import { TaskSelector } from '../../logic/TaskSelector' ;
2321import { Stopwatch } from '../../utilities/Stopwatch' ;
2422import { AlreadyReportedError } from '../../utilities/AlreadyReportedError' ;
25- import { CommandLineConfiguration } from '../../api/CommandLineConfiguration' ;
26- import { ParameterJson } from '../../api/CommandLineJson' ;
27- import { RushConstants } from '../../api/RushConstants' ;
23+ import { BaseScriptAction , IBaseScriptActionOptions } from './BaseScriptAction' ;
2824
29- export interface ICustomRushActionOptions extends IRushCommandLineActionOptions {
25+ export interface IBulkScriptActionOptions extends IBaseScriptActionOptions {
3026 enableParallelism : boolean ;
3127 ignoreMissingScript : boolean ;
32- commandLineConfiguration : CommandLineConfiguration ;
3328}
3429
35- export class BulkScriptAction extends BaseRushAction {
30+ export class BulkScriptAction extends BaseScriptAction {
3631 private _enableParallelism : boolean ;
3732 private _ignoreMissingScript : boolean ;
38- private _commandLineConfiguration : CommandLineConfiguration ;
3933
4034 private _changedProjectsOnly : CommandLineFlagParameter ;
4135 private _fromFlag : CommandLineStringListParameter ;
@@ -44,15 +38,12 @@ export class BulkScriptAction extends BaseRushAction {
4438 private _verboseParameter : CommandLineFlagParameter ;
4539 private _parallelismParameter : CommandLineStringParameter | undefined ;
4640
47- private _customParameters : CommandLineParameter [ ] = [ ] ;
48-
4941 constructor (
50- options : ICustomRushActionOptions
42+ options : IBulkScriptActionOptions
5143 ) {
5244 super ( options ) ;
5345 this . _enableParallelism = options . enableParallelism ;
5446 this . _ignoreMissingScript = options . ignoreMissingScript ;
55- this . _commandLineConfiguration = options . commandLineConfiguration ;
5647 }
5748
5849 public run ( ) : Promise < void > {
@@ -75,7 +66,7 @@ export class BulkScriptAction extends BaseRushAction {
7566 // Collect all custom parameter values
7667 const customParameterValues : string [ ] = [ ] ;
7768
78- for ( const customParameter of this . _customParameters ) {
69+ for ( const customParameter of this . customParameters ) {
7970 customParameter . appendToArgList ( customParameterValues ) ;
8071 }
8172
@@ -155,44 +146,7 @@ export class BulkScriptAction extends BaseRushAction {
155146 } ) ;
156147 }
157148
158- // Find any parameters that are associated with this command
159- for ( const parameter of this . _commandLineConfiguration . parameters ) {
160- let associated : boolean = false ;
161- for ( const associatedCommand of parameter . associatedCommands ) {
162- if ( associatedCommand === this . actionName ) {
163- associated = true ;
164- }
165- }
166-
167- if ( associated ) {
168- let customParameter : CommandLineParameter | undefined ;
169-
170- switch ( parameter . parameterKind ) {
171- case 'flag' :
172- customParameter = this . defineFlagParameter ( {
173- parameterShortName : parameter . shortName ,
174- parameterLongName : parameter . longName ,
175- description : parameter . description
176- } ) ;
177- break ;
178- case 'choice' :
179- customParameter = this . defineChoiceParameter ( {
180- parameterShortName : parameter . shortName ,
181- parameterLongName : parameter . longName ,
182- description : parameter . description ,
183- alternatives : parameter . alternatives . map ( x => x . name ) ,
184- defaultValue : parameter . defaultValue
185- } ) ;
186- break ;
187- default :
188- throw new Error ( `${ RushConstants . commandLineFilename } defines a parameter "${ parameter ! . longName } "`
189- + ` using an unsupported parameter kind "${ parameter ! . parameterKind } "` ) ;
190- }
191- if ( customParameter ) {
192- this . _customParameters . push ( customParameter ) ;
193- }
194- }
195- }
149+ this . defineScriptParameters ( ) ;
196150 }
197151
198152 private _mergeToProjects ( ) : string [ ] {
@@ -238,13 +192,12 @@ export class BulkScriptAction extends BaseRushAction {
238192 }
239193
240194 private _collectTelemetry ( stopwatch : Stopwatch , success : boolean ) : void {
241-
242195 const extraData : { [ key : string ] : string } = {
243196 command_to : ( this . _toFlag . values . length > 0 ) . toString ( ) ,
244197 command_from : ( this . _fromFlag . values . length > 0 ) . toString ( )
245198 } ;
246199
247- for ( const customParameter of this . _customParameters ) {
200+ for ( const customParameter of this . customParameters ) {
248201 switch ( customParameter . kind ) {
249202 case CommandLineParameterKind . Flag :
250203 case CommandLineParameterKind . Choice :
0 commit comments