forked from SAP/openui5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
208 lines (182 loc) · 5.13 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
/*
* Copyright (c) 2014-2018 SAP SE
*/
'use strict';
var path = require('path');
var moment = require('moment');
var semver = require('semver');
module.exports = function(grunt) {
// Force unix linefeeds (see https://github.com/gruntjs/grunt/issues/1123)
// (grunt uses grunt.util.normalizelf when processing templates)
grunt.util.linefeed = '\n';
// Log time how long tasks take
require('grunt-timer').init(grunt, {
deferLogs: true,
color: 'cyan'
});
// Check for valid required Node.js version from package.json
// npm does not validate this within the project itself; only if this project would be installed as a dependency (which is not the case as of now)
var pkg = grunt.file.readJSON(__dirname + "/package.json");
if (pkg.engines && pkg.engines.node && !semver.satisfies(process.version, pkg.engines.node)) {
grunt.log.error('!!! WARNING !!!');
grunt.log.error('Unsupported Node.js version: wanted "' + pkg.engines.node + '" (current: "' + process.version + '")');
grunt.log.error('Please update your Node.js installation!');
}
// Load all custom tasks from grunt/tasks dir
grunt.loadTasks(path.join(process.cwd(), 'grunt/tasks'));
// set default options
grunt.option('production', grunt.option('production') || false);
if (typeof grunt.option('minify-css') === 'undefined') {
grunt.option('minify-css', grunt.option('production'));
}
if (typeof grunt.option('include-test-resources') === 'undefined') {
grunt.option('include-test-resources', grunt.option('no-production'));
}
// set of libraries to use (e.g. --libs=sap.ui.core)
var libsOption = grunt.option('libs');
var libs = libsOption ? libsOption.split(',') : null;
// the gruntdata contains the configuration for the build part
// we distinguish here between a testsuite which is an application
// and the libraries which are the re-use modules
var gruntData = {
buildtime: moment().utc().format('YYYYMMDDHHmmss'),
lastchange: '',
testsuite: {
name: 'testsuite',
path: 'src/testsuite'
},
allLibraries: [
{
name: 'sap.ui.core',
path: 'src/sap.ui.core',
preload: {
src: [
'*.js',
// files are already part of sap-ui-core.js
'!sap/ui/thirdparty/es6-promise.js',
'!jquery.sap.global.js',
'!sap-ui-*.js',
'sap/ui/core/**',
'!sap/ui/core/cldr/**',
'!sap/ui/core/messagebundle*',
'sap/ui/base/**',
'sap/ui/model/**',
'sap/ui/Global.js'
]
}
},
{
name: 'sap.ui.unified',
path: 'src/sap.ui.unified'
},
{
name: 'sap.ui.layout',
path: 'src/sap.ui.layout'
},
{
name: 'sap.m',
path: 'src/sap.m'
},
{
name: 'sap.tnt',
path: 'src/sap.tnt'
},
{
name: 'sap.f',
path: 'src/sap.f'
},
{
name: 'sap.ui.commons',
path: 'src/sap.ui.commons'
},
{
name: 'sap.ui.table',
path: 'src/sap.ui.table'
},
{
name: 'sap.ui.ux3',
path: 'src/sap.ui.ux3'
},
{
name: 'sap.ui.suite',
path: 'src/sap.ui.suite'
},
{
name: 'sap.ui.documentation',
path: 'src/sap.ui.documentation'
},
{
name: 'sap.ui.dt',
path: 'src/sap.ui.dt'
},
{
name: 'sap.uxap',
path: 'src/sap.uxap'
},
{
name: 'sap.ui.fl',
path: 'src/sap.ui.fl'
},
{
name: 'sap.ui.codeeditor',
path: 'src/sap.ui.codeeditor'
},
{
name: 'sap.ui.support',
path: 'src/sap.ui.support'
},
{
name: 'sap.ui.rta',
path: 'src/sap.ui.rta'
},
{
name: 'themelib_sap_bluecrystal',
path: 'src/themelib_sap_bluecrystal',
type: 'theme'
},
{
name: 'themelib_sap_belize',
path: 'src/themelib_sap_belize',
type: 'theme'
},
{
name: 'sap.ui.demokit',
path: 'src/sap.ui.demokit',
bower: false // exclude from bower publish
}
]
};
// Load config extension script to allow overrides to "grunt" and "gruntData"
var configExtensionFile = grunt.option("config-extension");
if (configExtensionFile) {
configExtensionFile.split(',').forEach(file => require(path.resolve(file))(grunt, gruntData));
}
// Normalize all library 'path' to individual 'src' and 'test' paths
gruntData.allLibraries.forEach(function(library) {
library.src = library.src || library.path + "/src";
library.test = library.test || library.path + "/test";
});
// determine set of libraries to use (specified by --libs option)
gruntData.libraries = !libs ? gruntData.allLibraries : gruntData.allLibraries.filter(function(library) {
return libs.indexOf(library.name) > -1;
});
// Load all grunt config files (in grunt subfolder) and all tasks installed via npm
require('load-grunt-config')(grunt, {
configPath: path.join(process.cwd(), 'grunt/config'),
// loads grunt plugins just-in-time (faster than using load-grunt-tasks)
jitGrunt: {
staticMappings: {
'replace': 'grunt-text-replace',
'openui5_connect': 'grunt-openui5',
'openui5_theme': 'grunt-openui5',
'openui5_preload': 'grunt-openui5',
'gitclone': 'grunt-git',
'gitadd': 'grunt-git',
'gitcommit': 'grunt-git',
'gittag': 'grunt-git',
'gitpush': 'grunt-git'
}
},
data: gruntData
});
};