rules.d.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.dev/license
  7. */
  8. import { Rule } from '@angular-devkit/schematics';
  9. import { CodeBlockCallback } from './code_block';
  10. /**
  11. * Adds an import to the root of the project.
  12. * @param project Name of the project to which to add the import.
  13. * @param callback Function that generates the code block which should be inserted.
  14. * @example
  15. *
  16. * ```ts
  17. * import { Rule } from '@angular-devkit/schematics';
  18. * import { addRootImport } from '@schematics/angular/utility';
  19. *
  20. * export default function(): Rule {
  21. * return addRootImport('default', ({code, external}) => {
  22. * return code`${external('MyModule', '@my/module')}.forRoot({})`;
  23. * });
  24. * }
  25. * ```
  26. */
  27. export declare function addRootImport(project: string, callback: CodeBlockCallback): Rule;
  28. /**
  29. * Adds a provider to the root of the project.
  30. * @param project Name of the project to which to add the import.
  31. * @param callback Function that generates the code block which should be inserted.
  32. * @example
  33. *
  34. * ```ts
  35. * import { Rule } from '@angular-devkit/schematics';
  36. * import { addRootProvider } from '@schematics/angular/utility';
  37. *
  38. * export default function(): Rule {
  39. * return addRootProvider('default', ({code, external}) => {
  40. * return code`${external('provideLibrary', '@my/library')}({})`;
  41. * });
  42. * }
  43. * ```
  44. */
  45. export declare function addRootProvider(project: string, callback: CodeBlockCallback): Rule;