source: trip-planner-front/node_modules/@angular/material/schematics/ng-add/setup-project.mjs@ 571e0df

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

initial commit

  • Property mode set to 100644
File size: 17.3 KB
Line 
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 });
19const schematics_1 = require("@angular-devkit/schematics");
20const schematics_2 = require("@angular/cdk/schematics");
21const workspace_1 = require("@schematics/angular/utility/workspace");
22const workspace_models_1 = require("@schematics/angular/utility/workspace-models");
23const material_fonts_1 = require("./fonts/material-fonts");
24const theming_1 = require("./theming/theming");
25/** Name of the Angular module that enables Angular browser animations. */
26const browserAnimationsModuleName = 'BrowserAnimationsModule';
27/** Name of the module that switches Angular animations to a noop implementation. */
28const noopAnimationsModuleName = 'NoopAnimationsModule';
29/**
30 * Scaffolds the basics of a Angular Material application, this includes:
31 * - Add Packages to package.json
32 * - Adds pre-built themes to styles.ext
33 * - Adds Browser Animation to app.module
34 */
35function default_1(options) {
36 return (host, context) => __awaiter(this, void 0, void 0, function* () {
37 const workspace = yield workspace_1.getWorkspace(host);
38 const project = schematics_2.getProjectFromWorkspace(workspace, options.project);
39 if (project.extensions.projectType === workspace_models_1.ProjectType.Application) {
40 return schematics_1.chain([
41 addAnimationsModule(options),
42 theming_1.addThemeToAppStyles(options),
43 material_fonts_1.addFontsToIndex(options),
44 addMaterialAppStyles(options),
45 theming_1.addTypographyClass(options),
46 ]);
47 }
48 context.logger.warn('Angular Material has been set up in your workspace. There is no additional setup ' +
49 'required for consuming Angular Material in your library project.\n\n' +
50 'If you intended to run the schematic on a different project, pass the `--project` ' +
51 'option.');
52 return;
53 });
54}
55exports.default = default_1;
56/**
57 * Adds an animation module to the root module of the specified project. In case the "animations"
58 * option is set to false, we still add the `NoopAnimationsModule` because otherwise various
59 * components of Angular Material will throw an exception.
60 */
61function addAnimationsModule(options) {
62 return (host, context) => __awaiter(this, void 0, void 0, function* () {
63 const workspace = yield workspace_1.getWorkspace(host);
64 const project = schematics_2.getProjectFromWorkspace(workspace, options.project);
65 const appModulePath = schematics_2.getAppModulePath(host, schematics_2.getProjectMainFile(project));
66 if (options.animations) {
67 // In case the project explicitly uses the NoopAnimationsModule, we should print a warning
68 // message that makes the user aware of the fact that we won't automatically set up
69 // animations. If we would add the BrowserAnimationsModule while the NoopAnimationsModule
70 // is already configured, we would cause unexpected behavior and runtime exceptions.
71 if (schematics_2.hasNgModuleImport(host, appModulePath, noopAnimationsModuleName)) {
72 context.logger.error(`Could not set up "${browserAnimationsModuleName}" ` +
73 `because "${noopAnimationsModuleName}" is already imported.`);
74 context.logger.info(`Please manually set up browser animations.`);
75 return;
76 }
77 schematics_2.addModuleImportToRootModule(host, browserAnimationsModuleName, '@angular/platform-browser/animations', project);
78 }
79 else if (!schematics_2.hasNgModuleImport(host, appModulePath, browserAnimationsModuleName)) {
80 // Do not add the NoopAnimationsModule module if the project already explicitly uses
81 // the BrowserAnimationsModule.
82 schematics_2.addModuleImportToRootModule(host, noopAnimationsModuleName, '@angular/platform-browser/animations', project);
83 }
84 });
85}
86/**
87 * Adds custom Material styles to the project style file. The custom CSS sets up the Roboto font
88 * and reset the default browser body margin.
89 */
90function addMaterialAppStyles(options) {
91 return (host, context) => __awaiter(this, void 0, void 0, function* () {
92 const workspace = yield workspace_1.getWorkspace(host);
93 const project = schematics_2.getProjectFromWorkspace(workspace, options.project);
94 const styleFilePath = schematics_2.getProjectStyleFile(project);
95 const logger = context.logger;
96 if (!styleFilePath) {
97 logger.error(`Could not find the default style file for this project.`);
98 logger.info(`Consider manually adding the Roboto font to your CSS.`);
99 logger.info(`More information at https://fonts.google.com/specimen/Roboto`);
100 return;
101 }
102 const buffer = host.read(styleFilePath);
103 if (!buffer) {
104 logger.error(`Could not read the default style file within the project ` +
105 `(${styleFilePath})`);
106 logger.info(`Please consider manually setting up the Roboto font.`);
107 return;
108 }
109 const htmlContent = buffer.toString();
110 const insertion = '\n' +
111 `html, body { height: 100%; }\n` +
112 `body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }\n`;
113 if (htmlContent.includes(insertion)) {
114 return;
115 }
116 const recorder = host.beginUpdate(styleFilePath);
117 recorder.insertLeft(htmlContent.length, insertion);
118 host.commitUpdate(recorder);
119 });
120}
121//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2V0dXAtcHJvamVjdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9zY2hlbWF0aWNzL25nLWFkZC9zZXR1cC1wcm9qZWN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7Ozs7O0dBTUc7Ozs7Ozs7Ozs7O0FBRUgsMkRBQStFO0FBQy9FLHdEQU9pQztBQUNqQyxxRUFBbUU7QUFDbkUsbUZBQXlFO0FBQ3pFLDJEQUF1RDtBQUV2RCwrQ0FBMEU7QUFFMUUsMEVBQTBFO0FBQzFFLE1BQU0sMkJBQTJCLEdBQUcseUJBQXlCLENBQUM7QUFFOUQsb0ZBQW9GO0FBQ3BGLE1BQU0sd0JBQXdCLEdBQUcsc0JBQXNCLENBQUM7QUFFeEQ7Ozs7O0dBS0c7QUFDSCxtQkFBd0IsT0FBZTtJ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BzOi8vZm9udHMuZ29vZ2xlLmNvbS9zcGVjaW1lbi9Sb2JvdG9gKTtcbiAgICAgIHJldHVybjtcbiAgICB9XG5cbiAgICBjb25zdCBidWZmZXIgPSBob3N0LnJlYWQoc3R5bGVGaWxlUGF0aCk7XG5cbiAgICBpZiAoIWJ1ZmZlcikge1xuICAgICAgbG9nZ2VyLmVycm9yKGBDb3VsZCBub3QgcmVhZCB0aGUgZGVmYXVsdCBzdHlsZSBmaWxlIHdpdGhpbiB0aGUgcHJvamVjdCBgICtcbiAgICAgICAgYCgke3N0eWxlRmlsZVBhdGh9KWApO1xuICAgICAgbG9nZ2VyLmluZm8oYFBsZWFzZSBjb25zaWRlciBtYW51YWxseSBzZXR0aW5nIHVwIHRoZSBSb2JvdG8gZm9udC5gKTtcbiAgICAgIHJldHVybjtcbiAgICB9XG5cbiAgICBjb25zdCBodG1sQ29udGVudCA9IGJ1ZmZlci50b1N0cmluZygpO1xuICAgIGNvbnN0IGluc2VydGlvbiA9ICdcXG4nICtcbiAgICAgIGBodG1sLCBib2R5IHsgaGVpZ2h0OiAxMDAlOyB9XFxuYCArXG4gICAgICBgYm9keSB7IG1hcmdpbjogMDsgZm9udC1mYW1pbHk6IFJvYm90bywgXCJIZWx2ZXRpY2EgTmV1ZVwiLCBzYW5zLXNlcmlmOyB9XFxuYDtcblxuICAgIGlmIChodG1sQ29udGVudC5pbmNsdWRlcyhpbnNlcnRpb24pKSB7XG4gICAgICByZXR1cm47XG4gICAgfVxuXG4gICAgY29uc3QgcmVjb3JkZXIgPSBob3N0LmJlZ2luVXBkYXRlKHN0eWxlRmlsZVBhdGgpO1xuXG4gICAgcmVjb3JkZXIuaW5zZXJ0TGVmdChodG1sQ29udGVudC5sZW5ndGgsIGluc2VydGlvbik7XG4gICAgaG9zdC5jb21taXRVcGRhdGUocmVjb3JkZXIpO1xuICB9O1xufVxuIl19
Note: See TracBrowser for help on using the repository browser.