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 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
---|
10 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
---|
11 | return new (P || (P = Promise))(function (resolve, reject) {
|
---|
12 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
---|
13 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
---|
14 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
---|
15 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
---|
16 | });
|
---|
17 | };
|
---|
18 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
19 | exports.isDevkitMigration = exports.createMigrationSchematicRule = exports.cdkMigrations = void 0;
|
---|
20 | const tasks_1 = require("@angular-devkit/schematics/tasks");
|
---|
21 | const update_tool_1 = require("../update-tool");
|
---|
22 | const project_tsconfig_paths_1 = require("../utils/project-tsconfig-paths");
|
---|
23 | const devkit_file_system_1 = require("./devkit-file-system");
|
---|
24 | const devkit_migration_1 = require("./devkit-migration");
|
---|
25 | const find_stylesheets_1 = require("./find-stylesheets");
|
---|
26 | const attribute_selectors_1 = require("./migrations/attribute-selectors");
|
---|
27 | const class_inheritance_1 = require("./migrations/class-inheritance");
|
---|
28 | const class_names_1 = require("./migrations/class-names");
|
---|
29 | const constructor_signature_1 = require("./migrations/constructor-signature");
|
---|
30 | const css_selectors_1 = require("./migrations/css-selectors");
|
---|
31 | const element_selectors_1 = require("./migrations/element-selectors");
|
---|
32 | const input_names_1 = require("./migrations/input-names");
|
---|
33 | const method_call_arguments_1 = require("./migrations/method-call-arguments");
|
---|
34 | const misc_template_1 = require("./migrations/misc-template");
|
---|
35 | const output_names_1 = require("./migrations/output-names");
|
---|
36 | const property_names_1 = require("./migrations/property-names");
|
---|
37 | /** List of migrations which run for the CDK update. */
|
---|
38 | exports.cdkMigrations = [
|
---|
39 | attribute_selectors_1.AttributeSelectorsMigration,
|
---|
40 | class_inheritance_1.ClassInheritanceMigration,
|
---|
41 | class_names_1.ClassNamesMigration,
|
---|
42 | constructor_signature_1.ConstructorSignatureMigration,
|
---|
43 | css_selectors_1.CssSelectorsMigration,
|
---|
44 | element_selectors_1.ElementSelectorsMigration,
|
---|
45 | input_names_1.InputNamesMigration,
|
---|
46 | method_call_arguments_1.MethodCallArgumentsMigration,
|
---|
47 | misc_template_1.MiscTemplateMigration,
|
---|
48 | output_names_1.OutputNamesMigration,
|
---|
49 | property_names_1.PropertyNamesMigration,
|
---|
50 | ];
|
---|
51 | /**
|
---|
52 | * Creates a Angular schematic rule that runs the upgrade for the
|
---|
53 | * specified target version.
|
---|
54 | */
|
---|
55 | function createMigrationSchematicRule(targetVersion, extraMigrations, upgradeData, onMigrationCompleteFn) {
|
---|
56 | return (tree, context) => __awaiter(this, void 0, void 0, function* () {
|
---|
57 | const logger = context.logger;
|
---|
58 | const workspace = yield project_tsconfig_paths_1.getWorkspaceConfigGracefully(tree);
|
---|
59 | if (workspace === null) {
|
---|
60 | logger.error('Could not find workspace configuration file.');
|
---|
61 | return;
|
---|
62 | }
|
---|
63 | // Keep track of all project source files which have been checked/migrated. This is
|
---|
64 | // necessary because multiple TypeScript projects can contain the same source file and
|
---|
65 | // we don't want to check these again, as this would result in duplicated failure messages.
|
---|
66 | const analyzedFiles = new Set();
|
---|
67 | const fileSystem = new devkit_file_system_1.DevkitFileSystem(tree);
|
---|
68 | const projectNames = workspace.projects.keys();
|
---|
69 | const migrations = [...exports.cdkMigrations, ...extraMigrations];
|
---|
70 | let hasFailures = false;
|
---|
71 | for (const projectName of projectNames) {
|
---|
72 | const project = workspace.projects.get(projectName);
|
---|
73 | const buildTsconfigPath = project_tsconfig_paths_1.getTargetTsconfigPath(project, 'build');
|
---|
74 | const testTsconfigPath = project_tsconfig_paths_1.getTargetTsconfigPath(project, 'test');
|
---|
75 | if (!buildTsconfigPath && !testTsconfigPath) {
|
---|
76 | logger.warn(`Could not find TypeScript project for project: ${projectName}`);
|
---|
77 | continue;
|
---|
78 | }
|
---|
79 | // In some applications, developers will have global stylesheets which are not
|
---|
80 | // specified in any Angular component. Therefore we glob up all CSS and SCSS files
|
---|
81 | // in the project and migrate them if needed.
|
---|
82 | // TODO: rework this to collect global stylesheets from the workspace config. COMP-280.
|
---|
83 | const additionalStylesheetPaths = find_stylesheets_1.findStylesheetFiles(tree, project.root);
|
---|
84 | if (buildTsconfigPath !== null) {
|
---|
85 | runMigrations(project, projectName, buildTsconfigPath, additionalStylesheetPaths, false);
|
---|
86 | }
|
---|
87 | if (testTsconfigPath !== null) {
|
---|
88 | runMigrations(project, projectName, testTsconfigPath, additionalStylesheetPaths, true);
|
---|
89 | }
|
---|
90 | }
|
---|
91 | let runPackageManager = false;
|
---|
92 | // Run the global post migration static members for all
|
---|
93 | // registered devkit migrations.
|
---|
94 | migrations.forEach(m => {
|
---|
95 | const actionResult = isDevkitMigration(m) && m.globalPostMigration !== undefined ?
|
---|
96 | m.globalPostMigration(tree, context) : null;
|
---|
97 | if (actionResult) {
|
---|
98 | runPackageManager = runPackageManager || actionResult.runPackageManager;
|
---|
99 | }
|
---|
100 | });
|
---|
101 | // If a migration requested the package manager to run, we run it as an
|
---|
102 | // asynchronous post migration task. We cannot run it synchronously,
|
---|
103 | // as file changes from the current migration task are not applied to
|
---|
104 | // the file system yet.
|
---|
105 | if (runPackageManager) {
|
---|
106 | context.addTask(new tasks_1.NodePackageInstallTask({ quiet: false }));
|
---|
107 | }
|
---|
108 | if (onMigrationCompleteFn) {
|
---|
109 | onMigrationCompleteFn(context, targetVersion, hasFailures);
|
---|
110 | }
|
---|
111 | /** Runs the migrations for the specified workspace project. */
|
---|
112 | function runMigrations(project, projectName, tsconfigPath, additionalStylesheetPaths, isTestTarget) {
|
---|
113 | const program = update_tool_1.UpdateProject.createProgramFromTsconfig(tsconfigPath, fileSystem);
|
---|
114 | const updateContext = {
|
---|
115 | isTestTarget,
|
---|
116 | projectName,
|
---|
117 | project,
|
---|
118 | tree,
|
---|
119 | };
|
---|
120 | const updateProject = new update_tool_1.UpdateProject(updateContext, program, fileSystem, analyzedFiles, context.logger);
|
---|
121 | const result = updateProject.migrate(migrations, targetVersion, upgradeData, additionalStylesheetPaths);
|
---|
122 | // Commit all recorded edits in the update recorder. We apply the edits after all
|
---|
123 | // migrations ran because otherwise offsets in the TypeScript program would be
|
---|
124 | // shifted and individual migrations could no longer update the same source file.
|
---|
125 | fileSystem.commitEdits();
|
---|
126 | hasFailures = hasFailures || result.hasFailures;
|
---|
127 | }
|
---|
128 | });
|
---|
129 | }
|
---|
130 | exports.createMigrationSchematicRule = createMigrationSchematicRule;
|
---|
131 | /** Whether the given migration type refers to a devkit migration */
|
---|
132 | function isDevkitMigration(value) {
|
---|
133 | return devkit_migration_1.DevkitMigration.isPrototypeOf(value);
|
---|
134 | }
|
---|
135 | exports.isDevkitMigration = isDevkitMigration;
|
---|
136 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGV2a2l0LW1pZ3JhdGlvbi1ydWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL2Nkay9zY2hlbWF0aWNzL25nLXVwZGF0ZS9kZXZraXQtbWlncmF0aW9uLXJ1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7R0FNRzs7Ozs7Ozs7Ozs7O0FBR0gsNERBQXdFO0FBR3hFLGdEQUE2QztBQUk3Qyw0RUFBb0c7QUFFcEcsNkRBQXNEO0FBQ3RELHlEQUF1RjtBQUN2Rix5REFBdUQ7QUFDdkQsMEVBQTZFO0FBQzdF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