This repository has been archived by the owner on Sep 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
162 lines (146 loc) · 4 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
'use strict';
var path = require('path');
var fs = require('fs');
var _ = require('lodash-node');
var glob = require('glob');
var address = require('address');
function getJadeData(env) {
function getFilesInPath(pattern, removePrefix) {
var files = glob.sync(pattern);
_.each(files, function (file, num) {
files[num] = file.substring(removePrefix.length);
});
return files;
}
function getSection(root, name) {
var appJs = getFilesInPath(root + name + '/app.js', root);
var otherJsFiles = getFilesInPath(root + name + '/**/*.js', root);
return _.union(appJs, otherJsFiles);
}
function getBSJSCommon() {
var root = 'www/';
var path = 'bower_components/bs-js-common/bs.common.';
var models = getSection(root, path + 'models');
var services = getSection(root, path + 'services');
var filters = getSection(root, path + 'filters');
var directives = getSection(root, path + 'directives');
return _.union(['bower_components/bs-js-common/app.js'], models, services, filters, directives);
}
function getAppSection(name) {
return getSection('www/', 'js/' + name);
}
var styles = _.union([
'bower_components/ionic/release/css/ionic.css'
], getFilesInPath('www/css/*.css', 'www/'));
var scripts = _.union([
'bower_components/jquery/dist/jquery.js',
'bower_components/lodash/dist/lodash.js',
'bower_components/momentjs/moment.js',
'bower_components/ionic/release/js/ionic.bundle.js',
'bower_components/angular-resource/angular-resource.js',
'bower_components/angular-sanitize/angular-sanitize.js'
], getBSJSCommon(), getAppSection('components'), getAppSection('main'));
// Must be added last!
scripts.push('cordova.js');
var data = {
onDev: false,
BASE_URL: 'http://www.bucketstreams.com',
basicAuth: '',
stylesheets: styles,
scripts: scripts
};
if (/local/.test(env)) {
data.onDev = true;
data.BASE_URL = 'http://local.bucketstreams.com:3000';
// data.BASE_URL = 'http://' + address.ip() + ':3000';
data.basicAuth = 'Basic Z3Vlc3Q6YnVja2V0c3RyZWFtc3JvY2tzIQ==';
} else if (/alpha/.test(env)) {
data.onDev = true;
data.BASE_URL = 'http://alpha.bucketstreams.com';
data.basicAuth = 'Basic Z3Vlc3Q6SVMgaXMgdGhlIHRydXRo';
}
return data;
}
module.exports = function (grunt) {
grunt.initConfig({
jade: {
local: {
options: {
data: function() {
return getJadeData('local');
},
pretty: true
},
files: {
'www/index.html': ['builder/index.jade']
}
},
alpha: {
options: {
data: function() {
return getJadeData('alpha');
},
pretty: true
},
files: {
'www/index.html': ['builder/index.jade']
}
}
},
stylus: {
compile: {
options: {
linenos: true
},
files: {
'www/css/styles.css': [
'builder/stylus/imports.styl'
]
}
}
},
watch: {
builder: {
files: ['builder/**', 'Gruntfile.js'],
tasks: 'builder'
}
},
'http-server': {
dev: {
root: 'www',
port: 3001,
host: 'mobile.local.bucketstreams.com',
cache: -1
}
},
shell: {
runAndroid: {
options: {
stdout: true
},
command: 'cordova run android'
}
}
});
grunt.loadNpmTasks('grunt-contrib-stylus');
grunt.loadNpmTasks('grunt-contrib-jade');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-http-server');
grunt.loadNpmTasks('grunt-shell');
grunt.registerTask('builder', [
'stylus:compile',
'jade:local',
'watch'
]);
grunt.registerTask('default', [
'builder'
]);
grunt.registerTask('deploy', [
'stylus:compile',
'jade:alpha',
'shell:runAndroid'
]);
grunt.registerTask('server', 'Running http-server and watcher', function() {
grunt.task.run('watch', 'http-server');
});
};