UNPKG

2.07 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.getProjectMainFile = exports.isLib = exports.getProjectPath = exports.getProject = void 0;
4var config_1 = require("./config");
5var schematics_1 = require("@angular-devkit/schematics");
6function 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}
18exports.getProject = getProject;
19function 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}
30exports.getProjectPath = getProjectPath;
31function isLib(host, options) {
32 var project = getProject(host, options);
33 return project.projectType === 'library';
34}
35exports.isLib = isLib;
36function 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}
47exports.getProjectMainFile = getProjectMainFile;
48//# sourceMappingURL=project.js.map
\No newline at end of file