Skip to content

Commit

Permalink
feat(schematics): add v9 migration rules for tree (#4602)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsuanxyz authored Apr 14, 2020
1 parent fc87537 commit 87b8e55
Show file tree
Hide file tree
Showing 10 changed files with 230 additions and 75 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"@types/lodash.debounce": "^4.0.6",
"@types/node": "^12.11.1",
"@types/parse5": "^5.0.2",
"@types/shelljs": "^0.8.6",
"antd-theme-generator": "^1.1.9",
"chalk": "^2.4.2",
"classlist.js": "^1.1.20150312",
Expand Down
78 changes: 38 additions & 40 deletions schematics/ng-update/data/input-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,14 @@ export const inputNames: VersionChanges<InputNameUpgradeData> = {
whitelist : {
attributes: ['nz-popconfirm']
}
}
]
},
{
pr : 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/3909',
changes: [
},
{
replace : 'nzTrigger',
replaceWith: 'nzPopconfirmTrigger',
whitelist : {
attributes: ['nz-popconfirm']
}
}
]
},
{
pr : 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/3909',
changes: [
},
{
replace : 'nzPlacement',
replaceWith: 'nzPopconfirmPlacement',
Expand All @@ -61,24 +51,14 @@ export const inputNames: VersionChanges<InputNameUpgradeData> = {
whitelist : {
attributes: ['nz-tooltip']
}
}
]
},
{
pr : 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/3909',
changes: [
},
{
replace : 'nzTrigger',
replaceWith: 'nzTooltipTrigger',
whitelist : {
attributes: ['nz-tooltip']
}
}
]
},
{
pr : 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/3909',
changes: [
},
{
replace : 'nzPlacement',
replaceWith: 'nzTooltipPlacement',
Expand All @@ -97,41 +77,59 @@ export const inputNames: VersionChanges<InputNameUpgradeData> = {
whitelist : {
attributes: ['nz-popover']
}
}
]
},
{
pr : 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/3909',
changes: [
},
{
replace : 'nzTrigger',
replaceWith: 'nzPopoverTrigger',
whitelist : {
attributes: ['nz-popover']
}
}
]
},
{
pr : 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/3909',
changes: [
},
{
replace : 'nzPlacement',
replaceWith: 'nzPopoverPlacement',
whitelist : {
attributes: ['nz-popover']
}
},
{
replace : 'nzContent',
replaceWith: 'nzPopoverContent',
whitelist : {
attributes: ['nz-popover']
}
}
]
},
{
pr : 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/3909',
pr : 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/4601',
changes: [
{
replace : 'nzContent',
replaceWith: 'nzPopoverContent',
replace : 'nzDefaultExpandAll',
replaceWith: 'nzExpandAll',
whitelist : {
attributes: ['nz-popover']
elements: ['nz-tree', 'nz-tree-node']
}
},
{
replace : 'nzDefaultExpandedKeys',
replaceWith: 'nzExpandedKeys',
whitelist : {
elements: ['nz-tree', 'nz-tree-select']
}
},
{
replace : 'nzDefaultSelectedKeys',
replaceWith: 'nzSelectedKeys',
whitelist : {
elements: ['nz-tree']
}
},
{
replace : 'nzDefaultCheckedKeys',
replaceWith: 'nzCheckedKeys',
whitelist : {
elements: ['nz-tree']
}
}
]
Expand Down
16 changes: 15 additions & 1 deletion schematics/ng-update/data/output-names.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import { OutputNameUpgradeData, TargetVersion, VersionChanges } from '@angular/cdk/schematics';

export const outputNames: VersionChanges<OutputNameUpgradeData> = {
[ TargetVersion.V7 ]: []
[ TargetVersion.V7 ]: [],
[ TargetVersion.V9 ]: [
{
pr : 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/4601',
changes: [
{
replace : 'nzOnSearchNode',
replaceWith: 'nzSearchValueChange',
whitelist : {
elements: ['nz-tree']
}
}
]
}
]
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HostTree } from '@angular-devkit/schematics';
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
import * as shx from 'shelljs';

import { SchematicsTestTsConfig, SchematicsTestNGConfig } from '../config';
import { SchematicsTestNGConfig, SchematicsTestTsConfig } from '../config';

describe('dropdown class migration', () => {
let runner: SchematicTestRunner;
Expand All @@ -13,7 +13,6 @@ describe('dropdown class migration', () => {
let tmpDirPath: string;
let previousWorkingDir: string;
let warnOutput: string[];
let errorOutput: string[];

beforeEach(() => {
runner = new SchematicTestRunner('test', require.resolve('../../../migration.json'));
Expand All @@ -24,12 +23,9 @@ describe('dropdown class migration', () => {
writeFile('/angular.json', JSON.stringify(SchematicsTestNGConfig));

warnOutput = [];
errorOutput = [];
runner.logger.subscribe(logEntry => {
if (logEntry.level === 'warn') {
warnOutput.push(logEntry.message);
} else if (logEntry.level === 'error') {
errorOutput.push(logEntry.message);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TempScopedNodeJsSyncHost } from '@angular-devkit/core/node/testing';
import { HostTree } from '@angular-devkit/schematics';
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
import * as shx from 'shelljs';
import { SchematicsTestTsConfig, SchematicsTestNGConfig } from '../config';
import { SchematicsTestNGConfig, SchematicsTestTsConfig } from '../config';

describe('dropdown components migration', () => {
let runner: SchematicTestRunner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TempScopedNodeJsSyncHost } from '@angular-devkit/core/node/testing';
import { HostTree } from '@angular-devkit/schematics';
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
import * as shx from 'shelljs';
import { SchematicsTestTsConfig, SchematicsTestNGConfig } from '../config';
import { SchematicsTestNGConfig, SchematicsTestTsConfig } from '../config';

describe('tooltip-like migration', () => {
let runner: SchematicTestRunner;
Expand All @@ -12,7 +12,6 @@ describe('tooltip-like migration', () => {
let tmpDirPath: string;
let previousWorkingDir: string;
let warnOutput: string[];
let errorOutput: string[];

beforeEach(() => {
runner = new SchematicTestRunner('test', require.resolve('../../../migration.json'));
Expand All @@ -23,12 +22,9 @@ describe('tooltip-like migration', () => {
writeFile('/angular.json', JSON.stringify(SchematicsTestNGConfig));

warnOutput = [];
errorOutput = [];
runner.logger.subscribe(logEntry => {
if (logEntry.level === 'warn') {
warnOutput.push(logEntry.message);
} else if (logEntry.level === 'error') {
errorOutput.push(logEntry.message);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TempScopedNodeJsSyncHost } from '@angular-devkit/core/node/testing';
import { HostTree } from '@angular-devkit/schematics';
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
import * as shx from 'shelljs';
import { SchematicsTestTsConfig, SchematicsTestNGConfig } from '../config';
import { SchematicsTestNGConfig, SchematicsTestTsConfig } from '../config';

describe('calendar migration', () => {
let runner: SchematicTestRunner;
Expand All @@ -12,7 +12,6 @@ describe('calendar migration', () => {
let tmpDirPath: string;
let previousWorkingDir: string;
let warnOutput: string[];
let errorOutput: string[];

beforeEach(() => {
runner = new SchematicTestRunner('test', require.resolve('../../../migration.json'));
Expand All @@ -23,12 +22,9 @@ describe('calendar migration', () => {
writeFile('/angular.json', JSON.stringify(SchematicsTestNGConfig));

warnOutput = [];
errorOutput = [];
runner.logger.subscribe(logEntry => {
if (logEntry.level === 'warn') {
warnOutput.push(logEntry.message);
} else if (logEntry.level === 'error') {
errorOutput.push(logEntry.message);
}
});

Expand Down
6 changes: 1 addition & 5 deletions schematics/ng-update/test-cases/v9/input-names-icon.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TempScopedNodeJsSyncHost } from '@angular-devkit/core/node/testing';
import { HostTree } from '@angular-devkit/schematics';
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
import * as shx from 'shelljs';
import { SchematicsTestTsConfig, SchematicsTestNGConfig } from '../config';
import { SchematicsTestNGConfig, SchematicsTestTsConfig } from '../config';

describe('icon migration', () => {
let runner: SchematicTestRunner;
Expand All @@ -12,7 +12,6 @@ describe('icon migration', () => {
let tmpDirPath: string;
let previousWorkingDir: string;
let warnOutput: string[];
let errorOutput: string[];

beforeEach(() => {
runner = new SchematicTestRunner('test', require.resolve('../../../migration.json'));
Expand All @@ -23,12 +22,9 @@ describe('icon migration', () => {
writeFile('/angular.json', JSON.stringify(SchematicsTestNGConfig));

warnOutput = [];
errorOutput = [];
runner.logger.subscribe(logEntry => {
if (logEntry.level === 'warn') {
warnOutput.push(logEntry.message);
} else if (logEntry.level === 'error') {
errorOutput.push(logEntry.message);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ import { TempScopedNodeJsSyncHost } from '@angular-devkit/core/node/testing';
import { HostTree } from '@angular-devkit/schematics';
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
import * as shx from 'shelljs';
import { SchematicsTestTsConfig, SchematicsTestNGConfig } from '../config';
import { SchematicsTestNGConfig, SchematicsTestTsConfig } from '../config';

describe('tooltip-like migration', () => {
let runner: SchematicTestRunner;
let host: TempScopedNodeJsSyncHost;
let tree: UnitTestTree;
let tmpDirPath: string;
let previousWorkingDir: string;
let warnOutput: string[];
let errorOutput: string[];

beforeEach(() => {
runner = new SchematicTestRunner('test', require.resolve('../../../migration.json'));
Expand All @@ -22,16 +20,6 @@ describe('tooltip-like migration', () => {
writeFile('/tsconfig.json', JSON.stringify(SchematicsTestTsConfig));
writeFile('/angular.json', JSON.stringify(SchematicsTestNGConfig));

warnOutput = [];
errorOutput = [];
runner.logger.subscribe(logEntry => {
if (logEntry.level === 'warn') {
warnOutput.push(logEntry.message);
} else if (logEntry.level === 'error') {
errorOutput.push(logEntry.message);
}
});

previousWorkingDir = shx.pwd();
tmpDirPath = getSystemPath(host.root);

Expand Down
Loading

0 comments on commit 87b8e55

Please sign in to comment.