Skip to content

Commit 1a20de2

Browse files
authored
feat(schematics): add v19 ng update migration (#8911)
* 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
1 parent cc5e4f9 commit 1a20de2

Some content is hidden

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

56 files changed

+468
-279
lines changed

components/cascader/demo/multiple.ts

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ const options: NzCascaderOption[] = [
4242

4343
@Component({
4444
selector: 'nz-demo-cascader-multiple',
45-
standalone: true,
4645
imports: [FormsModule, NzCascaderModule],
4746
template: `
4847
<nz-cascader

components/i18n/date-helper.service.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { NZ_DATE_CONFIG } from './date-config';
77
import { DateHelperByDatePipe, DateHelperService } from './date-helper.service';
88
import en_US from './languages/en_US';
99
import { NzI18nModule } from './nz-i18n.module';
10-
import { NZ_DATE_LOCALE, NZ_I18N } from './nz-i18n.token';
10+
import { NZ_DATE_LOCALE, provideNzI18n } from './nz-i18n.token';
1111

1212
describe('DateHelperService', () => {
1313
let injector: Injector;
@@ -17,7 +17,7 @@ describe('DateHelperService', () => {
1717
beforeEach(() => {
1818
injector = TestBed.configureTestingModule({
1919
imports: [NzI18nModule],
20-
providers: [{ provide: NZ_I18N, useValue: en_US }]
20+
providers: [provideNzI18n(en_US)]
2121
});
2222

2323
dateHelper = injector.get(DateHelperService);

components/input-number-legacy/demo/addon.ts

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { NzSpaceModule } from 'ng-zorro-antd/space';
88

99
@Component({
1010
selector: 'nz-demo-input-number-legacy-addon',
11-
standalone: true,
1211
imports: [FormsModule, NzCascaderModule, NzInputNumberLegacyModule, NzSelectModule, NzSpaceModule],
1312
template: `
1413
<nz-space nzDirection="vertical" style="width: 100%">

components/input-number-legacy/demo/basic.ts

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { NzInputNumberLegacyModule } from 'ng-zorro-antd/input-number-legacy';
55

66
@Component({
77
selector: 'nz-demo-input-number-legacy-basic',
8-
standalone: true,
98
imports: [FormsModule, NzInputNumberLegacyModule],
109
template: `<nz-input-number [(ngModel)]="value" [nzMin]="1" [nzMax]="10" [nzStep]="1"></nz-input-number>`
1110
})

components/input-number-legacy/demo/borderless.ts

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { NzInputNumberLegacyModule } from 'ng-zorro-antd/input-number-legacy';
55

66
@Component({
77
selector: 'nz-demo-input-number-legacy-borderless',
8-
standalone: true,
98
imports: [FormsModule, NzInputNumberLegacyModule],
109
template: `<nz-input-number nzBorderless [(ngModel)]="value"></nz-input-number>`
1110
})

components/input-number-legacy/demo/digit.ts

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { NzInputNumberLegacyModule } from 'ng-zorro-antd/input-number-legacy';
55

66
@Component({
77
selector: 'nz-demo-input-number-legacy-digit',
8-
standalone: true,
98
imports: [FormsModule, NzInputNumberLegacyModule],
109
template: `
1110
<nz-input-number

components/input-number-legacy/demo/disabled.ts

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { NzInputNumberLegacyModule } from 'ng-zorro-antd/input-number-legacy';
66

77
@Component({
88
selector: 'nz-demo-input-number-legacy-disabled',
9-
standalone: true,
109
imports: [FormsModule, NzButtonModule, NzInputNumberLegacyModule],
1110
template: `
1211
<nz-input-number

components/input-number-legacy/demo/formatter.ts

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { NzInputNumberLegacyModule } from 'ng-zorro-antd/input-number-legacy';
55

66
@Component({
77
selector: 'nz-demo-input-number-legacy-formatter',
8-
standalone: true,
98
imports: [FormsModule, NzInputNumberLegacyModule],
109
template: `
1110
<nz-input-number

components/input-number-legacy/demo/prefix.ts

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { NzSpaceModule } from 'ng-zorro-antd/space';
66

77
@Component({
88
selector: 'nz-demo-input-number-legacy-prefix',
9-
standalone: true,
109
imports: [FormsModule, NzInputNumberLegacyModule, NzSpaceModule],
1110
template: `
1211
<nz-space nzDirection="vertical" style="width: 100%">

components/input-number-legacy/demo/size.ts

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { NzInputNumberLegacyModule } from 'ng-zorro-antd/input-number-legacy';
55

66
@Component({
77
selector: 'nz-demo-input-number-legacy-size',
8-
standalone: true,
98
imports: [FormsModule, NzInputNumberLegacyModule],
109
template: `
1110
<nz-input-number [(ngModel)]="value" [nzSize]="'large'" [nzMin]="1" [nzMax]="10" [nzStep]="1"></nz-input-number>

components/input-number-legacy/demo/status.ts

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { NzSpaceModule } from 'ng-zorro-antd/space';
66

77
@Component({
88
selector: 'nz-demo-input-number-legacy-status',
9-
standalone: true,
109
imports: [FormsModule, NzInputNumberLegacyModule, NzSpaceModule],
1110
template: `
1211
<nz-space nzDirection="vertical" style="width: 100%">

components/input-number-legacy/input-number.component.ts

-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ import { NZ_SPACE_COMPACT_ITEM_TYPE, NZ_SPACE_COMPACT_SIZE, NzSpaceCompactItemDi
120120
'[class.ant-input-number-borderless]': `nzBorderless`
121121
},
122122
imports: [NzIconModule, FormsModule, NzFormPatchModule],
123-
standalone: true,
124123
hostDirectives: [NzSpaceCompactItemDirective]
125124
})
126125
export class NzInputNumberLegacyComponent implements ControlValueAccessor, AfterViewInit, OnChanges, OnInit, OnDestroy {

components/input-number/demo/handler-icon.ts

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { NzInputNumberModule } from 'ng-zorro-antd/input-number';
66

77
@Component({
88
selector: 'nz-demo-input-number-handler-icon',
9-
standalone: true,
109
imports: [FormsModule, NzInputNumberModule, NzIconModule],
1110
template: `
1211
<nz-input-number [(ngModel)]="value">

components/input-number/demo/keyboard.ts

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { NzInputNumberModule } from 'ng-zorro-antd/input-number';
66

77
@Component({
88
selector: 'nz-demo-input-number-keyboard',
9-
standalone: true,
109
imports: [FormsModule, NzInputNumberModule, NzCheckboxModule],
1110
template: `
1211
<nz-input-number [(ngModel)]="value" [nzKeyboard]="keyboard" nzMin="1" nzMax="10" />

components/input-number/demo/out-of-range.ts

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { NzInputNumberModule } from 'ng-zorro-antd/input-number';
55

66
@Component({
77
selector: 'nz-demo-input-number-out-of-range',
8-
standalone: true,
98
imports: [FormsModule, NzInputNumberModule],
109
template: `<nz-input-number [(ngModel)]="value" nzMin="1" nzMax="10" />`
1110
})

components/input-number/input-number.component.spec.ts

-2
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ describe('Input number with affixes or addons', () => {
311311
});
312312

313313
@Component({
314-
standalone: true,
315314
imports: [NzInputNumberModule, FormsModule],
316315
template: `
317316
<nz-input-number
@@ -352,7 +351,6 @@ class InputNumberTestComponent {
352351
}
353352

354353
@Component({
355-
standalone: true,
356354
imports: [NzInputNumberModule],
357355
template: `
358356
<nz-input-number #withAffixes [nzDisabled]="disabled" [nzReadOnly]="readonly" [nzBordered]="bordered">

components/input/input-addon.directive.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
import { Directive } from '@angular/core';
77

88
@Directive({
9-
selector: '[nzInputAddonBefore]',
10-
standalone: true
9+
selector: '[nzInputAddonBefore]'
1110
})
1211
export class NzInputAddonBeforeDirective {}
1312

1413
@Directive({
15-
selector: '[nzInputAddonAfter]',
16-
standalone: true
14+
selector: '[nzInputAddonAfter]'
1715
})
1816
export class NzInputAddonAfterDirective {}

components/input/input-affix.directive.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
import { Directive } from '@angular/core';
77

88
@Directive({
9-
selector: '[nzInputPrefix]',
10-
standalone: true
9+
selector: '[nzInputPrefix]'
1110
})
1211
export class NzInputPrefixDirective {}
1312

1413
@Directive({
15-
selector: '[nzInputSuffix]',
16-
standalone: true
14+
selector: '[nzInputSuffix]'
1715
})
1816
export class NzInputSuffixDirective {}

docs/i18n.en-US.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ import { enUS, ja } from 'date-fns/locale';
166166
]
167167
})
168168
export class AppModule {
169-
constructor(private i18n: NzI18nService) { }
169+
constructor(private i18n: NzI18nService) {}
170170

171171
// ...
172172

@@ -202,7 +202,7 @@ The default configuration is as follows:
202202
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`:
203203

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

207207
const customLanguagePack = {
208208
en_US,
@@ -216,8 +216,8 @@ const customLanguagePack = {
216216
@NgModule({
217217
//...
218218
providers : [
219-
{ provide: NZ_I18N, useValue: customLanguagePack }
219+
provideNzI18n(customLanguagePack)
220220
]
221221
})
222-
export class AppModule { }
222+
export class AppModule {}
223223
```

docs/i18n.zh-CN.md

+53-53
Original file line numberDiff line numberDiff line change
@@ -89,65 +89,65 @@ class SomeComponent {
8989

9090
## 支持语言
9191

92-
| 语言 | 语言包名 |
93-
| ---------------- | ------ |
94-
| 阿拉伯 | ar_EG |
95-
| 亞美尼亞 | hy_AM |
96-
| 保加利亚语 | bg_BG |
97-
| 孟加拉语(孟加拉国)| bn_BD |
98-
| 加泰罗尼亚语 | ca_ES |
99-
| 捷克语 | cs_CZ |
100-
| 丹麦语 | da_DK |
101-
| 德语 | de_DE |
102-
| 希腊语 | el_GR |
103-
| 英语 | en_GB |
104-
| 英语(美式) | en_US |
105-
| 西班牙语 | es_ES |
92+
| 语言 | 语言包名 |
93+
|-------------| ------ |
94+
| 阿拉伯 | ar_EG |
95+
| 亚美尼亚 | hy_AM |
96+
| 保加利亚语 | bg_BG |
97+
| 孟加拉语(孟加拉国) | bn_BD |
98+
| 加泰罗尼亚语 | ca_ES |
99+
| 捷克语 | cs_CZ |
100+
| 丹麦语 | da_DK |
101+
| 德语 | de_DE |
102+
| 希腊语 | el_GR |
103+
| 英语 | en_GB |
104+
| 英语(美式) | en_US |
105+
| 西班牙语 | es_ES |
106106
| 爱沙尼亚语 | et_EE |
107-
| 波斯语 | fa_IR |
108-
| 芬兰语 | fi_FI |
109-
| 法语(比利时) | fr_BE |
110-
| 法语(加拿大) | fr_CA |
111-
| 法语 | fr_FR |
112-
| 希伯来语 | he_IL |
113-
| 印地语 | hi_IN |
107+
| 波斯语 | fa_IR |
108+
| 芬兰语 | fi_FI |
109+
| 法语(比利时) | fr_BE |
110+
| 法语(加拿大) | fr_CA |
111+
| 法语 | fr_FR |
112+
| 希伯来语 | he_IL |
113+
| 印地语 | hi_IN |
114114
| 克罗地亚语 | hr_HR |
115-
| 匈牙利 | hu_HU |
116-
| 冰岛语 | is_IS |
115+
| 匈牙利 | hu_HU |
116+
| 冰岛语 | is_IS |
117117
| 印度尼西亚语 | id_ID |
118-
| 意大利语 | it_IT |
119-
| 日语 | ja_JP |
118+
| 意大利语 | it_IT |
119+
| 日语 | ja_JP |
120120
| 格鲁吉亚语 | ka_GE |
121-
| 哈萨克语 | kk_KZ |
122-
| 高棉语 | km_KH |
123-
| 卡纳达语 | kn_IN |
121+
| 哈萨克语 | kk_KZ |
122+
| 高棉语 | km_KH |
123+
| 卡纳达语 | kn_IN |
124124
| 韩语/朝鲜语 | ko_KR |
125-
| 库尔德语 | ku_IQ |
125+
| 库尔德语 | ku_IQ |
126126
| 拉脱维亚语 | lv_LV |
127-
| 马来语 | ms_MY |
128-
| 马拉雅拉姆语 | ml_IN |
129-
| 蒙古语 | mn_MN |
130-
| 挪威 | nb_NO |
131-
| 尼泊尔语 | ne_NP |
132-
| 荷兰语(比利时) | nl_BE |
133-
| 荷兰语 | nl_NL |
134-
| 波兰语 | pl_PL |
135-
| 葡萄牙语(巴西) | pt_BR |
136-
| 葡萄牙语 | pt_PT |
127+
| 马来语 | ms_MY |
128+
| 马拉雅拉姆语 | ml_IN |
129+
| 蒙古语 | mn_MN |
130+
| 挪威 | nb_NO |
131+
| 尼泊尔语 | ne_NP |
132+
| 荷兰语(比利时) | nl_BE |
133+
| 荷兰语 | nl_NL |
134+
| 波兰语 | pl_PL |
135+
| 葡萄牙语(巴西) | pt_BR |
136+
| 葡萄牙语 | pt_PT |
137137
| 斯洛伐克语 | sk_SK |
138-
| 塞尔维亚 | sr_RS |
138+
| 塞尔维亚 | sr_RS |
139139
| 斯洛文尼亚 | sl_SI |
140-
| 瑞典语 | sv_SE |
141-
| 泰米尔语 | ta_IN |
142-
| 泰语 | th_TH |
143-
| 土耳其语 | tr_TR |
140+
| 瑞典语 | sv_SE |
141+
| 泰米尔语 | ta_IN |
142+
| 泰语 | th_TH |
143+
| 土耳其语 | tr_TR |
144144
| 罗马尼亚语 | ro_RO |
145-
| 俄罗斯语 | ru_RU |
146-
| 乌克兰语 | uk_UA |
145+
| 俄罗斯语 | ru_RU |
146+
| 乌克兰语 | uk_UA |
147147
| 乌尔都语 (巴基斯坦) | ur_PK |
148-
| 越南语 | vi_VN |
149-
| 简体中文 | zh_CN |
150-
| 繁体中文 | zh_TW |
148+
| 越南语 | vi_VN |
149+
| 简体中文 | zh_CN |
150+
| 繁体中文 | zh_TW |
151151

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

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

171171
// ...
172172

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

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

207207
const customLanguagePack = {
208208
en_US,
@@ -216,8 +216,8 @@ const customLanguagePack = {
216216
@NgModule({
217217
//...
218218
providers : [
219-
{ provide: NZ_I18N, useValue: customLanguagePack }
219+
provideNzI18n(customLanguagePack)
220220
]
221221
})
222-
export class AppModule { }
222+
export class AppModule {}
223223
```

schematics/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $ ng add ng-zorro-antd [--locale=zh-CN] [--theme] [--skipPackageJson]
3737
### 调试
3838

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

schematics/migration.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json",
33
"schematics": {
4-
"migration-v18": {
5-
"version": "18.0.0-0",
6-
"description": "Updates NG-ZORRO to v18 [https://github.com/NG-ZORRO/ng-zorro-antd/issues/8546]",
7-
"factory": "./ng-update/index#updateToV18"
4+
"migration-v19": {
5+
"version": "19.0.0-0",
6+
"description": "Updates NG-ZORRO to v19 [https://github.com/NG-ZORRO/ng-zorro-antd/issues/8890]",
7+
"factory": "./ng-update/index#updateToV19"
88
},
99
"ng-post-update": {
1010
"description": "Prints out results after ng-update.",

0 commit comments

Comments
 (0)