Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(schematics): fix duplcated alias t in tpl command #231

Merged
merged 7 commits into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,9 @@ import { ACLService } from '@delon/acl';<% if (i18n) { %>
import { TranslateService } from '@ngx-translate/core';
import { I18NService } from '../i18n/i18n.service';<% } %>

// #region static loading icons
// @see http://ng.ant.design/components/icon/zh#%E9%9D%99%E6%80%81%E5%8A%A0%E8%BD%BD%E4%B8%8E%E5%8A%A8%E6%80%81%E5%8A%A0%E8%BD%BD

import { NzIconService } from 'ng-zorro-antd';
import {} from '@ant-design/icons-angular/icons';

const ICONS = [];

// #endregion
import { ICONS_AUTO } from '../../../style-icons-auto';
import { ICONS } from '../../../style-icons';

/**
* 用于应用启动时
Expand All @@ -37,7 +31,7 @@ export class StartupService {
private httpClient: HttpClient,
private injector: Injector
) {
iconSrv.addIcon(...ICONS);
iconSrv.addIcon(...ICONS_AUTO, ...ICONS);
}

private viaHttp(resolve: any, reject: any) {
Expand Down
70 changes: 0 additions & 70 deletions packages/schematics/curd/schema.d.ts

This file was deleted.

29 changes: 22 additions & 7 deletions packages/schematics/curd/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,40 @@
"format": "html-selector",
"description": "The selector to use for the component."
},
"module": {
"type": "string",
"description": "Allows specification of the declaring module.",
"alias": "m"
},
"export": {
"type": "boolean",
"default": false,
"description": "Specifies if declaring module exports the component."
},
"entryComponent": {
"type": "boolean",
"default": false,
"description": "Specifies if the component is an entry component of declaring module."
},
"lintFix": {
"type": "boolean",
"default": false,
"description": "Specifies whether to apply lint fixes after generating the component."
},
"module": {
"type": "string",
"description": "Allows specification of the declaring module. (e.g., -m=trade)",
"alias": "m"
},
"target": {
"type": "string",
"description": "指定目标路径,支持 `bus/list` 写法 (Specifies relative path, could be set like `bus/list`.)",
"alias": "t"
},
"withoutPrefix": {
"type": "boolean",
"description": "Without prefix to selectors",
"description": "组件名不加前缀 (Without prefix to selectors)",
"default": false
},
"modal": {
"type": "boolean",
"default": true,
"description": "Specifies using modal mode."
"description": "指定是否使用模态框 (Specifies using modal mode)"
}
},
"required": []
Expand Down
16 changes: 16 additions & 0 deletions packages/schematics/curd/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {Schema as ComponentSchema} from '@schematics/angular/component/schema';

export interface Schema extends ComponentSchema {
/**
* 指定目标路径,支持 `bus/list` 写法 (Specifies relative path, could be set like `bus/list`.)
*/
target?: string;
/**
* 指定组件名不加前缀 (Without prefix to selectors)
*/
withoutPrefix?: boolean;
/**
* 指定是否使用模态框 (Specifies using modal mode)
*/
modal?: boolean;
}
4 changes: 2 additions & 2 deletions packages/schematics/docs/generate.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ sys
sys.module.ts
```

So when you want to generate a view page that should be under the `log` directory:
So when you want to generate a view page that should be under the `log` directory (could be set like `log/list`):

```bash
ng g ng-alain:view view -m=sys -t=log
Expand Down Expand Up @@ -99,7 +99,7 @@ For example, to create a custom edit page template, you only need to create the
After that, just run:

```bash
ng g ng-alain:tpl <Your template name> <name> -m=trade
ng g ng-alain:tpl [your template name] [name] -m=trade
```

### How to write a template file
Expand Down
4 changes: 2 additions & 2 deletions packages/schematics/docs/generate.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ sys
sys.module.ts
```

因此,当你希望生成的查看应该是在 `log` 组件下面时,你可以这样子:
因此,当你希望生成的查看应该是在 `log` 组件(支持 `log/list` 多级写法)下面时,你可以这样子:

```bash
ng g ng-alain:view view -m=sys -t=log
Expand Down Expand Up @@ -96,7 +96,7 @@ ng g ng-alain:edit <page name> --modal=false
之后,只需要运行:

```bash
ng g ng-alain:tpl <your template name> <name> -m=trade
ng g ng-alain:tpl [your template name] [name] -m=trade
```

> 自定义页参数同业务页一致。
Expand Down
2 changes: 0 additions & 2 deletions packages/schematics/docs/getting-started.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ Using ng-alain scaffolding should as use as possible the `ng` command set provid

## Installation

我们不建议直接克隆 Github 源代码,而应该使用 `ng add` 来构建 ng-alain 项目,而构建一个空 ng-alain 只需要简单几个动作:

We don't recommend directly cloning the git repository, but instead using `ng add` to build the ng-alain project, there are a few simple steps:

1. Create an empty angular project
Expand Down
26 changes: 26 additions & 0 deletions packages/schematics/docs/plugin.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,29 @@ ng g ng-alain:plugin networkEnv -packageManager=npm -t=remove
# remove yarn
ng g ng-alain:plugin networkEnv -packageManager=yarn -t=remove
```

### icon

From the project to analyze and generate static load Icon, The plugin will automatically generate two files in the `src` directory:

- `src/style-icons.ts` Custom Icon (e.g: remote menu icon)
- `src/style-icons-auto.ts` command automatically generates files

```bash
ng g ng-alain:plugin icon
```

Also, you need to manually import in `startup.service.ts`:

```ts
import { ICONS_AUTO } from '../../../style-icons-auto';
import { ICONS } from '../../../style-icons';

@Injectable()
export class StartupService {
constructor(iconSrv: NzIconService) {
iconSrv.addIcon(...ICONS_AUTO, ...ICONS);
}
}
```

25 changes: 25 additions & 0 deletions packages/schematics/docs/plugin.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,28 @@ ng g ng-alain:plugin networkEnv -packageManager=npm -t=remove
# remove yarn
ng g ng-alain:plugin networkEnv -packageManager=yarn -t=remove
```

### icon

**尽可能**从项目中分析并生成静态 Icon,插件会自动在 `src` 目录下生成两个文件:

- `src/style-icons.ts` 自定义部分无法解析(例如:远程菜单图标)
- `src/style-icons-auto.ts` 命令自动生成文件

```bash
ng g ng-alain:plugin icon
```

同时,需要手动在 `startup.service.ts` 中导入:

```ts
import { ICONS_AUTO } from '../../../style-icons-auto';
import { ICONS } from '../../../style-icons';

@Injectable()
export class StartupService {
constructor(iconSrv: NzIconService) {
iconSrv.addIcon(...ICONS_AUTO, ...ICONS);
}
}
```
33 changes: 22 additions & 11 deletions packages/schematics/edit/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"inlineTemplate": {
"description": "Specifies if the template will be in the ts file.",
"type": "boolean",
"default": false
"default": false,
"alias": "t"
},
"viewEncapsulation": {
"description": "Specifies the view encapsulation strategy.",
Expand Down Expand Up @@ -88,30 +89,40 @@
"format": "html-selector",
"description": "The selector to use for the component."
},
"module": {
"type": "string",
"description": "Allows specification of the declaring module.",
"alias": "m"
},
"export": {
"type": "boolean",
"default": false,
"description": "Specifies if declaring module exports the component."
},
"withoutPrefix": {
"entryComponent": {
"type": "boolean",
"description": "Without prefix to selectors",
"default": false
"default": false,
"description": "Specifies if the component is an entry component of declaring module."
},
"lintFix": {
"type": "boolean",
"default": false,
"description": "Specifies whether to apply lint fixes after generating the component."
},
"module": {
"type": "string",
"description": "Allows specification of the declaring module. (e.g., -m=trade)",
"alias": "m"
},
"target": {
"type": "string",
"description": "Specifies relative path.",
"description": "指定目标路径,支持 `bus/list` 写法 (Specifies relative path, could be set like `bus/list`.)",
"alias": "t"
},
"withoutPrefix": {
"type": "boolean",
"description": "组件名不加前缀 (Without prefix to selectors)",
"default": false
},
"modal": {
"type": "boolean",
"default": true,
"description": "Specifies using modal mode."
"description": "指定是否使用模态框 (Specifies using modal mode)"
}
},
"required": []
Expand Down
10 changes: 5 additions & 5 deletions packages/schematics/edit/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import {Schema as ComponentSchema} from '@schematics/angular/component/schema';

export interface Schema extends ComponentSchema {
/**
* Without prefix to selectors
* 指定目标路径,支持 `bus/list` 写法 (Specifies relative path, could be set like `bus/list`.)
*/
withoutPrefix?: boolean;
target?: string;
/**
* Specifies relative path.
* 指定组件名不加前缀 (Without prefix to selectors)
*/
target?: string;
withoutPrefix?: boolean;
/**
* Specifies using modal mode.
* 指定是否使用模态框 (Specifies using modal mode)
*/
modal?: boolean;
}
Loading