Skip to content

Commit

Permalink
refactor: support angular 16
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Mar 8, 2024
1 parent 63ed8a3 commit 15959af
Show file tree
Hide file tree
Showing 41 changed files with 3,525 additions and 4,397 deletions.
7,635 changes: 3,390 additions & 4,245 deletions package-lock.json

Large diffs are not rendered by default.

44 changes: 29 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,45 +97,59 @@
]
},
"devDependencies": {
"@angular-devkit/build-angular": "15.2.10",
"@angular-devkit/core": "15.2.10",
"@angular-devkit/schematics": "15.2.10",
"@angular/animations": "15.2.10",
"@angular/cdk": "15.2.9",
"@angular/cli": "15.2.10",
"@angular/common": "15.2.10",
"@angular/compiler-cli": "15.2.10",
"@angular/core": "15.2.10",
"@angular/forms": "15.2.10",
"@angular/platform-browser": "15.2.10",
"@angular/router": "15.2.10",
"@angular-builders/custom-webpack": "16.0.1",
"@angular-devkit/build-angular": "16.2.12",
"@angular-devkit/core": "16.2.12",
"@angular-devkit/schematics": "16.2.12",
"@angular/animations": "16.2.12",
"@angular/cdk": "16.2.14",
"@angular/cli": "16.2.12",
"@angular/common": "16.2.12",
"@angular/compiler-cli": "16.2.12",
"@angular/core": "16.2.12",
"@angular/forms": "16.2.12",
"@angular/localize": "16.2.12",
"@angular/platform-browser": "16.2.12",
"@angular/platform-browser-dynamic": "16.2.12",
"@angular/platform-server": "16.2.12",
"@angular/router": "16.2.12",
"@ng-web-apis/universal": "3.0.7",
"@nguniversal/builders": "16.2.0",
"@nguniversal/express-engine": "16.2.0",
"@nx/angular": "17.3.1",
"@nx/jest": "17.3.1",
"@nx/workspace": "17.3.1",
"@schematics/angular": "15.2.10",
"@schematics/angular": "16.2.12",
"@stackblitz/sdk": "1.9.0",
"@taiga-ui/browserslist-config": "0.6.0",
"@taiga-ui/commitlint-config": "0.7.1",
"@taiga-ui/cspell-config": "0.36.0",
"@taiga-ui/eslint-plugin-experience": "0.65.0",
"@taiga-ui/prettier-config": "0.10.0",
"@taiga-ui/stylelint-config": "0.20.0",
"@taiga-ui/tsconfig": "0.17.0",
"@tinkoff/ng-dompurify": "4.0.0",
"@types/express": "4.17.21",
"@types/glob": "8.1.0",
"@types/node": "20.11.25",
"@types/webpack-env": "1.18.4",
"cpy-cli": "5.0.0",
"date-fns": "3.3.1",
"express": "4.18.3",
"http-server": "14.1.1",
"husky": "9.0.11",
"kill-port": "2.0.1",
"lint-staged": "15.2.2",
"ng-packagr": "15.2.2",
"ng-packagr": "16.2.3",
"nx": "17.2.8",
"parse5": "^7.1.2",
"rollup": "4.12.1",
"rxjs": "7.5.0",
"standard-version": "9.5.0",
"terser-webpack-plugin": "5.3.10",
"ts-mockito": "2.6.1",
"ts-node": "10.9.2",
"typescript": "4.9.5",
"typescript": "5.0.2",
"wait-on": "7.2.0",
"webpack": "5.90.3"
},
Expand Down
4 changes: 2 additions & 2 deletions projects/addon-charts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"repository": "https://github.com/taiga-family/taiga-ui",
"license": "Apache-2.0",
"peerDependencies": {
"@angular/common": ">=15.0.0",
"@angular/core": ">=15.0.0",
"@angular/common": ">=16.0.0",
"@angular/core": ">=16.0.0",
"@ng-web-apis/common": "^3.0.6",
"@taiga-ui/cdk": "^3.59.0",
"@taiga-ui/core": "^3.59.0",
Expand Down
8 changes: 4 additions & 4 deletions projects/addon-commerce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"repository": "https://github.com/taiga-family/taiga-ui",
"license": "Apache-2.0",
"peerDependencies": {
"@angular/common": ">=15.0.0",
"@angular/core": ">=15.0.0",
"@angular/forms": ">=15.0.0",
"@angular/common": ">=16.0.0",
"@angular/core": ">=16.0.0",
"@angular/forms": ">=16.0.0",
"@maskito/angular": "^2.0.2",
"@maskito/core": "^2.0.2",
"@maskito/kit": "^2.0.2",
Expand All @@ -26,7 +26,7 @@
"@taiga-ui/i18n": "^3.59.0",
"@taiga-ui/kit": "^3.59.0",
"@tinkoff/ng-polymorpheus": "^4.3.0",
"rxjs": ">=6.0.0",
"rxjs": ">=7.0.0",
"tslib": "^2.6.2"
}
}
10 changes: 5 additions & 5 deletions projects/addon-doc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"@types/markdown-it": "13.0.7"
},
"peerDependencies": {
"@angular/cdk": ">=15.0.0",
"@angular/common": ">=15.0.0",
"@angular/core": ">=15.0.0",
"@angular/forms": ">=15.0.0",
"@angular/router": ">=15.0.0",
"@angular/cdk": ">=16.0.0",
"@angular/common": ">=16.0.0",
"@angular/core": ">=16.0.0",
"@angular/forms": ">=16.0.0",
"@angular/router": ">=16.0.0",
"@ng-web-apis/common": "^3.0.6",
"@taiga-ui/addon-mobile": "^3.59.0",
"@taiga-ui/cdk": "^3.59.0",
Expand Down
8 changes: 4 additions & 4 deletions projects/addon-mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
"repository": "https://github.com/taiga-family/taiga-ui",
"license": "Apache-2.0",
"peerDependencies": {
"@angular/cdk": ">=15.0.0",
"@angular/common": ">=15.0.0",
"@angular/core": ">=15.0.0",
"@angular/cdk": ">=16.0.0",
"@angular/common": ">=16.0.0",
"@angular/core": ">=16.0.0",
"@ng-web-apis/common": "^3.0.6",
"@taiga-ui/cdk": "^3.59.0",
"@taiga-ui/core": "^3.59.0",
"@taiga-ui/kit": "^3.59.0",
"@tinkoff/ng-polymorpheus": "^4.3.0",
"rxjs": ">=6.0.0",
"rxjs": ">=7.0.0",
"tslib": "^2.6.2"
}
}
6 changes: 3 additions & 3 deletions projects/addon-preview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
"repository": "https://github.com/taiga-family/taiga-ui",
"license": "Apache-2.0",
"peerDependencies": {
"@angular/common": ">=15.0.0",
"@angular/core": ">=15.0.0",
"@angular/common": ">=16.0.0",
"@angular/core": ">=16.0.0",
"@ng-web-apis/mutation-observer": "^3.1.0",
"@taiga-ui/cdk": "^3.59.0",
"@taiga-ui/core": "^3.59.0",
"@taiga-ui/i18n": "^3.59.0",
"@taiga-ui/kit": "^3.59.0",
"@tinkoff/ng-polymorpheus": "^4.3.0",
"rxjs": ">=6.0.0",
"rxjs": ">=7.0.0",
"tslib": "^2.6.2"
},
"publishConfig": {
Expand Down
6 changes: 3 additions & 3 deletions projects/addon-table/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
"repository": "https://github.com/taiga-family/taiga-ui",
"license": "Apache-2.0",
"peerDependencies": {
"@angular/common": ">=15.0.0",
"@angular/core": ">=15.0.0",
"@angular/common": ">=16.0.0",
"@angular/core": ">=16.0.0",
"@ng-web-apis/intersection-observer": "^3.2.0",
"@taiga-ui/cdk": "^3.59.0",
"@taiga-ui/core": "^3.59.0",
"@taiga-ui/i18n": "^3.59.0",
"@taiga-ui/kit": "^3.59.0",
"@tinkoff/ng-polymorpheus": "^4.3.0",
"rxjs": ">=6.0.0",
"rxjs": ">=7.0.0",
"tslib": "^2.6.2"
}
}
6 changes: 3 additions & 3 deletions projects/addon-tablebars/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
"repository": "https://github.com/taiga-family/taiga-ui",
"license": "Apache-2.0",
"peerDependencies": {
"@angular/common": ">=15.0.0",
"@angular/core": ">=15.0.0",
"@angular/common": ">=16.0.0",
"@angular/core": ">=16.0.0",
"@taiga-ui/cdk": "^3.59.0",
"@taiga-ui/core": "^3.59.0",
"@tinkoff/ng-polymorpheus": "^4.3.0",
"rxjs": ">=6.0.0",
"rxjs": ">=7.0.0",
"tslib": "2.6.2"
}
}
25 changes: 12 additions & 13 deletions projects/cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,28 @@
"tslib": "2.6.2"
},
"devDependencies": {
"@angular-devkit/core": "15.2.10",
"@angular-devkit/schematics": "15.2.10",
"@schematics/angular": "15.2.10",
"@types/parse5": "6.0.3"
"@angular-devkit/core": "16.2.12",
"@angular-devkit/schematics": "16.2.12",
"@schematics/angular": "16.2.12"
},
"peerDependencies": {
"@angular/animations": ">=15.0.0",
"@angular/common": ">=15.0.0",
"@angular/core": ">=15.0.0",
"@angular/forms": ">=15.0.0",
"@angular/animations": ">=16.0.0",
"@angular/common": ">=16.0.0",
"@angular/core": ">=16.0.0",
"@angular/forms": ">=16.0.0",
"@ng-web-apis/common": "^3.0.6",
"@ng-web-apis/mutation-observer": "^3.1.0",
"@ng-web-apis/resize-observer": "^3.0.6",
"@tinkoff/ng-event-plugins": "^3.1.0",
"@tinkoff/ng-polymorpheus": "^4.3.0",
"rxjs": ">=6.0.0"
"rxjs": ">=7.0.0"
},
"optionalDependencies": {
"@angular-devkit/core": ">=15.0.0",
"@angular-devkit/schematics": ">=15.0.0",
"@schematics/angular": ">=15.0.0",
"@angular-devkit/core": ">=16.0.0",
"@angular-devkit/schematics": ">=16.0.0",
"@schematics/angular": ">=16.0.0",
"ng-morph": "^4.0.6",
"parse5": "^6.0.1"
"parse5": "^7.1.2"
},
"ng-update": {
"migrations": "./schematics/migration.json",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Element} from 'parse5';
import type {Element} from 'parse5/dist/tree-adapters/default';

export interface ReplacementAttributeToDirective {
readonly componentSelector: string[] | string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Element} from 'parse5';
import type {Element} from 'parse5/dist/tree-adapters/default';

export interface ReplacementAttribute {
readonly from: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Element} from 'parse5';
import type {Element} from 'parse5/dist/tree-adapters/default';

export interface ReplacementTag {
readonly addAttributes?: string[];
Expand Down
15 changes: 6 additions & 9 deletions projects/cdk/schematics/ng-update/utils/templates/replace-tag.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
import type {UpdateRecorder} from '@angular-devkit/schematics';
import type {ElementLocation} from 'parse5';
import type {ElementLocation} from 'parse5/dist/common/token';

const START_TAG_OFFSET = 1;
const END_TAG_OFFSET = 2;

export function replaceTag(
recorder: UpdateRecorder,
sourceCodeLocation: ElementLocation | undefined,
sourceCodeLocation: ElementLocation | null | undefined,
from: string,
to: string,
templateOffset = 0,
addAttributes: string[] = [],
): void {
const startTagOffset = sourceCodeLocation?.startTag.startOffset;
const endTagOffset = sourceCodeLocation?.endTag?.startOffset;
const startTagOffset = sourceCodeLocation?.startTag?.startOffset ?? 0;
const endTagOffset = sourceCodeLocation?.endTag?.startOffset ?? 0;

if (endTagOffset) {
recorder.remove(endTagOffset + templateOffset + END_TAG_OFFSET, from.length);
recorder.insertRight(endTagOffset + templateOffset + END_TAG_OFFSET, to);
}

recorder.remove(
(startTagOffset ?? 0) + templateOffset + START_TAG_OFFSET,
from.length,
);
recorder.remove(startTagOffset + templateOffset + START_TAG_OFFSET, from.length);
recorder.insertRight(
(startTagOffset ?? 0) + templateOffset + START_TAG_OFFSET,
startTagOffset + templateOffset + START_TAG_OFFSET,
`${to} ${addAttributes.join(' ')}`,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function migrateExpand({
attr => attr.name === 'tuiexpandcontent',
);

const insertTo = templateElement?.sourceCodeLocation?.startTag.endOffset;
const insertTo = templateElement?.sourceCodeLocation?.startTag?.endOffset ?? 0;

if (!insertTo || tuiExpandAttr) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {UpdateRecorder} from '@angular-devkit/schematics';
import type {DevkitFileSystem} from 'ng-morph/project/classes/devkit-file-system';
import type {Element} from 'parse5';
import type {Element} from 'parse5/dist/tree-adapters/default';

import {
findElementsByFn,
Expand All @@ -12,8 +12,8 @@ import {
getTemplateFromTemplateResource,
getTemplateOffset,
} from '../../../utils/templates/template-resource';
import type {TemplateResource} from '../../interfaces/template-resource';
import {replaceTag} from '../../utils/templates/replace-tag';
import type {TemplateResource} from '../../interfaces';
import {replaceTag} from '../../utils/templates';

function insertPolymorpheus({
element,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {DevkitFileSystem} from 'ng-morph';
import {createProject, saveActiveProject, setActiveProject} from 'ng-morph';
import type {Element} from 'parse5';
import type {Element} from 'parse5/dist/tree-adapters/default';

import {ALL_FILES, ALL_TS_FILES} from '../../../constants';
import type {TuiSchema} from '../../../ng-add/schema';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function replaceBreadcrumbs({
elements.forEach(element => {
const itemsAttr = element.attrs.find(attr => attr.name === '[items]');
const itemsValue = itemsAttr?.value;
const insertTo = element?.sourceCodeLocation?.startTag.endOffset;
const insertTo = element?.sourceCodeLocation?.startTag?.endOffset ?? 0;

if (!itemsValue || !insertTo) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type {UpdateRecorder} from '@angular-devkit/schematics';
import {arrayFlat} from 'ng-morph';
import type {DevkitFileSystem} from 'ng-morph/project/classes/devkit-file-system';
import type {Attribute, Element} from 'parse5';
import type {Attribute} from 'parse5/dist/common/token';
import type {Element} from 'parse5/dist/tree-adapters/default';

import {
findElementsByFn,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {UpdateRecorder} from '@angular-devkit/schematics';
import type {DevkitFileSystem} from 'ng-morph';
import type {Attribute} from 'parse5';
import type {Attribute} from 'parse5/dist/common/token';

import {addImportToClosestModule} from '../../../../utils/add-import-to-closest-module';
import {findElementsByTagName} from '../../../../utils/templates/elements';
Expand Down Expand Up @@ -76,7 +76,8 @@ export function migrateAvatar({
fallbackAttr?.value &&
normalizeAttrValue(fallbackAttr.name, fallbackAttr.value);

const insertTo = sourceCodeLocation.startTag.startOffset + '<tui-avatar'.length;
const insertTo =
(sourceCodeLocation.startTag?.startOffset ?? 0) + '<tui-avatar'.length;

if (!insertTo) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {UpdateRecorder} from '@angular-devkit/schematics';
import type {DevkitFileSystem} from 'ng-morph';
import type {Attribute, Element, ElementLocation} from 'parse5';
import type {Attribute, ElementLocation} from 'parse5/dist/common/token';
import type {Element} from 'parse5/dist/tree-adapters/default';

import {findElementsByTagName} from '../../../../utils/templates/elements';
import {
Expand Down Expand Up @@ -97,7 +98,7 @@ function migrateBadgeValue({
templateOffset: number;
}): void {
const attrValue = valueAttr?.value;
const insertTo = sourceCodeLocation?.endTag.startOffset;
const insertTo = sourceCodeLocation?.endTag?.startOffset ?? 0;

if (!attrValue || !insertTo) {
return;
Expand All @@ -123,7 +124,7 @@ function addTodo(
templateOffset: number,
): void {
recorder.insertRight(
templateOffset + (sourceCodeLocation?.startTag.startOffset || 0),
templateOffset + (sourceCodeLocation?.startTag?.startOffset ?? 0),
'<!-- Taiga migration TODO: use "<tui-icon>" with "tuiBadge" directive for icon-only badges instead -->\n',
);
}
Loading

0 comments on commit 15959af

Please sign in to comment.