Skip to content

Commit 1fefd04

Browse files
committed
chore: remove upload to CDN task
1 parent efc91e0 commit 1fefd04

File tree

4 files changed

+47
-206
lines changed

4 files changed

+47
-206
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,3 @@ npm install leancloud-storage@2 --save
6868
5. 使用 GitHub 基于 dist 分支发布一个 release
6969
6. Fetch and checkout remote `dist` branch 并确认该提交的内容是即将发布的版本
7070
7. npm publish(`npm publish`,需 npm 协作者身份),如果是 pre-release 版本需要带 next tag
71-
8. 发布到 CDN,需要七牛权限(执行 `gulp upload`

gulpfile.babel.js

Lines changed: 14 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,43 @@
11
/**
22
* 每位工程师都有保持代码优雅的义务
33
* Each engineer has a duty to keep the code elegant
4-
**/
4+
**/
55

6-
import path from 'path';
7-
import qiniu from 'qiniu';
8-
import fs from 'fs';
96
import gulp from 'gulp';
107
import clean from 'gulp-clean';
118
import babel from 'gulp-babel';
129
import shell from 'gulp-shell';
13-
import { version } from './package.json';
14-
15-
const uploadCDN = (file) => {
16-
qiniu.conf.ACCESS_KEY = process.env.CDN_QINIU_KEY;
17-
qiniu.conf.SECRET_KEY = process.env.CDN_QINIU_SECRET;
18-
if (!qiniu.conf.ACCESS_KEY || !qiniu.conf.SECRET_KEY) {
19-
throw new Error('Need Qiniu CDN_QINIU_KEY and CDN_QINIU_SECRET');
20-
}
21-
const bucketname = 'paas_files';
22-
const key = `static/js/${version}/${path.basename(file)}`;
23-
const putPolicy = new qiniu.rs.PutPolicy(bucketname + ':' + key);
24-
const uptoken = putPolicy.token();
25-
const extra = new qiniu.io.PutExtra();
26-
extra.mimeType = 'application/javascript';
27-
const buffer = fs.readFileSync(file);
28-
qiniu.io.put(uptoken, key, buffer, extra, (err, ret) => {
29-
if (!err) {
30-
console.log('https://cdn1.lncld.net/' + ret.key);
31-
} else {
32-
console.log(err);
33-
}
34-
});
35-
return file;
36-
};
3710

3811
gulp.task('clean-dist', () =>
39-
gulp.src([
40-
'dist/**/*.*',
41-
]).pipe(clean({
42-
force: true
43-
}))
12+
gulp.src(['dist/**/*.*']).pipe(
13+
clean({
14+
force: true,
15+
})
16+
)
4417
);
4518

4619
// 编译浏览器版本
47-
gulp.task('bundle-browser', ['clean-dist'], shell.task('npm run build:browser'));
20+
gulp.task(
21+
'bundle-browser',
22+
['clean-dist'],
23+
shell.task('npm run build:browser')
24+
);
4825
gulp.task('bundle-rn', ['clean-dist'], shell.task('npm run build:rn'));
4926
gulp.task('bundle-weapp', ['clean-dist'], shell.task('npm run build:weapp'));
5027

5128
// 编译出 Node 版本
5229
gulp.task('babel-node', ['clean-dist'], () => {
53-
return gulp.src('src/**/*.js')
30+
return gulp
31+
.src('src/**/*.js')
5432
.pipe(babel())
5533
.pipe(gulp.dest('dist/node/'));
5634
});
5735

58-
// 上传到 CDN
59-
gulp.task('upload', () => {
60-
[
61-
'./dist/av-min.js',
62-
'./dist/av-weapp-min.js',
63-
'./dist/av.js',
64-
'./dist/av-weapp.js',
65-
'./dist/av-live-query-min.js',
66-
'./dist/av-live-query-weapp-min.js',
67-
'./dist/av-live-query.js',
68-
'./dist/av-live-query-weapp.js',
69-
].map(uploadCDN).map(file => `${file}.map`).map(uploadCDN);
70-
});
71-
7236
// 生成 release 文件
7337
gulp.task('build', [
7438
'clean-dist',
7539
'bundle-browser',
7640
'bundle-rn',
7741
'bundle-weapp',
78-
'babel-node'
42+
'babel-node',
7943
]);

0 commit comments

Comments
 (0)