This repository has been archived by the owner on Apr 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
/
gulpfile.js
107 lines (87 loc) · 2.9 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Lib path
var path = require('path');
var lib = process.env.AZK_LIB_PATH || 'lib';
var azk_gulp = require('azk-dev/lib/gulp')({
cwd : __dirname,
src : { src: "./src" , dest: path.join(lib, "/azk") },
spec : { src: "./spec", dest: path.join(lib, "/spec") },
mocha: { timeout: 10000 },
lint : [ "bin/**/*.js" ],
});
// Load gulp
var gulp = azk_gulp.gulp;
// Load envs from .env files
var dotenv = require('dotenv');
dotenv.load({ silent: true });
gulp.on('task_start', function(e) {
if (e.task === 'test') {
process.env.AZK_ENV = "test";
}
});
var integration_src = [
'src/**/*.js',
'spec/**/*.js',
'spec/integration/**/*.bats',
'spec/integration/**/*.bash',
];
gulp.task('lint:babel', "Run lint and babel after this", ['lint', 'babel']);
gulp.task('test:integration', "Run integration tests", ['lint:babel'], function() {
var filter = 'find spec/integration -name \'*.bats\'';
if (azk_gulp.yargs.argv.grep) {
filter = 'grep -Rl "' + azk_gulp.yargs.argv.grep + '" spec/integration';
}
var command = lib + '/bats/bin/bats `' + filter + '`';
var stream = azk_gulp.shell(command);
azk_gulp.gutil.log("running: " + azk_gulp.chalk.green(command));
stream.write(new azk_gulp.gutil.File());
stream.end();
return stream;
});
azk_gulp.new_watch('watch:test:integration', integration_src, {}, ['test:integration']);
// Publish packages
gulp.task('publish', function() {
var awspublish = require('gulp-awspublish');
var parallelize = require("concurrent-transform");
var rename = require("gulp-rename");
var gulpif = require("gulp-if");
var path_join = require('path').join;
// Select bucket
var bucket = process.env[
"AWS_PACKAGE_BUCKET_" + (azk_gulp.yargs.argv.production ? "PROD" : "STAGE")
];
// create a new publisher
var publisher = awspublish.create({
params: {
Bucket: bucket,
},
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_KEY,
region: 'sa-east-1',
});
// define custom headers
var headers = {
'Cache-Control': 'max-age=31536000, no-transform, public',
};
var src = [
'package/brew/*.tar.gz',
'package/public/!(fedora20)/**/*',
'package/fedora20/**/*',
'package/public/!(fedora23)/**/*',
'package/fedora23/**/*',
];
var add_prefix = function(cond, prefix) {
return gulpif(cond, rename(function (path) {
path.dirname = path_join(prefix, path.dirname);
}));
};
return gulp.src(src)
// Set dest path
.pipe(add_prefix(/package\/fedora20/, 'fedora20'))
.pipe(add_prefix(/package\/fedora23/, 'fedora23'))
.pipe(add_prefix(/package\/brew/, 'mac'))
// publisher will add Content-Length, Content-Type and headers specified above
// If not specified it will set x-amz-acl to public-read by default
.pipe(parallelize(publisher.publish(headers), 10))
// print upload updates to console
.pipe(awspublish.reporter());
});