Skip to content

Commit 96988e5

Browse files
author
levy
committed
Merge branch 'dev'
2 parents 6730fe2 + bbd729e commit 96988e5

File tree

8 files changed

+134
-54
lines changed

8 files changed

+134
-54
lines changed

README-zh.md

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Build Status](https://travis-ci.com/FEMessage/vue-sfc-cli.svg?branch=master)](https://travis-ci.com/FEMessage/vue-sfc-cli)
44
[![NPM Download](https://img.shields.io/npm/dm/vue-sfc-cli.svg)](https://www.npmjs.com/package/vue-sfc-cli)
5-
[![NPM Version](https://img.shields.io/npm/v/vue-sfc-cli.svg)](https://www.npmjs.com/package/vue-sfc-cli)
5+
[![NPM Version](https://badge.fury.io/js/vue-sfc-cli.svg)](https://www.npmjs.com/package/vue-sfc-cli)
66
[![NPM License](https://img.shields.io/npm/l/vue-sfc-cli.svg)](https://github.com/FEMessage/vue-sfc-cli/blob/master/LICENSE)
77
[![Automated Release Notes by gren](https://img.shields.io/badge/%F0%9F%A4%96-release%20notes-00B2EE.svg)](https://github-tools.github.io/github-release-notes/)
88

@@ -11,6 +11,11 @@
1111
## Table Of Contents
1212

1313
- [Links](#links)
14+
- [注意事项](#注意事项)
15+
- [环境需求](#环境需求)
16+
- [Prettier and husky](#prettier-and-husky)
17+
- [Stylelint](#stylelint)
18+
- [Windows](#windows)
1419
- [使用教程](#使用教程)
1520
- [快速开始](#快速开始)
1621
- [参数选项](#参数选项)
@@ -22,14 +27,31 @@
2227
- [methods](#methods)
2328
- [引入第三方库](#引入第三方库)
2429
- [环境变量](#环境变量)
25-
- [prettier and husky](#prettier-and-husky)
26-
- [注意](#注意)
27-
- [环境需求](#环境需求)
2830

2931
## Links
3032

3133
- [知乎文章](https://zhuanlan.zhihu.com/p/72590127)
3234

35+
## 注意事项
36+
37+
### 环境需求
38+
39+
Node.js 8.x
40+
41+
### Prettier and husky
42+
43+
组件模板内置prettier, 可以在提交代码时格式化。
44+
45+
注意的是需要先执行 `git init` 命令,之后再执行 `yarn` 安装依赖,否则提交钩子不生效。
46+
47+
### Stylelint
48+
49+
组件模板内置stylelint, 对 less/sass 支持友好, 但对 stylus 支持欠佳(不能写注释,否则会出错)
50+
51+
### Windows
52+
53+
不建议在Windows下生成组件, 因为.sh可能没有执行权限。
54+
3355
## 使用教程
3456

3557
### 快速开始
@@ -61,9 +83,7 @@ yarn publish
6183

6284
### 参数选项
6385

64-
```
65-
-u, --upgrade
66-
```
86+
`-u`, `--upgrade`
6787

6888
根据 template目录下模板,生成新的文件,更新到当前组件中。使用的是覆盖策略,默认覆盖的文件定义在 update-files.js。常用于使用最新版本vue-sfc-cli对旧组件的配置进行升级
6989

@@ -72,22 +92,30 @@ yarn publish
7292
npx vue-sfc-cli -u
7393
```
7494

75-
`—files`
95+
`-files`
7696

7797
如果想更新额外的文件,可以传此选项,后接文件名,多个文件使用 `,` 分隔
7898

7999
```
80100
npx vue-sfc-cli -u --files package.json,.babelrc.js
81101
```
82102

83-
`—test`
103+
`-—test`
84104

85105
生成一个测试的组件模板,常用于ci环境测试。
86106

87107
```
88108
npx vue-sfc-cli --test
89109
```
90110

111+
`--name`, `--owner`
112+
113+
以命令形式生成组件,跳过询问过程。它们通常成对出现。
114+
115+
```
116+
npx vue-sfc-cli --name log-viewer --owner FEMessage
117+
```
118+
91119
### 示例文档
92120

93121
在docs目录下,新建 `md` 文件,建议命名同样是kebab-case
@@ -240,17 +268,3 @@ module.exports = {
240268
}
241269
}
242270
```
243-
244-
### prettier and husky
245-
246-
组件模板内置prettier, 可以在提交代码时格式化。
247-
248-
注意的是需要先执行 `git init` 命令,之后再执行 `yarn` 安装依赖,否则提交钩子不生效。
249-
250-
### 注意
251-
252-
不建议在Windows下生成组件,因为.sh可能没有执行权限。
253-
254-
## 环境需求
255-
256-
Node.js 8.x

README.md

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,24 @@
22

33
[![Build Status](https://badgen.net/travis/FEMessage/vue-sfc-cli/master)](https://travis-ci.com/FEMessage/vue-sfc-cli)
44
[![NPM Download](https://badgen.net/npm/dm/vue-sfc-cli)](https://www.npmjs.com/package/vue-sfc-cli)
5-
[![NPM Version](https://badgen.net/npm/v/vue-sfc-cli)](https://www.npmjs.com/package/vue-sfc-cli)
5+
[![NPM Version](https://badge.fury.io/js/vue-sfc-cli.svg)](https://www.npmjs.com/package/vue-sfc-cli)
66
[![NPM License](https://badgen.net/npm/license/vue-sfc-cli)](https://github.com/FEMessage/vue-sfc-cli/blob/master/LICENSE)
77
[![Automated Release Notes by gren](https://img.shields.io/badge/%F0%9F%A4%96-release%20notes-00B2EE.svg)](https://github-tools.github.io/github-release-notes/)
88

99
vue-sfc-cli is a powerful tool for developing vue single-file component.
1010

1111
It makes writing docs and demo easily, integrated with an automated github workflow, and is always ready to publish to npm with best practices.
1212

13+
[中文文档](./README-zh.md)
14+
1315
## Table Of Contents
1416

1517
- [Links](#links)
18+
- [Notice](#notice)
19+
- [Requirement](#requirement)
20+
- [Prettier and husky](#prettier-and-husky)
21+
- [Stylelint](#stylelint)
22+
- [Windows](#windows)
1623
- [Tutorial](#tutorial)
1724
- [Quick Start](#quick-start)
1825
- [Options](#options)
@@ -24,15 +31,40 @@ It makes writing docs and demo easily, integrated with an automated github workf
2431
- [Methods](#methods)
2532
- [Working with third-party library](#working-with-third-party-library)
2633
- [Environment variable](#environment-variable)
27-
- [Prettier and husky](#prettier-and-husky)
28-
- [Notice](#notice)
29-
- [requirement](#requirement)
3034
- [Contributors](#contributors)
3135

3236
## Links
3337

3438
- [medium article](https://medium.com/deepexi/reveal-the-secret-of-vue-sfc-cli-69f0f21dbad3)
35-
- [中文文档](./README-zh.md)
39+
40+
## Notice
41+
42+
### Requirement
43+
44+
Node.js 8.x
45+
46+
### Prettier and husky
47+
48+
The component template has built-in prettier and husky setup that can format code when you commit.
49+
50+
However, you need to execute commands as following, otherwise the commit hook will not take effect:
51+
52+
```sh
53+
npx vue-sfc-cli
54+
55+
# git init must run before yarn
56+
git init
57+
58+
yarn
59+
```
60+
61+
### Stylelint
62+
63+
The component template has built-in stylelint, which perfectly supports less/sass, but not stylus(it cannot have comment)
64+
65+
### Windows
66+
67+
It is not recommended to generate components under Windows, cause `.sh` files may lost execution permissions.
3668

3769
## Tutorial
3870

@@ -66,9 +98,7 @@ yarn publish
6698

6799
### Options
68100

69-
```
70-
-u, --upgrade
71-
```
101+
`-u`, `--upgrade`
72102

73103
According to the template files in the templates directory, new files will be generated and override the files with same name in current component directory. The default override files is defined in update-files.js. This option often used to upgrade the configuration of old components using the latest version of vue-sfc-cli:
74104

@@ -77,22 +107,30 @@ According to the template files in the templates directory, new files will be ge
77107
npx vue-sfc-cli -u
78108
```
79109

80-
`—files`
110+
`-files`
81111

82112
If you want to update additional files, you can pass this option, multiple files use `,` to separate
83113

84114
```
85115
npx vue-sfc-cli -u --files package.json,.babelrc.js
86116
```
87117

88-
`—test`
118+
`-—test`
89119

90120
Generate a component template for testing, commonly used in CI .
91121

92122
```
93123
npx vue-sfc-cli --test
94124
```
95125

126+
`--name`, `--owner`
127+
128+
These two arguments are usually used together to generate component without prompt.
129+
130+
```
131+
npx vue-sfc-cli --name log-viewer --owner FEMessage
132+
```
133+
96134
### Writing Example
97135

98136
The docs directory hosts your component's examples. You just write markdown files, and they will turn into demo. It is also recommended to name the markdown files in kebab-case style.
@@ -245,20 +283,6 @@ module.exports = {
245283
}
246284
```
247285

248-
### Prettier and husky
249-
250-
The component template has a built-in prettier and husky setup that can format code when you commit.
251-
252-
However, you need to execute the git init command before running yarn ,otherwise the commit hook will not take effect.
253-
254-
### Notice
255-
256-
It is not recommended to generate components under Windows, as `.sh` files may lost execution permissions.
257-
258-
## requirement
259-
260-
Node.js 8.x
261-
262286
## Contributors
263287

264288
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let pkgName = ''
1515
/**
1616
* Prompt user for input to populate template files
1717
*/
18-
let npmName = argv.get('npm')
18+
let npmName = argv.get('name')
1919
let ownerName = argv.get('owner')
2020
const OWNER_NAME = 'FEMessage'
2121

templates/.eslintrc.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
browser: true,
5+
node: true
6+
},
7+
parserOptions: {
8+
parser: 'babel-eslint'
9+
},
10+
extends: [
11+
'eslint:recommended',
12+
'plugin:vue/recommended',
13+
'plugin:prettier/recommended',
14+
'prettier/vue'
15+
],
16+
plugins: ['vue', 'prettier'],
17+
rules: {
18+
'no-console': [
19+
'error',
20+
{
21+
allow: ['warn', 'error']
22+
}
23+
],
24+
'no-debugger': 'error',
25+
'prettier/prettier': 'error'
26+
}
27+
}

templates/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Build Status](https://badgen.net/travis/{{ownerName}}/{{componentName}}/master)](https://travis-ci.com/{{ownerName}}/{{componentName}})
44
[![NPM Download](https://badgen.net/npm/dm/@{{ownerNameLowerCase}}/{{componentName}})](https://www.npmjs.com/package/@{{ownerNameLowerCase}}/{{componentName}})
5-
[![NPM Version](https://badgen.net/npm/v/@{{ownerNameLowerCase}}/{{componentName}})](https://www.npmjs.com/package/@{{ownerNameLowerCase}}/{{componentName}})
5+
[![NPM Version](https://badge.fury.io/js/%40{{ownerNameLowerCase}}%2F{{componentName}}.svg)](https://www.npmjs.com/package/@{{ownerNameLowerCase}}/{{componentName}})
66
[![NPM License](https://badgen.net/npm/license/@{{ownerNameLowerCase}}/{{componentName}})](https://github.com/{{ownerName}}/{{componentName}}/blob/master/LICENSE)
77
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/{{ownerName}}/{{componentName}}/pulls)
88
[![Automated Release Notes by gren](https://img.shields.io/badge/%F0%9F%A4%96-release%20notes-00B2EE.svg)](https://github-tools.github.io/github-release-notes/)

templates/build/rollup.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ const config = {
1717
commonjs(),
1818
vue({
1919
css: true,
20-
compileTemplate: true
20+
compileTemplate: true,
21+
style: {
22+
postcssPlugins: [require('autoprefixer')]
23+
}
2124
}),
2225
babel({
2326
runtimeHelpers: true,

templates/package-json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@
3939
"@babel/core": "^7.4.3",
4040
"@babel/plugin-transform-runtime": "^7.4.3",
4141
"@babel/preset-env": "^7.4.3",
42+
"babel-eslint": "^10.0.3",
4243
"babel-loader": "^8.0.5",
44+
"eslint": "^6.6.0",
45+
"eslint-config-prettier": "^6.5.0",
46+
"eslint-plugin-prettier": "^3.1.1",
47+
"eslint-plugin-vue": "^5.2.3",
4348
"file-loader": "^3.0.1",
4449
"github-release-notes": "^0.17.0",
4550
"glob": "^7.1.3",
@@ -69,21 +74,28 @@
6974
},
7075
"vue-sfc-cli": "{{cliVersion}}",
7176
"engines": {
72-
"node": ">= 4.0.0",
77+
"node": ">= 8.3.0",
7378
"npm": ">= 3.0.0"
7479
},
7580
"husky": {
7681
"hooks": {
7782
"pre-commit": "lint-staged",
78-
"post-commit": "git update-index --again"
83+
"post-commit": "git update-index --again",
84+
"pre-push": "yarn test"
7985
}
8086
},
8187
"lint-staged": {
82-
"*.(js|md|json)": [
88+
"*.@(md|json)": [
89+
"prettier --write",
90+
"git add"
91+
],
92+
"*.js": [
93+
"eslint --fix",
8394
"prettier --write",
8495
"git add"
8596
],
8697
"*.vue": [
98+
"eslint --fix",
8799
"prettier --write",
88100
"stylelint --fix",
89101
"git add"

templates/src/component.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="{{componentName}}">
2+
<div class="{{componentName}}" v-bind="$attrs" v-on="$listeners">
33
hello
44
</div>
55
</template>

0 commit comments

Comments
 (0)