source: trip-planner-front/node_modules/@angular-devkit/schematics/src/engine/schematic.js@ 6a80231

Last change on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.5 KB
Line 
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.SchematicImpl = exports.InvalidSchematicsNameException = void 0;
11const core_1 = require("@angular-devkit/core");
12const rxjs_1 = require("rxjs");
13const operators_1 = require("rxjs/operators");
14const call_1 = require("../rules/call");
15const scoped_1 = require("../tree/scoped");
16class InvalidSchematicsNameException extends core_1.BaseException {
17 constructor(name) {
18 super(`Schematics has invalid name: "${name}".`);
19 }
20}
21exports.InvalidSchematicsNameException = InvalidSchematicsNameException;
22class SchematicImpl {
23 constructor(_description, _factory, _collection, _engine) {
24 this._description = _description;
25 this._factory = _factory;
26 this._collection = _collection;
27 this._engine = _engine;
28 if (!_description.name.match(/^[-@/_.a-zA-Z0-9]+$/)) {
29 throw new InvalidSchematicsNameException(_description.name);
30 }
31 }
32 get description() {
33 return this._description;
34 }
35 get collection() {
36 return this._collection;
37 }
38 call(options, host, parentContext, executionOptions) {
39 const context = this._engine.createContext(this, parentContext, executionOptions);
40 return host.pipe(operators_1.first(), operators_1.concatMap((tree) => this._engine
41 .transformOptions(this, options, context)
42 .pipe(operators_1.map((o) => [tree, o]))), operators_1.concatMap(([tree, transformedOptions]) => {
43 let input;
44 let scoped = false;
45 if (executionOptions && executionOptions.scope) {
46 scoped = true;
47 input = new scoped_1.ScopedTree(tree, executionOptions.scope);
48 }
49 else {
50 input = tree;
51 }
52 return call_1.callRule(this._factory(transformedOptions), rxjs_1.of(input), context).pipe(operators_1.map((output) => {
53 if (output === input) {
54 return tree;
55 }
56 else if (scoped) {
57 tree.merge(output);
58 return tree;
59 }
60 else {
61 return output;
62 }
63 }));
64 }));
65 }
66}
67exports.SchematicImpl = SchematicImpl;
Note: See TracBrowser for help on using the repository browser.