UNPKG

4.05 kBSource Map (JSON)View Raw
1{"version":3,"file":"project.js","sourceRoot":"","sources":["../../../../../modules/schematics/schematics-core/utility/project.ts"],"names":[],"mappings":";;;AACA,mCAAwC;AACxC,yDAAuE;AAUvE,SAAgB,UAAU,CACxB,IAAU,EACV,OAAoE;IAEpE,IAAM,SAAS,GAAG,IAAA,qBAAY,EAAC,IAAI,CAAC,CAAC;IAErC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACrB,IAAM,cAAc,GAAI,SAAyC;aAC9D,cAAc,CAAC;QAClB,OAAO,CAAC,OAAO;YACb,cAAc,KAAK,SAAS;gBAC1B,CAAC,CAAC,cAAc;gBAChB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAC7C,CAAC;AAhBD,gCAgBC;AAED,SAAgB,cAAc,CAC5B,IAAU,EACV,OAAoE;IAEpE,IAAM,OAAO,GAAG,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAE1C,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACnC,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC/B,IAAM,cAAc,GAClB,OAAO,CAAC,WAAW,KAAK,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;QAExD,OAAO,UAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,WAAI,OAAO,CAAC,IAAI,CAAE,CAAC,CAAC,CAAC,EAAE,kBAAQ,cAAc,CAAE,CAAC;IAC3E,CAAC;IAED,OAAO,OAAO,CAAC,IAAI,CAAC;AACtB,CAAC;AAlBD,wCAkBC;AAED,SAAgB,KAAK,CACnB,IAAU,EACV,OAAoE;IAEpE,IAAM,OAAO,GAAG,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAE1C,OAAO,OAAO,CAAC,WAAW,KAAK,SAAS,CAAC;AAC3C,CAAC;AAPD,sBAOC;AAED,SAAgB,kBAAkB,CAChC,IAAU,EACV,OAAoE;IAEpE,IAAI,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,gCAAmB,CAAC,sBAAsB,CAAC,CAAC;IACxD,CAAC;IACD,IAAM,OAAO,GAAG,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1C,IAAM,cAAc,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;IAE1D,IAAI,CAAC,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,IAAI,CAAA,IAAI,CAAC,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,OAAO,CAAA,EAAE,CAAC;QACtD,MAAM,IAAI,gCAAmB,CAAC,uCAAgC,OAAO,CAAE,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,CAAC,cAAc,CAAC,OAAO,IAAI,cAAc,CAAC,IAAI,CAAW,CAAC;AACnE,CAAC;AAfD,gDAeC","sourcesContent":["import { TargetDefinition } from '@angular-devkit/core/src/workspace';\nimport { getWorkspace } from './config';\nimport { SchematicsException, Tree } from '@angular-devkit/schematics';\n\nexport interface WorkspaceProject {\n root: string;\n projectType: string;\n architect: {\n [key: string]: TargetDefinition;\n };\n}\n\nexport function getProject(\n host: Tree,\n options: { project?: string | undefined; path?: string | undefined }\n): WorkspaceProject {\n const workspace = getWorkspace(host);\n\n if (!options.project) {\n const defaultProject = (workspace as { defaultProject?: string })\n .defaultProject;\n options.project =\n defaultProject !== undefined\n ? defaultProject\n : Object.keys(workspace.projects)[0];\n }\n\n return workspace.projects[options.project];\n}\n\nexport function getProjectPath(\n host: Tree,\n options: { project?: string | undefined; path?: string | undefined }\n) {\n const project = getProject(host, options);\n\n if (project.root.slice(-1) === '/') {\n project.root = project.root.substring(0, project.root.length - 1);\n }\n\n if (options.path === undefined) {\n const projectDirName =\n project.projectType === 'application' ? 'app' : 'lib';\n\n return `${project.root ? `/${project.root}` : ''}/src/${projectDirName}`;\n }\n\n return options.path;\n}\n\nexport function isLib(\n host: Tree,\n options: { project?: string | undefined; path?: string | undefined }\n) {\n const project = getProject(host, options);\n\n return project.projectType === 'library';\n}\n\nexport function getProjectMainFile(\n host: Tree,\n options: { project?: string | undefined; path?: string | undefined }\n) {\n if (isLib(host, options)) {\n throw new SchematicsException(`Invalid project type`);\n }\n const project = getProject(host, options);\n const projectOptions = project.architect['build'].options;\n\n if (!projectOptions?.main && !projectOptions?.browser) {\n throw new SchematicsException(`Could not find the main file ${project}`);\n }\n\n return (projectOptions.browser || projectOptions.main) as string;\n}\n"]}
\No newline at end of file