|
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 |
| - |
9 |
| -// tslint:disable:no-global-tslint-disable no-any |
10 | 8 | import {
|
11 | 9 | Architect,
|
12 | 10 | BuildEvent,
|
13 | 11 | BuilderDescription,
|
14 | 12 | TargetSpecifier,
|
15 | 13 | } from '@angular-devkit/architect';
|
16 |
| -import { JsonObject, experimental, schema, strings } from '@angular-devkit/core'; |
| 14 | +import { JsonObject, UnknownException, experimental, schema, strings } from '@angular-devkit/core'; |
17 | 15 | import { NodeJsSyncHost, createConsoleLogger } from '@angular-devkit/core/node';
|
18 | 16 | import { of } from 'rxjs';
|
19 | 17 | import { from } from 'rxjs';
|
@@ -98,11 +96,24 @@ export abstract class ArchitectCommand extends Command<ArchitectCommandOptions>
|
98 | 96 | return true;
|
99 | 97 | }
|
100 | 98 |
|
101 |
| - protected mapArchitectOptions(schema: any) { |
| 99 | + protected mapArchitectOptions(schema: JsonObject) { |
102 | 100 | const properties = schema.properties;
|
| 101 | + if (typeof properties != 'object' || properties === null || Array.isArray(properties)) { |
| 102 | + throw new UnknownException('Invalid schema.'); |
| 103 | + } |
103 | 104 | const keys = Object.keys(properties);
|
104 | 105 | keys
|
105 |
| - .map(key => ({ ...properties[key], ...{ name: strings.dasherize(key) } })) |
| 106 | + .map(key => { |
| 107 | + const value = properties[key]; |
| 108 | + if (typeof value != 'object') { |
| 109 | + throw new UnknownException('Invalid schema.'); |
| 110 | + } |
| 111 | + |
| 112 | + return { |
| 113 | + ...value, |
| 114 | + name: strings.dasherize(key), |
| 115 | + } as any; // tslint:disable-line:no-any |
| 116 | + }) |
106 | 117 | .map(opt => {
|
107 | 118 | let type;
|
108 | 119 | const schematicType = opt.type;
|
|
0 commit comments