Skip to content

Commit

Permalink
Merge branch 'v2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Franslee committed May 23, 2019
2 parents 2e8e67f + 8cba439 commit 1ff9a15
Show file tree
Hide file tree
Showing 24 changed files with 501 additions and 463 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ docshashCache.text
srchashCache.text
localsrc.cache
localdocs.cache
cache/src.cache
cache/mdToVue.cache
cache/docs.cache
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## 2.1.2

`2019-5-23`

* :sparkles: upd(Slider): 优化了拖动性能
* :sparkles: upd(Range): 优化了拖动性能
* :sparkles: upd(Switch): 优化了快速点击场景下的问题
* :sparkles: upd(CountDown): 优化了diffTime/restTime & 新增了一些事件
* :bug: fix(Calendar极值问题): 修复了极值问题
* :zap: chore: 优化了MD文档编译缓存机制
* :zap: chore: 不再单独构建commonjs包
* :zap: doc: 文档内容修改完善


## 2.1.1

`2019-4-22`
Expand Down
1 change: 0 additions & 1 deletion build/webpack.doc.base.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const webpackBaseConf = require('./webpack.base.conf.js');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const merge = require('webpack-merge');

const mdtohtml = require('../scripts/mdToVue');
const isDev = process.env.NODE_ENV === 'development';

Expand Down
46 changes: 0 additions & 46 deletions build/webpack.prod.cmn.conf.js

This file was deleted.

13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nutui/nutui",
"version": "2.1.1",
"version": "2.1.2",
"description": "一套轻量级移动端Vue组件库",
"typings": "dist/types/index.d.ts",
"main": "dist/nutui.js",
Expand All @@ -12,19 +12,18 @@
"CHANGELOG.md"
],
"scripts": {
"dev:demo": "cross-env NODE_ENV=development webpack-dev-server -d --open --progress --config build/webpack.demo.dev.conf.js",
"build:demo": "cross-env NODE_ENV=production webpack --hide-modules --progress --config build/webpack.demo.build.conf.js",
"dev:doc": "cross-env NODE_ENV=development DOC_TYPE=true webpack-dev-server -d --open -w --progress --config build/webpack.doc.dev.conf.js",
"doc:clear": "node scripts/clearCache.js",
"dev": "npm run dev:demo",
"dev:carefree": "cross-env NODE_ENV=carefree carefree_env=dev webpack -w --colors --progress --config build/webpack.demo.dev.conf.js",
"dev:demo": "cross-env NODE_ENV=development webpack-dev-server -d --open --progress --config build/webpack.demo.dev.conf.js",
"dev:doc": "cross-env NODE_ENV=development DOC_TYPE=true webpack-dev-server -d --open -w --progress --config build/webpack.doc.dev.conf.js",
"build:demo": "cross-env NODE_ENV=production webpack --hide-modules --progress --config build/webpack.demo.build.conf.js",
"build:doc": "cross-env NODE_ENV=production DOC_TYPE=true webpack --hide-modules --progress --config build/webpack.doc.build.conf.js",
"build:site": "npm run build:demo && npm run build:doc",
"build:prod": "cross-env NODE_ENV=production webpack --hide-modules --progress --config build/webpack.prod.conf.js && node scripts/createIndexScss.js",
"build:prodmin": "cross-env NODE_ENV=production webpack --hide-modules --progress --config build/webpack.prod.mini.conf.js",
"build:disp": "cross-env NODE_ENV=production PROD_TYPE=disp webpack --hide-modules --progress --config build/webpack.prod.disperse.conf.js",
"build:cmn": "cross-env NODE_ENV=production webpack --hide-modules --progress --config build/webpack.prod.cmn.conf.js",
"build": "npm run build:prod && npm run build:prodmin && npm run build:cmn && npm run build:disp",
"build": "npm run build:prod && npm run build:prodmin && npm run build:disp",
"clear": "node scripts/clearCache.js",
"eslint": "eslint src/packages/**/*.{js,vue}",
"add": "node scripts/createCptTpl.js",
"test": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha-webpack --webpack-config build/webpack.test.conf.js --require test/setup.js src/packages/*/__test__/**.spec.js",
Expand Down
4 changes: 2 additions & 2 deletions scripts/clearcache.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs');
const path = require('path');
fs.writeFileSync(path.join(__dirname,'./localdocs.cache'),"",'utf-8');
fs.writeFileSync(path.join(__dirname,'./localsrc.cache'),"",'utf-8');
let rimraf = require("rimraf");
rimraf('./cache',res=>{console.log(res)})
console.log("缓存清除成功")
132 changes: 132 additions & 0 deletions scripts/contrast.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
const path = require('path');
const fs = require('fs');
let { hashElement } = require('folder-hash');
/**
* 文件对比
* entry {string} 要对比的文件路径
* include {array} 要对比的文件格式 以数组形式
*/
class contrast{
constructor(options){
this.entry = options.entry;
this.include = options.include || ['*.md'] ;
this.fileHash = null;
this.oldHash = null;
this.differentHash = null;
this.outPath = path.join("./cache",options.entry.split(path.sep).pop().replace(/(\.md|\.js)/,'')+ '.cache');

}
run(){
let _that = this;
return new Promise((reslove,reject)=>{
_that.start().then(res=>{
this.getCache().then(out=>{
_that.compare();
_that.record();
reslove(_that.differentHash);
},err=>{
reslove(_that.fileHash);
_that.record();
})
})
})
}
start(){
let _that = this;
return new Promise((reslove,reject)=>{
hashElement(_that.entry, {
folders: { exclude: ['.*', 'node_modules', 'test_coverage','__test__','img','svg'] },
files: { include: _that.include, },
matchBasename: true
}).then(res=>{
//获取当前hash
_that.fileHash = _that.arraydownGrade(res);
if(_that.fileHash){
reslove(_that.fileHash)
}else{
reject("err")
}
})
})

}
arraydownGrade(ay){
let arys = {};
let paths = "";
function downGrade(data){
if(data.children && data.children.constructor == Array ){
paths = data.name;
data.children.map(item => {
downGrade(item)
})
}else{
let key = data.name.replace(/(\.md|\.js)/,'');
if(key =="doc"){
arys[paths] = data.hash;
}else{
arys[key] = data.hash;
}
}
}
downGrade(ay)
return arys;
}
/**
* 获取本地hash记录
*/
getCache(){
let _that = this;
return new Promise((reslove,reject)=>{
fs.readFile(this.outPath,"utf8",(err,data) => {
if(!err){
_that.oldHash = JSON.parse(data);
reslove();
}else{
console.error("There are no cached files in your locality");
reject();
}
})
})
}
compare(){
let fileHash = this.fileHash;
let oldHash = this.oldHash;
let differenthash = {};
for(let newkey in fileHash){
if(oldHash[newkey]){
if(oldHash[newkey] != fileHash[newkey]){
differenthash[newkey] = fileHash[newkey]
}
}else{
differenthash[newkey] = fileHash[newkey]
}
}
this.differentHash = differenthash;
}
record(){
let _that = this;
this.ishasOutFile("./cache").then(res=>{
fs.writeFile(_that.outPath,JSON.stringify(_that.fileHash),'utf8',(err,res)=>{ })
})

}
ishasOutFile(outPath){
return new Promise((resolve,reject)=>{
fs.stat(outPath,(err,res)=>{
if(err){
fs.mkdir(outPath,err=>{
if(err){
reject(err)
}else{
resolve(true)
}
})
}else{
resolve(true)
}
})
})
}

}
module.exports = contrast
Loading

0 comments on commit 1ff9a15

Please sign in to comment.