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 | */
|
---|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
10 | exports.schematic = exports.externalSchematic = void 0;
|
---|
11 | const rxjs_1 = require("rxjs");
|
---|
12 | const operators_1 = require("rxjs/operators");
|
---|
13 | const interface_1 = require("../tree/interface");
|
---|
14 | const static_1 = require("../tree/static");
|
---|
15 | /**
|
---|
16 | * Run a schematic from a separate collection.
|
---|
17 | *
|
---|
18 | * @param collectionName The name of the collection that contains the schematic to run.
|
---|
19 | * @param schematicName The name of the schematic to run.
|
---|
20 | * @param options The options to pass as input to the RuleFactory.
|
---|
21 | */
|
---|
22 | function externalSchematic(collectionName, schematicName, options, executionOptions) {
|
---|
23 | return (input, context) => {
|
---|
24 | const collection = context.engine.createCollection(collectionName, context.schematic.collection);
|
---|
25 | const schematic = collection.createSchematic(schematicName);
|
---|
26 | return schematic.call(options, rxjs_1.of(static_1.branch(input)), context, executionOptions).pipe(operators_1.last(), operators_1.map((x) => {
|
---|
27 | input.merge(x, interface_1.MergeStrategy.AllowOverwriteConflict);
|
---|
28 | return input;
|
---|
29 | }));
|
---|
30 | };
|
---|
31 | }
|
---|
32 | exports.externalSchematic = externalSchematic;
|
---|
33 | /**
|
---|
34 | * Run a schematic from the same collection.
|
---|
35 | *
|
---|
36 | * @param schematicName The name of the schematic to run.
|
---|
37 | * @param options The options to pass as input to the RuleFactory.
|
---|
38 | */
|
---|
39 | function schematic(schematicName, options, executionOptions) {
|
---|
40 | return (input, context) => {
|
---|
41 | const collection = context.schematic.collection;
|
---|
42 | const schematic = collection.createSchematic(schematicName, true);
|
---|
43 | return schematic.call(options, rxjs_1.of(static_1.branch(input)), context, executionOptions).pipe(operators_1.last(), operators_1.map((x) => {
|
---|
44 | // We allow overwrite conflict here because they're the only merge conflict we particularly
|
---|
45 | // don't want to deal with; the input tree might have an OVERWRITE which the sub
|
---|
46 | input.merge(x, interface_1.MergeStrategy.AllowOverwriteConflict);
|
---|
47 | return input;
|
---|
48 | }));
|
---|
49 | };
|
---|
50 | }
|
---|
51 | exports.schematic = schematic;
|
---|