@eui/tools 5.3.70 → 5.3.71

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.70
1
+ 5.3.71
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 5.3.71 (2022-10-06)
2
+
3
+ ##### Chores
4
+
5
+ * **other:**
6
+ * refactored sprite generator based on ECL builder using svg-sprite adapted config - EUI-6557 [EUI-6557](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-6557) ([aec93722](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/aec9372277ff41b2004b9c4a4d796c3201dc9d94))
7
+
8
+ * * *
9
+ * * *
1
10
  ## 5.3.70 (2022-10-05)
2
11
 
3
12
  ##### Chores
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eui/tools",
3
- "version": "5.3.70",
3
+ "version": "5.3.71",
4
4
  "tag": "latest",
5
5
  "license": "EUPL-1.1",
6
6
  "description": "eUI common tools and scripts",
@@ -45,6 +45,6 @@
45
45
  "sendmail": "1.6.1",
46
46
  "imagemin": "7.0.1",
47
47
  "imagemin-svgo": "9.0.0",
48
- "svgstore": "3.0.1"
48
+ "svg-sprite": "1.5.3"
49
49
  }
50
50
  }
@@ -2,13 +2,48 @@
2
2
 
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
-
6
5
  const tools = require('./tools');
7
6
 
7
+ const writeSprite = (srcPath, files, destPath, outputFile) => {
8
+ const SVGSpriter = require('svg-sprite');
9
+
10
+ const spriter = new SVGSpriter({
11
+ destPath,
12
+ svg: { dimensionAttributes: true },
13
+ mode: {
14
+ symbol: {
15
+ dest: '',
16
+ sprite: outputFile,
17
+ },
18
+ },
19
+ });
20
+
21
+ files.forEach((file) => {
22
+ const filePath = path.resolve(srcPath, file);
23
+ spriter.add(
24
+ filePath,
25
+ file,
26
+ fs.readFileSync(filePath, { encoding: 'utf-8' })
27
+ );
28
+ });
29
+
30
+ spriter.compile((error, result) => {
31
+ Object.keys(result).forEach((mode) => {
32
+ Object.keys(result[mode]).forEach((resource) => {
33
+ fs.writeFileSync(
34
+ path.join(destPath, outputFile),
35
+ result[mode][resource].contents
36
+ );
37
+ });
38
+ });
39
+ });
40
+ };
41
+
42
+
43
+
8
44
  module.exports.generateSvgsSprite = (svgsInPath, svgsSpritePath, svgsSpriteFile) => {
9
45
  const imagemin = require('imagemin');
10
46
  const imageminSvgo = require('imagemin-svgo');
11
- const svgstore = require('svgstore');
12
47
 
13
48
  const svgsOutPath = path.join(svgsInPath, 'temp');
14
49
 
@@ -55,15 +90,8 @@ module.exports.generateSvgsSprite = (svgsInPath, svgsSpritePath, svgsSpriteFile)
55
90
 
56
91
  tools.logInfo('Creating svg sprite');
57
92
 
58
- const sprites = svgstore();
59
93
 
60
- // compiling sprite file
61
- svgFiles.forEach((f) => {
62
- sprites.add(
63
- f.substr(0, f.indexOf('.svg')),
64
- fs.readFileSync(path.join(svgsOutPath, f), 'utf8')
65
- );
66
- });
94
+ writeSprite(svgsOutPath, svgFiles, svgsSpritePath, svgsSpriteFile);
67
95
 
68
96
  // generating json output list
69
97
  const outList = svgFiles.map((f) => {
@@ -75,8 +103,6 @@ module.exports.generateSvgsSprite = (svgsInPath, svgsSpritePath, svgsSpriteFile)
75
103
 
76
104
  tools.writeJsonFileSync(path.join(svgsSpritePath, svgsSpriteFileJson), outList);
77
105
 
78
- tools.writeFileContent(path.join(svgsSpritePath, svgsSpriteFile), sprites);
79
-
80
106
  tools.logSuccess(`OK => ${svgsSpritePath} generated`);
81
107
  })
82
108