This repository has been archived by the owner on Jun 3, 2023. It is now read-only.
forked from sc-date-time/sc-date-time
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.coffee
155 lines (140 loc) · 4.11 KB
/
gulpfile.coffee
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# dependencies
fs = require 'fs'
path = require 'path'
gulp = require 'gulp'
git = require 'gulp-git'
bump = require 'gulp-bump'
filter = require 'gulp-filter'
tag_version = require 'gulp-tag-version'
del = require 'del'
concat = require 'gulp-concat-util'
order = require 'gulp-order'
rename = require 'gulp-rename'
runSequence = require 'run-sequence'
changelog = require 'conventional-changelog'
stylus = require 'gulp-stylus'
autoprefixer = require 'gulp-autoprefixer'
coffee = require 'gulp-coffee'
coffeelint = require 'gulp-coffeelint'
jade = require 'gulp-jade'
ngtemplate = require 'gulp-ngtemplate'
htmlmin = require 'gulp-htmlmin'
gulp.task 'clean:dist', (cb) -> del ['dist/*'], cb
gulp.task 'compile:jade', ['clean:dist'], ->
gulp.src ['./src/*.jade']
.pipe jade
pretty: true
.pipe rename
prefix: 'scDateTime-'
extname: '.tpl'
.pipe gulp.dest 'dist'
.pipe htmlmin collapseWhitespace: true
.pipe ngtemplate module: 'scDateTime'
.pipe rename extname: '.tpl.temp' # for temp file cleanup
.pipe gulp.dest 'dist'
gulp.task 'compile:coffee', ['compile:jade'], ->
gulp.src ['./src/main.coffee']
# Lint the coffescript
.pipe coffeelint()
.pipe coffeelint.reporter()
.pipe coffeelint.reporter 'fail'
.pipe coffee bare: true
.pipe rename 'sc-date-time.js'
.pipe gulp.dest 'dist'
gulp.task 'compile:javascript', ['compile:coffee'], ->
pkg = JSON.parse fs.readFileSync './package.json', 'utf8'
gulp.src ['./dist/sc-date-time.js','./dist/*.tpl.temp']
.pipe order ['dist/sc-date-time.js','dist/*.tpl.temp']
.pipe concat 'sc-date-time.js'
.pipe concat.header """/*
@license sc-date-time
@author SimeonC
@license 2015 MIT
@version #{pkg.version}
See README.md for requirements and use.
*/
"""
.pipe gulp.dest 'dist'
gulp.task 'compile:stylus', ['clean:dist'], ->
pkg = JSON.parse fs.readFileSync './package.json', 'utf8'
gulp.src ['./src/styles.styl']
.pipe stylus()
.pipe autoprefixer()
.pipe concat()
.pipe concat.header """/*
@license sc-date-time
@author SimeonC
@license 2015 MIT
@version #{pkg.version}
See README.md for requirements and use.
*/
"""
.pipe rename 'sc-date-time.css'
.pipe gulp.dest 'dist'
gulp.task 'compile:main', ['compile:javascript','compile:stylus']
gulp.task 'compile', ['compile:main'], (cb) -> del ['dist/*.temp'], cb
###
Bumping version number and tagging the repository with it.
You can use the commands
gulp prerel # makes v0.1.0 -> v0.1.1-pre1
gulp patch # makes v0.1.0 → v0.1.1
gulp minor # makes v0.1.1 → v0.2.0
gulp major # makes v0.2.1 → v1.0.0
To bump the version numbers accordingly after you did a patch,
introduced a feature or made a backwards-incompatible release.
###
releaseVersion = (importance) ->
# get all the files to bump version in
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 './'
gulp.task 'tagversion', ->
gulp.src ['./package.json','./bower.json','./changelog.md','./dist/*']
# commit the changed version number
.pipe git.commit 'chore(release): Bump Version Number'
# Filter down to only one file
.pipe filter 'package.json'
# **tag it in the repository**
.pipe tag_version()
gulp.task 'changelog', (cb) ->
pkg = JSON.parse fs.readFileSync './package.json', 'utf8'
changelog
version: pkg.version
repository: pkg.repository.url
, (err, content) ->
fs.writeFile './changelog.md', content, cb
gulp.task 'release:prerel', -> releaseVersion 'prerelease'
gulp.task 'release:patch', -> releaseVersion 'patch'
gulp.task 'release:minor', -> releaseVersion 'minor'
gulp.task 'release:major', -> releaseVersion 'major'
gulp.task 'prerel', ->
runSequence(
'release:prerel'
, 'changelog'
, 'compile'
, 'tagversion'
)
gulp.task 'patch', ->
runSequence(
'release:patch'
, 'changelog'
, 'compile'
, 'tagversion'
)
gulp.task 'minor', ->
runSequence(
'release:minor'
, 'changelog'
, 'compile'
, 'tagversion'
)
gulp.task 'major', ->
runSequence(
'release:major'
, 'changelog'
, 'compile'
, 'tagversion'
)
gulp.task 'default', ['compile']