index.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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.dev/license
  8. */
  9. Object.defineProperty(exports, "__esModule", { value: true });
  10. exports.default = default_1;
  11. const tasks_1 = require("@angular-devkit/schematics/tasks");
  12. const package_config_1 = require("./package-config");
  13. /**
  14. * Schematic factory entry-point for the `ng-add` schematic. The ng-add schematic will be
  15. * automatically executed if developers run `ng add @angular/cdk`.
  16. *
  17. * By default, the CLI already installs the package that has been specified with `ng add`.
  18. * We just store the version in the `package.json` in case the package manager didn't. Also
  19. * this ensures that there will be no error that says that the CDK does not support `ng add`.
  20. */
  21. function default_1() {
  22. return (host, context) => {
  23. // The CLI inserts `@angular/cdk` into the `package.json` before this schematic runs. This
  24. // means that we do not need to insert the CDK into `package.json` files again. In some cases
  25. // though, it could happen that this schematic runs outside of the CLI `ng add` command, or
  26. // the CDK is only listed as a dev dependency. If that is the case, we insert a version based
  27. // on the current build version (substituted version placeholder).
  28. if ((0, package_config_1.getPackageVersionFromPackageJson)(host, '@angular/cdk') === null) {
  29. // In order to align the CDK version with other Angular dependencies that are setup by
  30. // `@schematics/angular`, we use tilde instead of caret. This is default for Angular
  31. // dependencies in new CLI projects.
  32. (0, package_config_1.addPackageToPackageJson)(host, '@angular/cdk', `~19.2.17`);
  33. // Add a task to run the package manager. This is necessary because we updated the
  34. // workspace "package.json" file and we want lock files to reflect the new version range.
  35. context.addTask(new tasks_1.NodePackageInstallTask());
  36. }
  37. };
  38. }
  39. //# sourceMappingURL=index.js.map