@eui/tools 6.16.34 → 6.16.35
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 +9 -0
- package/bin/eui-scripts.js +2 -0
- package/bin/scripts/generate-sprite.js +14 -0
- package/package.json +1 -1
- package/scripts/utils/svg-utils.js +47 -1
package/.version.properties
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
6.16.
|
|
1
|
+
6.16.35
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## 6.16.35 (2024-07-17)
|
|
2
|
+
|
|
3
|
+
##### Chores
|
|
4
|
+
|
|
5
|
+
* **other:**
|
|
6
|
+
* add generic svg sprite generation through generate-sprite script - EUI-9014 [EUI-9014](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-9014) ([b748514a](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/b748514a86f6f6c650e4d8c6f71d7e3cd968e6f6))
|
|
7
|
+
|
|
8
|
+
* * *
|
|
9
|
+
* * *
|
|
1
10
|
## 6.16.34 (2024-07-03)
|
|
2
11
|
|
|
3
12
|
##### Chores
|
package/bin/eui-scripts.js
CHANGED
|
@@ -29,6 +29,7 @@ const scriptIndex = args.findIndex(
|
|
|
29
29
|
x === 'publish' ||
|
|
30
30
|
x === 'publish-all' ||
|
|
31
31
|
x === 'generate-translations' ||
|
|
32
|
+
x === 'generate-sprite' ||
|
|
32
33
|
x === 'test-package' ||
|
|
33
34
|
x === 'csdr-app' ||
|
|
34
35
|
x === 'csdr-app-stats' ||
|
|
@@ -78,6 +79,7 @@ switch (script) {
|
|
|
78
79
|
case 'publish-all':
|
|
79
80
|
case 'test-package':
|
|
80
81
|
case 'generate-translations':
|
|
82
|
+
case 'generate-sprite':
|
|
81
83
|
case 'csdr-app':
|
|
82
84
|
case 'csdr-app-stats':
|
|
83
85
|
case 'csdr-app-package-init':
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const tools = require('../../scripts/utils/tools');
|
|
4
|
+
const svgUtils = require('../../scripts/utils/svg-utils');
|
|
5
|
+
|
|
6
|
+
Promise.resolve()
|
|
7
|
+
.then(() => {
|
|
8
|
+
return svgUtils.generateSprite();
|
|
9
|
+
})
|
|
10
|
+
.catch((e) => {
|
|
11
|
+
tools.logError('ERROR');
|
|
12
|
+
console.error(e);
|
|
13
|
+
process.exit(1);
|
|
14
|
+
});
|
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const tools = require('./tools');
|
|
5
5
|
|
|
6
|
+
|
|
6
7
|
const writeSprite = (srcPath, files, destPath, outputFile) => {
|
|
7
8
|
const SVGSpriter = require('svg-sprite');
|
|
8
9
|
|
|
@@ -39,8 +40,53 @@ const writeSprite = (srcPath, files, destPath, outputFile) => {
|
|
|
39
40
|
};
|
|
40
41
|
|
|
41
42
|
|
|
43
|
+
module.exports.generateSprite = () => {
|
|
44
|
+
let srcPath, spriteFile;
|
|
45
|
+
|
|
46
|
+
Promise.resolve()
|
|
47
|
+
.then(() => {
|
|
48
|
+
const args = tools.getArgs();
|
|
49
|
+
|
|
50
|
+
if (!args.inFolder) {
|
|
51
|
+
throw new Error('inFolder argument not provided');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
srcPath = path.join(process.cwd(), args.inFolder);
|
|
55
|
+
spriteFile = args.outFile;
|
|
56
|
+
|
|
57
|
+
if (!args.outFile) {
|
|
58
|
+
throw new Error('outFile not provided as argument');
|
|
59
|
+
} else {
|
|
60
|
+
if (args.outFile.indexOf('.svg') < 0) {
|
|
61
|
+
throw new Error('outFile filename should be in svg file format');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
spriteFile = args.outFile;
|
|
66
|
+
|
|
67
|
+
tools.logInfo(`Building svg sprite from : ${srcPath}`);
|
|
68
|
+
tools.logInfo(`Generating sprite file output : ${spriteFile}`);
|
|
69
|
+
|
|
70
|
+
return tools.getFilesGlob(srcPath, '**/*.svg');
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
.then((svgFiles) => {
|
|
74
|
+
if (svgFiles.length === 0) {
|
|
75
|
+
throw new Error('NO_FILES_FOUND');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
tools.logInfo(`...found ${svgFiles.length} svg files`);
|
|
79
|
+
|
|
80
|
+
return generateSvgsSprite(srcPath, path.join(srcPath, 'sprites'), spriteFile);
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
.catch((e) => {
|
|
84
|
+
throw e;
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
|
|
42
88
|
|
|
43
|
-
module.exports.generateSvgsSprite = (svgsInPath, svgsSpritePath, svgsSpriteFile) => {
|
|
89
|
+
const generateSvgsSprite = module.exports.generateSvgsSprite = (svgsInPath, svgsSpritePath, svgsSpriteFile) => {
|
|
44
90
|
const imagemin = require('imagemin');
|
|
45
91
|
const imageminSvgo = require('imagemin-svgo');
|
|
46
92
|
|