You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
3.1 KiB
82 lines
3.1 KiB
"use strict";
|
|
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const core_1 = require("@angular-devkit/core");
|
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
const dependencies_1 = require("../utility/dependencies");
|
|
const json_file_1 = require("../utility/json-file");
|
|
const paths_1 = require("../utility/paths");
|
|
const workspace_1 = require("../utility/workspace");
|
|
const workspace_models_1 = require("../utility/workspace-models");
|
|
function addScriptsToPackageJson() {
|
|
return (host) => {
|
|
const pkgJson = new json_file_1.JSONFile(host, 'package.json');
|
|
const e2eScriptPath = ['scripts', 'e2e'];
|
|
if (!pkgJson.get(e2eScriptPath)) {
|
|
pkgJson.modify(e2eScriptPath, 'ng e2e', false);
|
|
}
|
|
};
|
|
}
|
|
function default_1(options) {
|
|
return async (host) => {
|
|
const appProject = options.relatedAppName;
|
|
const workspace = await workspace_1.getWorkspace(host);
|
|
const project = workspace.projects.get(appProject);
|
|
if (!project) {
|
|
throw new schematics_1.SchematicsException(`Project name "${appProject}" doesn't not exist.`);
|
|
}
|
|
const root = core_1.join(core_1.normalize(project.root), 'e2e');
|
|
project.targets.add({
|
|
name: 'e2e',
|
|
builder: workspace_models_1.Builders.Protractor,
|
|
defaultConfiguration: 'development',
|
|
options: {
|
|
protractorConfig: `${root}/protractor.conf.js`,
|
|
},
|
|
configurations: {
|
|
production: {
|
|
devServerTarget: `${options.relatedAppName}:serve:production`,
|
|
},
|
|
development: {
|
|
devServerTarget: `${options.relatedAppName}:serve:development`,
|
|
},
|
|
},
|
|
});
|
|
return schematics_1.chain([
|
|
workspace_1.updateWorkspace(workspace),
|
|
schematics_1.mergeWith(schematics_1.apply(schematics_1.url('./files'), [
|
|
schematics_1.applyTemplates({
|
|
utils: core_1.strings,
|
|
...options,
|
|
relativePathToWorkspaceRoot: paths_1.relativePathToWorkspaceRoot(root),
|
|
}),
|
|
schematics_1.move(root),
|
|
])),
|
|
(host) => [
|
|
{
|
|
type: dependencies_1.NodeDependencyType.Dev,
|
|
name: 'protractor',
|
|
version: '~7.0.0',
|
|
},
|
|
{
|
|
type: dependencies_1.NodeDependencyType.Dev,
|
|
name: 'jasmine-spec-reporter',
|
|
version: '~7.0.0',
|
|
},
|
|
{
|
|
type: dependencies_1.NodeDependencyType.Dev,
|
|
name: 'ts-node',
|
|
version: '~9.1.1',
|
|
},
|
|
].forEach((dep) => dependencies_1.addPackageJsonDependency(host, dep)),
|
|
addScriptsToPackageJson(),
|
|
]);
|
|
};
|
|
}
|
|
exports.default = default_1;
|