-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
128 lines (117 loc) · 3.34 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
var gulp = require('gulp'),
wiredep = require('wiredep').stream,
gulpLoadPlugins = require('gulp-load-plugins'),
uri = require('URIjs'),
s = require('underscore.string'),
hawtio = require('hawtio-node-backend');
var plugins = gulpLoadPlugins({ lazy: false });
var pkg = require('./package.json');
var config = {
src: 'plugins/**/*.js',
templates: 'plugins/**/*.html',
js: pkg.name + '.js',
template: pkg.name + '-template.js',
templateModule: pkg.name + '-template'
};
gulp.task('bower', function() {
gulp.src('index.html')
.pipe(wiredep({
}))
.pipe(gulp.dest('.'));
});
gulp.task('templates', function() {
return gulp.src(config.templates)
.pipe(plugins.angularTemplatecache({
filename: 'templates.js',
root: 'plugins/',
standalone: true,
module: config.templateModule,
templateFooter: '}]); hawtioPluginLoader.addModule("' + config.templateModule + '");'
}))
.pipe(gulp.dest('.'));
});
gulp.task('concat', ['templates'], function() {
return gulp.src([config.src, './templates.js'])
.pipe(plugins.concat(config.js))
.pipe(gulp.dest('./dist/'));
});
gulp.task('clean', ['concat'], function() {
return gulp.src('./templates.js', { read: false })
.pipe(plugins.clean());
});
gulp.task('connect', function() {
plugins.watch([config.src, config.templates], function() {
gulp.start('build');
});
plugins.watch(['libs/**/*.js', 'libs/**/*.css', 'index.html', 'dist/' + config.js], function() {
gulp.start('reload');
});
/*
* Example of fetching a URL from the environment, in this case for kubernetes
var kube = uri(process.env.KUBERNETES_MASTER || 'http://localhost:8080');
console.log("Connecting to Kubernetes on: " + kube);
*/
hawtio.setConfig({
port: 2772,
staticProxies: [
{
port: 8778,
path: '/jolokia',
targetPath: '/jolokia'
}
/*
// proxy to a service, in this case kubernetes
{
proto: kube.protocol(),
port: kube.port(),
hostname: kube.hostname(),
path: '/services/kubernetes',
targetPath: kube.path()
},
// proxy to a jolokia instance
{
proto: kube.protocol(),
hostname: kube.hostname(),
port: kube.port(),
path: '/jolokia',
targetPath: '/hawtio/jolokia'
}
*/
],
staticAssets: [{
path: '/',
dir: '.'
}],
fallback: 'index.html',
liveReload: {
enabled: true
}
});
/*
* Example middleware that returns a 404 for templates
* as they're already embedded in the js
hawtio.use('/', function(req, res, next) {
var path = req.originalUrl;
// avoid returning these files, they should get pulled from js
if (s.startsWith(path, '/plugins/') && s.endsWith(path, 'html')) {
console.log("returning 404 for: ", path);
res.statusCode = 404;
res.end();
} else {
console.log("allowing: ", path);
next();
}
});
*/
hawtio.listen(function(server) {
var host = server.address().address;
var port = server.address().port;
console.log("started from gulp file at ", host, ":", port);
});
});
gulp.task('reload', function() {
gulp.src('.')
.pipe(hawtio.reload());
});
gulp.task('build', ['templates', 'concat', 'clean']);
gulp.task('default', ['build', 'connect']);