Skip to content

Commit d632dd2

Browse files
authored
Merge pull request #13712 from IgniteUI/dpetev/migrations-17
fix(migrations,ng-add): turn on encapsulation for devkit/schematics deps
2 parents 26f28ab + d5359f1 commit d632dd2

File tree

45 files changed

+94
-75
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+94
-75
lines changed

projects/igniteui-angular/migrations/common/ServerHost.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Tree } from '@angular-devkit/schematics';
1+
import type { Tree } from '@angular-devkit/schematics';
22
import * as pathFs from 'path';
33
import * as ts from 'typescript/lib/tsserverlibrary';
44
import { CUSTOM_TS_PLUGIN_NAME, CUSTOM_TS_PLUGIN_PATH } from './tsUtils';

projects/igniteui-angular/migrations/common/UpdateChanges.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ import * as fs from 'fs';
22
import * as path from 'path';
33
import * as ts from 'typescript';
44
import * as tss from 'typescript/lib/tsserverlibrary';
5-
import { SchematicContext, Tree, FileVisitor } from '@angular-devkit/schematics';
5+
import type { SchematicContext, Tree, FileVisitor } from '@angular-devkit/schematics';
66
import type { WorkspaceSchema } from '@schematics/angular/utility/workspace-models';
77
import {
88
ClassChanges, BindingChanges, SelectorChange,
99
SelectorChanges, ThemeChanges, ImportsChanges, MemberChanges, ThemeChange, ThemeType
1010
} from './schema';
1111
import {
12-
getLanguageService, getRenamePositions, getIdentifierPositions, replaceMatch,
12+
getLanguageService, getRenamePositions, getIdentifierPositions,
1313
createProjectService, isMemberIgniteUI, NG_LANG_SERVICE_PACKAGE_NAME, NG_CORE_PACKAGE_NAME, findMatches
1414
} from './tsUtils';
1515
import {
16-
getProjectPaths, getWorkspace, getProjects, escapeRegExp,
16+
getProjectPaths, getWorkspace, getProjects, escapeRegExp, replaceMatch,
1717
getPackageManager, canResolvePackage, tryInstallPackage, tryUninstallPackage, getPackageVersion
1818
} from './util';
1919
import { ServerHost } from './ServerHost';

projects/igniteui-angular/migrations/common/filterSourceDirs.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { filter, Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
1+
import { filter } from '@angular-devkit/schematics';
2+
import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
23
import { getWorkspace, getWorkspacePath, getProjectPaths } from './util';
34

45
/**

projects/igniteui-angular/migrations/common/tsUtils.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as ts from 'typescript';
22
import * as tss from 'typescript/lib/tsserverlibrary';
3-
import { Tree } from '@angular-devkit/schematics';
4-
import { MemberChange } from './schema';
3+
import type { Tree } from '@angular-devkit/schematics';
4+
import type { MemberChange } from './schema';
55
import { escapeRegExp } from './util';
66
import { Logger } from './tsLogger';
77
import { TSLanguageService } from './tsPlugin/TSLanguageService';
@@ -144,11 +144,6 @@ export const findMatches = (content: string, toFind: string): number[] => {
144144
return matchesPositions;
145145
};
146146

147-
export const replaceMatch = (content: string, toReplace: string, replaceWith: string, index: number): string =>
148-
content.substring(0, index) +
149-
replaceWith +
150-
content.substring(index + toReplace.length, content.length);
151-
152147
//#region Language Service
153148

154149
/**

projects/igniteui-angular/migrations/common/util.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { normalize } from '@angular-devkit/core';
22
import * as path from 'path';
3-
import { SchematicContext, Tree } from '@angular-devkit/schematics';
4-
import { WorkspaceSchema, WorkspaceProject } from '@schematics/angular/utility/workspace-models';
3+
import type { SchematicContext, Tree } from '@angular-devkit/schematics';
4+
import type { WorkspaceSchema, WorkspaceProject } from '@schematics/angular/utility/workspace-models';
55
import { execSync } from 'child_process';
6-
import {
6+
import type {
77
Attribute,
88
Block,
99
BlockParameter,
@@ -17,7 +17,6 @@ import {
1717
Text,
1818
Visitor
1919
} from '@angular/compiler';
20-
import { replaceMatch } from './tsUtils';
2120

2221
const configPaths = ['/.angular.json', '/angular.json'];
2322

@@ -58,6 +57,11 @@ export const getProjects = (config: WorkspaceSchema): WorkspaceProject[] => {
5857

5958
export const escapeRegExp = (string) => string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
6059

60+
export const replaceMatch = (content: string, toReplace: string, replaceWith: string, index: number): string =>
61+
content.substring(0, index) +
62+
replaceWith +
63+
content.substring(index + toReplace.length, content.length);
64+
6165
export const supports = (name: string): boolean => {
6266
try {
6367
execSync(`${name} --version`, { stdio: 'ignore' });

projects/igniteui-angular/migrations/migration-collection.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
3+
"encapsulation": true,
34
"schematics": {
45
"migration-01": {
56
"version": "6.0.0",

projects/igniteui-angular/migrations/tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
"typeRoots": [
99
"../../../node_modules/@types"
1010
],
11+
"paths": {
12+
"igniteui-angular/*": [
13+
"../*"
14+
],
15+
"@infragistics/igniteui-angular/*": [
16+
"../*"
17+
],
18+
}
1119
},
1220
"exclude": [
1321
"../../../node_modules",

projects/igniteui-angular/migrations/update-10_1_0/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

projects/igniteui-angular/migrations/update-10_2_0/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
1+
import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
22
import { UpdateChanges } from '../common/UpdateChanges';
33

44
const version = '10.2.0';

projects/igniteui-angular/migrations/update-11_0_0/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { Element } from '@angular/compiler';
2-
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
1+
import type { Element } from '@angular/compiler';
2+
import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
33
import { UpdateChanges } from '../common/UpdateChanges';
44
import { FileChange, findElementNodes, getAttribute, getSourceOffset, hasAttribute, parseFile, serializeNodes } from '../common/util';
5-
import { nativeImport } from '../common/import-helper.js';
5+
// use bare specifier to escape the schematics encapsulation for the dynamic import:
6+
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';
67

78
const version = '11.0.0';
89

projects/igniteui-angular/migrations/update-11_1_0/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
2-
import { Options } from '../../schematics/interfaces/options';
1+
import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
2+
import type { Options } from '../../schematics/interfaces/options';
33
import { UpdateChanges } from '../common/UpdateChanges';
44

55
const version = '11.1.0';

projects/igniteui-angular/migrations/update-12_0_0/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { Element } from '@angular/compiler';
2-
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
1+
import type { Element } from '@angular/compiler';
2+
import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
33
import { UpdateChanges } from '../common/UpdateChanges';
44
import { FileChange, getAttribute, findElementNodes, getSourceOffset, hasAttribute, parseFile } from '../common/util';
5-
import { nativeImport } from '../common/import-helper.js';
5+
// use bare specifier to escape the schematics encapsulation for the dynamic import:
6+
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';
67
import { Options } from '../../schematics/interfaces/options';
78

89
const version = '12.0.0';

projects/igniteui-angular/migrations/update-12_1_0/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { Element } from '@angular/compiler';
2-
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
1+
import type { Element } from '@angular/compiler';
2+
import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
33
import { UpdateChanges } from '../common/UpdateChanges';
44
import {
55
FileChange, findElementNodes, getAttribute, getSourceOffset, hasAttribute, parseFile,
66
serializeNodes, makeNgIf, stringifyAttributes
77
} from '../common/util';
8-
import { nativeImport } from '../common/import-helper.js';
8+
// use bare specifier to escape the schematics encapsulation for the dynamic import:
9+
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';
910

1011
const version = '12.1.0';
1112

projects/igniteui-angular/migrations/update-13_0_0/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import { Element, Text } from '@angular/compiler';
2-
import {
1+
import type { Element, Text } from '@angular/compiler';
2+
import type {
33
Rule,
44
SchematicContext,
55
Tree
66
} from '@angular-devkit/schematics';
7-
import { Options } from '../../schematics/interfaces/options';
7+
import type { Options } from '../../schematics/interfaces/options';
88
import { UpdateChanges } from '../common/UpdateChanges';
99
import { FileChange, findElementNodes, getAttribute, getSourceOffset, hasAttribute, parseFile } from '../common/util';
10-
import { nativeImport } from '../common/import-helper.js';
10+
// use bare specifier to escape the schematics encapsulation for the dynamic import:
11+
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';
1112

1213
const version = '13.0.0';
1314

@@ -191,7 +192,7 @@ export default (options: Options): Rule =>
191192
const replaceText = file.content.substring(startTag.start, endTag.end);
192193
result += '\n' + replaceText;
193194
});
194-
195+
195196
return result + `\n</igx-grid-toolbar>`;
196197
};
197198

projects/igniteui-angular/migrations/update-13_1_0/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree
55
} from '@angular-devkit/schematics';
6-
import { Element } from '@angular/compiler';
7-
import { nativeImport } from '../common/import-helper.js';
6+
import type { Element } from '@angular/compiler';
7+
// use bare specifier to escape the schematics encapsulation for the dynamic import:
8+
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';
89
import { UpdateChanges } from '../common/UpdateChanges';
910
import { FileChange, findElementNodes, getAttribute, getSourceOffset, hasAttribute, parseFile } from '../common/util';
1011

projects/igniteui-angular/migrations/update-13_2_0/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

projects/igniteui-angular/migrations/update-14_1_0/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

projects/igniteui-angular/migrations/update-15_0_0/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

projects/igniteui-angular/migrations/update-15_0_11/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

projects/igniteui-angular/migrations/update-15_0_4/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

projects/igniteui-angular/migrations/update-15_1_0/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree
55
} from '@angular-devkit/schematics';
6-
import { Element } from '@angular/compiler';
7-
import { nativeImport } from '../common/import-helper.js';
8-
import { Options } from '../../schematics/interfaces/options';
6+
import type { Element } from '@angular/compiler';
7+
// use bare specifier to escape the schematics encapsulation for the dynamic import:
8+
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';
9+
import type { Options } from '../../schematics/interfaces/options';
910
import { BoundPropertyObject, InputPropertyType, UpdateChanges } from '../common/UpdateChanges';
1011
import { FileChange, findElementNodes, getAttribute, getSourceOffset, parseFile, hasAttribute } from '../common/util';
1112

projects/igniteui-angular/migrations/update-16_0_0/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

projects/igniteui-angular/migrations/update-16_1_0/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree
55
} from '@angular-devkit/schematics';
66
import { UpdateChanges } from '../common/UpdateChanges';
77
import { FileChange, findElementNodes, getAttribute, getSourceOffset, hasAttribute, parseFile } from '../common/util';
8-
import { nativeImport } from '../common/import-helper.js';
9-
import { Element } from '@angular/compiler';
8+
// use bare specifier to escape the schematics encapsulation for the dynamic import:
9+
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';
10+
import type { Element } from '@angular/compiler';
1011

1112
const version = '16.1.0';
1213

projects/igniteui-angular/migrations/update-17_0_0/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree
55
} from '@angular-devkit/schematics';
6-
import { Element } from '@angular/compiler';
6+
import type { Element } from '@angular/compiler';
77
import * as ts from 'typescript';
88
import { UpdateChanges } from '../common/UpdateChanges';
9-
import { nativeImport } from '../common/import-helper.js';
9+
// use bare specifier to escape the schematics encapsulation for the dynamic import:
10+
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';
1011
import { namedImportFilter } from '../common/tsUtils';
1112
import { FileChange, findElementNodes, getAttribute, getSourceOffset, hasAttribute, parseFile } from '../common/util';
1213

projects/igniteui-angular/migrations/update-6/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

projects/igniteui-angular/migrations/update-6_01/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

projects/igniteui-angular/migrations/update-6_02/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

projects/igniteui-angular/migrations/update-6_1/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

projects/igniteui-angular/migrations/update-6_2/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

projects/igniteui-angular/migrations/update-6_2_1/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

projects/igniteui-angular/migrations/update-7_0_2/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

projects/igniteui-angular/migrations/update-7_2_0/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

projects/igniteui-angular/migrations/update-7_3_4/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

projects/igniteui-angular/migrations/update-8_2_0/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

projects/igniteui-angular/migrations/update-8_2_3/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

projects/igniteui-angular/migrations/update-8_2_6/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

projects/igniteui-angular/migrations/update-9_0_0/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

projects/igniteui-angular/migrations/update-9_0_1/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

projects/igniteui-angular/migrations/update-9_1_0/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Rule,
33
SchematicContext,
44
Tree

0 commit comments

Comments
 (0)