diff --git a/.angular-cli.json b/.angular-cli.json new file mode 100644 index 00000000000..594ff46ff88 --- /dev/null +++ b/.angular-cli.json @@ -0,0 +1,61 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "project": { + "name": "ng-zorro-antd-doc" + }, + "apps": [ + { + "root": "./site/src", + "outDir": "dist", + "assets": [ + "assets", + "favicon.ico", + "404.html" + ], + "index": "index.html", + "main": "main.ts", + "polyfills": "polyfills.ts", + "test": "../../components/test.ts", + "tsconfig": "tsconfig.app.json", + "testTsconfig": "../../components/tsconfig.spec.json", + "prefix": "app", + "styles": [ + "styles.less" + ], + "scripts": [], + "environmentSource": "environments/environment.ts", + "environments": { + "dev": "environments/environment.ts", + "prod": "environments/environment.prod.ts" + } + } + ], + "e2e": { + "protractor": { + "config": "./protractor.conf.js" + } + }, + "lint": [ + { + "project": "src/tsconfig.app.json", + "exclude": "**/node_modules/**" + }, + { + "project": "src/tsconfig.spec.json", + "exclude": "**/node_modules/**" + }, + { + "project": "e2e/tsconfig.e2e.json", + "exclude": "**/node_modules/**" + } + ], + "test": { + "karma": { + "config": "./components/karma.conf.js" + } + }, + "defaults": { + "styleExt": "less", + "component": {} + } +} diff --git a/README.md b/README.md index 4af59d75dfc..85279734a07 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,25 @@ 目前文档系统处于基本可用状态,依次执行 * git clone -b 0.7.0 https://github.com/NG-ZORRO/ng-zorro-antd.git ng-zorro-antd-0.7.0 * cd ng-zorro-antd-0.7.0 -* npm install -* npm run site:init (阿里内部运行 npm run site:init-tnpm) -* cd site +* npm i +* npm run site:init (初始化文档站点) * ng serve 即可看到目前的doc及相关组件的开发进度 +## 调试 + +运行 `ng serve` 可以直接修改 `./components` 会立即更新。 + +> (待开发)若修改DEMO代码,需要额外运行一次 `node scripts/generate-site button` 表示重新生成 button 所有DEMO代码。 + +## 测试代码 + +运行 `ng test`。 + +**加速度** + +默认会执行 `./components` 下所有 `*.spec.ts`,可手动调整 `./components/test.ts` 文件的临时针对某个测试文件,提升测试体验。 + # 开发 ## 文件夹结构 进入 components 文件夹,每个组件会有一个单独的文件夹,其中包括 diff --git a/components/test.ts b/components/test.ts index cd612eeb0e2..587aec6035d 100644 --- a/components/test.ts +++ b/components/test.ts @@ -26,6 +26,7 @@ getTestBed().initTestEnvironment( ); // Then we find all the tests. const context = require.context('./', true, /\.spec\.ts$/); +// const context = require.context('./', true, /nz-affix\.component\.spec\.ts$/); // And load the modules. context.keys().map(context); // Finally, start Karma to run the tests. diff --git a/package.json b/package.json index 678af61e65a..cad23d56e39 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,7 @@ "license": "MIT", "description": "An enterprise-class UI components based on Ant Design and Angular", "scripts": { - "site:init": "node scripts/generate-site init && cd site && npm i && cp -R ../components node_modules/ng-zorro-antd", - "site:init-tnpm": "node scripts/generate-site init && cd site && tnpm install --by=npm && cp -R ../components node_modules/ng-zorro-antd", + "site:init": "node scripts/generate-site init", "site": "node scripts/generate-site", "ng": "ng", "start": "ng serve", diff --git a/scripts/_site/src/app/_demo/demo.component.ts b/scripts/_site/src/app/_demo/demo.component.ts new file mode 100644 index 00000000000..0d0a448ea8c --- /dev/null +++ b/scripts/_site/src/app/_demo/demo.component.ts @@ -0,0 +1,12 @@ +/** + * TIPS:单纯为了开发过程方便调整DEMO示例代码 + */ +import { Component } from '@angular/core'; + +@Component({ + selector: 'nz-demo-COMPONENTNAME-basic', + template: `` +}) +export class DEMOComponent { + +} diff --git a/scripts/_site/src/app/app.module.ts b/scripts/_site/src/app/app.module.ts index f07c535ec74..47cebaa431a 100644 --- a/scripts/_site/src/app/app.module.ts +++ b/scripts/_site/src/app/app.module.ts @@ -8,6 +8,7 @@ import { NgZorroAntdModule } from 'ng-zorro-antd'; import { AppComponent } from './app.component'; +import { DEMOComponent } from './_demo/demo.component'; import { routes } from './app.routing.module'; import { environment } from '../environments/environment'; import { NzCodeBoxModule } from './share/nz-codebox/nz-codebox.module'; @@ -16,7 +17,7 @@ import { NzNavBottomModule } from './share/nz-nav-bottom/nz-nav-bottom.module'; @NgModule({ declarations: [ - AppComponent, + AppComponent, DEMOComponent ], imports : [ BrowserModule, diff --git a/scripts/_site/src/app/app.routing.module.ts b/scripts/_site/src/app/app.routing.module.ts index 01bf336c0eb..bb7c73b5b64 100644 --- a/scripts/_site/src/app/app.routing.module.ts +++ b/scripts/_site/src/app/app.routing.module.ts @@ -1,9 +1,11 @@ import { Routes } from '@angular/router'; import { DEMO_ROUTES } from './router'; +import { DEMOComponent } from './_demo/demo.component'; export const routes: Routes = [ { path: '', pathMatch: 'full', redirectTo: '/docs/introduce/zh' }, ...DEMO_ROUTES, { 'path': 'docs', 'loadChildren': './docs/index.module#NzDocsModule' }, + { path: 'demo', component: DEMOComponent }, { path: '**', redirectTo: '/docs/introduce/zh', pathMatch: 'full' } ]; diff --git a/scripts/_site/src/styles.less b/scripts/_site/src/styles.less index ab9c1b5cd2e..03020596c7f 100644 --- a/scripts/_site/src/styles.less +++ b/scripts/_site/src/styles.less @@ -1,5 +1,5 @@ /* You can add global styles to this file, and also import other style files */ @import "./theme"; -@import "~ng-zorro-antd/index.less"; +@import "../../components/index.less"; @import "./style/index"; diff --git a/scripts/_site/src/tsconfig.app.json b/scripts/_site/src/tsconfig.app.json index f82df49b807..bd86950eb68 100644 --- a/scripts/_site/src/tsconfig.app.json +++ b/scripts/_site/src/tsconfig.app.json @@ -6,14 +6,16 @@ "module": "es2015", "types": [ "node" - ] + ], + "paths": { + "ng-zorro-antd": [ "../../components" ] + } }, "exclude": [ "test.ts", "**/*.spec.ts" ], "include": [ - "../node_modules/ng-zorro-antd/index.ts", "../src/**/*" ] } diff --git a/scripts/_site/src/tsconfig.spec.json b/scripts/_site/src/tsconfig.spec.json index 63d89ff283f..d22c1587d04 100644 --- a/scripts/_site/src/tsconfig.spec.json +++ b/scripts/_site/src/tsconfig.spec.json @@ -8,7 +8,10 @@ "types": [ "jasmine", "node" - ] + ], + "paths": { + "ng-zorro-antd": [ "../../components" ] + } }, "files": [ "test.ts" diff --git a/scripts/generate-site.js b/scripts/generate-site.js index 60297a3e22b..3c3945be0b5 100644 --- a/scripts/generate-site.js +++ b/scripts/generate-site.js @@ -20,8 +20,8 @@ if (status === 'init') { } else { wrench.rmdirSyncRecursive(`${showCasePath}/src`, true); wrench.copyDirSyncRecursive(path.resolve(__dirname, '_site/src'), `${showCasePath}/src`); - wrench.rmdirSyncRecursive(`${showCasePath}/node_modules/ng-zorro-antd`, true); - wrench.copyDirSyncRecursive(path.resolve(__dirname, '../components'), `${showCasePath}/node_modules/ng-zorro-antd`); + // wrench.rmdirSyncRecursive(`${showCasePath}/node_modules/ng-zorro-antd`, true); + // wrench.copyDirSyncRecursive(path.resolve(__dirname, '../components'), `${showCasePath}/node_modules/ng-zorro-antd`); } const showCaseTargetPath = `${showCasePath}/src/app/`; @@ -92,4 +92,4 @@ docsDir.forEach(doc => { generateDocs(showCaseTargetPath, docsMap); -generateRoutes(showCaseTargetPath, componentsMap, docsMeta); \ No newline at end of file +generateRoutes(showCaseTargetPath, componentsMap, docsMeta);