"use strict"; /** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ Object.defineProperty(exports, "__esModule", { value: true }); const tasks_1 = require("@angular-devkit/schematics/tasks"); const package_config_1 = require("./package-config"); /** * Version range that will be used for the Angular CDK and Angular Material if this * schematic has been run outside of the CLI `ng add` command. In those cases, there * can be no dependency on `@angular/material` in the `package.json` file, and we need * to manually insert the dependency based on the build version placeholder. * * Note that the fallback version range does not use caret, but tilde because that is * the default for Angular framework dependencies in CLI projects. */ const fallbackMaterialVersionRange = `~16.2.14`; /** * Schematic factory entry-point for the `ng-add` schematic. The ng-add schematic will be * automatically executed if developers run `ng add @angular/material`. * * Since the Angular Material schematics depend on the schematic utility functions from the CDK, * we need to install the CDK before loading the schematic files that import from the CDK. */ function default_1(options) { return (host, context) => { // Version tag of the `@angular/core` dependency that has been loaded from the `package.json` // of the CLI project. This tag should be preferred because all Angular dependencies should // have the same version tag if possible. const ngCoreVersionTag = (0, package_config_1.getPackageVersionFromPackageJson)(host, '@angular/core'); const materialVersionRange = (0, package_config_1.getPackageVersionFromPackageJson)(host, '@angular/material'); const angularDependencyVersion = ngCoreVersionTag || `^16.0.0 || ^17.0.0`; // The CLI inserts `@angular/material` into the `package.json` before this schematic runs. // This means that we do not need to insert Angular Material into `package.json` files again. // In some cases though, it could happen that this schematic runs outside of the CLI `ng add` // command, or Material is only listed a dev dependency. If that is the case, we insert a // version based on the current build version (substituted version placeholder). if (materialVersionRange === null) { (0, package_config_1.addPackageToPackageJson)(host, '@angular/material', fallbackMaterialVersionRange); } (0, package_config_1.addPackageToPackageJson)(host, '@angular/cdk', materialVersionRange || fallbackMaterialVersionRange); (0, package_config_1.addPackageToPackageJson)(host, '@angular/forms', angularDependencyVersion); (0, package_config_1.addPackageToPackageJson)(host, '@angular/animations', angularDependencyVersion); // Since the Angular Material schematics depend on the schematic utility functions from the // CDK, we need to install the CDK before loading the schematic files that import from the CDK. const installTaskId = context.addTask(new tasks_1.NodePackageInstallTask()); context.addTask(new tasks_1.RunSchematicTask('ng-add-setup-project', options), [installTaskId]); }; } exports.default = default_1; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvc2NoZW1hdGljcy9uZy1hZGQvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7R0FNRzs7QUFHSCw0REFBMEY7QUFDMUYscURBQTJGO0FBRzNGOzs7Ozs7OztHQVFHO0FBQ0gsTUFBTSw0QkFBNEIsR0FBRyxvQkFBb0IsQ0FBQztBQUUxRDs7Ozs7O0dBTUc7QUFDSCxtQkFBeUIsT0FBZTtJQUN0QyxPQUFPLENBQUMsSUFBVSxFQUFFLE9BQXlCLEVBQUUsRUFBRTtRQUMvQyw2RkFBNkY7UUFDN0YsMkZBQTJGO1FBQzNGLHlDQUF5QztRQUN6QyxNQUFNLGdCQUFnQixHQUFHLElBQUEsaURBQWdDLEVBQUMsSUFBSSxFQUFFLGVBQWUsQ0FBQyxDQUFDO1FBQ2pGLE1BQU0sb0JBQW9CLEdBQUcsSUFBQSxpREFBZ0MsRUFBQyxJQUFJLEVBQUUsbUJBQW1CLENBQUMsQ0FBQztRQUN6RixNQUFNLHdCQUF3QixHQUFHLGdCQUFnQixJQUFJLFVBQVUsQ0FBQztRQUVoRSwwRkFBMEY7UUFDMUYsNkZBQTZGO1FBQzdGLDZGQUE2RjtRQUM3Rix5RkFBeUY7UUFDekYsZ0ZBQWdGO1FBQ2hGLElBQUksb0JBQW9CLEtBQUssSUFBSSxFQUFFO1lBQ2pDLElBQUEsd0NBQXVCLEVBQUMsSUFBSSxFQUFFLG1CQUFtQixFQUFFLDRCQUE0QixDQUFDLENBQUM7U0FDbEY7UUFFRCxJQUFBLHdDQUF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