Socket
Socket
Sign inDemoInstall

svg-symbol-sprite

Package Overview
Dependencies
22
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.1 to 1.5.0

12

CHANGELOG.md

@@ -7,2 +7,14 @@ ### Changelog

#### [1.5.0](https://github.com/scriptex/svg-symbol-sprite/compare/1.4.1...1.5.0)
> 22 April 2024
- Bump ip from 1.1.8 to 1.1.9 [`#52`](https://github.com/scriptex/svg-symbol-sprite/pull/52)
- Update dependency commander to v12 [`#51`](https://github.com/scriptex/svg-symbol-sprite/pull/51)
- Update dependency release-it to v17 [`#46`](https://github.com/scriptex/svg-symbol-sprite/pull/46)
- Update actions/setup-node action to v4 [`#44`](https://github.com/scriptex/svg-symbol-sprite/pull/44)
- Correctly use SVGO config (#54) [`71ff412`](https://github.com/scriptex/svg-symbol-sprite/commit/71ff412c067c48c0174386396c448c7ab0645b47)
- Update dependency release-it to v17.0.3 [`46be66a`](https://github.com/scriptex/svg-symbol-sprite/commit/46be66a938caf67fb86fc3bc942e052c13f8ebe3)
- Update dependency release-it to v17.2.0 [`577b428`](https://github.com/scriptex/svg-symbol-sprite/commit/577b428e2b33579f3f74cc94f6572561e79161af)
#### [1.4.1](https://github.com/scriptex/svg-symbol-sprite/compare/1.4.0...1.4.1)

@@ -9,0 +21,0 @@

33

config/svgo.config.js

@@ -0,21 +1,12 @@

const { randomBytes } = require('node:crypto');
module.exports = {
plugins: [
'cleanupAttrs',
'removeDoctype',
'removeXMLProcInst',
'removeComments',
'removeMetadata',
'removeUselessDefs',
'removeEditorsNSData',
'removeEmptyAttrs',
'removeEmptyText',
'removeEmptyContainers',
'cleanupEnableBackground',
'convertStyleToAttrs',
'removeUselessStrokeAndFill',
'removeDimensions',
'cleanupIds',
{
name: 'removeViewBox',
enabled: false
name: 'preset-default',
params: {
overrides: {
removeViewBox: false
}
}
},

@@ -25,9 +16,3 @@ {

params: {
prefix: {
toString() {
this.counter = this.counter || 0;
return `svgo-viewbox-id-${this.counter++}`;
}
}
prefix: () => randomBytes(20).toString('hex').slice(0, 4)
}

@@ -34,0 +19,0 @@ }

@@ -31,3 +31,3 @@ #!/usr/bin/env node

const filterFile = (file) => (0, path_1.extname)(file) === '.svg';
const processFiles = (files) => Promise.all(files.filter(filterFile).map(processFile));
const processFiles = (files) => Promise.all(files.map(processFile));
const removeOutput = async () => ((0, fs_1.existsSync)(OUTPUT) ? await rm(OUTPUT) : undefined);

@@ -55,5 +55,6 @@ const getSvgContent = (content) => getSvg(content).html();

};
const getName = (file) => (0, path_1.basename)(file, (0, path_1.extname)(file));
const processFile = (file) => {
const path = (0, path_1.resolve)(INPUT, file);
const name = (0, path_1.basename)(file, (0, path_1.extname)(file));
const name = getName(file);
const wrapContent = wrapFile.bind(null, name);

@@ -68,8 +69,9 @@ return readFile(path, 'utf8').then(wrapContent);

.then(async (files) => {
const matchingFiles = files.filter(filterFile);
if (CONFIG === 'false') {
return processFiles(files);
return processFiles(matchingFiles);
}
let svgoConfig = await (0, svgo_1.loadConfig)(DEFAULT_CONFIG);
try {
svgoConfig = await (0, svgo_1.loadConfig)(CONFIG);
svgoConfig = (await (0, svgo_1.loadConfig)(CONFIG));
}

@@ -79,9 +81,12 @@ catch (e) {

}
for (const file of files) {
const processedFiles = [];
for (const file of matchingFiles) {
const content = await fs_1.promises.readFile((0, path_1.join)(INPUT, file), {
encoding: 'utf-8'
});
(0, svgo_1.optimize)(content, svgoConfig);
const name = getName(file);
const optimizedSVG = (0, svgo_1.optimize)(content, svgoConfig).data;
processedFiles.push(wrapFile(name, optimizedSVG));
}
return processFiles(files);
return processedFiles;
})

@@ -88,0 +93,0 @@ .then(getSpriteContent)

{
"name": "svg-symbol-sprite",
"version": "1.4.1",
"version": "1.5.0",
"description": "A script to generate a symbol sprite from SVG files",

@@ -43,18 +43,23 @@ "keywords": [

"cheerio": "1.0.0-rc.12",
"commander": "11.0.0",
"svgo": "3.0.2"
"commander": "12.0.0",
"svgo": "3.2.0"
},
"devDependencies": {
"@types/cheerio": "0.22.32",
"@types/csso": "5.0.1",
"@types/node": "20.6.2",
"@types/svg-parser": "2.0.3",
"@types/tape": "5.6.1",
"release-it": "16.1.5",
"@types/cheerio": "0.22.35",
"@types/csso": "5.0.4",
"@types/node": "20.12.7",
"@types/svg-parser": "2.0.6",
"@types/tape": "5.6.4",
"release-it": "17.2.0",
"svg-parser": "2.0.4",
"tape": "5.6.6",
"ts-node": "10.9.1",
"tape": "5.7.5",
"ts-node": "10.9.2",
"tslib": "2.6.2",
"typescript": "5.2.2"
"typescript": "5.4.5"
},
"peerDependencies": {
"cheerio": "^1.0.0",
"commander": "^12.0.0",
"svgo": "^3.0.0"
},
"release-it": {

@@ -61,0 +66,0 @@ "hooks": {

@@ -8,3 +8,3 @@ #!/usr/bin/env node

import { Command } from 'commander';
import { optimize, loadConfig } from 'svgo';
import { optimize, loadConfig, Config } from 'svgo';

@@ -34,2 +34,12 @@ const { rm, readdir, readFile, writeFile } = fs;

type OptionValues = {
input: string;
output: string;
viewbox: string;
prefix: string;
config: string | 'false';
attrs: string;
style: string;
};
const {

@@ -43,3 +53,3 @@ input: INPUT,

style: STYLE
} = cli.opts();
} = cli.opts<OptionValues>();

@@ -49,3 +59,3 @@ const onEnd = (): void => console.log(`File ‘${OUTPUT}’ successfully generated.`);

const filterFile = (file: string) => extname(file) === '.svg';
const processFiles = (files: string[]) => Promise.all(files.filter(filterFile).map(processFile));
const processFiles = (files: string[]) => Promise.all(files.map(processFile));
const removeOutput = async () => (existsSync(OUTPUT) ? await rm(OUTPUT) : undefined);

@@ -79,5 +89,7 @@ const getSvgContent = (content: string) => getSvg(content).html();

const getName = (file: string) => basename(file, extname(file));
const processFile = (file: string) => {
const path = resolve(INPUT, file);
const name = basename(file, extname(file));
const name = getName(file);
const wrapContent = wrapFile.bind(null, name);

@@ -95,7 +107,9 @@

.then(async (files: string[]) => {
const matchingFiles = files.filter(filterFile);
if (CONFIG === 'false') {
return processFiles(files);
return processFiles(matchingFiles);
}
let svgoConfig = await loadConfig(DEFAULT_CONFIG);
let svgoConfig: Config = await loadConfig(DEFAULT_CONFIG);

@@ -108,11 +122,15 @@ try {

for (const file of files) {
const processedFiles = [];
for (const file of matchingFiles) {
const content = await fs.readFile(join(INPUT, file), {
encoding: 'utf-8'
});
const name = getName(file);
const optimizedSVG = optimize(content, svgoConfig).data;
optimize(content, svgoConfig);
processedFiles.push(wrapFile(name, optimizedSVG));
}
return processFiles(files);
return processedFiles;
})

@@ -119,0 +137,0 @@ .then(getSpriteContent)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc