@eui/tools 6.10.0 → 6.10.2
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/.prettierrc.json
CHANGED
package/.version.properties
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
6.10.
|
|
1
|
+
6.10.2
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
## 6.10.2 (2023-03-27)
|
|
2
|
+
|
|
3
|
+
##### Chores
|
|
4
|
+
|
|
5
|
+
* **other:**
|
|
6
|
+
* add remote-metadata.json extraction during routes replacement - refactored route replacement - MWP-9204 [MWP-9204](https://webgate.ec.europa.eu/CITnet/jira/browse/MWP-9204) ([d70be286](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/d70be286e52a0f9a4f2be0f3d854d4fe20776870))
|
|
7
|
+
|
|
8
|
+
* * *
|
|
9
|
+
* * *
|
|
10
|
+
## 6.10.1 (2023-03-24)
|
|
11
|
+
|
|
12
|
+
##### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **other:**
|
|
15
|
+
* test failing and replace by my-workplace-host project ([7aa2cee9](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/7aa2cee9d32c21e632cd423c6bbf29deac992f6f))
|
|
16
|
+
* throw exception if route not found or remote route not found - EUI-7121 [EUI-7121](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-7121) ([18f5d41e](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/18f5d41e321f2e91c874a9ec8e7b2d08d6a9b4c2))
|
|
17
|
+
|
|
18
|
+
* * *
|
|
19
|
+
* * *
|
|
1
20
|
## 6.10.0 (2023-03-24)
|
|
2
21
|
|
|
3
22
|
##### New Features
|
package/package.json
CHANGED
|
@@ -13,12 +13,12 @@ describe('[csdr/config/config-utils] - getCsdrProject()', () => {
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
it('should return valid project details if project exists', () => {
|
|
16
|
-
const prj = projects.getCsdrProject('my-workplace');
|
|
16
|
+
const prj = projects.getCsdrProject('my-workplace-host');
|
|
17
17
|
expect(prj).not.to.be.null;
|
|
18
|
-
expect(prj.name).to.equal('my-workplace');
|
|
19
|
-
expect(prj.devopsMetadataFile).to.equal('app-my-workplace-build-metadata.json');
|
|
20
|
-
expect(prj.devopsEnvsMetadataFile).to.equal('app-my-workplace-envs-metadata.json');
|
|
21
|
-
expect(prj.devopsVersionsMetadataFile).to.equal('app-my-workplace-versions-metadata.json');
|
|
22
|
-
expect(prj.devopsHistoryMetadataFile).to.equal('app-my-workplace-history-metadata.json');
|
|
18
|
+
expect(prj.name).to.equal('my-workplace-host');
|
|
19
|
+
expect(prj.devopsMetadataFile).to.equal('app-my-workplace-host-build-metadata.json');
|
|
20
|
+
expect(prj.devopsEnvsMetadataFile).to.equal('app-my-workplace-host-envs-metadata.json');
|
|
21
|
+
expect(prj.devopsVersionsMetadataFile).to.equal('app-my-workplace-host-versions-metadata.json');
|
|
22
|
+
expect(prj.devopsHistoryMetadataFile).to.equal('app-my-workplace-host-history-metadata.json');
|
|
23
23
|
})
|
|
24
24
|
});
|
|
@@ -8,10 +8,73 @@ const configUtils = require('../../../csdr/config/config-utils');
|
|
|
8
8
|
|
|
9
9
|
const { debug } = tools.getArgs();
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* ROUTES REPLACEMENT
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Process routes either for playground local environment OR by envTarget at build time,
|
|
19
|
+
* injects the routesContent generated inside the project/src/app/app.routes.ts file from a base route file and
|
|
20
|
+
* based on definitions in mywp-host-ui/assets/routes folder definitions as data input
|
|
21
|
+
*
|
|
22
|
+
* used by projects pre-build phase
|
|
23
|
+
*
|
|
24
|
+
* PUBLIC
|
|
25
|
+
*
|
|
26
|
+
* @param {project} project The CSDR project object fetched from csdr global projects config
|
|
27
|
+
* @param {string} envTarget The build-time environment target provided to target specific routes for specific environment deployments
|
|
28
|
+
* @param {boolean} build if the script is launched from a release pipeline OR from local CSDR playground environment (false in that case)
|
|
29
|
+
* @returns {Promise} returns a Promise as it involves async I/O processes
|
|
30
|
+
*/
|
|
31
|
+
module.exports.buildRoutes = (project, envTarget, build) => {
|
|
32
|
+
tools.logTitle('Starting routes replacement');
|
|
33
|
+
|
|
34
|
+
let config, routesFile, routesFileContent;
|
|
35
|
+
|
|
36
|
+
const euiVersion = configUtils.projects.getProjectEuiVersion(project);
|
|
37
|
+
|
|
38
|
+
return Promise.resolve()
|
|
39
|
+
.then(() => {
|
|
40
|
+
return injectRoutesConfig(project, project.externalRoutesSources.routesConfigNpmPkg);
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
.then(() => {
|
|
44
|
+
return getRoutesFile(project, euiVersion);
|
|
45
|
+
})
|
|
46
|
+
.then((outRoutesFile) => {
|
|
47
|
+
if (!outRoutesFile) {
|
|
48
|
+
throw 'ROUTES_FILE_NOT_FOUND';
|
|
49
|
+
}
|
|
50
|
+
routesFile = outRoutesFile;
|
|
51
|
+
routesFileContent = tools.getFileContent(routesFile);
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
.then(() => {
|
|
55
|
+
return processRoutesConfig(project, envTarget, build, routesFile, routesFileContent, euiVersion);
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
.then(() => {
|
|
59
|
+
tools.logSuccess();
|
|
60
|
+
})
|
|
11
61
|
|
|
62
|
+
.catch((e) => {
|
|
63
|
+
throw e;
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Get the env target, transform input envTarget to known files suffix or handle local / playground file
|
|
69
|
+
*
|
|
70
|
+
* PRIVATE
|
|
71
|
+
*
|
|
72
|
+
* @param {string} envTargetIn The build-time environment target provided to target specific routes for specific environment deployments
|
|
73
|
+
* @param {boolean} build if the script is launched from a release pipeline OR from local CSDR playground environment (false in that case) * @return routeContent the text block transformed from the route object as input
|
|
74
|
+
* @returns {string} the envTarget transformed
|
|
75
|
+
*/
|
|
12
76
|
const getEnvTarget = (envTargetIn, build) => {
|
|
13
77
|
if (!envTargetIn) {
|
|
14
|
-
|
|
15
78
|
// check if envTarget has been provided as cli args for stand-alone local build of CSDR apps
|
|
16
79
|
const { envTarget } = tools.getArgs();
|
|
17
80
|
|
|
@@ -30,7 +93,7 @@ const getEnvTarget = (envTargetIn, build) => {
|
|
|
30
93
|
envTargetFinal = 'test';
|
|
31
94
|
}
|
|
32
95
|
|
|
33
|
-
|
|
96
|
+
// serve configuration based
|
|
34
97
|
} else {
|
|
35
98
|
if (envTargetIn.indexOf('local') > -1) {
|
|
36
99
|
envTargetFinal = envTargetIn.replace('-openid', '');
|
|
@@ -40,9 +103,17 @@ const getEnvTarget = (envTargetIn, build) => {
|
|
|
40
103
|
}
|
|
41
104
|
|
|
42
105
|
return envTargetFinal;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Get routes file of project
|
|
110
|
+
*
|
|
111
|
+
* PRIVATE
|
|
112
|
+
*
|
|
113
|
+
* @param {project} project The CSDR project object fetched from csdr global projects config
|
|
114
|
+
* @param {string} euiVersion the eUI version of the current project used mainly in local CSDR playground environment (format : v.x)
|
|
115
|
+
* @returns {string} routeContent the text block transformed from the route object as input
|
|
116
|
+
*/
|
|
46
117
|
const getRoutesFile = (project, euiVersion) => {
|
|
47
118
|
tools.logInfo('Getting routes file for replacement');
|
|
48
119
|
|
|
@@ -56,14 +127,18 @@ const getRoutesFile = (project, euiVersion) => {
|
|
|
56
127
|
let routesFilePath;
|
|
57
128
|
let srcRoutesFilePath;
|
|
58
129
|
|
|
59
|
-
if (
|
|
130
|
+
if (
|
|
131
|
+
!project.externalRoutesSources.routesConfigNpmPkg ||
|
|
132
|
+
!project.externalRoutesSources.routesFileSource ||
|
|
133
|
+
!project.externalRoutesSources.routesFilePath
|
|
134
|
+
) {
|
|
60
135
|
tools.logError('project requires externalRoutesSources.routesConfigNpmPkg, routesFileSources and routesFilePath definitions');
|
|
61
136
|
return;
|
|
62
137
|
}
|
|
63
138
|
|
|
64
139
|
// check if package is locally cloned
|
|
65
140
|
const localPackage = configUtils.packages.getPackages().filter((p) => {
|
|
66
|
-
return p.npmPkg === project.externalRoutesSources.routesConfigNpmPkg
|
|
141
|
+
return p.npmPkg === project.externalRoutesSources.routesConfigNpmPkg;
|
|
67
142
|
})[0];
|
|
68
143
|
|
|
69
144
|
// if local package is found
|
|
@@ -73,23 +148,35 @@ const getRoutesFile = (project, euiVersion) => {
|
|
|
73
148
|
tools.logInfo(`constructing route path with eUI version provided: ${euiVersion}`);
|
|
74
149
|
|
|
75
150
|
srcRoutesFilePath = path.join(
|
|
76
|
-
process.cwd(),
|
|
77
|
-
'
|
|
78
|
-
|
|
151
|
+
process.cwd(),
|
|
152
|
+
'packages',
|
|
153
|
+
localPackage.name,
|
|
154
|
+
'assets',
|
|
155
|
+
euiVersion,
|
|
156
|
+
project.externalRoutesSources.routesFileSource
|
|
79
157
|
);
|
|
80
158
|
|
|
81
|
-
|
|
159
|
+
// if not sources are taken from the npm package def in node_modules
|
|
82
160
|
} else {
|
|
83
161
|
tools.logInfo('remote package found, copying from remote');
|
|
84
|
-
const npmPkgScope = project.externalRoutesSources.routesConfigNpmPkg.substr(
|
|
85
|
-
|
|
162
|
+
const npmPkgScope = project.externalRoutesSources.routesConfigNpmPkg.substr(
|
|
163
|
+
0,
|
|
164
|
+
project.externalRoutesSources.routesConfigNpmPkg.indexOf('/')
|
|
165
|
+
);
|
|
166
|
+
const npmPkgName = project.externalRoutesSources.routesConfigNpmPkg.substr(
|
|
167
|
+
project.externalRoutesSources.routesConfigNpmPkg.indexOf('/') + 1
|
|
168
|
+
);
|
|
86
169
|
|
|
87
170
|
tools.logInfo(`constructing route path with eUI version provided: ${euiVersion}`);
|
|
88
171
|
|
|
89
172
|
srcRoutesFilePath = path.join(
|
|
90
|
-
process.cwd(),
|
|
91
|
-
'
|
|
92
|
-
|
|
173
|
+
process.cwd(),
|
|
174
|
+
'node_modules',
|
|
175
|
+
npmPkgScope,
|
|
176
|
+
npmPkgName,
|
|
177
|
+
'assets',
|
|
178
|
+
euiVersion,
|
|
179
|
+
project.externalRoutesSources.routesFileSource
|
|
93
180
|
);
|
|
94
181
|
}
|
|
95
182
|
|
|
@@ -109,9 +196,17 @@ const getRoutesFile = (project, euiVersion) => {
|
|
|
109
196
|
|
|
110
197
|
.catch((e) => {
|
|
111
198
|
throw e;
|
|
112
|
-
})
|
|
113
|
-
}
|
|
114
|
-
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Replace route object and transform into an Angular / eUI route definition
|
|
204
|
+
*
|
|
205
|
+
* PRIVATE
|
|
206
|
+
*
|
|
207
|
+
* @param {route} route route object containing the result of the route translated into route props
|
|
208
|
+
* @returns {string} routeContent the text block transformed from the route object as input
|
|
209
|
+
*/
|
|
115
210
|
const replaceRoute = (route) => {
|
|
116
211
|
let routeContent = '{\n';
|
|
117
212
|
|
|
@@ -143,15 +238,29 @@ const replaceRoute = (route) => {
|
|
|
143
238
|
routeContent += ` canActivate: ${route.canActivate},\n`;
|
|
144
239
|
}
|
|
145
240
|
if (route.loadChildren) {
|
|
146
|
-
routeContent += ` ${route.loadChildren},\n
|
|
241
|
+
routeContent += ` ${route.loadChildren},\n`;
|
|
147
242
|
}
|
|
148
243
|
routeContent += '},\n\n';
|
|
149
244
|
|
|
150
245
|
return routeContent;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Process the routes config
|
|
250
|
+
* generates : app.routes.ts project file replacing app.routes-base.ts placehodler / remotes-metadata.json / route-defs-links.json
|
|
251
|
+
* and feature lib modules in playground local env
|
|
252
|
+
*
|
|
253
|
+
* PRIVATE
|
|
254
|
+
*
|
|
255
|
+
* @param {project} project The CSDR project object fetched from csdr global projects config
|
|
256
|
+
* @param {string} envTarget The build-time environment target provided to target specific routes for specific environment deployments
|
|
257
|
+
* @param {boolean} build if the script is launched from a release pipeline OR from local CSDR playground environment (false in that case)
|
|
258
|
+
* @param {string} routesFile the route file at project sources target to replace / update
|
|
259
|
+
* @param {string} routesFileContent the content of the base routes file to inject into the placeholder defined
|
|
260
|
+
* @param {string} euiVersion the eUI version of the current project used mainly in local CSDR playground environment
|
|
261
|
+
* @returns {Promise} returns a Promise as it involves async I/O processes
|
|
262
|
+
*/
|
|
263
|
+
const processRoutesConfig = (project, envTarget, build, routesFile, routesFileContent, euiVersion) => {
|
|
155
264
|
return Promise.resolve()
|
|
156
265
|
.then(() => {
|
|
157
266
|
tools.logInfo('Replace routes v2...');
|
|
@@ -166,7 +275,6 @@ const processRoutesConfig = (project, envTarget, build, routesFileContent, euiVe
|
|
|
166
275
|
const euiVersionNumber = euiVersion.split('.')[0];
|
|
167
276
|
const envTargetFinal = getEnvTarget(envTarget, build);
|
|
168
277
|
|
|
169
|
-
|
|
170
278
|
// getting the input file definitions of routes for replacements
|
|
171
279
|
// from tokenized template in config -- allowing to control playground vs normal env (when using the MWP HOST for release)
|
|
172
280
|
// format :
|
|
@@ -184,8 +292,6 @@ const processRoutesConfig = (project, envTarget, build, routesFileContent, euiVe
|
|
|
184
292
|
|
|
185
293
|
tools.logInfo(`Starting replacement of routes based on generated template : ${routeDefsInputFilename}`);
|
|
186
294
|
|
|
187
|
-
|
|
188
|
-
|
|
189
295
|
// Getting input routeDefs entry
|
|
190
296
|
|
|
191
297
|
const routeDefsInputPath = path.join(projectAssetsPath, routeDefsInputFilename);
|
|
@@ -197,18 +303,26 @@ const processRoutesConfig = (project, envTarget, build, routesFileContent, euiVe
|
|
|
197
303
|
|
|
198
304
|
const routeDefsInputJSON = require(path.join(routeDefsInputPath));
|
|
199
305
|
|
|
200
|
-
const appRoutes = [],
|
|
306
|
+
const appRoutes = [],
|
|
307
|
+
appFeatureLibs = [],
|
|
308
|
+
finalRemotesDefs = [];
|
|
309
|
+
|
|
310
|
+
// processing each routes found in the routeDefs entry
|
|
201
311
|
|
|
202
312
|
routeDefsInputJSON.forEach((route) => {
|
|
203
313
|
tools.logInfo(`Processing route : ${route.path}`);
|
|
204
314
|
|
|
205
|
-
const defRoute = routeDefsBaseJSON.filter(r => r.path === route.path)[0];
|
|
315
|
+
const defRoute = routeDefsBaseJSON.filter((r) => r.path === route.path)[0];
|
|
206
316
|
if (!defRoute) {
|
|
207
|
-
tools.logError('
|
|
208
|
-
|
|
317
|
+
tools.logError('route not found for: ');
|
|
318
|
+
console.log(route);
|
|
319
|
+
throw 'ROUTE_NOT_FOUND';
|
|
209
320
|
} else {
|
|
210
321
|
let loadChildrenGenerated;
|
|
211
322
|
|
|
323
|
+
// in case of a lazy route, the route is generated from a import/export feature lib module TS file
|
|
324
|
+
// those files are also generated based on the route "lazyDefs" data definition
|
|
325
|
+
|
|
212
326
|
if (route.lazy) {
|
|
213
327
|
const scopeName = defRoute.lazyLoadDef.npmPkg.split('/')[0].substr(1);
|
|
214
328
|
const pkgName = defRoute.lazyLoadDef.npmPkg.split('/')[1];
|
|
@@ -223,9 +337,10 @@ const processRoutesConfig = (project, envTarget, build, routesFileContent, euiVe
|
|
|
223
337
|
appFeatureLibs.push({
|
|
224
338
|
filename: `${lazyFeatureLibName}.ts`,
|
|
225
339
|
npmPkg: defRoute.lazyLoadDef.npmPkg,
|
|
226
|
-
moduleName: defRoute.lazyLoadDef.moduleName
|
|
340
|
+
moduleName: defRoute.lazyLoadDef.moduleName,
|
|
227
341
|
});
|
|
228
342
|
|
|
343
|
+
// if the route is a remote, the elementLoader is then used as a default feature module loaded
|
|
229
344
|
} else {
|
|
230
345
|
if (euiVersion === '10.x') {
|
|
231
346
|
loadChildrenGenerated = 'loadChildren: "./features/element-loader.module#ElementLoaderModule"';
|
|
@@ -234,38 +349,61 @@ const processRoutesConfig = (project, envTarget, build, routesFileContent, euiVe
|
|
|
234
349
|
}
|
|
235
350
|
}
|
|
236
351
|
|
|
352
|
+
// we define the route item definition, that will be injected in the project app.routes source
|
|
237
353
|
const newAppRoute = {
|
|
238
354
|
path: defRoute.path,
|
|
239
355
|
loadChildren: loadChildrenGenerated,
|
|
240
|
-
data: {}
|
|
356
|
+
data: {},
|
|
241
357
|
};
|
|
242
358
|
|
|
359
|
+
// in the case the route is auth guarded, we attach the defition of the auth parameters
|
|
243
360
|
if (defRoute.authMetadata) {
|
|
244
361
|
newAppRoute.data.id = defRoute.authMetadata.id;
|
|
245
362
|
newAppRoute.data.ids = defRoute.authMetadata.ids;
|
|
246
363
|
newAppRoute.canActivate = defRoute.authMetadata.canActivate;
|
|
247
364
|
}
|
|
248
365
|
|
|
366
|
+
// in case of a remote, the "remoteDefs" data entry are processed
|
|
367
|
+
// in case no remote corresponds to a remote path defined in the definitions, we throw an error and we stop the
|
|
368
|
+
// script to avoid bad route data / or partial routes data generated
|
|
249
369
|
if (route.remote) {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
370
|
+
let remoteDef;
|
|
371
|
+
try {
|
|
372
|
+
remoteDef = defRoute.remoteDefs.filter((r) => {
|
|
373
|
+
return r.euiVersion === route.euiVersion;
|
|
374
|
+
})[0];
|
|
375
|
+
} catch {
|
|
376
|
+
tools.logError('Remote route not found for: ');
|
|
377
|
+
console.log(route);
|
|
378
|
+
throw 'REMOTE_ROUTE_DEF_NOT_FOUND';
|
|
379
|
+
}
|
|
380
|
+
|
|
253
381
|
if (remoteDef) {
|
|
254
382
|
newAppRoute.data.moduleId = remoteDef.moduleId;
|
|
255
383
|
newAppRoute.data.elementTag = remoteDef.elementTag;
|
|
256
384
|
newAppRoute.data.iframe = remoteDef.iframe;
|
|
257
|
-
|
|
258
385
|
} else {
|
|
259
386
|
tools.logError('Remote route not found for: ');
|
|
260
387
|
console.log(route);
|
|
261
388
|
throw 'REMOTE_ROUTE_DEF_NOT_FOUND';
|
|
262
389
|
}
|
|
390
|
+
|
|
391
|
+
finalRemotesDefs.push(remoteDef.moduleId);
|
|
263
392
|
}
|
|
264
393
|
|
|
265
394
|
appRoutes.push(newAppRoute);
|
|
266
395
|
}
|
|
267
|
-
})
|
|
396
|
+
});
|
|
268
397
|
|
|
398
|
+
// writing final remotes metadata file base on routes definitions (loaded at runtime by the app for gathering the list of remotes)
|
|
399
|
+
|
|
400
|
+
if (finalRemotesDefs.length > 0) {
|
|
401
|
+
const finalRemotesDefsFile = path.join(projectAssetsPath, 'remotes-metadata.json');
|
|
402
|
+
|
|
403
|
+
tools.logInfo(`Generating ${finalRemotesDefsFile}`);
|
|
404
|
+
|
|
405
|
+
tools.writeJsonFileSync(finalRemotesDefsFile, finalRemotesDefs);
|
|
406
|
+
}
|
|
269
407
|
|
|
270
408
|
// processing creation of features lib modules entries
|
|
271
409
|
|
|
@@ -291,8 +429,7 @@ const processRoutesConfig = (project, envTarget, build, routesFileContent, euiVe
|
|
|
291
429
|
tools.writeFileContent(featureLibPath, featureLibDef);
|
|
292
430
|
});
|
|
293
431
|
|
|
294
|
-
|
|
295
|
-
// processing links generation
|
|
432
|
+
// processing links generation : generates a routes-defs-links.json based on the routes-defs-base-links.json definitions
|
|
296
433
|
|
|
297
434
|
const routeDefsBaseLinksFileName = 'route-defs-base-links.json';
|
|
298
435
|
const routeDefsBaseLinksJSON = require(path.join(projectAssetsPath, routeDefsBaseLinksFileName));
|
|
@@ -316,7 +453,10 @@ const processRoutesConfig = (project, envTarget, build, routesFileContent, euiVe
|
|
|
316
453
|
}
|
|
317
454
|
|
|
318
455
|
return routeDef;
|
|
319
|
-
}
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
// inner method for checking based on the "allowedEnvs" option provided on the links definition if the link has to be added
|
|
459
|
+
// to the links list
|
|
320
460
|
|
|
321
461
|
const isLinkAllowed = (link) => {
|
|
322
462
|
// allow all link for playground - local env
|
|
@@ -334,7 +474,9 @@ const processRoutesConfig = (project, envTarget, build, routesFileContent, euiVe
|
|
|
334
474
|
} else {
|
|
335
475
|
return true;
|
|
336
476
|
}
|
|
337
|
-
}
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
// processing each link and matching route from routes base data definitions
|
|
338
480
|
|
|
339
481
|
const linksGenerated = [];
|
|
340
482
|
|
|
@@ -343,7 +485,7 @@ const processRoutesConfig = (project, envTarget, build, routesFileContent, euiVe
|
|
|
343
485
|
|
|
344
486
|
if (link.parentId) {
|
|
345
487
|
if (isLinkAllowed(link)) {
|
|
346
|
-
newLink = { ...link};
|
|
488
|
+
newLink = { ...link };
|
|
347
489
|
newLink.children = [];
|
|
348
490
|
|
|
349
491
|
link.children.forEach((subLink) => {
|
|
@@ -354,9 +496,8 @@ const processRoutesConfig = (project, envTarget, build, routesFileContent, euiVe
|
|
|
354
496
|
newLink.children.push(defRoute);
|
|
355
497
|
}
|
|
356
498
|
}
|
|
357
|
-
})
|
|
499
|
+
});
|
|
358
500
|
}
|
|
359
|
-
|
|
360
501
|
} else {
|
|
361
502
|
if (isLinkAllowed(link)) {
|
|
362
503
|
const defRoute = getRouteMenuDef(link);
|
|
@@ -366,6 +507,10 @@ const processRoutesConfig = (project, envTarget, build, routesFileContent, euiVe
|
|
|
366
507
|
} else {
|
|
367
508
|
newLink = link;
|
|
368
509
|
}
|
|
510
|
+
|
|
511
|
+
if (link.alwaysDisplayed) {
|
|
512
|
+
newLink.alwaysDisplayed = true;
|
|
513
|
+
}
|
|
369
514
|
}
|
|
370
515
|
}
|
|
371
516
|
|
|
@@ -383,7 +528,6 @@ const processRoutesConfig = (project, envTarget, build, routesFileContent, euiVe
|
|
|
383
528
|
|
|
384
529
|
tools.writeJsonFileSync(path.join(projectAssetsPath, 'route-defs-links.json'), linksGenerated);
|
|
385
530
|
|
|
386
|
-
|
|
387
531
|
// getting routes content for replacement
|
|
388
532
|
|
|
389
533
|
tools.logInfo('Processing routes replacement');
|
|
@@ -402,21 +546,28 @@ const processRoutesConfig = (project, envTarget, build, routesFileContent, euiVe
|
|
|
402
546
|
console.log(routesFileContent);
|
|
403
547
|
}
|
|
404
548
|
|
|
405
|
-
|
|
549
|
+
// writing final routes content into project sources
|
|
550
|
+
tools.writeFileContent(routesFile, routesFileContent);
|
|
406
551
|
})
|
|
407
552
|
|
|
408
553
|
.catch((e) => {
|
|
409
554
|
throw e;
|
|
410
|
-
})
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
555
|
+
});
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Inject the routes config assets from mywp-host-ui / assets / routes to virtual project assets folder
|
|
560
|
+
*
|
|
561
|
+
* PRIVATE
|
|
562
|
+
*
|
|
563
|
+
* @param {project} project The CSDR project object fetched from csdr global projects config
|
|
564
|
+
* @param {string} npmPkg The npm package dependency containing the routes definition (for MyWorkplace : mywp-host-ui => @mywp/host)
|
|
565
|
+
* @returns undefined
|
|
566
|
+
*/
|
|
416
567
|
const injectRoutesConfig = (project, npmPkg) => {
|
|
417
568
|
// check if package is locally cloned
|
|
418
569
|
const localPackage = configUtils.packages.getPackages().filter((p) => {
|
|
419
|
-
return p.npmPkg === npmPkg
|
|
570
|
+
return p.npmPkg === npmPkg;
|
|
420
571
|
})[0];
|
|
421
572
|
|
|
422
573
|
var pkgAssetsPath;
|
|
@@ -426,7 +577,7 @@ const injectRoutesConfig = (project, npmPkg) => {
|
|
|
426
577
|
if (localPackage) {
|
|
427
578
|
pkgAssetsPath = path.join(process.cwd(), 'packages', localPackage.name, 'assets');
|
|
428
579
|
|
|
429
|
-
|
|
580
|
+
// if not sources are taken from the npm package def in node_modules
|
|
430
581
|
} else {
|
|
431
582
|
const npmPkgScope = npmPkg.substr(0, npmPkg.indexOf('/'));
|
|
432
583
|
const npmPkgName = npmPkg.substr(npmPkg.indexOf('/') + 1);
|
|
@@ -442,48 +593,4 @@ const injectRoutesConfig = (project, npmPkg) => {
|
|
|
442
593
|
|
|
443
594
|
tools.logInfo(`${routesConfigPath} - injecting in ${projectAssetsPath}`);
|
|
444
595
|
tools.copydir(routesConfigPath, projectAssetsPath);
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
module.exports.buildRoutes = (project, envTarget, build) => {
|
|
451
|
-
tools.logTitle('Starting routes replacement');
|
|
452
|
-
|
|
453
|
-
let config, routesFile, routesFileContent;
|
|
454
|
-
|
|
455
|
-
const euiVersion = configUtils.projects.getProjectEuiVersion(project);
|
|
456
|
-
|
|
457
|
-
return Promise.resolve()
|
|
458
|
-
.then(() => {
|
|
459
|
-
return injectRoutesConfig(project, project.externalRoutesSources.routesConfigNpmPkg);
|
|
460
|
-
})
|
|
461
|
-
|
|
462
|
-
.then(() => {
|
|
463
|
-
return getRoutesFile(project, euiVersion);
|
|
464
|
-
})
|
|
465
|
-
.then((outRoutesFile) => {
|
|
466
|
-
if (!outRoutesFile) {
|
|
467
|
-
throw 'ROUTES_FILE_NOT_FOUND';
|
|
468
|
-
}
|
|
469
|
-
routesFile = outRoutesFile;
|
|
470
|
-
routesFileContent = tools.getFileContent(routesFile);
|
|
471
|
-
})
|
|
472
|
-
|
|
473
|
-
.then(() => {
|
|
474
|
-
return processRoutesConfig(project, envTarget, build, routesFileContent, euiVersion);
|
|
475
|
-
})
|
|
476
|
-
|
|
477
|
-
.then((finalRouteFileContent) => {
|
|
478
|
-
return tools.writeFileContent(routesFile, finalRouteFileContent);
|
|
479
|
-
})
|
|
480
|
-
|
|
481
|
-
.then(() => {
|
|
482
|
-
tools.logSuccess();
|
|
483
|
-
})
|
|
484
|
-
|
|
485
|
-
.catch((e) => {
|
|
486
|
-
throw e;
|
|
487
|
-
})
|
|
488
|
-
}
|
|
489
|
-
|
|
596
|
+
};
|