From f402cc11abd4e31dcfa69488de036a277dcdf5b8 Mon Sep 17 00:00:00 2001 From: Hsuan Lee Date: Wed, 17 Jul 2019 13:49:34 +0800 Subject: [PATCH 1/3] refactor(module:version): add secondary entries --- components/ng-zorro-antd.module.ts | 108 +++++++++--------- components/version.ts | 3 - components/version/index.ts | 9 ++ components/version/package.json | 7 ++ components/version/public-api.ts | 9 ++ components/version/version.ts | 11 ++ docs/universal.en-US.md | 7 +- docs/universal.zh-CN.md | 5 +- schematics/ng-update/index.ts | 13 +-- scripts/release/release.ts | 11 +- scripts/site/_site/doc/app/app.component.ts | 4 +- .../share/nz-codebox/nz-codebox.component.ts | 4 +- .../doc/app/share/nz-codebox/stack-blitz.ts | 4 +- scripts/site/generate-site.js | 2 +- 14 files changed, 112 insertions(+), 85 deletions(-) delete mode 100644 components/version.ts create mode 100644 components/version/index.ts create mode 100644 components/version/package.json create mode 100644 components/version/public-api.ts create mode 100644 components/version/version.ts diff --git a/components/ng-zorro-antd.module.ts b/components/ng-zorro-antd.module.ts index 6413a5da18..4fc5c6de62 100644 --- a/components/ng-zorro-antd.module.ts +++ b/components/ng-zorro-antd.module.ts @@ -1,3 +1,11 @@ +/** + * @license + * Copyright Alibaba.com All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE + */ + import { ModuleWithProviders, NgModule } from '@angular/core'; import { NzAffixModule } from 'ng-zorro-antd/affix'; @@ -83,15 +91,14 @@ export * from 'ng-zorro-antd/date-picker'; export * from 'ng-zorro-antd/descriptions'; export * from 'ng-zorro-antd/divider'; export * from 'ng-zorro-antd/drawer'; -export * from 'ng-zorro-antd/drawer'; export * from 'ng-zorro-antd/dropdown'; export * from 'ng-zorro-antd/empty'; export * from 'ng-zorro-antd/form'; export * from 'ng-zorro-antd/grid'; export * from 'ng-zorro-antd/i18n'; export * from 'ng-zorro-antd/icon'; -export * from 'ng-zorro-antd/input-number'; export * from 'ng-zorro-antd/input'; +export * from 'ng-zorro-antd/input-number'; export * from 'ng-zorro-antd/layout'; export * from 'ng-zorro-antd/list'; export * from 'ng-zorro-antd/mention'; @@ -117,82 +124,81 @@ export * from 'ng-zorro-antd/table'; export * from 'ng-zorro-antd/tabs'; export * from 'ng-zorro-antd/tag'; export * from 'ng-zorro-antd/time-picker'; -export * from 'ng-zorro-antd/time-picker'; export * from 'ng-zorro-antd/timeline'; export * from 'ng-zorro-antd/tooltip'; export * from 'ng-zorro-antd/transfer'; -export * from 'ng-zorro-antd/tree-select'; export * from 'ng-zorro-antd/tree'; +export * from 'ng-zorro-antd/tree-select'; export * from 'ng-zorro-antd/typography'; export * from 'ng-zorro-antd/upload'; -export * from './version'; +export * from 'ng-zorro-antd/version'; @NgModule({ exports: [ - NzButtonModule, - NzCalendarModule, - NzGridModule, - NzSwitchModule, - NzSelectModule, - NzMenuModule, - NzMentionModule, - NzAnchorModule, NzAffixModule, - NzDropDownModule, - NzLayoutModule, - NzBreadCrumbModule, - NzPaginationModule, - NzStepsModule, - NzInputModule, - NzCheckboxModule, - NzInputNumberModule, - NzSliderModule, - NzRateModule, - NzBadgeModule, - NzRadioModule, NzAlertModule, - NzSpinModule, - NzPageHeaderModule, - NzProgressModule, - NzTabsModule, - NzIconModule, - NzCardModule, + NzAnchorModule, + NzAutocompleteModule, NzAvatarModule, - NzTimelineModule, - NzTransButtonModule, - NzTransferModule, + NzBackTopModule, + NzBadgeModule, + NzButtonModule, + NzBreadCrumbModule, + NzCalendarModule, + NzCardModule, NzCarouselModule, + NzCascaderModule, + NzCheckboxModule, NzCollapseModule, NzCommentModule, - NzTableModule, NzDatePickerModule, + NzDescriptionsModule, NzDividerModule, NzDrawerModule, + NzDropDownModule, + NzEmptyModule, NzFormModule, - NzListModule, + NzGridModule, NzI18nModule, - NzUploadModule, - NzAutocompleteModule, - NzTagModule, + NzIconModule, + NzInputModule, + NzInputNumberModule, + NzLayoutModule, + NzListModule, + NzMentionModule, + NzMenuModule, NzMessageModule, + NzModalModule, + NzNoAnimationModule, NzNotificationModule, + NzPageHeaderModule, + NzPaginationModule, + NzPopconfirmModule, NzPopoverModule, + NzProgressModule, + NzRadioModule, + NzRateModule, + NzSelectModule, + NzSkeletonModule, + NzSliderModule, + NzSpinModule, + NzStatisticModule, + NzStepsModule, + NzSwitchModule, + NzTableModule, + NzTabsModule, + NzTagModule, + NzTimePickerModule, + NzTimelineModule, NzToolTipModule, - NzPopconfirmModule, - NzModalModule, - NzBackTopModule, - NzCascaderModule, + NzTransButtonModule, + NzTransferModule, NzTreeModule, NzTreeSelectModule, - NzTimePickerModule, - NzWaveModule, - NzNoAnimationModule, - NzSkeletonModule, - NzStatisticModule, - NzEmptyModule, - NzDescriptionsModule, - NzTypographyModule + NzTypographyModule, + NzUploadModule, + NzWaveModule ] }) export class NgZorroAntdModule { diff --git a/components/version.ts b/components/version.ts deleted file mode 100644 index 98d3f6036c..0000000000 --- a/components/version.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { Version } from '@angular/core'; - -export const VERSION = new Version('8.0.3'); diff --git a/components/version/index.ts b/components/version/index.ts new file mode 100644 index 0000000000..f17e95188c --- /dev/null +++ b/components/version/index.ts @@ -0,0 +1,9 @@ +/** + * @license + * Copyright Alibaba.com All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE + */ + +export * from './public-api'; diff --git a/components/version/package.json b/components/version/package.json new file mode 100644 index 0000000000..ded1e7a9fd --- /dev/null +++ b/components/version/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} diff --git a/components/version/public-api.ts b/components/version/public-api.ts new file mode 100644 index 0000000000..c30df57ca0 --- /dev/null +++ b/components/version/public-api.ts @@ -0,0 +1,9 @@ +/** + * @license + * Copyright Alibaba.com All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE + */ + +export * from './version'; diff --git a/components/version/version.ts b/components/version/version.ts new file mode 100644 index 0000000000..68da39b02a --- /dev/null +++ b/components/version/version.ts @@ -0,0 +1,11 @@ +/** + * @license + * Copyright Alibaba.com All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE + */ + +import { Version } from '@angular/core'; + +export const VERSION = new Version('8.0.3'); diff --git a/docs/universal.en-US.md b/docs/universal.en-US.md index b5f7a4382a..e9675308eb 100644 --- a/docs/universal.en-US.md +++ b/docs/universal.en-US.md @@ -3,9 +3,12 @@ order: 5 title: Server-side Rendering --- -

This guide assumes that you already know about Server-side Rendering(SSR).

+
+

This guide assumes that you already know about Server-side Rendering(SSR).

+

You can also start your project with NG-ZORRO/ng-zorro-universal-starter.

+
-This guide is based on the popular [Express](https://expressjs.com/) framework. +This guide is based on the popular [Express](https://expressjs.com/) framework.n ## Installation dependence diff --git a/docs/universal.zh-CN.md b/docs/universal.zh-CN.md index ee901a0d8c..835675e0e8 100644 --- a/docs/universal.zh-CN.md +++ b/docs/universal.zh-CN.md @@ -3,7 +3,10 @@ order: 5 title: 服务端渲染 --- -

本指南假设你已了解关于 Angular Universal:服务端渲染 的相关知识。

+
+

本指南假设你已了解关于 Angular Universal:服务端渲染 的相关知识。

+

你也可以使用 NG-ZORRO/ng-zorro-universal-starter 开始你的项目。

+
本指南 Web 服务器是基于常见的 [Express](https://expressjs.com/) 框架。 diff --git a/schematics/ng-update/index.ts b/schematics/ng-update/index.ts index 3c117904dc..7512ad10f7 100644 --- a/schematics/ng-update/index.ts +++ b/schematics/ng-update/index.ts @@ -1,20 +1,11 @@ import { Rule } from '@angular-devkit/schematics'; -import { createUpgradeRule, TargetVersion, UpgradeTSLintConfig } from '@angular/cdk/schematics'; +import { createUpgradeRule, TargetVersion } from '@angular/cdk/schematics'; import chalk from 'chalk'; -import { sync as globSync } from 'glob'; import { materialUpgradeData } from './upgrade-data'; -const ruleDirectories = globSync('upgrade-rules/**/', { cwd: __dirname, absolute: true }); - -/** TSLint upgrade configuration that will be passed to the CDK ng-update rule. */ -const tslintUpgradeConfig: UpgradeTSLintConfig = { - upgradeData: materialUpgradeData, - extraRuleDirectories: ruleDirectories -}; - /** Entry point for the migration schematics with target of NG-ZORRO v7 */ export function updateToV7(): Rule { - return createUpgradeRule(TargetVersion.V7, tslintUpgradeConfig); + return createUpgradeRule(TargetVersion.V7, [], materialUpgradeData, postUpdate); } /** Post-update schematic to be called when update is finished. */ diff --git a/scripts/release/release.ts b/scripts/release/release.ts index e7b1514e32..8d777714de 100644 --- a/scripts/release/release.ts +++ b/scripts/release/release.ts @@ -106,11 +106,9 @@ function getRemoteUrl(remote: string): string { function bumpVersion(): void { log.info('Updating version number...'); - const appComponentPath = path.join(buildConfig.scriptsDir, 'site/_site/doc/app/app.component.ts'); - const codeBoxPath = path.join(buildConfig.scriptsDir, 'site/_site/doc/app/share/nz-codebox/stack-blitz.ts'); const packageJsonPath = path.join(buildConfig.componentsDir, 'package.json'); const packageJson = fs.readJsonSync(packageJsonPath); - const zorroVersionPath = path.join(buildConfig.componentsDir, 'version.ts'); + const zorroVersionPath = path.join(buildConfig.componentsDir, 'version', 'version.ts'); const currentVersion = packageJson.version; let versionNumberValid = false; let version; @@ -125,13 +123,6 @@ function bumpVersion(): void { } fs.writeJsonSync(packageJsonPath, {...packageJson, version: version}, {spaces: 2}); - fs.writeFileSync(appComponentPath, - fs.readFileSync(appComponentPath, 'utf-8') - .replace(/currentVersion = '.+';/g, `currentVersion = '${version}';`) - ); - fs.writeFileSync(codeBoxPath, - fs.readFileSync(codeBoxPath, 'utf-8').replace(/'ng-zorro-antd'\s*: '.+'/g, `'ng-zorro-antd': '^${version}'`) - ); fs.writeFileSync(zorroVersionPath, fs.readFileSync(zorroVersionPath, 'utf-8') .replace(/Version\('.+'\);/g, `Version('${version}');`) diff --git a/scripts/site/_site/doc/app/app.component.ts b/scripts/site/_site/doc/app/app.component.ts index 7992029c06..6bb3c0d4f9 100644 --- a/scripts/site/_site/doc/app/app.component.ts +++ b/scripts/site/_site/doc/app/app.component.ts @@ -2,7 +2,7 @@ import { Platform } from '@angular/cdk/platform'; import { AfterViewInit, Component, ElementRef, HostListener, NgZone, OnInit, ViewChild } from '@angular/core'; import { Title } from '@angular/platform-browser'; import { NavigationEnd, Router } from '@angular/router'; -import { en_US, zh_CN, NzI18nService, NzMessageService } from 'ng-zorro-antd'; +import { en_US, zh_CN, NzI18nService, NzMessageService, VERSION } from 'ng-zorro-antd'; import { fromEvent } from 'rxjs'; import { debounceTime, map, startWith } from 'rxjs/operators'; import { environment } from '../environments/environment'; @@ -45,7 +45,7 @@ export class AppComponent implements OnInit, AfterViewInit { language = 'zh'; oldVersionList = [ '0.5.x', '0.6.x', '0.7.x', '1.8.x', '7.5.x' ]; - currentVersion = '8.0.3'; + currentVersion = VERSION.full; @ViewChild('searchInput', { static: false }) searchInput: ElementRef; diff --git a/scripts/site/_site/doc/app/share/nz-codebox/nz-codebox.component.ts b/scripts/site/_site/doc/app/share/nz-codebox/nz-codebox.component.ts index def718b558..b9e68aa81a 100644 --- a/scripts/site/_site/doc/app/share/nz-codebox/nz-codebox.component.ts +++ b/scripts/site/_site/doc/app/share/nz-codebox/nz-codebox.component.ts @@ -16,7 +16,7 @@ import { takeUntil } from 'rxjs/operators'; import { environment } from '../../../environments/environment'; import { AppService } from '../../app.service'; import { stackBlitzConfiguration } from './stack-blitz'; - +import { VERSION } from 'ng-zorro-antd' @Component({ selector : 'nz-code-box', encapsulation : ViewEncapsulation.None, @@ -113,7 +113,7 @@ export class NzCodeBoxComponent implements OnInit, OnDestroy { } openOnStackBlitz() { - sdk.openProject(stackBlitzConfiguration(this.nzComponentName, this.nzRawCode, this.nzSelector)); + sdk.openProject(stackBlitzConfiguration(this.nzComponentName, this.nzRawCode, this.nzSelector, VERSION.full)); } check() { diff --git a/scripts/site/_site/doc/app/share/nz-codebox/stack-blitz.ts b/scripts/site/_site/doc/app/share/nz-codebox/stack-blitz.ts index c4fdcb1758..2daceba48e 100644 --- a/scripts/site/_site/doc/app/share/nz-codebox/stack-blitz.ts +++ b/scripts/site/_site/doc/app/share/nz-codebox/stack-blitz.ts @@ -1,4 +1,4 @@ -export const stackBlitzConfiguration = (componentName: string, appComponentCode: string, selector: string) => { +export const stackBlitzConfiguration = (componentName: string, appComponentCode: string, selector: string, version: string) => { const mainCode = `import './polyfills'; import { enableProdMode } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; @@ -258,7 +258,7 @@ export class AppModule { }`; '@angular/animations' : '^8.0.0', '@ant-design/icons-angular' : '^8.0.0', 'date-fns' : '^1.30.1', - 'ng-zorro-antd': '^8.0.3' + 'ng-zorro-antd': `^${version}` }, tags : [ 'stackblitz', 'sdk' ] }; diff --git a/scripts/site/generate-site.js b/scripts/site/generate-site.js index 5108ffa162..006cb8eed2 100644 --- a/scripts/site/generate-site.js +++ b/scripts/site/generate-site.js @@ -40,7 +40,7 @@ function generate(target) { } } const componentDirPath = path.join(rootPath, componentName); - if (componentName === 'style' || componentName === 'core' || componentName === 'locale' || componentName === 'i18n') { + if (componentName === 'style' || componentName === 'core' || componentName === 'locale' || componentName === 'i18n' || componentName === 'version') { return; } if (fs.statSync(componentDirPath).isDirectory()) { From 82099c79c4bdc2a95db930b5c7f69fff07ba78d9 Mon Sep 17 00:00:00 2001 From: Hsuan Lee Date: Wed, 17 Jul 2019 14:58:56 +0800 Subject: [PATCH 2/3] chore: fix lint --- .../_site/doc/app/share/nz-codebox/nz-codebox.component.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/site/_site/doc/app/share/nz-codebox/nz-codebox.component.ts b/scripts/site/_site/doc/app/share/nz-codebox/nz-codebox.component.ts index b9e68aa81a..ec8777a5e4 100644 --- a/scripts/site/_site/doc/app/share/nz-codebox/nz-codebox.component.ts +++ b/scripts/site/_site/doc/app/share/nz-codebox/nz-codebox.component.ts @@ -11,12 +11,13 @@ import { } from '@angular/core'; import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; import sdk from '@stackblitz/sdk'; +import { VERSION } from 'ng-zorro-antd' import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { environment } from '../../../environments/environment'; import { AppService } from '../../app.service'; import { stackBlitzConfiguration } from './stack-blitz'; -import { VERSION } from 'ng-zorro-antd' + @Component({ selector : 'nz-code-box', encapsulation : ViewEncapsulation.None, From 17e11c057a124068409253d3c453754d6de064b0 Mon Sep 17 00:00:00 2001 From: Hsuan Lee Date: Wed, 17 Jul 2019 16:41:51 +0800 Subject: [PATCH 3/3] docs(universal): fix docs Co-Authored-By: vthinkxie --- docs/universal.en-US.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/universal.en-US.md b/docs/universal.en-US.md index e9675308eb..c815e37aca 100644 --- a/docs/universal.en-US.md +++ b/docs/universal.en-US.md @@ -8,7 +8,7 @@ title: Server-side Rendering

You can also start your project with NG-ZORRO/ng-zorro-universal-starter.

-This guide is based on the popular [Express](https://expressjs.com/) framework.n +This guide is based on the popular [Express](https://expressjs.com/) framework. ## Installation dependence @@ -115,4 +115,4 @@ app.listen(PORT, () => { ```bash $ npm run build:ssr && npm run serve:ssr # Running http://localhost:4000/ -``` \ No newline at end of file +```