forked from akveo/digitsquare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
116 lines (105 loc) · 3.9 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
module.exports = function(grunt) {
function deepExtend(dst) {
var args = [].slice.call(arguments);
args.forEach(function(obj) {
if (obj !== dst) {
for (var key in obj) {
var value = obj[key];
if (dst[key] && dst[key].constructor && dst[key].constructor === Object) {
deepExtend(dst[key], value);
} else {
dst[key] = value;
}
}
}
});
return dst;
}
function extendConfigs() {
var configs = [].slice.call(arguments).map(function(name) {
return grunt.file.readJSON('config/config.' + name + '.json');
});
return deepExtend.apply(null, configs);
}
var templatesDirs = ['index.html', 'views/**/*.html'],
fontsDir = ['fonts/*'],
jsDirs = 'js/**/*js';
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
build: {
files: {
'www/css/style.css': 'sass/index.scss'
}
}
},
watch: {
scss: {
files: ['sass/**/*.scss'],
tasks: ['sass:build']
}
},
bower: {
install: {
options: {
targetDir: './www/lib',
layout: function(type, pkg) { return type; },
install: true,
verbose: false,
cleanTargetDir: true,
cleanBowerDir: false,
bowerOptions: {}
}
}
},
exec: {
signAndroid: {
command: 'cp my-release-key.keystore platforms/android/ant-build/;' +
'cd platforms/android/ant-build/;' +
'jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore -storepass 123456 -keypass 123456 MainActivity-release-unsigned.apk alias_name;' +
'jarsigner -verify -verbose -certs MainActivity-release-unsigned.apk;' +
'$ANDROID_HOME/build-tools/android-4.4W/zipalign -f -v 4 MainActivity-release-unsigned.apk MainActivity-release-signed-aligned.apk;' +
'cd ../../..'
},
buildAndroid: {
command: 'cordova build android --release'
},
buildIos: {
command: 'phonegap build ios --release'
}
},
ngconstant: {
options: {
dest: 'www/js/config.js',
name: 'app.config',
wrap: '\'use strict\';\n' +
'\n' +
'define(["angular"], function(angular) {\n' +
' return {%= __ngModule %}\n' +
'\n});'
},
dev: {
constants: {
'appConfig': extendConfigs('base', 'dev')
}
},
prod: {
constants: {
'appConfig': extendConfigs('base', 'prod')
}
}
}
});
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-bower-task');
grunt.loadNpmTasks('grunt-exec');
grunt.loadNpmTasks('grunt-ng-constant');
var envo = grunt.option('envo') || 'dev';
grunt.registerTask('copyConfig', ['ngconstant:' + envo]);
grunt.registerTask('buildAssets', ['copyConfig', 'bower:install', 'sass:build']);
grunt.registerTask('src-watch',['buildAssets', 'watch']);
grunt.registerTask('build-android', ['buildAssets', 'exec:buildAndroid', 'exec:signAndroid']);
grunt.registerTask('build-ios', ['buildAssets', 'exec:buildIos']);
};