Skip to content

Commit

Permalink
feat(schematics): add v19 ng update migration (#8911)
Browse files Browse the repository at this point in the history
* feat(schematics): add v19 ng update migration

* feat(schematics): add nz-card[borderless] migration

* feat(schematics): set standalone property of ng-add template

* feat(schematics): ng generate should set standalone property to be false

* feat(schematics): remove redundant standalone:true

* feat(schematics): should use provideNzI18n when ng add
  • Loading branch information
Laffery authored Dec 6, 2024
1 parent cc5e4f9 commit 1a20de2
Show file tree
Hide file tree
Showing 56 changed files with 468 additions and 279 deletions.
1 change: 0 additions & 1 deletion components/cascader/demo/multiple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const options: NzCascaderOption[] = [

@Component({
selector: 'nz-demo-cascader-multiple',
standalone: true,
imports: [FormsModule, NzCascaderModule],
template: `
<nz-cascader
Expand Down
4 changes: 2 additions & 2 deletions components/i18n/date-helper.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { NZ_DATE_CONFIG } from './date-config';
import { DateHelperByDatePipe, DateHelperService } from './date-helper.service';
import en_US from './languages/en_US';
import { NzI18nModule } from './nz-i18n.module';
import { NZ_DATE_LOCALE, NZ_I18N } from './nz-i18n.token';
import { NZ_DATE_LOCALE, provideNzI18n } from './nz-i18n.token';

describe('DateHelperService', () => {
let injector: Injector;
Expand All @@ -17,7 +17,7 @@ describe('DateHelperService', () => {
beforeEach(() => {
injector = TestBed.configureTestingModule({
imports: [NzI18nModule],
providers: [{ provide: NZ_I18N, useValue: en_US }]
providers: [provideNzI18n(en_US)]
});

dateHelper = injector.get(DateHelperService);
Expand Down
1 change: 0 additions & 1 deletion components/input-number-legacy/demo/addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { NzSpaceModule } from 'ng-zorro-antd/space';

@Component({
selector: 'nz-demo-input-number-legacy-addon',
standalone: true,
imports: [FormsModule, NzCascaderModule, NzInputNumberLegacyModule, NzSelectModule, NzSpaceModule],
template: `
<nz-space nzDirection="vertical" style="width: 100%">
Expand Down
1 change: 0 additions & 1 deletion components/input-number-legacy/demo/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { NzInputNumberLegacyModule } from 'ng-zorro-antd/input-number-legacy';

@Component({
selector: 'nz-demo-input-number-legacy-basic',
standalone: true,
imports: [FormsModule, NzInputNumberLegacyModule],
template: `<nz-input-number [(ngModel)]="value" [nzMin]="1" [nzMax]="10" [nzStep]="1"></nz-input-number>`
})
Expand Down
1 change: 0 additions & 1 deletion components/input-number-legacy/demo/borderless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { NzInputNumberLegacyModule } from 'ng-zorro-antd/input-number-legacy';

@Component({
selector: 'nz-demo-input-number-legacy-borderless',
standalone: true,
imports: [FormsModule, NzInputNumberLegacyModule],
template: `<nz-input-number nzBorderless [(ngModel)]="value"></nz-input-number>`
})
Expand Down
1 change: 0 additions & 1 deletion components/input-number-legacy/demo/digit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { NzInputNumberLegacyModule } from 'ng-zorro-antd/input-number-legacy';

@Component({
selector: 'nz-demo-input-number-legacy-digit',
standalone: true,
imports: [FormsModule, NzInputNumberLegacyModule],
template: `
<nz-input-number
Expand Down
1 change: 0 additions & 1 deletion components/input-number-legacy/demo/disabled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { NzInputNumberLegacyModule } from 'ng-zorro-antd/input-number-legacy';

@Component({
selector: 'nz-demo-input-number-legacy-disabled',
standalone: true,
imports: [FormsModule, NzButtonModule, NzInputNumberLegacyModule],
template: `
<nz-input-number
Expand Down
1 change: 0 additions & 1 deletion components/input-number-legacy/demo/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { NzInputNumberLegacyModule } from 'ng-zorro-antd/input-number-legacy';

@Component({
selector: 'nz-demo-input-number-legacy-formatter',
standalone: true,
imports: [FormsModule, NzInputNumberLegacyModule],
template: `
<nz-input-number
Expand Down
1 change: 0 additions & 1 deletion components/input-number-legacy/demo/prefix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { NzSpaceModule } from 'ng-zorro-antd/space';

@Component({
selector: 'nz-demo-input-number-legacy-prefix',
standalone: true,
imports: [FormsModule, NzInputNumberLegacyModule, NzSpaceModule],
template: `
<nz-space nzDirection="vertical" style="width: 100%">
Expand Down
1 change: 0 additions & 1 deletion components/input-number-legacy/demo/size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { NzInputNumberLegacyModule } from 'ng-zorro-antd/input-number-legacy';

@Component({
selector: 'nz-demo-input-number-legacy-size',
standalone: true,
imports: [FormsModule, NzInputNumberLegacyModule],
template: `
<nz-input-number [(ngModel)]="value" [nzSize]="'large'" [nzMin]="1" [nzMax]="10" [nzStep]="1"></nz-input-number>
Expand Down
1 change: 0 additions & 1 deletion components/input-number-legacy/demo/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { NzSpaceModule } from 'ng-zorro-antd/space';

@Component({
selector: 'nz-demo-input-number-legacy-status',
standalone: true,
imports: [FormsModule, NzInputNumberLegacyModule, NzSpaceModule],
template: `
<nz-space nzDirection="vertical" style="width: 100%">
Expand Down
1 change: 0 additions & 1 deletion components/input-number-legacy/input-number.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ import { NZ_SPACE_COMPACT_ITEM_TYPE, NZ_SPACE_COMPACT_SIZE, NzSpaceCompactItemDi
'[class.ant-input-number-borderless]': `nzBorderless`
},
imports: [NzIconModule, FormsModule, NzFormPatchModule],
standalone: true,
hostDirectives: [NzSpaceCompactItemDirective]
})
export class NzInputNumberLegacyComponent implements ControlValueAccessor, AfterViewInit, OnChanges, OnInit, OnDestroy {
Expand Down
1 change: 0 additions & 1 deletion components/input-number/demo/handler-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { NzInputNumberModule } from 'ng-zorro-antd/input-number';

@Component({
selector: 'nz-demo-input-number-handler-icon',
standalone: true,
imports: [FormsModule, NzInputNumberModule, NzIconModule],
template: `
<nz-input-number [(ngModel)]="value">
Expand Down
1 change: 0 additions & 1 deletion components/input-number/demo/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { NzInputNumberModule } from 'ng-zorro-antd/input-number';

@Component({
selector: 'nz-demo-input-number-keyboard',
standalone: true,
imports: [FormsModule, NzInputNumberModule, NzCheckboxModule],
template: `
<nz-input-number [(ngModel)]="value" [nzKeyboard]="keyboard" nzMin="1" nzMax="10" />
Expand Down
1 change: 0 additions & 1 deletion components/input-number/demo/out-of-range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { NzInputNumberModule } from 'ng-zorro-antd/input-number';

@Component({
selector: 'nz-demo-input-number-out-of-range',
standalone: true,
imports: [FormsModule, NzInputNumberModule],
template: `<nz-input-number [(ngModel)]="value" nzMin="1" nzMax="10" />`
})
Expand Down
2 changes: 0 additions & 2 deletions components/input-number/input-number.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ describe('Input number with affixes or addons', () => {
});

@Component({
standalone: true,
imports: [NzInputNumberModule, FormsModule],
template: `
<nz-input-number
Expand Down Expand Up @@ -352,7 +351,6 @@ class InputNumberTestComponent {
}

@Component({
standalone: true,
imports: [NzInputNumberModule],
template: `
<nz-input-number #withAffixes [nzDisabled]="disabled" [nzReadOnly]="readonly" [nzBordered]="bordered">
Expand Down
6 changes: 2 additions & 4 deletions components/input/input-addon.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
import { Directive } from '@angular/core';

@Directive({
selector: '[nzInputAddonBefore]',
standalone: true
selector: '[nzInputAddonBefore]'
})
export class NzInputAddonBeforeDirective {}

@Directive({
selector: '[nzInputAddonAfter]',
standalone: true
selector: '[nzInputAddonAfter]'
})
export class NzInputAddonAfterDirective {}
6 changes: 2 additions & 4 deletions components/input/input-affix.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
import { Directive } from '@angular/core';

@Directive({
selector: '[nzInputPrefix]',
standalone: true
selector: '[nzInputPrefix]'
})
export class NzInputPrefixDirective {}

@Directive({
selector: '[nzInputSuffix]',
standalone: true
selector: '[nzInputSuffix]'
})
export class NzInputSuffixDirective {}
8 changes: 4 additions & 4 deletions docs/i18n.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ import { enUS, ja } from 'date-fns/locale';
]
})
export class AppModule {
constructor(private i18n: NzI18nService) { }
constructor(private i18n: NzI18nService) {}

// ...

Expand Down Expand Up @@ -202,7 +202,7 @@ The default configuration is as follows:
The text of some components in `ng-zorro` depends on the internationalized text, such as the `size changer` in `nz-pagination`. At this time, you can modify the internationalization configuration to change the text content in the `size changer`:

```ts
import { NZ_I18N, en_US } from 'ng-zorro-antd/i18n';
import { en_US, provideNzI18n } from 'ng-zorro-antd/i18n';

const customLanguagePack = {
en_US,
Expand All @@ -216,8 +216,8 @@ const customLanguagePack = {
@NgModule({
//...
providers : [
{ provide: NZ_I18N, useValue: customLanguagePack }
provideNzI18n(customLanguagePack)
]
})
export class AppModule { }
export class AppModule {}
```
106 changes: 53 additions & 53 deletions docs/i18n.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,65 +89,65 @@ class SomeComponent {

## 支持语言

| 语言 | 语言包名 |
| ---------------- | ------ |
| 阿拉伯 | ar_EG |
| 亞美尼亞 | hy_AM |
| 保加利亚语 | bg_BG |
| 孟加拉语(孟加拉国)| bn_BD |
| 加泰罗尼亚语 | ca_ES |
| 捷克语 | cs_CZ |
| 丹麦语 | da_DK |
| 德语 | de_DE |
| 希腊语 | el_GR |
| 英语 | en_GB |
| 英语(美式) | en_US |
| 西班牙语 | es_ES |
| 语言 | 语言包名 |
|-------------| ------ |
| 阿拉伯 | ar_EG |
| 亚美尼亚 | hy_AM |
| 保加利亚语 | bg_BG |
| 孟加拉语(孟加拉国) | bn_BD |
| 加泰罗尼亚语 | ca_ES |
| 捷克语 | cs_CZ |
| 丹麦语 | da_DK |
| 德语 | de_DE |
| 希腊语 | el_GR |
| 英语 | en_GB |
| 英语(美式) | en_US |
| 西班牙语 | es_ES |
| 爱沙尼亚语 | et_EE |
| 波斯语 | fa_IR |
| 芬兰语 | fi_FI |
| 法语(比利时) | fr_BE |
| 法语(加拿大) | fr_CA |
| 法语 | fr_FR |
| 希伯来语 | he_IL |
| 印地语 | hi_IN |
| 波斯语 | fa_IR |
| 芬兰语 | fi_FI |
| 法语(比利时) | fr_BE |
| 法语(加拿大) | fr_CA |
| 法语 | fr_FR |
| 希伯来语 | he_IL |
| 印地语 | hi_IN |
| 克罗地亚语 | hr_HR |
| 匈牙利 | hu_HU |
| 冰岛语 | is_IS |
| 匈牙利 | hu_HU |
| 冰岛语 | is_IS |
| 印度尼西亚语 | id_ID |
| 意大利语 | it_IT |
| 日语 | ja_JP |
| 意大利语 | it_IT |
| 日语 | ja_JP |
| 格鲁吉亚语 | ka_GE |
| 哈萨克语 | kk_KZ |
| 高棉语 | km_KH |
| 卡纳达语 | kn_IN |
| 哈萨克语 | kk_KZ |
| 高棉语 | km_KH |
| 卡纳达语 | kn_IN |
| 韩语/朝鲜语 | ko_KR |
| 库尔德语 | ku_IQ |
| 库尔德语 | ku_IQ |
| 拉脱维亚语 | lv_LV |
| 马来语 | ms_MY |
| 马拉雅拉姆语 | ml_IN |
| 蒙古语 | mn_MN |
| 挪威 | nb_NO |
| 尼泊尔语 | ne_NP |
| 荷兰语(比利时) | nl_BE |
| 荷兰语 | nl_NL |
| 波兰语 | pl_PL |
| 葡萄牙语(巴西) | pt_BR |
| 葡萄牙语 | pt_PT |
| 马来语 | ms_MY |
| 马拉雅拉姆语 | ml_IN |
| 蒙古语 | mn_MN |
| 挪威 | nb_NO |
| 尼泊尔语 | ne_NP |
| 荷兰语(比利时) | nl_BE |
| 荷兰语 | nl_NL |
| 波兰语 | pl_PL |
| 葡萄牙语(巴西) | pt_BR |
| 葡萄牙语 | pt_PT |
| 斯洛伐克语 | sk_SK |
| 塞尔维亚 | sr_RS |
| 塞尔维亚 | sr_RS |
| 斯洛文尼亚 | sl_SI |
| 瑞典语 | sv_SE |
| 泰米尔语 | ta_IN |
| 泰语 | th_TH |
| 土耳其语 | tr_TR |
| 瑞典语 | sv_SE |
| 泰米尔语 | ta_IN |
| 泰语 | th_TH |
| 土耳其语 | tr_TR |
| 罗马尼亚语 | ro_RO |
| 俄罗斯语 | ru_RU |
| 乌克兰语 | uk_UA |
| 俄罗斯语 | ru_RU |
| 乌克兰语 | uk_UA |
| 乌尔都语 (巴基斯坦) | ur_PK |
| 越南语 | vi_VN |
| 简体中文 | zh_CN |
| 繁体中文 | zh_TW |
| 越南语 | vi_VN |
| 简体中文 | zh_CN |
| 繁体中文 | zh_TW |

## 如何使用 date-fns 进行日期格式化

Expand All @@ -166,7 +166,7 @@ import { enUS, ja } from 'date-fns/locale';
]
})
export class AppModule {
constructor(private i18n: NzI18nService) { }
constructor(private i18n: NzI18nService) {}

// ...

Expand Down Expand Up @@ -202,7 +202,7 @@ registerLocaleData(en);
`ng-zorro` 中有些组件的文本依赖于国际化文本,例如 `nz-pagination` 中的 `size changer`, 这时候你可以修改国际化配置来更改 `size changer` 中的文本内容:

```ts
import { NZ_I18N, en_US } from 'ng-zorro-antd/i18n';
import { en_US, provideNzI18n } from 'ng-zorro-antd/i18n';

const customLanguagePack = {
en_US,
Expand All @@ -216,8 +216,8 @@ const customLanguagePack = {
@NgModule({
//...
providers : [
{ provide: NZ_I18N, useValue: customLanguagePack }
provideNzI18n(customLanguagePack)
]
})
export class AppModule { }
export class AppModule {}
```
2 changes: 1 addition & 1 deletion schematics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $ ng add ng-zorro-antd [--locale=zh-CN] [--theme] [--skipPackageJson]
### 调试

1. `schematic:build` 修改代码后编译
2 `cd schematic-debug` 切换到 ng 项目
2. `cd schematic-debug` 切换到 ng 项目
3. `git checkout . && git clean -fd` 还原更改
4. `ng g ng-zorro-antd:[schematic]` 运行 schematic

Expand Down
8 changes: 4 additions & 4 deletions schematics/migration.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json",
"schematics": {
"migration-v18": {
"version": "18.0.0-0",
"description": "Updates NG-ZORRO to v18 [https://github.com/NG-ZORRO/ng-zorro-antd/issues/8546]",
"factory": "./ng-update/index#updateToV18"
"migration-v19": {
"version": "19.0.0-0",
"description": "Updates NG-ZORRO to v19 [https://github.com/NG-ZORRO/ng-zorro-antd/issues/8890]",
"factory": "./ng-update/index#updateToV19"
},
"ng-post-update": {
"description": "Prints out results after ng-update.",
Expand Down
Loading

0 comments on commit 1a20de2

Please sign in to comment.