-
Notifications
You must be signed in to change notification settings - Fork 37
/
Gruntfile.coffee
151 lines (134 loc) · 3.64 KB
/
Gruntfile.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
'use strict'
module.exports = (grunt) ->
pkg = grunt.file.readJSON 'package.json'
concatOptions =
process:
data: pkg
shellOptions =
stdout: true
stderr: true
failOnError: true
# Project configuration.
grunt.initConfig
pkg: pkg
concat:
style:
options: concatOptions
files:
'tmp/style.css': 'src/style.js'
userscript:
options: concatOptions
files:
'builds/<%= pkg.name %>.meta.js': 'src/meta/metadata.js'
'builds/<%= pkg.name %>.user.js': [
'src/meta/botproc.js'
'src/meta/metadata.js'
'src/script.js'
]
crx:
options: concatOptions
files:
'builds/crx/manifest.json': 'src/meta/manifest.json'
'builds/crx/script.js': [
'src/meta/botproc.js'
'src/script.js'
]
# css:
# options: concatOptions
# src: [
# 'test.css'
# ]
# dest: 'tmp/styleMain.css'
#
# coffee:
# options: concatOptions
# src: [
# 'test.coffee'
# ]
# dest: 'tmp/script.coffee'
#
# coffee:
# script:
# src: 'tmp/main.coffee'
# dest: 'tmp/script.js'
#
cssmin:
minify:
src: 'tmp/style.css'
dest: 'tmp/style.min.css'
shell:
commit:
options: shellOptions
command: [
'git checkout <%= pkg.meta.mainBranch %>',
'git commit -am "Release <%= pkg.meta.name %> v<%= pkg.version %>."',
'git tag -a <%= pkg.version %> -m "<%= pkg.meta.name %> v<%= pkg.version %>."',
'git tag -af stable -m "<%= pkg.meta.name %> v<%= pkg.version %>."'
].join(' && ')
stdout: true
push:
options: shellOptions
command: 'git push origin --tags -f && git push origin --all'
compress:
crx:
options:
archive: 'builds/OneeChan-Chrome.zip'
level: 9
pretty: true
expand: true
cwd: 'builds/crx/'
src: '**'
clean:
tmp: 'tmp/'
grunt.loadNpmTasks 'grunt-bump'
# grunt.loadNpmTasks 'grunt-concurrent'
grunt.loadNpmTasks 'grunt-contrib-clean'
# grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-compress'
grunt.loadNpmTasks 'grunt-contrib-concat'
# grunt.loadNpmTasks 'grunt-contrib-copy'
grunt.loadNpmTasks 'grunt-shell'
grunt.loadNpmTasks 'grunt-contrib-cssmin'
grunt.registerTask 'default', [
'build'
]
grunt.registerTask 'build', [
'concat:style'
'cssmin:minify'
'concat:crx'
'concat:userscript'
'clean:tmp'
]
grunt.registerTask 'release', [
'default'
'compress:crx'
'shell:commit'
'shell:push'
]
grunt.registerTask 'patch', [
'bump-only'
'reloadPkg'
'updcl:3'
]
grunt.registerTask 'minor', [
'bump-only:minor'
'reloadPkg'
'updcl:2'
]
grunt.registerTask 'major', [
'bump-only:major'
'reloadPkg'
'updcl:1'
]
grunt.registerTask 'reloadPkg', 'Reload the package', ->
# Update the `pkg` object with the new version.
pkg = grunt.file.readJSON('package.json')
grunt.config.data.pkg = concatOptions.process.data = pkg
grunt.log.ok('pkg reloaded.')
grunt.registerTask 'updcl', 'Update the changelog', (i) ->
# i is the number of #s for markdown.
version = []
version.length = +i + 1
version = version.join('#') + ' v' + pkg.version + '\n*' + grunt.template.today('yyyy-mm-dd') + '*\n'
grunt.file.write 'CHANGELOG.md', version + '\n' + grunt.file.read('CHANGELOG.md')
grunt.log.ok 'Changelog updated for v' + pkg.version + '.'