index.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. "use strict";
  2. Object.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. */
  10. const core_1 = require("@angular-devkit/core");
  11. const schematics_1 = require("@angular-devkit/schematics");
  12. const paths_1 = require("../utility/paths");
  13. const workspace_1 = require("../utility/workspace");
  14. const workspace_models_1 = require("../utility/workspace-models");
  15. function default_1(options) {
  16. return async (host) => {
  17. const appProject = options.relatedAppName;
  18. const workspace = await workspace_1.getWorkspace(host);
  19. const project = workspace.projects.get(appProject);
  20. if (!project) {
  21. throw new schematics_1.SchematicsException(`Project name "${appProject}" doesn't not exist.`);
  22. }
  23. const root = core_1.join(core_1.normalize(project.root), 'e2e');
  24. project.targets.add({
  25. name: 'e2e',
  26. builder: workspace_models_1.Builders.Protractor,
  27. options: {
  28. protractorConfig: `${root}/protractor.conf.js`,
  29. devServerTarget: `${options.relatedAppName}:serve`,
  30. },
  31. configurations: {
  32. production: {
  33. devServerTarget: `${options.relatedAppName}:serve:production`,
  34. },
  35. },
  36. });
  37. const lintTarget = project.targets.get('lint');
  38. if (lintTarget && lintTarget.options && Array.isArray(lintTarget.options.tsConfig)) {
  39. lintTarget.options.tsConfig =
  40. lintTarget.options.tsConfig.concat(`${root}/tsconfig.json`);
  41. }
  42. return schematics_1.chain([
  43. workspace_1.updateWorkspace(workspace),
  44. schematics_1.mergeWith(schematics_1.apply(schematics_1.url('./files'), [
  45. schematics_1.applyTemplates({
  46. utils: core_1.strings,
  47. ...options,
  48. relativePathToWorkspaceRoot: paths_1.relativePathToWorkspaceRoot(root),
  49. }),
  50. schematics_1.move(root),
  51. ])),
  52. ]);
  53. };
  54. }
  55. exports.default = default_1;