Skip to content

Commit 61415a1

Browse files
committed
初始化组件脚本update
1 parent 900b5d7 commit 61415a1

18 files changed

Lines changed: 160 additions & 295 deletions

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
end_of_line = lf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
10+
[*.md]
11+
trim_trailing_whitespace = false
12+
13+
[*.js]
14+
indent_size = 2
15+
16+
[*.vue]
17+
indent_size = 2
18+
19+
[*.scss]
20+
indent_size = 4

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
lib/
2+
dist/
3+
node_modules/

.eslintrc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"extends": "airbnb",
3+
"parser": "babel-eslint",
4+
"rules": {
5+
"semi": 0,
6+
"max-len": 0,
7+
"react/prefer-stateless-function": 0,
8+
"comma-dangle": 0,
9+
"func-names": 0,
10+
"prefer-const": 0,
11+
"arrow-body-style": 0,
12+
"react/sort-comp": 0,
13+
"react/no-multi-comp": 0,
14+
"react/prop-types": 0,
15+
"react/prefer-es6-class": 0,
16+
"react/jsx-closing-bracket-location": 0,
17+
"react/jsx-no-bind": 0,
18+
"no-param-reassign": 0,
19+
"no-return-assign": 0,
20+
"consistent-return": 0,
21+
"no-unused-expressions": ["error", { "allowShortCircuit": true, "allowTernary": true }],
22+
"no-use-before-define": ["error", { "functions": false }],
23+
"no-underscore-dangle": 0
24+
}
25+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.cache
33
.DS_Store
44
.idea
5+
.vscode
56
packages/**/lib
67
lib/*
78
!lib/index.js

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
registry=http://registry.npm.qima-inc.com
File renamed without changes.

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
usage = "\
2+
Usage: make <option> \n\n\
3+
init componentname 初始化一个新组件,请忽视makefile的报错 \n\n\
4+
\n"
5+
6+
7+
default:
8+
@echo $(usage)
9+
10+
init:
11+
node build/bin/init.js $(filter-out $@,$(MAKECMDGOALS))
12+
13+

README.md

Whitespace-only changes.

build/bin/build-entry.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,12 @@ var OUTPUT_PATH = path.join(__dirname, '../../src/index.js');
88
var IMPORT_TEMPLATE = 'import {{name}} from \'../packages/{{package}}/index.js\';';
99
var ISNTALL_COMPONENT_TEMPLATE = ' Vue.component({{name}}.name, {{name}});';
1010
var MAIN_TEMPLATE = `{{include}}
11-
import '../src/assets/font/iconfont.css';
1211
1312
const install = function(Vue) {
1413
if (install.installed) return;
1514
1615
{{install}}
17-
Vue.use(InfiniteScroll);
18-
Vue.use(Lazyload, {
19-
loading: require('./assets/loading-spin.svg'),
20-
try: 3
21-
});
22-
23-
Vue.$messagebox = Vue.prototype.$messagebox = MessageBox;
24-
Vue.$toast = Vue.prototype.$toast = Toast;
25-
Vue.$indicator = Vue.prototype.$indicator = Indicator;
16+
2617
};
2718
2819
// auto install

build/bin/init.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env node
2+
const ch = require('child_process');
3+
const gulp = require('gulp');
4+
const runSequence = require('run-sequence');
5+
const gutil = require('gulp-util');
6+
const fileSave = require('file-save');
7+
const path = require('path');
8+
const exec = ch.exec;
9+
10+
if (!process.argv[2]) {
11+
console.error('[组件名]必填.');
12+
process.exit(1);
13+
}
14+
15+
const name = process.argv[2];
16+
17+
18+
// 项目规范文件拷贝
19+
gulp.task('copy', function(callback) {
20+
gutil.log(gutil.colors.yellow('-------> 开始初始化'));
21+
22+
exec('cd packages && git clone git@gitlab.qima-inc.com:fe/vue-seed.git ' + name, function(err, stdout, stderr) {
23+
gutil.log('-------> 拉取 vue-seed');
24+
exec('rm -rf ./' + name + '/.git', function(err, stdout, stderr) {
25+
gutil.log('-------> ' + name + '组件初始化成功');
26+
callback();
27+
});
28+
});
29+
});
30+
31+
32+
// 添加到 components.json
33+
gulp.task('addComponents', function(callback) {
34+
const componentsFile = require('../../components.json');
35+
if (componentsFile[name]) {
36+
console.error(`${name} 已存在.`);
37+
process.exit(1);
38+
}
39+
componentsFile[name] = `./packages/${name}/index.js`;
40+
fileSave(path.join(__dirname, '../../components.json'))
41+
.write(JSON.stringify(componentsFile, null, ' '), 'utf8')
42+
.end('\n');
43+
gutil.log('-------> components.json文件更新成功');
44+
gutil.log(gutil.colors.yellow('-------> 请无视下面的make报错'));
45+
});
46+
47+
runSequence('copy', 'addComponents');
48+

0 commit comments

Comments
 (0)