This repository has been archived by the owner on Apr 18, 2023. It is now read-only.
forked from GoteoFoundation/goteo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
177 lines (149 loc) · 4.82 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
//
// Goteo
// Gruntfile.js
//
// # Folder Paths
// to match only one level down:
// 'test/spec/{,*/}*.js'
// to recursively match all subfolders:
// 'test/spec/**/*.js'
//
GOTEO = {
app: 'public',
templates: 'Resources/templates',
src: 'src',
dist: 'dist',
localHost: '0.0.0.0',
localPort:8081,
livePort:35729,
// to override this parameter, simply copy:
// var/php/php.ini file to config/php.ini
// and edit it with your own data
phpINI: 'var/php/php.ini',
configFile: process.env.GOTEO_CONFIG_FILE || 'config/settings.yml'
};
module.exports = function(grunt) {
if( ! grunt.file.exists(GOTEO.configFile)) {
grunt.log.fail( '################################################\n' +
'Please configure a settings file with this name:\n' +
GOTEO.configFile + '\n\n' +
'You can use the config/demo-settings.yml as a sample file\n' +
'################################################\n'
);
}
if( grunt.file.exists('config/php.ini')) {
GOTEO.phpINI = '../config/php.ini';
}
var config = grunt.file.readYAML(GOTEO.configFile);
var localHost = config.url.main;
var urlParts = localHost.split(':');
var host = urlParts[urlParts.length - 2];
if(host) {
host = host.substring(host.indexOf('//') + 2);
GOTEO.localHost = host;
grunt.log.warn('Using Host from settings: ' + host);
}
var port = parseInt(urlParts[urlParts.length - 1], 10);
if(port) {
GOTEO.localPort = port;
grunt.log.warn('Using local port from settings: ' + port);
}
var livePort = parseInt(config.livePort, 10);
if(livePort) {
GOTEO.livePort = livePort;
grunt.log.warn('Using livePort from settings: ' + livePort);
}
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
settings: config,
//config values
goteo: GOTEO
});
// show elapsed time at the end
require('time-grunt')(grunt);
// Load per-task config from separate files.
grunt.loadTasks('grunt');
// some non-configured tasks
grunt.loadNpmTasks('grunt-newer');
grunt.loadNpmTasks('grunt-notify');
// Default task. Just linter
grunt.registerTask('default', ['lint']);
grunt.registerTask('lint', ['jshint', 'phplint']);
// PRE-COMMIT ready hook
// $ cd {repo}
// $ nano .git/hooks/pre-commit
//
// #!/bin/sh
// grunt precommit
//
// $ chmod +x .git/hooks/pre-commit
grunt.registerTask('precommit', ['newer:jshint', 'newer:phplint']);
// SERVER
// The server task is used to "start a server". If you are using php's built-in
// web server for development testing, it will be started up. We'll start watching
// any files that need to be watched for changes, and open a browser to our dev URL
grunt.registerTask('serve', function (target) {
if (target === 'dist') {
return grunt.task.run([
'build:dist',
'php:dist:keepalive']);
}
if (target === 'devel') {
return grunt.task.run([
'clean:server',
'build:devel',
'php:dist:keepalive']);
}
grunt.task.run([
'clean:server',
'copy:devel',
'copy:plugins:devel',
'sass:devel',
'php:livereload',
'watch'
]);
});
grunt.registerTask('server', function () {
grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
grunt.task.run(['serve']);
});
grunt.registerTask('build:dist', [
'build'
]);
// Build the dist folder without compression (useful for apache/nginx servers pointing that dir)
grunt.registerTask('build:devel', [
'clean:dist',
'copy:dist',
'copy:plugins:dist',
'copy:fonts',
'sass:dist'
]);
//build and uploads
grunt.registerTask('deploy', function(){
grunt.task.run(['build']);
if(grunt.config.get('settings').filesystem.handler === 's3') {
grunt.task.run(['aws_s3']);
}
});
grunt.registerTask('build', [
'clean:dist',
// 'newer:jshint',
// 'newer:phplint',
'copy:devel', // copy assets to .tmp for postprocessing
'sass:devel',
'copy:plugins:devel',
'copy:dist', // copy from to dist as well
'copy:plugins:dist',
'copy:fonts',
'sass:dist',
'useminPrepare',
// 'imagemin',
'concat:generated',
'cssmin:dist', // manually minify css
'uglify:dist', // manually minify js
'filerev:dist',
'usemin'
]);
};