source: trip-planner-front/node_modules/@angular/material/schematics/ng-update/migrations/theming-api-v12/theming-api-migration.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: 6.2 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 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.ThemingApiMigration = void 0;
11const core_1 = require("@angular-devkit/core");
12const schematics_1 = require("@angular/cdk/schematics");
13const migration_1 = require("./migration");
14/** Migration that switches all Sass files using Material theming APIs to `@use`. */
15class ThemingApiMigration extends schematics_1.DevkitMigration {
16 constructor() {
17 super(...arguments);
18 this.enabled = this.targetVersion === schematics_1.TargetVersion.V12;
19 }
20 visitStylesheet(stylesheet) {
21 if (core_1.extname(stylesheet.filePath) === '.scss') {
22 const content = stylesheet.content;
23 const migratedContent = content ? migration_1.migrateFileContent(content, '~@angular/material/', '~@angular/cdk/', '~@angular/material', '~@angular/cdk', undefined, /material\/prebuilt-themes|cdk\/.*-prebuilt/) : content;
24 if (migratedContent && migratedContent !== content) {
25 this.fileSystem.edit(stylesheet.filePath)
26 .remove(0, stylesheet.content.length)
27 .insertLeft(0, migratedContent);
28 ThemingApiMigration.migratedFileCount++;
29 }
30 }
31 }
32 /** Logs out the number of migrated files at the end of the migration. */
33 static globalPostMigration(_tree, context) {
34 const count = ThemingApiMigration.migratedFileCount;
35 if (count > 0) {
36 context.logger.info(`Migrated ${count === 1 ? `1 file` : `${count} files`} to the ` +
37 `new Angular Material theming API.`);
38 ThemingApiMigration.migratedFileCount = 0;
39 }
40 }
41}
42exports.ThemingApiMigration = ThemingApiMigration;
43/** Number of files that have been migrated. */
44ThemingApiMigration.migratedFileCount = 0;
45//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGhlbWluZy1hcGktbWlncmF0aW9uLm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owser for help on using the repository browser.