mirror of https://github.com/ElemeFE/element
Merge pull request #42 from QingWei-Li/master
package: add lint script & lock vue versionpull/44/head
commit
08e31a3feb
|
@ -14,7 +14,7 @@ Object.keys(components).forEach(key => {
|
||||||
const filePath = path.join(__dirname, `../packages/${key}/cooking.conf.js`);
|
const filePath = path.join(__dirname, `../packages/${key}/cooking.conf.js`);
|
||||||
|
|
||||||
if (existsSync(filePath)) {
|
if (existsSync(filePath)) {
|
||||||
componentPaths.push(`packages/${key}/cooking.conf.js`)
|
componentPaths.push(`packages/${key}/cooking.conf.js`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
var Components = require('../components.json')
|
var Components = require('../components.json');
|
||||||
var fs = require('fs')
|
var fs = require('fs');
|
||||||
var render = require('json-templater/string')
|
var render = require('json-templater/string');
|
||||||
var uppercamelcase = require('uppercamelcase')
|
var uppercamelcase = require('uppercamelcase');
|
||||||
var path = require('path')
|
var path = require('path');
|
||||||
|
|
||||||
var OUTPUT_PATH = path.join(__dirname, '../src/index.js')
|
var OUTPUT_PATH = path.join(__dirname, '../src/index.js');
|
||||||
var IMPORT_TEMPLATE = `import {{name}} from '../packages/{{package}}/index.js';`
|
var IMPORT_TEMPLATE = 'import {{name}} from \'../packages/{{package}}/index.js\';';
|
||||||
var ISNTALL_COMPONENT_TEMPLATE = ` Vue.component({{name}}.name, {{name}});`
|
var ISNTALL_COMPONENT_TEMPLATE = ' Vue.component({{name}}.name, {{name}});';
|
||||||
var MAIN_TEMPLATE = `{{include}}
|
var MAIN_TEMPLATE = `{{include}}
|
||||||
|
|
||||||
const install = function(Vue) {
|
const install = function(Vue) {
|
||||||
|
@ -33,41 +33,40 @@ module.exports = {
|
||||||
install,
|
install,
|
||||||
{{list}}
|
{{list}}
|
||||||
};
|
};
|
||||||
`
|
`;
|
||||||
|
|
||||||
delete Components.font
|
delete Components.font;
|
||||||
|
|
||||||
var ComponentNames = Object.keys(Components)
|
var ComponentNames = Object.keys(Components);
|
||||||
|
|
||||||
var includeComponentTemplate = []
|
var includeComponentTemplate = [];
|
||||||
var installTemplate = []
|
var installTemplate = [];
|
||||||
var listTemplate = []
|
var listTemplate = [];
|
||||||
|
|
||||||
ComponentNames.forEach(name => {
|
ComponentNames.forEach(name => {
|
||||||
var componentName = uppercamelcase(name)
|
var componentName = uppercamelcase(name);
|
||||||
|
|
||||||
includeComponentTemplate.push(render(IMPORT_TEMPLATE, {
|
includeComponentTemplate.push(render(IMPORT_TEMPLATE, {
|
||||||
name: componentName,
|
name: componentName,
|
||||||
package: name
|
package: name
|
||||||
}))
|
}));
|
||||||
|
|
||||||
|
|
||||||
if (['Loading', 'MessageBox', 'Notification'].indexOf(componentName) === -1) {
|
if (['Loading', 'MessageBox', 'Notification'].indexOf(componentName) === -1) {
|
||||||
installTemplate.push(render(ISNTALL_COMPONENT_TEMPLATE, {
|
installTemplate.push(render(ISNTALL_COMPONENT_TEMPLATE, {
|
||||||
name: componentName,
|
name: componentName,
|
||||||
component: name
|
component: name
|
||||||
}))
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
listTemplate.push(` ${componentName}`)
|
listTemplate.push(` ${componentName}`);
|
||||||
})
|
});
|
||||||
|
|
||||||
var template = render(MAIN_TEMPLATE, {
|
var template = render(MAIN_TEMPLATE, {
|
||||||
include: includeComponentTemplate.join('\n'),
|
include: includeComponentTemplate.join('\n'),
|
||||||
install: installTemplate.join('\n'),
|
install: installTemplate.join('\n'),
|
||||||
list: listTemplate.join(',\n')
|
list: listTemplate.join(',\n')
|
||||||
})
|
});
|
||||||
|
|
||||||
fs.writeFileSync(OUTPUT_PATH, template)
|
fs.writeFileSync(OUTPUT_PATH, template);
|
||||||
console.log('[build entry] DONE:', OUTPUT_PATH)
|
console.log('[build entry] DONE:', OUTPUT_PATH);
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,6 @@ nodes.forEach((node) => {
|
||||||
if (arr && arr[1]) {
|
if (arr && arr[1]) {
|
||||||
classList.push(arr[1]);
|
classList.push(arr[1]);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
fs.writeFile(path.resolve(__dirname, '../examples/icon.json'), JSON.stringify(classList));
|
fs.writeFile(path.resolve(__dirname, '../examples/icon.json'), JSON.stringify(classList));
|
||||||
|
|
18
bin/new.js
18
bin/new.js
|
@ -92,9 +92,9 @@ export default {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: path.join('../../examples/docs/', `${componentname}.md`),
|
filename: path.join('../../examples/docs/', `${componentname}.md`),
|
||||||
content:`## ${chineseName}`
|
content: `## ${chineseName}`
|
||||||
}
|
}
|
||||||
]
|
];
|
||||||
|
|
||||||
// 添加到 components.json
|
// 添加到 components.json
|
||||||
const componentsFile = require('../components.json');
|
const componentsFile = require('../components.json');
|
||||||
|
@ -105,27 +105,27 @@ if (componentsFile[componentname]) {
|
||||||
componentsFile[componentname] = [`./packages/${componentname}/index.js`];
|
componentsFile[componentname] = [`./packages/${componentname}/index.js`];
|
||||||
fileSave(path.join(__dirname, '../components.json'))
|
fileSave(path.join(__dirname, '../components.json'))
|
||||||
.write(JSON.stringify(componentsFile, null, ' '), 'utf8')
|
.write(JSON.stringify(componentsFile, null, ' '), 'utf8')
|
||||||
.end('\n')
|
.end('\n');
|
||||||
|
|
||||||
// 创建 package
|
// 创建 package
|
||||||
Files.forEach(file => {
|
Files.forEach(file => {
|
||||||
fileSave(path.join(PackagePath, file.filename))
|
fileSave(path.join(PackagePath, file.filename))
|
||||||
.write(file.content, 'utf8')
|
.write(file.content, 'utf8')
|
||||||
.end('\n')
|
.end('\n');
|
||||||
})
|
});
|
||||||
|
|
||||||
// 添加到 nav.config.json
|
// 添加到 nav.config.json
|
||||||
const navConfigFile = require('../examples/nav.config.json');
|
const navConfigFile = require('../examples/nav.config.json');
|
||||||
navConfigFile[navConfigFile.length - 1].list.push({
|
navConfigFile[navConfigFile.length - 1].list.push({
|
||||||
path: `/${componentname}`,
|
path: `/${componentname}`,
|
||||||
name: `${chineseName} (${componentname})`,
|
name: `${chineseName} (${componentname})`,
|
||||||
title: componentname === chineseName ?
|
title: componentname === chineseName
|
||||||
componentname :
|
? componentname
|
||||||
`${componentname} ${chineseName}`
|
: `${componentname} ${chineseName}`
|
||||||
});
|
});
|
||||||
|
|
||||||
fileSave(path.join(__dirname, '../examples/nav.config.json'))
|
fileSave(path.join(__dirname, '../examples/nav.config.json'))
|
||||||
.write(JSON.stringify(navConfigFile, null, ' '), 'utf8')
|
.write(JSON.stringify(navConfigFile, null, ' '), 'utf8')
|
||||||
.end('\n')
|
.end('\n');
|
||||||
|
|
||||||
console.log('DONE!');
|
console.log('DONE!');
|
||||||
|
|
|
@ -9,14 +9,15 @@
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "npm i && (node bin/iconInit.js & node bin/build-entry.js) && cooking watch -c scripts/cooking.demo.js",
|
"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",
|
"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",
|
"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",
|
"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",
|
"gh-docs": "cooking build -c scripts/cooking.demo.js -p && gh-pages -d examples/element-ui --remote origin",
|
||||||
"postinstall": "lerna bootstrap",
|
"postinstall": "lerna bootstrap",
|
||||||
"pub": "npm run dist && kp",
|
"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": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -67,10 +68,12 @@
|
||||||
"theaterjs": "^3.0.0",
|
"theaterjs": "^3.0.0",
|
||||||
"uppercamelcase": "^1.1.0",
|
"uppercamelcase": "^1.1.0",
|
||||||
"url-loader": "^0.5.7",
|
"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-markdown-loader": "^0.4.0",
|
||||||
"vue-popup": "^0.2.3",
|
"vue-popup": "^0.2.3",
|
||||||
"vue-router": "^2.0.0-beta.2",
|
"vue-router": "^2.0.0-beta.2",
|
||||||
|
"vue-template-compiler": "2.0.0-rc.3",
|
||||||
"webpack": "^1.13.2",
|
"webpack": "^1.13.2",
|
||||||
"webpack-dev-server": "^1.15.1",
|
"webpack-dev-server": "^1.15.1",
|
||||||
"wind-dom": "0.0.3"
|
"wind-dom": "0.0.3"
|
||||||
|
|
|
@ -21,14 +21,14 @@ const salad = require('postcss-salad')({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('compile', function () {
|
gulp.task('compile', function() {
|
||||||
return gulp.src('./src/*.css')
|
return gulp.src('./src/*.css')
|
||||||
.pipe(postcss([salad]))
|
.pipe(postcss([salad]))
|
||||||
.pipe(cssmin())
|
.pipe(cssmin())
|
||||||
.pipe(gulp.dest('./lib'));
|
.pipe(gulp.dest('./lib'));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('copyfont', function () {
|
gulp.task('copyfont', function() {
|
||||||
return gulp.src('./src/fonts/**')
|
return gulp.src('./src/fonts/**')
|
||||||
.pipe(cssmin())
|
.pipe(cssmin())
|
||||||
.pipe(gulp.dest('./lib/fonts'));
|
.pipe(gulp.dest('./lib/fonts'));
|
||||||
|
|
|
@ -3,7 +3,7 @@ var path = require('path');
|
||||||
var Components = require('../components.json');
|
var Components = require('../components.json');
|
||||||
var entries = {};
|
var entries = {};
|
||||||
|
|
||||||
Object.keys(Components).forEach(function (key) {
|
Object.keys(Components).forEach(function(key) {
|
||||||
const compo = Components[key];
|
const compo = Components[key];
|
||||||
|
|
||||||
compo[0] = path.join(process.cwd(), compo[0]);
|
compo[0] = path.join(process.cwd(), compo[0]);
|
||||||
|
|
|
@ -4,9 +4,9 @@ var md = require('markdown-it')();
|
||||||
var Components = require('../components.json');
|
var Components = require('../components.json');
|
||||||
var striptags = require('../src/utils/strip-tags');
|
var striptags = require('../src/utils/strip-tags');
|
||||||
|
|
||||||
function convert(str){
|
function convert(str) {
|
||||||
str = str.replace(/(&#x)(\w{4});/gi,function($0){
|
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 String.fromCharCode(parseInt(encodeURIComponent($0).replace(/(%26%23x)(\w{4})(%3B)/g, '$2'), 16));
|
||||||
});
|
});
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ cooking.set({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
]
|
];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ cooking.add('vueMarkdown', {
|
||||||
return params.trim().match(/^demo\s*(.*)$/);
|
return params.trim().match(/^demo\s*(.*)$/);
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function (tokens, idx) {
|
render: function(tokens, idx) {
|
||||||
var m = tokens[idx].info.trim().match(/^demo\s*(.*)$/);
|
var m = tokens[idx].info.trim().match(/^demo\s*(.*)$/);
|
||||||
if (tokens[idx].nesting === 1) {
|
if (tokens[idx].nesting === 1) {
|
||||||
var description = (m && m.length > 1) ? m[1] : '';
|
var description = (m && m.length > 1) ? m[1] : '';
|
||||||
|
@ -88,8 +88,8 @@ cooking.add('vueMarkdown', {
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
],
|
],
|
||||||
preprocess: function (MarkdownIt, source) {
|
preprocess: function(MarkdownIt, source) {
|
||||||
MarkdownIt.renderer.rules.table_open = function () {
|
MarkdownIt.renderer.rules.table_open = function() {
|
||||||
return '<table class="table">';
|
return '<table class="table">';
|
||||||
};
|
};
|
||||||
MarkdownIt.renderer.rules.fence = wrap(MarkdownIt.renderer.rules.fence);
|
MarkdownIt.renderer.rules.fence = wrap(MarkdownIt.renderer.rules.fence);
|
||||||
|
@ -97,11 +97,11 @@ cooking.add('vueMarkdown', {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var wrap = function (render) {
|
var wrap = function(render) {
|
||||||
return function () {
|
return function() {
|
||||||
return render.apply(this, arguments)
|
return render.apply(this, arguments)
|
||||||
.replace('<code class="', '<code class="hljs ')
|
.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 = {};
|
var externals = {};
|
||||||
Object.keys(Components).forEach(function (key) {
|
Object.keys(Components).forEach(function(key) {
|
||||||
externals[`packages/${key}/style.css`] = 'null';
|
externals[`packages/${key}/style.css`] = 'null';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
var cheerio = require('cheerio');
|
var cheerio = require('cheerio');
|
||||||
|
|
||||||
module.exports = function (str, tags) {
|
module.exports = function(str, tags) {
|
||||||
var $ = cheerio.load(str, {decodeEntities: false});
|
var $ = cheerio.load(str, {decodeEntities: false});
|
||||||
|
|
||||||
if (!tags || tags.length === 0) {
|
if (!tags || tags.length === 0) {
|
||||||
|
|
Loading…
Reference in New Issue