UNPKG

15.2 kBJavaScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { SchematicsException } from '@angular-devkit/schematics';
9import { readWorkspace } from '@schematics/angular/utility';
10import * as ts from 'typescript';
11export async function getProject(host, projectName) {
12 const workspace = await readWorkspace(host);
13 const project = workspace.projects.get(projectName);
14 if (!project || project.extensions.projectType !== 'application') {
15 throw new SchematicsException(`Universal requires a project type of 'application'.`);
16 }
17 return project;
18}
19export function stripTsExtension(file) {
20 return file.replace(/\.ts$/, '');
21}
22export async function getOutputPath(host, projectName, target) {
23 // Generate new output paths
24 const project = await getProject(host, projectName);
25 const serverTarget = project.targets.get(target);
26 if (!serverTarget || !serverTarget.options) {
27 throw new SchematicsException(`Cannot find 'options' for ${projectName} ${target} target.`);
28 }
29 const { outputPath } = serverTarget.options;
30 if (typeof outputPath !== 'string') {
31 throw new SchematicsException(`outputPath for ${projectName} ${target} target is not a string.`);
32 }
33 return outputPath;
34}
35export function findImport(sourceFile, moduleName, symbolName) {
36 // Only look through the top-level imports.
37 for (const node of sourceFile.statements) {
38 if (!ts.isImportDeclaration(node) ||
39 !ts.isStringLiteral(node.moduleSpecifier) ||
40 node.moduleSpecifier.text !== moduleName) {
41 continue;
42 }
43 const namedBindings = node.importClause && node.importClause.namedBindings;
44 if (!namedBindings || !ts.isNamedImports(namedBindings)) {
45 continue;
46 }
47 if (namedBindings.elements.some((element) => element.name.text === symbolName)) {
48 return namedBindings;
49 }
50 }
51 return null;
52}
53/** Gets import information about the specified identifier by using the Type checker. */
54export function getImportOfIdentifier(typeChecker, node) {
55 const symbol = typeChecker.getSymbolAtLocation(node);
56 if (!symbol || !symbol.declarations.length) {
57 return null;
58 }
59 const decl = symbol.declarations[0];
60 if (!ts.isImportSpecifier(decl)) {
61 return null;
62 }
63 const importDecl = decl.parent.parent.parent;
64 if (!ts.isStringLiteral(importDecl.moduleSpecifier)) {
65 return null;
66 }
67 return {
68 // Handles aliased imports: e.g. "import {Component as myComp} from ...";
69 name: decl.propertyName ? decl.propertyName.text : decl.name.text,
70 importModule: importDecl.moduleSpecifier.text,
71 node: importDecl,
72 };
73}
74export function addInitialNavigation(node) {
75 const existingOptions = node.arguments[1];
76 // If the user has explicitly set initialNavigation, we respect that
77 if (existingOptions &&
78 existingOptions.properties.some((exp) => ts.isPropertyAssignment(exp) &&
79 ts.isIdentifier(exp.name) &&
80 exp.name.text === 'initialNavigation')) {
81 return node;
82 }
83 const enabledLiteral = ts.factory.createStringLiteral('enabledBlocking');
84 // TypeScript will emit the Node with double quotes.
85 // In schematics we usually write code with a single quotes
86 // eslint-disable-next-line @typescript-eslint/no-explicit-any
87 enabledLiteral.singleQuote = true;
88 const initialNavigationProperty = ts.factory.createPropertyAssignment('initialNavigation', enabledLiteral);
89 const routerOptions = existingOptions
90 ? ts.factory.updateObjectLiteralExpression(existingOptions, ts.factory.createNodeArray([...existingOptions.properties, initialNavigationProperty]))
91 : ts.factory.createObjectLiteralExpression([initialNavigationProperty], true);
92 const args = [node.arguments[0], routerOptions];
93 return ts.factory.createCallExpression(node.expression, node.typeArguments, args);
94}
95//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9tb2R1bGVzL2V4cHJlc3MtZW5naW5lL3NjaGVtYXRpY3MvdXRpbHMvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBR0gsT0FBTyxFQUFFLG1CQUFtQixFQUFFLE1BQU0sNEJBQTRCLENBQUM7QUFFakUsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQzVELE9BQU8sS0FBSyxFQUFFLE1BQU0sWUFBWSxDQUFDO0FBRWpDLE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