-
Notifications
You must be signed in to change notification settings - Fork 302
/
schematics.js
46 lines (46 loc) · 1.63 KB
/
schematics.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"use strict";
/**
* Refer to the angular shematics library to let the dependency validator
* know it is used..
*
* require('@schematics/angular')
*/
Object.defineProperty(exports, "__esModule", { value: true });
const schematics_1 = require("@angular-devkit/schematics");
const tools_1 = require("@angular-devkit/schematics/tools");
const json_schema_1 = require("@ngtools/json-schema");
const SilentError = require('silent-error');
const engineHost = new tools_1.NodeModulesEngineHost();
const engine = new schematics_1.SchematicEngine(engineHost);
function getEngineHost() {
return engineHost;
}
exports.getEngineHost = getEngineHost;
function getEngine() {
return engine;
}
exports.getEngine = getEngine;
function getCollection(collectionName) {
const engineHost = getEngineHost();
const engine = getEngine();
// Add support for schemaJson.
engineHost.registerOptionsTransform((schematic, options) => {
if (schematic.schema) {
const SchemaMetaClass = json_schema_1.SchemaClassFactory(schematic.schemaJson);
const schemaClass = new SchemaMetaClass(options);
return schemaClass.$$root();
}
return options;
});
const collection = engine.createCollection(collectionName);
if (collection === null) {
throw new SilentError(`Invalid collection (${collectionName}).`);
}
return collection;
}
exports.getCollection = getCollection;
function getSchematic(collection, schematicName) {
return collection.createSchematic(schematicName);
}
exports.getSchematic = getSchematic;
//# sourceMappingURL=/users/hansl/sources/hansl/angular-cli/utilities/schematics.js.map