@eui/tools 4.15.14 → 4.16.3
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/.version.properties +1 -1
- package/CHANGELOG.md +48 -0
- package/bin/eui-scripts.js +0 -4
- package/global.test.js +1 -4
- package/package.json +3 -3
- package/sandbox.js +10 -3
- package/scripts/csdr/config/packages.js +28 -0
- package/scripts/csdr/init/init-utils.js +39 -0
- package/scripts/csdr/init/init.js +6 -0
- package/scripts/csdr/init/resources/13.x/resolutions.json +15 -0
- package/scripts/csdr/install/build-package.js +0 -84
- package/scripts/csdr/install/common.js +0 -16
- package/scripts/csdr/metadata/app.js +3 -3
- package/scripts/csdr/release/package/backend.js +26 -0
- package/scripts/csdr/release/package/common.js +1 -1
- package/scripts/csdr/release/package/release-package.js +4 -0
- package/scripts/csdr/release/package/ui.js +84 -1
- package/scripts/csdr/sync/sync-utils.js +7 -4
- package/scripts/csdr/version/package.js +2 -1
- package/scripts/utils/build/app/build-app-utils.js +2 -2
- package/scripts/utils/build/package/element.js +2 -2
- package/scripts/utils/notification/common.js +5 -0
- package/scripts/utils/notification/mail-utils.js +3 -0
- package/scripts/utils/notification/mailstack.js +3 -5
- package/scripts/utils/notification/package.js +0 -2
- package/scripts/utils/notification/slack-utils.js +6 -7
- package/scripts/utils/pre-build/injection/config.js +29 -30
- package/scripts/utils/pre-build/injection/externals.js +6 -0
- package/scripts/utils/serve/app.js +6 -3
- package/scripts/utils/tools.js +362 -304
- package/bin/scripts/csdr-jira-update.js +0 -12
- package/bin/scripts/csdr-migrate-package.js +0 -17
- package/bin/scripts/e2e-app.js +0 -62
- package/scripts/csdr/init/resources/yarn-eui13.lock +0 -15857
- package/scripts/migration/eui8-migration.js +0 -94
- package/scripts/migration/migrate-utils.js +0 -191
package/scripts/utils/tools.js
CHANGED
|
@@ -16,6 +16,7 @@ const eol = require('eol');
|
|
|
16
16
|
const execa = require('execa');
|
|
17
17
|
const replace = require('replace-in-file');
|
|
18
18
|
const xml2js = require('xml2js');
|
|
19
|
+
const moment = require('moment');
|
|
19
20
|
|
|
20
21
|
const isTestRunning = process.env._TEST;
|
|
21
22
|
|
|
@@ -38,41 +39,89 @@ function runScript(_args, cwdFolder) {
|
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
function getPackages(rootFolder) {
|
|
43
|
+
if (!rootFolder) {
|
|
44
|
+
rootFolder = 'src/packages';
|
|
45
|
+
}
|
|
46
|
+
logInfo('-- Getting packages from ' + rootFolder);
|
|
47
|
+
|
|
48
|
+
const packages = fs.readdirSync(rootFolder)
|
|
49
|
+
.filter(name => fs.lstatSync(path.resolve(rootFolder, name)).isDirectory())
|
|
50
|
+
.map(name => {
|
|
51
|
+
return { 'package': name }
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (packages.length === 0) {
|
|
55
|
+
logInfo('----> no packages found');
|
|
56
|
+
} else {
|
|
57
|
+
logInfo('----> packages found : ' + packages.map(p => p.package));
|
|
58
|
+
}
|
|
59
|
+
return packages;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getArgs() {
|
|
63
|
+
const argv = require('yargs').argv;
|
|
64
|
+
|
|
65
|
+
const processArgs = process.env._CSDR_ARGS;
|
|
66
|
+
|
|
67
|
+
let args = {};
|
|
68
|
+
|
|
69
|
+
if (processArgs) {
|
|
70
|
+
processArgs.split(',').forEach((item) => {
|
|
71
|
+
const itemSplit = item.split(':');
|
|
72
|
+
args[itemSplit[0].trim()] = itemSplit[1].trim();
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
root: argv._[0],
|
|
78
|
+
...argv,
|
|
79
|
+
...args
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
/* -------------------------------------------------------------------------------------------
|
|
87
|
+
** FILES OPERATIONS
|
|
88
|
+
** ------------------------------------------------------------------------------------------- */
|
|
89
|
+
|
|
41
90
|
// TODO DETECT if folder exists, otherwise it's exiting without continuing the promise chain
|
|
42
91
|
function relativeCopy(fileGlob, from, to) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
92
|
+
return new Promise((resolve, reject) => {
|
|
93
|
+
glob(fileGlob, { cwd: from, nodir: true, follow: true, dot: true }, (err, files) => {
|
|
94
|
+
if (err) {
|
|
95
|
+
logError(err);
|
|
96
|
+
reject(err);
|
|
97
|
+
}
|
|
98
|
+
files.forEach(file => {
|
|
99
|
+
const origin = path.join(from, file);
|
|
100
|
+
const dest = path.join(to, file);
|
|
101
|
+
_recursiveMkDir(path.dirname(dest));
|
|
102
|
+
fse.copy(origin, dest);
|
|
103
|
+
resolve();
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
});
|
|
58
107
|
}
|
|
59
108
|
|
|
60
109
|
function relativeCopyEol(fileGlob, from, to) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
110
|
+
return new Promise((resolve, reject) => {
|
|
111
|
+
glob(fileGlob, { cwd: from, nodir: true, follow: true, dot: true }, (err, files) => {
|
|
112
|
+
if (err) reject(err);
|
|
113
|
+
files.forEach(file => {
|
|
114
|
+
const origin = path.join(from, file);
|
|
115
|
+
const dest = path.join(to, file);
|
|
116
|
+
_recursiveMkDir(path.dirname(dest));
|
|
117
|
+
//fse.copy(origin, dest);
|
|
118
|
+
const content = fs.readFileSync(origin, { encoding: 'utf8' });
|
|
119
|
+
const contentToCRLF = eol.crlf(content);
|
|
120
|
+
fs.writeFileSync(dest, contentToCRLF);
|
|
121
|
+
resolve();
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
});
|
|
76
125
|
}
|
|
77
126
|
|
|
78
127
|
function copydir(from, to, overwrite = true, globPattern = '**/*') {
|
|
@@ -87,15 +136,15 @@ function copydir(from, to, overwrite = true, globPattern = '**/*') {
|
|
|
87
136
|
}
|
|
88
137
|
|
|
89
138
|
function rmdir(path) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
139
|
+
logInfo('----> remiving ' + path);
|
|
140
|
+
try {
|
|
141
|
+
if (isWindows()) {
|
|
142
|
+
fs.rmdirSync(path);
|
|
143
|
+
} else {
|
|
144
|
+
fs.unlinkSync(path);
|
|
145
|
+
}
|
|
146
|
+
} catch(e) {
|
|
147
|
+
}
|
|
99
148
|
}
|
|
100
149
|
|
|
101
150
|
function rimraf(inputPath) {
|
|
@@ -108,14 +157,21 @@ function rimraf(inputPath) {
|
|
|
108
157
|
}
|
|
109
158
|
|
|
110
159
|
function rmdirFull(dirPath, removeSelf) {
|
|
111
|
-
|
|
112
|
-
|
|
160
|
+
try {
|
|
161
|
+
if (removeSelf === undefined) {
|
|
113
162
|
removeSelf = true;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
try {
|
|
166
|
+
var files = fse.readdirSync(dirPath);
|
|
167
|
+
}
|
|
168
|
+
catch(e) {
|
|
169
|
+
this.logWarning('Error trying to read folder files');
|
|
170
|
+
console.log(e);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (files.length > 0) {
|
|
119
175
|
for (var i = 0; i < files.length; i++) {
|
|
120
176
|
var filePath = path.join(dirPath, files[i]);
|
|
121
177
|
if (fse.statSync(filePath).isFile())
|
|
@@ -123,32 +179,38 @@ function rmdirFull(dirPath, removeSelf) {
|
|
|
123
179
|
else
|
|
124
180
|
rmdir(filePath);
|
|
125
181
|
}
|
|
126
|
-
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (removeSelf) {
|
|
127
185
|
fse.rmdirSync(dirPath);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
catch(e) {
|
|
190
|
+
this.logWarning('Error trying to remove folder content');
|
|
191
|
+
console.log(e);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
133
195
|
|
|
134
196
|
function mkdir(path) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
197
|
+
if (!fs.existsSync(path)) {
|
|
198
|
+
fs.mkdirSync(path);
|
|
199
|
+
}
|
|
138
200
|
}
|
|
139
201
|
|
|
140
202
|
function mkdirRecursive(path) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
203
|
+
if (!fs.existsSync(path)) {
|
|
204
|
+
_recursiveMkDir(path);
|
|
205
|
+
}
|
|
144
206
|
}
|
|
145
207
|
|
|
146
208
|
function isDirExists(path) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
209
|
+
try {
|
|
210
|
+
return fs.statSync(path).isDirectory();
|
|
211
|
+
} catch (err) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
152
214
|
}
|
|
153
215
|
|
|
154
216
|
function isDirEmpty(path) {
|
|
@@ -167,52 +229,22 @@ function isDirEmpty(path) {
|
|
|
167
229
|
}
|
|
168
230
|
|
|
169
231
|
function isFileExists(path) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
232
|
+
try {
|
|
233
|
+
return fs.statSync(path);
|
|
234
|
+
} catch (err) {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
175
237
|
}
|
|
176
238
|
|
|
177
239
|
function link(src, target) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function isWindows() {
|
|
187
|
-
if (path.sep === "\\") {
|
|
188
|
-
return true;
|
|
189
|
-
} else {
|
|
190
|
-
return false;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function getPackages(rootFolder) {
|
|
195
|
-
if (!rootFolder) {
|
|
196
|
-
rootFolder = 'src/packages';
|
|
197
|
-
}
|
|
198
|
-
logInfo('-- Getting packages from ' + rootFolder);
|
|
199
|
-
|
|
200
|
-
const packages = fs.readdirSync(rootFolder)
|
|
201
|
-
.filter(name => fs.lstatSync(path.resolve(rootFolder, name)).isDirectory())
|
|
202
|
-
.map(name => {
|
|
203
|
-
return { 'package': name }
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
if (packages.length === 0) {
|
|
207
|
-
logInfo('----> no packages found');
|
|
208
|
-
} else {
|
|
209
|
-
logInfo('----> packages found : ' + packages.map(p => p.package));
|
|
210
|
-
}
|
|
211
|
-
return packages;
|
|
240
|
+
rmdir(target);
|
|
241
|
+
if (isWindows()) {
|
|
242
|
+
execSync(`mklink /D ${target} ${src}`);
|
|
243
|
+
} else {
|
|
244
|
+
execSync(`ln -s ${src} ${target}`);
|
|
245
|
+
}
|
|
212
246
|
}
|
|
213
247
|
|
|
214
|
-
|
|
215
|
-
// Recursively create a dir.
|
|
216
248
|
function _recursiveMkDir(dir) {
|
|
217
249
|
if (!fs.existsSync(dir)) {
|
|
218
250
|
_recursiveMkDir(path.dirname(dir));
|
|
@@ -324,6 +356,101 @@ function mkdirFilePath(filename) {
|
|
|
324
356
|
}
|
|
325
357
|
}
|
|
326
358
|
|
|
359
|
+
function replaceInFile(file, fromString, toString) {
|
|
360
|
+
const fromRegExp = new RegExp(fromString, 'g');
|
|
361
|
+
|
|
362
|
+
logInfo('replace in file: ' + file);
|
|
363
|
+
|
|
364
|
+
return new Promise((resolve, reject) => {
|
|
365
|
+
replace({
|
|
366
|
+
files: file,
|
|
367
|
+
from: fromRegExp,
|
|
368
|
+
to: toString,
|
|
369
|
+
disableGlobs: true,
|
|
370
|
+
}, function (err, response) {
|
|
371
|
+
if (err) {
|
|
372
|
+
return reject(err);
|
|
373
|
+
} else {
|
|
374
|
+
return resolve(response);
|
|
375
|
+
}
|
|
376
|
+
})
|
|
377
|
+
})
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function replaceInPath(rootPath, fromString, toString) {
|
|
381
|
+
const fromRegExp = new RegExp(fromString, 'g');
|
|
382
|
+
|
|
383
|
+
return replace.sync({
|
|
384
|
+
files: [rootPath + '/**/*.*'],
|
|
385
|
+
from: fromRegExp,
|
|
386
|
+
to: toString,
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function getXMLJsContent(file) {
|
|
391
|
+
const content = fs.readFileSync(file, { encoding: 'utf8' });
|
|
392
|
+
|
|
393
|
+
var output;
|
|
394
|
+
xml2js.parseString(content, function (err, result) {
|
|
395
|
+
output = result;
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
return output;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function getFolders(parentPath) {
|
|
402
|
+
if (isDirExists(parentPath)) {
|
|
403
|
+
return fs.readdirSync(parentPath).filter(f => fs.statSync(path.join(parentPath, f)).isDirectory());
|
|
404
|
+
} else {
|
|
405
|
+
return [];
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
function getFiles(parentPath) {
|
|
410
|
+
return fs.readdirSync(parentPath).filter(f => fs.statSync(path.join(parentPath, f)).isFile());
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
function getFilesGlob(from, fileGlob) {
|
|
414
|
+
return new Promise((resolve, reject) => {
|
|
415
|
+
glob(fileGlob, { cwd: from, nodir: true, follow: true, dot: true }, (err, files) => {
|
|
416
|
+
if (err) {
|
|
417
|
+
logError(err);
|
|
418
|
+
reject(err);
|
|
419
|
+
}
|
|
420
|
+
return resolve(files);
|
|
421
|
+
})
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
function removeFilesExtension(rootPath, extension) {
|
|
426
|
+
return new Promise((resolve, reject) => {
|
|
427
|
+
glob(rootPath + "/**/*" + extension,
|
|
428
|
+
function (err, files) {
|
|
429
|
+
if (err) {
|
|
430
|
+
return reject(err);
|
|
431
|
+
} else {
|
|
432
|
+
var processed = 0;
|
|
433
|
+
files.forEach(function (file) {
|
|
434
|
+
const dir = path.dirname(file);
|
|
435
|
+
const filename = path.basename(file);
|
|
436
|
+
// logInfo('remove extention for file : ' + filename + ' in ' + dir);
|
|
437
|
+
const filenameUpdate = filename.substr(0, filename.indexOf(extension));
|
|
438
|
+
fs.renameSync(file, dir + "/" + filenameUpdate);
|
|
439
|
+
processed++;
|
|
440
|
+
});
|
|
441
|
+
logInfo(processed + " files processed");
|
|
442
|
+
resolve();
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
})
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
/* -------------------------------------------------------------------------------------------
|
|
451
|
+
** STRING and ARRAY
|
|
452
|
+
** ------------------------------------------------------------------------------------------- */
|
|
453
|
+
|
|
327
454
|
function capitalizeFirstLetter(string) {
|
|
328
455
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
329
456
|
}
|
|
@@ -349,6 +476,77 @@ function camelCaseString(string, separator, first) {
|
|
|
349
476
|
return result;
|
|
350
477
|
}
|
|
351
478
|
|
|
479
|
+
function replaceAll(str, find, replace) {
|
|
480
|
+
return str.replace(new RegExp(find, 'g'), replace);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function compareValues(key, order='asc') {
|
|
484
|
+
return function(a, b) {
|
|
485
|
+
if(!a.hasOwnProperty(key) || !b.hasOwnProperty(key)) {
|
|
486
|
+
return 0;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
const varA = (typeof a[key] === 'string') ?
|
|
490
|
+
a[key].toUpperCase() : a[key];
|
|
491
|
+
const varB = (typeof b[key] === 'string') ?
|
|
492
|
+
b[key].toUpperCase() : b[key];
|
|
493
|
+
|
|
494
|
+
let comparison = 0;
|
|
495
|
+
if (varA > varB) {
|
|
496
|
+
comparison = 1;
|
|
497
|
+
} else if (varA < varB) {
|
|
498
|
+
comparison = -1;
|
|
499
|
+
}
|
|
500
|
+
return (
|
|
501
|
+
(order == 'desc') ? (comparison * -1) : comparison
|
|
502
|
+
);
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
function sortArray(arr, key, order) {
|
|
507
|
+
return arr.sort(compareValues(key, order));
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function removeArrayDuplicates(myArr, prop) {
|
|
511
|
+
return myArr.filter((obj, pos, arr) => {
|
|
512
|
+
if (prop) {
|
|
513
|
+
return arr.map(mapObj => mapObj[prop]).indexOf(obj[prop]) === pos;
|
|
514
|
+
} else {
|
|
515
|
+
return arr.map(mapObj => mapObj).indexOf(obj) === pos;
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function getArraySum(myArr, prop) {
|
|
521
|
+
return myArr.reduce((prev, cur) => {
|
|
522
|
+
return prev + cur[prop];
|
|
523
|
+
}, 0);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
function splitNpmPkg(npmPkg) {
|
|
527
|
+
const scope = npmPkg.substr(0, npmPkg.indexOf('/'));
|
|
528
|
+
const name = npmPkg.substr(npmPkg.indexOf('/') + 1);
|
|
529
|
+
|
|
530
|
+
return { scope: scope, name: name };
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
/* -------------------------------------------------------------------------------------------
|
|
540
|
+
** SYSTEM
|
|
541
|
+
** ------------------------------------------------------------------------------------------- */
|
|
542
|
+
function isWindows() {
|
|
543
|
+
if (path.sep === "\\") {
|
|
544
|
+
return true;
|
|
545
|
+
} else {
|
|
546
|
+
return false;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
352
550
|
function getSysConfig() {
|
|
353
551
|
logInfo('Getting system infos...');
|
|
354
552
|
|
|
@@ -358,11 +556,6 @@ function getSysConfig() {
|
|
|
358
556
|
|
|
359
557
|
infos.node = semver.clean(node);
|
|
360
558
|
|
|
361
|
-
try {
|
|
362
|
-
infos.npm = execSync('npm -v').toString().trim();
|
|
363
|
-
} catch(e) {
|
|
364
|
-
infos.npm = null;
|
|
365
|
-
}
|
|
366
559
|
try {
|
|
367
560
|
infos.yarn = execSync('yarn -v').toString().trim();
|
|
368
561
|
} catch(e) {
|
|
@@ -372,7 +565,6 @@ function getSysConfig() {
|
|
|
372
565
|
infos.httpsProxy = execSync('npm config get https-proxy').toString().trim();
|
|
373
566
|
const registry = execSync('npm config get registry').toString().trim();
|
|
374
567
|
|
|
375
|
-
infos.isRegistryDiplazium = registry.indexOf('diplazium') >= 0;
|
|
376
568
|
infos.isRegistryEcDevops = registry.indexOf('ecdevops.eu') >= 0;
|
|
377
569
|
|
|
378
570
|
logSuccess();
|
|
@@ -384,9 +576,8 @@ function isSysConfigValid() {
|
|
|
384
576
|
const infos = getSysConfig();
|
|
385
577
|
|
|
386
578
|
const validVersions = {
|
|
387
|
-
node: '>=
|
|
388
|
-
|
|
389
|
-
}
|
|
579
|
+
node: '>=12.20.x',
|
|
580
|
+
};
|
|
390
581
|
|
|
391
582
|
logTitle('Checking system infos...');
|
|
392
583
|
|
|
@@ -395,29 +586,31 @@ function isSysConfigValid() {
|
|
|
395
586
|
return false;
|
|
396
587
|
}
|
|
397
588
|
|
|
398
|
-
if (infos.isRegistryDiplazium && !semver.satisfies(infos.npm, validVersions.npmMaxDiplazium) && infos.yarn === null) {
|
|
399
|
-
logError(`---> Invalid NPM version when used against diplazium : found:${infos.npm} - required:${validVersions.npmMaxDiplazium}`);
|
|
400
|
-
logError('------> you can only use NPM 5.x and above if YARN is used as your dependency manager ===> Yarn NOT INSTALLED');
|
|
401
|
-
return false;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
if (infos.isRegistryDiplazium && infos.httpsProxy === 'undefined') {
|
|
405
|
-
logError('---> No proxy setting set when used against diplazium registry');
|
|
406
|
-
logError('------> check eUI documentation on how to configure your proxy setting');
|
|
407
|
-
return false;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
589
|
logSuccess();
|
|
411
590
|
|
|
412
591
|
return true;
|
|
413
592
|
}
|
|
414
593
|
|
|
415
|
-
function replaceAll(str, find, replace) {
|
|
416
|
-
return str.replace(new RegExp(find, 'g'), replace);
|
|
417
|
-
}
|
|
418
594
|
|
|
419
595
|
|
|
420
596
|
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
/* -------------------------------------------------------------------------------------------
|
|
601
|
+
** LOGGING
|
|
602
|
+
** ------------------------------------------------------------------------------------------- */
|
|
603
|
+
|
|
604
|
+
function logBigTitle(text) {
|
|
605
|
+
console.log('\n\n');
|
|
606
|
+
console.log(
|
|
607
|
+
chalk.yellow(
|
|
608
|
+
figlet.textSync(text, { horizontalLayout: 'full' })
|
|
609
|
+
)
|
|
610
|
+
);
|
|
611
|
+
console.log('\n');
|
|
612
|
+
}
|
|
613
|
+
|
|
421
614
|
const logTitle = (msg) => {
|
|
422
615
|
log(msg, 0);
|
|
423
616
|
}
|
|
@@ -443,215 +636,78 @@ const logAccent = (msg) => {
|
|
|
443
636
|
log(msg, 5);
|
|
444
637
|
}
|
|
445
638
|
|
|
639
|
+
const logBanner = (msg) => {
|
|
640
|
+
log(msg, 6);
|
|
641
|
+
}
|
|
642
|
+
|
|
446
643
|
const log = (msg, type) => {
|
|
447
|
-
var prefix;
|
|
644
|
+
var prefix, msgContent, currentDateTime = moment(new Date()).format("HH:mm:ss");
|
|
645
|
+
|
|
448
646
|
if (type === 0 || !type) {
|
|
449
647
|
prefix = figures.play;
|
|
450
|
-
|
|
648
|
+
msgContent = `\n${currentDateTime} - ${prefix} ${msg.toUpperCase()}`;
|
|
649
|
+
if (!isTestRunning) console.info(chalk.yellow(msgContent));
|
|
451
650
|
}
|
|
452
651
|
if (type === 1) {
|
|
453
|
-
prefix =
|
|
454
|
-
|
|
652
|
+
prefix = figures.pointer.repeat(3);
|
|
653
|
+
msgContent = `${currentDateTime} - ${prefix} ${msg}`;
|
|
654
|
+
if (!isTestRunning) console.info(chalk.cyan(msgContent));
|
|
455
655
|
}
|
|
456
656
|
if (type === 2) {
|
|
457
|
-
prefix = figures.pointer
|
|
458
|
-
|
|
657
|
+
prefix = figures.pointer.repeat(6);
|
|
658
|
+
msgContent = `${currentDateTime} - ${prefix} ${msg}\n`;
|
|
659
|
+
if (!isTestRunning) console.info(chalk.green(msgContent));
|
|
459
660
|
}
|
|
460
661
|
if (type === 3) {
|
|
461
|
-
prefix = figures.pointer
|
|
462
|
-
|
|
662
|
+
prefix = figures.pointer.repeat(6);
|
|
663
|
+
msgContent = `\n${currentDateTime} - ${prefix} ${msg}\n`;
|
|
664
|
+
console.info(chalk.red(msgContent));
|
|
463
665
|
}
|
|
464
666
|
if (type === 4) {
|
|
465
|
-
prefix = figures.pointer
|
|
466
|
-
|
|
667
|
+
prefix = figures.pointer.repeat(6);
|
|
668
|
+
msgContent = `\n${currentDateTime} - ${prefix} ${msg}\n`;
|
|
669
|
+
console.info(chalk.keyword('orange')(msgContent));
|
|
467
670
|
}
|
|
468
671
|
if (type === 5) {
|
|
469
|
-
prefix = figures.star
|
|
470
|
-
|
|
672
|
+
prefix = figures.star.repeat(3);
|
|
673
|
+
msgContent = `${currentDateTime} - ${prefix} ${msg}\n`;
|
|
674
|
+
console.info(chalk.keyword('yellow')(msgContent));
|
|
675
|
+
}
|
|
676
|
+
if (type === 6) {
|
|
677
|
+
prefix = figures.star.repeat(3)
|
|
678
|
+
msgContent = prefix + ' ' + msg + ' ' + prefix;
|
|
679
|
+
console.info('\n\n');
|
|
680
|
+
console.info(chalk.keyword('yellow')(figures.star.repeat(msgContent.length)));
|
|
681
|
+
console.info(chalk.keyword('yellow')(msgContent));
|
|
682
|
+
console.info(chalk.keyword('yellow')(figures.star.repeat(msgContent.length)));
|
|
683
|
+
console.info('\n');
|
|
471
684
|
}
|
|
472
685
|
}
|
|
473
686
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
return new Promise((resolve, reject) => {
|
|
482
|
-
replace({
|
|
483
|
-
files: file,
|
|
484
|
-
from: fromRegExp,
|
|
485
|
-
to: toString,
|
|
486
|
-
disableGlobs: true,
|
|
487
|
-
}, function (err, response) {
|
|
488
|
-
if (err) {
|
|
489
|
-
return reject(err);
|
|
490
|
-
} else {
|
|
491
|
-
return resolve(response);
|
|
492
|
-
}
|
|
493
|
-
})
|
|
494
|
-
})
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
function replaceInPath(rootPath, fromString, toString) {
|
|
498
|
-
const fromRegExp = new RegExp(fromString, 'g');
|
|
499
|
-
|
|
500
|
-
return replace.sync({
|
|
501
|
-
files: [rootPath + '/**/*.*'],
|
|
502
|
-
from: fromRegExp,
|
|
503
|
-
to: toString,
|
|
504
|
-
});
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
function compareValues(key, order='asc') {
|
|
509
|
-
return function(a, b) {
|
|
510
|
-
if(!a.hasOwnProperty(key) || !b.hasOwnProperty(key)) {
|
|
511
|
-
return 0;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
const varA = (typeof a[key] === 'string') ?
|
|
515
|
-
a[key].toUpperCase() : a[key];
|
|
516
|
-
const varB = (typeof b[key] === 'string') ?
|
|
517
|
-
b[key].toUpperCase() : b[key];
|
|
518
|
-
|
|
519
|
-
let comparison = 0;
|
|
520
|
-
if (varA > varB) {
|
|
521
|
-
comparison = 1;
|
|
522
|
-
} else if (varA < varB) {
|
|
523
|
-
comparison = -1;
|
|
524
|
-
}
|
|
525
|
-
return (
|
|
526
|
-
(order == 'desc') ? (comparison * -1) : comparison
|
|
527
|
-
);
|
|
528
|
-
};
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
function sortArray(arr, key, order) {
|
|
532
|
-
return arr.sort(compareValues(key, order));
|
|
687
|
+
function logVersion() {
|
|
688
|
+
try {
|
|
689
|
+
const nmToolsPackageJsonPath = path.join(process.cwd(), 'node_modules', '@eui', 'tools', 'package.json');
|
|
690
|
+
const jsonContent = getJsonFileContent(nmToolsPackageJsonPath);
|
|
691
|
+
const version = jsonContent.version;
|
|
692
|
+
logBanner(`eUI TOOLS version : ${version}`)
|
|
693
|
+
} catch(e) {}
|
|
533
694
|
}
|
|
534
695
|
|
|
535
|
-
function removeArrayDuplicates(myArr, prop) {
|
|
536
|
-
return myArr.filter((obj, pos, arr) => {
|
|
537
|
-
if (prop) {
|
|
538
|
-
return arr.map(mapObj => mapObj[prop]).indexOf(obj[prop]) === pos;
|
|
539
|
-
} else {
|
|
540
|
-
return arr.map(mapObj => mapObj).indexOf(obj) === pos;
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
696
|
|
|
545
|
-
function getArraySum(myArr, prop) {
|
|
546
|
-
return myArr.reduce((prev, cur) => {
|
|
547
|
-
return prev + cur[prop];
|
|
548
|
-
}, 0);
|
|
549
|
-
}
|
|
550
697
|
|
|
551
|
-
function getArgs() {
|
|
552
|
-
const argv = require('yargs').argv;
|
|
553
698
|
|
|
554
|
-
const processArgs = process.env._CSDR_ARGS;
|
|
555
699
|
|
|
556
|
-
let args = {};
|
|
557
700
|
|
|
558
|
-
if (processArgs) {
|
|
559
|
-
processArgs.split(',').forEach((item) => {
|
|
560
|
-
const itemSplit = item.split(':');
|
|
561
|
-
args[itemSplit[0].trim()] = itemSplit[1].trim();
|
|
562
|
-
})
|
|
563
|
-
}
|
|
564
701
|
|
|
565
|
-
return {
|
|
566
|
-
root: argv._[0],
|
|
567
|
-
...argv,
|
|
568
|
-
...args
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
702
|
|
|
572
|
-
function getXMLJsContent(file) {
|
|
573
|
-
const content = fs.readFileSync(file, { encoding: 'utf8' });
|
|
574
703
|
|
|
575
|
-
var output;
|
|
576
|
-
xml2js.parseString(content, function (err, result) {
|
|
577
|
-
output = result;
|
|
578
|
-
});
|
|
579
704
|
|
|
580
|
-
return output;
|
|
581
|
-
}
|
|
582
705
|
|
|
583
|
-
function getFolders(parentPath) {
|
|
584
|
-
if (isDirExists(parentPath)) {
|
|
585
|
-
return fs.readdirSync(parentPath).filter(f => fs.statSync(path.join(parentPath, f)).isDirectory());
|
|
586
|
-
} else {
|
|
587
|
-
return [];
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
706
|
|
|
591
|
-
function getFiles(parentPath) {
|
|
592
|
-
return fs.readdirSync(parentPath).filter(f => fs.statSync(path.join(parentPath, f)).isFile());
|
|
593
|
-
}
|
|
594
707
|
|
|
595
|
-
function getFilesGlob(from, fileGlob) {
|
|
596
|
-
return new Promise((resolve, reject) => {
|
|
597
|
-
glob(fileGlob, { cwd: from, nodir: true, follow: true, dot: true }, (err, files) => {
|
|
598
|
-
if (err) {
|
|
599
|
-
logError(err);
|
|
600
|
-
reject(err);
|
|
601
|
-
}
|
|
602
|
-
return resolve(files);
|
|
603
|
-
})
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
708
|
|
|
607
|
-
function logBigTitle(text) {
|
|
608
|
-
console.log('\n\n');
|
|
609
|
-
console.log(
|
|
610
|
-
chalk.yellow(
|
|
611
|
-
figlet.textSync(text, { horizontalLayout: 'full' })
|
|
612
|
-
)
|
|
613
|
-
);
|
|
614
|
-
console.log('\n');
|
|
615
|
-
}
|
|
616
709
|
|
|
617
|
-
function removeFilesExtension(rootPath, extension) {
|
|
618
|
-
return new Promise((resolve, reject) => {
|
|
619
|
-
glob(rootPath + "/**/*" + extension,
|
|
620
|
-
function (err, files) {
|
|
621
|
-
if (err) {
|
|
622
|
-
return reject(err);
|
|
623
|
-
} else {
|
|
624
|
-
var processed = 0;
|
|
625
|
-
files.forEach(function (file) {
|
|
626
|
-
const dir = path.dirname(file);
|
|
627
|
-
const filename = path.basename(file);
|
|
628
|
-
// logInfo('remove extention for file : ' + filename + ' in ' + dir);
|
|
629
|
-
const filenameUpdate = filename.substr(0, filename.indexOf(extension));
|
|
630
|
-
fs.renameSync(file, dir + "/" + filenameUpdate);
|
|
631
|
-
processed++;
|
|
632
|
-
});
|
|
633
|
-
logInfo(processed + " files processed");
|
|
634
|
-
resolve();
|
|
635
|
-
}
|
|
636
|
-
});
|
|
637
|
-
})
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
function splitNpmPkg(npmPkg) {
|
|
641
|
-
const scope = npmPkg.substr(0, npmPkg.indexOf('/'));
|
|
642
|
-
const name = npmPkg.substr(npmPkg.indexOf('/') + 1);
|
|
643
|
-
|
|
644
|
-
return { scope: scope, name: name };
|
|
645
|
-
}
|
|
646
710
|
|
|
647
|
-
function logVersion() {
|
|
648
|
-
try {
|
|
649
|
-
const nmToolsPackageJsonPath = path.join(process.cwd(), 'node_modules', '@eui', 'tools', 'package.json');
|
|
650
|
-
const jsonContent = getJsonFileContent(nmToolsPackageJsonPath);
|
|
651
|
-
const version = jsonContent.version;
|
|
652
|
-
logAccent(`eUI TOOLS version : ${version}`)
|
|
653
|
-
} catch(e) {}
|
|
654
|
-
}
|
|
655
711
|
|
|
656
712
|
module.exports.relativeCopy = relativeCopy;
|
|
657
713
|
module.exports.relativeCopyEol = relativeCopyEol;
|
|
@@ -690,6 +746,8 @@ module.exports.logInfo = logInfo;
|
|
|
690
746
|
module.exports.logSuccess = logSuccess;
|
|
691
747
|
module.exports.logError = logError;
|
|
692
748
|
module.exports.logWarning = logWarning;
|
|
749
|
+
module.exports.logAccent = logAccent;
|
|
750
|
+
module.exports.logBanner = logBanner;
|
|
693
751
|
module.exports.replaceInFile = replaceInFile;
|
|
694
752
|
module.exports.replaceInPath = replaceInPath;
|
|
695
753
|
module.exports.sortArray = sortArray;
|