@eui/tools 5.3.67 → 5.3.68

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
- 5.3.67
1
+ 5.3.68
package/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 5.3.68 (2022-10-02)
2
+
3
+ ##### Chores
4
+
5
+ * **other:**
6
+ * generated eui icon set - sprite generator script - cleanup ECL import script - cleanup - EUI-6562 [EUI-6562](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-6562) ([c610a9e9](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/c610a9e9b5c6d216bd6adc8b9951f92bcf1383fe))
7
+ * added svg sprite generator utils - EUI-6427 [EUI-6427](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-6427) ([89127a7d](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/89127a7dbcd72fa20a1a04478c79ee733ccac5e6))
8
+
9
+ * * *
10
+ * * *
1
11
  ## 5.3.67 (2022-09-30)
2
12
 
3
13
  ##### Chores
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eui/tools",
3
- "version": "5.3.67",
3
+ "version": "5.3.68",
4
4
  "tag": "latest",
5
5
  "license": "EUPL-1.1",
6
6
  "description": "eUI common tools and scripts",
@@ -42,6 +42,9 @@
42
42
  "chai": "4.3.6",
43
43
  "nyc": "15.1.0",
44
44
  "node-fetch": "2.6.7",
45
- "sendmail": "1.6.1"
45
+ "sendmail": "1.6.1",
46
+ "imagemin": "7.0.1",
47
+ "imagemin-svgo": "9.0.0",
48
+ "svgstore": "3.0.1"
46
49
  }
47
50
  }
package/sandbox.js CHANGED
@@ -15,6 +15,7 @@ const injectionUtils = require('./scripts/utils/pre-build/injection/injection-ut
15
15
  const installUtils = require('./scripts/csdr/install/install-utils');
16
16
  const notificationUtils = require('./scripts/utils/notification/notification-utils');
17
17
  const translationUtils = require('./scripts/utils/pre-build/translations/translation-utils');
18
+ const preBuildUtils = require('./scripts/utils/pre-build/pre-build-utils');
18
19
  const apiUtils = require('./scripts/utils/api-utils');
19
20
  const versionUtils = require('./scripts/csdr/version/version-utils');
20
21
 
@@ -881,7 +882,7 @@ const project = configUtils.projects.getProject('pmo-mobile');
881
882
  // let versionsMetadata;
882
883
  // let envsMetadata;
883
884
 
884
- return Promise.resolve()
885
+ // return Promise.resolve()
885
886
  // .then(() => {
886
887
  // return metadataUtils.appVersions.getMetadata(project);
887
888
  // })
@@ -897,11 +898,17 @@ return Promise.resolve()
897
898
  // .then(() => {
898
899
  // return versionUtils.common.getNewVersionDTAP('DEV', versionsMetadata, envsMetadata);
899
900
  // })
901
+ // .then(() => {
902
+ // return versionUtils.appEnvTarget.getNewVersion(project, 'DEV');
903
+ // })
904
+ // .then((version) => {
905
+ // console.log(version);
906
+ // })
907
+
908
+ return Promise.resolve()
900
909
  .then(() => {
901
- return versionUtils.appEnvTarget.getNewVersion(project, 'DEV');
902
- })
903
- .then((version) => {
904
- console.log(version);
910
+ const project = configUtils.projects.getProject('eui-sample');
911
+ return preBuildUtils.projects.processSvgAssets(project);
905
912
  })
906
913
 
907
914
 
@@ -9,6 +9,7 @@ const injectionUtils = require('./injection/injection-utils');
9
9
  const translationUtils = require('./translations/translation-utils');
10
10
 
11
11
  const configUtils = require('../../csdr/config/config-utils');
12
+ const svgUtils = require('../svg-utils');
12
13
 
13
14
  let { openid, dryRun } = tools.getArgs();
14
15
 
@@ -153,12 +154,11 @@ module.exports.preBuild = (project, envTarget, build, configEnvTarget) => {
153
154
  module.exports.injectAppConfig = (project, configEnvTarget) => {
154
155
  return Promise.resolve()
155
156
  .then(() => {
156
- tools.logInfo(`Executing configuration replacement for : ${configEnvTarget} environment`);
157
-
158
157
  // set default if not envTarget provided
159
158
  let envFilePath = path.join(project.paths.angularPath, 'src/assets/config', `env-json-config.json`);;
160
159
 
161
160
  if (configEnvTarget) {
161
+ tools.logInfo(`Executing configuration replacement for : ${configEnvTarget} environment`);
162
162
  envFilePath = path.join(project.paths.angularPath, 'src/assets/config', `env-json-config-${configEnvTarget}.json`);
163
163
  }
164
164
 
@@ -190,3 +190,18 @@ module.exports.injectAppConfig = (project, configEnvTarget) => {
190
190
  })
191
191
  }
192
192
 
193
+
194
+ module.exports.processSvgAssets = (project) => {
195
+ return Promise.resolve()
196
+ .then(() => {
197
+ const svgsInPath = path.join(project.paths.rootPath, 'src', 'assets', 'svg');
198
+ const svgsOutPath = path.join(project.paths.rootPath, 'src', 'assets', 'svg', 'optimized');
199
+ const svgsSpritePath = path.join(svgsInPath, 'sprite.svg');
200
+
201
+ return svgUtils.generateSvgsSprite(svgsInPath, svgsOutPath, svgsSpritePath);
202
+ })
203
+
204
+ .catch((e) => {
205
+ throw e;
206
+ })
207
+ }
@@ -0,0 +1,81 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const tools = require('./tools');
7
+
8
+ module.exports.generateSvgsSprite = (svgsInPath, svgsOutPath, svgsSpritePath) => {
9
+ const imagemin = require('imagemin');
10
+ const imageminSvgo = require('imagemin-svgo');
11
+ const svgstore = require('svgstore');
12
+
13
+ let svgFiles;
14
+
15
+ return Promise.resolve()
16
+ .then(() => {
17
+ return tools.rimraf(svgsOutPath);
18
+ })
19
+ .then(() => {
20
+ return tools.remove(svgsSpritePath);
21
+ })
22
+ .then(() => {
23
+ return tools.getFilesGlob(svgsInPath, '**/*.svg');
24
+ })
25
+ .then((files) => {
26
+ svgFiles = files;
27
+
28
+ tools.logInfo('Optimizing svg files');
29
+ tools.logInfo('Found :');
30
+ console.log(svgFiles);
31
+
32
+ const filesPaths = svgFiles.map(f => path.join(svgsInPath, f));
33
+
34
+ return imagemin(filesPaths, {
35
+ glob: false,
36
+ destination: svgsOutPath,
37
+ plugins: [
38
+ imageminSvgo({
39
+ plugins: [
40
+ { name: 'cleanupIDs', remove: false },
41
+ { name: 'cleanupNumericValues', floatPrecision: 2 },
42
+ { name: 'removeStyleElement', remove: true },
43
+ { name: 'removeTitle', remove: true },
44
+ ],
45
+ multipass: true
46
+ })
47
+ ]
48
+ })
49
+ })
50
+
51
+ .then((files) => {
52
+ tools.logSuccess(`${files.length} processed`);
53
+
54
+ tools.logInfo('Creating svg sprite');
55
+
56
+ const sprites = svgstore();
57
+
58
+ svgFiles.forEach((f) => {
59
+ sprites.add(
60
+ f.substr(0, f.indexOf('.svg')),
61
+ fs.readFileSync(path.join(svgsOutPath, f), 'utf8')
62
+ );
63
+ });
64
+
65
+ tools.writeFileContent(svgsSpritePath, sprites);
66
+
67
+ tools.logSuccess(`OK => ${svgsSpritePath} generated`);
68
+ })
69
+
70
+ .then(() => {
71
+ return tools.rimraf(svgsOutPath);
72
+ })
73
+
74
+ .then(() => {
75
+ tools.logSuccess(`${svgsOutPath} cleaned up`);
76
+ })
77
+
78
+ .catch((e) => {
79
+ throw e;
80
+ })
81
+ }