Skip to content

Commit 93e5d46

Browse files
filipesilvaBrocco
authored andcommitted
feat(@angular/cli): use devkit core formats for schematics
Followup to angular/devkit#334
1 parent d53eb59 commit 93e5d46

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"homepage": "https://github.com/angular/angular-cli",
4343
"dependencies": {
4444
"@angular-devkit/build-optimizer": "~0.0.37",
45+
"@angular-devkit/core": "~0.0.24",
4546
"@angular-devkit/schematics": "~0.0.45",
4647
"@schematics/angular": "~0.1.12",
4748
"autoprefixer": "^7.2.3",

Diff for: packages/@angular/cli/commands/generate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export default Command.extend({
148148
dryRun: commandOptions.dryRun
149149
};
150150
const parsedPath = dynamicPathParser(dynamicPathOptions);
151-
commandOptions.sourceDir = parsedPath.sourceDir;
151+
commandOptions.sourceDir = parsedPath.sourceDir.replace(separatorRegEx, '/');
152152
const root = parsedPath.sourceDir + path.sep;
153153
commandOptions.appRoot = parsedPath.appRoot === parsedPath.sourceDir ? '' :
154154
parsedPath.appRoot.startsWith(root)

Diff for: packages/@angular/cli/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"homepage": "https://github.com/angular/angular-cli",
2929
"dependencies": {
3030
"@angular-devkit/build-optimizer": "~0.0.37",
31+
"@angular-devkit/core": "~0.0.24",
3132
"@angular-devkit/schematics": "~0.0.45",
3233
"@ngtools/json-schema": "1.1.0",
3334
"@ngtools/webpack": "1.10.0-beta.0",

Diff for: packages/@angular/cli/tasks/schematic-run.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ function prepOptions(schematic: Schematic<{}, {}>, options: SchematicOptions): S
173173
const keys = Object.keys(properties);
174174
if (['component', 'c', 'directive', 'd'].indexOf(schematic.description.name) !== -1) {
175175
options.prefix = (options.prefix === 'false' || options.prefix === '')
176-
? '' : options.prefix;
176+
? undefined : options.prefix;
177177
}
178178

179179
let preppedOptions = {

Diff for: packages/@angular/cli/utilities/schematics.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@
55
* require('@schematics/angular')
66
*/
77

8+
import { schema } from '@angular-devkit/core';
89
import {
910
Collection,
1011
Engine,
1112
Schematic,
1213
SchematicEngine,
14+
formats,
1315
} from '@angular-devkit/schematics';
1416
import {
1517
FileSystemCollectionDesc,
1618
FileSystemSchematicDesc,
17-
NodeModulesEngineHost
19+
NodeModulesEngineHost,
20+
validateOptionsWithSchema
1821
} from '@angular-devkit/schematics/tools';
1922
import { SchemaClassFactory } from '@ngtools/json-schema';
2023
import 'rxjs/add/operator/concatMap';
@@ -26,6 +29,10 @@ const engineHost = new NodeModulesEngineHost();
2629
const engine: Engine<FileSystemCollectionDesc, FileSystemSchematicDesc>
2730
= new SchematicEngine(engineHost);
2831

32+
// Add support for schemaJson.
33+
const registry = new schema.CoreSchemaRegistry(formats.standardFormats);
34+
engineHost.registerOptionsTransform(validateOptionsWithSchema(registry));
35+
2936

3037
export function getEngineHost() {
3138
return engineHost;

0 commit comments

Comments
 (0)