From 2701fe1e9da679bcea6bdb031c9d4c3e112f705e Mon Sep 17 00:00:00 2001 From: SpotlightOn <265342703+SpotlightOn@users.noreply.github.com> Date: Sun, 1 Nov 2026 20:26:54 +0100 Subject: [PATCH 1/5] fix: drop the css-mode leftovers from the options The sprite defaults pointed at sprite.css.svg, and the align/precision options had no consumer since the css mode was removed. --- bin/config.yaml | 16 +++----------- test/cli.test.js | 48 ++++++++++++++++++++-------------------- test/fixtures/align.yaml | 2 -- 3 files changed, 27 insertions(+), 39 deletions(-) delete mode 100644 test/fixtures/align.yaml diff --git a/bin/config.yaml b/bin/config.yaml index 5674849..86a827a 100644 --- a/bin/config.yaml +++ b/bin/config.yaml @@ -81,11 +81,6 @@ shape: alias: m map: shape.meta - align: - description: Path to YAML file with alignment information - alias: a - map: shape.align - dest: description: Path to output directory for intermediate SVG files alias: ims @@ -135,11 +130,6 @@ svg: description: Custom root attributes for the outermost element (external JSON file) map: svg.rootAttributes - precision: - description: Floating point precision for CSS positioning values - default: -1 - map: svg.precision - view: description: Activates the «view» mode default: false @@ -222,7 +212,7 @@ defs: sprite: description: Sprite path and filename (relative to --defs-dest) - default: svg/sprite.css.svg + default: svg/sprite.defs.svg alias: ds map: mode.defs.sprite @@ -298,7 +288,7 @@ symbol: sprite: description: Sprite path and filename (relative to --symbol-dest) - default: svg/sprite.css.svg + default: svg/sprite.symbol.svg alias: ss map: mode.symbol.sprite @@ -374,7 +364,7 @@ stack: sprite: description: Sprite path and filename (relative to --stack-dest) - default: svg/sprite.css.svg + default: svg/sprite.stack.svg alias: Ss map: mode.stack.sprite diff --git a/test/cli.test.js b/test/cli.test.js index 79e965e..8358db7 100644 --- a/test/cli.test.js +++ b/test/cli.test.js @@ -81,7 +81,7 @@ describe('svgforge-cli', () => { assert.match(css, /\.svg-one-dims\s*\{/u); assert.match(css, /\.svg-two-dims\s*\{/u); - const sprite = readFile(path.join(dest, 'defs', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'defs', 'svg', 'sprite.defs.svg')); assert.match(sprite, /^<\?xml/u); assert.match(sprite, / { const example = readFile(path.join(dest, 'defs', 'sprite.defs.html')); assert.match(example, / { const dest = path.join(dir, 'out'); await execCli(['--symbol', `--dest=${dest}`, ...svgFiles]); - const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.symbol.svg')); assert.match(sprite, / { const dest = path.join(dir, 'out'); await execCli(['--defs', `--dest=${dest}`, ...svgFiles]); - const sprite = readFile(path.join(dest, 'defs', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'defs', 'svg', 'sprite.defs.svg')); assert.match(sprite, //u); assert.match(sprite, /id="one"/u); assert.match(sprite, /id="two"/u); @@ -135,7 +135,7 @@ describe('svgforge-cli', () => { const dest = path.join(dir, 'out'); await execCli(['--stack', `--dest=${dest}`, ...svgFiles]); - const sprite = readFile(path.join(dest, 'stack', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'stack', 'svg', 'sprite.stack.svg')); assert.match(sprite, /:root>svg:target/u); assert.match(sprite, /id="one"/u); assert.match(sprite, /id="two"/u); @@ -192,7 +192,7 @@ describe('svgforge-cli', () => { await execCli(['--view', '--symbol', '--view-bust=false', `--dest=${dest}`, ...svgFiles]); assert.equal(fs.existsSync(path.join(dest, 'view', 'svg', 'sprite.view.svg')), true); - assert.equal(fs.existsSync(path.join(dest, 'symbol', 'svg', 'sprite.css.svg')), true); + assert.equal(fs.existsSync(path.join(dest, 'symbol', 'svg', 'sprite.symbol.svg')), true); }); }); }); @@ -211,7 +211,7 @@ describe('svgforge-cli', () => { const css = readFile(path.join(dest, 'symbol', 'sprite.css')); assert.match(css, /\.svg-one/u); - const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.symbol.svg')); assert.match(sprite, / { ...svgFiles, ]); - const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.symbol.svg')); assert.match(sprite, /]*data-testid="sprite-root"/u); }); }); @@ -244,7 +244,7 @@ describe('svgforge-cli', () => { ...svgFiles, ]); - const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.symbol.svg')); assert.match(sprite, /viewBox="-5 -5 34 34"/u); assert.match(sprite, /id="one"/u); }); @@ -264,7 +264,7 @@ describe('svgforge-cli', () => { const dest = path.join(dir, 'out'); await execCli(['--symbol', `--dest=${dest}`, './nested/**/*.svg'], {cwd: fixtureDir}); - const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.symbol.svg')); assert.match(sprite, /id="nested--leaf"/u); }); }); @@ -274,7 +274,7 @@ describe('svgforge-cli', () => { const dest = path.join(dir, 'out'); await execCli(['--symbol', `--dest=${dest}`, 'nested/./**/*.svg'], {cwd: fixtureDir}); - const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.symbol.svg')); assert.match(sprite, /id="leaf"/u); assert.doesNotMatch(sprite, /id="nested--leaf"/u); }); @@ -285,7 +285,7 @@ describe('svgforge-cli', () => { const dest = path.join(dir, 'out'); await execCli(['--symbol', '--shape-id-separator=__', `--dest=${dest}`, './nested/**/*.svg'], {cwd: fixtureDir}); - const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.symbol.svg')); assert.match(sprite, /id="nested__leaf"/u); assert.doesNotMatch(sprite, /id="nested--leaf"/u); }); @@ -296,7 +296,7 @@ describe('svgforge-cli', () => { const dest = path.join(dir, 'out'); await execCli(['--symbol', '--shape-id-generator=%s-icon', `--dest=${dest}`, ...svgFiles]); - const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.symbol.svg')); assert.match(sprite, /id="one-icon"/u); assert.match(sprite, /id="two-icon"/u); }); @@ -307,7 +307,7 @@ describe('svgforge-cli', () => { const dest = path.join(dir, 'out'); await execCli(['--symbol', '--shape-id-whitespace=-', `--dest=${dest}`, path.join(fixtureDir, 'with space.svg')]); - const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.symbol.svg')); assert.match(sprite, /id="with-space"/u); }); }); @@ -373,7 +373,7 @@ describe('svgforge-cli', () => { const dest = path.join(dir, 'out'); await execCli(['--symbol', '--shape-meta', path.join(fixtureDir, 'meta.yaml'), `--dest=${dest}`, path.join(fixtureDir, 'one.svg')]); - const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.symbol.svg')); assert.match(sprite, /aria-labelledby=/u); assert.match(sprite, /]*>Alpha<\/title>/u); assert.match(sprite, /]*>First icon<\/desc>/u); @@ -395,7 +395,7 @@ describe('svgforge-cli', () => { const dest = path.join(dir, 'out'); await execCli(['--symbol', '--shape-transform=svgo', '--shape-transform-svgo', path.join(fixtureDir, 'svgo.config.json'), `--dest=${dest}`, path.join(fixtureDir, 'comment.svg')]); - const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.symbol.svg')); assert.match(sprite, //u); }); }); @@ -407,7 +407,7 @@ describe('svgforge-cli', () => { const dest = path.join(dir, 'out'); await execCli(['--symbol', '--svg-xmldecl=false', `--dest=${dest}`, ...svgFiles]); - const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.symbol.svg')); assert.doesNotMatch(sprite, /^<\?xml/u); }); }); @@ -417,7 +417,7 @@ describe('svgforge-cli', () => { const dest = path.join(dir, 'out'); await execCli(['--symbol', '--symbol-bust=false', `--dest=${dest}`, path.join(fixtureDir, 'doctype.svg')]); - const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.symbol.svg')); assert.match(sprite, / { const dest = path.join(dir, 'out'); await execCli(['--symbol', '--symbol-bust=false', '--svg-doctype=false', `--dest=${dest}`, path.join(fixtureDir, 'doctype.svg')]); - const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.symbol.svg')); assert.doesNotMatch(sprite, / { const dest = path.join(dir, 'out'); await execCli(['--symbol', '--shape-transform=', '--svg-namespace-ids=false', `--dest=${dest}`, path.join(fixtureDir, 'ref.svg')]); - const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.symbol.svg')); assert.match(sprite, /id="arrow"/u); assert.match(sprite, /href="#arrow"/u); }); @@ -446,7 +446,7 @@ describe('svgforge-cli', () => { const dest = path.join(dir, 'out'); await execCli(['--symbol', '--shape-transform=', '--svg-namespace-classnames=false', `--dest=${dest}`, path.join(fixtureDir, 'ref.svg')]); - const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.symbol.svg')); assert.match(sprite, /class="ic"/u); }); }); @@ -456,7 +456,7 @@ describe('svgforge-cli', () => { const dest = path.join(dir, 'out'); await execCli(['--symbol', '--shape-transform=', '--svg-namespace-prefix=p-', `--dest=${dest}`, path.join(fixtureDir, 'ref.svg')]); - const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.symbol.svg')); assert.match(sprite, /id="p-aarrow"/u); assert.match(sprite, /href="#p-aarrow"/u); }); @@ -560,7 +560,7 @@ describe('svgforge-cli', () => { const dest = path.join(dir, 'out'); await execCli(['--defs', '--defs-inline', `--dest=${dest}`, ...svgFiles]); - const sprite = readFile(path.join(dest, 'defs', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'defs', 'svg', 'sprite.defs.svg')); assert.match(sprite, /style="position:absolute"/u); }); }); @@ -570,7 +570,7 @@ describe('svgforge-cli', () => { const dest = path.join(dir, 'out'); await execCli(['--symbol', '--symbol-inline', `--dest=${dest}`, ...svgFiles]); - const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.css.svg')); + const sprite = readFile(path.join(dest, 'symbol', 'svg', 'sprite.symbol.svg')); assert.match(sprite, /style="position:absolute"/u); }); }); diff --git a/test/fixtures/align.yaml b/test/fixtures/align.yaml deleted file mode 100644 index a109dcb..0000000 --- a/test/fixtures/align.yaml +++ /dev/null @@ -1,2 +0,0 @@ -one: - "%s": 1 \ No newline at end of file From a0a6503f8310fa646e23e259f0130ac05a6db088 Mon Sep 17 00:00:00 2001 From: SpotlightOn <265342703+SpotlightOn@users.noreply.github.com> Date: Sun, 1 Nov 2026 20:27:20 +0100 Subject: [PATCH 2/5] chore: remove the unused vinyl dependency The CLI reads path and contents from the compiled files directly since 1.0.1, only the declaration and the type references were left. --- bin/svgforge.js | 14 +++++++++++--- package.json | 1 - pnpm-lock.yaml | 3 --- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bin/svgforge.js b/bin/svgforge.js index a888323..1c147ed 100755 --- a/bin/svgforge.js +++ b/bin/svgforge.js @@ -68,9 +68,17 @@ const RENDER_TYPES = ['css']; */ /** - Recursively nested map of vinyl files + A compiled output file (sprite, stylesheet or example document) - @typedef {{[key: string]: File | FileMap}} FileMap + @typedef {object} FileLike + @property {string} path Absolute output path + @property {Buffer|string} contents File contents + */ + +/** + Recursively nested map of file objects + + @typedef {{[key: string]: FileLike | FileMap}} FileMap */ /** @@ -195,7 +203,7 @@ function addConfigMap(store, keyPath, value) { /** Recursively write files to disk - @param {FileMap} files Nested map of vinyl files + @param {FileMap} files Nested map of file objects @returns {number} Number of written files */ function writeFiles(files) { diff --git a/package.json b/package.json index f2c5648..ce9618a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,6 @@ "dependencies": { "@svgforge/svgforge": "^3.1.0", "js-yaml": "^5.4.3", - "vinyl": "^3.0.1", "yargs": "^18.2.0" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0e80138..1e6323d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,9 +14,6 @@ importers: js-yaml: specifier: ^5.4.3 version: 5.4.3 - vinyl: - specifier: ^3.0.1 - version: 3.0.1 yargs: specifier: ^18.2.0 version: 18.2.0 From a73f6a9412e06442e4def8c5a28a5d8fa3d6546a Mon Sep 17 00:00:00 2001 From: SpotlightOn <265342703+SpotlightOn@users.noreply.github.com> Date: Sun, 1 Nov 2026 20:27:38 +0100 Subject: [PATCH 3/5] chore: prepare 3.2.0 --- CHANGELOG.md | 40 +++++++--- README.md | 2 +- bin/svgforge.js | 2 +- docs/command-line.md | 184 ++++++++++++++++++++++--------------------- package.json | 4 +- 5 files changed, 128 insertions(+), 104 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd17a8c..18475fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,33 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 3.2.0 — Sprite filenames, vinyl removal and dead options + +### Changed + +* The `defs`, `symbol` and `stack` modes now write their sprites to + `sprite.defs.svg`, `sprite.symbol.svg` and `sprite.stack.svg` by default, + matching the library defaults. Previously the CLI overrode them with the + outdated `sprite.css.svg`. +* `vinyl` is completely removed from the CLI: the dependency in `package.json`, + the import and every type reference are gone. Compiled files are detected by + their `path` property since 1.0.1, so the package was only still declared. + +### Removed + +* Dropped the `--shape-align` / `-a` option. It had no effect since the «css» + sprite mode was removed from the library. +* Dropped the `--svg-precision` option. It was parsed and forwarded but never + read by the library. + +### Fixed + +* `docs/command-line.md` now reflects the actual `--help` output: Vento instead + of Mustache, `.vto` template defaults, the `--quiet`, `--view-render-css` + and `--view-render-*` options, and the current sprite filenames. +* `--help` shows the template defaults as short paths (`tmpl/…`) instead of the + absolute paths they resolve to at runtime. + ## 3.1.0 — Clear skip reporting and resvg status ### Added @@ -102,13 +129,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 svgforge library (`svgforge/lib/svg-sprite/utils/index.js`), removing the last lodash dependency -### Changed: depend on svgforge 1.1.0 and fix the GitHub release step +### Changed: depend on svgforge 1.1.0 * Bump the `svgforge` dependency to `^1.1.0` (view-mode `.dims` stylesheet, example-document overhaul and invalid-XML fix) -* Add `GH_TOKEN` to the release workflow so `gh release create` can publish - the GitHub release (it previously failed for svgforge with - "select a GitHub user or use GH_TOKEN") ### Changed: re-add the `view` mode dimension stylesheet @@ -128,7 +152,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 page instead of the online configurator * Mark the `defs` sprite mode as legacy in the modes table -## 1.0.1 — Drop remaining lodash/async dependencies +## 1.0.1 — Depend on svgforge 1.0.1 * Bump the `svgforge` dependency to `^1.0.1` (native promise-based helpers, `deepMerge` and `escapeHtml` utilities, no `async`/`lodash` dependencies) @@ -150,16 +174,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Refactor: ES6 classes, JSDoc and xo-default linting * Convert the CLI to modern ES6 with JSDoc type annotations -* Strip all `off` rules from `xo.config.js`; fixed lint findings in code with - justified line/file-level disables (`xo .` → 0 errors, 0 warnings) * Add `u` flags to all regex literals (`require-unicode-regexp`) * Rename the binary and package from `svg-sprite-cli`/`svg-sprite` to `svgforge-cli`/`svgforge`, including all user-facing config descriptions * Bump engines to Node >= 22 and modernize package metadata -* Resolve the local `svgforge` workspace dependency via a gitignored - `pnpm-workspace.yaml` override (`svgforge: link:../svgforge`) so the - committed `package.json` stays publication-safe (`svgforge: 1.0.0`) -* Add `/pnpm-workspace.yaml` to `.gitignore` and regenerate the lockfile * Replace the `glob` package with the native `fs.globSync` API and drop `glob` from the dependencies; `engines.node` stays `>= 22` (required for the glob API introduced in Node 22) diff --git a/README.md b/README.md index d1335df..7675dd9 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ This results in shape IDs like `path--to--source` (assuming the default shape ID ## Development -Requirements: Node.js >= 18, [pnpm](https://pnpm.io). +Requirements: Node.js >= 24, [pnpm](https://pnpm.io). ```bash pnpm install diff --git a/bin/svgforge.js b/bin/svgforge.js index 1c147ed..c403770 100755 --- a/bin/svgforge.js +++ b/bin/svgforge.js @@ -154,7 +154,7 @@ function addOption(parser, name, option) { if ('default' in option) { const templated = name.endsWith('-template'); const defaultValue = templated ? resolveSvgForgePath(option.default) : option.default; - parser = parser.default(alias, defaultValue); + parser = parser.default(alias, defaultValue, templated ? option.default : undefined); if (option.default === true || option.default === false) { parser = parser.boolean(name); diff --git a/docs/command-line.md b/docs/command-line.md index 1a64438..bdb04ff 100644 --- a/docs/command-line.md +++ b/docs/command-line.md @@ -8,98 +8,104 @@ This file is part of the documentation of *svgforge* — a free low-level Node.j You may use *svgforge* as a command line tool. Type `svgforge --help` to get all the available options: ```text +Create one or multiple sprites of the given SVG files, optionally along with some stylesheet resources. Usage: svgforge [options] files Options: - --version Show version number [boolean] - --help Display this help information [boolean] - -D, --dest Main output directory (base path) [default: "."] - -C, --config Path to external JSON config file - -l, --log Logging verbosity ("info", "verbose" or "debug") - --shape-id-separator Separator for traversing a directory structure into a shape ID [default: "--"] - --shape-id-generator ID generation callback [via CLI only template strings] [default: "%s"] - --shape-id-pseudo Separator for CSS pseudo classes [default: "~"] - --shape-id-whitespace Whitespace replacement string for shape IDs [default: "_"] - -w, --shape-dim-width Maximum shape width in pixels [default: 2000] - -h, --shape-dim-height Maximum shape height in pixels [default: 2000] - --shape-dim-precision Precision (decimal places) for dimension calculations [default: 2] - --shape-dim-attributes Whether to add width and height attributes to the shapes [boolean] [default: false] - -p, --shape-spacing-padding Padding around shape (up to 4 x comma-separated) [default: "0,0,0,0"] - -b, --shape-spacing-box Box sizing strategy ("content", "padding" or "icon") [default: "content"] - -m, --shape-meta Path to YAML file with meta information - -a, --shape-align Path to YAML file with alignment information - --ims, --shape-dest Path to output directory for intermediate SVG files - --shape-transform Comma-separated list of predefined transformers (see docs) [default: "svgo"] - --shape-transform-* External JSON config files for named transformers - --svg-xmldecl Whether to include an XML declaration in SVG files [boolean] [default: true] - --svg-doctype Whether to include a doctype declaration in SVG files [boolean] [default: true] - --svg-namespace-ids Whether to apply ID namespacing to the sprite [boolean] [default: true] - --svg-namespace-prefix What, if any, prefix to apply to the automatically generated id [default: ""] - --svg-namespace-classnames Whether to apply CSS class namespacing to the sprite [boolean] [default: true] - --svg-dimattrs Whether to add width and height attributes to the sprite [boolean] [default: true] - --svg-rootattrs Custom root attributes for the outermost element (external JSON file) - --svg-precision Floating point precision for CSS positioning values [default: -1] - - -v, --view Activates the «view» mode [boolean] [default: false] - --view-dest Mode specific output directory [default: "view"] - --vs, --view-sprite Sprite path and filename (relative to --view-dest) [default: "svg/sprite.view.svg"] - --view-bust Enable cache busting [boolean] [default: true] - --vx, --view-example Whether to render an example HTML document [boolean] [default: false] - --view-example-template HTML document Mustache template (relative to svgforge basedir) [default: "tmpl/view/sprite.html"] - --view-example-dest HTML document destination (relative to the --view-dest) [default: "sprite.view.html"] - - -d, --defs Activates the «defs» mode [boolean] [default: false] - --defs-dest Mode specific output directory [default: "defs"] - --defs-prefix CSS selector prefix for all shapes (including placeholders) [default: ".svg-%s"] - --defs-dimensions CSS selector suffix for shape dimension rules ("" for inline) [default: "-dims"] - --ds, --defs-sprite Sprite path and filename (relative to --defs-dest) [default: "svg/sprite.css.svg"] - --defs-bust Enable cache busting [boolean] [default: false] - --dcss, --defs-render-css Whether to render a CSS stylesheet [boolean] [default: false] - --defs-render-css-template CSS stylesheet Mustache template (relative to svgforge basedir) [default: "tmpl/common/sprite.css"] - --defs-render-css-dest CSS stylesheet destination (relative to the --defs-dest) [default: "sprite.css"] - --defs-render-* Custom output renderings - --defs-render-*-template Custom output Mustache template (relative to svgforge basedir) - --defs-render-*-dest Custom output destination (relative to the --defs-dest) - --di, --defs-inline Create sprite variant suitable for inline embedding [boolean] [default: false] - --dx, --defs-example Whether to render an example HTML document [boolean] [default: false] - --defs-example-template HTML document Mustache template (relative to svgforge basedir) [default: "tmpl/defs/sprite.html"] - --defs-example-dest HTML document destination (relative to the --defs-dest) [default: "sprite.defs.html"] - - -s, --symbol Activates the «symbol» mode [boolean] [default: false] - --symbol-dest Mode specific output directory [default: "symbol"] - --symbol-prefix CSS selector prefix for all shapes (including placeholders) [default: ".svg-%s"] - --symbol-dimensions CSS selector suffix for shape dimension rules ("" for inline) [default: "-dims"] - --ss, --symbol-sprite Sprite path and filename (relative to --symbol-dest) [default: "svg/sprite.css.svg"] - --symbol-bust Enable cache busting [boolean] [default: false] - --sc, --symbol-render-css Whether to render a CSS stylesheet [boolean] [default: false] - --symbol-render-css-template CSS stylesheet Mustache template (relative to svgforge basedir) [default: "tmpl/common/sprite.css"] - --symbol-render-css-dest CSS stylesheet destination (relative to the --symbol-dest) [default: "sprite.css"] - --symbol-render-* Custom output renderings - --symbol-render-*-template Custom output Mustache template (relative to svgforge basedir) - --symbol-render-*-dest Custom output destination (relative to the --symbol-dest) - --si, --symbol-inline Create sprite variant suitable for inline embedding [boolean] [default: false] - --sx, --symbol-example Whether to render an example HTML document [boolean] [default: false] - --symbol-example-template HTML document Mustache template (relative to svgforge basedir) [default: "tmpl/symbol/sprite.html"] - --symbol-example-dest HTML document destination (relative to the --symbol-dest) [default: "sprite.symbol.html"] - - -S, --stack Activates the «stack» mode [boolean] [default: false] - --stack-dest Mode specific output directory [default: "stack"] - --stack-prefix CSS selector prefix for all shapes (including placeholders) [default: ".svg-%s"] - --stack-dimensions CSS selector suffix for shape dimension rules ("" for inline) [default: "-dims"] - --Ss, --stack-sprite Sprite path and filename (relative to --stack-dest) [default: "svg/sprite.css.svg"] - --stack-bust Enable cache busting [boolean] [default: false] - --stack-rootviewbox Add viewBox attribute to root svg automatically [boolean] [default: true] - --Sc, --stack-render-css Whether to render a CSS stylesheet [boolean] [default: false] - --stack-render-css-template CSS stylesheet Mustache template (relative to svgforge basedir) [default: "tmpl/common/sprite.css"] - --stack-render-css-dest CSS stylesheet destination (relative to the --stack-dest) [default: "sprite.css"] - --stack-render-* Custom output renderings - --stack-render-*-template Custom output Mustache template (relative to svgforge basedir) - --stack-render-*-dest Custom output destination (relative to the --stack-dest) - --Sx, --stack-example Whether to render an example HTML document [boolean] [default: false] - --stack-example-template HTML document Mustache template (relative to svgforge basedir) [default: "tmpl/stack/sprite.html"] - --stack-example-dest HTML document destination (relative to the --stack-dest) [default: "sprite.stack.html"] - - --variables Path to external JSON file with Mustache variable definitions + --version Show version number [boolean] + --help Display this help information [boolean] + -D, --dest Main output directory (base path) [default: "."] + -C, --config Path to external JSON config file + -l, --log Logging verbosity ("info", "verbose" or "debug") + -q, --quiet Suppress all output except errors [boolean] [default: false] + --shape-id-separator Separator for traversing a directory structure into a shape ID [default: "--"] + --shape-id-generator ID generation callback [via CLI only template strings] [default: "%s"] + --shape-id-pseudo Separator for CSS pseudo classes [default: "~"] + --shape-id-whitespace Whitespace replacement string for shape IDs [default: "_"] + -w, --shape-dim-width Maximum shape width in pixels [default: 2000] + -h, --shape-dim-height Maximum shape height in pixels [default: 2000] + --shape-dim-precision Precision (decimal places) for dimension calculations [default: 2] + --shape-dim-attributes Whether to add width and height attributes to the shapes [boolean] [default: false] + -p, --shape-spacing-padding Padding around shape (up to 4 x comma-separated) [default: "0,0,0,0"] + -b, --shape-spacing-box Box sizing strategy ("content", "padding" or "icon") [default: "content"] + -m, --shape-meta Path to YAML file with meta information + --ims, --shape-dest Path to output directory for intermediate SVG files + --shape-transform Comma-separated list of predefined transformers (see docs) [default: "svgo"] + --shape-transform-* External JSON config files for named transformers + --svg-xmldecl Whether to include an XML declaration in SVG files [boolean] [default: true] + --svg-doctype Whether to include a doctype declaration in SVG files [boolean] [default: true] + --svg-namespace-ids Whether to apply ID namespacing to the sprite [boolean] [default: true] + --svg-namespace-prefix What, if any, prefix to apply to the automatically generated id [default: ""] + --svg-namespace-classnames Whether to apply CSS class namespacing to the sprite [boolean] [default: true] + --svg-dimattrs Whether to add width and height attributes to the sprite [boolean] [default: true] + --svg-rootattrs Custom root attributes for the outermost element (external JSON file) + -v, --view Activates the «view» mode [boolean] [default: false] + --view-dest Mode specific output directory [default: "view"] + --vs, --view-sprite Sprite path and filename (relative to --view-dest) [default: "svg/sprite.view.svg"] + --view-bust Enable cache busting [boolean] [default: true] + --vcss, --view-render-css Whether to render a CSS stylesheet with shape dimension classes [boolean] [default: false] + --view-render-css-template CSS stylesheet Vento template (relative to svgforge basedir) [default: "tmpl/common/sprite.css.vto"] + --view-render-css-dest CSS stylesheet destination (relative to the --view-dest) [default: "sprite.css"] + --view-render-* Custom output renderings + --view-render-*-template Custom output Vento template (relative to svgforge basedir) + --view-render-*-dest Custom output destination (relative to the --view-dest) + --vx, --view-example Whether to render an example HTML document [boolean] [default: false] + --view-example-template HTML document Vento template (relative to svgforge basedir) [default: "tmpl/view/sprite.vto"] + --view-example-dest HTML document destination (relative to the --view-dest) [default: "sprite.view.html"] + -d, --defs Activates the «defs» mode [boolean] [default: false] + --defs-dest Mode specific output directory [default: "defs"] + --defs-prefix CSS selector prefix for all shapes (including placeholders) [default: ".svg-%s"] + --defs-dimensions CSS selector suffix for shape dimension rules ("" for inline) [default: "-dims"] + --ds, --defs-sprite Sprite path and filename (relative to --defs-dest) [default: "svg/sprite.defs.svg"] + --defs-bust Enable cache busting [boolean] [default: false] + --dcss, --defs-render-css Whether to render a CSS stylesheet [boolean] [default: false] + --defs-render-css-template CSS stylesheet Vento template (relative to svgforge basedir) [default: "tmpl/common/sprite.css.vto"] + --defs-render-css-dest CSS stylesheet destination (relative to the --defs-dest) [default: "sprite.css"] + --defs-render-* Custom output renderings + --defs-render-*-template Custom output Vento template (relative to svgforge basedir) + --defs-render-*-dest Custom output destination (relative to the --defs-dest) + --di, --defs-inline Create sprite variant suitable for inline embedding [boolean] [default: false] + --dx, --defs-example Whether to render an example HTML document [boolean] [default: false] + --defs-example-template HTML document Vento template (relative to svgforge basedir) [default: "tmpl/defs/sprite.vto"] + --defs-example-dest HTML document destination (relative to the --defs-dest) [default: "sprite.defs.html"] + -s, --symbol Activates the «symbol» mode [boolean] [default: false] + --symbol-dest Mode specific output directory [default: "symbol"] + --symbol-prefix CSS selector prefix for all shapes (including placeholders) [default: ".svg-%s"] + --symbol-dimensions CSS selector suffix for shape dimension rules ("" for inline) [default: "-dims"] + --ss, --symbol-sprite Sprite path and filename (relative to --symbol-dest) [default: "svg/sprite.symbol.svg"] + --symbol-bust Enable cache busting [boolean] [default: false] + --sc, --symbol-render-css Whether to render a CSS stylesheet [boolean] [default: false] + --symbol-render-css-template CSS stylesheet Vento template (relative to svgforge basedir) [default: "tmpl/common/sprite.css.vto"] + --symbol-render-css-dest CSS stylesheet destination (relative to the --symbol-dest) [default: "sprite.css"] + --symbol-render-* Custom output renderings + --symbol-render-*-template Custom output Vento template (relative to svgforge basedir) + --symbol-render-*-dest Custom output destination (relative to the --symbol-dest) + --si, --symbol-inline Create sprite variant suitable for inline embedding [boolean] [default: false] + --sx, --symbol-example Whether to render an example HTML document [boolean] [default: false] + --symbol-example-template HTML document Vento template (relative to svgforge basedir) [default: "tmpl/symbol/sprite.vto"] + --symbol-example-dest HTML document destination (relative to the --symbol-dest) [default: "sprite.symbol.html"] + -S, --stack Activates the «stack» mode [boolean] [default: false] + --stack-dest Mode specific output directory [default: "stack"] + --stack-prefix CSS selector prefix for all shapes (including placeholders) [default: ".svg-%s"] + --stack-dimensions CSS selector suffix for shape dimension rules ("" for inline) [default: "-dims"] + --Ss, --stack-sprite Sprite path and filename (relative to --stack-dest) [default: "svg/sprite.stack.svg"] + --stack-bust Enable cache busting [boolean] [default: false] + --stack-rootviewbox Add viewBox attribute to root svg automatically [boolean] [default: true] + --Sc, --stack-render-css Whether to render a CSS stylesheet [boolean] [default: false] + --stack-render-css-template CSS stylesheet Vento template (relative to svgforge basedir) [default: "tmpl/common/sprite.css.vto"] + --stack-render-css-dest CSS stylesheet destination (relative to the --stack-dest) [default: "sprite.css"] + --stack-render-* Custom output renderings + --stack-render-*-template Custom output Vento template (relative to svgforge basedir) + --stack-render-*-dest Custom output destination (relative to the --stack-dest) + --Sx, --stack-example Whether to render an example HTML document [boolean] [default: false] + --stack-example-template HTML document Vento template (relative to svgforge basedir) [default: "tmpl/stack/sprite.vto"] + --stack-example-dest HTML document destination (relative to the --stack-dest) [default: "sprite.stack.html"] + --variables Path to external JSON file with Vento variable definitions + +Examples: + svgforge --view --view-example --dest=out assets/*.svg Create a view sprite of the given SVG files including example document to the subdirectory "out" + svgforge --defs --defs-render-css --defs-example --dest=out assets/*.svg Create a defs sprite of the given SVG files including a CSS stylesheet and example document + svgforge -S -p 10 assets/*.svg Create a stack sprite and add 10px padding around all shapes ``` ### Examples diff --git a/package.json b/package.json index ce9618a..f92c4fc 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "@svgforge/svgforge-cli", - "version": "3.1.0", + "version": "3.2.0", "author": "svgforge (https://github.com/SpotlightOn)", - "description": "Command line interface for svgforge \u2014 create SVG sprites & stacks with stylesheet resources (CSS, Sass, etc.)", + "description": "Command line interface for svgforge \u2014 create SVG sprites & stacks with stylesheet resources", "homepage": "https://github.com/svgforge/svgforge-cli", "repository": { "type": "git", From 51aaff10d638c2a24fe6102e6d6e7cf9b7d18573 Mon Sep 17 00:00:00 2001 From: SpotlightOn <265342703+SpotlightOn@users.noreply.github.com> Date: Sun, 1 Nov 2026 20:34:44 +0100 Subject: [PATCH 4/5] ci: install pnpm and Node.js with pnpm/setup The action installs Node.js from .nvmrc and runs pnpm install itself, so the separate install step goes. require-lockfile keeps it frozen. --- .github/workflows/beta.yml | 8 ++------ .github/workflows/lint.yml | 8 ++------ .github/workflows/release.yml | 8 ++------ .github/workflows/test.yml | 11 ++++------- .github/workflows/unstable.yml | 8 ++------ .husky/pre-commit | 10 ++++------ .nvmrc | 1 + 7 files changed, 17 insertions(+), 37 deletions(-) create mode 100644 .nvmrc diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 168618f..50148a8 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -11,7 +11,6 @@ permissions: env: FORCE_COLOR: 2 - NODE: 24 # The Node.js version to publish from jobs: publish: @@ -26,14 +25,11 @@ jobs: persist-credentials: false - name: Install pnpm and Node.js - uses: pnpm/setup@c9883cc79df532ad1a7b81bf9ab944ceb090d65c # v2.0.0 + uses: pnpm/setup@v3 with: version: 12 - runtime: node@${{ env.NODE }} cache: true - - - name: Install dependencies - run: pnpm install + require-lockfile: true - name: Lint run: pnpm lint diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0d5eea0..3549304 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,7 +11,6 @@ on: env: FORCE_COLOR: 2 - NODE: 24 # The Node.js version to run lint on permissions: contents: read @@ -27,14 +26,11 @@ jobs: persist-credentials: false - name: Install pnpm and Node.js - uses: pnpm/setup@c9883cc79df532ad1a7b81bf9ab944ceb090d65c # v2.0.0 + uses: pnpm/setup@v3 with: version: 12 - runtime: node@${{ env.NODE }} cache: true - - - name: Install dependencies - run: pnpm install + require-lockfile: true - name: Run lint run: pnpm lint diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8893fd8..a181594 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,7 +8,6 @@ on: env: FORCE_COLOR: 2 - NODE: 24 # The Node.js version to publish from permissions: contents: write @@ -28,14 +27,11 @@ jobs: persist-credentials: false - name: Install pnpm and Node.js - uses: pnpm/setup@c9883cc79df532ad1a7b81bf9ab944ceb090d65c # v2.0.0 + uses: pnpm/setup@v3 with: version: 12 - runtime: node@${{ env.NODE }} cache: true - - - name: Install dependencies - run: pnpm install + require-lockfile: true - name: Verify version matches tag run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 57a266f..743fddd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,19 +27,16 @@ jobs: persist-credentials: false - name: Install pnpm and Node.js - uses: pnpm/setup@c9883cc79df532ad1a7b81bf9ab944ceb090d65c # v2.0.0 + uses: pnpm/setup@v3 with: version: 12 - runtime: node@24 cache: true + require-lockfile: true - - name: Install dependencies - run: pnpm install - - - name: Reject local link overrides (Kernregel) + - name: Reject local link overrides run: | if grep -R "link:" pnpm-workspace.yaml pnpm-lock.yaml 2>/dev/null; then - echo "::error::pnpm-workspace.yaml/pnpm-lock.yaml contain a local link: override. Run ./set-dev.sh false before committing." >&2 + echo "::error::pnpm-workspace.yaml/pnpm-lock.yaml contain a local link: override." >&2 exit 1 fi echo "No link: override found — lockfile resolves from the registry." diff --git a/.github/workflows/unstable.yml b/.github/workflows/unstable.yml index ce56b5b..5f793c8 100644 --- a/.github/workflows/unstable.yml +++ b/.github/workflows/unstable.yml @@ -11,7 +11,6 @@ permissions: env: FORCE_COLOR: 2 - NODE: 24 # The Node.js version to publish from jobs: publish: @@ -26,14 +25,11 @@ jobs: persist-credentials: false - name: Install pnpm and Node.js - uses: pnpm/setup@c9883cc79df532ad1a7b81bf9ab944ceb090d65c # v2.0.0 + uses: pnpm/setup@v3 with: version: 12 - runtime: node@${{ env.NODE }} cache: true - - - name: Install dependencies - run: pnpm install + require-lockfile: true - name: Lint run: pnpm lint diff --git a/.husky/pre-commit b/.husky/pre-commit index efa1f48..ca65b85 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,7 +1,6 @@ #!/usr/bin/env sh -# Kernregel (AGENTS.md): niemals einen lokalen link:-Override committen. -# Lokaler Dev-Zustand: ./set-dev.sh true — vor dem Commit: ./set-dev.sh false. -# Dieser Guard prüft den Staging-Bereich, nicht den Arbeitsbaum. +# Never commit a local link: override (see AGENTS.md). +# This guard inspects the staging area, not the working tree. files="pnpm-workspace.yaml pnpm-lock.yaml" offenders="" @@ -13,8 +12,7 @@ for f in $files; do done if [ -n "$offenders" ]; then - echo "✗ Commit abgebrochen: link:-Override in:$offenders" >&2 - echo " (Kernregel, AGENTS.md — verunreinigt CI und die Registry-Lockfile)" >&2 - echo " → ./set-dev.sh false ausführen, erneut adden und committen." >&2 + echo "✗ Commit aborted: link: override in:$offenders" >&2 + echo " Remove the override, stage the files again and commit." >&2 exit 1 fi diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..a45fd52 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +24 From 9d112c02ad8603fa057d445d21030988112d65c2 Mon Sep 17 00:00:00 2001 From: SpotlightOn <265342703+SpotlightOn@users.noreply.github.com> Date: Sun, 1 Nov 2026 21:49:36 +0100 Subject: [PATCH 5/5] chore: depend on svgforge 3.2.0 --- CHANGELOG.md | 1 + package.json | 2 +- pnpm-lock.yaml | 10 +++++----- pnpm-workspace.yaml | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18475fa..d8b02e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * `vinyl` is completely removed from the CLI: the dependency in `package.json`, the import and every type reference are gone. Compiled files are detected by their `path` property since 1.0.1, so the package was only still declared. +* Requires `@svgforge/svgforge` 3.2.0. ### Removed diff --git a/package.json b/package.json index f92c4fc..fbe72af 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "test:coverage": "mkdir -p coverage && node --test --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=coverage/lcov.info" }, "dependencies": { - "@svgforge/svgforge": "^3.1.0", + "@svgforge/svgforge": "^3.2.0", "js-yaml": "^5.4.3", "yargs": "^18.2.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1e6323d..241dd02 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: '@svgforge/svgforge': - specifier: ^3.1.0 - version: 3.1.0(@resvg/resvg-js@2.6.2) + specifier: ^3.2.0 + version: 3.2.0(@resvg/resvg-js@2.6.2) js-yaml: specifier: ^5.4.3 version: 5.4.3 @@ -304,8 +304,8 @@ packages: peerDependencies: eslint: ^9.0.0 || ^10.0.0 - '@svgforge/svgforge@3.1.0': - resolution: {integrity: sha512-epW+Dpt+NfZBZUvi1xr+hrTEIZBlX3klHKKQQdPunRD4ayMKyjGtYmNIZvPZNIJtfcSguICyZZojOQ5xUhVsog==} + '@svgforge/svgforge@3.2.0': + resolution: {integrity: sha512-UmuOPu98gbRFokHfQSBr/yQPHQkHDsN3sMxQeLUXLdvkI5D/DYZumRexh3RDjs+BdQW0DyhYvPXlEemrx8558g==} engines: {node: '>=24'} peerDependencies: '@resvg/resvg-js': ^2.6.2 @@ -2168,7 +2168,7 @@ snapshots: estraverse: 5.3.0 picomatch: 4.0.7 - '@svgforge/svgforge@3.1.0(@resvg/resvg-js@2.6.2)': + '@svgforge/svgforge@3.2.0(@resvg/resvg-js@2.6.2)': dependencies: '@resvg/resvg-js': 2.6.2 '@xmldom/xmldom': 0.9.12 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index d1eae43..0c12904 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,7 +1,7 @@ allowBuilds: unrs-resolver: true minimumReleaseAgeExclude: - - '@svgforge/svgforge@3.1.0' + - '@svgforge/svgforge@3.2.0' peerDependencyRules: ignoreMissing: - '@resvg/resvg-js'