Merge pull request #42 from QingWei-Li/master

package: add lint script & lock vue version
pull/44/head
baiyaaaaa 2016-09-09 12:27:00 +08:00 committed by GitHub
commit 08e31a3feb
29 changed files with 75 additions and 73 deletions

View File

@ -14,7 +14,7 @@ Object.keys(components).forEach(key => {
const filePath = path.join(__dirname, `../packages/${key}/cooking.conf.js`);
if (existsSync(filePath)) {
componentPaths.push(`packages/${key}/cooking.conf.js`)
componentPaths.push(`packages/${key}/cooking.conf.js`);
}
});

View File

@ -1,12 +1,12 @@
var Components = require('../components.json')
var fs = require('fs')
var render = require('json-templater/string')
var uppercamelcase = require('uppercamelcase')
var path = require('path')
var Components = require('../components.json');
var fs = require('fs');
var render = require('json-templater/string');
var uppercamelcase = require('uppercamelcase');
var path = require('path');
var OUTPUT_PATH = path.join(__dirname, '../src/index.js')
var IMPORT_TEMPLATE = `import {{name}} from '../packages/{{package}}/index.js';`
var ISNTALL_COMPONENT_TEMPLATE = ` Vue.component({{name}}.name, {{name}});`
var OUTPUT_PATH = path.join(__dirname, '../src/index.js');
var IMPORT_TEMPLATE = 'import {{name}} from \'../packages/{{package}}/index.js\';';
var ISNTALL_COMPONENT_TEMPLATE = ' Vue.component({{name}}.name, {{name}});';
var MAIN_TEMPLATE = `{{include}}
const install = function(Vue) {
@ -33,41 +33,40 @@ module.exports = {
install,
{{list}}
};
`
`;
delete Components.font
delete Components.font;
var ComponentNames = Object.keys(Components)
var ComponentNames = Object.keys(Components);
var includeComponentTemplate = []
var installTemplate = []
var listTemplate = []
var includeComponentTemplate = [];
var installTemplate = [];
var listTemplate = [];
ComponentNames.forEach(name => {
var componentName = uppercamelcase(name)
var componentName = uppercamelcase(name);
includeComponentTemplate.push(render(IMPORT_TEMPLATE, {
name: componentName,
package: name
}))
}));
if (['Loading', 'MessageBox', 'Notification'].indexOf(componentName) === -1) {
installTemplate.push(render(ISNTALL_COMPONENT_TEMPLATE, {
name: componentName,
component: name
}))
}));
}
listTemplate.push(` ${componentName}`)
})
listTemplate.push(` ${componentName}`);
});
var template = render(MAIN_TEMPLATE, {
include: includeComponentTemplate.join('\n'),
install: installTemplate.join('\n'),
list: listTemplate.join(',\n')
})
});
fs.writeFileSync(OUTPUT_PATH, template)
console.log('[build entry] DONE:', OUTPUT_PATH)
fs.writeFileSync(OUTPUT_PATH, template);
console.log('[build entry] DONE:', OUTPUT_PATH);

View File

@ -15,6 +15,6 @@ nodes.forEach((node) => {
if (arr && arr[1]) {
classList.push(arr[1]);
}
})
});
fs.writeFile(path.resolve(__dirname, '../examples/icon.json'), JSON.stringify(classList));

View File

@ -92,9 +92,9 @@ export default {
},
{
filename: path.join('../../examples/docs/', `${componentname}.md`),
content:`## ${chineseName}`
content: `## ${chineseName}`
}
]
];
// 添加到 components.json
const componentsFile = require('../components.json');
@ -105,27 +105,27 @@ if (componentsFile[componentname]) {
componentsFile[componentname] = [`./packages/${componentname}/index.js`];
fileSave(path.join(__dirname, '../components.json'))
.write(JSON.stringify(componentsFile, null, ' '), 'utf8')
.end('\n')
.end('\n');
// 创建 package
Files.forEach(file => {
fileSave(path.join(PackagePath, file.filename))
.write(file.content, 'utf8')
.end('\n')
})
.end('\n');
});
// 添加到 nav.config.json
const navConfigFile = require('../examples/nav.config.json');
navConfigFile[navConfigFile.length - 1].list.push({
path: `/${componentname}`,
name: `${chineseName} (${componentname})`,
title: componentname === chineseName ?
componentname :
`${componentname} ${chineseName}`
title: componentname === chineseName
? componentname
: `${componentname} ${chineseName}`
});
fileSave(path.join(__dirname, '../examples/nav.config.json'))
.write(JSON.stringify(navConfigFile, null, ' '), 'utf8')
.end('\n')
.end('\n');
console.log('DONE!');

View File

@ -9,14 +9,15 @@
],
"scripts": {
"dev": "npm i && (node bin/iconInit.js & node bin/build-entry.js) && cooking watch -c scripts/cooking.demo.js",
"dist": "del -f lib && cooking build -c scripts/cooking.conf.js,scripts/cooking.common.js -p && cooking build -c scripts/cooking.component.js -p && npm run build:theme",
"dist": "npm run lint && del -f lib && cooking build -c scripts/cooking.conf.js,scripts/cooking.common.js -p && cooking build -c scripts/cooking.component.js -p && npm run build:theme",
"dist:all": "node bin/build-all.js && npm run build:theme",
"build:theme": "gulp build --gulpfile packages/theme-default/gulpfile.js && cp-cli packages/theme-default/lib lib/theme-default",
"deploy": "cooking build -c scripts/cooking.demo.js -p",
"gh-docs": "cooking build -c scripts/cooking.demo.js -p && gh-pages -d examples/element-ui --remote origin",
"postinstall": "lerna bootstrap",
"pub": "npm run dist && kp",
"pub:all": "npm run dist:all && lerna publish"
"pub:all": "npm run dist:all && lerna publish",
"lint": "eslint src/** packages/** scripts/** bin/** --ext .js,.vue --ignore-pattern node_modules"
},
"repository": {
"type": "git",
@ -67,12 +68,14 @@
"theaterjs": "^3.0.0",
"uppercamelcase": "^1.1.0",
"url-loader": "^0.5.7",
"vue": "^2.0.0-rc.3",
"vue": "2.0.0-rc.3",
"vue-loader": "9.3.2",
"vue-markdown-loader": "^0.4.0",
"vue-popup": "^0.2.3",
"vue-router": "^2.0.0-beta.2",
"vue-template-compiler": "2.0.0-rc.3",
"webpack": "^1.13.2",
"webpack-dev-server": "^1.15.1",
"wind-dom": "0.0.3"
}
}
}

View File

@ -9,7 +9,7 @@ cooking.set({
template: false,
format: 'umd',
moduleName: 'ElMessageBox',
extends: ['vue2']
extends: ['vue2']
});
cooking.add('resolve.alias', {

View File

@ -9,7 +9,7 @@ cooking.set({
template: false,
format: 'umd',
moduleName: 'ElNotification',
extends: ['vue2']
extends: ['vue2']
});
cooking.add('resolve.alias', {

View File

@ -9,7 +9,7 @@ cooking.set({
template: false,
format: 'umd',
moduleName: 'ElPagination',
extends: ['vue2']
extends: ['vue2']
});
cooking.add('resolve.alias', {

View File

@ -9,7 +9,7 @@ cooking.set({
template: false,
format: 'umd',
moduleName: 'ElPopover',
extends: ['vue2']
extends: ['vue2']
});
cooking.add('resolve.alias', {

View File

@ -9,7 +9,7 @@ cooking.set({
template: false,
format: 'umd',
moduleName: 'ElProgress',
extends: ['vue2']
extends: ['vue2']
});
cooking.add('resolve.alias', {

View File

@ -9,7 +9,7 @@ cooking.set({
template: false,
format: 'umd',
moduleName: 'ElCascader',
extends: ['vue2']
extends: ['vue2']
});
cooking.add('resolve.alias', {

View File

@ -9,7 +9,7 @@ cooking.set({
template: false,
format: 'umd',
moduleName: 'ElRate',
extends: ['vue2']
extends: ['vue2']
});
cooking.add('resolve.alias', {

View File

@ -9,7 +9,7 @@ cooking.set({
template: false,
format: 'umd',
moduleName: 'ElRow',
extends: ['vue2']
extends: ['vue2']
});
cooking.add('resolve.alias', {

View File

@ -9,7 +9,7 @@ cooking.set({
template: false,
format: 'umd',
moduleName: 'ElSelectMenu',
extends: ['vue2']
extends: ['vue2']
});
cooking.add('resolve.alias', {

View File

@ -9,7 +9,7 @@ cooking.set({
template: false,
format: 'umd',
moduleName: 'ElSelect',
extends: ['vue2']
extends: ['vue2']
});
cooking.add('resolve.alias', {

View File

@ -9,7 +9,7 @@ cooking.set({
template: false,
format: 'umd',
moduleName: 'ElSlider',
extends: ['vue2']
extends: ['vue2']
});
cooking.add('resolve.alias', {

View File

@ -9,7 +9,7 @@ cooking.set({
template: false,
format: 'umd',
moduleName: 'ElSpinner',
extends: ['vue2']
extends: ['vue2']
});
cooking.add('resolve.alias', {

View File

@ -9,7 +9,7 @@ cooking.set({
template: false,
format: 'umd',
moduleName: 'ElSteps',
extends: ['vue2']
extends: ['vue2']
});
cooking.add('resolve.alias', {

View File

@ -9,7 +9,7 @@ cooking.set({
template: false,
format: 'umd',
moduleName: 'ElCascader',
extends: ['vue2']
extends: ['vue2']
});
cooking.add('resolve.alias', {

View File

@ -9,7 +9,7 @@ cooking.set({
template: false,
format: 'umd',
moduleName: 'ElTable',
extends: ['vue2']
extends: ['vue2']
});
cooking.add('resolve.alias', {

View File

@ -9,7 +9,7 @@ cooking.set({
template: false,
format: 'umd',
moduleName: 'ElTabs',
extends: ['vue2']
extends: ['vue2']
});
cooking.add('resolve.alias', {

View File

@ -9,7 +9,7 @@ cooking.set({
template: false,
format: 'umd',
moduleName: 'ElTag',
extends: ['vue2']
extends: ['vue2']
});
cooking.add('resolve.alias', {

View File

@ -21,14 +21,14 @@ const salad = require('postcss-salad')({
}
});
gulp.task('compile', function () {
gulp.task('compile', function() {
return gulp.src('./src/*.css')
.pipe(postcss([salad]))
.pipe(cssmin())
.pipe(gulp.dest('./lib'));
});
gulp.task('copyfont', function () {
gulp.task('copyfont', function() {
return gulp.src('./src/fonts/**')
.pipe(cssmin())
.pipe(gulp.dest('./lib/fonts'));

View File

@ -9,7 +9,7 @@ cooking.set({
template: false,
format: 'umd',
moduleName: 'ElTooltip',
extends: ['vue2']
extends: ['vue2']
});
cooking.add('resolve.alias', {

View File

@ -9,7 +9,7 @@ cooking.set({
template: false,
format: 'umd',
moduleName: 'ElTree',
extends: ['vue2']
extends: ['vue2']
});
cooking.add('resolve.alias', {

View File

@ -9,7 +9,7 @@ cooking.set({
template: false,
format: 'umd',
moduleName: 'ElUpload',
extends: ['vue2']
extends: ['vue2']
});
cooking.add('resolve.alias', {

View File

@ -3,7 +3,7 @@ var path = require('path');
var Components = require('../components.json');
var entries = {};
Object.keys(Components).forEach(function (key) {
Object.keys(Components).forEach(function(key) {
const compo = Components[key];
compo[0] = path.join(process.cwd(), compo[0]);

View File

@ -4,9 +4,9 @@ var md = require('markdown-it')();
var Components = require('../components.json');
var striptags = require('../src/utils/strip-tags');
function convert(str){
str = str.replace(/(&#x)(\w{4});/gi,function($0){
return String.fromCharCode(parseInt(encodeURIComponent($0).replace(/(%26%23x)(\w{4})(%3B)/g,"$2"),16));
function convert(str) {
str = str.replace(/(&#x)(\w{4});/gi, function($0) {
return String.fromCharCode(parseInt(encodeURIComponent($0).replace(/(%26%23x)(\w{4})(%3B)/g, '$2'), 16));
});
return str;
}
@ -50,7 +50,7 @@ cooking.set({
}
}
})
]
];
}
});
@ -70,7 +70,7 @@ cooking.add('vueMarkdown', {
return params.trim().match(/^demo\s*(.*)$/);
},
render: function (tokens, idx) {
render: function(tokens, idx) {
var m = tokens[idx].info.trim().match(/^demo\s*(.*)$/);
if (tokens[idx].nesting === 1) {
var description = (m && m.length > 1) ? m[1] : '';
@ -88,8 +88,8 @@ cooking.add('vueMarkdown', {
}
}]
],
preprocess: function (MarkdownIt, source) {
MarkdownIt.renderer.rules.table_open = function () {
preprocess: function(MarkdownIt, source) {
MarkdownIt.renderer.rules.table_open = function() {
return '<table class="table">';
};
MarkdownIt.renderer.rules.fence = wrap(MarkdownIt.renderer.rules.fence);
@ -97,11 +97,11 @@ cooking.add('vueMarkdown', {
}
});
var wrap = function (render) {
return function () {
var wrap = function(render) {
return function() {
return render.apply(this, arguments)
.replace('<code class="', '<code class="hljs ')
.replace('<code>', '<code class="hljs">')
.replace('<code>', '<code class="hljs">');
};
};
@ -112,7 +112,7 @@ cooking.add('resolve.alias', {
});
var externals = {};
Object.keys(Components).forEach(function (key) {
Object.keys(Components).forEach(function(key) {
externals[`packages/${key}/style.css`] = 'null';
});

View File

@ -9,7 +9,7 @@
var cheerio = require('cheerio');
module.exports = function (str, tags) {
module.exports = function(str, tags) {
var $ = cheerio.load(str, {decodeEntities: false});
if (!tags || tags.length === 0) {