weboptimizer 2.0.1235 → 2.0.1237
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser.js +20 -62
- package/configurator.js +53 -126
- package/ejsLoader.js +8 -52
- package/helper.js +53 -198
- package/index.js +31 -167
- package/jestEnvironmentBrowser.js +1 -12
- package/jestSetup.js +5 -7
- package/package.json +9 -2
- package/stylelintConfigurator.js +1 -6
- package/type.js +4 -4
- package/webpackConfigurator.js +99 -244
package/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
3
|
/** @module weboptimizer */
|
|
5
4
|
'use strict';
|
|
5
|
+
|
|
6
6
|
/* !
|
|
7
7
|
region header
|
|
8
8
|
[Project page](https://torben.website/webOptimizer)
|
|
@@ -18,54 +18,31 @@
|
|
|
18
18
|
endregion
|
|
19
19
|
*/
|
|
20
20
|
// region imports
|
|
21
|
-
|
|
22
21
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
23
|
-
|
|
24
22
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
25
|
-
|
|
26
23
|
Object.defineProperty(exports, "__esModule", {
|
|
27
24
|
value: true
|
|
28
25
|
});
|
|
29
26
|
exports["default"] = void 0;
|
|
30
|
-
|
|
31
27
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
32
|
-
|
|
33
28
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
34
|
-
|
|
35
29
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
36
|
-
|
|
37
30
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
38
|
-
|
|
39
31
|
var _child_process = require("child_process");
|
|
40
|
-
|
|
41
32
|
var _clientnode = _interopRequireWildcard(require("clientnode"));
|
|
42
|
-
|
|
43
33
|
var _fs = require("fs");
|
|
44
|
-
|
|
45
34
|
var _promises = require("fs/promises");
|
|
46
|
-
|
|
47
35
|
var _path = _interopRequireWildcard(require("path"));
|
|
48
|
-
|
|
49
36
|
var _rimraf = _interopRequireWildcard(require("rimraf"));
|
|
50
|
-
|
|
51
37
|
var _configurator = require("./configurator");
|
|
52
|
-
|
|
53
38
|
var _helper = _interopRequireDefault(require("./helper"));
|
|
54
|
-
|
|
55
39
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
56
|
-
|
|
57
40
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
58
|
-
|
|
59
41
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
60
|
-
|
|
61
42
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
62
|
-
|
|
63
43
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
64
|
-
|
|
65
44
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
66
|
-
|
|
67
45
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
68
|
-
|
|
69
46
|
// endregion
|
|
70
47
|
// NOTE: Environment variables can only be strings.
|
|
71
48
|
process.env.UV_THREADPOOL_SIZE = '128';
|
|
@@ -80,14 +57,13 @@ process.env.UV_THREADPOOL_SIZE = '128';
|
|
|
80
57
|
*
|
|
81
58
|
* @returns Nothing.
|
|
82
59
|
*/
|
|
83
|
-
|
|
84
60
|
var main = /*#__PURE__*/function () {
|
|
85
61
|
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(context) {
|
|
86
62
|
var currentWorkingDirectory,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
63
|
+
commandLineArguments,
|
|
64
|
+
webOptimizerPath,
|
|
65
|
+
environment,
|
|
66
|
+
_args4 = arguments;
|
|
91
67
|
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
92
68
|
while (1) {
|
|
93
69
|
switch (_context4.prev = _context4.next) {
|
|
@@ -107,7 +83,6 @@ var main = /*#__PURE__*/function () {
|
|
|
107
83
|
_context3.prev = 2;
|
|
108
84
|
return _context3.delegateYield( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
109
85
|
var processOptions, childProcessOptions, childProcesses, processPromises, possibleArguments, closeEventHandlers, dynamicConfiguration, count, filePath, additionalArguments, _iterator, _step, file, _iterator2, _step2, _filePath, _iterator3, _step3, filePathPattern, buildConfigurations, tidiedUp, tidyUp, testModuleFilePaths, _iterator9, _step9, buildConfiguration, expression, _iterator10, _step10, _filePath6, handleTask, finished, closeHandler, _iterator14, _step14, closeEventName;
|
|
110
|
-
|
|
111
86
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
112
87
|
while (1) {
|
|
113
88
|
switch (_context2.prev = _context2.next) {
|
|
@@ -125,12 +100,10 @@ var main = /*#__PURE__*/function () {
|
|
|
125
100
|
processPromises = [];
|
|
126
101
|
possibleArguments = ['build', 'build:types', 'clear', 'document', 'lint', 'preinstall', 'serve', 'test', 'test:browser', 'test:coverage', 'test:coverage:report', 'check:types'];
|
|
127
102
|
closeEventHandlers = [];
|
|
128
|
-
|
|
129
103
|
if (!(configuration.givenCommandLineArguments.length > 2)) {
|
|
130
104
|
_context2.next = 74;
|
|
131
105
|
break;
|
|
132
106
|
}
|
|
133
|
-
|
|
134
107
|
// region temporary save dynamically given configurations
|
|
135
108
|
// NOTE: We need a copy of given arguments array.
|
|
136
109
|
dynamicConfiguration = {
|
|
@@ -139,47 +112,38 @@ var main = /*#__PURE__*/function () {
|
|
|
139
112
|
if (configuration.givenCommandLineArguments.length > 3 && _clientnode["default"].stringParseEncodedObject(configuration.givenCommandLineArguments[configuration.givenCommandLineArguments.length - 1], configuration, 'configuration')) configuration.givenCommandLineArguments.pop();
|
|
140
113
|
count = 0;
|
|
141
114
|
filePath = (0, _path.resolve)(configuration.path.context, ".dynamicConfiguration-".concat(count, ".json"));
|
|
142
|
-
|
|
143
115
|
case 11:
|
|
144
116
|
if (!true) {
|
|
145
117
|
_context2.next = 20;
|
|
146
118
|
break;
|
|
147
119
|
}
|
|
148
|
-
|
|
149
120
|
filePath = (0, _path.resolve)(configuration.path.context, ".dynamicConfiguration-".concat(count, ".json"));
|
|
150
121
|
_context2.next = 15;
|
|
151
122
|
return _clientnode["default"].isFile(filePath);
|
|
152
|
-
|
|
153
123
|
case 15:
|
|
154
124
|
if (_context2.sent) {
|
|
155
125
|
_context2.next = 17;
|
|
156
126
|
break;
|
|
157
127
|
}
|
|
158
|
-
|
|
159
128
|
return _context2.abrupt("break", 20);
|
|
160
|
-
|
|
161
129
|
case 17:
|
|
162
130
|
count += 1;
|
|
163
131
|
_context2.next = 11;
|
|
164
132
|
break;
|
|
165
|
-
|
|
166
133
|
case 20:
|
|
167
134
|
_context2.next = 22;
|
|
168
135
|
return (0, _promises.writeFile)(filePath, JSON.stringify(dynamicConfiguration));
|
|
169
|
-
|
|
170
136
|
case 22:
|
|
171
137
|
additionalArguments = commandLineArguments.splice(3); /// region register exit handler to tidy up
|
|
172
|
-
|
|
173
138
|
clear = function clear(error) {
|
|
174
139
|
// NOTE: Close handler have to be synchronous.
|
|
175
140
|
if (_clientnode["default"].isFileSync(filePath)) (0, _fs.unlinkSync)(filePath);
|
|
176
141
|
if (error) throw error;
|
|
177
142
|
};
|
|
178
|
-
|
|
179
|
-
|
|
143
|
+
closeEventHandlers.push(clear);
|
|
144
|
+
/// endregion
|
|
180
145
|
// endregion
|
|
181
146
|
// region handle clear
|
|
182
|
-
|
|
183
147
|
/*
|
|
184
148
|
NOTE: Some tasks could depend on previously created artefacts
|
|
185
149
|
packages so a preceding clear should not be performed in that
|
|
@@ -187,22 +151,18 @@ var main = /*#__PURE__*/function () {
|
|
|
187
151
|
NOTE: If we have a dependency cycle we need to preserve files
|
|
188
152
|
during pre-install phase.
|
|
189
153
|
*/
|
|
190
|
-
|
|
191
154
|
if (!(!['build', 'build:types', 'preinstall', 'serve', 'test', 'test:browser', 'test:coverage', 'test:coverage:report'].includes(configuration.givenCommandLineArguments[2]) && possibleArguments.includes(configuration.givenCommandLineArguments[2]))) {
|
|
192
155
|
_context2.next = 64;
|
|
193
156
|
break;
|
|
194
157
|
}
|
|
195
|
-
|
|
196
158
|
if (!((0, _path.resolve)(configuration.path.target.base) === (0, _path.resolve)(configuration.path.context))) {
|
|
197
159
|
_context2.next = 53;
|
|
198
160
|
break;
|
|
199
161
|
}
|
|
200
|
-
|
|
201
162
|
_context2.next = 29;
|
|
202
163
|
return _clientnode["default"].walkDirectoryRecursively(configuration.path.target.base, /*#__PURE__*/function () {
|
|
203
164
|
var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(file) {
|
|
204
165
|
var type, _file$stats;
|
|
205
|
-
|
|
206
166
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
207
167
|
while (1) {
|
|
208
168
|
switch (_context.prev = _context.next) {
|
|
@@ -215,30 +175,23 @@ var main = /*#__PURE__*/function () {
|
|
|
215
175
|
_context.next = 2;
|
|
216
176
|
break;
|
|
217
177
|
}
|
|
218
|
-
|
|
219
178
|
return _context.abrupt("return", false);
|
|
220
|
-
|
|
221
179
|
case 2:
|
|
222
180
|
_context.t0 = _regenerator["default"].keys(configuration.buildContext.types);
|
|
223
|
-
|
|
224
181
|
case 3:
|
|
225
182
|
if ((_context.t1 = _context.t0()).done) {
|
|
226
183
|
_context.next = 15;
|
|
227
184
|
break;
|
|
228
185
|
}
|
|
229
|
-
|
|
230
186
|
type = _context.t1.value;
|
|
231
|
-
|
|
232
187
|
if (!new RegExp(configuration.buildContext.types[type].filePathPattern).test(file.path)) {
|
|
233
188
|
_context.next = 13;
|
|
234
189
|
break;
|
|
235
190
|
}
|
|
236
|
-
|
|
237
191
|
if (!((_file$stats = file.stats) !== null && _file$stats !== void 0 && _file$stats.isDirectory())) {
|
|
238
192
|
_context.next = 10;
|
|
239
193
|
break;
|
|
240
194
|
}
|
|
241
|
-
|
|
242
195
|
_context.next = 9;
|
|
243
196
|
return new Promise(function (resolve, reject) {
|
|
244
197
|
return (0, _rimraf["default"])(file.path, {
|
|
@@ -247,21 +200,16 @@ var main = /*#__PURE__*/function () {
|
|
|
247
200
|
return error ? reject(error) : resolve();
|
|
248
201
|
});
|
|
249
202
|
});
|
|
250
|
-
|
|
251
203
|
case 9:
|
|
252
204
|
return _context.abrupt("return", false);
|
|
253
|
-
|
|
254
205
|
case 10:
|
|
255
206
|
_context.next = 12;
|
|
256
207
|
return (0, _promises.unlink)(file.path);
|
|
257
|
-
|
|
258
208
|
case 12:
|
|
259
209
|
return _context.abrupt("break", 15);
|
|
260
|
-
|
|
261
210
|
case 13:
|
|
262
211
|
_context.next = 3;
|
|
263
212
|
break;
|
|
264
|
-
|
|
265
213
|
case 15:
|
|
266
214
|
case "end":
|
|
267
215
|
return _context.stop();
|
|
@@ -269,67 +217,50 @@ var main = /*#__PURE__*/function () {
|
|
|
269
217
|
}
|
|
270
218
|
}, _callee);
|
|
271
219
|
}));
|
|
272
|
-
|
|
273
220
|
return function (_x2) {
|
|
274
221
|
return _ref3.apply(this, arguments);
|
|
275
222
|
};
|
|
276
223
|
}());
|
|
277
|
-
|
|
278
224
|
case 29:
|
|
279
225
|
_context2.t0 = _createForOfIteratorHelper;
|
|
280
226
|
_context2.next = 32;
|
|
281
227
|
return _clientnode["default"].walkDirectoryRecursively(configuration.path.target.base, function () {
|
|
282
228
|
return false;
|
|
283
229
|
}, configuration.encoding);
|
|
284
|
-
|
|
285
230
|
case 32:
|
|
286
231
|
_context2.t1 = _context2.sent;
|
|
287
232
|
_iterator = (0, _context2.t0)(_context2.t1);
|
|
288
233
|
_context2.prev = 34;
|
|
289
|
-
|
|
290
234
|
_iterator.s();
|
|
291
|
-
|
|
292
235
|
case 36:
|
|
293
236
|
if ((_step = _iterator.n()).done) {
|
|
294
237
|
_context2.next = 43;
|
|
295
238
|
break;
|
|
296
239
|
}
|
|
297
|
-
|
|
298
240
|
file = _step.value;
|
|
299
|
-
|
|
300
241
|
if (!file.name.startsWith('npm-debug')) {
|
|
301
242
|
_context2.next = 41;
|
|
302
243
|
break;
|
|
303
244
|
}
|
|
304
|
-
|
|
305
245
|
_context2.next = 41;
|
|
306
246
|
return (0, _promises.unlink)(file.path);
|
|
307
|
-
|
|
308
247
|
case 41:
|
|
309
248
|
_context2.next = 36;
|
|
310
249
|
break;
|
|
311
|
-
|
|
312
250
|
case 43:
|
|
313
251
|
_context2.next = 48;
|
|
314
252
|
break;
|
|
315
|
-
|
|
316
253
|
case 45:
|
|
317
254
|
_context2.prev = 45;
|
|
318
255
|
_context2.t2 = _context2["catch"](34);
|
|
319
|
-
|
|
320
256
|
_iterator.e(_context2.t2);
|
|
321
|
-
|
|
322
257
|
case 48:
|
|
323
258
|
_context2.prev = 48;
|
|
324
|
-
|
|
325
259
|
_iterator.f();
|
|
326
|
-
|
|
327
260
|
return _context2.finish(48);
|
|
328
|
-
|
|
329
261
|
case 51:
|
|
330
262
|
_context2.next = 55;
|
|
331
263
|
break;
|
|
332
|
-
|
|
333
264
|
case 53:
|
|
334
265
|
_context2.next = 55;
|
|
335
266
|
return new Promise(function (resolve, reject) {
|
|
@@ -339,17 +270,14 @@ var main = /*#__PURE__*/function () {
|
|
|
339
270
|
return error ? reject(error) : resolve();
|
|
340
271
|
});
|
|
341
272
|
});
|
|
342
|
-
|
|
343
273
|
case 55:
|
|
344
274
|
_context2.next = 57;
|
|
345
275
|
return _clientnode["default"].isDirectory(configuration.path.apiDocumentation);
|
|
346
|
-
|
|
347
276
|
case 57:
|
|
348
277
|
if (!_context2.sent) {
|
|
349
278
|
_context2.next = 60;
|
|
350
279
|
break;
|
|
351
280
|
}
|
|
352
|
-
|
|
353
281
|
_context2.next = 60;
|
|
354
282
|
return new Promise(function (resolve, reject) {
|
|
355
283
|
return (0, _rimraf["default"])(configuration.path.apiDocumentation, {
|
|
@@ -358,14 +286,13 @@ var main = /*#__PURE__*/function () {
|
|
|
358
286
|
return error ? reject(error) : resolve();
|
|
359
287
|
});
|
|
360
288
|
});
|
|
361
|
-
|
|
362
289
|
case 60:
|
|
363
290
|
_iterator2 = _createForOfIteratorHelper(configuration.path.tidyUpOnClear);
|
|
364
|
-
|
|
365
291
|
try {
|
|
366
292
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
367
293
|
_filePath = _step2.value;
|
|
368
|
-
if (_filePath) if (_clientnode["default"].isFileSync(_filePath))
|
|
294
|
+
if (_filePath) if (_clientnode["default"].isFileSync(_filePath))
|
|
295
|
+
// NOTE: Close handler have to be synchronous.
|
|
369
296
|
(0, _fs.unlinkSync)(_filePath);else if (_clientnode["default"].isDirectorySync(_filePath)) (0, _rimraf.sync)(_filePath, {
|
|
370
297
|
glob: false
|
|
371
298
|
});
|
|
@@ -375,9 +302,7 @@ var main = /*#__PURE__*/function () {
|
|
|
375
302
|
} finally {
|
|
376
303
|
_iterator2.f();
|
|
377
304
|
}
|
|
378
|
-
|
|
379
305
|
_iterator3 = _createForOfIteratorHelper(configuration.path.tidyUpOnClearGlobs.pattern);
|
|
380
|
-
|
|
381
306
|
try {
|
|
382
307
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
383
308
|
filePathPattern = _step3.value;
|
|
@@ -388,7 +313,6 @@ var main = /*#__PURE__*/function () {
|
|
|
388
313
|
} finally {
|
|
389
314
|
_iterator3.f();
|
|
390
315
|
}
|
|
391
|
-
|
|
392
316
|
case 64:
|
|
393
317
|
// endregion
|
|
394
318
|
// region handle build
|
|
@@ -397,10 +321,8 @@ var main = /*#__PURE__*/function () {
|
|
|
397
321
|
}).filter(function (filePath) {
|
|
398
322
|
return !configuration.path.context.startsWith(filePath);
|
|
399
323
|
}), configuration["package"].main.fileNames);
|
|
400
|
-
|
|
401
324
|
if (['build', 'document', 'test', 'test:coverage', 'test:coverage:report'].includes(commandLineArguments[2])) {
|
|
402
325
|
tidiedUp = false;
|
|
403
|
-
|
|
404
326
|
tidyUp = function tidyUp() {
|
|
405
327
|
/*
|
|
406
328
|
Determines all none javaScript entities which have been
|
|
@@ -408,26 +330,20 @@ var main = /*#__PURE__*/function () {
|
|
|
408
330
|
*/
|
|
409
331
|
if (tidiedUp) return;
|
|
410
332
|
tidiedUp = true;
|
|
411
|
-
|
|
412
333
|
for (var _i = 0, _Object$entries = Object.entries(configuration.injection.entry.normalized); _i < _Object$entries.length; _i++) {
|
|
413
334
|
var _Object$entries$_i = (0, _slicedToArray2["default"])(_Object$entries[_i], 2),
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
335
|
+
chunkName = _Object$entries$_i[0],
|
|
336
|
+
chunk = _Object$entries$_i[1];
|
|
417
337
|
var _iterator4 = _createForOfIteratorHelper(chunk),
|
|
418
|
-
|
|
419
|
-
|
|
338
|
+
_step4;
|
|
420
339
|
try {
|
|
421
340
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
422
341
|
var moduleID = _step4.value;
|
|
423
|
-
|
|
424
342
|
var _filePath2 = _helper["default"].determineModuleFilePath(moduleID, configuration.module.aliases, configuration.module.replacements.normal, {
|
|
425
343
|
file: configuration.extensions.file.internal
|
|
426
344
|
}, configuration.path.context, configuration.path.source.asset.base, configuration.path.ignore, configuration.module.directoryNames, configuration["package"].main.fileNames, configuration["package"].main.propertyNames, configuration["package"].aliasPropertyNames, configuration.encoding);
|
|
427
|
-
|
|
428
345
|
var type = null;
|
|
429
346
|
if (_filePath2) type = _helper["default"].determineAssetType(_filePath2, configuration.buildContext.types, configuration.path);
|
|
430
|
-
|
|
431
347
|
if (typeof type === 'string' && configuration.buildContext.types[type]) {
|
|
432
348
|
var _filePath3 = _helper["default"].renderFilePathTemplate(_helper["default"].stripLoader(configuration.files.compose.javaScript), {
|
|
433
349
|
'[name]': chunkName
|
|
@@ -436,8 +352,6 @@ var main = /*#__PURE__*/function () {
|
|
|
436
352
|
NOTE: Close handler have to be
|
|
437
353
|
synchronous.
|
|
438
354
|
*/
|
|
439
|
-
|
|
440
|
-
|
|
441
355
|
if (configuration.buildContext.types[type].outputExtension === 'js' && _clientnode["default"].isFileSync(_filePath3)) (0, _fs.chmodSync)(_filePath3, '755');
|
|
442
356
|
}
|
|
443
357
|
}
|
|
@@ -447,14 +361,13 @@ var main = /*#__PURE__*/function () {
|
|
|
447
361
|
_iterator4.f();
|
|
448
362
|
}
|
|
449
363
|
}
|
|
450
|
-
|
|
451
364
|
var _iterator5 = _createForOfIteratorHelper(configuration.path.tidyUp),
|
|
452
|
-
|
|
453
|
-
|
|
365
|
+
_step5;
|
|
454
366
|
try {
|
|
455
367
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
456
368
|
var _filePath4 = _step5.value;
|
|
457
|
-
if (_filePath4) if (_clientnode["default"].isFileSync(_filePath4))
|
|
369
|
+
if (_filePath4) if (_clientnode["default"].isFileSync(_filePath4))
|
|
370
|
+
// NOTE: Close handler have to be synchronous.
|
|
458
371
|
(0, _fs.unlinkSync)(_filePath4);else if (_clientnode["default"].isDirectorySync(_filePath4)) (0, _rimraf.sync)(_filePath4, {
|
|
459
372
|
glob: false
|
|
460
373
|
});
|
|
@@ -464,10 +377,8 @@ var main = /*#__PURE__*/function () {
|
|
|
464
377
|
} finally {
|
|
465
378
|
_iterator5.f();
|
|
466
379
|
}
|
|
467
|
-
|
|
468
380
|
var _iterator6 = _createForOfIteratorHelper(configuration.path.tidyUpGlobs.pattern),
|
|
469
|
-
|
|
470
|
-
|
|
381
|
+
_step6;
|
|
471
382
|
try {
|
|
472
383
|
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
473
384
|
var _filePathPattern = _step6.value;
|
|
@@ -479,39 +390,36 @@ var main = /*#__PURE__*/function () {
|
|
|
479
390
|
_iterator6.f();
|
|
480
391
|
}
|
|
481
392
|
};
|
|
482
|
-
|
|
483
393
|
closeEventHandlers.push(tidyUp);
|
|
394
|
+
|
|
484
395
|
/*
|
|
485
396
|
Triggers complete asset compiling and bundles them into the
|
|
486
397
|
final productive output.
|
|
487
398
|
*/
|
|
488
|
-
|
|
489
399
|
processPromises.push(new Promise(function (resolve, reject) {
|
|
490
400
|
var commandLineArguments = (configuration.commandLine.build.arguments || []).concat(additionalArguments);
|
|
491
401
|
console.info('Running "' + ("".concat(configuration.commandLine.build.command, " ") + commandLineArguments.join(' ')).trim() + '"');
|
|
402
|
+
|
|
492
403
|
/*
|
|
493
404
|
NOTE: Take current weboptimizer's dependencies into
|
|
494
405
|
account.
|
|
495
406
|
*/
|
|
496
|
-
|
|
497
407
|
childProcessOptions.env.PATH += ":".concat(webOptimizerPath, "/node_modules/.bin");
|
|
498
408
|
var childProcess = (0, _child_process.spawn)(configuration.commandLine.build.command, commandLineArguments, childProcessOptions);
|
|
499
|
-
|
|
500
409
|
var copyAdditionalFilesAndTidyUp = function copyAdditionalFilesAndTidyUp() {
|
|
501
410
|
var _iterator7 = _createForOfIteratorHelper(configuration.files.additionalPaths),
|
|
502
|
-
|
|
503
|
-
|
|
411
|
+
_step7;
|
|
504
412
|
try {
|
|
505
413
|
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
506
414
|
var _filePath5 = _step7.value;
|
|
507
415
|
var sourcePath = (0, _path.join)(configuration.path.source.base, _filePath5);
|
|
508
|
-
var targetPath = (0, _path.join)(configuration.path.target.base, _filePath5);
|
|
416
|
+
var targetPath = (0, _path.join)(configuration.path.target.base, _filePath5);
|
|
509
417
|
|
|
418
|
+
// NOTE: Close handler have to be synchronous.
|
|
510
419
|
if (_clientnode["default"].isDirectorySync(sourcePath)) {
|
|
511
420
|
if (_clientnode["default"].isDirectorySync(targetPath)) (0, _rimraf.sync)(targetPath, {
|
|
512
421
|
glob: false
|
|
513
422
|
});
|
|
514
|
-
|
|
515
423
|
_clientnode["default"].copyDirectoryRecursiveSync(sourcePath, targetPath);
|
|
516
424
|
} else if (_clientnode["default"].isFileSync(sourcePath)) _clientnode["default"].copyFileSync(sourcePath, targetPath);
|
|
517
425
|
}
|
|
@@ -520,15 +428,11 @@ var main = /*#__PURE__*/function () {
|
|
|
520
428
|
} finally {
|
|
521
429
|
_iterator7.f();
|
|
522
430
|
}
|
|
523
|
-
|
|
524
431
|
tidyUp();
|
|
525
432
|
};
|
|
526
|
-
|
|
527
433
|
var closeHandler = _clientnode["default"].getProcessCloseHandler(resolve, reject, null, commandLineArguments[2] === 'build' ? copyAdditionalFilesAndTidyUp : tidyUp);
|
|
528
|
-
|
|
529
434
|
var _iterator8 = _createForOfIteratorHelper(_clientnode.CloseEventNames),
|
|
530
|
-
|
|
531
|
-
|
|
435
|
+
_step8;
|
|
532
436
|
try {
|
|
533
437
|
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
534
438
|
var closeEventName = _step8.value;
|
|
@@ -539,10 +443,10 @@ var main = /*#__PURE__*/function () {
|
|
|
539
443
|
} finally {
|
|
540
444
|
_iterator8.f();
|
|
541
445
|
}
|
|
542
|
-
|
|
543
446
|
childProcesses.push(childProcess);
|
|
544
447
|
return childProcesses;
|
|
545
|
-
}));
|
|
448
|
+
}));
|
|
449
|
+
// endregion
|
|
546
450
|
// region handle pre-install
|
|
547
451
|
} else if (configuration.library && configuration.givenCommandLineArguments[2] === 'preinstall') {
|
|
548
452
|
// Perform all file specific preprocessing stuff.
|
|
@@ -551,17 +455,14 @@ var main = /*#__PURE__*/function () {
|
|
|
551
455
|
file: configuration.extensions.file.internal
|
|
552
456
|
}, configuration.path.context, configuration.path.source.asset.base, configuration.path.ignore).filePaths;
|
|
553
457
|
_iterator9 = _createForOfIteratorHelper(buildConfigurations);
|
|
554
|
-
|
|
555
458
|
try {
|
|
556
459
|
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
557
460
|
buildConfiguration = _step9.value;
|
|
558
461
|
expression = buildConfiguration[configuration.givenCommandLineArguments[2]].trim();
|
|
559
462
|
_iterator10 = _createForOfIteratorHelper(buildConfiguration.filePaths);
|
|
560
|
-
|
|
561
463
|
try {
|
|
562
464
|
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
563
465
|
_filePath6 = _step10.value;
|
|
564
|
-
|
|
565
466
|
if (!testModuleFilePaths.includes(_filePath6)) {
|
|
566
467
|
(function () {
|
|
567
468
|
var evaluated = _clientnode["default"].stringEvaluate("`".concat(expression, "`"), {
|
|
@@ -572,7 +473,6 @@ var main = /*#__PURE__*/function () {
|
|
|
572
473
|
additionalArguments: additionalArguments,
|
|
573
474
|
filePath: _filePath6
|
|
574
475
|
});
|
|
575
|
-
|
|
576
476
|
if (evaluated.error) throw new Error('Error occurred during processing given ' + "command: ".concat(evaluated.error));
|
|
577
477
|
console.info("Running \"".concat(evaluated.result, "\""));
|
|
578
478
|
processPromises.push(new Promise(function (resolve, reject) {
|
|
@@ -599,37 +499,29 @@ var main = /*#__PURE__*/function () {
|
|
|
599
499
|
} finally {
|
|
600
500
|
_iterator9.f();
|
|
601
501
|
}
|
|
602
|
-
}
|
|
502
|
+
}
|
|
503
|
+
// endregion
|
|
603
504
|
// region handle remaining tasks
|
|
604
|
-
|
|
605
|
-
|
|
606
505
|
handleTask = function handleTask(type) {
|
|
607
506
|
var tasks = Array.isArray(configuration.commandLine[type]) ? configuration.commandLine[type] : [configuration.commandLine[type]];
|
|
608
|
-
|
|
609
507
|
var _iterator11 = _createForOfIteratorHelper(tasks),
|
|
610
|
-
|
|
611
|
-
|
|
508
|
+
_step11;
|
|
612
509
|
try {
|
|
613
510
|
var _loop = function _loop() {
|
|
614
511
|
var task = _step11.value;
|
|
615
|
-
|
|
616
512
|
var evaluated = _clientnode["default"].stringEvaluate(Object.prototype.hasOwnProperty.call(task, 'indicator') ? task.indicator : 'true', {
|
|
617
513
|
global: global,
|
|
618
514
|
self: configuration,
|
|
619
515
|
path: _path["default"]
|
|
620
516
|
});
|
|
621
|
-
|
|
622
517
|
if (evaluated.error) throw new Error('Error occurred during processing given task: ' + evaluated.error);
|
|
623
518
|
if (evaluated.result) processPromises.push(new Promise(function (resolve, reject) {
|
|
624
519
|
var commandLineArguments = (task.arguments || []).concat(additionalArguments);
|
|
625
520
|
console.info('Running "' + ("".concat(task.command, " ") + commandLineArguments.join(' ')).trim() + '"');
|
|
626
521
|
var childProcess = (0, _child_process.spawn)(task.command, commandLineArguments, childProcessOptions);
|
|
627
|
-
|
|
628
522
|
var closeHandler = _clientnode["default"].getProcessCloseHandler(resolve, reject);
|
|
629
|
-
|
|
630
523
|
var _iterator12 = _createForOfIteratorHelper(_clientnode.CloseEventNames),
|
|
631
|
-
|
|
632
|
-
|
|
524
|
+
_step12;
|
|
633
525
|
try {
|
|
634
526
|
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
635
527
|
var closeEventName = _step12.value;
|
|
@@ -640,12 +532,10 @@ var main = /*#__PURE__*/function () {
|
|
|
640
532
|
} finally {
|
|
641
533
|
_iterator12.f();
|
|
642
534
|
}
|
|
643
|
-
|
|
644
535
|
childProcesses.push(childProcess);
|
|
645
536
|
return childProcesses;
|
|
646
537
|
}));
|
|
647
538
|
};
|
|
648
|
-
|
|
649
539
|
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
650
540
|
_loop();
|
|
651
541
|
}
|
|
@@ -655,32 +545,24 @@ var main = /*#__PURE__*/function () {
|
|
|
655
545
|
_iterator11.f();
|
|
656
546
|
}
|
|
657
547
|
}; /// region a-/synchronous
|
|
658
|
-
|
|
659
|
-
|
|
660
548
|
if (!['document', 'test', 'test:coverage', 'test:coverage:report'].includes(configuration.givenCommandLineArguments[2])) {
|
|
661
549
|
_context2.next = 73;
|
|
662
550
|
break;
|
|
663
551
|
}
|
|
664
|
-
|
|
665
552
|
_context2.next = 70;
|
|
666
553
|
return Promise.all(processPromises);
|
|
667
|
-
|
|
668
554
|
case 70:
|
|
669
555
|
handleTask(configuration.givenCommandLineArguments[2]);
|
|
670
556
|
_context2.next = 74;
|
|
671
557
|
break;
|
|
672
|
-
|
|
673
558
|
case 73:
|
|
674
559
|
if (['build:types', 'check:types', 'lint', 'serve', 'test:browser'].includes(configuration.givenCommandLineArguments[2])) handleTask(configuration.givenCommandLineArguments[2]);
|
|
675
|
-
|
|
676
560
|
case 74:
|
|
677
561
|
finished = false;
|
|
678
|
-
|
|
679
562
|
closeHandler = function closeHandler() {
|
|
680
563
|
if (!finished) {
|
|
681
564
|
var _iterator13 = _createForOfIteratorHelper(closeEventHandlers),
|
|
682
|
-
|
|
683
|
-
|
|
565
|
+
_step13;
|
|
684
566
|
try {
|
|
685
567
|
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
686
568
|
var closeEventHandler = _step13.value;
|
|
@@ -692,12 +574,9 @@ var main = /*#__PURE__*/function () {
|
|
|
692
574
|
_iterator13.f();
|
|
693
575
|
}
|
|
694
576
|
}
|
|
695
|
-
|
|
696
577
|
finished = true;
|
|
697
578
|
};
|
|
698
|
-
|
|
699
579
|
_iterator14 = _createForOfIteratorHelper(_clientnode.CloseEventNames);
|
|
700
|
-
|
|
701
580
|
try {
|
|
702
581
|
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
703
582
|
closeEventName = _step14.value;
|
|
@@ -708,24 +587,20 @@ var main = /*#__PURE__*/function () {
|
|
|
708
587
|
} finally {
|
|
709
588
|
_iterator14.f();
|
|
710
589
|
}
|
|
711
|
-
|
|
712
|
-
|
|
590
|
+
if (require.main === module && (configuration.givenCommandLineArguments.length < 3 || !possibleArguments.includes(configuration.givenCommandLineArguments[2]))) console.info("Give one of \"".concat(possibleArguments.join('", "'), "\" as command ") + 'line argument. You can provide a json string as second ' + 'parameter to dynamically overwrite some configurations.\n');
|
|
591
|
+
// endregion
|
|
713
592
|
// region forward nested return codes
|
|
714
|
-
|
|
715
593
|
_context2.prev = 79;
|
|
716
594
|
_context2.next = 82;
|
|
717
595
|
return Promise.all(processPromises);
|
|
718
|
-
|
|
719
596
|
case 82:
|
|
720
597
|
_context2.next = 88;
|
|
721
598
|
break;
|
|
722
|
-
|
|
723
599
|
case 84:
|
|
724
600
|
_context2.prev = 84;
|
|
725
601
|
_context2.t3 = _context2["catch"](79);
|
|
726
602
|
console.error(_context2.t3);
|
|
727
603
|
process.exit(_context2.t3.returnCode);
|
|
728
|
-
|
|
729
604
|
case 88:
|
|
730
605
|
case "end":
|
|
731
606
|
return _context2.stop();
|
|
@@ -733,28 +608,21 @@ var main = /*#__PURE__*/function () {
|
|
|
733
608
|
}
|
|
734
609
|
}, _callee2, null, [[34, 45, 48, 51], [79, 84]]);
|
|
735
610
|
})(), "t0", 4);
|
|
736
|
-
|
|
737
611
|
case 4:
|
|
738
612
|
_context3.next = 13;
|
|
739
613
|
break;
|
|
740
|
-
|
|
741
614
|
case 6:
|
|
742
615
|
_context3.prev = 6;
|
|
743
616
|
_context3.t1 = _context3["catch"](2);
|
|
744
|
-
|
|
745
617
|
if (!configuration.debug) {
|
|
746
618
|
_context3.next = 12;
|
|
747
619
|
break;
|
|
748
620
|
}
|
|
749
|
-
|
|
750
621
|
throw _context3.t1;
|
|
751
|
-
|
|
752
622
|
case 12:
|
|
753
623
|
console.error(_context3.t1);
|
|
754
|
-
|
|
755
624
|
case 13:
|
|
756
625
|
return _context3.abrupt("return", clear);
|
|
757
|
-
|
|
758
626
|
case 14:
|
|
759
627
|
case "end":
|
|
760
628
|
return _context3.stop();
|
|
@@ -762,7 +630,6 @@ var main = /*#__PURE__*/function () {
|
|
|
762
630
|
}
|
|
763
631
|
}, _callee3, null, [[2, 6]]);
|
|
764
632
|
}))());
|
|
765
|
-
|
|
766
633
|
case 5:
|
|
767
634
|
case "end":
|
|
768
635
|
return _context4.stop();
|
|
@@ -770,16 +637,13 @@ var main = /*#__PURE__*/function () {
|
|
|
770
637
|
}
|
|
771
638
|
}, _callee4);
|
|
772
639
|
}));
|
|
773
|
-
|
|
774
640
|
return function main(_x) {
|
|
775
641
|
return _ref.apply(this, arguments);
|
|
776
642
|
};
|
|
777
643
|
}();
|
|
778
|
-
|
|
779
644
|
if (require.main === module) void main();
|
|
780
645
|
var _default = main; // region vim modline
|
|
781
646
|
// vim: set tabstop=4 shiftwidth=4 expandtab:
|
|
782
647
|
// vim: foldmethod=marker foldmarker=region,endregion:
|
|
783
648
|
// endregion
|
|
784
|
-
|
|
785
649
|
exports["default"] = _default;
|