UNPKG

2.41 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3/**
4 * @license
5 * Copyright Google Inc. All Rights Reserved.
6 *
7 * Use of this source code is governed by an MIT-style license that can be
8 * found in the LICENSE file at https://angular.io/license
9 */
10const core_1 = require("@angular-devkit/core");
11const schematics_1 = require("@angular-devkit/schematics");
12const paths_1 = require("../utility/paths");
13const tsconfig_1 = require("../utility/tsconfig");
14const workspace_1 = require("../utility/workspace");
15const workspace_models_1 = require("../utility/workspace-models");
16function default_1(options) {
17 return async (host) => {
18 const appProject = options.relatedAppName;
19 const workspace = await workspace_1.getWorkspace(host);
20 const project = workspace.projects.get(appProject);
21 if (!project) {
22 throw new schematics_1.SchematicsException(`Project name "${appProject}" doesn't not exist.`);
23 }
24 tsconfig_1.verifyBaseTsConfigExists(host);
25 const root = core_1.join(core_1.normalize(project.root), 'e2e');
26 project.targets.add({
27 name: 'e2e',
28 builder: workspace_models_1.Builders.Protractor,
29 options: {
30 protractorConfig: `${root}/protractor.conf.js`,
31 devServerTarget: `${options.relatedAppName}:serve`,
32 },
33 configurations: {
34 production: {
35 devServerTarget: `${options.relatedAppName}:serve:production`,
36 },
37 },
38 });
39 const e2eTsConfig = `${root}/tsconfig.json`;
40 const lintTarget = project.targets.get('lint');
41 if (lintTarget && lintTarget.options && Array.isArray(lintTarget.options.tsConfig)) {
42 lintTarget.options.tsConfig =
43 lintTarget.options.tsConfig.concat(e2eTsConfig);
44 }
45 return schematics_1.chain([
46 workspace_1.updateWorkspace(workspace),
47 schematics_1.mergeWith(schematics_1.apply(schematics_1.url('./files'), [
48 schematics_1.applyTemplates({
49 utils: core_1.strings,
50 ...options,
51 relativePathToWorkspaceRoot: paths_1.relativePathToWorkspaceRoot(root),
52 }),
53 schematics_1.move(root),
54 ])),
55 ]);
56 };
57}
58exports.default = default_1;