From f391b151a91e9b713323c820defaafcf49696b6c Mon Sep 17 00:00:00 2001 From: Trotyl Yu Date: Sun, 22 Jul 2018 12:03:35 +0800 Subject: [PATCH] build: use ng-packagr to generate library --- angular.json | 14 ++++ build.sh | 64 ------------------- build_scripts/generate-less.js | 2 +- build_scripts/migration-styles.js | 12 ++++ .../calendar/nz-calendar-header.component.ts | 2 +- components/calendar/nz-calendar.component.ts | 30 ++++----- components/core/util/index.ts | 1 + components/core/util/public-api.ts | 8 +++ .../date-picker/date-picker.component.spec.ts | 2 +- components/date-picker/demo/basic.ts | 2 +- components/date-picker/demo/disabled-date.ts | 4 +- .../date-picker/demo/presetted-ranges.ts | 2 +- .../date-picker/lib/candy-date/candy-date.ts | 12 ++-- .../month-picker.component.spec.ts | 2 +- .../range-picker.component.spec.ts | 4 +- components/i18n/nz-i18n.service.ts | 2 +- components/ng-package.json | 13 ++++ components/ng-zorro-antd.module.ts | 5 +- components/package.json | 36 +++++++++++ components/tsconfig.lib.json | 27 ++++++++ components/tsconfig.spec.json | 1 + docs/customize-theme.en-US.md | 4 +- docs/customize-theme.zh-CN.md | 4 +- docs/getting-started.zh-CN.md | 2 +- docs/schematics.en-US.md | 2 +- docs/schematics.zh-CN.md | 2 +- integration/webpack/package.json | 2 +- package.json | 46 ++++--------- publish_scripts/publish.js | 2 +- schematics/ng-add/index.ts | 2 +- schematics_script/set-theme.js | 2 +- schematics_script/set-version.js | 2 +- site_scripts/utils/generate-code-box.js | 2 +- tsconfig.json | 1 + 34 files changed, 173 insertions(+), 145 deletions(-) delete mode 100755 build.sh create mode 100644 build_scripts/migration-styles.js create mode 100644 components/core/util/index.ts create mode 100644 components/core/util/public-api.ts create mode 100644 components/ng-package.json create mode 100644 components/package.json create mode 100644 components/tsconfig.lib.json diff --git a/angular.json b/angular.json index 91e1b2ee49..db8bd77130 100644 --- a/angular.json +++ b/angular.json @@ -86,6 +86,20 @@ "root": "", "sourceRoot": "", "projectType": "application" + }, + "ng-zorro-antd-lib": { + "root": "components", + "projectType": "library", + "prefix": "nz", + "architect": { + "build": { + "builder": "@angular-devkit/build-ng-packagr:build", + "options": { + "tsConfig": "components/tsconfig.lib.json", + "project": "components/ng-package.json" + } + } + } } }, "defaultProject": "ng-zorro-antd-doc", diff --git a/build.sh b/build.sh deleted file mode 100755 index 5f9b3127f6..0000000000 --- a/build.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env bash - -readonly currentDir=$(cd $(dirname $0); pwd) -cd ${currentDir} -rm -rf publish -rm -rf __gen_components -rm -rf publish-es2015 -cp -r components __gen_components -node ./build_scripts/inline-template.js - -VERSION=$(node -p "require('./package.json').version") - -echo "Package Version: ${VERSION}" -perl -p -i -e "s/0\.0\.0\-PLACEHOLDER/${VERSION}/g" $(grep -ril 0\.0\.0\-PLACEHOLDER __gen_components) < /dev/null 2> /dev/null - -echo 'Compiling to es2015 via Angular compiler' -$(npm bin)/ngc -p tsconfig-build.json -t es2015 --outDir publish-es2015/src - -echo 'Bundling to es module of es2015' -export ROLLUP_TARGET=esm -$(npm bin)/rollup -c rollup.config.js -f es -i publish-es2015/src/index.js -o publish-es2015/esm2015/antd.js - -echo 'Compiling to es5 via Angular compiler' -$(npm bin)/ngc -p tsconfig-build.json -t es5 --outDir publish-es5/src - -echo 'Bundling to es module of es5' -export ROLLUP_TARGET=esm -$(npm bin)/rollup -c rollup.config.js -f es -i publish-es5/src/index.js -o publish-es5/esm5/antd.js - -echo 'Bundling to umd module of es5' -export ROLLUP_TARGET=umd -$(npm bin)/rollup -c rollup.config.js -f umd -i publish-es5/esm5/antd.js -o publish-es5/bundles/antd.umd.js - -echo 'Bundling to minified umd module of es5' -export ROLLUP_TARGET=mumd -$(npm bin)/rollup -c rollup.config.js -f umd -i publish-es5/esm5/antd.js -o publish-es5/bundles/antd.umd.min.js - -echo 'Unifying publish folder' -mv publish-es5 publish -mv publish-es2015/esm2015 publish/esm2015 -rm -rf publish-es2015 - -echo 'Cleaning up temporary files' -rm -rf __gen_components -rm -rf publish/src/*.js -rm -rf publish/src/**/*.js - -echo 'Normalizing entry files' -sed -e "s/from '.\//from '.\/src\//g" publish/src/index.d.ts > publish/antd.d.ts -sed -e "s/\":\".\//\":\".\/src\//g" publish/src/index.metadata.json > publish/antd.metadata.json -rm publish/src/index.d.ts publish/src/index.metadata.json - -echo 'Building schematics' -npm run schematic:demo -npm run schematic:build -rm -rf schematics/demo - -echo 'Copying package.json' -cp package.json publish/package.json - -echo 'Copying README.md' -cp README.md publish/README.md - -node ./build_scripts/generate-less.js \ No newline at end of file diff --git a/build_scripts/generate-less.js b/build_scripts/generate-less.js index ee9fa927e0..6039772659 100644 --- a/build_scripts/generate-less.js +++ b/build_scripts/generate-less.js @@ -21,7 +21,7 @@ function compileLess(content, savePath, min) { } const sourcePath = path.resolve(__dirname, '../components'); -const targetPath = path.resolve(__dirname, '../publish/src'); +const targetPath = path.resolve(__dirname, '../publish'); const targetFolder = fs.readdirSync(targetPath); let componentsLessContent = ''; diff --git a/build_scripts/migration-styles.js b/build_scripts/migration-styles.js new file mode 100644 index 0000000000..cd69bde4ae --- /dev/null +++ b/build_scripts/migration-styles.js @@ -0,0 +1,12 @@ +const fs = require('fs-extra'); +const path = require('path'); + +const sourcePath = path.resolve(__dirname, `../publish`); +const targetPath = path.resolve(__dirname, `../publish/src`); + +fs.mkdirsSync(targetPath); +fs.copySync(path.resolve(sourcePath, `style`), path.resolve(targetPath, `style`)); +fs.copySync(path.resolve(sourcePath, `ng-zorro-antd.css`), path.resolve(targetPath, `ng-zorro-antd.css`)); +fs.copySync(path.resolve(sourcePath, `ng-zorro-antd.min.css`), path.resolve(targetPath, `ng-zorro-antd.min.css`)); +fs.outputFileSync(path.resolve(targetPath, `ng-zorro-antd.less`), `@import "../style/index.less"; +@import "../components.less";`); diff --git a/components/calendar/nz-calendar-header.component.ts b/components/calendar/nz-calendar-header.component.ts index f2fc0f6a3e..7b2831bad6 100644 --- a/components/calendar/nz-calendar-header.component.ts +++ b/components/calendar/nz-calendar-header.component.ts @@ -1,5 +1,5 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import * as setMonth from 'date-fns/set_month'; +import setMonth from 'date-fns/set_month'; import { NzI18nService as I18n } from '../i18n/nz-i18n.service'; @Component({ diff --git a/components/calendar/nz-calendar.component.ts b/components/calendar/nz-calendar.component.ts index a2f86ab0e0..21d5827ab2 100644 --- a/components/calendar/nz-calendar.component.ts +++ b/components/calendar/nz-calendar.component.ts @@ -1,21 +1,21 @@ import { coerceBooleanProperty } from '@angular/cdk/coercion'; import { forwardRef, Component, ContentChild, EventEmitter, HostBinding, Input, OnInit, Output, TemplateRef } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; -import * as addDays from 'date-fns/add_days'; -import * as differenceInCalendarDays from 'date-fns/difference_in_calendar_days'; -import * as differenceInCalendarMonths from 'date-fns/difference_in_calendar_months'; -import * as differenceInCalendarWeeks from 'date-fns/difference_in_calendar_weeks'; -import * as endOfMonth from 'date-fns/end_of_month'; -import * as isSameDay from 'date-fns/is_same_day'; -import * as isSameMonth from 'date-fns/is_same_month'; -import * as isSameYear from 'date-fns/is_same_year'; -import * as isThisMonth from 'date-fns/is_this_month'; -import * as isThisYear from 'date-fns/is_this_year'; -import * as setMonth from 'date-fns/set_month'; -import * as setYear from 'date-fns/set_year'; -import * as startOfMonth from 'date-fns/start_of_month'; -import * as startOfWeek from 'date-fns/start_of_week'; -import * as startOfYear from 'date-fns/start_of_year'; +import addDays from 'date-fns/add_days'; +import differenceInCalendarDays from 'date-fns/difference_in_calendar_days'; +import differenceInCalendarMonths from 'date-fns/difference_in_calendar_months'; +import differenceInCalendarWeeks from 'date-fns/difference_in_calendar_weeks'; +import endOfMonth from 'date-fns/end_of_month'; +import isSameDay from 'date-fns/is_same_day'; +import isSameMonth from 'date-fns/is_same_month'; +import isSameYear from 'date-fns/is_same_year'; +import isThisMonth from 'date-fns/is_this_month'; +import isThisYear from 'date-fns/is_this_year'; +import setMonth from 'date-fns/set_month'; +import setYear from 'date-fns/set_year'; +import startOfMonth from 'date-fns/start_of_month'; +import startOfWeek from 'date-fns/start_of_week'; +import startOfYear from 'date-fns/start_of_year'; import { NzI18nService as I18n } from '../i18n/nz-i18n.service'; import { NzDateCellDirective as DateCell, NzDateFullCellDirective as DateFullCell, NzMonthCellDirective as MonthCell, NzMonthFullCellDirective as MonthFullCell } from './nz-calendar-cells'; diff --git a/components/core/util/index.ts b/components/core/util/index.ts new file mode 100644 index 0000000000..7e1a213e3e --- /dev/null +++ b/components/core/util/index.ts @@ -0,0 +1 @@ +export * from './public-api'; diff --git a/components/core/util/public-api.ts b/components/core/util/public-api.ts new file mode 100644 index 0000000000..3406c31f85 --- /dev/null +++ b/components/core/util/public-api.ts @@ -0,0 +1,8 @@ +export * from './calculate-node-height'; +export * from './check'; +export * from './convert'; +export * from './getMentions'; +export * from './keycodes'; +export * from './nz-global-monitor'; +export * from './textarea-caret-position'; +export * from './throttleByAnimationFrame'; diff --git a/components/date-picker/date-picker.component.spec.ts b/components/date-picker/date-picker.component.spec.ts index 024a091b84..fcf224bc11 100644 --- a/components/date-picker/date-picker.component.spec.ts +++ b/components/date-picker/date-picker.component.spec.ts @@ -7,7 +7,7 @@ import { fakeAsync, flush, inject, tick, ComponentFixture, TestBed } from '@angu import { FormsModule } from '@angular/forms'; import { By } from '@angular/platform-browser'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import * as isSameDay from 'date-fns/is_same_day'; +import isSameDay from 'date-fns/is_same_day'; import { dispatchKeyboardEvent, dispatchMouseEvent } from '../core/testing'; import en_US from '../i18n/languages/en_US'; diff --git a/components/date-picker/demo/basic.ts b/components/date-picker/demo/basic.ts index 527f66195d..07db530d75 100644 --- a/components/date-picker/demo/basic.ts +++ b/components/date-picker/demo/basic.ts @@ -1,5 +1,5 @@ import { Component } from '@angular/core'; -import * as getISOWeek from 'date-fns/get_iso_week'; +import getISOWeek from 'date-fns/get_iso_week'; import { en_US, zh_CN, NzI18nService } from 'ng-zorro-antd'; @Component({ diff --git a/components/date-picker/demo/disabled-date.ts b/components/date-picker/demo/disabled-date.ts index 5174ce40b4..af02a65fe9 100644 --- a/components/date-picker/demo/disabled-date.ts +++ b/components/date-picker/demo/disabled-date.ts @@ -1,6 +1,6 @@ import { Component } from '@angular/core'; -import * as differenceInCalendarDays from 'date-fns/difference_in_calendar_days'; -import * as setHours from 'date-fns/set_hours'; +import differenceInCalendarDays from 'date-fns/difference_in_calendar_days'; +import setHours from 'date-fns/set_hours'; @Component({ selector: 'nz-demo-date-picker-disabled-date', diff --git a/components/date-picker/demo/presetted-ranges.ts b/components/date-picker/demo/presetted-ranges.ts index c691a508c4..d7dee93aa2 100644 --- a/components/date-picker/demo/presetted-ranges.ts +++ b/components/date-picker/demo/presetted-ranges.ts @@ -1,5 +1,5 @@ import { Component } from '@angular/core'; -import * as endOfMonth from 'date-fns/end_of_month'; +import endOfMonth from 'date-fns/end_of_month'; @Component({ selector: 'nz-demo-date-picker-presetted-ranges', diff --git a/components/date-picker/lib/candy-date/candy-date.ts b/components/date-picker/lib/candy-date/candy-date.ts index ca16ad2506..ed4eb057b0 100644 --- a/components/date-picker/lib/candy-date/candy-date.ts +++ b/components/date-picker/lib/candy-date/candy-date.ts @@ -1,9 +1,9 @@ -import * as addMonths from 'date-fns/add_months'; -import * as addYears from 'date-fns/add_years'; -import * as endOfMonth from 'date-fns/end_of_month'; -import * as setDay from 'date-fns/set_day'; -import * as setMonth from 'date-fns/set_month'; -// import * as setYear from 'date-fns/set_year'; +import addMonths from 'date-fns/add_months'; +import addYears from 'date-fns/add_years'; +import endOfMonth from 'date-fns/end_of_month'; +import setDay from 'date-fns/set_day'; +import setMonth from 'date-fns/set_month'; +// import setYear from 'date-fns/set_year'; import { firstDayOfWeek } from './util'; /** diff --git a/components/date-picker/month-picker.component.spec.ts b/components/date-picker/month-picker.component.spec.ts index 19391e8e5d..373b81260a 100644 --- a/components/date-picker/month-picker.component.spec.ts +++ b/components/date-picker/month-picker.component.spec.ts @@ -7,7 +7,7 @@ import { FormsModule } from '@angular/forms'; import { By } from '@angular/platform-browser'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import * as isBefore from 'date-fns/is_before'; +import isBefore from 'date-fns/is_before'; import { dispatchMouseEvent } from '../core/testing'; import { NzDatePickerModule } from './date-picker.module'; import { CandyDate } from './lib/candy-date'; diff --git a/components/date-picker/range-picker.component.spec.ts b/components/date-picker/range-picker.component.spec.ts index b780f08222..c97f04feb3 100644 --- a/components/date-picker/range-picker.component.spec.ts +++ b/components/date-picker/range-picker.component.spec.ts @@ -6,8 +6,8 @@ import { fakeAsync, inject, tick, ComponentFixture, TestBed } from '@angular/cor import { FormsModule } from '@angular/forms'; import { By } from '@angular/platform-browser'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import * as differenceInDays from 'date-fns/difference_in_days'; -import * as isSameDay from 'date-fns/is_same_day'; +import differenceInDays from 'date-fns/difference_in_days'; +import isSameDay from 'date-fns/is_same_day'; import { dispatchMouseEvent } from '../core/testing'; import { NzDatePickerModule } from './date-picker.module'; diff --git a/components/i18n/nz-i18n.service.ts b/components/i18n/nz-i18n.service.ts index 3d11af2743..8600943f45 100644 --- a/components/i18n/nz-i18n.service.ts +++ b/components/i18n/nz-i18n.service.ts @@ -4,7 +4,7 @@ import { BehaviorSubject, Observable } from 'rxjs'; import { LoggerService } from '../core/util/logger/logger.service'; -import * as parse from 'date-fns/parse'; +import parse from 'date-fns/parse'; import zh_CN from './languages/zh_CN'; import { NzI18nInterface } from './nz-i18n.interface'; diff --git a/components/ng-package.json b/components/ng-package.json new file mode 100644 index 0000000000..8336e7acc5 --- /dev/null +++ b/components/ng-package.json @@ -0,0 +1,13 @@ +{ + "$schema": "../node_modules/ng-packagr/ng-package.schema.json", + "dest": "../publish", + "deleteDestPath": true, + "lib": { + "entryFile": "ng-zorro-antd.module.ts" + }, + "whitelistedNonPeerDependencies": [ + "tslib", + "angular", + "date-fns" + ] +} diff --git a/components/ng-zorro-antd.module.ts b/components/ng-zorro-antd.module.ts index 1dfc0261bc..a1e97ee504 100644 --- a/components/ng-zorro-antd.module.ts +++ b/components/ng-zorro-antd.module.ts @@ -14,6 +14,7 @@ import { NzCarouselModule } from './carousel/nz-carousel.module'; import { NzCascaderModule } from './cascader/nz-cascader.module'; import { NzCheckboxModule } from './checkbox/nz-checkbox.module'; import { NzCollapseModule } from './collapse/nz-collapse.module'; +import { NzWaveModule } from './core/wave/nz-wave.module'; import { NzDatePickerModule } from './date-picker/date-picker.module'; import { NzDividerModule } from './divider/nz-divider.module'; import { NzDrawerModule } from './drawer/nz-drawer.module'; @@ -52,7 +53,6 @@ import { NzTransferModule } from './transfer/nz-transfer.module'; import { NzTreeSelectModule } from './tree-select/nz-tree-select.module'; import { NzTreeModule } from './tree/nz-tree.module'; import { NzUploadModule } from './upload/nz-upload.module'; -import { NzWaveModule } from './core/wave/nz-wave.module'; export * from './affix'; export * from './alert'; @@ -70,6 +70,7 @@ export * from './collapse'; export * from './date-picker'; export * from './divider'; export * from './dropdown'; +export * from './drawer'; export * from './form'; export * from './grid'; export * from './i18n'; @@ -109,6 +110,7 @@ export * from './tree-select'; export * from './time-picker'; export * from './version'; export * from './core/wave'; +export * from './core/util'; @NgModule({ exports: [ @@ -140,7 +142,6 @@ export * from './core/wave'; NzCardModule, NzAvatarModule, NzTimelineModule, - NzTimePickerModule, NzTransferModule, NzCarouselModule, NzCollapseModule, diff --git a/components/package.json b/components/package.json new file mode 100644 index 0000000000..f4bb0add24 --- /dev/null +++ b/components/package.json @@ -0,0 +1,36 @@ +{ + "name": "ng-zorro-antd", + "version": "1.5.0", + "license": "MIT", + "description": "An enterprise-class UI components based on Ant Design and Angular", + "schematics": "./schematics/collection.json", + "keywords": [ + "ant", + "design", + "angular", + "ui", + "framework", + "frontend" + ], + "homepage": "https://ng.ant.design", + "repository": { + "type": "git", + "url": "https://github.com/NG-ZORRO/ng-zorro-antd" + }, + "bugs": { + "url": "https://github.com/NG-ZORRO/ng-zorro-antd/issues" + }, + "dependencies": { + "date-fns": "^1.29.0", + "@angular/cdk": "^6.0.0" + }, + "peerDependencies": { + "@angular/animations": "^6.0.0", + "@angular/cdk": "^6.0.0", + "@angular/common": "^6.0.0", + "@angular/core": "^6.0.0", + "@angular/forms": "^6.0.0", + "tslib": "^1.9.0", + "typescript": "~2.9.2" + } +} diff --git a/components/tsconfig.lib.json b/components/tsconfig.lib.json new file mode 100644 index 0000000000..ca6c65fea1 --- /dev/null +++ b/components/tsconfig.lib.json @@ -0,0 +1,27 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "baseUrl": "./", + "target": "es2015", + "module": "es2015", + "sourceMap": true, + "inlineSources": true, + "moduleResolution": "node", + "importHelpers": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "declaration": true, + "outDir": "../release", + "lib": ["es2015", "dom"] + }, + "angularCompilerOptions": { + "annotateForClosureCompiler": true, + "skipTemplateCodegen": true, + "strictMetadataEmit": true, + "fullTemplateTypeCheck": false, + "strictInjectionParameters": true, + "enableResourceInlining": true, + "flatModuleId": "AUTOGENERATED", + "flatModuleOutFile": "AUTOGENERATED" + } +} diff --git a/components/tsconfig.spec.json b/components/tsconfig.spec.json index bc16455f6d..4477ed77cd 100644 --- a/components/tsconfig.spec.json +++ b/components/tsconfig.spec.json @@ -4,6 +4,7 @@ "outDir": "../out-tsc/spec", "baseUrl": "./", "module": "commonjs", + "esModuleInterop": true, "target": "es5", "types": [ "jasmine", diff --git a/docs/customize-theme.en-US.md b/docs/customize-theme.en-US.md index 72b77fb1a3..ae4091595c 100644 --- a/docs/customize-theme.en-US.md +++ b/docs/customize-theme.en-US.md @@ -40,7 +40,7 @@ Here is an example of `theme.less` ```css // -------- import official less file ----------- -@import "../node_modules/ng-zorro-antd/src/ng-zorro-antd.less"; +@import "../node_modules/ng-zorro-antd/ng-zorro-antd.less"; // -------- override less var ----------- @primary-color : #f5222d; @@ -57,7 +57,7 @@ Here is an example set icon url to the folder `assets/fonts` ```css // -------- import official less file ----------- -@import "../node_modules/ng-zorro-antd/src/ng-zorro-antd.less"; +@import "../node_modules/ng-zorro-antd/ng-zorro-antd.less"; // -------- override less var ----------- @icon-url : "/assets/fonts/iconfont"; diff --git a/docs/customize-theme.zh-CN.md b/docs/customize-theme.zh-CN.md index bbfd13bc5f..87f53d537f 100644 --- a/docs/customize-theme.zh-CN.md +++ b/docs/customize-theme.zh-CN.md @@ -40,7 +40,7 @@ Ant Design 的样式使用了 [Less](http://lesscss.org/) 作为开发语言, ```css // -------- 引入官方提供的 less 样式入口文件 ----------- -@import "../node_modules/ng-zorro-antd/src/ng-zorro-antd.less"; +@import "../node_modules/ng-zorro-antd/ng-zorro-antd.less"; // -------- 自定义参数覆盖 ----------- @primary-color : #f5222d; @@ -56,7 +56,7 @@ Ant Design 的样式使用了 [Less](http://lesscss.org/) 作为开发语言, ```css // -------- 引入官方提供的 less 样式入口文件 ----------- -@import "../node_modules/ng-zorro-antd/src/ng-zorro-antd.less"; +@import "../node_modules/ng-zorro-antd/ng-zorro-antd.less"; // -------- 自定义参数覆盖 ----------- @icon-url : "/assets/fonts/iconfont"; diff --git a/docs/getting-started.zh-CN.md b/docs/getting-started.zh-CN.md index 420c4ff222..ce11df891d 100755 --- a/docs/getting-started.zh-CN.md +++ b/docs/getting-started.zh-CN.md @@ -116,7 +116,7 @@ export class AppModule { } ### 3. 引入样式 -在全局样式中引入 `node_modules/ng-zorro-antd/src/ng-zorro-antd.min.css` 文件。如果需要自定义主题样式,请参考[自定义主题](/docs/customize-theme/zh)部分。 +在全局样式中引入 `node_modules/ng-zorro-antd/ng-zorro-antd.min.css` 文件。如果需要自定义主题样式,请参考[自定义主题](/docs/customize-theme/zh)部分。 ## 配置主题和字体 diff --git a/docs/schematics.en-US.md b/docs/schematics.en-US.md index 10d21c5ea2..a3b6854741 100644 --- a/docs/schematics.en-US.md +++ b/docs/schematics.en-US.md @@ -41,7 +41,7 @@ ng g ng-zorro-antd:[template] --name=NAME [options] For example, you can generate an login form with the follow command. ```bash -ng g ng-zorro-antd:form-normal-login -p app --styleext='less' --name=login +ng g ng-zorro-antd:form-normal-login -p app --styleext=less --name=login ``` ### Options diff --git a/docs/schematics.zh-CN.md b/docs/schematics.zh-CN.md index e4b1627184..96fe18f53f 100644 --- a/docs/schematics.zh-CN.md +++ b/docs/schematics.zh-CN.md @@ -42,7 +42,7 @@ ng g ng-zorro-antd:[template] --name=NAME [options] 例如通过以下代码可以快速生成一个登陆框组件 ```bash -ng g ng-zorro-antd:form-normal-login -p app --styleext='less' --name=login +ng g ng-zorro-antd:form-normal-login -p app --styleext=less --name=login ``` ### 生成组件参数 diff --git a/integration/webpack/package.json b/integration/webpack/package.json index a2d3e3bab6..6781c8f165 100644 --- a/integration/webpack/package.json +++ b/integration/webpack/package.json @@ -31,7 +31,7 @@ "zone.js": "file:lib/zone.js" }, "devDependencies": { - "@angular-devkit/build-optimizer": "0.0.18", + "@angular-devkit/build-optimizer": "0.6.8", "@angular/cli": "file:lib/@angular/cli", "@angular/compiler-cli": "file:lib/@angular/compiler-cli", "@ngtools/webpack": "^1.6.2", diff --git a/package.json b/package.json index 7ebbc65dd6..6334877e7d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "ng-zorro-antd", - "version": "1.5.0", + "name": "ng-zorro-antd-workspace", + "version": "0.0.0-NOT-USED", "license": "MIT", "description": "An enterprise-class UI components based on Ant Design and Angular", "scripts": { @@ -10,12 +10,15 @@ "schematic:demo": "node schematics_script/demo2schematics", "schematic:tsc": "tsc -p schematics/tsconfig.json", "schematic:build": "node ./schematics_script/set-theme.js && node ./schematics_script/set-version.js && npm run schematic:tsc && node schematics_script/copy-resources", + "schematic:generate": "npm run schematic:demo && npm run schematic:build && rm -rf schematics/demo", "ng": "ng", "start": "ng serve -port 0", "build": "node site_scripts/generate-site init && ng build", "doc": "npm run site:init && node --max_old_space_size=5120 ./node_modules/@angular/cli/bin/ng build --prod --build-optimizer", "helper": "bash ./release-helper.sh", - "generate": "bash ./build.sh", + "migration-styles": "node build_scripts/migration-styles.js", + "generate": "ng build ng-zorro-antd-lib", + "postgenerate": "node ./build_scripts/generate-less.js && cp README.md publish/README.md && npm run migration-styles && npm run schematic:generate", "pre-release": "npm run site:init && bash ./build_scripts/replace-publish.sh && npm run generate && node --max_old_space_size=5120 ./node_modules/@angular/cli/bin/ng build --prod && npm run helper", "test": "ng test --watch=false --code-coverage", "integration": "npm run generate && bash ./integration-test.sh", @@ -23,29 +26,8 @@ "integration-webpack": "npm run generate && cd integration/webpack && npm run integration", "integration-rollup": "npm run generate && cd integration/rollup && npm run integration", "lint": "tslint -c tslint.json 'components/*/*.ts'", - "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s && node site_scripts/replace-scope-prefix.js", - "release": "node ./publish_scripts/publish.js" - }, - "main": "./bundles/antd.umd.js", - "module": "./esm5/antd.js", - "es2015": "./esm2015/antd.js", - "typings": "./antd.d.ts", - "schematics": "./schematics/collection.json", - "keywords": [ - "ant", - "design", - "angular", - "ui", - "framework", - "frontend" - ], - "homepage": "https://ng.ant.design", - "repository": { - "type": "git", - "url": "https://github.com/NG-ZORRO/ng-zorro-antd" - }, - "bugs": { - "url": "https://github.com/NG-ZORRO/ng-zorro-antd/issues" + "release": "node ./publish_scripts/publish.js", + "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --pkg components/package.json && node site_scripts/replace-scope-prefix.js" }, "dependencies": { "@angular/cdk": "^6.0.0", @@ -72,6 +54,7 @@ "ts-node": "~7.0.0", "tslint": "~5.11.0", "typescript": "~2.9.2", + "@angular-devkit/build-ng-packagr": "^0.6.8", "@angular-devkit/core": "^0.6.0", "@angular-devkit/schematics": "^0.6.0", "@angular/animations": "^6.0.0", @@ -97,6 +80,7 @@ "less": "^2.7.3", "less-plugin-clean-css": "^1.5.1", "marked": "^0.3.6", + "ng-packagr": "^4.0.0", "ngx-color": "^1.5.2", "ngx-infinite-scroll": "^6.0.0", "node-prismjs": "^0.1.1", @@ -109,16 +93,10 @@ "rollup-plugin-replace": "^2.0.0", "rollup-plugin-sourcemaps": "^0.4.2", "rollup-plugin-uglify": "^2.0.1", - "rxjs": "^6.0.0", + "rxjs": "~6.2.2", + "tsickle": "^0.30.0", "tslib": "^1.9.0", "yaml-front-matter": "^3.4.0", "zone.js": "^0.8.26" - }, - "peerDependencies": { - "@angular/animations": "^6.0.0", - "@angular/cdk": "^6.0.0", - "@angular/common": "^6.0.0", - "@angular/core": "^6.0.0", - "@angular/forms": "^6.0.0" } } diff --git a/publish_scripts/publish.js b/publish_scripts/publish.js index f42bf44ecc..3b16e2ab4c 100644 --- a/publish_scripts/publish.js +++ b/publish_scripts/publish.js @@ -41,7 +41,7 @@ checkout(); function changeVersion() { log.info('Updating version number...'); - const packageJson = path.join(__dirname, '../package.json'); + const packageJson = path.join(__dirname, '../components/package.json'); const appComponent = path.join(__dirname, '../site_scripts/_site/src/app/app.component.ts') ; const codeBox = path.join(__dirname, '../site_scripts/_site/src/app/share/nz-codebox/nz-codebox.component.ts'); const currentVersion = fs.readFileSync(packageJson, 'utf-8').match(/"version": "([0-9.]+)"/)[ 1 ]; diff --git a/schematics/ng-add/index.ts b/schematics/ng-add/index.ts index 36e0e5b901..d6ecd8d8fc 100644 --- a/schematics/ng-add/index.ts +++ b/schematics/ng-add/index.ts @@ -21,7 +21,7 @@ import { Schema } from './schema'; const ADD_CONFIG = { LESS_VERSION: '^2.7.3', CUSTOM_THEME_PATH: 'src/theme.less', - COMPILED_THEME_PATH: 'node_modules/ng-zorro-antd/src/ng-zorro-antd.min.css', + COMPILED_THEME_PATH: 'node_modules/ng-zorro-antd/ng-zorro-antd.min.css', BOOT_PAGE_PATH: 'src/app/app.component.html', BOOT_PAGE_HTML: ` diff --git a/schematics_script/set-theme.js b/schematics_script/set-theme.js index c6b84688b4..1383dbb9e8 100644 --- a/schematics_script/set-theme.js +++ b/schematics_script/set-theme.js @@ -5,7 +5,7 @@ const theme = fs.readFileSync(path.resolve(__dirname, `../site_scripts/_site/src fs.outputFileSync( path.resolve(__dirname, `../schematics/utils/custom-theme.ts`), `export function createCustomTheme() { - return \`@import "../node_modules/ng-zorro-antd/src/ng-zorro-antd.less"; + return \`@import "../node_modules/ng-zorro-antd/ng-zorro-antd.less"; ${theme.replace(/`/g, '\\`')} \`; } diff --git a/schematics_script/set-version.js b/schematics_script/set-version.js index 9bf0e34528..20dacdab8b 100644 --- a/schematics_script/set-version.js +++ b/schematics_script/set-version.js @@ -1,7 +1,7 @@ const fs = require('fs-extra'); const path = require('path'); -const packageJson = fs.readJsonSync(path.resolve(__dirname, `../package.json`)); +const packageJson = fs.readJsonSync(path.resolve(__dirname, `../components/package.json`)); fs.outputFileSync( path.resolve(__dirname, `../schematics/utils/lib-versions.ts`), `export const zorroVersion = '^${packageJson.version}';\n` diff --git a/site_scripts/utils/generate-code-box.js b/site_scripts/utils/generate-code-box.js index 8b6f75bbde..83603e798d 100644 --- a/site_scripts/utils/generate-code-box.js +++ b/site_scripts/utils/generate-code-box.js @@ -29,6 +29,6 @@ module.exports = function generateCodeBox(component, key, title, doc, iframe) { } output = output.replace(/{{code}}/g, camelCase(key)); output = output.replace(/{{rawCode}}/g, `${camelCase(key)}Raw`); - output = output.replace(/{{nzGenerateCommand}}/g, `ng g ng-zorro-antd:${component}-${key} -p app --styleext='less' --name=`); + output = output.replace(/{{nzGenerateCommand}}/g, `ng g ng-zorro-antd:${component}-${key} -p app --name=`); return output; }; diff --git a/tsconfig.json b/tsconfig.json index a6c016bf38..77f72238ae 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,7 @@ "sourceMap": true, "declaration": false, "moduleResolution": "node", + "allowSyntheticDefaultImports": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es5",