index.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. */
  9. Object.defineProperty(exports, "__esModule", { value: true });
  10. const package_config_1 = require("./package-config");
  11. /** Name of the Angular CDK version that is shipped together with the schematics. */
  12. exports.cdkVersion = loadPackageVersionGracefully('@angular/cdk');
  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) => {
  23. // In order to align the CDK version with the other Angular dependencies, we use tilde
  24. // instead of caret. This is default for Angular dependencies in new CLI projects.
  25. package_config_1.addPackageToPackageJson(host, '@angular/cdk', `~${exports.cdkVersion}`);
  26. };
  27. }
  28. exports.default = default_1;
  29. /** Loads the full version from the given Angular package gracefully. */
  30. function loadPackageVersionGracefully(packageName) {
  31. try {
  32. return require(`${packageName}/package.json`).version;
  33. }
  34. catch (_a) {
  35. return null;
  36. }
  37. }
  38. //# sourceMappingURL=index.js.map