|
5 | 5 | * Use of this source code is governed by an MIT-style license that can be
|
6 | 6 | * found in the LICENSE file at https://angular.io/license
|
7 | 7 | */
|
8 |
| -import { Architect, BuildEvent, TargetSpecifier } from '@angular-devkit/architect'; |
| 8 | +import { |
| 9 | + Architect, |
| 10 | + BuildEvent, |
| 11 | + BuilderConfiguration, |
| 12 | + TargetSpecifier, |
| 13 | +} from '@angular-devkit/architect'; |
9 | 14 | import { experimental, json, schema, tags } from '@angular-devkit/core';
|
10 | 15 | import { NodeJsSyncHost, createConsoleLogger } from '@angular-devkit/core/node';
|
11 | 16 | import { from } from 'rxjs';
|
@@ -88,11 +93,31 @@ export abstract class ArchitectCommand extends Command<ArchitectCommandOptions>
|
88 | 93 | throw new Error('Cannot determine project or target for Architect command.');
|
89 | 94 | }
|
90 | 95 |
|
91 |
| - const builderConf = this._architect.getBuilderConfiguration(targetSpec); |
92 |
| - const builderDesc = await this._architect.getBuilderDescription(builderConf).toPromise(); |
93 |
| - const targetOptionArray = await parseJsonSchemaToOptions(this._registry, builderDesc.schema); |
| 96 | + if (this.target) { |
| 97 | + // Add options IF there's only one builder of this kind. |
| 98 | + const projectNames = this.getProjectNamesByTarget(this.target); |
| 99 | + const builderConfigurations: BuilderConfiguration[] = []; |
| 100 | + for (const projectName of projectNames) { |
| 101 | + const targetSpec: TargetSpecifier = this._makeTargetSpecifier(options); |
| 102 | + const targetDesc = this._architect.getBuilderConfiguration({ |
| 103 | + project: projectName, |
| 104 | + target: targetSpec.target, |
| 105 | + }); |
| 106 | + |
| 107 | + if (!builderConfigurations.find(b => b.builder === targetDesc.builder)) { |
| 108 | + builderConfigurations.push(targetDesc); |
| 109 | + } |
| 110 | + } |
| 111 | + |
| 112 | + if (builderConfigurations.length == 1) { |
| 113 | + const builderConf = builderConfigurations[0]; |
| 114 | + const builderDesc = await this._architect.getBuilderDescription(builderConf).toPromise(); |
94 | 115 |
|
95 |
| - this.description.options.push(...targetOptionArray); |
| 116 | + this.description.options.push(...( |
| 117 | + await parseJsonSchemaToOptions(this._registry, builderDesc.schema) |
| 118 | + )); |
| 119 | + } |
| 120 | + } |
96 | 121 | }
|
97 | 122 |
|
98 | 123 | async run(options: ArchitectCommandOptions) {
|
|
0 commit comments