Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(migrations,ng-add): turn on encapsulation for devkit/schematics deps #13712

Merged
merged 6 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion projects/igniteui-angular/migrations/common/ServerHost.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Tree } from '@angular-devkit/schematics';
import type { Tree } from '@angular-devkit/schematics';
import * as pathFs from 'path';
import * as ts from 'typescript/lib/tsserverlibrary';
import { CUSTOM_TS_PLUGIN_NAME, CUSTOM_TS_PLUGIN_PATH } from './tsUtils';
Expand Down
6 changes: 3 additions & 3 deletions projects/igniteui-angular/migrations/common/UpdateChanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import * as fs from 'fs';
import * as path from 'path';
import * as ts from 'typescript';
import * as tss from 'typescript/lib/tsserverlibrary';
import { SchematicContext, Tree, FileVisitor } from '@angular-devkit/schematics';
import type { SchematicContext, Tree, FileVisitor } from '@angular-devkit/schematics';
import type { WorkspaceSchema } from '@schematics/angular/utility/workspace-models';
import {
ClassChanges, BindingChanges, SelectorChange,
SelectorChanges, ThemeChanges, ImportsChanges, MemberChanges, ThemeChange, ThemeType
} from './schema';
import {
getLanguageService, getRenamePositions, getIdentifierPositions, replaceMatch,
getLanguageService, getRenamePositions, getIdentifierPositions,
createProjectService, isMemberIgniteUI, NG_LANG_SERVICE_PACKAGE_NAME, NG_CORE_PACKAGE_NAME, findMatches
} from './tsUtils';
import {
getProjectPaths, getWorkspace, getProjects, escapeRegExp,
getProjectPaths, getWorkspace, getProjects, escapeRegExp, replaceMatch,
getPackageManager, canResolvePackage, tryInstallPackage, tryUninstallPackage, getPackageVersion
} from './util';
import { ServerHost } from './ServerHost';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { filter, Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
import { filter } from '@angular-devkit/schematics';
import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
import { getWorkspace, getWorkspacePath, getProjectPaths } from './util';

/**
Expand Down
9 changes: 2 additions & 7 deletions projects/igniteui-angular/migrations/common/tsUtils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as ts from 'typescript';
import * as tss from 'typescript/lib/tsserverlibrary';
import { Tree } from '@angular-devkit/schematics';
import { MemberChange } from './schema';
import type { Tree } from '@angular-devkit/schematics';
import type { MemberChange } from './schema';
import { escapeRegExp } from './util';
import { Logger } from './tsLogger';
import { TSLanguageService } from './tsPlugin/TSLanguageService';
Expand Down Expand Up @@ -144,11 +144,6 @@ export const findMatches = (content: string, toFind: string): number[] => {
return matchesPositions;
};

export const replaceMatch = (content: string, toReplace: string, replaceWith: string, index: number): string =>
content.substring(0, index) +
replaceWith +
content.substring(index + toReplace.length, content.length);

//#region Language Service

/**
Expand Down
12 changes: 8 additions & 4 deletions projects/igniteui-angular/migrations/common/util.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { normalize } from '@angular-devkit/core';
import * as path from 'path';
import { SchematicContext, Tree } from '@angular-devkit/schematics';
import { WorkspaceSchema, WorkspaceProject } from '@schematics/angular/utility/workspace-models';
import type { SchematicContext, Tree } from '@angular-devkit/schematics';
import type { WorkspaceSchema, WorkspaceProject } from '@schematics/angular/utility/workspace-models';
import { execSync } from 'child_process';
import {
import type {
Attribute,
Block,
BlockParameter,
Expand All @@ -17,7 +17,6 @@ import {
Text,
Visitor
} from '@angular/compiler';
import { replaceMatch } from './tsUtils';

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

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

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

export const replaceMatch = (content: string, toReplace: string, replaceWith: string, index: number): string =>
content.substring(0, index) +
replaceWith +
content.substring(index + toReplace.length, content.length);

export const supports = (name: string): boolean => {
try {
execSync(`${name} --version`, { stdio: 'ignore' });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
"encapsulation": true,
"schematics": {
"migration-01": {
"version": "6.0.0",
Expand Down
8 changes: 8 additions & 0 deletions projects/igniteui-angular/migrations/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
"typeRoots": [
"../../../node_modules/@types"
],
"paths": {
"igniteui-angular/*": [
"../*"
],
"@infragistics/igniteui-angular/*": [
"../*"
],
}
},
"exclude": [
"../../../node_modules",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
import { UpdateChanges } from '../common/UpdateChanges';

const version = '10.2.0';
Expand Down
7 changes: 4 additions & 3 deletions projects/igniteui-angular/migrations/update-11_0_0/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Element } from '@angular/compiler';
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
import type { Element } from '@angular/compiler';
import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
import { UpdateChanges } from '../common/UpdateChanges';
import { FileChange, findElementNodes, getAttribute, getSourceOffset, hasAttribute, parseFile, serializeNodes } from '../common/util';
import { nativeImport } from '../common/import-helper.js';
// use bare specifier to escape the schematics encapsulation for the dynamic import:
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';

const version = '11.0.0';

Expand Down
4 changes: 2 additions & 2 deletions projects/igniteui-angular/migrations/update-11_1_0/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
import { Options } from '../../schematics/interfaces/options';
import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
import type { Options } from '../../schematics/interfaces/options';
import { UpdateChanges } from '../common/UpdateChanges';

const version = '11.1.0';
Expand Down
7 changes: 4 additions & 3 deletions projects/igniteui-angular/migrations/update-12_0_0/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Element } from '@angular/compiler';
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
import type { Element } from '@angular/compiler';
import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
import { UpdateChanges } from '../common/UpdateChanges';
import { FileChange, getAttribute, findElementNodes, getSourceOffset, hasAttribute, parseFile } from '../common/util';
import { nativeImport } from '../common/import-helper.js';
// use bare specifier to escape the schematics encapsulation for the dynamic import:
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';
import { Options } from '../../schematics/interfaces/options';

const version = '12.0.0';
Expand Down
7 changes: 4 additions & 3 deletions projects/igniteui-angular/migrations/update-12_1_0/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Element } from '@angular/compiler';
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
import type { Element } from '@angular/compiler';
import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
import { UpdateChanges } from '../common/UpdateChanges';
import {
FileChange, findElementNodes, getAttribute, getSourceOffset, hasAttribute, parseFile,
serializeNodes, makeNgIf, stringifyAttributes
} from '../common/util';
import { nativeImport } from '../common/import-helper.js';
// use bare specifier to escape the schematics encapsulation for the dynamic import:
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';

const version = '12.1.0';

Expand Down
11 changes: 6 additions & 5 deletions projects/igniteui-angular/migrations/update-13_0_0/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Element, Text } from '@angular/compiler';
import {
import type { Element, Text } from '@angular/compiler';
import type {
Rule,
SchematicContext,
Tree
} from '@angular-devkit/schematics';
import { Options } from '../../schematics/interfaces/options';
import type { Options } from '../../schematics/interfaces/options';
import { UpdateChanges } from '../common/UpdateChanges';
import { FileChange, findElementNodes, getAttribute, getSourceOffset, hasAttribute, parseFile } from '../common/util';
import { nativeImport } from '../common/import-helper.js';
// use bare specifier to escape the schematics encapsulation for the dynamic import:
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';

const version = '13.0.0';

Expand Down Expand Up @@ -191,7 +192,7 @@ export default (options: Options): Rule =>
const replaceText = file.content.substring(startTag.start, endTag.end);
result += '\n' + replaceText;
});

return result + `\n</igx-grid-toolbar>`;
};

Expand Down
7 changes: 4 additions & 3 deletions projects/igniteui-angular/migrations/update-13_1_0/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {
import type {
Rule,
SchematicContext,
Tree
} from '@angular-devkit/schematics';
import { Element } from '@angular/compiler';
import { nativeImport } from '../common/import-helper.js';
import type { Element } from '@angular/compiler';
// use bare specifier to escape the schematics encapsulation for the dynamic import:
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';
import { UpdateChanges } from '../common/UpdateChanges';
import { FileChange, findElementNodes, getAttribute, getSourceOffset, hasAttribute, parseFile } from '../common/util';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
9 changes: 5 additions & 4 deletions projects/igniteui-angular/migrations/update-15_1_0/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {
import type {
Rule,
SchematicContext,
Tree
} from '@angular-devkit/schematics';
import { Element } from '@angular/compiler';
import { nativeImport } from '../common/import-helper.js';
import { Options } from '../../schematics/interfaces/options';
import type { Element } from '@angular/compiler';
// use bare specifier to escape the schematics encapsulation for the dynamic import:
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';
import type { Options } from '../../schematics/interfaces/options';
import { BoundPropertyObject, InputPropertyType, UpdateChanges } from '../common/UpdateChanges';
import { FileChange, findElementNodes, getAttribute, getSourceOffset, parseFile, hasAttribute } from '../common/util';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
7 changes: 4 additions & 3 deletions projects/igniteui-angular/migrations/update-16_1_0/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {
import type {
Rule,
SchematicContext,
Tree
} from '@angular-devkit/schematics';
import { UpdateChanges } from '../common/UpdateChanges';
import { FileChange, findElementNodes, getAttribute, getSourceOffset, hasAttribute, parseFile } from '../common/util';
import { nativeImport } from '../common/import-helper.js';
import { Element } from '@angular/compiler';
// use bare specifier to escape the schematics encapsulation for the dynamic import:
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';
import type { Element } from '@angular/compiler';

const version = '16.1.0';

Expand Down
7 changes: 4 additions & 3 deletions projects/igniteui-angular/migrations/update-17_0_0/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {
import type {
Rule,
SchematicContext,
Tree
} from '@angular-devkit/schematics';
import { Element } from '@angular/compiler';
import type { Element } from '@angular/compiler';
import * as ts from 'typescript';
import { UpdateChanges } from '../common/UpdateChanges';
import { nativeImport } from '../common/import-helper.js';
// use bare specifier to escape the schematics encapsulation for the dynamic import:
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';
import { namedImportFilter } from '../common/tsUtils';
import { FileChange, findElementNodes, getAttribute, getSourceOffset, hasAttribute, parseFile } from '../common/util';

Expand Down
2 changes: 1 addition & 1 deletion projects/igniteui-angular/migrations/update-6/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
2 changes: 1 addition & 1 deletion projects/igniteui-angular/migrations/update-6_01/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
2 changes: 1 addition & 1 deletion projects/igniteui-angular/migrations/update-6_02/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
2 changes: 1 addition & 1 deletion projects/igniteui-angular/migrations/update-6_1/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
2 changes: 1 addition & 1 deletion projects/igniteui-angular/migrations/update-6_2/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
2 changes: 1 addition & 1 deletion projects/igniteui-angular/migrations/update-6_2_1/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
2 changes: 1 addition & 1 deletion projects/igniteui-angular/migrations/update-7_0_2/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
2 changes: 1 addition & 1 deletion projects/igniteui-angular/migrations/update-7_2_0/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
2 changes: 1 addition & 1 deletion projects/igniteui-angular/migrations/update-7_3_4/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
2 changes: 1 addition & 1 deletion projects/igniteui-angular/migrations/update-8_2_0/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
2 changes: 1 addition & 1 deletion projects/igniteui-angular/migrations/update-8_2_3/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
2 changes: 1 addition & 1 deletion projects/igniteui-angular/migrations/update-8_2_6/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
2 changes: 1 addition & 1 deletion projects/igniteui-angular/migrations/update-9_0_0/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
2 changes: 1 addition & 1 deletion projects/igniteui-angular/migrations/update-9_0_1/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
2 changes: 1 addition & 1 deletion projects/igniteui-angular/migrations/update-9_1_0/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Rule,
SchematicContext,
Tree
Expand Down
Loading
Loading