UNPKG

@ngrx/schematics

Version:

NgRx Schematics for Angular

38 lines 2.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; const schematics_1 = require("@angular-devkit/schematics"); const schematics_core_1 = require("../../schematics-core"); function default_1(options) { return (host, context) => { const projectConfig = (0, schematics_core_1.getProject)(host, options); options.path = (0, schematics_core_1.getProjectPath)(host, options); const parsedPath = (0, schematics_core_1.parseName)(options.path, options.name); options.name = parsedPath.name; options.path = parsedPath.path; if (options.module) { options.module = (0, schematics_core_1.findModuleFromOptions)(host, options); } const templateOptions = { ...schematics_core_1.stringUtils, 'if-flat': (s) => (options.flat ? '' : s), 'group-actions': (name) => schematics_core_1.stringUtils.group(name, options.group ? 'actions' : ''), 'group-models': (name) => schematics_core_1.stringUtils.group(name, options.group ? 'models' : ''), 'group-reducers': (s) => schematics_core_1.stringUtils.group(s, options.group ? 'reducers' : ''), ...options, }; const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [ options.skipTests ? (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts.template')) : (0, schematics_1.noop)(), (0, schematics_1.applyTemplates)(templateOptions), (0, schematics_1.move)(parsedPath.path), ]); return (0, schematics_1.chain)([ (0, schematics_core_1.addReducerToState)({ ...options, plural: true }), (0, schematics_core_1.addReducerImportToNgModule)({ ...options, plural: true }), (0, schematics_1.branchAndMerge)((0, schematics_1.mergeWith)(templateSource)), ])(host, context); }; } //# sourceMappingURL=index.js.map