This repository has been archived by the owner on Sep 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Gruntfile.js
225 lines (214 loc) · 6.51 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
216
217
218
219
220
221
222
// requires
var shell = require("shelljs");
var path = require('path');
var fs = require('fs');
// grunt
module.exports = function(grunt) {
grunt.initConfig({
// apps
run_grunt: {
source_apps: {
options: {
log: true,
task: ["source"],
process: function(res) {
if (res.fail) {
grunt.log.writeln('Error during building (source version of) all applications');
}
}
},
src: ['application/play/Gruntfile.js', "application/mobileshowcase/Gruntfile.js"]
},
source_modules: {
options: {
log: true,
task: ["source"],
process: function(res) {
if (res.fail) {
grunt.log.writeln('Error during building (source version of) all modules');
}
}
},
src: ["framework/Gruntfile.js"]
},
source_testsuite: {
options: {
log: true,
task: ["source", "html"],
process: function(res) {
if (res.fail) {
grunt.log.writeln('Error during building (source version of) test suite');
}
}
},
src: ["framework/source/test/Gruntfile.js"]
},
build_apps: {
options: {
log: true,
task: ["build"],
process: function(res) {
if (res.fail) {
grunt.log.writeln('Error during building all applications');
}
}
},
src: ['application/play/Gruntfile.js', "application/mobileshowcase/Gruntfile.js"]
},
build_modules: {
options: {
log: true,
task: ["build"],
process: function(res) {
if (res.fail) {
grunt.log.writeln('Error during building all modules');
}
}
},
src: ["framework/Gruntfile.js"]
},
build_testsuite: {
options: {
log: true,
task: ["build", "html"],
process: function(res) {
if (res.fail) {
grunt.log.writeln('Error during building test suite');
}
}
},
src: ["framework/source/test/Gruntfile.js"]
},
clean_apps: {
options: {
log: true,
task: ["clean:app"],
process: function(res) {
if (res.fail) {
grunt.log.writeln('Error during cleaning all applications');
}
}
},
src: ['application/play/Gruntfile.js', "application/mobileshowcase/Gruntfile.js"]
},
clean_modules: {
options: {
log: true,
task: ["clean:app"],
process: function(res) {
if (res.fail) {
grunt.log.writeln('Error during cleaning all modules');
}
}
},
src: ["framework/Gruntfile.js"]
},
eslint_apps: {
options: {
log: true,
task: ["eslint:default"],
process: function(res) {
if (res.fail) {
grunt.log.writeln('Error during eslinting all applications');
}
}
},
src: [
"application/play/Gruntfile.js",
"application/mobileshowcase/Gruntfile.js",
"tool/grunt/Gruntfile.js",
"framework/Gruntfile.js"
]
},
}
});
// alias
grunt.registerTask('lint', 'run_grunt:eslint_apps');
grunt.registerTask('clean', ['run_grunt:clean_apps', 'run_grunt:clean_modules']);
grunt.registerTask('build', ['run_grunt:build_apps', 'run_grunt:build_modules', 'run_grunt:build_testsuite']);
grunt.registerTask('source', ['run_grunt:source_apps', 'run_grunt:source_modules', 'run_grunt:source_testsuite']);
// run toolchain tests
grunt.task.registerTask (
'test_toolchain',
'Run toolchain tests',
function() {
shell.cd('tool/grunt/');
shell.cd('eslint/eslint-plugin-qx-rules');
shell.exec('npm test');
shell.cd('../../task/package');
var packages = shell.ls('.');
packages.forEach(function(pkgPath) {
if (shell.test('-d', pkgPath)) {
shell.cd(pkgPath);
shell.exec('npm test');
shell.cd('../');
}
});
}
);
// run toolchain tasks
grunt.task.registerTask (
'run_toolchain_tasks',
'Run toolchain tasks',
function() {
shell.cd('tool/grunt/task/source');
shell.exec('grunt source');
shell.cd('../build');
shell.exec('grunt build');
shell.cd('../info');
shell.exec('grunt info');
}
);
// rm node_modules (grunt remove_node_modules <=> grunt setup)
grunt.task.registerTask (
'remove_node_modules',
'Removes all node_modules directories',
function() {
var dirs = shell.find('.').filter(function(file) {
return file.match(/node_modules$/);
}).forEach(function(path) {
shell.rm('-rf', path);
});
}
);
// setup toolchain, apps and tests (grunt setup <=> grunt remove_node_modules)
grunt.task.registerTask (
'setup',
'Setup toolchain and apps',
function() {
var rootDir = shell.pwd();
shell.cd('tool/grunt');
shell.exec('npm install');
shell.exec('node setup.js');
shell.cd('../../framework');
shell.exec('npm install');
shell.cd('../application');
var apps = shell.ls('.');
apps.forEach(function(appPath) {
shell.cd(appPath);
shell.exec('npm install');
shell.cd('../');
});
shell.cd('../framework/source/test');
shell.exec('npm install');
// symlink yeoman generator
shell.cd(rootDir);
var homeDir = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'];
var homeGeneratorPath = path.join(homeDir, 'node_modules/generator-next');
var yeomanPath = path.join(rootDir, 'tool/yeoman/generator-next');
shell.cd(yeomanPath);
shell.exec('npm install');
shell.cd(rootDir);
grunt.log.subhead("Installing yeoman generator for next");
grunt.log.oklns('Creating a symlink for next\'s yeoman generator in: ' + homeGeneratorPath);
grunt.log.oklns('If you intend to create applications outside of your home directory, '+
'run \'npm link\' (may require sudo) in: ' + yeomanPath);
if (shell.test('-L', homeGeneratorPath)) {
fs.unlinkSync(homeGeneratorPath);
}
shell.mkdir('-p', path.join(homeDir, 'node_modules'));
fs.symlinkSync(yeomanPath, homeGeneratorPath, 'dir');
}
);
grunt.loadNpmTasks('grunt-run-grunt');
};