devkit-migration.d.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  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 { SchematicContext, Tree } from '@angular-devkit/schematics';
  9. import { workspaces } from '@angular-devkit/core';
  10. import { Constructor, Migration, PostMigrationAction } from '../update-tool/migration';
  11. import { TargetVersion } from '../update-tool/target-version';
  12. export type DevkitContext = {
  13. /** Devkit tree for the current migrations. Can be used to insert/remove files. */
  14. tree: Tree;
  15. /** Name of the project the migrations run against. */
  16. projectName: string;
  17. /** Workspace project the migrations run against. */
  18. project: workspaces.ProjectDefinition;
  19. /** Whether the migrations run for a test target. */
  20. isTestTarget: boolean;
  21. };
  22. export declare abstract class DevkitMigration<Data> extends Migration<Data, DevkitContext> {
  23. /** Prints an informative message with context on the current target. */
  24. protected printInfo(text: string): void;
  25. /**
  26. * Optional static method that will be called once the migration of all project
  27. * targets has been performed. This method can be used to make changes respecting the
  28. * migration result of all individual targets. e.g. removing HammerJS if it
  29. * is not needed in any project target.
  30. */
  31. static globalPostMigration?(tree: Tree, targetVersion: TargetVersion, context: SchematicContext): PostMigrationAction;
  32. }
  33. export type DevkitMigrationCtor<Data> = Constructor<DevkitMigration<Data>> & {
  34. [m in keyof typeof DevkitMigration]: (typeof DevkitMigration)[m];
  35. };