-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
134 lines (116 loc) · 3.5 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
129
130
131
132
'use strict';
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var clean = require('gulp-clean');
var concat = require('gulp-concat');
var ngAnnotate = require('gulp-ng-annotate');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var stripDebug = require('gulp-strip-debug');
var runSequence = require('run-sequence');
var gutil = require('gulp-util');
var browserSync = require('browser-sync');
var deploy = require('gulp-gh-pages');
var Dgeni = require('dgeni');
var del = require('del');
// source directives and services
var srcJsFiles = 'src/**/*.js';
// lint source javascript files
gulp.task('lint', function() {
return gulp.src(srcJsFiles)
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
// clean built copies of javascript files
// from dist folder and docs
gulp.task('clean', function() {
return gulp.src(['dist', 'docs/lib'])
.pipe(clean({force: true}));
});
// concatenate and minify source javascript files
// and copy into dist folder and docs
gulp.task('build-js', function() {
return gulp.src([
'src/services/esriLoader.js',
'src/services/esriRegistry.js',
'src/directives/esriMap.js',
'src/directives/esriFeatureLayer.js',
'src/directives/esriLegend.js'])
.pipe(concat('angular-esri-map.js'))
.pipe(gulp.dest('dist'))
.pipe(gulp.dest('docs/lib'))
.pipe(stripDebug())
.pipe(ngAnnotate())
.pipe(uglify())
.pipe(rename('angular-esri-map.min.js'))
.pipe(gulp.dest('dist'))
.on('error', gutil.log);
});
// lint then clean and build javascript
gulp.task('build', function(callback) {
runSequence('lint', 'clean', 'build-js', callback);
});
// serve docs on local web server
// and reload anytime source code or docs are modified
gulp.task('serve', ['build'], function() {
browserSync({
server: {
baseDir: ['docs', 'test']
},
open: true,
port: 9002,
notify: false
});
gulp.watch([srcJsFiles,'./docs/**.*.html', './docs/app/**/*.js', './docs/styles/*.css'], ['build', browserSync.reload ]);
});
// deploy to github pages
gulp.task('deploy', ['build'], function () {
return gulp.src(['./docs/**/*', './test/**/*'])
.pipe(deploy());
});
// deploy to Esri's github pages
gulp.task('deploy-prod', ['build'], function () {
return gulp.src(['./docs/**/*', './test/**/*'])
.pipe(deploy({
remoteUrl: 'https://github.com/Esri/angular-esri-map.git'
}));
});
// Default Task
gulp.task('default', ['serve']);
// Dgeni Tasks
gulp.task('dgeni-build',['clean-docs'], function() {
try {
var dgeni = new Dgeni([require('./myDgeni/docs/config/dgeni-conf')]);
return dgeni.generate();
} catch(x) {
console.log(x.stack);
throw x;
}
});
// remove doc related documents
gulp.task('clean-docs', function() {
return del([
// 'dist/mydgeni/docs/**',
'dist/mydgeni/docs/**'
]);
});
// important task: copy site resources to the app folder; images, styles, app.js
// !myDgeni/docs/app/js/**/*.txt is for exclusion.
gulp.task('doc-resources', ['dgeni-build'], function() {
return gulp.src(['myDgeni/docs/app/**/*', '!myDgeni/docs/app/js/**/*.txt'])
.pipe(gulp.dest('dist/mydgeni/docs/app'));
});
// run doc generation
gulp.task('dgeni', ['clean-docs', 'dgeni-build', 'doc-resources']);
// serve docs on local web server
// and reload anytime source code or docs are modified
gulp.task('dgeni:serve', ['dgeni'], function() {
browserSync({
server: {
baseDir: ['dist/mydgeni/docs/app']
},
open: true,
port: 9001,
notify: false
});
});