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.io/license
|
---|
7 | */
|
---|
8 | import * as ts from 'typescript';
|
---|
9 | import { FileSystem, WorkspacePath } from './file-system';
|
---|
10 | import { UpdateLogger } from './logger';
|
---|
11 | import { MigrationCtor } from './migration';
|
---|
12 | import { TargetVersion } from './target-version';
|
---|
13 | /**
|
---|
14 | * An update project that can be run against individual migrations. An update project
|
---|
15 | * accepts a TypeScript program and a context that is provided to all migrations. The
|
---|
16 | * context is usually not used by migrations, but in some cases migrations rely on
|
---|
17 | * specifics from the tool that performs the update (e.g. the Angular CLI). In those cases,
|
---|
18 | * the context can provide the necessary specifics to the migrations in a type-safe way.
|
---|
19 | */
|
---|
20 | export declare class UpdateProject<Context> {
|
---|
21 | private _context;
|
---|
22 | /** TypeScript program using workspace paths. */
|
---|
23 | private _program;
|
---|
24 | /** File system used for reading, writing and editing files. */
|
---|
25 | private _fileSystem;
|
---|
26 | /**
|
---|
27 | * Set of analyzed files. Used for avoiding multiple migration runs if
|
---|
28 | * files overlap between targets.
|
---|
29 | */
|
---|
30 | private _analyzedFiles;
|
---|
31 | /** Logger used for printing messages. */
|
---|
32 | private _logger;
|
---|
33 | private readonly _typeChecker;
|
---|
34 | constructor(/** Context provided to all migrations. */ _context: Context,
|
---|
35 | /** TypeScript program using workspace paths. */
|
---|
36 | _program: ts.Program,
|
---|
37 | /** File system used for reading, writing and editing files. */
|
---|
38 | _fileSystem: FileSystem,
|
---|
39 | /**
|
---|
40 | * Set of analyzed files. Used for avoiding multiple migration runs if
|
---|
41 | * files overlap between targets.
|
---|
42 | */
|
---|
43 | _analyzedFiles?: Set<WorkspacePath>,
|
---|
44 | /** Logger used for printing messages. */
|
---|
45 | _logger?: UpdateLogger);
|
---|
46 | /**
|
---|
47 | * Migrates the project to the specified target version.
|
---|
48 | * @param migrationTypes Migrations that should be run.
|
---|
49 | * @param target Version the project should be updated to.
|
---|
50 | * @param data Upgrade data that is passed to all migration rules.
|
---|
51 | * @param additionalStylesheetPaths Additional stylesheets that should be migrated, if not
|
---|
52 | * referenced in an Angular component. This is helpful for global stylesheets in a project.
|
---|
53 | */
|
---|
54 | migrate<Data>(migrationTypes: MigrationCtor<Data, Context>[], target: TargetVersion, data: Data, additionalStylesheetPaths?: string[]): {
|
---|
55 | hasFailures: boolean;
|
---|
56 | };
|
---|
57 | /**
|
---|
58 | * Creates instances of the given migrations with the specified target
|
---|
59 | * version and data.
|
---|
60 | */
|
---|
61 | private _createMigrations;
|
---|
62 | /**
|
---|
63 | * Creates a program form the specified tsconfig and patches the host
|
---|
64 | * to read files and directories through the given file system.
|
---|
65 | */
|
---|
66 | static createProgramFromTsconfig(tsconfigPath: WorkspacePath, fs: FileSystem): ts.Program;
|
---|
67 | }
|
---|