1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
10 | exports.generateFromFiles = void 0;
|
11 | const core_1 = require("@angular-devkit/core");
|
12 | const schematics_1 = require("@angular-devkit/schematics");
|
13 | const lint_fix_1 = require("./lint-fix");
|
14 | const parse_name_1 = require("./parse-name");
|
15 | const workspace_1 = require("./workspace");
|
16 | function generateFromFiles(options, extraTemplateValues = {}) {
|
17 | return async (host) => {
|
18 | var _a, _b, _c;
|
19 | (_a = options.path) !== null && _a !== void 0 ? _a : (options.path = await workspace_1.createDefaultPath(host, options.project));
|
20 | (_b = options.prefix) !== null && _b !== void 0 ? _b : (options.prefix = '');
|
21 | (_c = options.flat) !== null && _c !== void 0 ? _c : (options.flat = true);
|
22 | const parsedPath = parse_name_1.parseName(options.path, options.name);
|
23 | options.name = parsedPath.name;
|
24 | options.path = parsedPath.path;
|
25 | const templateSource = schematics_1.apply(schematics_1.url('./files'), [
|
26 | options.skipTests ? schematics_1.filter((path) => !path.endsWith('.spec.ts.template')) : schematics_1.noop(),
|
27 | schematics_1.applyTemplates({
|
28 | ...core_1.strings,
|
29 | ...options,
|
30 | ...extraTemplateValues,
|
31 | }),
|
32 | schematics_1.move(parsedPath.path + (options.flat ? '' : '/' + core_1.strings.dasherize(options.name))),
|
33 | ]);
|
34 | return schematics_1.chain([
|
35 | schematics_1.mergeWith(templateSource),
|
36 | options.lintFix ? lint_fix_1.applyLintFix(options.path) : schematics_1.noop(),
|
37 | ]);
|
38 | };
|
39 | }
|
40 | exports.generateFromFiles = generateFromFiles;
|