@eui/tools 4.19.4 → 4.19.8
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 +36 -0
- package/global.test.js +1 -0
- package/package.json +1 -1
- package/sandbox.js +2 -1
- package/scripts/csdr/config/angular.js +1 -1
- package/scripts/csdr/init/resources/13.x/resolutions.json +1 -1
- package/scripts/utils/pre-build/injection/externals.js +4 -149
- package/scripts/utils/pre-build/injection/injection-utils.js +2 -0
- package/scripts/utils/pre-build/injection/routes-replacement.js +318 -0
- package/scripts/utils/pre-build/projects.js +1 -1
package/.version.properties
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
4.19.
|
|
1
|
+
4.19.8
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
## 4.19.8 (2022-02-16)
|
|
2
|
+
|
|
3
|
+
##### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **other:**
|
|
6
|
+
* routes replacement for local-dev not taken into account - MWP-7941 [MWP-7941](https://webgate.ec.europa.eu/CITnet/jira/browse/MWP-7941) ([18a42cee](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/18a42ceeeb32aacf72fb2d441059ec91b6cef055))
|
|
7
|
+
|
|
8
|
+
* * *
|
|
9
|
+
* * *
|
|
10
|
+
## 4.19.7 (2022-02-13)
|
|
11
|
+
|
|
12
|
+
##### Chores
|
|
13
|
+
|
|
14
|
+
* **other:**
|
|
15
|
+
* activate route replacement - added backward compatibility with current route replacement for higher envs - MWP-7941 [MWP-7941](https://webgate.ec.europa.eu/CITnet/jira/browse/MWP-7941) ([be5735d6](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/be5735d645e360389b64da44b2b9fcae4739febf))
|
|
16
|
+
|
|
17
|
+
* * *
|
|
18
|
+
* * *
|
|
19
|
+
## 4.19.6 (2022-02-07)
|
|
20
|
+
|
|
21
|
+
##### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* **other:**
|
|
24
|
+
* set dot-prop injected resources for v13 to 6.0.1 - EUI-4107 [EUI-4107](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-4107) ([27e176a9](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/27e176a96b57b2b57488be4defe39490ec12d07c))
|
|
25
|
+
|
|
26
|
+
* * *
|
|
27
|
+
* * *
|
|
28
|
+
## 4.19.5 (2022-02-03)
|
|
29
|
+
|
|
30
|
+
##### Bug Fixes
|
|
31
|
+
|
|
32
|
+
* **other:**
|
|
33
|
+
* pwa project location - EUI-4107 [EUI-4107](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-4107) ([6b645602](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/6b64560289d1faae81906efab5e840ab48472d2b))
|
|
34
|
+
|
|
35
|
+
* * *
|
|
36
|
+
* * *
|
|
1
37
|
## 4.19.4 (2022-02-03)
|
|
2
38
|
|
|
3
39
|
##### Chores
|
package/global.test.js
CHANGED
|
@@ -28,6 +28,7 @@ describe('eUI tools - test imports', () => {
|
|
|
28
28
|
const prebuildInjectionConfig = require('./scripts/utils/pre-build/injection/config');
|
|
29
29
|
const prebuildInjectionSkeletons = require('./scripts/utils/pre-build/injection/skeletons');
|
|
30
30
|
const prebuildInjectionExternals = require('./scripts/utils/pre-build/injection/externals');
|
|
31
|
+
const prebuildInjectionRoutesReplacement = require('./scripts/utils/pre-build/injection/routes-replacement');
|
|
31
32
|
|
|
32
33
|
// utils -pre-build - translations
|
|
33
34
|
const prebuildTranslationUtils = require('./scripts/utils/pre-build/translations/translation-utils');
|
package/package.json
CHANGED
package/sandbox.js
CHANGED
|
@@ -648,5 +648,6 @@ return Promise.resolve()
|
|
|
648
648
|
// return injectionUtils.externals.injectExternalAppSources(prj);
|
|
649
649
|
// })
|
|
650
650
|
.then(() => {
|
|
651
|
-
return injectionUtils.externals.remapRoutesByEnvConfig(prj, 'DEV', true);
|
|
651
|
+
// return injectionUtils.externals.remapRoutesByEnvConfig(prj, 'DEV', true);
|
|
652
|
+
return injectionUtils.routesReplacement.buildRoutes(prj, 'DEV', true);
|
|
652
653
|
})
|
|
@@ -1125,7 +1125,7 @@ module.exports.registerAngularProjectDef = (project, build = false) => {
|
|
|
1125
1125
|
if (project.build && project.build.pwa) {
|
|
1126
1126
|
jsonFile['projects'][project.name].architect.build.options.serviceWorker = true;
|
|
1127
1127
|
jsonFile['projects'][project.name].architect.build.options.ngswConfigPath = "ngsw-config.json";
|
|
1128
|
-
jsonFile['projects'][project.name].architect.build.options.assets.push(
|
|
1128
|
+
jsonFile['projects'][project.name].architect.build.options.assets.push(`apps/${project.name}/src/manifest.webmanifest`);
|
|
1129
1129
|
}
|
|
1130
1130
|
}
|
|
1131
1131
|
|
|
@@ -9,7 +9,7 @@ const configUtils = require('../../../csdr/config/config-utils');
|
|
|
9
9
|
|
|
10
10
|
module.exports.injectExternalFeatures = (project) => {
|
|
11
11
|
|
|
12
|
-
tools.
|
|
12
|
+
tools.logTitle(`Injecting project external features for : ${project.name}`);
|
|
13
13
|
|
|
14
14
|
return Promise.resolve()
|
|
15
15
|
.then(() => {
|
|
@@ -66,7 +66,7 @@ module.exports.injectExternalFeatures = (project) => {
|
|
|
66
66
|
|
|
67
67
|
module.exports.injectExternalAppSources = (project) => {
|
|
68
68
|
|
|
69
|
-
tools.
|
|
69
|
+
tools.logTitle(`Injecting project external application sources for : ${project.name}`);
|
|
70
70
|
|
|
71
71
|
return Promise.resolve()
|
|
72
72
|
.then(() => {
|
|
@@ -123,7 +123,7 @@ module.exports.injectExternalAppSources = (project) => {
|
|
|
123
123
|
|
|
124
124
|
module.exports.injectElementExternalSources = (pkg) => {
|
|
125
125
|
|
|
126
|
-
tools.
|
|
126
|
+
tools.logTitle(`Injecting package external sources for : ${pkg.name}`);
|
|
127
127
|
|
|
128
128
|
return Promise.resolve()
|
|
129
129
|
.then(() => {
|
|
@@ -181,7 +181,7 @@ module.exports.injectElementExternalSources = (pkg) => {
|
|
|
181
181
|
|
|
182
182
|
module.exports.injectExternalMock = (project) => {
|
|
183
183
|
|
|
184
|
-
tools.
|
|
184
|
+
tools.logTitle(`Injecting project external mock for : ${project.name}`);
|
|
185
185
|
|
|
186
186
|
return Promise.resolve()
|
|
187
187
|
.then(() => {
|
|
@@ -197,148 +197,3 @@ module.exports.injectExternalMock = (project) => {
|
|
|
197
197
|
throw e;
|
|
198
198
|
})
|
|
199
199
|
}
|
|
200
|
-
|
|
201
|
-
module.exports.remapRoutesByEnvConfig = (project, envTarget, build) => {
|
|
202
|
-
tools.logInfo(`Remapping routes by env config for ${envTarget}`);
|
|
203
|
-
|
|
204
|
-
return Promise.resolve()
|
|
205
|
-
.then(() => {
|
|
206
|
-
// getting config file
|
|
207
|
-
const projectAssetsPath = path.join(process.cwd(), project.folder, 'src', 'assets');
|
|
208
|
-
let configFile;
|
|
209
|
-
|
|
210
|
-
// build - envTarget based
|
|
211
|
-
if (build) {
|
|
212
|
-
let envTargetFinal = envTarget.toLowerCase();
|
|
213
|
-
// dirty fix as openid files do not respect envTarget names
|
|
214
|
-
if (envTargetFinal === 'tst') {
|
|
215
|
-
envTargetFinal = 'test';
|
|
216
|
-
}
|
|
217
|
-
configFile = path.join(projectAssetsPath, 'openid-login-config.' + envTargetFinal + '.json');
|
|
218
|
-
|
|
219
|
-
// serve configuration based
|
|
220
|
-
} else {
|
|
221
|
-
if (envTarget.indexOf('local') > -1) {
|
|
222
|
-
configFile = path.join(projectAssetsPath, 'openid-login-config.' + envTarget.replace('-openid', '') + '.json');
|
|
223
|
-
} else {
|
|
224
|
-
configFile = path.join(projectAssetsPath, 'openid-login-config.local-' + envTarget + '.json');
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
tools.logInfo(`checking ${configFile}`);
|
|
229
|
-
if (!tools.isFileExists(configFile)) {
|
|
230
|
-
tools.logError(`config file for ${envTarget} do not exists`);
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// getting config file content and checking if routesRemapping is set
|
|
235
|
-
const config = require(configFile);
|
|
236
|
-
const routesRemapping = config.routesRemapping;
|
|
237
|
-
if (!routesRemapping) {
|
|
238
|
-
tools.logWarning('No routes remapping found in current config...skipping');
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
// checking is routes path declared
|
|
243
|
-
if (!project.appSources.routesFilePath) {
|
|
244
|
-
tools.logError('project appSources.routesFilePath is not declared in app config');
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
// checking is routes file exists
|
|
249
|
-
const routesFilePath = path.join(project.paths.rootPath, project.appSources.routesFilePath);
|
|
250
|
-
if (!tools.isFileExists(routesFilePath)) {
|
|
251
|
-
tools.logError(`Unable to find routes files : ${routesFilePath}`);
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
let routesFileContent = tools.getFileContent(routesFilePath);
|
|
256
|
-
|
|
257
|
-
// get routes file content and replace tokens
|
|
258
|
-
routesRemapping.forEach((route) => {
|
|
259
|
-
tools.logInfo(`\nchecking replacement for : ${JSON.stringify(route)}`);
|
|
260
|
-
const tokenToSearch = `./features/${route.featureModule}-lib.module#Module`;
|
|
261
|
-
tools.logInfo(`Searching token : ${tokenToSearch}`);
|
|
262
|
-
if (routesFileContent.indexOf(tokenToSearch) > -1) {
|
|
263
|
-
tools.logInfo(`token ${tokenToSearch} found...replacing by ${route.routeModuleDef}`);
|
|
264
|
-
routesFileContent = tools.replaceAll(routesFileContent, tokenToSearch, route.routeModuleDef);
|
|
265
|
-
} else {
|
|
266
|
-
tools.logWarning(`token ${tokenToSearch} NOT FOUND`);
|
|
267
|
-
}
|
|
268
|
-
})
|
|
269
|
-
|
|
270
|
-
// extra physical routes remapping
|
|
271
|
-
const extraRoutesRemapping = config.extraRoutesRemapping;
|
|
272
|
-
if (!extraRoutesRemapping) {
|
|
273
|
-
tools.logWarning('No extra routes remapping found in current config...skipping');
|
|
274
|
-
|
|
275
|
-
} else {
|
|
276
|
-
tools.logInfo('Extra routes remapping');
|
|
277
|
-
extraRoutesRemapping.forEach((route) => {
|
|
278
|
-
tools.logInfo(`checking replacement ${JSON.stringify(route)}`);
|
|
279
|
-
const tokenToSearch = route.currentRoute;
|
|
280
|
-
if (routesFileContent.indexOf(tokenToSearch) > -1) {
|
|
281
|
-
tools.logInfo(`token ${tokenToSearch} found...replacing by ${route.updatedRoute}`);
|
|
282
|
-
routesFileContent = tools.replaceAll(routesFileContent, tokenToSearch, route.updatedRoute);
|
|
283
|
-
} else {
|
|
284
|
-
tools.logWarning(`token ${tokenToSearch} NOT FOUND`);
|
|
285
|
-
}
|
|
286
|
-
})
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
// checking paths mapping (new method for v10 remotes)
|
|
290
|
-
const pathsMapping = config.pathsMapping;
|
|
291
|
-
if (!pathsMapping) {
|
|
292
|
-
tools.logWarning('No pathsMapping found in current config...skipping');
|
|
293
|
-
|
|
294
|
-
} else {
|
|
295
|
-
tools.logInfo('Paths mappings for v10 remotes activation');
|
|
296
|
-
pathsMapping.forEach((pathMapping) => {
|
|
297
|
-
tools.logInfo(`Checking path: ${pathMapping.path}`);
|
|
298
|
-
const placeholderToSearch = `// ${pathMapping.path}-placeholder`;
|
|
299
|
-
|
|
300
|
-
if (routesFileContent.indexOf(placeholderToSearch) > -1) {
|
|
301
|
-
tools.logInfo(`path placeholder: "${placeholderToSearch}" found...replacing`);
|
|
302
|
-
|
|
303
|
-
let placeholderContent = '';
|
|
304
|
-
if (pathMapping.data) {
|
|
305
|
-
placeholderContent += 'data:{';
|
|
306
|
-
if (pathMapping.data.featureName) {
|
|
307
|
-
placeholderContent += `featureName: "${pathMapping.data.featureName}"`;
|
|
308
|
-
}
|
|
309
|
-
if (pathMapping.data.moduleId) {
|
|
310
|
-
placeholderContent += `, moduleId: "${pathMapping.data.moduleId}"`;
|
|
311
|
-
}
|
|
312
|
-
if (pathMapping.data.elementTag) {
|
|
313
|
-
placeholderContent += `, elementTag: "${pathMapping.data.elementTag}"`;
|
|
314
|
-
}
|
|
315
|
-
if (pathMapping.data.iframe) {
|
|
316
|
-
placeholderContent += `, iframe: ${pathMapping.data.iframe}`;
|
|
317
|
-
}
|
|
318
|
-
placeholderContent += '}';
|
|
319
|
-
}
|
|
320
|
-
if (pathMapping.loadChildren) {
|
|
321
|
-
placeholderContent += `, loadChildren: "${pathMapping.loadChildren}"`;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
tools.logInfo('Generated content for route: ');
|
|
325
|
-
console.log(placeholderContent);
|
|
326
|
-
|
|
327
|
-
routesFileContent = tools.replaceAll(routesFileContent, placeholderToSearch, placeholderContent);
|
|
328
|
-
|
|
329
|
-
} else {
|
|
330
|
-
tools.logWarning(`token ${placeholderToSearch} NOT FOUND`);
|
|
331
|
-
}
|
|
332
|
-
})
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
return tools.writeFileContent(routesFilePath, routesFileContent);
|
|
336
|
-
})
|
|
337
|
-
.then(() => {
|
|
338
|
-
tools.logSuccess();
|
|
339
|
-
})
|
|
340
|
-
|
|
341
|
-
.catch((e) => {
|
|
342
|
-
throw e;
|
|
343
|
-
})
|
|
344
|
-
}
|
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
const innerConfig = require('./config');
|
|
5
5
|
const innerSkeletons = require('./skeletons');
|
|
6
6
|
const innerExternals = require('./externals');
|
|
7
|
+
const innerRoutesReplacement = require('./routes-replacement');
|
|
7
8
|
|
|
8
9
|
// re-exports inner modules
|
|
9
10
|
module.exports.config = innerConfig;
|
|
10
11
|
module.exports.skeletons = innerSkeletons;
|
|
11
12
|
module.exports.externals = innerExternals;
|
|
13
|
+
module.exports.routesReplacement = innerRoutesReplacement;
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const _ = require('lodash');
|
|
5
|
+
|
|
6
|
+
const tools = require('../../tools');
|
|
7
|
+
const configUtils = require('../../../csdr/config/config-utils');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
const getEnvTarget = (envTarget, build) => {
|
|
11
|
+
let envTargetFinal = envTarget.toLowerCase();
|
|
12
|
+
|
|
13
|
+
if (build) {
|
|
14
|
+
// dirty fix as openid files do not respect envTarget names
|
|
15
|
+
if (envTargetFinal === 'tst') {
|
|
16
|
+
envTargetFinal = 'test';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// serve configuration based
|
|
20
|
+
} else {
|
|
21
|
+
if (envTarget.indexOf('local') > -1) {
|
|
22
|
+
envTargetFinal = envTarget.replace('-openid', '');
|
|
23
|
+
} else {
|
|
24
|
+
envTargetFinal = 'local-' + envTargetFinal;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return envTargetFinal;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
const getEnvConfig = (project, envTarget, build) => {
|
|
34
|
+
tools.logInfo(`Getting config file for env : ${envTarget}`);
|
|
35
|
+
|
|
36
|
+
return Promise.resolve()
|
|
37
|
+
.then(() => {
|
|
38
|
+
// getting config file
|
|
39
|
+
const projectAssetsPath = path.join(process.cwd(), project.folder, 'src', 'assets');
|
|
40
|
+
const envTargetFinal = getEnvTarget(envTarget, build);
|
|
41
|
+
const configFile = path.join(projectAssetsPath, 'openid-login-config.' + envTargetFinal + '.json');
|
|
42
|
+
|
|
43
|
+
tools.logInfo(`checking ${configFile}`);
|
|
44
|
+
if (!tools.isFileExists(configFile)) {
|
|
45
|
+
tools.logError(`config file for ${envTarget} do not exists`);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return require(configFile);
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
.catch((e) => {
|
|
53
|
+
throw e;
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const getRoutesFile = (project, isFullReplacement) => {
|
|
58
|
+
tools.logInfo('Getting routes file for replacement');
|
|
59
|
+
|
|
60
|
+
return Promise.resolve()
|
|
61
|
+
.then(() => {
|
|
62
|
+
if (!project.appSources) {
|
|
63
|
+
tools.logError('project requires appSources definition');
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let routesFilePath;
|
|
68
|
+
|
|
69
|
+
if (isFullReplacement) {
|
|
70
|
+
let srcRoutesFilePath;
|
|
71
|
+
|
|
72
|
+
if (!project.appSources.routesFileNpmPkg || !project.appSources.routesFileSource || !project.appSources.routesFilePath) {
|
|
73
|
+
tools.logError('project requires appSources.routesFileNpmPkg, routesFileSources and routesFilePath definitions');
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// check if package is locally cloned
|
|
78
|
+
const localPackage = configUtils.packages.getPackages().filter((p) => {
|
|
79
|
+
return p.npmPkg === project.appSources.routesFileNpmPkg
|
|
80
|
+
})[0];
|
|
81
|
+
|
|
82
|
+
// if local package is found
|
|
83
|
+
if (localPackage) {
|
|
84
|
+
tools.logInfo('local package found, copying from local');
|
|
85
|
+
srcRoutesFilePath = path.join(process.cwd(), 'packages', localPackage.name, project.appSources.routesFileSource);
|
|
86
|
+
|
|
87
|
+
// if not sources are taken from the npm package def in node_modules
|
|
88
|
+
} else {
|
|
89
|
+
tools.logInfo('remote package found, copying from remote');
|
|
90
|
+
const npmPkgScope = project.appSources.routesFileNpmPkg.substr(0, project.appSources.routesFileNpmPkg.indexOf('/'));
|
|
91
|
+
const npmPkgName = project.appSources.routesFileNpmPkg.substr(project.appSources.routesFileNpmPkg.indexOf('/') + 1);
|
|
92
|
+
|
|
93
|
+
srcRoutesFilePath = path.join(process.cwd(), 'node_modules', npmPkgScope, npmPkgName, project.appSources.routesFileSource);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
routesFilePath = path.join(project.paths.rootPath, project.appSources.routesFilePath);
|
|
97
|
+
|
|
98
|
+
// copy source file to project destination
|
|
99
|
+
tools.copy(srcRoutesFilePath, routesFilePath);
|
|
100
|
+
|
|
101
|
+
} else {
|
|
102
|
+
if (!project.appSources.routesFilePath) {
|
|
103
|
+
tools.logError('project requires appSources.routesFilePath definition');
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
routesFilePath = path.join(project.paths.rootPath, project.appSources.routesFilePath);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// checking is routes path declared
|
|
111
|
+
if (!tools.isFileExists(routesFilePath)) {
|
|
112
|
+
tools.logError(`Unable to find ${routesFilePath}`);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return routesFilePath;
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
.catch((e) => {
|
|
120
|
+
throw e;
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const remapRoutes = (config, routesFileContent) => {
|
|
125
|
+
tools.logInfo('config.routesRemapping found...Staring routes remapping');
|
|
126
|
+
|
|
127
|
+
console.log(routesFileContent);
|
|
128
|
+
|
|
129
|
+
return Promise.resolve()
|
|
130
|
+
.then(() => {
|
|
131
|
+
config.routesRemapping.forEach((route) => {
|
|
132
|
+
tools.logInfo(`\nchecking replacement for : ${JSON.stringify(route)}`);
|
|
133
|
+
const tokenToSearch = `./features/${route.featureModule}-lib.module#Module`;
|
|
134
|
+
tools.logInfo(`Searching token : ${tokenToSearch}`);
|
|
135
|
+
if (routesFileContent.indexOf(tokenToSearch) > -1) {
|
|
136
|
+
tools.logInfo(`token ${tokenToSearch} found...replacing by ${route.routeModuleDef}`);
|
|
137
|
+
routesFileContent = tools.replaceAll(routesFileContent, tokenToSearch, route.routeModuleDef);
|
|
138
|
+
} else {
|
|
139
|
+
tools.logWarning(`token ${tokenToSearch} NOT FOUND`);
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
if (!config.extraRoutesRemapping) {
|
|
144
|
+
tools.logWarning('No extra routes remapping found in current config...skipping');
|
|
145
|
+
|
|
146
|
+
} else {
|
|
147
|
+
tools.logInfo('Extra routes remapping');
|
|
148
|
+
config.extraRoutesRemapping.forEach((route) => {
|
|
149
|
+
tools.logInfo(`checking replacement ${JSON.stringify(route)}`);
|
|
150
|
+
const tokenToSearch = route.currentRoute;
|
|
151
|
+
if (routesFileContent.indexOf(tokenToSearch) > -1) {
|
|
152
|
+
tools.logInfo(`token ${tokenToSearch} found...replacing by ${route.updatedRoute}`);
|
|
153
|
+
routesFileContent = tools.replaceAll(routesFileContent, tokenToSearch, route.updatedRoute);
|
|
154
|
+
} else {
|
|
155
|
+
tools.logWarning(`token ${tokenToSearch} NOT FOUND`);
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return routesFileContent;
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
.catch((e) => {
|
|
164
|
+
throw e;
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
const replaceRoutes = (project, envTarget, build, routesFileContent) => {
|
|
170
|
+
tools.logInfo('config.routesRemapping not found...Starting full routes replacement');
|
|
171
|
+
|
|
172
|
+
return Promise.resolve()
|
|
173
|
+
.then(() => {
|
|
174
|
+
// getting base route defs content
|
|
175
|
+
const projectAssetsPath = path.join(process.cwd(), project.folder, 'src', 'assets');
|
|
176
|
+
const baseRouteDefsPath = path.join(projectAssetsPath, 'route-defs-base.json');
|
|
177
|
+
|
|
178
|
+
if (!tools.isFileExists(baseRouteDefsPath)) {
|
|
179
|
+
tools.logError(`${baseRouteDefsPath} File NOT FOUND`);
|
|
180
|
+
throw 'BASE_ROUTE_DEFS_FILE_NOT_FOUND';
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const baseRouteDefsJSON = require(baseRouteDefsPath);
|
|
184
|
+
|
|
185
|
+
// getting env route defs content if build mode (not serve)
|
|
186
|
+
let envRouteDefsPath, envRouteDefsJSON = [];
|
|
187
|
+
const envTargetFinal = getEnvTarget(envTarget, build);
|
|
188
|
+
|
|
189
|
+
envRouteDefsPath = path.join(projectAssetsPath, 'route-defs.' + envTargetFinal + '.json');
|
|
190
|
+
|
|
191
|
+
if (!tools.isFileExists(envRouteDefsPath)) {
|
|
192
|
+
tools.logError(`${envRouteDefsPath} File NOT FOUND`);
|
|
193
|
+
throw 'ENV_ROUTE_DEFS_FILE_NOT_FOUND';
|
|
194
|
+
}
|
|
195
|
+
envRouteDefsJSON = require(envRouteDefsPath);
|
|
196
|
+
|
|
197
|
+
// merging content of base + env
|
|
198
|
+
tools.logInfo(`Merging ${baseRouteDefsPath} with ${envRouteDefsPath}`);
|
|
199
|
+
|
|
200
|
+
const mergedRouteDefs = _.merge(_.keyBy(baseRouteDefsJSON, 'path'), _.keyBy(envRouteDefsJSON, 'path'));
|
|
201
|
+
const finalRouteDefs = _.values(mergedRouteDefs);
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
// processing routes
|
|
205
|
+
let placeHolderContent = '';
|
|
206
|
+
|
|
207
|
+
tools.logInfo('Processing routes replacement');
|
|
208
|
+
finalRouteDefs.forEach((route) => {
|
|
209
|
+
tools.logInfo(`====> route : ${route.path}`);
|
|
210
|
+
|
|
211
|
+
let routeContent = '{\n';
|
|
212
|
+
|
|
213
|
+
routeContent += ` path: '${route.path}',\n`;
|
|
214
|
+
if (route.data) {
|
|
215
|
+
routeContent += ' data: {\n';
|
|
216
|
+
|
|
217
|
+
if (route.data.id) {
|
|
218
|
+
routeContent += ` id: '${route.data.id}',\n`;
|
|
219
|
+
}
|
|
220
|
+
if (route.data.ids) {
|
|
221
|
+
routeContent += ` ids: '${route.data.ids}',\n`;
|
|
222
|
+
}
|
|
223
|
+
if (route.data.featureName) {
|
|
224
|
+
routeContent += ` featureName: '${route.data.featureName}',\n`;
|
|
225
|
+
}
|
|
226
|
+
if (route.data.moduleId) {
|
|
227
|
+
routeContent += ` moduleId: '${route.data.moduleId}',\n`;
|
|
228
|
+
}
|
|
229
|
+
if (route.data.elementTag) {
|
|
230
|
+
routeContent += ` elementTag: '${route.data.elementTag}',\n`;
|
|
231
|
+
}
|
|
232
|
+
if (route.data.iframe) {
|
|
233
|
+
routeContent += ` iframe: ${route.data.iframe},\n`;
|
|
234
|
+
}
|
|
235
|
+
routeContent += ' },\n';
|
|
236
|
+
}
|
|
237
|
+
if (route.canActivate) {
|
|
238
|
+
routeContent += ` canActivate: ${route.canActivate},\n`;
|
|
239
|
+
}
|
|
240
|
+
if (route.loadChildren) {
|
|
241
|
+
routeContent += ` loadChildren: '${route.loadChildren}',\n`
|
|
242
|
+
}
|
|
243
|
+
routeContent += '},\n\n';
|
|
244
|
+
|
|
245
|
+
placeHolderContent += routeContent;
|
|
246
|
+
|
|
247
|
+
tools.logSuccess('======> OK replaced');
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
const placeHolderToken = '// routes-placeholder';
|
|
251
|
+
routesFileContent = tools.replaceAll(routesFileContent, placeHolderToken, placeHolderContent);
|
|
252
|
+
|
|
253
|
+
tools.logInfo('Routes file content replaced : ');
|
|
254
|
+
console.log(routesFileContent);
|
|
255
|
+
|
|
256
|
+
return routesFileContent;
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
.catch((e) => {
|
|
260
|
+
throw e;
|
|
261
|
+
})
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
module.exports.buildRoutes = (project, envTarget, build) => {
|
|
266
|
+
tools.logTitle('Starting routes replacement');
|
|
267
|
+
|
|
268
|
+
let config, routesFile, routesFileContent;
|
|
269
|
+
|
|
270
|
+
return Promise.resolve()
|
|
271
|
+
.then(() => {
|
|
272
|
+
return getEnvConfig(project, envTarget, build);
|
|
273
|
+
})
|
|
274
|
+
.then((envConfig) => {
|
|
275
|
+
if (!envConfig) {
|
|
276
|
+
throw 'ENV_CONFIG_NOT_FOUND';
|
|
277
|
+
}
|
|
278
|
+
config = envConfig;
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
.then(() => {
|
|
282
|
+
if (config.routesRemapping) {
|
|
283
|
+
return getRoutesFile(project);
|
|
284
|
+
|
|
285
|
+
} else {
|
|
286
|
+
return getRoutesFile(project, true);
|
|
287
|
+
}
|
|
288
|
+
})
|
|
289
|
+
.then((outRoutesFile) => {
|
|
290
|
+
if (!outRoutesFile) {
|
|
291
|
+
throw 'ROUTES_FILE_NOT_FOUND';
|
|
292
|
+
}
|
|
293
|
+
routesFile = outRoutesFile;
|
|
294
|
+
routesFileContent = tools.getFileContent(routesFile);
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
.then(() => {
|
|
299
|
+
if (config.routesRemapping) {
|
|
300
|
+
return remapRoutes(config, routesFileContent);
|
|
301
|
+
|
|
302
|
+
} else {
|
|
303
|
+
return replaceRoutes(project, envTarget, build, routesFileContent);
|
|
304
|
+
}
|
|
305
|
+
})
|
|
306
|
+
|
|
307
|
+
.then((finalRouteFileContent) => {
|
|
308
|
+
return tools.writeFileContent(routesFile, finalRouteFileContent);
|
|
309
|
+
})
|
|
310
|
+
.then(() => {
|
|
311
|
+
tools.logSuccess();
|
|
312
|
+
})
|
|
313
|
+
|
|
314
|
+
.catch((e) => {
|
|
315
|
+
throw e;
|
|
316
|
+
})
|
|
317
|
+
}
|
|
318
|
+
|
|
@@ -60,7 +60,7 @@ module.exports.preBuild = (project, envTarget, build, configEnvTarget) => {
|
|
|
60
60
|
|
|
61
61
|
.then(() => {
|
|
62
62
|
if (project.config && project.appSources && project.appSources.external && project.appSources.remapRoutesByEnvConfig) {
|
|
63
|
-
return injectionUtils.
|
|
63
|
+
return injectionUtils.routesReplacement.buildRoutes(project, envTarget, build);
|
|
64
64
|
}
|
|
65
65
|
})
|
|
66
66
|
|