Skip to content

Commit 8ffb83f

Browse files
committed
1.4.0
1. 增加调试模式 2. 增加自动化编译 3. 增加 svg 格式支持 4. 优化 JS 合并模块 5. 更新示例 6. 优化编译提示和修复一些 bug
1 parent a09e7ec commit 8ffb83f

File tree

10 files changed

+254
-36
lines changed

10 files changed

+254
-36
lines changed

appveyor.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# version format
2+
version: "{build}"
3+
4+
# branches to build
5+
branches:
6+
only:
7+
- master
8+
9+
# Build worker image (VM template)
10+
os: Visual Studio 2015
11+
12+
# scripts that are called at very beginning, before repo cloning
13+
init:
14+
- git config --global core.autocrlf input
15+
16+
environment:
17+
WeFlowBuild: true
18+
19+
qiniu_ACCESS_KEY:
20+
secure: T10k13x11WzEOXvMqo8pXNK4fMb2+iSqj6ate+fhL7pwWxySeKhsoxjZ2GpAAsBU
21+
qiniu_SECRET_KEY:
22+
secure: XRWyQSCo7yWHH7LN5AUlFd3UYl/T6ZAc7WiK4NJJGAKocvmEm7ait8jm+y51CZ6c
23+
matrix:
24+
- nodejs_version: 5.10.0
25+
26+
matrix:
27+
fast_finish: true
28+
29+
platform:
30+
- x86
31+
- x64
32+
33+
install:
34+
- ps: Install-Product node $env:nodejs_version $env:platform
35+
- echo "%PLATFORM%"
36+
- node -v
37+
- npm -v
38+
- npm install -g node-gyp
39+
- npm install
40+
- cd node_modules\node-lwip
41+
- if "%PLATFORM%" == "x64" node-gyp rebuild --target=0.37.8 --arch=x64 --dist-url=https://atom.io/download/atom-shell
42+
- if "%PLATFORM%" == "x86" node-gyp rebuild --target=0.37.8 --arch=ia32 --dist-url=https://atom.io/download/atom-shell
43+
- cd ..\..\
44+
- node build\downBinding
45+
- if "%PLATFORM%" == "x64" npm run build:win64
46+
- if "%PLATFORM%" == "x86" npm run build:win32
47+
- ps: Compress-Archive -Path dist -DestinationPath dist.zip
48+
- node build\upload
49+
50+
51+
build: OFF
52+
test: OFF
53+
deploy: OFF

build/downBinding.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"use strict";
2+
const path = require('path');
3+
const http = require('http');
4+
const fs = require('fs');
5+
6+
const BINDING = 'binding.node';
7+
const DIRNAME = `${process.platform}-${process.arch}-${process.versions.modules}`;
8+
const HOST = 'http://o92gtaqgp.bkt.clouddn.com'
9+
10+
let weflowPath = path.join(__dirname, '../');
11+
let nodeModulesPath = path.join(weflowPath, 'node_modules');
12+
let nodeSassLocalPath = path.join(nodeModulesPath, 'node-sass', 'vendor', DIRNAME, BINDING);
13+
let nodeSassRemotePath = `${HOST}/${process.platform}-${process.arch}-${process.versions.modules}/${BINDING}`;
14+
15+
16+
downFile(nodeSassLocalPath, nodeSassRemotePath, function (err) {
17+
if(err){
18+
throw new Error(err);
19+
}
20+
console.log('Download success: ', nodeSassLocalPath);
21+
});
22+
23+
24+
function downFile(localFilePath, remoteFilePath, callback) {
25+
26+
console.log(remoteFilePath + ' downloading...');
27+
28+
let file = fs.createWriteStream(localFilePath);
29+
30+
http.get(remoteFilePath, function (response) {
31+
if (response.statusCode !== 200) {
32+
callback.apply(this, [true]);
33+
} else {
34+
response.pipe(file);
35+
file.on('finish', function () {
36+
callback.apply(this, [false, 0]);
37+
});
38+
}
39+
40+
}).on('error', function (err) {
41+
console.log('Download fail: ', localFilePath, err);
42+
});
43+
}

build/upload.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"use strict";
2+
3+
const path = require('path');
4+
// const async = require('async');
5+
const qiniu = require('qiniu');
6+
// const extract = require('extract-zip');
7+
const http = require('http');
8+
const fs = require('fs');
9+
// const del = require('del');
10+
// const gulp = require('gulp');
11+
// const rename = require('gulp-rename');
12+
const config = require('rc')('qiniu');
13+
14+
// let weflowPath = path.join(__dirname, '../');
15+
// let distZip = path.join(weflowPath, 'dist.zip');
16+
// let pkg = require(path.join(weflowPath, 'package.json'));
17+
// let distName = `WeFlow-${pkg.version}-${process.platform}-${process.arch}.zip`;
18+
19+
console.log(config['ACCESS_KEY'])
20+
console.log(config['SECRET_KEY'])
21+
22+
// async.series([
23+
// function (next) {
24+
// gulp.src(distZip)
25+
// .pipe(rename(distName))
26+
// .pipe(gulp.dest(weflowPath))
27+
// .on('end', function () {
28+
// console.log('rename success.');
29+
// next();
30+
// });
31+
// },
32+
// function (next) {
33+
// //准备上传
34+
// qiniu.conf.ACCESS_KEY = config['ACCESS_KEY'];
35+
// qiniu.conf.SECRET_KEY = config['SECRET_KEY'];
36+
//
37+
// var uptoken = new qiniu.rs.PutPolicy('weflow' + ":" + distName).token();
38+
// var zipPath = path.join(weflowPath, distName);
39+
//
40+
// uploadFile(uptoken, distName, zipPath, function (ret) {
41+
// console.log(ret.key + ' upload success.');
42+
// next();
43+
// });
44+
// }
45+
// ]);
46+
47+
function uploadFile(token, key, filePath, callback) {
48+
49+
var extra = new qiniu.io.PutExtra();
50+
51+
qiniu.io.putFile(token, key, filePath, extra, function (err, ret) {
52+
53+
if (err) {
54+
console.log(err);
55+
}
56+
57+
callback && callback(ret);
58+
59+
});
60+
}
61+

package.json

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"name": "WeFlow",
3-
"version": "1.3.1",
4-
"release": "1.3.1",
3+
"version": "1.4.0",
4+
"release": "1.4.0",
55
"description": "A minimal Electron application",
66
"main": "main.js",
77
"scripts": {
88
"start": "electron main.js",
9-
"build:mac": "rimraf dist && electron-packager ./ WeFlow --platform=darwin --arch=x64 --icon=./assets/img/WeFlow.icns --overwrite --out ./dist/$npm_package_version --version=0.37.8",
10-
"build:win64": "rimraf dist-win && electron-packager ./ WeFlow --platform=win32 --arch=x64 --icon=./assets/img/WeFlow.png --overwrite --out ./dist-win --version=0.37.8",
9+
"build:mac": "rimraf dist && electron-packager ./ WeFlow --platform=darwin --arch=x64 --icon=./assets/img/WeFlow.icns --overwrite --out ./dist/$npm_package_version --version=0.37.8 --ignore='(.github|.DS_Store)'",
10+
"build:win32": "rimraf dist && electron-packager ./ WeFlow --platform=win32 --arch=ia32 --icon=./assets/img/WeFlow.png --overwrite --out ./dist --version=0.37.8 --ignore=.github",
11+
"build:win64": "rimraf dist && electron-packager ./ WeFlow --platform=win32 --arch=x64 --icon=./assets/img/WeFlow.png --overwrite --out ./dist --version=0.37.8 --ignore=.github",
1112
"pack": "build --target dir",
1213
"dist": "rimraf dist && build"
1314
},
@@ -35,48 +36,51 @@
3536
},
3637
"homepage": "https://github.com/weixin/WeFlow#readme",
3738
"devDependencies": {
38-
"electron-builder": "^4.2.2",
3939
"electron-packager": "^7.0.3",
4040
"electron-prebuilt": "^0.37.0",
41-
"electron-winstaller": "^2.3.1",
4241
"rimraf": "^2.5.2"
4342
},
4443
"dependencies": {
4544
"async": "^2.0.0-rc.3",
4645
"autoprefixer": "^6.3.3",
46+
"babel-core": "^6.11.4",
47+
"babel-preset-electron": "^0.37.8",
48+
"babel-preset-es2015": "^6.9.0",
49+
"babel-preset-stage-2": "^6.11.0",
4750
"browser-sync": "^2.13.0",
4851
"crypto-md5": "^1.0.0",
4952
"del": "^2.2.0",
5053
"extract-zip": "^1.5.0",
5154
"gulp": "git://github.com/gulpjs/gulp#4.0",
55+
"gulp-babel": "^6.1.2",
5256
"gulp-cssnano": "^2.1.1",
5357
"gulp-ejs": "^2.1.1",
5458
"gulp-ftp": "^1.1.0",
5559
"gulp-if": "^2.0.0",
56-
"gulp-imagemin": "^2.4.0",
5760
"gulp-lazyimagecss": "^2.0.0",
5861
"gulp-less": "^3.0.5",
5962
"gulp-postcss": "^6.0.1",
6063
"gulp-posthtml": "^1.5.2",
6164
"gulp-rename": "^1.2.2",
6265
"gulp-replace": "^0.5.4",
63-
"gulp-rev-all": "^0.8.22",
6466
"gulp-rev-delete-original": "^0.1.0",
6567
"gulp-sass": "^2.3.2",
6668
"gulp-sftp": "^0.1.5",
67-
"gulp-tmtsprite": "^0.0.20",
69+
"gulp-tmtsprite": "^0.0.22",
6870
"gulp-uglify": "^1.5.3",
69-
"gulp-usemin2": "^0.2.4",
71+
"gulp-usemin": "^0.3.23",
7072
"gulp-util": "^3.0.7",
7173
"gulp-webp": "^2.3.0",
7274
"gulp-zip": "^3.2.0",
7375
"imagemin-pngquant": "^4.2.2",
7476
"lodash": "^4.5.1",
7577
"postcss-pxtorem": "^3.3.1",
7678
"posthtml-px2rem": "^0.0.3",
79+
"qiniu": "^6.1.11",
7780
"rc": "^1.1.6",
7881
"rd": "^0.0.2",
7982
"tmt-ejs-helper": "^0.0.1",
80-
"vinyl-fs": "^2.4.3"
83+
"weflow-imagemin": "^0.0.3",
84+
"weflow-rev-all": "^0.0.1"
8185
}
8286
}

src/_tasks/dev.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ const ejs = require('gulp-ejs');
55
const ejshelper = require('tmt-ejs-helper');
66
const async = require('async');
77
const gulp = require('gulp');
8+
const gulpif = require('gulp-if');
89
const less = require('gulp-less');
910
const lazyImageCSS = require('gulp-lazyimagecss'); // 自动为图片样式添加 宽/高/background-size 属性
1011
const postcss = require('gulp-postcss'); // CSS 预处理
1112
const posthtml = require('gulp-posthtml'); // HTML 预处理
1213
const sass = require('gulp-sass');
14+
const babel = require('gulp-babel');
1315
const Common = require(path.join(__dirname, '../common.js'));
1416

17+
1518
function dev(projectPath, log, callback) {
1619

1720
const bs = require('browser-sync').create(); // 自动刷新浏览器
@@ -33,11 +36,10 @@ function dev(projectPath, log, callback) {
3336
}
3437
}
3538

36-
3739
let paths = {
3840
src: {
3941
dir: path.join(projectPath, './src'),
40-
img: path.join(projectPath, './src/img/**/*.{JPG,jpg,png,gif}'),
42+
img: path.join(projectPath, './src/img/**/*.{JPG,jpg,png,gif,svg}'),
4143
slice: path.join(projectPath, './src/slice/**/*.png'),
4244
js: path.join(projectPath, './src/js/**/*.js'),
4345
media: path.join(projectPath, './src/media/**/*'),
@@ -51,7 +53,8 @@ function dev(projectPath, log, callback) {
5153
dev: {
5254
dir: path.join(projectPath, './dev'),
5355
css: path.join(projectPath, './dev/css'),
54-
html: path.join(projectPath, './dev/html')
56+
html: path.join(projectPath, './dev/html'),
57+
js: path.join(projectPath, './dev/js')
5558
}
5659
};
5760

@@ -101,7 +104,7 @@ function dev(projectPath, log, callback) {
101104
function compileSass(cb) {
102105
gulp.src(paths.src.sass)
103106
.pipe(sass())
104-
.on('error', function(error){
107+
.on('error', function (error) {
105108
console.log(error.message);
106109
log(error.message);
107110
})
@@ -141,6 +144,24 @@ function dev(projectPath, log, callback) {
141144
})
142145
}
143146

147+
//编译 JS
148+
function compileJs(cb) {
149+
gulp.src(paths.src.js)
150+
.pipe(babel({
151+
presets: ['es2015', 'stage-2']
152+
}))
153+
.pipe(gulp.dest(paths.dev.js))
154+
.on('end', function () {
155+
if (cb) {
156+
console.log('compile JS success.');
157+
log('compile JS success.');
158+
cb();
159+
} else {
160+
reloadHandler();
161+
}
162+
})
163+
}
164+
144165
//监听文件
145166
function watch(cb) {
146167
var watcher = gulp.watch([
@@ -314,7 +335,7 @@ function dev(projectPath, log, callback) {
314335
copyHandler('slice', cb);
315336
},
316337
function (cb) {
317-
copyHandler('js', cb);
338+
compileJs(cb);
318339
},
319340
function (cb) {
320341
copyHandler('media', cb);

0 commit comments

Comments
 (0)