-
Notifications
You must be signed in to change notification settings - Fork 16
/
Gruntfile.js
215 lines (192 loc) · 6.68 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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
filename: 'ng-sharepoint',
banner: ['/*',
' * <%= pkg.name %>',
' * <%= pkg.homepage %>',
' * <%= pkg.author.name %> - <%= pkg.author.company %>',
' * Version: <%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>',
' * License: <%= pkg.license %>',
' */\n'
].join('\n'),
uglify: {
options: {
banner: '<%= banner %>'
},
build: {
//src: ['src/**/*.js', '!src/libs/**/*.js'],
src: ['build/<%= pkg.name %>.js'],
dest: 'build/<%= pkg.name %>.min.js'
}
},
concat: {
options: {
separator: '\n'
},
ngSharePoint: {
src: [
'src/utils/**/*.js',
'src/camlhelper/**/*.js',
'src/sharepoint/ng-sharepoint.js',
'src/sharepoint/services/**/*.js',
'src/sharepoint/directives/**/*.js',
'src/sharepoint/filters/**/*.js',
'src/sharepoint/ng-sharepoint-formpage.js'
],
dest: 'build/<%= pkg.name %>.js'
}
},
jshint: {
all: ['Gruntfile.js', 'src/**/*.js', '!src/libs/**/*.js'],
beforeconcat: ['src/**/*.js'],
afterconcat: ['build/*.js'],
options: {
newcap: false //-> http://www.jshint.com/docs/options/#newcap
}
},
html2js: {
sharepoint: {
options: {
// custom options, see below
module: 'ngSharePoint.templates',
base: './ui/sharepoint'
},
src: ['ui/sharepoint/templates/**/*.html'],
dest: 'build/<%= pkg.name %>.sharepoint.templates.js'
},
bootstrap: {
options: {
// custom options, see below
module: 'ngSharePoint.templates',
base: './ui/bootstrap'
},
src: ['ui/bootstrap/templates/**/*.html'],
dest: 'build/<%= pkg.name %>.bootstrap.templates.js'
}
},
ngdocs: {
options: {
dest: 'docs',
scripts: ['angular.js'],
html5Mode: false,
startPage: '/api/ngSharePoint',
title: "ng-SharePoint",
image: "ui/logo-kaldeera.png",
imageLink: "https://github.com/Kaldeera/ng-SharePoint",
titleLink: "/api/ngSharePoint",
bestMatch: true,
/*
analytics: {
account: 'UA-08150815-0',
domainName: 'kaldeera.com'
},
discussions: {
shortName: 'my',
url: 'http://www.kaldeera.com',
dev: false
}
*/
},
/*
tutorial: {
src: ['documents/tutorials/*.ngdoc'],
title: 'Tutorial'
},
*/
api: {
src: ['src/**/*.js'],
title: 'API Reference'
}
},
less: {
GenericStyles: {
options: {
compress: true,
optimization: 2
},
files: [
{'build/ng-sharepoint.min.css': 'ui/sharepoint/css/ng-sharepoint.less'},
]
}
},
watch: {
files: 'ui/sharepoint/css/**/*',
tasks: ['less:GenericStyles']
}
});
/*
grunt.event.on('watch', function(action, filepath, target) {
});
*/
// Load plugins
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-html2js');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-ngdocs');
grunt.loadNpmTasks('grunt-contrib-watch');
// Default task(s).
grunt.registerTask('docs', ['ngdocs']);
// grunt.registerTask('publishcdn', ['copy']);
grunt.registerTask('debug', ['concat']);
grunt.registerTask('documentation', ['ngdocs']);
grunt.registerTask('styles', ['less:GenericStyles']);
grunt.registerTask('rebuild', ['watch']);
grunt.registerTask('default', [
'jshint:all',
'concat:ngSharePoint',
'uglify',
'less:GenericStyles',
'html2js:sharepoint'
]);
grunt.registerTask('publish-pages', 'Publish a clean build, docs, and sample to github.io', function() {
promising(this,
ensureCleanMaster().then(function() {
shjs.rm('-rf', 'build');
return system('git checkout gh-pages');
}).then(function() {
return system('git merge master');
}).then(function() {
return system('grunt ngdocs');
}).then(function() {
return system('git commit -a -m \'Automatic gh-pages build\'');
}).then(function() {
return system('git push origin gh-pages');
}).then(function() {
return system('git checkout master');
})
);
});
var exec = require('faithful-exec'),
shjs = require('shelljs');
function system(cmd) {
grunt.log.write('% ' + cmd + '\n');
return exec(cmd).then(function(result) {
grunt.log.write(result.stderr + result.stdout);
}, function(error) {
grunt.log.write(error.stderr + '\n');
throw 'Failed to run \'' + cmd + '\'';
});
}
function ensureCleanMaster() {
return exec('git symbolic-ref HEAD').then(function(result) {
if (result.stdout.trim() !== 'refs/heads/master') throw 'Not on master branch, aborting';
return exec('git status --porcelain');
}).then(function(result) {
if (result.stdout.trim() !== '') throw 'Working copy is dirty, aborting';
});
}
function promising(task, promise) {
var done = task.async();
promise.then(function() {
done();
}, function(error) {
grunt.log.write(error + '\n');
done(false);
});
}
};