@eui/tools 6.9.7 → 6.10.1

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.
@@ -1 +1 @@
1
- 6.9.7
1
+ 6.10.1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ ## 6.10.1 (2023-03-24)
2
+
3
+ ##### Bug Fixes
4
+
5
+ * **other:**
6
+ * test failing and replace by my-workplace-host project ([7aa2cee9](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/7aa2cee9d32c21e632cd423c6bbf29deac992f6f))
7
+ * 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))
8
+
9
+ * * *
10
+ * * *
11
+ ## 6.10.0 (2023-03-24)
12
+
13
+ ##### New Features
14
+
15
+ * **other:**
16
+ * route replacement for route config v2 activated - EUI-7121 [EUI-7121](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-7121) ([bf43901b](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/bf43901b7fceac0dd0610677d32f4eeab88e95df))
17
+
18
+ * * *
19
+ * * *
1
20
  ## 6.9.7 (2023-03-22)
2
21
 
3
22
  ##### Chores
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eui/tools",
3
- "version": "6.9.7",
3
+ "version": "6.10.1",
4
4
  "tag": "latest",
5
5
  "license": "EUPL-1.1",
6
6
  "description": "eUI common tools and scripts",
@@ -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
  });
@@ -56,62 +56,41 @@ const getRoutesFile = (project, euiVersion) => {
56
56
  let routesFilePath;
57
57
  let srcRoutesFilePath;
58
58
 
59
- if (!project.externalRoutesSources.routesFileNpmPkg || !project.externalRoutesSources.routesFileSource || !project.externalRoutesSources.routesFilePath) {
60
- tools.logError('project requires externalRoutesSources.routesFileNpmPkg, routesFileSources and routesFilePath definitions');
59
+ if (!project.externalRoutesSources.routesConfigNpmPkg || !project.externalRoutesSources.routesFileSource || !project.externalRoutesSources.routesFilePath) {
60
+ tools.logError('project requires externalRoutesSources.routesConfigNpmPkg, routesFileSources and routesFilePath definitions');
61
61
  return;
62
62
  }
63
63
 
64
64
  // check if package is locally cloned
65
65
  const localPackage = configUtils.packages.getPackages().filter((p) => {
66
- return p.npmPkg === project.externalRoutesSources.routesFileNpmPkg
66
+ return p.npmPkg === project.externalRoutesSources.routesConfigNpmPkg
67
67
  })[0];
68
68
 
69
69
  // if local package is found
70
70
  if (localPackage) {
71
71
  tools.logInfo('local package found, copying from local');
72
72
 
73
- if (tools.isFalse(project.externalRoutesSources.includeEuiVersion)) {
74
- tools.logInfo('include eUI version in routes path...skipped');
75
-
76
- srcRoutesFilePath = path.join(
77
- process.cwd(), 'packages', localPackage.name,
78
- project.externalRoutesSources.routesFileSource,
79
- );
80
-
81
- } else {
82
- tools.logInfo(`constructing route path with eUI version provided: ${euiVersion}`);
83
-
84
- srcRoutesFilePath = path.join(
85
- process.cwd(), 'packages', localPackage.name,
86
- 'assets', euiVersion,
87
- project.externalRoutesSources.routesFileSource,
88
- );
89
- }
73
+ tools.logInfo(`constructing route path with eUI version provided: ${euiVersion}`);
90
74
 
75
+ srcRoutesFilePath = path.join(
76
+ process.cwd(), 'packages', localPackage.name,
77
+ 'assets', euiVersion,
78
+ project.externalRoutesSources.routesFileSource,
79
+ );
91
80
 
92
81
  // if not sources are taken from the npm package def in node_modules
93
82
  } else {
94
83
  tools.logInfo('remote package found, copying from remote');
95
- const npmPkgScope = project.externalRoutesSources.routesFileNpmPkg.substr(0, project.externalRoutesSources.routesFileNpmPkg.indexOf('/'));
96
- const npmPkgName = project.externalRoutesSources.routesFileNpmPkg.substr(project.externalRoutesSources.routesFileNpmPkg.indexOf('/') + 1);
84
+ const npmPkgScope = project.externalRoutesSources.routesConfigNpmPkg.substr(0, project.externalRoutesSources.routesConfigNpmPkg.indexOf('/'));
85
+ const npmPkgName = project.externalRoutesSources.routesConfigNpmPkg.substr(project.externalRoutesSources.routesConfigNpmPkg.indexOf('/') + 1);
97
86
 
98
- if (tools.isFalse(project.externalRoutesSources.includeEuiVersion)) {
99
- tools.logInfo('include eUI version in routes path...skipped');
87
+ tools.logInfo(`constructing route path with eUI version provided: ${euiVersion}`);
100
88
 
101
- srcRoutesFilePath = path.join(
102
- process.cwd(), 'node_modules', npmPkgScope, npmPkgName,
103
- project.externalRoutesSources.routesFileSource,
104
- );
105
-
106
- } else {
107
- tools.logInfo(`constructing route path with eUI version provided: ${euiVersion}`);
108
-
109
- srcRoutesFilePath = path.join(
110
- process.cwd(), 'node_modules', npmPkgScope, npmPkgName,
111
- 'assets', euiVersion,
112
- project.externalRoutesSources.routesFileSource,
113
- );
114
- }
89
+ srcRoutesFilePath = path.join(
90
+ process.cwd(), 'node_modules', npmPkgScope, npmPkgName,
91
+ 'assets', euiVersion,
92
+ project.externalRoutesSources.routesFileSource,
93
+ );
115
94
  }
116
95
 
117
96
  routesFilePath = path.join(project.paths.rootPath, project.externalRoutesSources.routesFilePath);
@@ -133,93 +112,9 @@ const getRoutesFile = (project, euiVersion) => {
133
112
  })
134
113
  }
135
114
 
136
- /* @deprecated - TO REMOVE */
137
- const replaceRouteLegacy = (route) => {
138
- let routeContent = '{\n';
139
-
140
- routeContent += ` path: '${route.path}',\n`;
141
- if (route.data) {
142
- routeContent += ' data: {\n';
143
-
144
- if (route.data.id) {
145
- routeContent += ` id: '${route.data.id}',\n`;
146
- }
147
- if (route.data.ids) {
148
- routeContent += ` ids: ${route.data.ids},\n`;
149
- }
150
- if (route.data.featureName) {
151
- routeContent += ` featureName: '${route.data.featureName}',\n`;
152
- }
153
- if (route.data.moduleId) {
154
- routeContent += ` moduleId: '${route.data.moduleId}',\n`;
155
- }
156
- if (route.data.elementTag) {
157
- routeContent += ` elementTag: '${route.data.elementTag}',\n`;
158
- }
159
- if (route.data.iframe) {
160
- routeContent += ` iframe: ${route.data.iframe},\n`;
161
- }
162
- routeContent += ' },\n';
163
- }
164
- if (route.canActivate) {
165
- routeContent += ` canActivate: ${route.canActivate},\n`;
166
- }
167
- if (route.loadChildren) {
168
- routeContent += ` loadChildren: '${route.loadChildren}',\n`
169
- }
170
- routeContent += '},\n\n';
171
-
172
- return routeContent;
173
- }
174
-
175
-
176
- /* @deprecated - TO REMOVE */
177
115
  const replaceRoute = (route) => {
178
116
  let routeContent = '{\n';
179
117
 
180
- routeContent += ` path: '${route.path}',\n`;
181
- if (route.data) {
182
- routeContent += ' data: {\n';
183
-
184
- if (route.data.id) {
185
- routeContent += ` id: '${route.data.id}',\n`;
186
- }
187
- if (route.data.ids) {
188
- routeContent += ` ids: ${route.data.ids},\n`;
189
- }
190
- if (route.data.featureName) {
191
- routeContent += ` featureName: '${route.data.featureName}',\n`;
192
- }
193
- if (route.data.moduleId) {
194
- routeContent += ` moduleId: '${route.data.moduleId}',\n`;
195
- }
196
- if (route.data.elementTag) {
197
- routeContent += ` elementTag: '${route.data.elementTag}',\n`;
198
- }
199
- if (route.data.iframe) {
200
- routeContent += ` iframe: ${route.data.iframe},\n`;
201
- }
202
- routeContent += ' },\n';
203
- }
204
- if (route.canActivate) {
205
- routeContent += ` canActivate: ${route.canActivate},\n`;
206
- }
207
- if (route.loadChildren) {
208
- const lcArray = route.loadChildren.split('#');
209
- const lcImport = lcArray[0];
210
- const lcModule = lcArray[1];
211
- routeContent += ` loadChildren: () => import('${lcImport}').then(m => m.${lcModule}),\n`
212
- }
213
- routeContent += '},\n\n';
214
-
215
- return routeContent;
216
- }
217
-
218
-
219
-
220
- const replaceRouteV2 = (route) => {
221
- let routeContent = '{\n';
222
-
223
118
  routeContent += ` path: '${route.path}',\n`;
224
119
  if (Object.keys(route.data).length > 0) {
225
120
  routeContent += ' data: {\n';
@@ -256,129 +151,7 @@ const replaceRouteV2 = (route) => {
256
151
  }
257
152
 
258
153
 
259
- /* @deprecated - TO REMOVE */
260
- const replaceRoutes = (project, envTarget, build, routesFileContent, euiVersion) => {
261
- return Promise.resolve()
262
- .then(() => {
263
-
264
- tools.logInfo('Replace routes legacy started...');
265
-
266
- // getting base route defs content
267
- // default route
268
- let routeDefsBaseFilename = 'route-defs-base.json';
269
-
270
- // if full route base name is setup
271
- if (project.externalRoutesSources.routesBaseFilename) {
272
- routeDefsBaseFilename = project.externalRoutesSources.routesBaseFilename;
273
-
274
- // if prefix and type, we construct the route base name (dynamic following eUI version of host installed)
275
- // format is : route-defs-base-vVERSION_NUMBER[-TYPE].json
276
- } else if (project.externalRoutesSources.routesBaseFilenamePrefix) {
277
- let routesBaseType = '';
278
- if (project.externalRoutesSources.routesBaseFilenameType) {
279
- routesBaseType = `-${project.externalRoutesSources.routesBaseFilenameType}`;
280
- }
281
- const euiVersionNumber = euiVersion.split('.')[0];
282
- routeDefsBaseFilename = `${project.externalRoutesSources.routesBaseFilenamePrefix}-v${euiVersionNumber}${routesBaseType}.json`;
283
- }
284
-
285
- const projectAssetsPath = path.join(process.cwd(), project.folder, 'src', 'assets');
286
- const baseRouteDefsPath = path.join(projectAssetsPath, routeDefsBaseFilename);
287
-
288
- if (!tools.isFileExists(baseRouteDefsPath)) {
289
- tools.logError(`${baseRouteDefsPath} File NOT FOUND`);
290
- throw 'BASE_ROUTE_DEFS_FILE_NOT_FOUND';
291
- }
292
-
293
- // fetching base route defs file content
294
- const baseRouteDefsJSON = require(baseRouteDefsPath);
295
-
296
- // getting env route defs content if build mode (not serve)
297
- let envRouteDefsPath, envRouteDefsJSON = [];
298
- const envTargetFinal = getEnvTarget(envTarget, build);
299
-
300
- envRouteDefsPath = path.join(projectAssetsPath, 'route-defs.' + envTargetFinal + '.json');
301
-
302
- if (!tools.isFileExists(envRouteDefsPath)) {
303
- tools.logError(`${envRouteDefsPath} File NOT FOUND`);
304
- throw 'ENV_ROUTE_DEFS_FILE_NOT_FOUND';
305
- }
306
-
307
- // fetching file content
308
- envRouteDefsJSON = require(envRouteDefsPath);
309
-
310
- // merging content of base + env
311
- tools.logInfo(`Merging ${baseRouteDefsPath} with ${envRouteDefsPath}`);
312
-
313
- let mergedRouteDefs = _.merge(_.keyBy(baseRouteDefsJSON, 'path'), _.keyBy(envRouteDefsJSON, 'path'));
314
- let finalRouteDefs = _.values(mergedRouteDefs);
315
-
316
- // checking if overrides needs to be applied specific to env + version
317
- let euiVersionNumber;
318
- if (euiVersion === 'DEFAULT') {
319
- euiVersionNumber = '7'
320
- } else {
321
- euiVersionNumber = euiVersion.split('.')[0];
322
- };
323
-
324
- const envRouteVersionOverridesPath = path.join(projectAssetsPath, 'route-defs.' + envTargetFinal + '-overrides-v' + euiVersionNumber + '.json');
325
-
326
- if (!tools.isFileExists(envRouteVersionOverridesPath)) {
327
- tools.logInfo('Routes file overrides not found for ' + envTargetFinal + ' ' + euiVersionNumber + '...skipping');
328
-
329
- } else {
330
- const euiRoutesOVerridesJSON = require(envRouteVersionOverridesPath);
331
- tools.logInfo(`Merging ${envRouteVersionOverridesPath}`);
332
- mergedRouteDefs = _.merge(_.keyBy(mergedRouteDefs, 'path'), _.keyBy(euiRoutesOVerridesJSON, 'path'));
333
- finalRouteDefs = _.values(mergedRouteDefs);
334
- }
335
-
336
- // processing routes
337
- let placeHolderContent = '';
338
-
339
- tools.logInfo('Processing routes replacement');
340
-
341
- finalRouteDefs.forEach((route) => {
342
- if (debug) tools.logInfo(`====> route : ${route.path}`);
343
-
344
- if (!route.loadChildren) {
345
- tools.logInfo('Loadchildren does not exist for route...skipping');
346
- tools.logInfo('Route excluded:');
347
- console.log(route);
348
-
349
- } else {
350
- if (euiVersion === 'DEFAULT' || euiVersion === '10.x') {
351
- tools.logInfo(`Legacy routes replacement for v7 and v10 => replacing ${route.path}`);
352
- placeHolderContent += replaceRouteLegacy(route);
353
-
354
- } else {
355
- tools.logInfo(`New route replacement for v14+ => replacing ${route.path}`);
356
- placeHolderContent += replaceRoute(route);
357
- }
358
-
359
- if (debug) tools.logSuccess('======> OK replaced');
360
- }
361
- })
362
-
363
- const placeHolderToken = '// routes-placeholder';
364
- routesFileContent = tools.replaceAll(routesFileContent, placeHolderToken, placeHolderContent);
365
-
366
- if (debug) {
367
- tools.logInfo('Routes file content replaced : ');
368
- console.log(routesFileContent);
369
- }
370
-
371
- return routesFileContent;
372
- })
373
-
374
- .catch((e) => {
375
- throw e;
376
- })
377
- }
378
-
379
-
380
-
381
- const processRoutesConfigV2 = (project, envTarget, build, routesFileContent, euiVersion) => {
154
+ const processRoutesConfig = (project, envTarget, build, routesFileContent, euiVersion) => {
382
155
  return Promise.resolve()
383
156
  .then(() => {
384
157
  tools.logInfo('Replace routes v2...');
@@ -431,7 +204,9 @@ const processRoutesConfigV2 = (project, envTarget, build, routesFileContent, eui
431
204
 
432
205
  const defRoute = routeDefsBaseJSON.filter(r => r.path === route.path)[0];
433
206
  if (!defRoute) {
434
- tools.logError('==>route not found');
207
+ tools.logError('route not found for: ');
208
+ console.log(route);
209
+ throw 'ROUTE_NOT_FOUND';
435
210
 
436
211
  } else {
437
212
  let loadChildrenGenerated;
@@ -474,9 +249,17 @@ const processRoutesConfigV2 = (project, envTarget, build, routesFileContent, eui
474
249
  }
475
250
 
476
251
  if (route.remote) {
477
- const remoteDef = defRoute.remoteDefs.filter((r) => {
478
- return r.euiVersion === route.euiVersion
479
- })[0];
252
+ let remoteDef;
253
+ try {
254
+ remoteDef = defRoute.remoteDefs.filter((r) => {
255
+ return r.euiVersion === route.euiVersion
256
+ })[0];
257
+ } catch {
258
+ tools.logError('Remote route not found for: ');
259
+ console.log(route);
260
+ throw 'REMOTE_ROUTE_DEF_NOT_FOUND';
261
+ }
262
+
480
263
  if (remoteDef) {
481
264
  newAppRoute.data.moduleId = remoteDef.moduleId;
482
265
  newAppRoute.data.elementTag = remoteDef.elementTag;
@@ -618,7 +401,7 @@ const processRoutesConfigV2 = (project, envTarget, build, routesFileContent, eui
618
401
  let placeHolderContent = '';
619
402
 
620
403
  appRoutes.forEach((route) => {
621
- placeHolderContent += replaceRouteV2(route);
404
+ placeHolderContent += replaceRoute(route);
622
405
  });
623
406
 
624
407
  const placeHolderToken = '// routes-placeholder';
@@ -683,9 +466,7 @@ module.exports.buildRoutes = (project, envTarget, build) => {
683
466
 
684
467
  return Promise.resolve()
685
468
  .then(() => {
686
- if (project.externalRoutesSources.routesConfigVersion === '2') {
687
- return injectRoutesConfig(project, project.externalRoutesSources.routesConfigNpmPkg);
688
- }
469
+ return injectRoutesConfig(project, project.externalRoutesSources.routesConfigNpmPkg);
689
470
  })
690
471
 
691
472
  .then(() => {
@@ -700,11 +481,7 @@ module.exports.buildRoutes = (project, envTarget, build) => {
700
481
  })
701
482
 
702
483
  .then(() => {
703
- if (project.externalRoutesSources.routesConfigVersion === '2') {
704
- return processRoutesConfigV2(project, envTarget, build, routesFileContent, euiVersion);
705
- } else {
706
- return replaceRoutes(project, envTarget, build, routesFileContent, euiVersion);
707
- }
484
+ return processRoutesConfig(project, envTarget, build, routesFileContent, euiVersion);
708
485
  })
709
486
 
710
487
  .then((finalRouteFileContent) => {