This repository has been archived by the owner on Apr 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathgulpfile.js
88 lines (77 loc) · 2.3 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
var gulp = require('gulp');
var concat = require('gulp-concat');
var template = require('gulp-ng-templates');
var rename = require('gulp-rename');
var ngAnnotate = require('gulp-ng-annotate');
var uglify = require('gulp-uglify');
var gulp = require('gulp');
var git = require('gulp-git');
var bump = require('gulp-bump');
var filter = require('gulp-filter');
var tag_version = require('gulp-tag-version');
var minifyHtml = require("gulp-minify-html");
//Build Vars
var ionicTemplates = 'templates-ionic';
var prebuildDir = '.tmp';
var finalName = 'angular-formly-templates-ionic';
gulp.task('default', ['build']);
gulp.task('template', function() {
return gulp.src('src/fields/*html')
//.pipe(htmlmin({collapseWhitespace: true}))
.pipe(minifyHtml({
empty: false,
spare: true,
quotes: true
}))
.pipe(template({
filename: ionicTemplates + ".js",
module: 'formlyIonic',
path: function(path, base) {
return path.replace(base, 'fields/');
},
header: 'angular.module("<%= module %>").run(["$templateCache", function($templateCache) {'
}))
.pipe(gulp.dest('.tmp'));
});
// Then save the main provider in the same tmp dir
gulp.task('mkSrc', function() {
return gulp.src('./src/modules/*.js')
// .pipe(concat('all.js'))
.pipe(gulp.dest('./.tmp/'));
});
gulp.task('build', ['template', 'mkSrc'], function() {
return gulp.src('./.tmp/*.js')
.pipe(ngAnnotate())
.pipe(concat(finalName + ".js"))
.pipe(gulp.dest('./dist'))
.pipe(uglify())
.pipe(rename({
extname: '.min.js'
}))
.pipe(gulp.dest('./dist'));
});
function inc(importance) {
// get all the files to bump version in
return gulp.src(['./package.json', './bower.json'])
// bump the version number in those files
.pipe(bump({
type: importance
}))
// save it back to filesystem
.pipe(gulp.dest('./'))
// commit the changed version number
.pipe(git.commit('bumps package version'))
// read only one file to get the version number
.pipe(filter('package.json'))
// **tag it in the repository**
.pipe(tag_version());
}
gulp.task('patch', ['build'], function() {
return inc('patch');
});
gulp.task('minor', ['build'], function() {
return inc('minor');
});
gulp.task('major', ['build'], function() {
return inc('major');
});