@eui/tools 4.15.11 → 4.16.0
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 +45 -0
- package/bin/eui-scripts.js +6 -6
- package/bin/scripts/build-package-sub.js +20 -0
- package/bin/scripts/version.js +12 -0
- package/global.test.js +2 -5
- package/package.json +16 -20
- package/sandbox.js +10 -2
- package/scripts/csdr/cli/app.js +30 -3
- package/scripts/csdr/cli/skeletons/app-showcase-eui13/angular-config.json +33 -0
- package/scripts/csdr/cli/skeletons/app-showcase-eui13/dependencies-composite.json +5 -0
- package/scripts/csdr/cli/skeletons/app-showcase-eui13/gitignore_TO_REPLACE +50 -0
- package/scripts/csdr/cli/skeletons/app-showcase-eui13/package.json +6 -0
- package/scripts/csdr/cli/skeletons/app-showcase-eui13/scripts.json +3 -0
- package/scripts/csdr/cli/skeletons/app-showcase-eui13/src/app/app-routing.module.ts +21 -0
- package/scripts/csdr/cli/skeletons/app-showcase-eui13/src/app/app.component.html +26 -0
- package/scripts/csdr/cli/skeletons/app-showcase-eui13/src/app/app.component.ts +19 -0
- package/scripts/csdr/cli/skeletons/app-showcase-eui13/src/app/app.routes.ts +7 -0
- package/scripts/csdr/cli/skeletons/app-showcase-eui13/src/app/features/_home/home-routing.module.ts +15 -0
- package/scripts/csdr/cli/skeletons/app-showcase-eui13/src/app/features/_home/home.component.html +7 -0
- package/scripts/csdr/cli/skeletons/app-showcase-eui13/src/app/features/_home/home.component.ts +8 -0
- package/scripts/csdr/cli/skeletons/app-showcase-eui13/src/app/features/_home/home.module.ts +17 -0
- package/scripts/csdr/cli/skeletons/app-showcase-eui13/src/app/features/shared/shared.module.ts +15 -0
- package/scripts/csdr/cli/skeletons/app-showcase-eui13/src/assets/app-metadata.json +8 -0
- package/scripts/csdr/cli/skeletons/app-showcase-eui13/src/assets/config/env-json-config.json +41 -0
- package/scripts/csdr/cli/skeletons/app-showcase-eui13/src/index.html +22 -0
- package/scripts/csdr/config/angular.js +213 -3
- package/scripts/csdr/config/global.js +16 -0
- package/scripts/csdr/config/packages.js +28 -0
- package/scripts/csdr/init/init-utils.js +37 -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 +10 -8
- package/scripts/csdr/jira/jira-utils.js +168 -168
- package/scripts/csdr/jira/update.js +150 -150
- package/scripts/csdr/metadata/app-envs.js +34 -33
- package/scripts/csdr/metadata/app-history.js +62 -61
- package/scripts/csdr/metadata/app.js +3 -3
- package/scripts/csdr/metadata/common.js +2 -2
- package/scripts/csdr/metadata/package-history.js +0 -1
- package/scripts/csdr/release/app/release-app.js +3 -0
- 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 +8 -0
- package/scripts/csdr/release/package/ui.js +83 -1
- package/scripts/csdr/sync/sync-utils.js +13 -6
- package/scripts/csdr/version/package.js +2 -1
- package/scripts/utils/build/app/build-app-utils.js +2 -2
- package/scripts/utils/build/package/angular.js +4 -4
- package/scripts/utils/build/package/build-package-utils.js +50 -1
- package/scripts/utils/build/package/element.js +5 -16
- package/scripts/utils/build/package/styles.js +100 -7
- package/scripts/utils/confluence-utils.js +126 -126
- package/scripts/utils/index.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/app-sources-full-skeleton/src/_generated/favicon.ico +0 -0
- package/scripts/utils/pre-build/injection/app-sources-full-skeleton-eui13/src/_generated/app/app.module.ts +52 -0
- package/scripts/utils/pre-build/injection/app-sources-full-skeleton-eui13/src/_generated/app/core/reducers/index.ts +40 -0
- package/scripts/utils/pre-build/injection/app-sources-full-skeleton-eui13/src/_generated/config/global.ts +4 -0
- package/scripts/utils/pre-build/injection/app-sources-full-skeleton-eui13/src/_generated/config/index.ts +8 -0
- package/scripts/utils/pre-build/injection/app-sources-full-skeleton-eui13/src/_generated/config/modules.ts +4 -0
- package/scripts/utils/pre-build/injection/app-sources-full-skeleton-eui13/src/_generated/environments/environment.dev.ts +9 -0
- package/scripts/utils/pre-build/injection/app-sources-full-skeleton-eui13/src/_generated/environments/environment.prod.ts +9 -0
- package/scripts/utils/pre-build/injection/app-sources-full-skeleton-eui13/src/_generated/environments/environment.ts +21 -0
- package/scripts/utils/pre-build/injection/app-sources-full-skeleton-eui13/src/_generated/favicon.ico +0 -0
- package/scripts/utils/pre-build/injection/app-sources-full-skeleton-eui13/src/_generated/karma.conf.js +7 -0
- package/scripts/utils/pre-build/injection/app-sources-full-skeleton-eui13/src/_generated/main.ts +21 -0
- package/scripts/utils/pre-build/injection/app-sources-full-skeleton-eui13/src/_generated/polyfills.ts +86 -0
- package/scripts/utils/pre-build/injection/app-sources-full-skeleton-eui13/src/_generated/tst.ts +33 -0
- package/scripts/utils/pre-build/injection/app-sources-full-skeleton-eui13/tsconfig.app.json +19 -0
- package/scripts/utils/pre-build/injection/app-sources-full-skeleton-eui13/tsconfig.spec.json +9 -0
- package/scripts/utils/pre-build/injection/app-sources-full-skeleton-eui13/tslint.json +17 -0
- package/scripts/utils/pre-build/injection/config.js +29 -30
- package/scripts/utils/pre-build/injection/externals.js +6 -0
- package/scripts/utils/pre-build/injection/skeletons.js +6 -2
- package/scripts/utils/pre-build/projects.js +5 -1
- package/scripts/utils/serve/app.js +6 -3
- package/scripts/utils/tools.js +370 -283
- 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/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
|
}
|
|
@@ -439,190 +632,80 @@ const logWarning = (msg) => {
|
|
|
439
632
|
log(msg, 4);
|
|
440
633
|
}
|
|
441
634
|
|
|
635
|
+
const logAccent = (msg) => {
|
|
636
|
+
log(msg, 5);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
const logBanner = (msg) => {
|
|
640
|
+
log(msg, 6);
|
|
641
|
+
}
|
|
642
|
+
|
|
442
643
|
const log = (msg, type) => {
|
|
443
|
-
var prefix;
|
|
644
|
+
var prefix, msgContent, currentDateTime = moment(new Date()).format("HH:mm:ss");
|
|
645
|
+
|
|
444
646
|
if (type === 0 || !type) {
|
|
445
647
|
prefix = figures.play;
|
|
446
|
-
|
|
648
|
+
msgContent = `\n${currentDateTime} - ${prefix} ${msg.toUpperCase()}`;
|
|
649
|
+
if (!isTestRunning) console.info(chalk.yellow(msgContent));
|
|
447
650
|
}
|
|
448
651
|
if (type === 1) {
|
|
449
|
-
prefix =
|
|
450
|
-
|
|
652
|
+
prefix = figures.pointer.repeat(3);
|
|
653
|
+
msgContent = `${currentDateTime} - ${prefix} ${msg}`;
|
|
654
|
+
if (!isTestRunning) console.info(chalk.cyan(msgContent));
|
|
451
655
|
}
|
|
452
656
|
if (type === 2) {
|
|
453
|
-
prefix = figures.pointer
|
|
454
|
-
|
|
657
|
+
prefix = figures.pointer.repeat(6);
|
|
658
|
+
msgContent = `${currentDateTime} - ${prefix} ${msg}\n`;
|
|
659
|
+
if (!isTestRunning) console.info(chalk.green(msgContent));
|
|
455
660
|
}
|
|
456
661
|
if (type === 3) {
|
|
457
|
-
prefix = figures.pointer
|
|
458
|
-
|
|
662
|
+
prefix = figures.pointer.repeat(6);
|
|
663
|
+
msgContent = `\n${currentDateTime} - ${prefix} ${msg}\n`;
|
|
664
|
+
console.info(chalk.red(msgContent));
|
|
459
665
|
}
|
|
460
666
|
if (type === 4) {
|
|
461
|
-
prefix = figures.pointer
|
|
462
|
-
|
|
667
|
+
prefix = figures.pointer.repeat(6);
|
|
668
|
+
msgContent = `\n${currentDateTime} - ${prefix} ${msg}\n`;
|
|
669
|
+
console.info(chalk.keyword('orange')(msgContent));
|
|
670
|
+
}
|
|
671
|
+
if (type === 5) {
|
|
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');
|
|
463
684
|
}
|
|
464
685
|
}
|
|
465
686
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
return new Promise((resolve, reject) => {
|
|
474
|
-
replace({
|
|
475
|
-
files: file,
|
|
476
|
-
from: fromRegExp,
|
|
477
|
-
to: toString,
|
|
478
|
-
disableGlobs: true,
|
|
479
|
-
}, function (err, response) {
|
|
480
|
-
if (err) {
|
|
481
|
-
return reject(err);
|
|
482
|
-
} else {
|
|
483
|
-
return resolve(response);
|
|
484
|
-
}
|
|
485
|
-
})
|
|
486
|
-
})
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
function replaceInPath(rootPath, fromString, toString) {
|
|
490
|
-
const fromRegExp = new RegExp(fromString, 'g');
|
|
491
|
-
|
|
492
|
-
return replace.sync({
|
|
493
|
-
files: [rootPath + '/**/*.*'],
|
|
494
|
-
from: fromRegExp,
|
|
495
|
-
to: toString,
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
function compareValues(key, order='asc') {
|
|
501
|
-
return function(a, b) {
|
|
502
|
-
if(!a.hasOwnProperty(key) || !b.hasOwnProperty(key)) {
|
|
503
|
-
return 0;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
const varA = (typeof a[key] === 'string') ?
|
|
507
|
-
a[key].toUpperCase() : a[key];
|
|
508
|
-
const varB = (typeof b[key] === 'string') ?
|
|
509
|
-
b[key].toUpperCase() : b[key];
|
|
510
|
-
|
|
511
|
-
let comparison = 0;
|
|
512
|
-
if (varA > varB) {
|
|
513
|
-
comparison = 1;
|
|
514
|
-
} else if (varA < varB) {
|
|
515
|
-
comparison = -1;
|
|
516
|
-
}
|
|
517
|
-
return (
|
|
518
|
-
(order == 'desc') ? (comparison * -1) : comparison
|
|
519
|
-
);
|
|
520
|
-
};
|
|
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) {}
|
|
521
694
|
}
|
|
522
695
|
|
|
523
|
-
function sortArray(arr, key, order) {
|
|
524
|
-
return arr.sort(compareValues(key, order));
|
|
525
|
-
}
|
|
526
696
|
|
|
527
|
-
function removeArrayDuplicates(myArr, prop) {
|
|
528
|
-
return myArr.filter((obj, pos, arr) => {
|
|
529
|
-
if (prop) {
|
|
530
|
-
return arr.map(mapObj => mapObj[prop]).indexOf(obj[prop]) === pos;
|
|
531
|
-
} else {
|
|
532
|
-
return arr.map(mapObj => mapObj).indexOf(obj) === pos;
|
|
533
|
-
}
|
|
534
|
-
});
|
|
535
|
-
}
|
|
536
697
|
|
|
537
|
-
function getArraySum(myArr, prop) {
|
|
538
|
-
return myArr.reduce((prev, cur) => {
|
|
539
|
-
return prev + cur[prop];
|
|
540
|
-
}, 0);
|
|
541
|
-
}
|
|
542
698
|
|
|
543
|
-
function getArgs() {
|
|
544
|
-
const argv = require('yargs').argv;
|
|
545
699
|
|
|
546
|
-
const processArgs = process.env._CSDR_ARGS;
|
|
547
700
|
|
|
548
|
-
let args = {};
|
|
549
701
|
|
|
550
|
-
if (processArgs) {
|
|
551
|
-
processArgs.split(',').forEach((item) => {
|
|
552
|
-
const itemSplit = item.split(':');
|
|
553
|
-
args[itemSplit[0].trim()] = itemSplit[1].trim();
|
|
554
|
-
})
|
|
555
|
-
}
|
|
556
702
|
|
|
557
|
-
return {
|
|
558
|
-
root: argv._[0],
|
|
559
|
-
...argv,
|
|
560
|
-
...args
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
703
|
|
|
564
|
-
function getXMLJsContent(file) {
|
|
565
|
-
const content = fs.readFileSync(file, { encoding: 'utf8' });
|
|
566
704
|
|
|
567
|
-
var output;
|
|
568
|
-
xml2js.parseString(content, function (err, result) {
|
|
569
|
-
output = result;
|
|
570
|
-
});
|
|
571
705
|
|
|
572
|
-
return output;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
function getFolders(parentPath) {
|
|
576
|
-
if (isDirExists(parentPath)) {
|
|
577
|
-
return fs.readdirSync(parentPath).filter(f => fs.statSync(path.join(parentPath, f)).isDirectory());
|
|
578
|
-
} else {
|
|
579
|
-
return [];
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
function getFiles(parentPath) {
|
|
584
|
-
return fs.readdirSync(parentPath).filter(f => fs.statSync(path.join(parentPath, f)).isFile());
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
function logBigTitle(text) {
|
|
588
|
-
console.log('\n\n');
|
|
589
|
-
console.log(
|
|
590
|
-
chalk.yellow(
|
|
591
|
-
figlet.textSync(text, { horizontalLayout: 'full' })
|
|
592
|
-
)
|
|
593
|
-
);
|
|
594
|
-
console.log('\n');
|
|
595
|
-
}
|
|
596
706
|
|
|
597
|
-
function removeFilesExtension(rootPath, extension) {
|
|
598
|
-
return new Promise((resolve, reject) => {
|
|
599
|
-
glob(rootPath + "/**/*" + extension,
|
|
600
|
-
function (err, files) {
|
|
601
|
-
if (err) {
|
|
602
|
-
return reject(err);
|
|
603
|
-
} else {
|
|
604
|
-
var processed = 0;
|
|
605
|
-
files.forEach(function (file) {
|
|
606
|
-
const dir = path.dirname(file);
|
|
607
|
-
const filename = path.basename(file);
|
|
608
|
-
// logInfo('remove extention for file : ' + filename + ' in ' + dir);
|
|
609
|
-
const filenameUpdate = filename.substr(0, filename.indexOf(extension));
|
|
610
|
-
fs.renameSync(file, dir + "/" + filenameUpdate);
|
|
611
|
-
processed++;
|
|
612
|
-
});
|
|
613
|
-
logInfo(processed + " files processed");
|
|
614
|
-
resolve();
|
|
615
|
-
}
|
|
616
|
-
});
|
|
617
|
-
})
|
|
618
|
-
}
|
|
619
707
|
|
|
620
|
-
function splitNpmPkg(npmPkg) {
|
|
621
|
-
const scope = npmPkg.substr(0, npmPkg.indexOf('/'));
|
|
622
|
-
const name = npmPkg.substr(npmPkg.indexOf('/') + 1);
|
|
623
708
|
|
|
624
|
-
return { scope: scope, name: name };
|
|
625
|
-
}
|
|
626
709
|
|
|
627
710
|
|
|
628
711
|
|
|
@@ -663,6 +746,8 @@ module.exports.logInfo = logInfo;
|
|
|
663
746
|
module.exports.logSuccess = logSuccess;
|
|
664
747
|
module.exports.logError = logError;
|
|
665
748
|
module.exports.logWarning = logWarning;
|
|
749
|
+
module.exports.logAccent = logAccent;
|
|
750
|
+
module.exports.logBanner = logBanner;
|
|
666
751
|
module.exports.replaceInFile = replaceInFile;
|
|
667
752
|
module.exports.replaceInPath = replaceInPath;
|
|
668
753
|
module.exports.sortArray = sortArray;
|
|
@@ -672,6 +757,8 @@ module.exports.getArgs = getArgs;
|
|
|
672
757
|
module.exports.getXMLJsContent = getXMLJsContent;
|
|
673
758
|
module.exports.getFolders = getFolders;
|
|
674
759
|
module.exports.getFiles = getFiles;
|
|
760
|
+
module.exports.getFilesGlob = getFilesGlob;
|
|
675
761
|
module.exports.logBigTitle = logBigTitle;
|
|
676
762
|
module.exports.removeFilesExtension = removeFilesExtension;
|
|
677
763
|
module.exports.splitNpmPkg = splitNpmPkg;
|
|
764
|
+
module.exports.logVersion = logVersion;
|