@eui/tools 6.8.0 → 6.9.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 +18 -0
- package/package.json +1 -1
- package/sandbox.js +5 -4
- package/scripts/csdr/config/angular.js +7 -0
- package/scripts/utils/pre-build/injection/migrate-routes.js +281 -0
- package/scripts/utils/pre-build/injection/routes-replacement.js +340 -34
- package/scripts/utils/pre-build/projects.js +2 -2
- package/scripts/utils/pre-build/translations/projects.js +9 -2
package/.version.properties
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
6.
|
|
1
|
+
6.9.0
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
## 6.9.0 (2023-03-11)
|
|
2
|
+
|
|
3
|
+
##### New Features
|
|
4
|
+
|
|
5
|
+
* **other:**
|
|
6
|
+
* route config and replacement v2 - setup default files pre-integration - EUI-7121 [EUI-7121](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-7121) ([ba99c941](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/ba99c941145d7c48b21b654a2ead2889462a525d))
|
|
7
|
+
|
|
8
|
+
* * *
|
|
9
|
+
* * *
|
|
10
|
+
## 6.8.1 (2023-03-10)
|
|
11
|
+
|
|
12
|
+
##### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **other:**
|
|
15
|
+
* project eUI version fetch when no dependencies-composite - EUI-7240 [EUI-7240](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-7240) ([f78ecdc8](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/f78ecdc823d2d7ebd49b21dea47ac70c59cfc6db))
|
|
16
|
+
|
|
17
|
+
* * *
|
|
18
|
+
* * *
|
|
1
19
|
## 6.8.0 (2023-03-09)
|
|
2
20
|
|
|
3
21
|
##### New Features
|
package/package.json
CHANGED
package/sandbox.js
CHANGED
|
@@ -1214,9 +1214,10 @@ const versionUtils = require('./scripts/csdr/version/version-utils');
|
|
|
1214
1214
|
|
|
1215
1215
|
Promise.resolve()
|
|
1216
1216
|
.then(() => {
|
|
1217
|
-
|
|
1217
|
+
const prjName = 'my-workplace-host-playground';
|
|
1218
|
+
const project = configUtils.projects.getCsdrProject(prjName);
|
|
1219
|
+
return preBuildUtils.projects.preBuild(project, 'TST', true, 'TST');
|
|
1218
1220
|
})
|
|
1219
|
-
.
|
|
1220
|
-
|
|
1221
|
-
console.log(JSON.stringify(stats, null, 2));
|
|
1221
|
+
.catch((e) => {
|
|
1222
|
+
console.log(e);
|
|
1222
1223
|
})
|
|
@@ -189,6 +189,13 @@ module.exports.registerAngularProjectDef = (project, build = false, element = fa
|
|
|
189
189
|
angularRootPath = project.paths.root;
|
|
190
190
|
} else {
|
|
191
191
|
euiVersion = innerProjects.getProjectEuiVersion(project);
|
|
192
|
+
|
|
193
|
+
if (!euiVersion) {
|
|
194
|
+
if (project.build && project.build.euiVersion) {
|
|
195
|
+
euiVersion = project.build.euiVersion;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
192
199
|
angularRootPath = project.paths.angularPath;
|
|
193
200
|
}
|
|
194
201
|
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const tools = require('../../tools');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
// ONE-TIME ONLY !!!! as manual updates has been made...
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
const defaultSample = {
|
|
10
|
+
"path": "sample -- full options",
|
|
11
|
+
"authMetadata": {
|
|
12
|
+
"id": "SECUNDA_TASK_ID",
|
|
13
|
+
"ids": "['SECUNDA_TASK_ID', 'SECUNDA_TASK_ID', ...]",
|
|
14
|
+
"canActivate": "[AuthGuardService] -- if data.id or data.ids present"
|
|
15
|
+
},
|
|
16
|
+
"lazyLoadDef": {
|
|
17
|
+
"npmPkg": "@scope/packageName",
|
|
18
|
+
"moduleName": "RootPackageModuleName"
|
|
19
|
+
},
|
|
20
|
+
"remoteDef": {
|
|
21
|
+
"featureName": "FEATURE_FLAG_NAME in openid config files - to activate/deactivate links in environment (runtime config)",
|
|
22
|
+
"moduleId": "used by the elementLoader - name of the remote name in the config : scope-package-euiXX-remote-el-ui",
|
|
23
|
+
"elementTag": "used by the elementLoader - unique name identifying the remote - scope-package-vXX",
|
|
24
|
+
"iframe": true
|
|
25
|
+
},
|
|
26
|
+
"menuLinkDef": {
|
|
27
|
+
"label": "sidebar-link.KEY - as defined in the assets/i18n/lng files",
|
|
28
|
+
"iconClass": "eui-icon eui-icon-ICON_NAME for the menu link entry in the sidebar",
|
|
29
|
+
"deniedRightId": "SECUNDA_TASK_ID - denied right to not show this link for category of user having this taskId set",
|
|
30
|
+
"allowedRightId": "SECUNDA_TASK_ID - allowed right to show this link for category of user having this taskId set",
|
|
31
|
+
"allowedRightIds": "['SECUNDA_TASK_ID', 'SECUNDA_TASK_ID', ...] - multiple taskId are allowed to view this link",
|
|
32
|
+
"parenLinkId": "PARENT_ID -- children of existing parent in defs-links.json menu links structure"
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
Promise.resolve()
|
|
38
|
+
.then(() => {
|
|
39
|
+
const rPath = path.join(process.cwd(), 'packages', 'mywp-routes-config', 'assets', 'route-defs.dev.json');
|
|
40
|
+
const rDev = tools.getJsonFileContent(rPath);
|
|
41
|
+
const lPath = path.join(process.cwd(), 'packages', 'mywp-routes-config', 'assets', 'route-defs-links.json');
|
|
42
|
+
const rLink = tools.getJsonFileContent(lPath);
|
|
43
|
+
const plPath = path.join(process.cwd(), 'packages', 'mywp-routes-config', 'assets', 'route-defs-base-v10-playground.json');
|
|
44
|
+
const rPg = tools.getJsonFileContent(plPath);
|
|
45
|
+
const plPath15 = path.join(process.cwd(), 'packages', 'mywp-routes-config', 'assets', 'route-defs-base-v15-playground.json');
|
|
46
|
+
const rPg15 = tools.getJsonFileContent(plPath15);
|
|
47
|
+
|
|
48
|
+
const parentLinks = rLink.filter(r => r.parentId !== undefined);
|
|
49
|
+
|
|
50
|
+
// base routes
|
|
51
|
+
|
|
52
|
+
const resultRoutes = [];
|
|
53
|
+
|
|
54
|
+
resultRoutes.push(defaultSample);
|
|
55
|
+
|
|
56
|
+
rDev.forEach((route) => {
|
|
57
|
+
const n = {};
|
|
58
|
+
n.path = route.path;
|
|
59
|
+
|
|
60
|
+
const auth = {};
|
|
61
|
+
let lazy = {};
|
|
62
|
+
let remote = {};
|
|
63
|
+
|
|
64
|
+
lazy.npmPkg = 'TO_BE_FILLED';
|
|
65
|
+
lazy.moduleName = 'TO_BE_FILLED';
|
|
66
|
+
|
|
67
|
+
if (route.data) {
|
|
68
|
+
if (route.data.id) {
|
|
69
|
+
auth.id = route.data.id;
|
|
70
|
+
auth.canActivate = "[AuthGuardService]";
|
|
71
|
+
n.authMetadata = auth;
|
|
72
|
+
}
|
|
73
|
+
if (route.data.ids) {
|
|
74
|
+
auth.ids = route.data.ids;
|
|
75
|
+
auth.canActivate = "[AuthGuardService]";
|
|
76
|
+
n.authMetadata = auth;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (route.data.elementTag) {
|
|
80
|
+
remote = {
|
|
81
|
+
featureName: route.data.featureName,
|
|
82
|
+
moduleId: route.data.moduleId,
|
|
83
|
+
elementTag: route.data.elementTag,
|
|
84
|
+
iframe: route.data.iframe,
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const linkRoute = rLink.filter((r) => {
|
|
90
|
+
if (r.url) {
|
|
91
|
+
return r.url.indexOf(route.path) > 0;
|
|
92
|
+
}
|
|
93
|
+
})[0];
|
|
94
|
+
|
|
95
|
+
if (linkRoute) {
|
|
96
|
+
n.menuLinkDef = linkRoute;
|
|
97
|
+
|
|
98
|
+
} else {
|
|
99
|
+
let childRoute;
|
|
100
|
+
|
|
101
|
+
parentLinks.forEach((pl) => {
|
|
102
|
+
pl.children.forEach((r) => {
|
|
103
|
+
if (r.url) {
|
|
104
|
+
if (r.url.indexOf(route.path) > 0) {
|
|
105
|
+
childRoute = r;
|
|
106
|
+
childRoute.parentLinkId = pl.parentId;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
if (childRoute) {
|
|
112
|
+
n.menuLinkDef = childRoute;
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
let mod, imp;
|
|
118
|
+
let mdRoute;
|
|
119
|
+
|
|
120
|
+
mdRoute = rPg.filter(r => r.path === route.path || r.path === route.path.substr(0, route.path.length - 4))[0];
|
|
121
|
+
|
|
122
|
+
if (mdRoute) {
|
|
123
|
+
const libModFilename = mdRoute.loadChildren.substr(0, mdRoute.loadChildren.length - 7);
|
|
124
|
+
const libModFilePath = path.join(process.cwd(), 'packages', 'mywp-host-ui', 'assets', '10.x', 'app-sources-playground', 'app', libModFilename + '.ts');
|
|
125
|
+
|
|
126
|
+
if (tools.isFileExists(libModFilePath)) {
|
|
127
|
+
const libModFileContent = tools.getFileContent(libModFilePath);
|
|
128
|
+
const lines = libModFileContent.split('\n');
|
|
129
|
+
let libModLine;
|
|
130
|
+
libModLine = lines.filter(l => l.indexOf('LibModule') > 0)[0];
|
|
131
|
+
if (!libModLine) {
|
|
132
|
+
libModLine = lines[1];
|
|
133
|
+
}
|
|
134
|
+
// console.log(libModFilename, libModLine);
|
|
135
|
+
const words = libModLine.split(' ');
|
|
136
|
+
// console.log(words);
|
|
137
|
+
mod = words.filter(w => w.indexOf('Module') > -1)[0];
|
|
138
|
+
// console.log(route.path, mod);
|
|
139
|
+
const impLast = words[words.length-1];
|
|
140
|
+
imp = impLast.substr(1, impLast.length - 4);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
mdRoute = rPg15.filter(r => r.path === route.path || r.path === route.path.substr(0, route.path.length - 4))[0];
|
|
145
|
+
|
|
146
|
+
if (mdRoute) {
|
|
147
|
+
const libModFilename = mdRoute.loadChildren.substr(0, mdRoute.loadChildren.length - 7);
|
|
148
|
+
const libModFilePath = path.join(process.cwd(), 'packages', 'mywp-host-ui', 'assets', '15.x', 'app-sources-playground', 'app', libModFilename + '.ts');
|
|
149
|
+
|
|
150
|
+
if (tools.isFileExists(libModFilePath)) {
|
|
151
|
+
const libModFileContent = tools.getFileContent(libModFilePath);
|
|
152
|
+
const lines = libModFileContent.split('\n');
|
|
153
|
+
let libModLine;
|
|
154
|
+
libModLine = lines.filter(l => l.indexOf('LibModule') > 0)[0];
|
|
155
|
+
if (!libModLine) {
|
|
156
|
+
libModLine = lines[1];
|
|
157
|
+
}
|
|
158
|
+
// console.log(libModFilename, libModLine);
|
|
159
|
+
const words = libModLine.split(' ');
|
|
160
|
+
// console.log(words);
|
|
161
|
+
mod = words.filter(w => w.indexOf('Module') > -1)[0];
|
|
162
|
+
// console.log(route.path, mod);
|
|
163
|
+
const impLast = words[words.length-1];
|
|
164
|
+
imp = impLast.substr(1, impLast.length - 4);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (route.path.indexOf('delegations-manager-v15') > -1) {
|
|
169
|
+
mod = 'DelegationManagerModule';
|
|
170
|
+
imp = '@mywp/delegations-manager';
|
|
171
|
+
}
|
|
172
|
+
if (route.path.indexOf('task-details-v15') > -1) {
|
|
173
|
+
mod = 'CcTaskDetailsModule';
|
|
174
|
+
imp = '@cc/task-details';
|
|
175
|
+
}
|
|
176
|
+
if (route.path.indexOf('item-v15') > -1) {
|
|
177
|
+
mod = 'CcPortfolioItemModule';
|
|
178
|
+
imp = '@cc/portfolio-item';
|
|
179
|
+
}
|
|
180
|
+
if (route.path.indexOf('process-v15') > -1) {
|
|
181
|
+
mod = 'ProcessCentreListModule';
|
|
182
|
+
imp = '@cc/process-centre';
|
|
183
|
+
}
|
|
184
|
+
if (route.path.indexOf('flex-v15') > -1) {
|
|
185
|
+
mod = 'FlexModule';
|
|
186
|
+
imp = '@cc/flex';
|
|
187
|
+
}
|
|
188
|
+
if (route.path.indexOf('rsp-management') > -1) {
|
|
189
|
+
mod = 'Module';
|
|
190
|
+
imp = '@rsp/management';
|
|
191
|
+
}
|
|
192
|
+
if (route.path.indexOf('cps-tools') > -1) {
|
|
193
|
+
mod = 'CpsCigipModule';
|
|
194
|
+
imp = '@cps/cigip-orchestrator';
|
|
195
|
+
}
|
|
196
|
+
if (route.path.indexOf('decide-poc') > -1) {
|
|
197
|
+
mod = 'DecideSectionModule';
|
|
198
|
+
imp = '@cc/decidepoc/section';
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
if (mod) {
|
|
203
|
+
lazy.moduleName = mod;
|
|
204
|
+
} else {
|
|
205
|
+
console.log('mod not found : ', route.path);
|
|
206
|
+
}
|
|
207
|
+
if (imp) {
|
|
208
|
+
lazy.npmPkg = imp;
|
|
209
|
+
} else {
|
|
210
|
+
console.log('import not found : ', route.path);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
n.lazyLoadDef = lazy;
|
|
214
|
+
n.remoteDef = remote;
|
|
215
|
+
|
|
216
|
+
resultRoutes.push(n);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
resultRoutes.push({
|
|
220
|
+
"path": "notifications",
|
|
221
|
+
"menuLinkDef": {
|
|
222
|
+
"url": "/notifications/view-all",
|
|
223
|
+
"label": "sidebar-link.NOTIFICATIONS",
|
|
224
|
+
"iconClass": "ux-icon ux-icon-envelope-o",
|
|
225
|
+
"deniedRightId": "IGNORE_NOTIFICATION"
|
|
226
|
+
},
|
|
227
|
+
"lazyLoadDef": {
|
|
228
|
+
"npmPkg": "@mywp/notifications",
|
|
229
|
+
"moduleName": "NotificationsModule"
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
tools.writeJsonFileSync(path.join(process.cwd(), 'packages', 'mywp-host-ui', 'assets', 'routes', 'route-defs-base.json'), resultRoutes);
|
|
234
|
+
// console.log(JSON.stringify(resultRoutes, null, 2));
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
// env routes
|
|
238
|
+
const envs = ['dev', 'test', 'int', 'acc', 'dlt', 'trn', 'prod'];
|
|
239
|
+
|
|
240
|
+
envs.forEach((env) => {
|
|
241
|
+
const envPath = path.join(process.cwd(), 'packages', 'mywp-routes-config', 'assets', `route-defs.${env}.json`);
|
|
242
|
+
const rEnv = tools.getJsonFileContent(envPath);
|
|
243
|
+
|
|
244
|
+
const routes = rEnv.map((r) => {
|
|
245
|
+
return {
|
|
246
|
+
"path": r.path,
|
|
247
|
+
"remote": true
|
|
248
|
+
};
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
routes.push({
|
|
252
|
+
path: "notifications",
|
|
253
|
+
lazy: true
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
tools.writeJsonFileSync(path.join(process.cwd(), 'packages', 'mywp-host-ui', 'assets', 'routes', `route-defs.${env}.json`), routes);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
// playground routes
|
|
261
|
+
const pgs = ['v10', 'v15'];
|
|
262
|
+
|
|
263
|
+
pgs.forEach((pg) => {
|
|
264
|
+
const pgPath = path.join(process.cwd(), 'packages', 'mywp-routes-config', 'assets', `route-defs-base-${pg}-playground.json`);
|
|
265
|
+
const rPg = tools.getJsonFileContent(pgPath);
|
|
266
|
+
|
|
267
|
+
const routes = rPg.map((r) => {
|
|
268
|
+
return {
|
|
269
|
+
"path": r.path,
|
|
270
|
+
"lazy": true
|
|
271
|
+
};
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
routes.push({
|
|
275
|
+
path: "notifications",
|
|
276
|
+
lazy: true
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
tools.writeJsonFileSync(path.join(process.cwd(), 'packages', 'mywp-host-ui', 'assets', 'routes', `route-defs-base-${pg}-playground.json`), routes);
|
|
280
|
+
});
|
|
281
|
+
})
|
|
@@ -43,31 +43,6 @@ const getEnvTarget = (envTargetIn, build) => {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
const getEnvConfig = (project, envTarget, build) => {
|
|
48
|
-
tools.logInfo(`Getting config file for env : ${envTarget}`);
|
|
49
|
-
|
|
50
|
-
return Promise.resolve()
|
|
51
|
-
.then(() => {
|
|
52
|
-
// getting config file
|
|
53
|
-
const projectAssetsPath = path.join(process.cwd(), project.folder, 'src', 'assets');
|
|
54
|
-
const envTargetFinal = getEnvTarget(envTarget, build);
|
|
55
|
-
const configFile = path.join(projectAssetsPath, 'openid-login-config.' + envTargetFinal + '.json');
|
|
56
|
-
|
|
57
|
-
tools.logInfo(`checking ${configFile}`);
|
|
58
|
-
if (!tools.isFileExists(configFile)) {
|
|
59
|
-
tools.logError(`config file for ${envTarget} does not exists`);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return require(configFile);
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
.catch((e) => {
|
|
67
|
-
throw e;
|
|
68
|
-
})
|
|
69
|
-
}
|
|
70
|
-
|
|
71
46
|
const getRoutesFile = (project, euiVersion) => {
|
|
72
47
|
tools.logInfo('Getting routes file for replacement');
|
|
73
48
|
|
|
@@ -158,7 +133,7 @@ const getRoutesFile = (project, euiVersion) => {
|
|
|
158
133
|
})
|
|
159
134
|
}
|
|
160
135
|
|
|
161
|
-
|
|
136
|
+
/* @deprecated - TO REMOVE */
|
|
162
137
|
const replaceRouteLegacy = (route) => {
|
|
163
138
|
let routeContent = '{\n';
|
|
164
139
|
|
|
@@ -198,7 +173,7 @@ const replaceRouteLegacy = (route) => {
|
|
|
198
173
|
}
|
|
199
174
|
|
|
200
175
|
|
|
201
|
-
|
|
176
|
+
/* @deprecated - TO REMOVE */
|
|
202
177
|
const replaceRoute = (route) => {
|
|
203
178
|
let routeContent = '{\n';
|
|
204
179
|
|
|
@@ -242,10 +217,52 @@ const replaceRoute = (route) => {
|
|
|
242
217
|
|
|
243
218
|
|
|
244
219
|
|
|
220
|
+
const replaceRouteV2 = (route) => {
|
|
221
|
+
let routeContent = '{\n';
|
|
222
|
+
|
|
223
|
+
routeContent += ` path: '${route.path}',\n`;
|
|
224
|
+
if (Object.keys(route.data).length > 0) {
|
|
225
|
+
routeContent += ' data: {\n';
|
|
226
|
+
|
|
227
|
+
if (route.data.id) {
|
|
228
|
+
routeContent += ` id: '${route.data.id}',\n`;
|
|
229
|
+
}
|
|
230
|
+
if (route.data.ids) {
|
|
231
|
+
routeContent += ` ids: ${route.data.ids},\n`;
|
|
232
|
+
}
|
|
233
|
+
if (route.data.featureName) {
|
|
234
|
+
routeContent += ` featureName: '${route.data.featureName}',\n`;
|
|
235
|
+
}
|
|
236
|
+
if (route.data.moduleId) {
|
|
237
|
+
routeContent += ` moduleId: '${route.data.moduleId}',\n`;
|
|
238
|
+
}
|
|
239
|
+
if (route.data.elementTag) {
|
|
240
|
+
routeContent += ` elementTag: '${route.data.elementTag}',\n`;
|
|
241
|
+
}
|
|
242
|
+
if (route.data.iframe) {
|
|
243
|
+
routeContent += ` iframe: ${route.data.iframe},\n`;
|
|
244
|
+
}
|
|
245
|
+
routeContent += ' },\n';
|
|
246
|
+
}
|
|
247
|
+
if (route.canActivate) {
|
|
248
|
+
routeContent += ` canActivate: ${route.canActivate},\n`;
|
|
249
|
+
}
|
|
250
|
+
if (route.loadChildren) {
|
|
251
|
+
routeContent += ` ${route.loadChildren},\n`
|
|
252
|
+
}
|
|
253
|
+
routeContent += '},\n\n';
|
|
254
|
+
|
|
255
|
+
return routeContent;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
/* @deprecated - TO REMOVE */
|
|
245
260
|
const replaceRoutes = (project, envTarget, build, routesFileContent, euiVersion) => {
|
|
246
261
|
return Promise.resolve()
|
|
247
262
|
.then(() => {
|
|
248
263
|
|
|
264
|
+
tools.logInfo('Replace routes legacy started...');
|
|
265
|
+
|
|
249
266
|
// getting base route defs content
|
|
250
267
|
// default route
|
|
251
268
|
let routeDefsBaseFilename = 'route-defs-base.json';
|
|
@@ -360,6 +377,294 @@ const replaceRoutes = (project, envTarget, build, routesFileContent, euiVersion)
|
|
|
360
377
|
}
|
|
361
378
|
|
|
362
379
|
|
|
380
|
+
|
|
381
|
+
const processRoutesConfigV2 = (project, envTarget, build, routesFileContent, euiVersion) => {
|
|
382
|
+
return Promise.resolve()
|
|
383
|
+
.then(() => {
|
|
384
|
+
tools.logInfo('Replace routes v2...');
|
|
385
|
+
|
|
386
|
+
// source of all routes - routes defs base
|
|
387
|
+
const projectAssetsPath = path.join(process.cwd(), project.folder, 'src', 'assets');
|
|
388
|
+
|
|
389
|
+
const routeDefsBaseFilename = 'route-defs-base.json';
|
|
390
|
+
const routeDefsBaseJSON = require(path.join(projectAssetsPath, routeDefsBaseFilename));
|
|
391
|
+
|
|
392
|
+
// getting generated from input params
|
|
393
|
+
const euiVersionNumber = euiVersion.split('.')[0];
|
|
394
|
+
const envTargetFinal = getEnvTarget(envTarget, build);
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
// getting the input file definitions of routes for replacements
|
|
398
|
+
// from tokenized template in config -- allowing to control playground vs normal env (when using the MWP HOST for release)
|
|
399
|
+
// format :
|
|
400
|
+
// playground : "routesFilenameTemplate": "route-defs-base-v@eui.version@-playground.json"
|
|
401
|
+
// host : "routesFilenameTemplate": "route-defs.@env.target@.json"
|
|
402
|
+
|
|
403
|
+
let routeDefsInputFilename;
|
|
404
|
+
|
|
405
|
+
if (!project.externalRoutesSources.routesFilenameTemplate) {
|
|
406
|
+
throw 'ROUTES_CONFIG_V2_TEMPLATE_NOT_FOUND';
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
routeDefsInputFilename = project.externalRoutesSources.routesFilenameTemplate.replace('@eui.version@', euiVersionNumber);
|
|
410
|
+
routeDefsInputFilename = routeDefsInputFilename.replace('@env.target@', envTargetFinal);
|
|
411
|
+
|
|
412
|
+
tools.logInfo(`Starting replacement of routes based on generated template : ${routeDefsInputFilename}`);
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
// Getting input routeDefs entry
|
|
417
|
+
|
|
418
|
+
const routeDefsInputPath = path.join(projectAssetsPath, routeDefsInputFilename);
|
|
419
|
+
|
|
420
|
+
if (!tools.isFileExists(routeDefsInputPath)) {
|
|
421
|
+
tools.logError(`${routeDefsInputPath} File NOT FOUND`);
|
|
422
|
+
throw 'ROUTE_DEFS_INPUT_FILE_NOT_FOUND';
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
const routeDefsInputJSON = require(path.join(routeDefsInputPath));
|
|
426
|
+
|
|
427
|
+
const appRoutes = [], appFeatureLibs = [];
|
|
428
|
+
|
|
429
|
+
routeDefsInputJSON.forEach((route) => {
|
|
430
|
+
tools.logInfo(`Processing route : ${route.path}`);
|
|
431
|
+
|
|
432
|
+
const defRoute = routeDefsBaseJSON.filter(r => r.path === route.path)[0];
|
|
433
|
+
if (!defRoute) {
|
|
434
|
+
tools.logError('==>route not found');
|
|
435
|
+
|
|
436
|
+
} else {
|
|
437
|
+
let loadChildrenGenerated;
|
|
438
|
+
|
|
439
|
+
if (route.lazy) {
|
|
440
|
+
const scopeName = defRoute.lazyLoadDef.npmPkg.split('/')[0].substr(1);
|
|
441
|
+
const pkgName = defRoute.lazyLoadDef.npmPkg.split('/')[1];
|
|
442
|
+
const lazyFeatureLibName = `${scopeName}-${pkgName}-${defRoute.lazyLoadDef.moduleName}.lib.module`;
|
|
443
|
+
|
|
444
|
+
if (euiVersion === '10.x') {
|
|
445
|
+
loadChildrenGenerated = `loadChildren: "./features/${lazyFeatureLibName}#Module"`;
|
|
446
|
+
} else {
|
|
447
|
+
loadChildrenGenerated = `loadChildren: () => import("./features/${lazyFeatureLibName}").then(m => m.Module)`;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
appFeatureLibs.push({
|
|
451
|
+
filename: `${lazyFeatureLibName}.ts`,
|
|
452
|
+
npmPkg: defRoute.lazyLoadDef.npmPkg,
|
|
453
|
+
moduleName: defRoute.lazyLoadDef.moduleName
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
} else {
|
|
457
|
+
if (euiVersion === '10.x') {
|
|
458
|
+
loadChildrenGenerated = 'loadChildren: "./features/element-loader.module#ElementLoaderModule"';
|
|
459
|
+
} else {
|
|
460
|
+
loadChildrenGenerated = 'loadChildren: () => import("./features/element-loader.module").then(m => m.ElementLoaderModule)';
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
const newAppRoute = {
|
|
465
|
+
path: defRoute.path,
|
|
466
|
+
loadChildren: loadChildrenGenerated,
|
|
467
|
+
data: {}
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
if (defRoute.authMetadata) {
|
|
471
|
+
newAppRoute.data.id = defRoute.authMetadata.id;
|
|
472
|
+
newAppRoute.data.ids = defRoute.authMetadata.ids;
|
|
473
|
+
newAppRoute.canActivate = defRoute.authMetadata.canActivate;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
if (route.remote) {
|
|
477
|
+
newAppRoute.data.featureName = defRoute.remoteDef.featureName;
|
|
478
|
+
newAppRoute.data.moduleId = defRoute.remoteDef.moduleId;
|
|
479
|
+
newAppRoute.data.elementTag = defRoute.remoteDef.elementTag;
|
|
480
|
+
newAppRoute.data.iframe = defRoute.remoteDef.iframe;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
appRoutes.push(newAppRoute);
|
|
484
|
+
}
|
|
485
|
+
})
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
// processing creation of features lib modules entries
|
|
489
|
+
|
|
490
|
+
tools.logInfo('Processing creation of features lib modules entries');
|
|
491
|
+
|
|
492
|
+
appFeatureLibs.forEach((f) => {
|
|
493
|
+
const featureLibPath = path.join(process.cwd(), project.folder, 'src', 'app', 'features', f.filename);
|
|
494
|
+
|
|
495
|
+
const featureLibDef = `
|
|
496
|
+
import { NgModule } from '@angular/core';
|
|
497
|
+
import { ${f.moduleName} as LibModule } from '${f.npmPkg}';
|
|
498
|
+
|
|
499
|
+
@NgModule({
|
|
500
|
+
imports: [LibModule],
|
|
501
|
+
exports: [LibModule],
|
|
502
|
+
})
|
|
503
|
+
export class Module {
|
|
504
|
+
}
|
|
505
|
+
`;
|
|
506
|
+
|
|
507
|
+
tools.logInfo(`Creating lazy feature lib module : ${f.filename}`);
|
|
508
|
+
|
|
509
|
+
tools.writeFileContent(featureLibPath, featureLibDef);
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
// processing links generation
|
|
514
|
+
|
|
515
|
+
const routeDefsBaseLinksFileName = 'route-defs-base-links.json';
|
|
516
|
+
const routeDefsBaseLinksJSON = require(path.join(projectAssetsPath, routeDefsBaseLinksFileName));
|
|
517
|
+
|
|
518
|
+
tools.logInfo('Processing links generation');
|
|
519
|
+
|
|
520
|
+
const getRouteMenuDef = (link) => {
|
|
521
|
+
let routeDef = null;
|
|
522
|
+
|
|
523
|
+
if (link.url) {
|
|
524
|
+
routeDefsBaseJSON.forEach((r) => {
|
|
525
|
+
if (r.menuLinkDefs && r.menuLinkDefs.length > 0) {
|
|
526
|
+
r.menuLinkDefs.forEach((md) => {
|
|
527
|
+
if (md.url === link.url) {
|
|
528
|
+
routeDef = md;
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
return routeDef;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
const isLinkAllowed = (link) => {
|
|
540
|
+
// allow all link for playground - local env
|
|
541
|
+
if (envTargetFinal.indexOf('local') > -1) {
|
|
542
|
+
return true;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// checking if current envTarget generated is allowed
|
|
546
|
+
if (link.allowedEnvs) {
|
|
547
|
+
if (link.allowedEnvs.includes(envTargetFinal)) {
|
|
548
|
+
return true;
|
|
549
|
+
} else {
|
|
550
|
+
return false;
|
|
551
|
+
}
|
|
552
|
+
} else {
|
|
553
|
+
return true;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
const linksGenerated = [];
|
|
558
|
+
|
|
559
|
+
routeDefsBaseLinksJSON.forEach((link) => {
|
|
560
|
+
let newLink;
|
|
561
|
+
|
|
562
|
+
if (link.parentId) {
|
|
563
|
+
if (isLinkAllowed(link)) {
|
|
564
|
+
newLink = { ...link};
|
|
565
|
+
newLink.children = [];
|
|
566
|
+
|
|
567
|
+
link.children.forEach((subLink) => {
|
|
568
|
+
if (isLinkAllowed(subLink)) {
|
|
569
|
+
const defRoute = getRouteMenuDef(subLink);
|
|
570
|
+
|
|
571
|
+
if (defRoute) {
|
|
572
|
+
newLink.children.push(defRoute);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
})
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
} else {
|
|
579
|
+
if (isLinkAllowed(link)) {
|
|
580
|
+
const defRoute = getRouteMenuDef(link);
|
|
581
|
+
|
|
582
|
+
if (defRoute) {
|
|
583
|
+
newLink = defRoute;
|
|
584
|
+
} else {
|
|
585
|
+
newLink = link;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
if (newLink) {
|
|
591
|
+
linksGenerated.push(newLink);
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
if (debug) {
|
|
595
|
+
console.log('Links generated');
|
|
596
|
+
console.log(JSON.stringify(linksGenerated));
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
tools.logInfo(`Links generated : ${linksGenerated.length} found`);
|
|
601
|
+
|
|
602
|
+
tools.writeJsonFileSync(path.join(projectAssetsPath, 'route-defs-links.json'), linksGenerated);
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
// getting routes content for replacement
|
|
606
|
+
|
|
607
|
+
tools.logInfo('Processing routes replacement');
|
|
608
|
+
|
|
609
|
+
let placeHolderContent = '';
|
|
610
|
+
|
|
611
|
+
appRoutes.forEach((route) => {
|
|
612
|
+
placeHolderContent += replaceRouteV2(route);
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
const placeHolderToken = '// routes-placeholder';
|
|
616
|
+
routesFileContent = tools.replaceAll(routesFileContent, placeHolderToken, placeHolderContent);
|
|
617
|
+
|
|
618
|
+
if (debug) {
|
|
619
|
+
tools.logInfo('Routes file content replaced : ');
|
|
620
|
+
console.log(routesFileContent);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
return routesFileContent;
|
|
624
|
+
})
|
|
625
|
+
|
|
626
|
+
.catch((e) => {
|
|
627
|
+
throw e;
|
|
628
|
+
})
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
const injectRoutesConfig = (project, npmPkg) => {
|
|
635
|
+
// check if package is locally cloned
|
|
636
|
+
const localPackage = configUtils.packages.getPackages().filter((p) => {
|
|
637
|
+
return p.npmPkg === npmPkg
|
|
638
|
+
})[0];
|
|
639
|
+
|
|
640
|
+
var pkgAssetsPath;
|
|
641
|
+
const projectAssetsPath = path.join(process.cwd(), project.folder, 'src', 'assets');
|
|
642
|
+
|
|
643
|
+
// if local package is found
|
|
644
|
+
if (localPackage) {
|
|
645
|
+
pkgAssetsPath = path.join(process.cwd(), 'packages', localPackage.name, 'assets');
|
|
646
|
+
|
|
647
|
+
// if not sources are taken from the npm package def in node_modules
|
|
648
|
+
} else {
|
|
649
|
+
const npmPkgScope = npmPkg.substr(0, npmPkg.indexOf('/'));
|
|
650
|
+
const npmPkgName = npmPkg.substr(npmPkg.indexOf('/') + 1);
|
|
651
|
+
pkgAssetsPath = path.join(process.cwd(), 'node_modules', npmPkgScope, npmPkgName, 'assets');
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
if (!tools.isDirExists(pkgAssetsPath)) {
|
|
655
|
+
tools.logWarning(`Linked config pkg : ${npmPkg} cannot be found in node_modules`);
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
const routesConfigPath = path.join(pkgAssetsPath, project.externalRoutesSources.routesConfigAssetsPath);
|
|
660
|
+
|
|
661
|
+
tools.logInfo(`${routesConfigPath} - injecting in ${projectAssetsPath}`);
|
|
662
|
+
tools.copydir(routesConfigPath, projectAssetsPath);
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
|
|
363
668
|
module.exports.buildRoutes = (project, envTarget, build) => {
|
|
364
669
|
tools.logTitle('Starting routes replacement');
|
|
365
670
|
|
|
@@ -369,13 +674,9 @@ module.exports.buildRoutes = (project, envTarget, build) => {
|
|
|
369
674
|
|
|
370
675
|
return Promise.resolve()
|
|
371
676
|
.then(() => {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
.then((envConfig) => {
|
|
375
|
-
if (!envConfig) {
|
|
376
|
-
throw 'ENV_CONFIG_NOT_FOUND';
|
|
677
|
+
if (project.externalRoutesSources.routesConfigVersion === '2') {
|
|
678
|
+
return injectRoutesConfig(project, project.externalRoutesSources.routesConfigNpmPkg);
|
|
377
679
|
}
|
|
378
|
-
config = envConfig;
|
|
379
680
|
})
|
|
380
681
|
|
|
381
682
|
.then(() => {
|
|
@@ -390,12 +691,17 @@ module.exports.buildRoutes = (project, envTarget, build) => {
|
|
|
390
691
|
})
|
|
391
692
|
|
|
392
693
|
.then(() => {
|
|
393
|
-
|
|
694
|
+
if (project.externalRoutesSources.routesConfigVersion === '2') {
|
|
695
|
+
return processRoutesConfigV2(project, envTarget, build, routesFileContent, euiVersion);
|
|
696
|
+
} else {
|
|
697
|
+
return replaceRoutes(project, envTarget, build, routesFileContent, euiVersion);
|
|
698
|
+
}
|
|
394
699
|
})
|
|
395
700
|
|
|
396
701
|
.then((finalRouteFileContent) => {
|
|
397
702
|
return tools.writeFileContent(routesFile, finalRouteFileContent);
|
|
398
703
|
})
|
|
704
|
+
|
|
399
705
|
.then(() => {
|
|
400
706
|
tools.logSuccess();
|
|
401
707
|
})
|
|
@@ -45,9 +45,9 @@ module.exports.preBuild = (project, envTarget, build, configEnvTarget) => {
|
|
|
45
45
|
if (project.build && project.build.compiledTranslations) {
|
|
46
46
|
const scopes = project.build.translationScopes;
|
|
47
47
|
if (scopes) {
|
|
48
|
-
return translationUtils.projects.generate(scopes);
|
|
48
|
+
return translationUtils.projects.generate(scopes, project);
|
|
49
49
|
} else {
|
|
50
|
-
return translationUtils.projects.generate();
|
|
50
|
+
return translationUtils.projects.generate(null, project);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
})
|
|
@@ -13,11 +13,18 @@ const configUtils = require('../../../csdr/config/config-utils');
|
|
|
13
13
|
const { dryRun, scopes } = tools.getArgs();
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
module.exports.generate = (inputScopes = 'opsys,cc,mywp,sygma,gem,cotg,eac') => {
|
|
16
|
+
module.exports.generate = (inputScopes = 'opsys,cc,mywp,sygma,gem,cotg,eac', project) => {
|
|
17
17
|
|
|
18
18
|
tools.logTitle('Generating translations...');
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
let prj;
|
|
21
|
+
if (project) {
|
|
22
|
+
prj = project;
|
|
23
|
+
} else {
|
|
24
|
+
prj = configUtils.projects.getProject();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const rootFolder = path.join(process.cwd(), prj.folder);
|
|
21
28
|
const rootSrcFolder = path.join(rootFolder,'src');
|
|
22
29
|
const destFolder = path.join(rootSrcFolder, 'assets/i18n-compiled');
|
|
23
30
|
const globalTranslationsFolder = path.join(rootSrcFolder, 'assets/i18n-global');
|