Skip to content

Commit a61363f

Browse files
author
xiang.hu胡祥
committed
cli调整。详见changelog
1 parent ad70201 commit a61363f

File tree

10 files changed

+30
-84
lines changed

10 files changed

+30
-84
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## V0.1.0
2+
3+
<ol>
4+
<li>新增changelog.md</li>
5+
<li>调整component生成逻辑。移除同名ts。将controller逻辑移至index.ts文件中。</li>
6+
<li>移除--template 选项。不再支持模板格式。</li>
7+
<li>调整directive模板</li>
8+
</ol>

actions/generate-component.js

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const {
1010
spinner,
1111
} = require('../utils');
1212

13-
module.exports = (component, basePath, isView, withTemplate) => new Promise((resolve) => {
13+
module.exports = (component, basePath, isView) => new Promise((resolve) => {
1414
let {
1515
file_name,
1616
fileName,
@@ -45,36 +45,19 @@ module.exports = (component, basePath, isView, withTemplate) => new Promise((res
4545

4646
const tplPath = path.join(__dirname, '../templates/component');
4747
let tpls = [];
48-
if (isView && withTemplate) {
49-
tpls = [
50-
{ source: 'index.tpl', dest: 'index.ts' },
51-
{ source: 'scss.tpl', dest: `${file_name}.scss` },
52-
{ source: 'service.tpl', dest: `${file_name}.service.ts` },
53-
{ source: 'controller-service.tpl', dest: `${file_name}.ts` },
54-
{ source: 'html.tpl', dest: `${file_name}.html` },
55-
];
56-
} else if (isView && !withTemplate) {
48+
if (isView) {
5749
tpls = [
58-
{ source: 'index.tpl', dest: 'index.ts' },
5950
{ source: 'scss.tpl', dest: `${file_name}.scss` },
60-
{ source: 'service.tpl', dest: `${file_name}.service.ts` },
61-
{ source: 'controller-service-with-render.tpl', dest: `${file_name}.ts` },
6251
{ source: 'html.tpl', dest: `${file_name}.render.html` },
52+
{ source: 'index-with-service.tpl', dest: 'index.ts' },
53+
{ source: 'service.tpl', dest: `${file_name}.service.ts` },
6354
];
6455

65-
} else if (withTemplate) {
66-
tpls = [
67-
{ source: 'index.tpl', dest: 'index.ts' },
68-
{ source: 'scss.tpl', dest: `${file_name}.scss` },
69-
{ source: 'html.tpl', dest: `${file_name}.html` },
70-
{ source: 'controller.tpl', dest: `${file_name}.ts` },
71-
];
7256
} else {
7357
tpls = [
74-
{ source: 'index.tpl', dest: 'index.ts' },
7558
{ source: 'scss.tpl', dest: `${file_name}.scss` },
7659
{ source: 'html.tpl', dest: `${file_name}.render.html` },
77-
{ source: 'controller-with-render.tpl', dest: `${file_name}.ts` },
60+
{ source: 'index.tpl', dest: 'index.ts' },
7861
];
7962
}
8063

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ program
5656
try {
5757
let basePath = generatePath();
5858
program.simple ? generateSimpleComponent(component, basePath) :
59-
generateComponent(component, basePath, false, program.template);
59+
generateComponent(component, basePath, false);
6060
} catch (error) {
6161
console.error(error);
6262
}
@@ -69,7 +69,7 @@ program
6969
.action(component => {
7070
try {
7171
let basePath = generatePath();
72-
generateComponent(component, basePath, true, program.template);
72+
generateComponent(component, basePath, true);
7373
} catch (error) {
7474
console.error(error);
7575
}
@@ -185,7 +185,7 @@ program
185185
.version(package.version)
186186
.option('-B, --basePath [path]', 'set BasePath, default src')
187187
.option('-s, --simple', 'create a component in single file')
188-
.option('-t, --template', 'create a component or view with template property')
188+
// .option('-t, --template', 'create a component or view with template property')
189189
.parse(process.argv);
190190

191191
/**

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vt-cli",
3-
"version": "0.0.13",
3+
"version": "0.1.0",
44
"description": "",
55
"main": "index.js",
66
"bin": {

templates/component/controller-service.tpl

Lines changed: 0 additions & 10 deletions
This file was deleted.

templates/component/controller-with-render.tpl

Lines changed: 0 additions & 7 deletions
This file was deleted.

templates/component/controller.tpl

Lines changed: 0 additions & 9 deletions
This file was deleted.

templates/component/index.tpl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
import {{camelName}} from './{{kebabCaseName}}';
1+
import { Vue, Component } from 'vue-property-decorator';
22

3-
export default {{camelName}};
3+
@require('./{{kebabCaseName}}.render.html?style=./{{kebabCaseName}}.scss')
4+
@Component({})
5+
export default class {{camelName}} extends Vue {
6+
7+
}

templates/directive.ts

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,35 @@
1-
import {
2-
VNode,
3-
VNodeDirective,
4-
} from 'vue';
1+
import { VNode, VNodeDirective } from 'vue';
52

63
/**
74
* 只调用一次,指令第一次绑定到元素时调用。在这里可以进行一次性的初始化设置
8-
*
9-
* @param {HTMLElement} el
10-
* @param {VNodeDirective} binding
11-
* @param {VNode} vnode
125
*/
13-
function bind(el: HTMLElement, binding: VNodeDirective, vnode: VNode) {}
6+
function bind(el: HTMLElement, binding: VNodeDirective, vnode: VNode) { }
147

158
/**
169
* 被绑定元素插入父节点时调用 (仅保证父节点存在,但不一定已被插入文档中)。
17-
*
18-
* @param {HTMLElement} el
19-
* @param {VNodeDirective} binding
20-
* @param {VNode} vnode
2110
*/
22-
function inserted(el: HTMLElement, binding: VNodeDirective, vnode: VNode) {}
11+
function inserted(el: HTMLElement, binding: VNodeDirective, vnode: VNode) { }
2312

2413
/**
2514
* 所在组件的 VNode 更新时调用,但是可能发生在其子 VNode 更新之前。
2615
* 指令的值可能发生了改变,也可能没有。
2716
* 但是你可以通过比较更新前后的值来忽略不必要的模板更新 (详细的钩子函数参数见下)。
28-
*
29-
* @param {HTMLElement} el
30-
* @param {VNodeDirective} binding
31-
* @param {VNode} vnode
3217
*/
33-
function update(el: HTMLElement, binding: VNodeDirective, vnode: VNode) {}
18+
function update(el: HTMLElement, binding: VNodeDirective, vnode: VNode) { }
3419

3520
/**
3621
* 指令所在组件的 VNode 及其子 VNode 全部更新后调用。
37-
*
38-
* @param {HTMLElement} el
39-
* @param {VNodeDirective} binding
40-
* @param {VNode} vnode
4122
*/
42-
function componentUpdated(el: HTMLElement, binding: VNodeDirective, vnode: VNode) {}
23+
function componentUpdated(el: HTMLElement, binding: VNodeDirective, vnode: VNode) { }
4324

4425

4526
/**
4627
* 只调用一次,指令与元素解绑时调用
47-
*
48-
* @param {HTMLElement} el
49-
* @param {VNodeDirective} binding
50-
* @param {VNode} vnode
5128
*/
52-
function unbind(el: HTMLElement, binding: VNodeDirective, vnode: VNode) {}
29+
function unbind(el: HTMLElement, binding: VNodeDirective, vnode: VNode) { }
5330

5431

55-
export default {
32+
export default {
5633
bind,
5734
update,
5835
// inserted,

0 commit comments

Comments
 (0)