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 core_1 = require("@angular-devkit/core");
|
---|
11 | const json_file_1 = require("../../utility/json-file");
|
---|
12 | const workspace_1 = require("../../utility/workspace");
|
---|
13 | function* visitJsonFiles(directory) {
|
---|
14 | for (const path of directory.subfiles) {
|
---|
15 | if (!path.endsWith('.json')) {
|
---|
16 | continue;
|
---|
17 | }
|
---|
18 | yield core_1.join(directory.path, path);
|
---|
19 | }
|
---|
20 | for (const path of directory.subdirs) {
|
---|
21 | if (path === 'node_modules' || path.startsWith('.')) {
|
---|
22 | continue;
|
---|
23 | }
|
---|
24 | yield* visitJsonFiles(directory.dir(path));
|
---|
25 | }
|
---|
26 | }
|
---|
27 | function default_1() {
|
---|
28 | return async (tree, { logger }) => {
|
---|
29 | const workspace = await workspace_1.getWorkspace(tree);
|
---|
30 | const hasThirdPartyBuilders = [...workspace_1.allWorkspaceTargets(workspace)].some(([, target]) => {
|
---|
31 | const { builder } = target;
|
---|
32 | return !(builder.startsWith('@angular-devkit/build-angular') ||
|
---|
33 | builder.startsWith('@nguniversal/builders'));
|
---|
34 | });
|
---|
35 | if (hasThirdPartyBuilders) {
|
---|
36 | logger.warn('Skipping migration as the workspace uses third-party builders which may ' +
|
---|
37 | 'require "emitDecoratorMetadata" TypeScript compiler option.');
|
---|
38 | return;
|
---|
39 | }
|
---|
40 | for (const path of visitJsonFiles(tree.root)) {
|
---|
41 | const content = tree.read(path);
|
---|
42 | if (content === null || content === void 0 ? void 0 : content.toString().includes('"emitDecoratorMetadata"')) {
|
---|
43 | const json = new json_file_1.JSONFile(tree, path);
|
---|
44 | json.remove(['compilerOptions', 'emitDecoratorMetadata']);
|
---|
45 | }
|
---|
46 | }
|
---|
47 | };
|
---|
48 | }
|
---|
49 | exports.default = default_1;
|
---|