-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
128 lines (115 loc) · 4.29 KB
/
Gruntfile.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
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
var fs = require('fs'),
Release = require('./tasks/Release'),
versionReal = grunt.option('ver') || '',
versionPlus = versionReal.split('.').map(function(part, index) {
return index === 0 ? Number(part) + 1 : part;
}).join('.'),
jsonFiles = ['package.json', 'bower.json'],
ibem = 'i-bem.js',
ibemmin = 'i-bem.min.js',
releaseBranch = 'release-' + versionPlus,
releaseTag = 'v' + versionPlus;
grunt.initConfig({
clean: {
githooks: ['.git/hooks/*'],
test: ['!test/tmp/.gitkeep', 'test/tmp/*'],
jsdoc: ['jsdoc'],
release: ['release']
},
shell: {
install: { command: 'bower install git://github.com/bem/bem-core#' + versionReal },
make: { command: 'npm run make' },
addJSONFiles: { command: 'git add ' + jsonFiles.join(' ') },
commitJSONFiles: { command: 'git commit -m "' + releaseTag + '"' },
addReleaseBranch: { command: 'git checkout -b ' + releaseBranch },
addBuildFiles: { command: 'git add -f ' + ibem + ' ' + ibemmin },
commitBuildFiles: { command: 'git commit -m "' + releaseTag + '"' },
tag: { command: 'git tag ' + releaseTag },
removeReleaseBranch: { command: 'git checkout master && git branch -D ' + releaseBranch },
mergeBemBlToMaster: { command: 'git merge --no-ff bem-core -m "' + releaseTag + '"' },
push: {
command: function() {
return grunt.config('isReleaseOk')
? 'git push origin master bem-core ' + releaseTag
: '';
}
}
},
prompt: {
removeDomReady: {
options: {
questions: [
{
config: 'isRemoveDomReady',
type: 'confirm',
default: false,
message: 'Please remove $.ready from ./i-bem/i-bem.js \n' +
'https://github.com/bem/bem-core/blob/v2.6.0/common.blocks/i-bem/__dom/i-bem__dom.js#L227'
}
]
}
},
release: {
options: {
questions: [
{
config: 'isReleaseOk',
type: 'confirm',
default: false,
message: 'Please check is everything alright'
}
]
}
}
},
uglify: {
release: {
options: {
preserveComments: 'some'
},
files: { 'i-bem/i-bem.min.js': 'i-bem/i-bem.js' }
}
},
copy: {
ibem: {
src: 'i-bem/i-bem.js',
dest: ibem
},
ibemmin: {
src: 'i-bem/i-bem.min.js',
dest: ibemmin
}
},
mochaTest: {
test: {
options: {
reporter: 'spec',
require: './test/helpers/chai-assert.js'
},
src: ['test/*.js']
}
}
});
grunt.registerTask('test', ['shell:make', 'mochaTest:test']);
grunt.registerTask('release', function() {
if(!versionReal) throw new Error('Parameter --ver must be set!');
new Release(versionReal, versionPlus).setJsDoc().updateJsonFiles(jsonFiles);
grunt.task.run('shell:install', 'shell:make');
grunt.task.run('test');
grunt.task.run('prompt:removeDomReady');
grunt.task.run('uglify:release', 'copy');
grunt.task.run('shell:addJSONFiles', 'shell:commitJSONFiles');
grunt.task.run(
'shell:addReleaseBranch',
'shell:addBuildFiles',
'shell:commitBuildFiles',
'shell:tag',
'shell:removeReleaseBranch',
'shell:mergeBemBlToMaster',
'prompt:release',
'shell:push'
);
});
};