1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.getProjectMainFile = exports.isLib = exports.getProjectPath = exports.getProject = void 0;
|
4 | var config_1 = require("./config");
|
5 | var schematics_1 = require("@angular-devkit/schematics");
|
6 | function getProject(host, options) {
|
7 | var workspace = (0, config_1.getWorkspace)(host);
|
8 | if (!options.project) {
|
9 | var defaultProject = workspace
|
10 | .defaultProject;
|
11 | options.project =
|
12 | defaultProject !== undefined
|
13 | ? defaultProject
|
14 | : Object.keys(workspace.projects)[0];
|
15 | }
|
16 | return workspace.projects[options.project];
|
17 | }
|
18 | exports.getProject = getProject;
|
19 | function getProjectPath(host, options) {
|
20 | var project = getProject(host, options);
|
21 | if (project.root.slice(-1) === '/') {
|
22 | project.root = project.root.substring(0, project.root.length - 1);
|
23 | }
|
24 | if (options.path === undefined) {
|
25 | var projectDirName = project.projectType === 'application' ? 'app' : 'lib';
|
26 | return "".concat(project.root ? "/".concat(project.root) : '', "/src/").concat(projectDirName);
|
27 | }
|
28 | return options.path;
|
29 | }
|
30 | exports.getProjectPath = getProjectPath;
|
31 | function isLib(host, options) {
|
32 | var project = getProject(host, options);
|
33 | return project.projectType === 'library';
|
34 | }
|
35 | exports.isLib = isLib;
|
36 | function getProjectMainFile(host, options) {
|
37 | if (isLib(host, options)) {
|
38 | throw new schematics_1.SchematicsException("Invalid project type");
|
39 | }
|
40 | var project = getProject(host, options);
|
41 | var projectOptions = project.architect['build'].options;
|
42 | if (!(projectOptions === null || projectOptions === void 0 ? void 0 : projectOptions.main) && !(projectOptions === null || projectOptions === void 0 ? void 0 : projectOptions.browser)) {
|
43 | throw new schematics_1.SchematicsException("Could not find the main file ".concat(project));
|
44 | }
|
45 | return (projectOptions.browser || projectOptions.main);
|
46 | }
|
47 | exports.getProjectMainFile = getProjectMainFile;
|
48 |
|
\ | No newline at end of file |