-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
125 lines (112 loc) · 4.83 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
module.exports = function(grunt) {
var
concurrently = 'concurrently --color --kill-others',
concColMongod = 'black.bgRed.bold',
concColNode = 'black.bgGreen.bold',
concColMiddle = 'black.bgYellow.bold',
concColFront = 'black.bgBlue.bold',
concColLivereload = 'black.bgMagenta.bold',
startMongoCmd = 'mongod --config /usr/local/etc/mongod.conf',
startNodeProdCmd = 'nodemon -w build/middle build/middle/server.js',
startNodeCmd = 'NODE_ENV=dev ' + startNodeProdCmd,
buildMiddleCmd = 'tsc -p srv --pretty --preserveWatchOutput',
buildMiddleProdCmd = buildMiddleCmd,
watchMiddleCmd = buildMiddleCmd + ' --watch',
watchMiddleProdCmd = buildMiddleProdCmd + ' --watch',
lintMiddleCmd = 'tslint -p srv',
lintMiddleFixCmd = 'tslint -p srv --fix',
buildFrontCmd = 'ng build --aot --no-progress',
buildFrontProdCmd = buildFrontCmd + ' --prod --source-map',
watchFrontCmd = buildFrontCmd + ' --watch',
watchFrontProdCmd = buildFrontProdCmd + ' --watch',
lintFrontCmd = 'ng lint',
lintFrontFixCmd = 'ng lint --fix',
liveReloadCmd = 'livereload build -w 250',
clocAllCmd = 'cloc . --exclude-dir=node_modules,build --not-match-f "(package-lock.json)" --force-lang=TypeScript,ts',
clocCodeCmd = 'cloc . --exclude-dir=node_modules,build --not-match-f "(package-lock.json)|(.spec.ts)" --force-lang=TypeScript,ts',
clocTestCmd = 'cloc . --exclude-dir=node_modules,build --match-f "(.spec.ts$)" --force-lang=TypeScript,ts',
mongoClientCmd = 'mongo mean-upload-download -u sam --authenticationDatabase admin'
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Commands to parse.
exec: {
// Start servers.
serve: {
cmd: `${concurrently} -n "mongod,node,reload" -c "${concColMongod},${concColNode},${concColLivereload}" "${startMongoCmd}" "${startNodeCmd}" "${liveReloadCmd}"`
},
// Lint commands config.
lint: {
cmd: `${concurrently} -n "middle,front" -c "${concColMiddle},${concColFront}" "${lintMiddleCmd}" "${lintFrontCmd}"`
},
lint_fix: {
cmd: `${concurrently} -n "middle,front" -c "${concColMiddle},${concColFront}" "${lintMiddleCmd}" "${lintFrontCmd}"`
},
// Watch commands config.
watch_dev: {
cmd: `${concurrently} -n "mongod,node,middle,front,reload" -c "${concColMongod},${concColNode},${concColMiddle},${concColFront},${concColLivereload}" "${startMongoCmd}" "${startNodeCmd}" "${watchMiddleCmd}" "${watchFrontCmd}" "${liveReloadCmd}"`
},
watch_prod: {
cmd: `${concurrently} -n "mongod,node,middle,front,reload" -c "${concColMongod},${concColNode},${concColMiddle},${concColFront},${concColLivereload}" "${startMongoCmd}" "${startNodeProdCmd}" "${watchMiddleProdCmd}" "${watchFrontProdCmd}" "${liveReloadCmd}"`
},
// Build commands config.
build_dev: {
cmd: `echo "${buildMiddleCmd}" && ${buildMiddleCmd} && echo "${buildFrontCmd}" && ${buildFrontCmd}`
},
build_dev_middle: {
cmd: buildMiddleCmd
},
build_dev_front: {
cmd: buildFrontCmd
},
build_prod: {
cmd: `echo "${buildMiddleProdCmd}" && ${buildMiddleProdCmd} && echo "${buildFrontProdCmd}" && ${buildFrontProdCmd}`
},
build_prod_middle: {
cmd: buildMiddleProdCmd
},
build_prod_front: {
cmd: buildFrontProdCmd
},
// cloc commands config.
cloc_all: {
cmd: clocAllCmd
},
cloc_code: {
cmd: clocCodeCmd
},
cloc_test: {
cmd: clocTestCmd
},
cloc_code_and_test: {
cmd: `echo "cloc for CODE" && ${clocCodeCmd} && echo "cloc for TEST CODE" && ${clocTestCmd}`
},
// Mongo client config.
mongo_client_connect: {
cmd: `echo "Run the following command:\n${mongoClientCmd}"`
}
}
})
// Load plugins.
grunt.task.loadNpmTasks('grunt-exec')
// Load additional tasks.
//grunt.task.loadTasks('tasks')
// Create synonyms for my exec tasks.
grunt.registerTask('serve',['exec:serve'])
grunt.registerTask('lint',['exec:lint'])
grunt.registerTask('lint-fix',['exec:lint_fix'])
grunt.registerTask('watch-dev',['exec:watch_dev'])
grunt.registerTask('watch-prod',['exec:watch_prod'])
grunt.registerTask('watch',['watch-dev'])
grunt.registerTask('build-dev',['exec:build_dev'])
grunt.registerTask('build-prod',['exec:build_prod'])
grunt.registerTask('build',['build-prod'])
grunt.registerTask('cloc-all',['exec:cloc_all'])
grunt.registerTask('cloc-code',['exec:cloc_code'])
grunt.registerTask('cloc-test',['exec:cloc_test'])
grunt.registerTask('cloc-both',['exec:cloc_code_and_test'])
grunt.registerTask('cloc',['cloc-both'])
grunt.registerTask('mongo',['exec:mongo_client_connect'])
// Default task(s).
grunt.registerTask('default', ['watch'])
}