@eui/tools 5.3.72 → 5.3.73
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
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
5.3.
|
|
1
|
+
5.3.73
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## 5.3.73 (2022-10-11)
|
|
2
|
+
|
|
3
|
+
##### Chores
|
|
4
|
+
|
|
5
|
+
* **other:**
|
|
6
|
+
* allow array of app sources injection and overrides - MWP-8868 [MWP-8868](https://webgate.ec.europa.eu/CITnet/jira/browse/MWP-8868) ([55ae46fc](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/55ae46fcaea7263983452b9da90c56545561238c))
|
|
7
|
+
|
|
8
|
+
* * *
|
|
9
|
+
* * *
|
|
1
10
|
## 5.3.72 (2022-10-07)
|
|
2
11
|
|
|
3
12
|
##### Chores
|
package/package.json
CHANGED
|
@@ -64,89 +64,119 @@ module.exports.injectExternalFeatures = (project) => {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
|
|
67
|
+
|
|
68
|
+
const injectExternalAppSourcesCore = (project, build = false, injectedNpmPkg, injectedFolder) => {
|
|
69
|
+
|
|
70
|
+
tools.logInfo(`Injecting : ${injectedNpmPkg} / ${injectedFolder}`);
|
|
71
|
+
|
|
72
|
+
return Promise.resolve()
|
|
73
|
+
.then(() => {
|
|
74
|
+
// check if package is locally cloned
|
|
75
|
+
const localPackage = configUtils.packages.getPackages().filter((p) => {
|
|
76
|
+
return p.npmPkg === injectedNpmPkg
|
|
77
|
+
})[0];
|
|
78
|
+
|
|
79
|
+
let appSourcesSrcPath;
|
|
80
|
+
const projectSrcPath = path.join(process.cwd(), project.folder, 'src');
|
|
81
|
+
|
|
82
|
+
// if local package is found
|
|
83
|
+
if (localPackage) {
|
|
84
|
+
tools.logInfo('local project found, copying from local');
|
|
85
|
+
appSourcesSrcPath = path.join(process.cwd(), 'packages', localPackage.name, injectedFolder);
|
|
86
|
+
|
|
87
|
+
// if not sources are taken from the npm package def in node_modules
|
|
88
|
+
} else {
|
|
89
|
+
tools.logInfo('remote project found, copying from remote');
|
|
90
|
+
const npmPkgScope = injectedNpmPkg.substr(0, injectedNpmPkg.indexOf('/'));
|
|
91
|
+
const npmPkgName = injectedNpmPkg.substr(injectedNpmPkg.indexOf('/') + 1);
|
|
92
|
+
|
|
93
|
+
appSourcesSrcPath = path.join(process.cwd(), 'node_modules', npmPkgScope, npmPkgName, injectedFolder);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (!tools.isDirExists(appSourcesSrcPath)) {
|
|
97
|
+
tools.logWarning(`External sources location : ${appSourcesSrcPath} cannot be found in node_modules`);
|
|
98
|
+
throw new Error('External sources not found');
|
|
99
|
+
|
|
100
|
+
} else {
|
|
101
|
+
|
|
102
|
+
return Promise.resolve()
|
|
103
|
+
.then(() => {
|
|
104
|
+
tools.logInfo(`${appSourcesSrcPath} injecting in ${projectSrcPath}`);
|
|
105
|
+
return tools.copydir(appSourcesSrcPath, projectSrcPath, true);
|
|
106
|
+
})
|
|
107
|
+
.catch((e) => {
|
|
108
|
+
throw e;
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
.catch((e) => {
|
|
114
|
+
throw e;
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
67
120
|
module.exports.injectExternalAppSources = (project, build = false) => {
|
|
68
121
|
|
|
69
122
|
tools.logTitle(`Injecting project external application sources for : ${project.name}`);
|
|
70
123
|
|
|
71
124
|
return Promise.resolve()
|
|
72
125
|
.then(() => {
|
|
73
|
-
if (!
|
|
126
|
+
if (!build) {
|
|
127
|
+
// removing previously injected content, except assets
|
|
128
|
+
const projectSrcPath = path.join(process.cwd(), project.folder, 'src');
|
|
129
|
+
const projectSrcAppPath = path.join(projectSrcPath, 'app');
|
|
130
|
+
const projectSrcConfigPath = path.join(projectSrcPath, 'config');
|
|
131
|
+
const projectSrcEnvironmentsPath = path.join(projectSrcPath, 'environments');
|
|
132
|
+
|
|
133
|
+
return Promise.resolve()
|
|
134
|
+
.then(() => {
|
|
135
|
+
tools.logInfo(`Removing ${projectSrcAppPath} content`);
|
|
136
|
+
return tools.rimraf(projectSrcAppPath);
|
|
137
|
+
})
|
|
138
|
+
.then(() => {
|
|
139
|
+
tools.logInfo(`Removing ${projectSrcConfigPath} content`);
|
|
140
|
+
return tools.rimraf(projectSrcConfigPath);
|
|
141
|
+
})
|
|
142
|
+
.then(() => {
|
|
143
|
+
tools.logInfo(`Removing ${projectSrcEnvironmentsPath} content`);
|
|
144
|
+
return tools.rimraf(projectSrcEnvironmentsPath);
|
|
145
|
+
})
|
|
146
|
+
.catch((e) => {
|
|
147
|
+
throw e;
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
})
|
|
151
|
+
.then(() => {
|
|
152
|
+
if (!project.externalSources) {
|
|
74
153
|
tools.logInfo('No external app sources setup...skipping');
|
|
75
154
|
return;
|
|
76
155
|
}
|
|
77
156
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
157
|
+
// in case of multiple injection are defined, we promise loop on each injection
|
|
158
|
+
if (Array.isArray(project.externalSources)) {
|
|
159
|
+
return Promise.resolve().then(() => {
|
|
160
|
+
return project.externalSources.reduce((promise, appSource) => {
|
|
161
|
+
return promise.then(() => (
|
|
162
|
+
injectExternalAppSourcesCore(project, build, appSource.npmPkg, appSource.folder)
|
|
163
|
+
));
|
|
164
|
+
}, Promise.resolve());
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
// if only one injection externalSources is defined
|
|
81
168
|
} else {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return p.npmPkg === project.appSources.npmPkg
|
|
85
|
-
})[0];
|
|
86
|
-
|
|
87
|
-
let appSourcesSrcPath;
|
|
88
|
-
const projectSrcPath = path.join(process.cwd(), project.folder, 'src');
|
|
89
|
-
|
|
90
|
-
// if local package is found
|
|
91
|
-
if (localPackage) {
|
|
92
|
-
tools.logInfo('local project found, copying from local');
|
|
93
|
-
appSourcesSrcPath = path.join(process.cwd(), 'packages', localPackage.name, project.appSources.folder);
|
|
94
|
-
|
|
95
|
-
// if not sources are taken from the npm package def in node_modules
|
|
96
|
-
} else {
|
|
97
|
-
tools.logInfo('remote project found, copying from remote');
|
|
98
|
-
const npmPkgScope = project.appSources.npmPkg.substr(0, project.appSources.npmPkg.indexOf('/'));
|
|
99
|
-
const npmPkgName = project.appSources.npmPkg.substr(project.appSources.npmPkg.indexOf('/') + 1);
|
|
100
|
-
|
|
101
|
-
appSourcesSrcPath = path.join(process.cwd(), 'node_modules', npmPkgScope, npmPkgName, project.appSources.folder);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (!tools.isDirExists(appSourcesSrcPath)) {
|
|
105
|
-
tools.logWarning(`External features location : ${appSourcesSrcPath} cannot be found in node_modules`);
|
|
106
|
-
throw new Error('External features not found');
|
|
169
|
+
if (!project.externalSources.npmPkg || !project.externalSources.folder) {
|
|
170
|
+
return tools.logWarning('External externalSources use requires a source [npmPkg] and a [folder] declared');
|
|
107
171
|
|
|
108
172
|
} else {
|
|
109
|
-
|
|
110
|
-
return Promise.resolve()
|
|
111
|
-
.then(() => {
|
|
112
|
-
if (!build) {
|
|
113
|
-
// removing previously injected content, except assets
|
|
114
|
-
const projectSrcAppPath = path.join(projectSrcPath, 'app');
|
|
115
|
-
const projectSrcConfigPath = path.join(projectSrcPath, 'config');
|
|
116
|
-
const projectSrcEnvironmentsPath = path.join(projectSrcPath, 'environments');
|
|
117
|
-
|
|
118
|
-
return Promise.resolve()
|
|
119
|
-
.then(() => {
|
|
120
|
-
tools.logInfo(`Removing ${projectSrcAppPath} content`);
|
|
121
|
-
return tools.rimraf(projectSrcAppPath);
|
|
122
|
-
})
|
|
123
|
-
.then(() => {
|
|
124
|
-
tools.logInfo(`Removing ${projectSrcConfigPath} content`);
|
|
125
|
-
return tools.rimraf(projectSrcConfigPath);
|
|
126
|
-
})
|
|
127
|
-
.then(() => {
|
|
128
|
-
tools.logInfo(`Removing ${projectSrcEnvironmentsPath} content`);
|
|
129
|
-
return tools.rimraf(projectSrcEnvironmentsPath);
|
|
130
|
-
})
|
|
131
|
-
.catch((e) => {
|
|
132
|
-
throw e;
|
|
133
|
-
})
|
|
134
|
-
}
|
|
135
|
-
})
|
|
136
|
-
.then(() => {
|
|
137
|
-
tools.logInfo(`${appSourcesSrcPath} injecting in ${projectSrcPath}`);
|
|
138
|
-
return tools.copydir(appSourcesSrcPath, projectSrcPath, true);
|
|
139
|
-
})
|
|
140
|
-
.catch((e) => {
|
|
141
|
-
throw e;
|
|
142
|
-
})
|
|
173
|
+
return injectExternalAppSourcesCore(project, build, project.externalSources.npmPkg, project.externalSources.folder);
|
|
143
174
|
}
|
|
144
175
|
}
|
|
145
176
|
})
|
|
146
177
|
.catch((e) => {
|
|
147
178
|
throw e;
|
|
148
179
|
})
|
|
149
|
-
|
|
150
180
|
}
|
|
151
181
|
|
|
152
182
|
|
|
@@ -6,6 +6,10 @@ const _ = require('lodash');
|
|
|
6
6
|
const tools = require('../../tools');
|
|
7
7
|
const configUtils = require('../../../csdr/config/config-utils');
|
|
8
8
|
|
|
9
|
+
// const { subRoutes, debug } = tools.getArgs();
|
|
10
|
+
const { debug } = tools.getArgs();
|
|
11
|
+
|
|
12
|
+
|
|
9
13
|
|
|
10
14
|
const getEnvTarget = (envTargetIn, build) => {
|
|
11
15
|
if (!envTargetIn) {
|
|
@@ -71,39 +75,39 @@ const getRoutesFile = (project) => {
|
|
|
71
75
|
|
|
72
76
|
return Promise.resolve()
|
|
73
77
|
.then(() => {
|
|
74
|
-
if (!project.
|
|
75
|
-
tools.logError('project requires
|
|
78
|
+
if (!project.externalRoutesSources) {
|
|
79
|
+
tools.logError('project requires externalRoutesSources definition');
|
|
76
80
|
return;
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
let routesFilePath;
|
|
80
84
|
let srcRoutesFilePath;
|
|
81
85
|
|
|
82
|
-
if (!project.
|
|
83
|
-
tools.logError('project requires
|
|
86
|
+
if (!project.externalRoutesSources.routesFileNpmPkg || !project.externalRoutesSources.routesFileSource || !project.externalRoutesSources.routesFilePath) {
|
|
87
|
+
tools.logError('project requires externalRoutesSources.routesFileNpmPkg, routesFileSources and routesFilePath definitions');
|
|
84
88
|
return;
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
// check if package is locally cloned
|
|
88
92
|
const localPackage = configUtils.packages.getPackages().filter((p) => {
|
|
89
|
-
return p.npmPkg === project.
|
|
93
|
+
return p.npmPkg === project.externalRoutesSources.routesFileNpmPkg
|
|
90
94
|
})[0];
|
|
91
95
|
|
|
92
96
|
// if local package is found
|
|
93
97
|
if (localPackage) {
|
|
94
98
|
tools.logInfo('local package found, copying from local');
|
|
95
|
-
srcRoutesFilePath = path.join(process.cwd(), 'packages', localPackage.name, project.
|
|
99
|
+
srcRoutesFilePath = path.join(process.cwd(), 'packages', localPackage.name, project.externalRoutesSources.routesFileSource);
|
|
96
100
|
|
|
97
101
|
// if not sources are taken from the npm package def in node_modules
|
|
98
102
|
} else {
|
|
99
103
|
tools.logInfo('remote package found, copying from remote');
|
|
100
|
-
const npmPkgScope = project.
|
|
101
|
-
const npmPkgName = project.
|
|
104
|
+
const npmPkgScope = project.externalRoutesSources.routesFileNpmPkg.substr(0, project.externalRoutesSources.routesFileNpmPkg.indexOf('/'));
|
|
105
|
+
const npmPkgName = project.externalRoutesSources.routesFileNpmPkg.substr(project.externalRoutesSources.routesFileNpmPkg.indexOf('/') + 1);
|
|
102
106
|
|
|
103
|
-
srcRoutesFilePath = path.join(process.cwd(), 'node_modules', npmPkgScope, npmPkgName, project.
|
|
107
|
+
srcRoutesFilePath = path.join(process.cwd(), 'node_modules', npmPkgScope, npmPkgName, project.externalRoutesSources.routesFileSource);
|
|
104
108
|
}
|
|
105
109
|
|
|
106
|
-
routesFilePath = path.join(project.paths.rootPath, project.
|
|
110
|
+
routesFilePath = path.join(project.paths.rootPath, project.externalRoutesSources.routesFilePath);
|
|
107
111
|
|
|
108
112
|
// copy source file to project destination
|
|
109
113
|
tools.copy(srcRoutesFilePath, routesFilePath);
|
|
@@ -130,8 +134,8 @@ const replaceRoutes = (project, envTarget, build, routesFileContent) => {
|
|
|
130
134
|
// getting base route defs content
|
|
131
135
|
const projectAssetsPath = path.join(process.cwd(), project.folder, 'src', 'assets');
|
|
132
136
|
let routeDefsBaseFilename = 'route-defs-base.json';
|
|
133
|
-
if (project.
|
|
134
|
-
routeDefsBaseFilename = project.
|
|
137
|
+
if (project.externalRoutesSources.routesBaseFilename) {
|
|
138
|
+
routeDefsBaseFilename = project.externalRoutesSources.routesBaseFilename;
|
|
135
139
|
}
|
|
136
140
|
const baseRouteDefsPath = path.join(projectAssetsPath, routeDefsBaseFilename);
|
|
137
141
|
|
|
@@ -160,13 +164,22 @@ const replaceRoutes = (project, envTarget, build, routesFileContent) => {
|
|
|
160
164
|
const mergedRouteDefs = _.merge(_.keyBy(baseRouteDefsJSON, 'path'), _.keyBy(envRouteDefsJSON, 'path'));
|
|
161
165
|
const finalRouteDefs = _.values(mergedRouteDefs);
|
|
162
166
|
|
|
167
|
+
// getting subRoutes if passed as arguments
|
|
168
|
+
// let subRoutesArray;
|
|
169
|
+
|
|
170
|
+
// if (subRoutes) {
|
|
171
|
+
// subRoutesArray = subRoutes.split(',');
|
|
172
|
+
|
|
173
|
+
// tools.logInfo('subRoutes arguments foound : ');
|
|
174
|
+
// tools.logInfo(subRoutesArray);
|
|
175
|
+
// }
|
|
163
176
|
|
|
164
177
|
// processing routes
|
|
165
178
|
let placeHolderContent = '';
|
|
166
179
|
|
|
167
180
|
tools.logInfo('Processing routes replacement');
|
|
168
181
|
finalRouteDefs.forEach((route) => {
|
|
169
|
-
tools.logInfo(`====> route : ${route.path}`);
|
|
182
|
+
if (debug) tools.logInfo(`====> route : ${route.path}`);
|
|
170
183
|
|
|
171
184
|
let routeContent = '{\n';
|
|
172
185
|
|
|
@@ -204,14 +217,24 @@ const replaceRoutes = (project, envTarget, build, routesFileContent) => {
|
|
|
204
217
|
|
|
205
218
|
placeHolderContent += routeContent;
|
|
206
219
|
|
|
207
|
-
|
|
220
|
+
// if (subRoutesArray) {
|
|
221
|
+
// if (subRoutesArray.includes(route.path)) {
|
|
222
|
+
// placeHolderContent += routeContent;
|
|
223
|
+
// }
|
|
224
|
+
// } else {
|
|
225
|
+
// placeHolderContent += routeContent;
|
|
226
|
+
// }
|
|
227
|
+
|
|
228
|
+
if (debug) tools.logSuccess('======> OK replaced');
|
|
208
229
|
})
|
|
209
230
|
|
|
210
231
|
const placeHolderToken = '// routes-placeholder';
|
|
211
232
|
routesFileContent = tools.replaceAll(routesFileContent, placeHolderToken, placeHolderContent);
|
|
212
233
|
|
|
213
|
-
|
|
214
|
-
|
|
234
|
+
if (debug) {
|
|
235
|
+
tools.logInfo('Routes file content replaced : ');
|
|
236
|
+
console.log(routesFileContent);
|
|
237
|
+
}
|
|
215
238
|
|
|
216
239
|
return routesFileContent;
|
|
217
240
|
})
|
|
@@ -29,7 +29,7 @@ module.exports.preBuild = (project, envTarget, build, configEnvTarget) => {
|
|
|
29
29
|
|
|
30
30
|
// inject external app sources declaration
|
|
31
31
|
.then(() => {
|
|
32
|
-
if (project.
|
|
32
|
+
if (project.externalSources) {
|
|
33
33
|
return injectionUtils.externals.injectExternalAppSources(project, build);
|
|
34
34
|
}
|
|
35
35
|
})
|
|
@@ -62,7 +62,7 @@ module.exports.preBuild = (project, envTarget, build, configEnvTarget) => {
|
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
.then(() => {
|
|
65
|
-
if (project.config && project.
|
|
65
|
+
if (project.config && project.externalRoutesSources) {
|
|
66
66
|
return injectionUtils.routesReplacement.buildRoutes(project, envTarget, build);
|
|
67
67
|
}
|
|
68
68
|
})
|