Skip to content

Commit 5bcc854

Browse files
committed
fix cli
1 parent 62639b2 commit 5bcc854

File tree

15 files changed

+51
-33
lines changed

15 files changed

+51
-33
lines changed

docs/Build Command.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,37 @@ npm run svg
2424
--version, -v 显示版本号 [布尔]
2525
--help, -h 显示帮助信息 [布尔]
2626
--type, -t The component type
27-
[可选值: "view", "ui", "tag"] [默认值: "view"]
2827
--path, -p The target path [默认值: "src/components"]
2928
```
29+
默认路径是从 **src/components** 开始的
3030
```bash
3131
# 添加组件,
32-
./tools/cli.js add [componentName] -t [componentType]
32+
./tools/cli add [componentPath] -t [componentType]
3333

34-
# 如果只是添加 view, 而且已经安装 yarn
35-
yarn cli add [componentName] -t [componentType]
34+
# use npm script
35+
npm run cli add [componentPath] -- -t [componentType]
36+
37+
# use yarn
38+
yarn cli add [componentPath] -- -t [componentType]
3639
```
40+
### -t
41+
**-t** 参数只是标记这个组件是什么类型的组件,可以根据这个参数选择不同的模板创建组件。默认是根据 componentPath 开始的路径名确定 component type。比如
3742

38-
componentName 可以是路径
39-
```bash
40-
./tools/cli.js add public/login -t view
4143
```
42-
以上会在 src/components/views/public/login 创建一个 view 类型的组件。
43-
#####
44+
# component type: view
45+
yarn cli add views/home
46+
47+
# component type: tag
48+
yarn cli add tags/hello
49+
50+
# component type: tag
51+
yarn cli add views/home/list -- -t tag
52+
```
53+
54+
### -p
4455
**-p** 参数是指定根路径。如果你要创建的组件不在 **src/components**, 你可以通过设置该参数改变根路径。
4556

4657
```bash
47-
./tools/cli.js add hello -t tag -p demo/components
58+
yarn cli add tags/hello -- -p demo/components
4859
```
4960
以上会在 demo/components/tags/hello 创建一个 tag 类型的组件。

template/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,11 @@ yarn svg
2323

2424
## Cli Tool
2525
```
26-
yarn cli add [componentName] -t [componentType]
26+
./tools/cli add [componentPath] -t [componentType]
27+
28+
# use npm script
29+
npm run cli add [componentPath] -- -t [componentType]
30+
31+
# use yarn
32+
yarn cli add [componentPath] -- -t [componentType]
2733
```

template/src/components/pages/app/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Component } from 'vue-property-decorator'
33
import template from './app.vue'
44

55
@Component({
6-
name: 'App',
6+
name: 'page-app',
77
mixins: [template]
88
})
99
export default class App extends Vue {

template/src/components/tags/hello/hello.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Component, Prop } from 'vue-property-decorator'
33
import template from './hello.vue'
44

55
@Component({
6-
name: 'Hello',
6+
name: 'tag-hello',
77
mixins: [template]
88
})
99
export default class Hello extends Vue {

template/src/components/views/home/home.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import template from './home.vue'
55
import Hello from 'components/tags/hello'
66

77
@Component({
8-
name: 'Home',
8+
name: 'view-home',
99
mixins: [template],
1010
components: {
1111
Hello

template/src/components/views/product/detail/detail.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Component } from 'vue-property-decorator'
1010
import template from './detail.vue'
1111

1212
@Component({
13-
name: 'product-detail',
13+
name: 'view-product-detail',
1414
mixins: [template]
1515
})
1616
export default class Detail extends Vue {

template/src/components/views/product/list/list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Component } from 'vue-property-decorator'
1010
import template from './list.vue'
1111

1212
@Component({
13-
name: 'product-list',
13+
name: 'view-product-list',
1414
mixins: [template]
1515
})
1616
export default class List extends Vue {

template/src/components/views/scoped/child1/child1.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Component } from 'vue-property-decorator'
1010
import template from './child1.vue'
1111

1212
@Component({
13-
name: 'view-scoped-child1',
13+
name: 'tag-scoped-child1',
1414
mixins: [template]
1515
})
1616
export default class Child1 extends Vue {

template/src/components/views/scoped/child2/child2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Component } from 'vue-property-decorator'
1010
import template from './child2.vue'
1111

1212
@Component({
13-
name: 'view-scoped-child2',
13+
name: 'tag-scoped-child2',
1414
mixins: [template]
1515
})
1616
export default class Child2 extends Vue {

template/src/components/views/todo/filter/filter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Component } from 'vue-property-decorator'
1010
import template from './filter.vue'
1111

1212
@Component({
13-
name: 'view-todo-filter',
13+
name: 'tag-todo-filter',
1414
mixins: [template]
1515
})
1616
export default class Filter extends Vue {

0 commit comments

Comments
 (0)