UNPKG

2.55 kBJavaScriptView Raw
1"use strict";
2var __assign = (this && this.__assign) || function () {
3 __assign = Object.assign || function(t) {
4 for (var s, i = 1, n = arguments.length; i < n; i++) {
5 s = arguments[i];
6 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7 t[p] = s[p];
8 }
9 return t;
10 };
11 return __assign.apply(this, arguments);
12};
13Object.defineProperty(exports, "__esModule", { value: true });
14var schematics_1 = require("@angular-devkit/schematics");
15var schematics_core_1 = require("../../schematics-core");
16function default_1(options) {
17 return function (host, context) {
18 var projectConfig = (0, schematics_core_1.getProject)(host, options);
19 options.path = (0, schematics_core_1.getProjectPath)(host, options);
20 var parsedPath = (0, schematics_core_1.parseName)(options.path, options.name);
21 options.name = parsedPath.name;
22 options.path = parsedPath.path;
23 if (options.module) {
24 options.module = (0, schematics_core_1.findModuleFromOptions)(host, options);
25 }
26 var templateOptions = __assign(__assign(__assign({}, schematics_core_1.stringUtils), { 'if-flat': function (s) { return (options.flat ? '' : s); }, 'group-actions': function (name) {
27 return schematics_core_1.stringUtils.group(name, options.group ? 'actions' : '');
28 }, 'group-models': function (name) {
29 return schematics_core_1.stringUtils.group(name, options.group ? 'models' : '');
30 }, 'group-reducers': function (s) {
31 return schematics_core_1.stringUtils.group(s, options.group ? 'reducers' : '');
32 } }), options);
33 var templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
34 options.skipTests
35 ? (0, schematics_1.filter)(function (path) { return !path.endsWith('.spec.ts.template'); })
36 : (0, schematics_1.noop)(),
37 (0, schematics_1.applyTemplates)(templateOptions),
38 (0, schematics_1.move)(parsedPath.path),
39 ]);
40 return (0, schematics_1.chain)([
41 (0, schematics_core_1.addReducerToState)(__assign(__assign({}, options), { plural: true })),
42 (0, schematics_core_1.addReducerImportToNgModule)(__assign(__assign({}, options), { plural: true })),
43 (0, schematics_1.branchAndMerge)((0, schematics_1.mergeWith)(templateSource)),
44 ])(host, context);
45 };
46}
47exports.default = default_1;
48//# sourceMappingURL=index.js.map
\No newline at end of file