1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
10 | const schematics_1 = require("@angular-devkit/schematics");
|
11 | const add_declaration_to_ng_module_1 = require("../utility/add-declaration-to-ng-module");
|
12 | const find_module_1 = require("../utility/find-module");
|
13 | const parse_name_1 = require("../utility/parse-name");
|
14 | const validation_1 = require("../utility/validation");
|
15 | const workspace_1 = require("../utility/workspace");
|
16 | function default_1(options) {
|
17 | return async (host) => {
|
18 | options.path ??= await (0, workspace_1.createDefaultPath)(host, options.project);
|
19 | options.module = (0, find_module_1.findModuleFromOptions)(host, options);
|
20 | const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
|
21 | options.name = parsedPath.name;
|
22 | options.path = parsedPath.path;
|
23 | (0, validation_1.validateClassName)(schematics_1.strings.classify(options.name));
|
24 | const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
25 | options.skipTests ? (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts.template')) : (0, schematics_1.noop)(),
|
26 | (0, schematics_1.applyTemplates)({
|
27 | ...schematics_1.strings,
|
28 | 'if-flat': (s) => (options.flat ? '' : s),
|
29 | ...options,
|
30 | }),
|
31 | (0, schematics_1.move)(parsedPath.path),
|
32 | ]);
|
33 | return (0, schematics_1.chain)([
|
34 | (0, add_declaration_to_ng_module_1.addDeclarationToNgModule)({
|
35 | type: 'pipe',
|
36 | ...options,
|
37 | }),
|
38 | (0, schematics_1.mergeWith)(templateSource),
|
39 | ]);
|
40 | };
|
41 | }
|
42 | exports.default = default_1;
|