@eui/tools 6.3.16 → 6.3.17

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.3.16
1
+ 6.3.17
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 6.3.17 (2023-02-06)
2
+
3
+ ##### Chores
4
+
5
+ * **other:**
6
+ * added custom env script injection for MWP CDN - EUI-7035 [EUI-7035](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-7035) ([b38f15fb](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/b38f15fb3c89f29065280d9b4d165cf27d8a258b))
7
+
8
+ * * *
9
+ * * *
1
10
  ## 6.3.16 (2023-02-02)
2
11
 
3
12
  ##### Bug Fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eui/tools",
3
- "version": "6.3.16",
3
+ "version": "6.3.17",
4
4
  "tag": "latest",
5
5
  "license": "EUPL-1.1",
6
6
  "description": "eUI common tools and scripts",
@@ -329,33 +329,13 @@ module.exports.generateProjectDistributionFile = (project, isSnapshot, envTarget
329
329
  bucketName = project.build.distribution.bucketNameSnapshot;
330
330
  }
331
331
 
332
+ // if bucket has been defined for specific envTarget
332
333
  if (envTarget) {
333
- if (envTarget === 'DEV' && project.build.distribution.bucketNameDev) {
334
- bucketName = project.build.distribution.bucketNameDev;
335
- }
336
-
337
- if (envTarget === 'TST' && project.build.distribution.bucketNameTst) {
338
- bucketName = project.build.distribution.bucketNameTst;
339
- }
340
-
341
- if (envTarget === 'INT' && project.build.distribution.bucketNameInt) {
342
- bucketName = project.build.distribution.bucketNameInt;
343
- }
344
-
345
- if (envTarget === 'ACC' && project.build.distribution.bucketNameAcc) {
346
- bucketName = project.build.distribution.bucketNameAcc;
347
- }
348
-
349
- if (envTarget === 'DLT' && project.build.distribution.bucketNameDlt) {
350
- bucketName = project.build.distribution.bucketNameDlt;
351
- }
352
-
353
- if (envTarget === 'TRN' && project.build.distribution.bucketNameTrn) {
354
- bucketName = project.build.distribution.bucketNameTrn;
355
- }
356
-
357
- if (envTarget === 'PROD' && project.build.distribution.bucketNameProd) {
358
- bucketName = project.build.distribution.bucketNameProd;
334
+ if (project.build.distribution.envs) {
335
+ const envBucketName = project.build.distribution.envs[envTarget.toLowerCase()];
336
+ if (envBucketName) {
337
+ bucketName = envBucketName;
338
+ }
359
339
  }
360
340
  }
361
341
  }
@@ -126,10 +126,22 @@ module.exports.preBuild = (project, envTarget, build, configEnvTarget) => {
126
126
  }
127
127
  tools.logSuccess();
128
128
  }
129
+ })
130
+
129
131
 
132
+ // injection config based on configEnvTarget (for openid files replacement)
133
+ .then(() => {
130
134
  return this.injectAppConfig(project, configEnvTarget);
131
135
  })
132
136
 
137
+
138
+ // processing custom script injection if enabled in project config
139
+ .then(() => {
140
+ return this.processCustomScriptsInjection(project, envTarget);
141
+ })
142
+
143
+
144
+ // checking if project as own pre-build.js script defined, and executing it
133
145
  .then(() => {
134
146
  const prebuildScript = path.join(project.paths.rootPath, 'pre-build.js');
135
147
 
@@ -149,7 +161,6 @@ module.exports.preBuild = (project, envTarget, build, configEnvTarget) => {
149
161
  }
150
162
 
151
163
 
152
-
153
164
  module.exports.injectAppConfig = (project, configEnvTarget) => {
154
165
  return Promise.resolve()
155
166
  .then(() => {
@@ -200,6 +211,43 @@ module.exports.injectAppConfig = (project, configEnvTarget) => {
200
211
  }
201
212
 
202
213
 
214
+ module.exports.processCustomEnvScriptInjection = (project, envTarget) => {
215
+ return Promise.resolve()
216
+ .then(() => {
217
+ if (project.build && project.build.customEnvScriptInjection) {
218
+ tools.logInfo(`Processing custom script injection for ${project.name} - envTarget: ${envTarget}`);
219
+
220
+ const scriptName = project.build.customEnvScriptInjection[(envTarget.toLowerCase())];
221
+ if (!scriptName) {
222
+ tools.logWarning('Unable to find script replacement definition for envTarget...skipping');
223
+ return;
224
+
225
+ } else {
226
+ tools.logInfo(`Script to replace : ${scriptName}`);
227
+ const injectedScript = `<script type="text/javascript" src="${scriptName}" crossorigin="anonymous"></script>`;
228
+ const placeholderToReplace = '<!-- CUSTOM SCRIPT INJECTION PLACEHOLDER -->';
229
+ const fileToReplace = path.join(project.paths.angularPath, 'src', 'index.html');
230
+
231
+ if (tools.isFileExists(fileToReplace)) {
232
+ return tools.replaceInFile(
233
+ fileToReplace,
234
+ placeholderToReplace,
235
+ injectedScript
236
+ );
237
+
238
+ } else {
239
+ tools.logWarning(`Source replacement file does not exist : ${fileToReplace}`);
240
+ }
241
+ }
242
+ }
243
+ })
244
+
245
+ .catch((e) => {
246
+ throw e;
247
+ })
248
+ }
249
+
250
+
203
251
  module.exports.processSvgAssets = (project) => {
204
252
  return Promise.resolve()
205
253
  .then(() => {