source: trip-planner-front/node_modules/@angular/cdk/schematics/utils/build-component.mjs

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 31.6 KB
RevLine 
[6a3a178]1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
10 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
11 return new (P || (P = Promise))(function (resolve, reject) {
12 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
13 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
14 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
15 step((generator = generator.apply(thisArg, _arguments || [])).next());
16 });
17};
18Object.defineProperty(exports, "__esModule", { value: true });
19exports.buildComponent = void 0;
20const core_1 = require("@angular-devkit/core");
21const schematics_1 = require("@angular-devkit/schematics");
22const change_1 = require("@schematics/angular/utility/change");
23const workspace_1 = require("@schematics/angular/utility/workspace");
24const find_module_1 = require("@schematics/angular/utility/find-module");
25const parse_name_1 = require("@schematics/angular/utility/parse-name");
26const validation_1 = require("@schematics/angular/utility/validation");
27const workspace_models_1 = require("@schematics/angular/utility/workspace-models");
28const fs_1 = require("fs");
29const path_1 = require("path");
30const ts = require("typescript");
31const vendored_ast_utils_1 = require("../utils/vendored-ast-utils");
32const get_project_1 = require("./get-project");
33const schematic_options_1 = require("./schematic-options");
34/**
35 * Build a default project path for generating.
36 * @param project The project to build the path for.
37 */
38function buildDefaultPath(project) {
39 const root = project.sourceRoot
40 ? `/${project.sourceRoot}/`
41 : `/${project.root}/src/`;
42 const projectDirName = project.extensions.projectType === workspace_models_1.ProjectType.Application ? 'app' : 'lib';
43 return `${root}${projectDirName}`;
44}
45/**
46 * List of style extensions which are CSS compatible. All supported CLI style extensions can be
47 * found here: angular/angular-cli/master/packages/schematics/angular/ng-new/schema.json#L118-L122
48 */
49const supportedCssExtensions = ['css', 'scss', 'less'];
50function readIntoSourceFile(host, modulePath) {
51 const text = host.read(modulePath);
52 if (text === null) {
53 throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
54 }
55 return ts.createSourceFile(modulePath, text.toString('utf-8'), ts.ScriptTarget.Latest, true);
56}
57function addDeclarationToNgModule(options) {
58 return (host) => {
59 if (options.skipImport || !options.module) {
60 return host;
61 }
62 const modulePath = options.module;
63 let source = readIntoSourceFile(host, modulePath);
64 const componentPath = `/${options.path}/`
65 + (options.flat ? '' : core_1.strings.dasherize(options.name) + '/')
66 + core_1.strings.dasherize(options.name)
67 + '.component';
68 const relativePath = find_module_1.buildRelativePath(modulePath, componentPath);
69 const classifiedName = core_1.strings.classify(`${options.name}Component`);
70 const declarationChanges = vendored_ast_utils_1.addDeclarationToModule(source, modulePath, classifiedName, relativePath);
71 const declarationRecorder = host.beginUpdate(modulePath);
72 for (const change of declarationChanges) {
73 if (change instanceof change_1.InsertChange) {
74 declarationRecorder.insertLeft(change.pos, change.toAdd);
75 }
76 }
77 host.commitUpdate(declarationRecorder);
78 if (options.export) {
79 // Need to refresh the AST because we overwrote the file in the host.
80 source = readIntoSourceFile(host, modulePath);
81 const exportRecorder = host.beginUpdate(modulePath);
82 const exportChanges = vendored_ast_utils_1.addExportToModule(source, modulePath, core_1.strings.classify(`${options.name}Component`), relativePath);
83 for (const change of exportChanges) {
84 if (change instanceof change_1.InsertChange) {
85 exportRecorder.insertLeft(change.pos, change.toAdd);
86 }
87 }
88 host.commitUpdate(exportRecorder);
89 }
90 return host;
91 };
92}
93function buildSelector(options, projectPrefix) {
94 let selector = core_1.strings.dasherize(options.name);
95 if (options.prefix) {
96 selector = `${options.prefix}-${selector}`;
97 }
98 else if (options.prefix === undefined && projectPrefix) {
99 selector = `${projectPrefix}-${selector}`;
100 }
101 return selector;
102}
103/**
104 * Indents the text content with the amount of specified spaces. The spaces will be added after
105 * every line-break. This utility function can be used inside of EJS templates to properly
106 * include the additional files.
107 */
108function indentTextContent(text, numSpaces) {
109 // In the Material project there should be only LF line-endings, but the schematic files
110 // are not being linted and therefore there can be also CRLF or just CR line-endings.
111 return text.replace(/(\r\n|\r|\n)/g, `$1${' '.repeat(numSpaces)}`);
112}
113/**
114 * Rule that copies and interpolates the files that belong to this schematic context. Additionally
115 * a list of file paths can be passed to this rule in order to expose them inside the EJS
116 * template context.
117 *
118 * This allows inlining the external template or stylesheet files in EJS without having
119 * to manually duplicate the file content.
120 */
121function buildComponent(options, additionalFiles = {}) {
122 return (host, ctx) => __awaiter(this, void 0, void 0, function* () {
123 const context = ctx;
124 const workspace = yield workspace_1.getWorkspace(host);
125 const project = get_project_1.getProjectFromWorkspace(workspace, options.project);
126 const defaultComponentOptions = schematic_options_1.getDefaultComponentOptions(project);
127 // TODO(devversion): Remove if we drop support for older CLI versions.
128 // This handles an unreported breaking change from the @angular-devkit/schematics. Previously
129 // the description path resolved to the factory file, but starting from 6.2.0, it resolves
130 // to the factory directory.
131 const schematicPath = fs_1.statSync(context.schematic.description.path).isDirectory() ?
132 context.schematic.description.path :
133 path_1.dirname(context.schematic.description.path);
134 const schematicFilesUrl = './files';
135 const schematicFilesPath = path_1.resolve(schematicPath, schematicFilesUrl);
136 // Add the default component option values to the options if an option is not explicitly
137 // specified but a default component option is available.
138 Object.keys(options)
139 .filter(key => options[key] == null &&
140 defaultComponentOptions[key])
141 .forEach(key => options[key] =
142 defaultComponentOptions[key]);
143 if (options.path === undefined) {
144 // TODO(jelbourn): figure out if the need for this `as any` is a bug due to two different
145 // incompatible `ProjectDefinition` classes in @angular-devkit
146 options.path = buildDefaultPath(project);
147 }
148 options.module = find_module_1.findModuleFromOptions(host, options);
149 const parsedPath = parse_name_1.parseName(options.path, options.name);
150 options.name = parsedPath.name;
151 options.path = parsedPath.path;
152 options.selector = options.selector || buildSelector(options, project.prefix);
153 validation_1.validateName(options.name);
154 validation_1.validateHtmlSelector(options.selector);
155 // In case the specified style extension is not part of the supported CSS supersets,
156 // we generate the stylesheets with the "css" extension. This ensures that we don't
157 // accidentally generate invalid stylesheets (e.g. drag-drop-comp.styl) which will
158 // break the Angular CLI project. See: https://github.com/angular/components/issues/15164
159 if (!supportedCssExtensions.includes(options.style)) {
160 // TODO: Cast is necessary as we can't use the Style enum which has been introduced
161 // within CLI v7.3.0-rc.0. This would break the schematic for older CLI versions.
162 options.style = 'css';
163 }
164 // Object that will be used as context for the EJS templates.
165 const baseTemplateContext = Object.assign(Object.assign(Object.assign({}, core_1.strings), { 'if-flat': (s) => options.flat ? '' : s }), options);
166 // Key-value object that includes the specified additional files with their loaded content.
167 // The resolved contents can be used inside EJS templates.
168 const resolvedFiles = {};
169 for (let key in additionalFiles) {
170 if (additionalFiles[key]) {
171 const fileContent = fs_1.readFileSync(path_1.join(schematicFilesPath, additionalFiles[key]), 'utf-8');
172 // Interpolate the additional files with the base EJS template context.
173 resolvedFiles[key] = core_1.template(fileContent)(baseTemplateContext);
174 }
175 }
176 const templateSource = schematics_1.apply(schematics_1.url(schematicFilesUrl), [
177 options.skipTests ? schematics_1.filter(path => !path.endsWith('.spec.ts.template')) : schematics_1.noop(),
178 options.inlineStyle ? schematics_1.filter(path => !path.endsWith('.__style__.template')) : schematics_1.noop(),
179 options.inlineTemplate ? schematics_1.filter(path => !path.endsWith('.html.template')) : schematics_1.noop(),
180 // Treat the template options as any, because the type definition for the template options
181 // is made unnecessarily explicit. Every type of object can be used in the EJS template.
182 schematics_1.applyTemplates(Object.assign({ indentTextContent, resolvedFiles }, baseTemplateContext)),
183 // TODO(devversion): figure out why we cannot just remove the first parameter
184 // See for example: angular-cli#schematics/angular/component/index.ts#L160
185 schematics_1.move(null, parsedPath.path),
186 ]);
187 return () => schematics_1.chain([
188 schematics_1.branchAndMerge(schematics_1.chain([
189 addDeclarationToNgModule(options),
190 schematics_1.mergeWith(templateSource),
191 ])),
192 ])(host, context);
193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