From d17d523e618a3e6c80dd09eeb67508afa8e082bd Mon Sep 17 00:00:00 2001 From: Imani Manyara Date: Wed, 11 Nov 2026 10:12:49 -0500 Subject: [PATCH 1/2] Name packs by lowercase slugs, and rename the icon-sets-extras set configs A pack name is a file name, a URL segment and a run-history key, so it is letters a-z and digits in words joined by single hyphens (config.IsSlug). The 20 icon-sets-extras. configs become icon-sets-extras-. The old spellings are deprecated, not removed: a dotted, capitalised or underscore-joined name in --pack, a registry, a config's name or its file name loads as the slug with a warning, and /packs/ redirects, until 1.0.0. A name with no slug spelling is refused. TestEveryShippedNameIsASlug reads the raw files, so the loader's leniency cannot hide a shipped dotted name; proven red by restoring icon-sets-extras.eva. --- CHANGELOG.md | 1 + ....json => icon-sets-extras-ant-design.json} | 2 +- .../icon-sets-extras-boxicons.json | 2 +- .../icon-sets-extras-coolicons.json | 2 +- .../icon-sets-extras-coreui.json | 2 +- .../icon-sets-extras-devicon.json | 2 +- ...ras.eva.json => icon-sets-extras-eva.json} | 2 +- .../icon-sets-extras-feather.json | 2 +- ...son => icon-sets-extras-fluent-emoji.json} | 2 +- ....json => icon-sets-extras-game-icons.json} | 2 +- ...rden.json => icon-sets-extras-garden.json} | 2 +- ...son => icon-sets-extras-health-icons.json} | 2 +- .../icon-sets-extras-iconpark.json | 2 +- .../icon-sets-extras-mingcute.json | 2 +- ....json => icon-sets-extras-noto-emoji.json} | 2 +- ...ns.json => icon-sets-extras-pepicons.json} | 2 +- ...ead.json => icon-sets-extras-pinhead.json} | 2 +- ...json => icon-sets-extras-radix-icons.json} | 2 +- .../icon-sets-extras-siemens-ix.json | 2 +- ...s.json => icon-sets-extras-svg-logos.json} | 2 +- .../icon-sets-extras-tdesign.json | 2 +- config/packs.json | 40 ++--- config/schema/pack.schema.json | 2 +- src/internal/core/checker/archive_test.go | 2 +- src/internal/core/checker/checker.go | 2 +- src/internal/core/config/config.go | 15 ++ .../core/config/schema/pack.schema.json | 2 +- src/internal/core/config/slug.go | 85 +++++++++++ src/internal/core/config/slug_test.go | 141 ++++++++++++++++++ ....json => icon-sets-extras-ant-design.json} | 2 +- .../config/icon-sets-extras-boxicons.json | 2 +- .../config/icon-sets-extras-coolicons.json | 2 +- .../config/icon-sets-extras-coreui.json | 2 +- .../config/icon-sets-extras-devicon.json | 2 +- ...ras.eva.json => icon-sets-extras-eva.json} | 2 +- .../config/icon-sets-extras-feather.json | 2 +- ...son => icon-sets-extras-fluent-emoji.json} | 2 +- ....json => icon-sets-extras-game-icons.json} | 2 +- ...rden.json => icon-sets-extras-garden.json} | 2 +- ...son => icon-sets-extras-health-icons.json} | 2 +- .../config/icon-sets-extras-iconpark.json | 2 +- .../config/icon-sets-extras-mingcute.json | 2 +- ....json => icon-sets-extras-noto-emoji.json} | 2 +- ...ns.json => icon-sets-extras-pepicons.json} | 2 +- ...ead.json => icon-sets-extras-pinhead.json} | 2 +- ...json => icon-sets-extras-radix-icons.json} | 2 +- .../config/icon-sets-extras-siemens-ix.json | 2 +- ...s.json => icon-sets-extras-svg-logos.json} | 2 +- .../config/icon-sets-extras-tdesign.json | 2 +- src/internal/defaultconfig/config/packs.json | 40 ++--- .../config/schema/pack.schema.json | 2 +- src/internal/ui/ui.go | 5 +- src/internal/ui/ui_test.go | 2 +- src/internal/web/handle_pack.go | 26 +++- src/internal/web/runs_test.go | 16 +- 55 files changed, 364 insertions(+), 97 deletions(-) rename config/{icon-sets-extras.ant-design.json => icon-sets-extras-ant-design.json} (97%) rename src/internal/defaultconfig/config/icon-sets-extras.boxicons.json => config/icon-sets-extras-boxicons.json (97%) rename src/internal/defaultconfig/config/icon-sets-extras.coolicons.json => config/icon-sets-extras-coolicons.json (97%) rename src/internal/defaultconfig/config/icon-sets-extras.coreui.json => config/icon-sets-extras-coreui.json (97%) rename src/internal/defaultconfig/config/icon-sets-extras.devicon.json => config/icon-sets-extras-devicon.json (97%) rename config/{icon-sets-extras.eva.json => icon-sets-extras-eva.json} (98%) rename src/internal/defaultconfig/config/icon-sets-extras.feather.json => config/icon-sets-extras-feather.json (97%) rename config/{icon-sets-extras.fluent-emoji.json => icon-sets-extras-fluent-emoji.json} (97%) rename config/{icon-sets-extras.game-icons.json => icon-sets-extras-game-icons.json} (97%) rename config/{icon-sets-extras.garden.json => icon-sets-extras-garden.json} (97%) rename config/{icon-sets-extras.health-icons.json => icon-sets-extras-health-icons.json} (97%) rename src/internal/defaultconfig/config/icon-sets-extras.iconpark.json => config/icon-sets-extras-iconpark.json (97%) rename src/internal/defaultconfig/config/icon-sets-extras.mingcute.json => config/icon-sets-extras-mingcute.json (97%) rename config/{icon-sets-extras.noto-emoji.json => icon-sets-extras-noto-emoji.json} (97%) rename config/{icon-sets-extras.pepicons.json => icon-sets-extras-pepicons.json} (97%) rename config/{icon-sets-extras.pinhead.json => icon-sets-extras-pinhead.json} (97%) rename config/{icon-sets-extras.radix-icons.json => icon-sets-extras-radix-icons.json} (97%) rename src/internal/defaultconfig/config/icon-sets-extras.siemens-ix.json => config/icon-sets-extras-siemens-ix.json (96%) rename config/{icon-sets-extras.svg-logos.json => icon-sets-extras-svg-logos.json} (97%) rename src/internal/defaultconfig/config/icon-sets-extras.tdesign.json => config/icon-sets-extras-tdesign.json (96%) create mode 100644 src/internal/core/config/slug.go create mode 100644 src/internal/core/config/slug_test.go rename src/internal/defaultconfig/config/{icon-sets-extras.ant-design.json => icon-sets-extras-ant-design.json} (97%) rename config/icon-sets-extras.boxicons.json => src/internal/defaultconfig/config/icon-sets-extras-boxicons.json (97%) rename config/icon-sets-extras.coolicons.json => src/internal/defaultconfig/config/icon-sets-extras-coolicons.json (97%) rename config/icon-sets-extras.coreui.json => src/internal/defaultconfig/config/icon-sets-extras-coreui.json (97%) rename config/icon-sets-extras.devicon.json => src/internal/defaultconfig/config/icon-sets-extras-devicon.json (97%) rename src/internal/defaultconfig/config/{icon-sets-extras.eva.json => icon-sets-extras-eva.json} (98%) rename config/icon-sets-extras.feather.json => src/internal/defaultconfig/config/icon-sets-extras-feather.json (97%) rename src/internal/defaultconfig/config/{icon-sets-extras.fluent-emoji.json => icon-sets-extras-fluent-emoji.json} (97%) rename src/internal/defaultconfig/config/{icon-sets-extras.game-icons.json => icon-sets-extras-game-icons.json} (97%) rename src/internal/defaultconfig/config/{icon-sets-extras.garden.json => icon-sets-extras-garden.json} (97%) rename src/internal/defaultconfig/config/{icon-sets-extras.health-icons.json => icon-sets-extras-health-icons.json} (97%) rename config/icon-sets-extras.iconpark.json => src/internal/defaultconfig/config/icon-sets-extras-iconpark.json (97%) rename config/icon-sets-extras.mingcute.json => src/internal/defaultconfig/config/icon-sets-extras-mingcute.json (97%) rename src/internal/defaultconfig/config/{icon-sets-extras.noto-emoji.json => icon-sets-extras-noto-emoji.json} (97%) rename src/internal/defaultconfig/config/{icon-sets-extras.pepicons.json => icon-sets-extras-pepicons.json} (97%) rename src/internal/defaultconfig/config/{icon-sets-extras.pinhead.json => icon-sets-extras-pinhead.json} (97%) rename src/internal/defaultconfig/config/{icon-sets-extras.radix-icons.json => icon-sets-extras-radix-icons.json} (97%) rename config/icon-sets-extras.siemens-ix.json => src/internal/defaultconfig/config/icon-sets-extras-siemens-ix.json (96%) rename src/internal/defaultconfig/config/{icon-sets-extras.svg-logos.json => icon-sets-extras-svg-logos.json} (97%) rename config/icon-sets-extras.tdesign.json => src/internal/defaultconfig/config/icon-sets-extras-tdesign.json (96%) diff --git a/CHANGELOG.md b/CHANGELOG.md index eead320..d27de88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ All notable changes to `ichava/icon-sets-sync` (formerly `ichava/maintainer-tool ### Changed +- **Pack names are lowercase slugs, and the 20 `icon-sets-extras` set configs are renamed to match.** `icon-sets-extras.` (for example `icon-sets-extras.ant-design`) is now `icon-sets-extras-`, in the config file names, their `name`, `packs.json` and the embedded copy. A name is letters a-z and digits in words joined by single hyphens (`config.IsSlug`), and `TestEveryShippedNameIsASlug` reads the raw files and fails on anything else. The old spellings are deprecated, not removed: a dotted, capitalised or underscore-joined name in `--pack`, a registry, a config's `name` or its file name loads as the slug with a warning, and `/packs/` redirects to the slug's page, until 1.0.0. A name with no slug spelling is refused, naming the rule. The check table still labels a set config's row with its set. - **The emoji pack is `icon-sets-twemoji`, synced by the `twemoji-sets` recipe** (owner, 2026-11-05: forward only, no aliases). The pack was renamed on GitHub and ships Twemoji only, so its config is `config/icon-sets-twemoji.json` (and the embedded copy), registered in `packs.json` under that name, with `pack` `ichava/icon-sets-twemoji` and `pack_root` `/work/icon-sets-twemoji`. The recipe `emoji-sets` is now `twemoji-sets` (`RecipeTwemojiSets`, the schema enum), and its pipelines are `twemoji-sets:twemoji@` and `twemoji-sets:commit`; the OpenMoji pipelines, which borrowed the old prefix, are named for their own recipe, `openmoji-sets:@`. `make build-emoji` is `make build-twemoji`. Nothing reads the old pack name, recipe name or target. The frozen lxml oracle's sample paths follow the files to where they now live (Twemoji under `icon-sets-twemoji/`, OpenMoji under `icon-sets-openmoji/`, same bytes), so the differential compares them again: 726 of 1,238 present. The `emoji.unicode_version` setting and `ICHAVA_EMOJI_UNICODE_VERSION` keep their names: both recipes read them, so they name emoji, not the pack. - **The Composer launcher downloads a release binary only on opt-in** (`ICHAVA_ICON_SETS_SYNC_DOWNLOAD=1`). Without it, and without `ICHAVA_ICON_SETS_SYNC_BIN`, it stops and says how to build from source, so cutting a release can never switch a download channel on by itself (G-06). - **The web-asset vendor fetches through `httpx`**, under the upstream allowlist, the https-only redirect guard and the size caps, and `internal/tabler` is `internal/webvendor` (G-03). `orDash`, `orDefault` and `itoa` are written once (G-04). diff --git a/config/icon-sets-extras.ant-design.json b/config/icon-sets-extras-ant-design.json similarity index 97% rename from config/icon-sets-extras.ant-design.json rename to config/icon-sets-extras-ant-design.json index 611055b..252b179 100644 --- a/config/icon-sets-extras.ant-design.json +++ b/config/icon-sets-extras-ant-design.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. inline-svg/{outlined,filled,twotone} flattened to -outlined/-filled/-twotone. The npm package ships no licence file (licence_missing): licenses/ant-design/ needs a source.md before the first real sync, or the sink removes the hand-supplied text. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 848 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.ant-design", + "name": "icon-sets-extras-ant-design", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "4.6.0", diff --git a/src/internal/defaultconfig/config/icon-sets-extras.boxicons.json b/config/icon-sets-extras-boxicons.json similarity index 97% rename from src/internal/defaultconfig/config/icon-sets-extras.boxicons.json rename to config/icon-sets-extras-boxicons.json index 2f21df8..307f4d2 100644 --- a/src/internal/defaultconfig/config/icon-sets-extras.boxicons.json +++ b/config/icon-sets-extras-boxicons.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. svg/regular, svg/solid and svg/logos merged; the bx-/bxs-/bxl- prefixes already keep names apart. The bxl- logos depict trademarks. The package offers CC-BY-4.0, OFL-1.1 or MIT; the LICENSE it ships, and the option taken, is MIT. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 1,634 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.boxicons", + "name": "icon-sets-extras-boxicons", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "2.1.4", diff --git a/src/internal/defaultconfig/config/icon-sets-extras.coolicons.json b/config/icon-sets-extras-coolicons.json similarity index 97% rename from src/internal/defaultconfig/config/icon-sets-extras.coolicons.json rename to config/icon-sets-extras-coolicons.json index 513c1b1..51e9268 100644 --- a/src/internal/defaultconfig/config/icon-sets-extras.coolicons.json +++ b/config/icon-sets-extras-coolicons.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. icons/svg/{line,fill}/regular flattened to -line/-fill. The other 13 style folders (bulk, duotone, duocolor; round and sharp corners) are the same drawings restyled and are not vendored. v5 is MIT; v4 was CC-BY-4.0. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 2,648 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.coolicons", + "name": "icon-sets-extras-coolicons", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "5.2.0", diff --git a/src/internal/defaultconfig/config/icon-sets-extras.coreui.json b/config/icon-sets-extras-coreui.json similarity index 97% rename from src/internal/defaultconfig/config/icon-sets-extras.coreui.json rename to config/icon-sets-extras-coreui.json index c65aa64..c9e5ef5 100644 --- a/src/internal/defaultconfig/config/icon-sets-extras.coreui.json +++ b/config/icon-sets-extras-coreui.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. svg/free/*.svg, unchanged names. Only the free set: the brand and flag SVGs are CC0 in the same LICENSE, but the brands are trademarks and the flags duplicate icon-sets-flag. CoreUI's LICENSE is its own summary (icons CC-BY-4.0, brands and flags CC0, code MIT) rather than the CC text, so it is pinned by SHA-256. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 562 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.coreui", + "name": "icon-sets-extras-coreui", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "3.1.0", diff --git a/src/internal/defaultconfig/config/icon-sets-extras.devicon.json b/config/icon-sets-extras-devicon.json similarity index 97% rename from src/internal/defaultconfig/config/icon-sets-extras.devicon.json rename to config/icon-sets-extras-devicon.json index 8e9eb3a..bdb5966 100644 --- a/src/internal/defaultconfig/config/icon-sets-extras.devicon.json +++ b/config/icon-sets-extras-devicon.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. icons//.svg flattened; upstream names already carry the tech and the style. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 2,120 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.devicon", + "name": "icon-sets-extras-devicon", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "2.18.0", diff --git a/config/icon-sets-extras.eva.json b/config/icon-sets-extras-eva.json similarity index 98% rename from config/icon-sets-extras.eva.json rename to config/icon-sets-extras-eva.json index aa1f83e..e11dc50 100644 --- a/config/icon-sets-extras.eva.json +++ b/config/icon-sets-extras-eva.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. fill/svg and outline/svg merged; upstream already names outline icons -outline. The sprites and font are left out. Unmaintained upstream (last push 2023). The npm package ships no licence file (licence_missing): licenses/eva/ needs a source.md before the first real sync. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 490 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.eva", + "name": "icon-sets-extras-eva", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "1.1.3", diff --git a/src/internal/defaultconfig/config/icon-sets-extras.feather.json b/config/icon-sets-extras-feather.json similarity index 97% rename from src/internal/defaultconfig/config/icon-sets-extras.feather.json rename to config/icon-sets-extras-feather.json index 3c518c9..60cb1ce 100644 --- a/src/internal/defaultconfig/config/icon-sets-extras.feather.json +++ b/config/icon-sets-extras-feather.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. dist/icons/*.svg, unchanged names. Lucide is its maintained successor. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 287 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.feather", + "name": "icon-sets-extras-feather", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "4.29.2", diff --git a/config/icon-sets-extras.fluent-emoji.json b/config/icon-sets-extras-fluent-emoji.json similarity index 97% rename from config/icon-sets-extras.fluent-emoji.json rename to config/icon-sets-extras-fluent-emoji.json index d53d3f5..80c9465 100644 --- a/config/icon-sets-extras.fluent-emoji.json +++ b/config/icon-sets-extras-fluent-emoji.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. assets//[/]{Flat,High Contrast}/.svg flattened and slugged. The Color style (3,145 files, 132 MB of gradients) is excluded by directory; the 3D PNGs are not SVGs. Upstream has no tags, so the version is a commit. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 4,740 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.fluent-emoji", + "name": "icon-sets-extras-fluent-emoji", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "1ffb34c752ecf5d402f04cfb4b392c77f57c54bc", diff --git a/config/icon-sets-extras.game-icons.json b/config/icon-sets-extras-game-icons.json similarity index 97% rename from config/icon-sets-extras.game-icons.json rename to config/icon-sets-extras-game-icons.json index e291b7d..3736748 100644 --- a/config/icon-sets-extras.game-icons.json +++ b/config/icon-sets-extras-game-icons.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. /.svg kept, one directory per contributor, so every icon stays attributable. badges/ and various-artists/ are excluded: license.txt does not name them, so no licence is stated for them. license.txt is the project's own CC-BY-3.0 statement rather than the CC text, so it is pinned by SHA-256. Upstream has no tags, so the version is a commit. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 4,178 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.game-icons", + "name": "icon-sets-extras-game-icons", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "82d948812bfe3f269ef8f731dcdb07b08160edc4", diff --git a/config/icon-sets-extras.garden.json b/config/icon-sets-extras-garden.json similarity index 97% rename from config/icon-sets-extras.garden.json rename to config/icon-sets-extras-garden.json index 7f2134d..9614325 100644 --- a/config/icon-sets-extras.garden.json +++ b/config/icon-sets-extras-garden.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. src/16 and src/12 flattened to -16/-12. 9.0.0 exists only as a pre-release; the stable 8.4.0 is pinned. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 932 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.garden", + "name": "icon-sets-extras-garden", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "8.4.0", diff --git a/config/icon-sets-extras.health-icons.json b/config/icon-sets-extras-health-icons.json similarity index 97% rename from config/icon-sets-extras.health-icons.json rename to config/icon-sets-extras-health-icons.json index d0107b8..e8eb9f8 100644 --- a/config/icon-sets-extras.health-icons.json +++ b/config/icon-sets-extras-health-icons.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. public/icons/svg/{outline,filled}//.svg flattened to -outline/-filled, the stem slugged before the suffix (`!.svg` is committed as `-filled.svg`). The 24px redraws are not vendored. Its LICENSE splits icons (CC0) from website code (MIT), so it is pinned by SHA-256. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 1,552 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.health-icons", + "name": "icon-sets-extras-health-icons", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "3.1.0", diff --git a/src/internal/defaultconfig/config/icon-sets-extras.iconpark.json b/config/icon-sets-extras-iconpark.json similarity index 97% rename from src/internal/defaultconfig/config/icon-sets-extras.iconpark.json rename to config/icon-sets-extras-iconpark.json index 7d9d917..169015b 100644 --- a/src/internal/defaultconfig/config/icon-sets-extras.iconpark.json +++ b/config/icon-sets-extras-iconpark.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. source//*.svg flattened; names are unique across categories. Upstream is archived; 1.4.2 is final. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 2,658 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.iconpark", + "name": "icon-sets-extras-iconpark", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "1.4.2", diff --git a/src/internal/defaultconfig/config/icon-sets-extras.mingcute.json b/config/icon-sets-extras-mingcute.json similarity index 97% rename from src/internal/defaultconfig/config/icon-sets-extras.mingcute.json rename to config/icon-sets-extras-mingcute.json index d0bde8e..c2e0dc3 100644 --- a/src/internal/defaultconfig/config/icon-sets-extras.mingcute.json +++ b/config/icon-sets-extras-mingcute.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. assets/stroke/core/{regular,filled}//.svg flattened to -regular/-filled. The npm package ships JavaScript only, so the source is the tagged archive. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 4,526 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.mingcute", + "name": "icon-sets-extras-mingcute", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "4.0.0", diff --git a/config/icon-sets-extras.noto-emoji.json b/config/icon-sets-extras-noto-emoji.json similarity index 97% rename from config/icon-sets-extras.noto-emoji.json rename to config/icon-sets-extras-noto-emoji.json index 731cb00..10c0191 100644 --- a/config/icon-sets-extras.noto-emoji.json +++ b/config/icon-sets-extras-noto-emoji.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. 2D/svg/emoji_u.svg, slugged (emoji-u1f600). The root LICENSE is the OFL and covers the fonts; 2D/svg/LICENSE is the Apache-2.0 notice that governs the SVGs, so the licence is read from there (licence_from) and pinned by SHA-256. 170 SVGs declare Adobe Illustrator entities in an internal DTD, which the sanitiser cannot parse, so they cannot be checked and are dropped (drop_unparsable). The tagged archive is 1.2 GB, almost all of it 3D PNGs, so this source raises the download cap to 2 GiB. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 3,580 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.noto-emoji", + "name": "icon-sets-extras-noto-emoji", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "2026-09-24-unicode18_0", diff --git a/config/icon-sets-extras.pepicons.json b/config/icon-sets-extras-pepicons.json similarity index 97% rename from config/icon-sets-extras.pepicons.json rename to config/icon-sets-extras-pepicons.json index 24c65ee..657bee3 100644 --- a/config/icon-sets-extras.pepicons.json +++ b/config/icon-sets-extras-pepicons.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. svg/{pop,print,pencil} flattened to -pop/-print/-pencil. CC-BY-4.0: attribution is required and is carried in ATTRIBUTION.md. The npm package ships no licence file (licence_missing): licenses/pepicons/ needs a source.md before the first real sync. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 3,825 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.pepicons", + "name": "icon-sets-extras-pepicons", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "3.1.6", diff --git a/config/icon-sets-extras.pinhead.json b/config/icon-sets-extras-pinhead.json similarity index 97% rename from config/icon-sets-extras.pinhead.json rename to config/icon-sets-extras-pinhead.json index 4ec88ad..6330a40 100644 --- a/config/icon-sets-extras.pinhead.json +++ b/config/icon-sets-extras-pinhead.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. dist/icons/*.svg, underscores slugged to hyphens. Pinhead incorporates icons from Temaki, Maki, OpenStreetMap Carto, Osmic, Health Icons and others; its README lists every source as CC0 or public domain. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 2,747 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.pinhead", + "name": "icon-sets-extras-pinhead", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "16.26.0", diff --git a/config/icon-sets-extras.radix-icons.json b/config/icon-sets-extras-radix-icons.json similarity index 97% rename from config/icon-sets-extras.radix-icons.json rename to config/icon-sets-extras-radix-icons.json index 6c0242f..b9fb624 100644 --- a/config/icon-sets-extras.radix-icons.json +++ b/config/icon-sets-extras-radix-icons.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. packages/radix-icons/icons/*.svg, unchanged names. The archive tag is website@0.0.17, which holds packages/radix-icons 1.3.2: the version here is the tag's, because it is what the archive URL takes. The pack's config.json records 1.3.2 at upstream.sets.radix-icons.current_version, so the first real sync stamps 0.0.17 there. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 318 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.radix-icons", + "name": "icon-sets-extras-radix-icons", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "0.0.17", diff --git a/src/internal/defaultconfig/config/icon-sets-extras.siemens-ix.json b/config/icon-sets-extras-siemens-ix.json similarity index 96% rename from src/internal/defaultconfig/config/icon-sets-extras.siemens-ix.json rename to config/icon-sets-extras-siemens-ix.json index b9ffb3f..a38d3db 100644 --- a/src/internal/defaultconfig/config/icon-sets-extras.siemens-ix.json +++ b/config/icon-sets-extras-siemens-ix.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. svg/*.svg, unchanged names. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 1,490 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.siemens-ix", + "name": "icon-sets-extras-siemens-ix", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "3.7.1", diff --git a/config/icon-sets-extras.svg-logos.json b/config/icon-sets-extras-svg-logos.json similarity index 97% rename from config/icon-sets-extras.svg-logos.json rename to config/icon-sets-extras-svg-logos.json index 3ba63ed..262763a 100644 --- a/config/icon-sets-extras.svg-logos.json +++ b/config/icon-sets-extras-svg-logos.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. logos/*.svg, slugged with dots hyphenated (lucene.net -> lucene-net, daisyUI -> daisyui). The logos depict trademarks. Upstream has no releases, so the version is a commit. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 2,068 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.svg-logos", + "name": "icon-sets-extras-svg-logos", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "22f03ffc4a652309d1fea4ade70f46e9e1d6602c", diff --git a/src/internal/defaultconfig/config/icon-sets-extras.tdesign.json b/config/icon-sets-extras-tdesign.json similarity index 96% rename from src/internal/defaultconfig/config/icon-sets-extras.tdesign.json rename to config/icon-sets-extras-tdesign.json index e543a0d..8c2cd62 100644 --- a/src/internal/defaultconfig/config/icon-sets-extras.tdesign.json +++ b/config/icon-sets-extras-tdesign.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. src/*.svg, unchanged names. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 2,358 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.tdesign", + "name": "icon-sets-extras-tdesign", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "0.4.8", diff --git a/config/packs.json b/config/packs.json index 459357a..f636b5c 100644 --- a/config/packs.json +++ b/config/packs.json @@ -6,26 +6,26 @@ "icon-sets-openmoji", "icon-sets-bootstrap", "icon-sets-carbon", - "icon-sets-extras.ant-design", - "icon-sets-extras.boxicons", - "icon-sets-extras.coolicons", - "icon-sets-extras.coreui", - "icon-sets-extras.devicon", - "icon-sets-extras.eva", - "icon-sets-extras.feather", - "icon-sets-extras.fluent-emoji", - "icon-sets-extras.game-icons", - "icon-sets-extras.garden", - "icon-sets-extras.health-icons", - "icon-sets-extras.iconpark", - "icon-sets-extras.mingcute", - "icon-sets-extras.noto-emoji", - "icon-sets-extras.pepicons", - "icon-sets-extras.pinhead", - "icon-sets-extras.radix-icons", - "icon-sets-extras.siemens-ix", - "icon-sets-extras.svg-logos", - "icon-sets-extras.tdesign", + "icon-sets-extras-ant-design", + "icon-sets-extras-boxicons", + "icon-sets-extras-coolicons", + "icon-sets-extras-coreui", + "icon-sets-extras-devicon", + "icon-sets-extras-eva", + "icon-sets-extras-feather", + "icon-sets-extras-fluent-emoji", + "icon-sets-extras-game-icons", + "icon-sets-extras-garden", + "icon-sets-extras-health-icons", + "icon-sets-extras-iconpark", + "icon-sets-extras-mingcute", + "icon-sets-extras-noto-emoji", + "icon-sets-extras-pepicons", + "icon-sets-extras-pinhead", + "icon-sets-extras-radix-icons", + "icon-sets-extras-siemens-ix", + "icon-sets-extras-svg-logos", + "icon-sets-extras-tdesign", "icon-sets-fluent", "icon-sets-font-awesome-free", "icon-sets-heroicons", diff --git a/config/schema/pack.schema.json b/config/schema/pack.schema.json index 4f7af70..4ef8183 100644 --- a/config/schema/pack.schema.json +++ b/config/schema/pack.schema.json @@ -17,7 +17,7 @@ "name": { "type": "string", "minLength": 1, - "description": "The pack slug, e.g. icon-sets-tabler." + "description": "The pack slug: lowercase letters a-z and digits in words joined by single hyphens, e.g. icon-sets-tabler or icon-sets-extras-feather. A dotted or capitalised name (icon-sets-extras.feather) is deprecated: it loads with a warning until 1.0.0." }, "pack": { "type": "string", diff --git a/src/internal/core/checker/archive_test.go b/src/internal/core/checker/archive_test.go index 34a3e7e..f55c6b7 100644 --- a/src/internal/core/checker/archive_test.go +++ b/src/internal/core/checker/archive_test.go @@ -83,7 +83,7 @@ func TestShippedArchiveConfigsNamePollableEndpoints(t *testing.T) { func TestCheckPackCarriesTheConfigName(t *testing.T) { c := &Checker{Fetch: stubFetcher{body: `{"version":"1.0.0"}`}} p := packWithVendored(t, "1.0.0") - p.Name = "icon-sets-extras.ant-design" + p.Name = "icon-sets-extras-ant-design" if got := c.CheckPack(t.Context(), p); got.Name != p.Name { t.Errorf("Name = %q, want %q", got.Name, p.Name) } diff --git a/src/internal/core/checker/checker.go b/src/internal/core/checker/checker.go index ce6e437..c7b5906 100644 --- a/src/internal/core/checker/checker.go +++ b/src/internal/core/checker/checker.go @@ -20,7 +20,7 @@ import ( type Result struct { Package string // Name is the config's slug. It differs from the pack's own name when - // several configs feed one pack (icon-sets-extras.), and is the only + // several configs feed one pack (icon-sets-extras-), and is the only // thing that tells those results apart. Name string Current string diff --git a/src/internal/core/config/config.go b/src/internal/core/config/config.go index 8b752cd..657e451 100644 --- a/src/internal/core/config/config.go +++ b/src/internal/core/config/config.go @@ -337,8 +337,15 @@ func PackFile(slug, configDir string) (string, error) { if configDir == "" { configDir = DefaultConfigDir() } + slug, err := canonicalName("pack", slug) + if err != nil { + return "", err + } path, err := findDoc(configDir, slug) if errors.Is(err, os.ErrNotExist) { + if old := findOldSpelling(configDir, slug); old != "" { + return old, nil + } if private := PrivateConfigDir(); private != "" { return "", fmt.Errorf("missing pack config: %s (nor in the private config dir %s)", filepath.Join(configDir, slug+".json"), private) @@ -425,6 +432,9 @@ func ParsePackBytes(path string, data []byte) (*PackConfig, error) { if len(pack.VersionKeys) == 0 { pack.VersionKeys = DefaultVersionKeys() } + if pack.Name, err = canonicalName(path, pack.Name); err != nil { + return nil, err + } pack.PackRoot = expandUser(pack.PackRoot) pack.File = path @@ -492,6 +502,11 @@ func ParseRegistryBytes(registryFile string, data []byte) (*PacksRegistry, error if slug == "" { return nil, fmt.Errorf("%s: packs[%d] is empty", registryFile, i) } + slug, err := canonicalName(fmt.Sprintf("%s: packs[%d]", registryFile, i), slug) + if err != nil { + return nil, err + } + registry.Packs[i] = slug if seen[slug] { return nil, fmt.Errorf("%s: %q is listed twice", registryFile, slug) } diff --git a/src/internal/core/config/schema/pack.schema.json b/src/internal/core/config/schema/pack.schema.json index 4f7af70..4ef8183 100644 --- a/src/internal/core/config/schema/pack.schema.json +++ b/src/internal/core/config/schema/pack.schema.json @@ -17,7 +17,7 @@ "name": { "type": "string", "minLength": 1, - "description": "The pack slug, e.g. icon-sets-tabler." + "description": "The pack slug: lowercase letters a-z and digits in words joined by single hyphens, e.g. icon-sets-tabler or icon-sets-extras-feather. A dotted or capitalised name (icon-sets-extras.feather) is deprecated: it loads with a warning until 1.0.0." }, "pack": { "type": "string", diff --git a/src/internal/core/config/slug.go b/src/internal/core/config/slug.go new file mode 100644 index 0000000..13adb3c --- /dev/null +++ b/src/internal/core/config/slug.go @@ -0,0 +1,85 @@ +package config + +import ( + "fmt" + "os" + "path/filepath" + "regexp" + "sort" + "strings" +) + +// slugRE is the one shape a pack name may take: lowercase letters and digits +// in words joined by single hyphens. A pack name is a file name, a URL path +// segment, a branch-name part and a key in run history, so it carries no dot, +// underscore, capital or space ("icon-sets-extras-ant-design", never +// "icon-sets-extras.ant-design"). +var slugRE = regexp.MustCompile(`^[a-z0-9]+(-[a-z0-9]+)*$`) + +// SlugRule is the rule in words, for messages. +const SlugRule = "a pack name is a lowercase slug: letters a-z and digits, in words joined by single hyphens" + +// IsSlug reports whether s is a pack slug. +func IsSlug(s string) bool { return len(s) <= 100 && slugRE.MatchString(s) } + +// CanonicalSlug returns the slug a name stands for. deprecated is true when +// name is an old spelling of a slug -- capitals, or words joined by dots, +// underscores or spaces, as the icon-sets-extras. configs were named +// until they became icon-sets-extras- -- and false when name is already +// a slug or has no slug spelling at all (then name is returned unchanged). +// +// Deprecated spellings: accepted, with a warning, until 1.0.0. +func CanonicalSlug(name string) (slug string, deprecated bool) { + if IsSlug(name) { + return name, false + } + s := strings.ToLower(name) + s = strings.NewReplacer(".", "-", "_", "-", " ", "-").Replace(s) + if IsSlug(s) { + return s, true + } + return name, false +} + +// Deprecated reports a deprecated spelling. A seam for tests; the CLI and the +// server print it on stderr. +var Deprecated = func(msg string) { fmt.Fprintln(os.Stderr, "warning: "+msg) } + +// canonicalName is CanonicalSlug for a name read from where: the slug, with a +// deprecation warning for an old spelling, or an error naming the rule. +func canonicalName(where, name string) (string, error) { + slug, deprecated := CanonicalSlug(name) + switch { + case deprecated: + Deprecated(fmt.Sprintf("%s: pack name %q is deprecated; use %q (%s; the old spelling stops working at 1.0.0)", + where, name, slug, SlugRule)) + return slug, nil + case !IsSlug(slug): + return "", fmt.Errorf("%s: pack name %q is not allowed: %s", where, name, SlugRule) + } + return slug, nil +} + +// findOldSpelling looks in the search directories for a config file whose +// name is a deprecated spelling of slug (icon-sets-extras.feather.json for +// icon-sets-extras-feather), so a user's own config keeps loading after the +// rename. +func findOldSpelling(configDir, slug string) string { + for _, dir := range searchDirs(configDir) { + var hits []string + for _, ext := range []string{".json", ".yaml", ".yml"} { + m, _ := filepath.Glob(filepath.Join(dir, "*"+ext)) + hits = append(hits, m...) + } + sort.Strings(hits) + for _, f := range hits { + base := strings.TrimSuffix(filepath.Base(f), filepath.Ext(f)) + if got, deprecated := CanonicalSlug(base); deprecated && got == slug { + Deprecated(fmt.Sprintf("%s: the file name is deprecated; rename it %s%s", + f, slug, filepath.Ext(f))) + return f + } + } + } + return "" +} diff --git a/src/internal/core/config/slug_test.go b/src/internal/core/config/slug_test.go new file mode 100644 index 0000000..93c3600 --- /dev/null +++ b/src/internal/core/config/slug_test.go @@ -0,0 +1,141 @@ +package config + +import ( + "encoding/json" + "os" + "path/filepath" + "strings" + "testing" +) + +func TestIsSlug(t *testing.T) { + for s, want := range map[string]bool{ + "icon-sets-flag": true, "icon-sets-extras-ant-design": true, "a1": true, + "icon-sets-extras.ant-design": false, "Icon-Sets": false, "a_b": false, + "": false, "-a": false, "a-": false, "a--b": false, "a b": false, "../x": false, + } { + if IsSlug(s) != want { + t.Errorf("IsSlug(%q) = %v, want %v", s, !want, want) + } + } +} + +func TestCanonicalSlug(t *testing.T) { + for in, want := range map[string]string{ + "icon-sets-extras.ant-design": "icon-sets-extras-ant-design", + "Icon-Sets-Extras.Feather": "icon-sets-extras-feather", + "icon_sets.x": "icon-sets-x", + } { + got, deprecated := CanonicalSlug(in) + if got != want || !deprecated { + t.Errorf("CanonicalSlug(%q) = %q, %v; want %q, true", in, got, deprecated, want) + } + } + if got, deprecated := CanonicalSlug("icon-sets-flag"); got != "icon-sets-flag" || deprecated { + t.Errorf("a slug is its own canonical form: %q %v", got, deprecated) + } + if _, deprecated := CanonicalSlug("../etc"); deprecated { + t.Error("a path is not a deprecated spelling of a slug") + } +} + +// Every name shipped in config/ -- each pack config's file name, its "name" +// and each registry entry -- is a lowercase slug. Counted, so an empty glob +// fails rather than passes. +func TestEveryShippedNameIsASlug(t *testing.T) { + dir := filepath.Join("..", "..", "..", "..", "config") + // Read the raw documents: the loaders accept a deprecated spelling and + // hand back the slug, which would hide one shipped by mistake. + var reg PacksRegistry + if err := json.Unmarshal(mustRead(t, filepath.Join(dir, "packs.json")), ®); err != nil { + t.Fatal(err) + } + for _, slug := range reg.Packs { + if !IsSlug(slug) { + t.Errorf("packs.json lists %q, which is not a slug", slug) + } + } + if len(reg.Packs) < 30 { + t.Fatalf("read %d registry entries, want at least 30", len(reg.Packs)) + } + files, _ := filepath.Glob(filepath.Join(dir, "*.json")) + n := 0 + for _, f := range files { + base := strings.TrimSuffix(filepath.Base(f), ".json") + if base == "packs" { + continue + } + n++ + if !IsSlug(base) { + t.Errorf("config file %s is not named by a slug", filepath.Base(f)) + } + var p struct{ Name string } + if err := json.Unmarshal(mustRead(t, f), &p); err != nil { + t.Errorf("%s: %v", f, err) + continue + } + if !IsSlug(p.Name) || p.Name != base { + t.Errorf("%s: name %q is not the slug %q", filepath.Base(f), p.Name, base) + } + } + if n != len(reg.Packs) { + t.Errorf("%d pack configs, %d registry entries", n, len(reg.Packs)) + } +} + +func mustRead(t *testing.T, p string) []byte { + t.Helper() + b, err := os.ReadFile(p) + if err != nil { + t.Fatal(err) + } + return b +} + +// The dotted names are deprecated, not removed: a registry entry, a pack's +// "name" and a --pack argument in the old spelling still resolve, to the +// canonical slug, with a warning. +func TestDeprecatedDottedNamesStillResolve(t *testing.T) { + var warned []string + old := Deprecated + Deprecated = func(msg string) { warned = append(warned, msg) } + t.Cleanup(func() { Deprecated = old }) + + dir := t.TempDir() + write := func(name, body string) { + if err := os.WriteFile(filepath.Join(dir, name), []byte(body), 0o644); err != nil { + t.Fatal(err) + } + } + write("packs.json", `{"packs":["icon-sets-extras.feather"]}`) + // A user's own config still in the old spelling, file name and all. + write("icon-sets-extras.feather.json", `{"name":"icon-sets-extras.feather","pack":"ichava/icon-sets-extras", + "pack_root":"/tmp/x","version_check_url":"https://registry.npmjs.org/feather-icons/latest", + "source":{"type":"npm","package":"feather-icons"}}`) + + reg, err := ParseRegistryBytes(filepath.Join(dir, "packs.json"), mustRead(t, filepath.Join(dir, "packs.json"))) + if err != nil || reg.Packs[0] != "icon-sets-extras-feather" { + t.Fatalf("registry: %+v %v", reg, err) + } + p, err := LoadPack("icon-sets-extras.feather", dir) + if err != nil { + t.Fatal(err) + } + if p.Name != "icon-sets-extras-feather" { + t.Errorf("name %q, want the canonical slug", p.Name) + } + if p2, err := LoadPack("icon-sets-extras-feather", dir); err != nil || p2.Name != p.Name { + t.Errorf("the canonical slug does not find the old-spelled file: %v", err) + } + if len(warned) == 0 || !strings.Contains(strings.Join(warned, "\n"), "icon-sets-extras-feather") { + t.Errorf("no deprecation warning naming the new slug: %q", warned) + } +} + +// A name that is not a slug and has no slug spelling is refused, naming the rule. +func TestANameThatIsNoSlugIsRefused(t *testing.T) { + _, err := ParseRegistryBytes("packs.json", []byte(`{"packs":["icon sets/../x"]}`)) + if err == nil || !strings.Contains(err.Error(), "lowercase") { + t.Fatalf("err = %v", err) + } +} diff --git a/src/internal/defaultconfig/config/icon-sets-extras.ant-design.json b/src/internal/defaultconfig/config/icon-sets-extras-ant-design.json similarity index 97% rename from src/internal/defaultconfig/config/icon-sets-extras.ant-design.json rename to src/internal/defaultconfig/config/icon-sets-extras-ant-design.json index 611055b..252b179 100644 --- a/src/internal/defaultconfig/config/icon-sets-extras.ant-design.json +++ b/src/internal/defaultconfig/config/icon-sets-extras-ant-design.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. inline-svg/{outlined,filled,twotone} flattened to -outlined/-filled/-twotone. The npm package ships no licence file (licence_missing): licenses/ant-design/ needs a source.md before the first real sync, or the sink removes the hand-supplied text. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 848 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.ant-design", + "name": "icon-sets-extras-ant-design", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "4.6.0", diff --git a/config/icon-sets-extras.boxicons.json b/src/internal/defaultconfig/config/icon-sets-extras-boxicons.json similarity index 97% rename from config/icon-sets-extras.boxicons.json rename to src/internal/defaultconfig/config/icon-sets-extras-boxicons.json index 2f21df8..307f4d2 100644 --- a/config/icon-sets-extras.boxicons.json +++ b/src/internal/defaultconfig/config/icon-sets-extras-boxicons.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. svg/regular, svg/solid and svg/logos merged; the bx-/bxs-/bxl- prefixes already keep names apart. The bxl- logos depict trademarks. The package offers CC-BY-4.0, OFL-1.1 or MIT; the LICENSE it ships, and the option taken, is MIT. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 1,634 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.boxicons", + "name": "icon-sets-extras-boxicons", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "2.1.4", diff --git a/config/icon-sets-extras.coolicons.json b/src/internal/defaultconfig/config/icon-sets-extras-coolicons.json similarity index 97% rename from config/icon-sets-extras.coolicons.json rename to src/internal/defaultconfig/config/icon-sets-extras-coolicons.json index 513c1b1..51e9268 100644 --- a/config/icon-sets-extras.coolicons.json +++ b/src/internal/defaultconfig/config/icon-sets-extras-coolicons.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. icons/svg/{line,fill}/regular flattened to -line/-fill. The other 13 style folders (bulk, duotone, duocolor; round and sharp corners) are the same drawings restyled and are not vendored. v5 is MIT; v4 was CC-BY-4.0. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 2,648 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.coolicons", + "name": "icon-sets-extras-coolicons", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "5.2.0", diff --git a/config/icon-sets-extras.coreui.json b/src/internal/defaultconfig/config/icon-sets-extras-coreui.json similarity index 97% rename from config/icon-sets-extras.coreui.json rename to src/internal/defaultconfig/config/icon-sets-extras-coreui.json index c65aa64..c9e5ef5 100644 --- a/config/icon-sets-extras.coreui.json +++ b/src/internal/defaultconfig/config/icon-sets-extras-coreui.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. svg/free/*.svg, unchanged names. Only the free set: the brand and flag SVGs are CC0 in the same LICENSE, but the brands are trademarks and the flags duplicate icon-sets-flag. CoreUI's LICENSE is its own summary (icons CC-BY-4.0, brands and flags CC0, code MIT) rather than the CC text, so it is pinned by SHA-256. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 562 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.coreui", + "name": "icon-sets-extras-coreui", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "3.1.0", diff --git a/config/icon-sets-extras.devicon.json b/src/internal/defaultconfig/config/icon-sets-extras-devicon.json similarity index 97% rename from config/icon-sets-extras.devicon.json rename to src/internal/defaultconfig/config/icon-sets-extras-devicon.json index 8e9eb3a..bdb5966 100644 --- a/config/icon-sets-extras.devicon.json +++ b/src/internal/defaultconfig/config/icon-sets-extras-devicon.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. icons//.svg flattened; upstream names already carry the tech and the style. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 2,120 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.devicon", + "name": "icon-sets-extras-devicon", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "2.18.0", diff --git a/src/internal/defaultconfig/config/icon-sets-extras.eva.json b/src/internal/defaultconfig/config/icon-sets-extras-eva.json similarity index 98% rename from src/internal/defaultconfig/config/icon-sets-extras.eva.json rename to src/internal/defaultconfig/config/icon-sets-extras-eva.json index aa1f83e..e11dc50 100644 --- a/src/internal/defaultconfig/config/icon-sets-extras.eva.json +++ b/src/internal/defaultconfig/config/icon-sets-extras-eva.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. fill/svg and outline/svg merged; upstream already names outline icons -outline. The sprites and font are left out. Unmaintained upstream (last push 2023). The npm package ships no licence file (licence_missing): licenses/eva/ needs a source.md before the first real sync. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 490 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.eva", + "name": "icon-sets-extras-eva", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "1.1.3", diff --git a/config/icon-sets-extras.feather.json b/src/internal/defaultconfig/config/icon-sets-extras-feather.json similarity index 97% rename from config/icon-sets-extras.feather.json rename to src/internal/defaultconfig/config/icon-sets-extras-feather.json index 3c518c9..60cb1ce 100644 --- a/config/icon-sets-extras.feather.json +++ b/src/internal/defaultconfig/config/icon-sets-extras-feather.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. dist/icons/*.svg, unchanged names. Lucide is its maintained successor. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 287 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.feather", + "name": "icon-sets-extras-feather", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "4.29.2", diff --git a/src/internal/defaultconfig/config/icon-sets-extras.fluent-emoji.json b/src/internal/defaultconfig/config/icon-sets-extras-fluent-emoji.json similarity index 97% rename from src/internal/defaultconfig/config/icon-sets-extras.fluent-emoji.json rename to src/internal/defaultconfig/config/icon-sets-extras-fluent-emoji.json index d53d3f5..80c9465 100644 --- a/src/internal/defaultconfig/config/icon-sets-extras.fluent-emoji.json +++ b/src/internal/defaultconfig/config/icon-sets-extras-fluent-emoji.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. assets//[/]{Flat,High Contrast}/.svg flattened and slugged. The Color style (3,145 files, 132 MB of gradients) is excluded by directory; the 3D PNGs are not SVGs. Upstream has no tags, so the version is a commit. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 4,740 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.fluent-emoji", + "name": "icon-sets-extras-fluent-emoji", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "1ffb34c752ecf5d402f04cfb4b392c77f57c54bc", diff --git a/src/internal/defaultconfig/config/icon-sets-extras.game-icons.json b/src/internal/defaultconfig/config/icon-sets-extras-game-icons.json similarity index 97% rename from src/internal/defaultconfig/config/icon-sets-extras.game-icons.json rename to src/internal/defaultconfig/config/icon-sets-extras-game-icons.json index e291b7d..3736748 100644 --- a/src/internal/defaultconfig/config/icon-sets-extras.game-icons.json +++ b/src/internal/defaultconfig/config/icon-sets-extras-game-icons.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. /.svg kept, one directory per contributor, so every icon stays attributable. badges/ and various-artists/ are excluded: license.txt does not name them, so no licence is stated for them. license.txt is the project's own CC-BY-3.0 statement rather than the CC text, so it is pinned by SHA-256. Upstream has no tags, so the version is a commit. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 4,178 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.game-icons", + "name": "icon-sets-extras-game-icons", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "82d948812bfe3f269ef8f731dcdb07b08160edc4", diff --git a/src/internal/defaultconfig/config/icon-sets-extras.garden.json b/src/internal/defaultconfig/config/icon-sets-extras-garden.json similarity index 97% rename from src/internal/defaultconfig/config/icon-sets-extras.garden.json rename to src/internal/defaultconfig/config/icon-sets-extras-garden.json index 7f2134d..9614325 100644 --- a/src/internal/defaultconfig/config/icon-sets-extras.garden.json +++ b/src/internal/defaultconfig/config/icon-sets-extras-garden.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. src/16 and src/12 flattened to -16/-12. 9.0.0 exists only as a pre-release; the stable 8.4.0 is pinned. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 932 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.garden", + "name": "icon-sets-extras-garden", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "8.4.0", diff --git a/src/internal/defaultconfig/config/icon-sets-extras.health-icons.json b/src/internal/defaultconfig/config/icon-sets-extras-health-icons.json similarity index 97% rename from src/internal/defaultconfig/config/icon-sets-extras.health-icons.json rename to src/internal/defaultconfig/config/icon-sets-extras-health-icons.json index d0107b8..e8eb9f8 100644 --- a/src/internal/defaultconfig/config/icon-sets-extras.health-icons.json +++ b/src/internal/defaultconfig/config/icon-sets-extras-health-icons.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. public/icons/svg/{outline,filled}//.svg flattened to -outline/-filled, the stem slugged before the suffix (`!.svg` is committed as `-filled.svg`). The 24px redraws are not vendored. Its LICENSE splits icons (CC0) from website code (MIT), so it is pinned by SHA-256. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 1,552 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.health-icons", + "name": "icon-sets-extras-health-icons", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "3.1.0", diff --git a/config/icon-sets-extras.iconpark.json b/src/internal/defaultconfig/config/icon-sets-extras-iconpark.json similarity index 97% rename from config/icon-sets-extras.iconpark.json rename to src/internal/defaultconfig/config/icon-sets-extras-iconpark.json index 7d9d917..169015b 100644 --- a/config/icon-sets-extras.iconpark.json +++ b/src/internal/defaultconfig/config/icon-sets-extras-iconpark.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. source//*.svg flattened; names are unique across categories. Upstream is archived; 1.4.2 is final. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 2,658 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.iconpark", + "name": "icon-sets-extras-iconpark", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "1.4.2", diff --git a/config/icon-sets-extras.mingcute.json b/src/internal/defaultconfig/config/icon-sets-extras-mingcute.json similarity index 97% rename from config/icon-sets-extras.mingcute.json rename to src/internal/defaultconfig/config/icon-sets-extras-mingcute.json index d0bde8e..c2e0dc3 100644 --- a/config/icon-sets-extras.mingcute.json +++ b/src/internal/defaultconfig/config/icon-sets-extras-mingcute.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. assets/stroke/core/{regular,filled}//.svg flattened to -regular/-filled. The npm package ships JavaScript only, so the source is the tagged archive. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 4,526 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.mingcute", + "name": "icon-sets-extras-mingcute", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "4.0.0", diff --git a/src/internal/defaultconfig/config/icon-sets-extras.noto-emoji.json b/src/internal/defaultconfig/config/icon-sets-extras-noto-emoji.json similarity index 97% rename from src/internal/defaultconfig/config/icon-sets-extras.noto-emoji.json rename to src/internal/defaultconfig/config/icon-sets-extras-noto-emoji.json index 731cb00..10c0191 100644 --- a/src/internal/defaultconfig/config/icon-sets-extras.noto-emoji.json +++ b/src/internal/defaultconfig/config/icon-sets-extras-noto-emoji.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. 2D/svg/emoji_u.svg, slugged (emoji-u1f600). The root LICENSE is the OFL and covers the fonts; 2D/svg/LICENSE is the Apache-2.0 notice that governs the SVGs, so the licence is read from there (licence_from) and pinned by SHA-256. 170 SVGs declare Adobe Illustrator entities in an internal DTD, which the sanitiser cannot parse, so they cannot be checked and are dropped (drop_unparsable). The tagged archive is 1.2 GB, almost all of it 3D PNGs, so this source raises the download cap to 2 GiB. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 3,580 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.noto-emoji", + "name": "icon-sets-extras-noto-emoji", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "2026-09-24-unicode18_0", diff --git a/src/internal/defaultconfig/config/icon-sets-extras.pepicons.json b/src/internal/defaultconfig/config/icon-sets-extras-pepicons.json similarity index 97% rename from src/internal/defaultconfig/config/icon-sets-extras.pepicons.json rename to src/internal/defaultconfig/config/icon-sets-extras-pepicons.json index 24c65ee..657bee3 100644 --- a/src/internal/defaultconfig/config/icon-sets-extras.pepicons.json +++ b/src/internal/defaultconfig/config/icon-sets-extras-pepicons.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. svg/{pop,print,pencil} flattened to -pop/-print/-pencil. CC-BY-4.0: attribution is required and is carried in ATTRIBUTION.md. The npm package ships no licence file (licence_missing): licenses/pepicons/ needs a source.md before the first real sync. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 3,825 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.pepicons", + "name": "icon-sets-extras-pepicons", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "3.1.6", diff --git a/src/internal/defaultconfig/config/icon-sets-extras.pinhead.json b/src/internal/defaultconfig/config/icon-sets-extras-pinhead.json similarity index 97% rename from src/internal/defaultconfig/config/icon-sets-extras.pinhead.json rename to src/internal/defaultconfig/config/icon-sets-extras-pinhead.json index 4ec88ad..6330a40 100644 --- a/src/internal/defaultconfig/config/icon-sets-extras.pinhead.json +++ b/src/internal/defaultconfig/config/icon-sets-extras-pinhead.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. dist/icons/*.svg, underscores slugged to hyphens. Pinhead incorporates icons from Temaki, Maki, OpenStreetMap Carto, Osmic, Health Icons and others; its README lists every source as CC0 or public domain. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 2,747 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.pinhead", + "name": "icon-sets-extras-pinhead", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "16.26.0", diff --git a/src/internal/defaultconfig/config/icon-sets-extras.radix-icons.json b/src/internal/defaultconfig/config/icon-sets-extras-radix-icons.json similarity index 97% rename from src/internal/defaultconfig/config/icon-sets-extras.radix-icons.json rename to src/internal/defaultconfig/config/icon-sets-extras-radix-icons.json index 6c0242f..b9fb624 100644 --- a/src/internal/defaultconfig/config/icon-sets-extras.radix-icons.json +++ b/src/internal/defaultconfig/config/icon-sets-extras-radix-icons.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. packages/radix-icons/icons/*.svg, unchanged names. The archive tag is website@0.0.17, which holds packages/radix-icons 1.3.2: the version here is the tag's, because it is what the archive URL takes. The pack's config.json records 1.3.2 at upstream.sets.radix-icons.current_version, so the first real sync stamps 0.0.17 there. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 318 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.radix-icons", + "name": "icon-sets-extras-radix-icons", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "0.0.17", diff --git a/config/icon-sets-extras.siemens-ix.json b/src/internal/defaultconfig/config/icon-sets-extras-siemens-ix.json similarity index 96% rename from config/icon-sets-extras.siemens-ix.json rename to src/internal/defaultconfig/config/icon-sets-extras-siemens-ix.json index b9ffb3f..a38d3db 100644 --- a/config/icon-sets-extras.siemens-ix.json +++ b/src/internal/defaultconfig/config/icon-sets-extras-siemens-ix.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. svg/*.svg, unchanged names. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 1,490 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.siemens-ix", + "name": "icon-sets-extras-siemens-ix", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "3.7.1", diff --git a/src/internal/defaultconfig/config/icon-sets-extras.svg-logos.json b/src/internal/defaultconfig/config/icon-sets-extras-svg-logos.json similarity index 97% rename from src/internal/defaultconfig/config/icon-sets-extras.svg-logos.json rename to src/internal/defaultconfig/config/icon-sets-extras-svg-logos.json index 3ba63ed..262763a 100644 --- a/src/internal/defaultconfig/config/icon-sets-extras.svg-logos.json +++ b/src/internal/defaultconfig/config/icon-sets-extras-svg-logos.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. logos/*.svg, slugged with dots hyphenated (lucene.net -> lucene-net, daisyUI -> daisyui). The logos depict trademarks. Upstream has no releases, so the version is a commit. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 2,068 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.svg-logos", + "name": "icon-sets-extras-svg-logos", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "22f03ffc4a652309d1fea4ade70f46e9e1d6602c", diff --git a/config/icon-sets-extras.tdesign.json b/src/internal/defaultconfig/config/icon-sets-extras-tdesign.json similarity index 96% rename from config/icon-sets-extras.tdesign.json rename to src/internal/defaultconfig/config/icon-sets-extras-tdesign.json index e543a0d..8c2cd62 100644 --- a/config/icon-sets-extras.tdesign.json +++ b/src/internal/defaultconfig/config/icon-sets-extras-tdesign.json @@ -1,6 +1,6 @@ { "_note": "One of the 20 sets of ichava/icon-sets-extras, each refreshed by its own config into files// and licenses//, with its version recorded at upstream.sets..current_version in the pack's config.json. src/*.svg, unchanged names. Reproduces the committed pack byte for byte: a dry run at the pinned version against the local checkout on 2026-11-04 wrote 2,358 SVGs with 0 added, removed or changed.", - "name": "icon-sets-extras.tdesign", + "name": "icon-sets-extras-tdesign", "pack": "ichava/icon-sets-extras", "pack_root": "/work/icon-sets-extras", "current_version": "0.4.8", diff --git a/src/internal/defaultconfig/config/packs.json b/src/internal/defaultconfig/config/packs.json index 459357a..f636b5c 100644 --- a/src/internal/defaultconfig/config/packs.json +++ b/src/internal/defaultconfig/config/packs.json @@ -6,26 +6,26 @@ "icon-sets-openmoji", "icon-sets-bootstrap", "icon-sets-carbon", - "icon-sets-extras.ant-design", - "icon-sets-extras.boxicons", - "icon-sets-extras.coolicons", - "icon-sets-extras.coreui", - "icon-sets-extras.devicon", - "icon-sets-extras.eva", - "icon-sets-extras.feather", - "icon-sets-extras.fluent-emoji", - "icon-sets-extras.game-icons", - "icon-sets-extras.garden", - "icon-sets-extras.health-icons", - "icon-sets-extras.iconpark", - "icon-sets-extras.mingcute", - "icon-sets-extras.noto-emoji", - "icon-sets-extras.pepicons", - "icon-sets-extras.pinhead", - "icon-sets-extras.radix-icons", - "icon-sets-extras.siemens-ix", - "icon-sets-extras.svg-logos", - "icon-sets-extras.tdesign", + "icon-sets-extras-ant-design", + "icon-sets-extras-boxicons", + "icon-sets-extras-coolicons", + "icon-sets-extras-coreui", + "icon-sets-extras-devicon", + "icon-sets-extras-eva", + "icon-sets-extras-feather", + "icon-sets-extras-fluent-emoji", + "icon-sets-extras-game-icons", + "icon-sets-extras-garden", + "icon-sets-extras-health-icons", + "icon-sets-extras-iconpark", + "icon-sets-extras-mingcute", + "icon-sets-extras-noto-emoji", + "icon-sets-extras-pepicons", + "icon-sets-extras-pinhead", + "icon-sets-extras-radix-icons", + "icon-sets-extras-siemens-ix", + "icon-sets-extras-svg-logos", + "icon-sets-extras-tdesign", "icon-sets-fluent", "icon-sets-font-awesome-free", "icon-sets-heroicons", diff --git a/src/internal/defaultconfig/config/schema/pack.schema.json b/src/internal/defaultconfig/config/schema/pack.schema.json index 4f7af70..4ef8183 100644 --- a/src/internal/defaultconfig/config/schema/pack.schema.json +++ b/src/internal/defaultconfig/config/schema/pack.schema.json @@ -17,7 +17,7 @@ "name": { "type": "string", "minLength": 1, - "description": "The pack slug, e.g. icon-sets-tabler." + "description": "The pack slug: lowercase letters a-z and digits in words joined by single hyphens, e.g. icon-sets-tabler or icon-sets-extras-feather. A dotted or capitalised name (icon-sets-extras.feather) is deprecated: it loads with a warning until 1.0.0." }, "pack": { "type": "string", diff --git a/src/internal/ui/ui.go b/src/internal/ui/ui.go index 1d0dda8..82e1698 100644 --- a/src/internal/ui/ui.go +++ b/src/internal/ui/ui.go @@ -245,10 +245,11 @@ func CheckRows(results []checker.Result) []CheckRow { } // checkLabel names a result's row: the pack, plus the set when the result -// came from one of several configs feeding that pack ("."). +// came from one of several configs feeding that pack ("-": +// a config whose name is the pack's slug plus a suffix). func checkLabel(r checker.Result) string { slug := r.Package[strings.LastIndex(r.Package, "/")+1:] - if set, ok := strings.CutPrefix(r.Name, slug+"."); ok && set != "" { + if set, ok := strings.CutPrefix(r.Name, slug+"-"); ok && set != "" { return r.Package + " (" + set + ")" } return r.Package diff --git a/src/internal/ui/ui_test.go b/src/internal/ui/ui_test.go index 8491cb6..d94a8ee 100644 --- a/src/internal/ui/ui_test.go +++ b/src/internal/ui/ui_test.go @@ -155,7 +155,7 @@ func TestGlyphSetsCoverTheSameKeys(t *testing.T) { // with one config keeps its bare name. func TestCheckRowsNameTheSetOfASharedPack(t *testing.T) { rows := CheckRows([]checker.Result{ - {Package: "ichava/icon-sets-extras", Name: "icon-sets-extras.ant-design", Latest: "1"}, + {Package: "ichava/icon-sets-extras", Name: "icon-sets-extras-ant-design", Latest: "1"}, {Package: "ichava/icon-sets-tabler", Name: "icon-sets-tabler", Latest: "1"}, {Package: "ichava/icon-sets-x", Latest: "1"}, }) diff --git a/src/internal/web/handle_pack.go b/src/internal/web/handle_pack.go index 7a4004f..b8308ef 100644 --- a/src/internal/web/handle_pack.go +++ b/src/internal/web/handle_pack.go @@ -82,6 +82,20 @@ func (s *Server) handlePack(w http.ResponseWriter, r *http.Request) { func (s *Server) loadPack(w http.ResponseWriter, r *http.Request) (*config.PackConfig, bool) { slug := r.PathValue("slug") + // A deprecated spelling (icon-sets-extras.feather) still reaches its pack: + // a page is sent to the canonical URL, so bookmarks and old links work and + // the address bar shows the slug; a form post is served as the slug. + if canon, deprecated := config.CanonicalSlug(slug); deprecated && validSlug(slug) { + if r.Method == http.MethodGet || r.Method == http.MethodHead { + to := strings.Replace(r.URL.Path, "/"+slug, "/"+canon, 1) + if r.URL.RawQuery != "" { + to += "?" + r.URL.RawQuery + } + http.Redirect(w, r, to, http.StatusMovedPermanently) + return nil, false + } + slug = canon + } if !validSlug(slug) { s.renderError(w, r, http.StatusNotFound, "No such pack", "There is no registered pack by that name.") return nil, false @@ -94,12 +108,12 @@ func (s *Server) loadPack(w http.ResponseWriter, r *http.Request) (*config.PackC return p, true } -// validSlug keeps a path value to the shape pack slugs have, so it can never -// name a file outside the config directory: lowercase letters, digits and -// hyphens, in segments joined by single dots ("icon-sets-extras.game-icons", -// a set config of a shared pack). No segment is empty, so ".", ".." and a -// leading or trailing dot are refused. Until R4 the dot was refused outright, -// and every set config's page and actions answered 404. +// validSlug keeps a path value to a shape that can never name a file outside +// the config directory: lowercase letters, digits and hyphens, in segments +// joined by single dots. No segment is empty, so ".", ".." and a leading or +// trailing dot are refused. A pack slug itself has no dot (config.IsSlug); the +// dot is admitted only so the deprecated "icon-sets-extras." spelling of +// a set config reaches loadPack, which redirects it to the slug. func validSlug(s string) bool { if s == "" || len(s) > 100 { return false diff --git a/src/internal/web/runs_test.go b/src/internal/web/runs_test.go index 63e6f92..7d64967 100644 --- a/src/internal/web/runs_test.go +++ b/src/internal/web/runs_test.go @@ -315,7 +315,7 @@ func TestPackPage(t *testing.T) { func TestValidSlug(t *testing.T) { for slug, want := range map[string]bool{ "icon-sets-flag": true, "a1": true, - // A set config of a shared pack is "." (R4). + // The deprecated "." spelling still passes, to be redirected. "icon-sets-extras.game-icons": true, "a.b": true, "": false, "../etc": false, "Icon": false, "a/b": false, strings.Repeat("a", 101): false, ".": false, "..": false, ".a": false, "a.": false, "a..b": false, @@ -327,8 +327,8 @@ func TestValidSlug(t *testing.T) { } // R4: validSlug refused the dot, so the pages and actions of all twenty -// icon-sets-extras. configs answered 404 "No such pack" from links the -// dashboard itself rendered. Every shipped config name must pass. Counted, so +// set configs (then icon-sets-extras., now icon-sets-extras-) +// answered 404 "No such pack" from links the dashboard itself rendered. Every shipped config name must pass. Counted, so // an empty glob fails. func TestEveryShippedPackNameIsAValidSlug(t *testing.T) { files, err := filepath.Glob(filepath.Join("..", "..", "..", "config", "*.json")) @@ -350,3 +350,13 @@ func TestEveryShippedPackNameIsAValidSlug(t *testing.T) { t.Fatalf("inspected %d shipped configs, want at least 30", n) } } + +// An old link to a set config's page, in the deprecated dotted spelling, is +// sent to the slug's page rather than answering 404. +func TestDeprecatedDottedPackURLRedirectsToTheSlug(t *testing.T) { + s, _ := newTestServer(t) + rec := signIn(t, s).get("/packs/icon-sets-tabler.x?y=1") + if rec.Code != http.StatusMovedPermanently || rec.Header().Get("Location") != "/packs/icon-sets-tabler-x?y=1" { + t.Fatalf("got %d %q", rec.Code, rec.Header().Get("Location")) + } +} From 9085e42bce5201b9a5a9900ec960f157ac2440d5 Mon Sep 17 00:00:00 2001 From: Imani Manyara Date: Wed, 11 Nov 2026 10:26:51 -0500 Subject: [PATCH 2/2] Refuse non-slug pack names instead of translating them The owner asked for the old names to be removed. A dotted, capitalised, underscore- or space-joined name in --pack, a registry or a config's name is now refused with the rule and the slug to use, and /packs/ answers 404. The aliasing (CanonicalSlug, the deprecation warning, the old-file-name lookup, the redirect) is gone; none of it ever shipped. pack.schema.json carries the slug pattern on name so editors flag a bad name as it is typed; TestSchemaSlugPatternMatchesIsSlug keeps it and the loader on one pattern (proven red by widening the schema's). The rule is written up in docs/configuration.md "Naming packs" and CONTRIBUTING.md. --- CHANGELOG.md | 2 +- CONTRIBUTING.md | 4 + config/schema/pack.schema.json | 5 +- docs/configuration.md | 31 ++++++- src/internal/core/config/config.go | 23 ++--- .../core/config/schema/pack.schema.json | 5 +- src/internal/core/config/slug.go | 82 ++++------------- src/internal/core/config/slug_test.go | 91 +++++++++---------- .../config/schema/pack.schema.json | 5 +- src/internal/web/handle_pack.go | 39 +------- src/internal/web/runs_test.go | 13 ++- 11 files changed, 123 insertions(+), 177 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d27de88..25ed1d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ All notable changes to `ichava/icon-sets-sync` (formerly `ichava/maintainer-tool ### Changed -- **Pack names are lowercase slugs, and the 20 `icon-sets-extras` set configs are renamed to match.** `icon-sets-extras.` (for example `icon-sets-extras.ant-design`) is now `icon-sets-extras-`, in the config file names, their `name`, `packs.json` and the embedded copy. A name is letters a-z and digits in words joined by single hyphens (`config.IsSlug`), and `TestEveryShippedNameIsASlug` reads the raw files and fails on anything else. The old spellings are deprecated, not removed: a dotted, capitalised or underscore-joined name in `--pack`, a registry, a config's `name` or its file name loads as the slug with a warning, and `/packs/` redirects to the slug's page, until 1.0.0. A name with no slug spelling is refused, naming the rule. The check table still labels a set config's row with its set. +- **Pack names are lowercase slugs, and the 20 `icon-sets-extras` set configs are renamed to match** (breaking). `icon-sets-extras.` (for example `icon-sets-extras.ant-design`) is now `icon-sets-extras-`, in the config file names, their `name`, `packs.json` and the embedded copy. A name is letters a-z and digits in words joined by single hyphens (`config.IsSlug`, and the same `pattern` on `name` in `pack.schema.json`). The old names are not kept: a dotted, capitalised, underscore- or space-joined name in `--pack`, a registry or a config's `name` is refused with the rule and the slug to use, and `/packs/` answers 404. `TestEveryShippedNameIsASlug` reads the raw files and fails on any shipped name that is not a slug; `TestSchemaSlugPatternMatchesIsSlug` keeps the schema and the loader on one pattern. The rule is in docs/configuration.md, "Naming packs", and CONTRIBUTING.md. The check table still labels a set config's row with its set. - **The emoji pack is `icon-sets-twemoji`, synced by the `twemoji-sets` recipe** (owner, 2026-11-05: forward only, no aliases). The pack was renamed on GitHub and ships Twemoji only, so its config is `config/icon-sets-twemoji.json` (and the embedded copy), registered in `packs.json` under that name, with `pack` `ichava/icon-sets-twemoji` and `pack_root` `/work/icon-sets-twemoji`. The recipe `emoji-sets` is now `twemoji-sets` (`RecipeTwemojiSets`, the schema enum), and its pipelines are `twemoji-sets:twemoji@` and `twemoji-sets:commit`; the OpenMoji pipelines, which borrowed the old prefix, are named for their own recipe, `openmoji-sets:@`. `make build-emoji` is `make build-twemoji`. Nothing reads the old pack name, recipe name or target. The frozen lxml oracle's sample paths follow the files to where they now live (Twemoji under `icon-sets-twemoji/`, OpenMoji under `icon-sets-openmoji/`, same bytes), so the differential compares them again: 726 of 1,238 present. The `emoji.unicode_version` setting and `ICHAVA_EMOJI_UNICODE_VERSION` keep their names: both recipes read them, so they name emoji, not the pack. - **The Composer launcher downloads a release binary only on opt-in** (`ICHAVA_ICON_SETS_SYNC_DOWNLOAD=1`). Without it, and without `ICHAVA_ICON_SETS_SYNC_BIN`, it stops and says how to build from source, so cutting a release can never switch a download channel on by itself (G-06). - **The web-asset vendor fetches through `httpx`**, under the upstream allowlist, the https-only redirect guard and the size caps, and `internal/tabler` is `internal/webvendor` (G-03). `orDash`, `orDefault` and `itoa` are written once (G-04). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9e4cc58..d7c442b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -42,6 +42,10 @@ there is how this tool spent weeks re-opening a pull request it had already open - No em-dashes in shipped docs or code comments. - Table-driven tests for anything new, and no test that needs the network or a listening socket: use the `Runner`, `Fetcher` and `Transport` seams. +- **Pack names are lowercase slugs**: `a-z` and digits in words joined by single hyphens, the same + string as the config file name and the `packs.json` entry (`icon-sets-extras-feather`, never + `icon-sets-extras.feather`). The loader refuses anything else and a test fails on a shipped one; + see [Naming packs](docs/configuration.md#naming-packs). - The pack config schema is `config/schema/pack.schema.json`; the binary embeds a copy at `src/internal/core/config/schema/`, and a test fails until the two are identical. A new setting goes in `src/internal/core/settings` and in the settings table in `docs/configuration.md`, which a diff --git a/config/schema/pack.schema.json b/config/schema/pack.schema.json index 4ef8183..e066116 100644 --- a/config/schema/pack.schema.json +++ b/config/schema/pack.schema.json @@ -16,8 +16,9 @@ }, "name": { "type": "string", - "minLength": 1, - "description": "The pack slug: lowercase letters a-z and digits in words joined by single hyphens, e.g. icon-sets-tabler or icon-sets-extras-feather. A dotted or capitalised name (icon-sets-extras.feather) is deprecated: it loads with a warning until 1.0.0." + "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$", + "maxLength": 100, + "description": "The pack slug, and the config's file name without .json: lowercase letters a-z and digits in words joined by single hyphens, e.g. icon-sets-tabler or icon-sets-extras-feather. No dots, underscores, capitals or spaces." }, "pack": { "type": "string", diff --git a/docs/configuration.md b/docs/configuration.md index 62e722b..5b27ac9 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -38,6 +38,31 @@ config (`"recipe": "manifest-pack"` for one pipeline per set in its set manifest Nothing describing a private pack is committed to this repository; a test fails on any tracked file that names a private pack's paths or config files. +## Naming packs + +A pack name is a **lowercase slug**: letters `a-z` and digits, in words joined by single hyphens +(`^[a-z0-9]+(-[a-z0-9]+)*$`, at most 100 characters). The same string is the config's `name`, its +file name (`config/.json`), its entry in `packs.json` and the value of `--pack`, and it ends +up in URLs (`/packs/`), branch names and run history, so it has no dots, underscores, +capitals or spaces. + +| Right | Wrong | +|---|---| +| `icon-sets-tabler` | `Icon-Sets-Tabler`, `icon_sets_tabler` | +| `icon-sets-extras-feather` (one config per set of a shared pack: `-`) | `icon-sets-extras.feather` | + +It is enforced, not advised: + +- the loader refuses any other name in `packs.json`, a config's `name` or `--pack`, states the + rule, and names the slug to use when there is one; +- `config/schema/pack.schema.json` carries the pattern, so an editor that reads `$schema` marks a + bad name as you type; +- `TestEveryShippedNameIsASlug` fails on any shipped config, file name or registry entry that is + not a slug. + +The dotted `icon-sets-extras.` names were renamed `icon-sets-extras-` (icon-sets-sync#104) +and are no longer accepted. + ## A pack config ```json @@ -73,7 +98,7 @@ turning it into `"16"`. | Key | Meaning | |---|---| -| `name` | pack slug; must match the filename and the registry entry | +| `name` | pack slug; must match the filename and the registry entry. A lowercase slug: see [Naming packs](#naming-packs) | | `pack` | Composer package name, e.g. `ichava/icon-sets-tabler` | | `pack_root` | the pack repo: absolute, `~`-prefixed, or relative to the `workspace` setting | | `version_check_url` | the URL polled to discover the latest upstream version | @@ -569,7 +594,9 @@ into the pack repo, before the `git-branch` sink commits. ## Adding a pack -1. Write `config/.json` (or `.yaml`) describing the upstream and the sinks. +1. Pick the slug: lowercase, words joined by hyphens, `-` for one set of a shared pack + ([Naming packs](#naming-packs)). Write `config/.json` (or `.yaml`) with that slug as its + `name`, describing the upstream and the sinks. 2. Add the slug to `config/packs.json`. 3. `icon-sets-sync config validate`, then `icon-sets-sync check --pack=` to confirm the upstream poll resolves. diff --git a/src/internal/core/config/config.go b/src/internal/core/config/config.go index 657e451..36ca2f2 100644 --- a/src/internal/core/config/config.go +++ b/src/internal/core/config/config.go @@ -337,15 +337,11 @@ func PackFile(slug, configDir string) (string, error) { if configDir == "" { configDir = DefaultConfigDir() } - slug, err := canonicalName("pack", slug) - if err != nil { + if err := checkName("pack", slug); err != nil { return "", err } path, err := findDoc(configDir, slug) if errors.Is(err, os.ErrNotExist) { - if old := findOldSpelling(configDir, slug); old != "" { - return old, nil - } if private := PrivateConfigDir(); private != "" { return "", fmt.Errorf("missing pack config: %s (nor in the private config dir %s)", filepath.Join(configDir, slug+".json"), private) @@ -395,6 +391,16 @@ func ParsePackBytes(path string, data []byte) (*PackConfig, error) { if err != nil { return nil, err } + // The name is checked before the schema, so a dotted or capitalised name + // gets the rule in words and the slug to use, not a bare pattern mismatch. + var named struct { + Name *string `json:"name"` + } + if json.Unmarshal(canonical, &named) == nil && named.Name != nil { + if err := checkName(path, *named.Name); err != nil { + return nil, err + } + } if err := ValidatePackDocument(canonical); err != nil { return nil, fmt.Errorf("%s: %w", path, err) } @@ -432,9 +438,6 @@ func ParsePackBytes(path string, data []byte) (*PackConfig, error) { if len(pack.VersionKeys) == 0 { pack.VersionKeys = DefaultVersionKeys() } - if pack.Name, err = canonicalName(path, pack.Name); err != nil { - return nil, err - } pack.PackRoot = expandUser(pack.PackRoot) pack.File = path @@ -502,11 +505,9 @@ func ParseRegistryBytes(registryFile string, data []byte) (*PacksRegistry, error if slug == "" { return nil, fmt.Errorf("%s: packs[%d] is empty", registryFile, i) } - slug, err := canonicalName(fmt.Sprintf("%s: packs[%d]", registryFile, i), slug) - if err != nil { + if err := checkName(fmt.Sprintf("%s: packs[%d]", registryFile, i), slug); err != nil { return nil, err } - registry.Packs[i] = slug if seen[slug] { return nil, fmt.Errorf("%s: %q is listed twice", registryFile, slug) } diff --git a/src/internal/core/config/schema/pack.schema.json b/src/internal/core/config/schema/pack.schema.json index 4ef8183..e066116 100644 --- a/src/internal/core/config/schema/pack.schema.json +++ b/src/internal/core/config/schema/pack.schema.json @@ -16,8 +16,9 @@ }, "name": { "type": "string", - "minLength": 1, - "description": "The pack slug: lowercase letters a-z and digits in words joined by single hyphens, e.g. icon-sets-tabler or icon-sets-extras-feather. A dotted or capitalised name (icon-sets-extras.feather) is deprecated: it loads with a warning until 1.0.0." + "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$", + "maxLength": 100, + "description": "The pack slug, and the config's file name without .json: lowercase letters a-z and digits in words joined by single hyphens, e.g. icon-sets-tabler or icon-sets-extras-feather. No dots, underscores, capitals or spaces." }, "pack": { "type": "string", diff --git a/src/internal/core/config/slug.go b/src/internal/core/config/slug.go index 13adb3c..05a262f 100644 --- a/src/internal/core/config/slug.go +++ b/src/internal/core/config/slug.go @@ -2,19 +2,19 @@ package config import ( "fmt" - "os" - "path/filepath" "regexp" - "sort" "strings" ) -// slugRE is the one shape a pack name may take: lowercase letters and digits -// in words joined by single hyphens. A pack name is a file name, a URL path -// segment, a branch-name part and a key in run history, so it carries no dot, -// underscore, capital or space ("icon-sets-extras-ant-design", never -// "icon-sets-extras.ant-design"). -var slugRE = regexp.MustCompile(`^[a-z0-9]+(-[a-z0-9]+)*$`) +// SlugPattern is the one shape a pack name may take: lowercase letters and +// digits in words joined by single hyphens. A pack name is a file name, a URL +// path segment, a branch-name part and a key in run history, so it carries no +// dot, underscore, capital or space ("icon-sets-extras-ant-design", never +// "icon-sets-extras.ant-design"). config/schema/pack.schema.json carries the +// same pattern for editors; TestSchemaSlugPatternMatchesIsSlug keeps them one. +const SlugPattern = `^[a-z0-9]+(-[a-z0-9]+)*$` + +var slugRE = regexp.MustCompile(SlugPattern) // SlugRule is the rule in words, for messages. const SlugRule = "a pack name is a lowercase slug: letters a-z and digits, in words joined by single hyphens" @@ -22,64 +22,16 @@ const SlugRule = "a pack name is a lowercase slug: letters a-z and digits, in wo // IsSlug reports whether s is a pack slug. func IsSlug(s string) bool { return len(s) <= 100 && slugRE.MatchString(s) } -// CanonicalSlug returns the slug a name stands for. deprecated is true when -// name is an old spelling of a slug -- capitals, or words joined by dots, -// underscores or spaces, as the icon-sets-extras. configs were named -// until they became icon-sets-extras- -- and false when name is already -// a slug or has no slug spelling at all (then name is returned unchanged). -// -// Deprecated spellings: accepted, with a warning, until 1.0.0. -func CanonicalSlug(name string) (slug string, deprecated bool) { +// checkName refuses a name that is not a slug, suggesting the slug it was +// probably meant to be. +func checkName(where, name string) error { if IsSlug(name) { - return name, false + return nil } - s := strings.ToLower(name) - s = strings.NewReplacer(".", "-", "_", "-", " ", "-").Replace(s) + msg := fmt.Sprintf("%s: pack name %q is not allowed: %s", where, name, SlugRule) + s := strings.NewReplacer(".", "-", "_", "-", " ", "-").Replace(strings.ToLower(name)) if IsSlug(s) { - return s, true - } - return name, false -} - -// Deprecated reports a deprecated spelling. A seam for tests; the CLI and the -// server print it on stderr. -var Deprecated = func(msg string) { fmt.Fprintln(os.Stderr, "warning: "+msg) } - -// canonicalName is CanonicalSlug for a name read from where: the slug, with a -// deprecation warning for an old spelling, or an error naming the rule. -func canonicalName(where, name string) (string, error) { - slug, deprecated := CanonicalSlug(name) - switch { - case deprecated: - Deprecated(fmt.Sprintf("%s: pack name %q is deprecated; use %q (%s; the old spelling stops working at 1.0.0)", - where, name, slug, SlugRule)) - return slug, nil - case !IsSlug(slug): - return "", fmt.Errorf("%s: pack name %q is not allowed: %s", where, name, SlugRule) - } - return slug, nil -} - -// findOldSpelling looks in the search directories for a config file whose -// name is a deprecated spelling of slug (icon-sets-extras.feather.json for -// icon-sets-extras-feather), so a user's own config keeps loading after the -// rename. -func findOldSpelling(configDir, slug string) string { - for _, dir := range searchDirs(configDir) { - var hits []string - for _, ext := range []string{".json", ".yaml", ".yml"} { - m, _ := filepath.Glob(filepath.Join(dir, "*"+ext)) - hits = append(hits, m...) - } - sort.Strings(hits) - for _, f := range hits { - base := strings.TrimSuffix(filepath.Base(f), filepath.Ext(f)) - if got, deprecated := CanonicalSlug(base); deprecated && got == slug { - Deprecated(fmt.Sprintf("%s: the file name is deprecated; rename it %s%s", - f, slug, filepath.Ext(f))) - return f - } - } + msg += fmt.Sprintf(" (use %q, and name its file %s.json)", s, s) } - return "" + return fmt.Errorf("%s", msg) } diff --git a/src/internal/core/config/slug_test.go b/src/internal/core/config/slug_test.go index 93c3600..28c5555 100644 --- a/src/internal/core/config/slug_test.go +++ b/src/internal/core/config/slug_test.go @@ -20,25 +20,6 @@ func TestIsSlug(t *testing.T) { } } -func TestCanonicalSlug(t *testing.T) { - for in, want := range map[string]string{ - "icon-sets-extras.ant-design": "icon-sets-extras-ant-design", - "Icon-Sets-Extras.Feather": "icon-sets-extras-feather", - "icon_sets.x": "icon-sets-x", - } { - got, deprecated := CanonicalSlug(in) - if got != want || !deprecated { - t.Errorf("CanonicalSlug(%q) = %q, %v; want %q, true", in, got, deprecated, want) - } - } - if got, deprecated := CanonicalSlug("icon-sets-flag"); got != "icon-sets-flag" || deprecated { - t.Errorf("a slug is its own canonical form: %q %v", got, deprecated) - } - if _, deprecated := CanonicalSlug("../etc"); deprecated { - t.Error("a path is not a deprecated spelling of a slug") - } -} - // Every name shipped in config/ -- each pack config's file name, its "name" // and each registry entry -- is a lowercase slug. Counted, so an empty glob // fails rather than passes. @@ -92,50 +73,62 @@ func mustRead(t *testing.T, p string) []byte { return b } -// The dotted names are deprecated, not removed: a registry entry, a pack's -// "name" and a --pack argument in the old spelling still resolve, to the -// canonical slug, with a warning. -func TestDeprecatedDottedNamesStillResolve(t *testing.T) { - var warned []string - old := Deprecated - Deprecated = func(msg string) { warned = append(warned, msg) } - t.Cleanup(func() { Deprecated = old }) - +// Old spellings are refused, not translated: the error states the rule and +// names the slug to use, wherever the name comes from. +func TestNonSlugNamesAreRefusedWithTheSlugToUse(t *testing.T) { dir := t.TempDir() write := func(name, body string) { if err := os.WriteFile(filepath.Join(dir, name), []byte(body), 0o644); err != nil { t.Fatal(err) } } - write("packs.json", `{"packs":["icon-sets-extras.feather"]}`) - // A user's own config still in the old spelling, file name and all. - write("icon-sets-extras.feather.json", `{"name":"icon-sets-extras.feather","pack":"ichava/icon-sets-extras", + write("icon-sets-extras-feather.json", `{"name":"icon-sets-extras.feather","pack":"ichava/icon-sets-extras", "pack_root":"/tmp/x","version_check_url":"https://registry.npmjs.org/feather-icons/latest", "source":{"type":"npm","package":"feather-icons"}}`) + write("icon-sets-extras.feather.json", `{}`) - reg, err := ParseRegistryBytes(filepath.Join(dir, "packs.json"), mustRead(t, filepath.Join(dir, "packs.json"))) - if err != nil || reg.Packs[0] != "icon-sets-extras-feather" { - t.Fatalf("registry: %+v %v", reg, err) - } - p, err := LoadPack("icon-sets-extras.feather", dir) - if err != nil { - t.Fatal(err) - } - if p.Name != "icon-sets-extras-feather" { - t.Errorf("name %q, want the canonical slug", p.Name) - } - if p2, err := LoadPack("icon-sets-extras-feather", dir); err != nil || p2.Name != p.Name { - t.Errorf("the canonical slug does not find the old-spelled file: %v", err) - } - if len(warned) == 0 || !strings.Contains(strings.Join(warned, "\n"), "icon-sets-extras-feather") { - t.Errorf("no deprecation warning naming the new slug: %q", warned) + check := func(what string, err error) { + t.Helper() + if err == nil { + t.Fatalf("%s: an old spelling was accepted", what) + } + for _, want := range []string{"lowercase slug", `"icon-sets-extras-feather"`} { + if !strings.Contains(err.Error(), want) { + t.Errorf("%s: %q lacks %q", what, err, want) + } + } } + _, err := ParseRegistryBytes("packs.json", []byte(`{"packs":["icon-sets-extras.feather"]}`)) + check("registry", err) + _, err = LoadPack("icon-sets-extras.feather", dir) + check("--pack", err) + _, err = LoadPack("Icon_Sets_Extras_Feather", dir) + check("--pack, capitals", err) + _, err = LoadPack("icon-sets-extras-feather", dir) + check("name inside the file", err) } -// A name that is not a slug and has no slug spelling is refused, naming the rule. +// A name with no slug spelling is refused with the rule and no suggestion. func TestANameThatIsNoSlugIsRefused(t *testing.T) { _, err := ParseRegistryBytes("packs.json", []byte(`{"packs":["icon sets/../x"]}`)) - if err == nil || !strings.Contains(err.Error(), "lowercase") { + if err == nil || !strings.Contains(err.Error(), "lowercase slug") || strings.Contains(err.Error(), "use ") { t.Fatalf("err = %v", err) } } + +// The schema editors validate against and the loader use one pattern. +func TestSchemaSlugPatternMatchesIsSlug(t *testing.T) { + var schema struct { + Properties struct { + Name struct { + Pattern string `json:"pattern"` + } `json:"name"` + } `json:"properties"` + } + if err := json.Unmarshal(mustRead(t, filepath.Join("..", "..", "..", "..", "config", "schema", "pack.schema.json")), &schema); err != nil { + t.Fatal(err) + } + if schema.Properties.Name.Pattern != SlugPattern { + t.Errorf("schema name pattern %q, IsSlug uses %q", schema.Properties.Name.Pattern, SlugPattern) + } +} diff --git a/src/internal/defaultconfig/config/schema/pack.schema.json b/src/internal/defaultconfig/config/schema/pack.schema.json index 4ef8183..e066116 100644 --- a/src/internal/defaultconfig/config/schema/pack.schema.json +++ b/src/internal/defaultconfig/config/schema/pack.schema.json @@ -16,8 +16,9 @@ }, "name": { "type": "string", - "minLength": 1, - "description": "The pack slug: lowercase letters a-z and digits in words joined by single hyphens, e.g. icon-sets-tabler or icon-sets-extras-feather. A dotted or capitalised name (icon-sets-extras.feather) is deprecated: it loads with a warning until 1.0.0." + "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$", + "maxLength": 100, + "description": "The pack slug, and the config's file name without .json: lowercase letters a-z and digits in words joined by single hyphens, e.g. icon-sets-tabler or icon-sets-extras-feather. No dots, underscores, capitals or spaces." }, "pack": { "type": "string", diff --git a/src/internal/web/handle_pack.go b/src/internal/web/handle_pack.go index b8308ef..1c8400f 100644 --- a/src/internal/web/handle_pack.go +++ b/src/internal/web/handle_pack.go @@ -82,20 +82,6 @@ func (s *Server) handlePack(w http.ResponseWriter, r *http.Request) { func (s *Server) loadPack(w http.ResponseWriter, r *http.Request) (*config.PackConfig, bool) { slug := r.PathValue("slug") - // A deprecated spelling (icon-sets-extras.feather) still reaches its pack: - // a page is sent to the canonical URL, so bookmarks and old links work and - // the address bar shows the slug; a form post is served as the slug. - if canon, deprecated := config.CanonicalSlug(slug); deprecated && validSlug(slug) { - if r.Method == http.MethodGet || r.Method == http.MethodHead { - to := strings.Replace(r.URL.Path, "/"+slug, "/"+canon, 1) - if r.URL.RawQuery != "" { - to += "?" + r.URL.RawQuery - } - http.Redirect(w, r, to, http.StatusMovedPermanently) - return nil, false - } - slug = canon - } if !validSlug(slug) { s.renderError(w, r, http.StatusNotFound, "No such pack", "There is no registered pack by that name.") return nil, false @@ -108,28 +94,9 @@ func (s *Server) loadPack(w http.ResponseWriter, r *http.Request) (*config.PackC return p, true } -// validSlug keeps a path value to a shape that can never name a file outside -// the config directory: lowercase letters, digits and hyphens, in segments -// joined by single dots. No segment is empty, so ".", ".." and a leading or -// trailing dot are refused. A pack slug itself has no dot (config.IsSlug); the -// dot is admitted only so the deprecated "icon-sets-extras." spelling of -// a set config reaches loadPack, which redirects it to the slug. -func validSlug(s string) bool { - if s == "" || len(s) > 100 { - return false - } - for _, seg := range strings.Split(s, ".") { - if seg == "" { - return false - } - for _, r := range seg { - if (r < 'a' || r > 'z') && (r < '0' || r > '9') && r != '-' { - return false - } - } - } - return true -} +// validSlug keeps a path value to a pack slug's shape (config.IsSlug), so it +// can never name a file outside the config directory. +func validSlug(s string) bool { return config.IsSlug(s) } // runForm is a run's choices as submitted. type runForm struct { diff --git a/src/internal/web/runs_test.go b/src/internal/web/runs_test.go index 7d64967..537b2d3 100644 --- a/src/internal/web/runs_test.go +++ b/src/internal/web/runs_test.go @@ -315,8 +315,8 @@ func TestPackPage(t *testing.T) { func TestValidSlug(t *testing.T) { for slug, want := range map[string]bool{ "icon-sets-flag": true, "a1": true, - // The deprecated "." spelling still passes, to be redirected. - "icon-sets-extras.game-icons": true, "a.b": true, + // A pack name has no dot: the old "." spelling is refused. + "icon-sets-extras-game-icons": true, "icon-sets-extras.game-icons": false, "a.b": false, "": false, "../etc": false, "Icon": false, "a/b": false, strings.Repeat("a", 101): false, ".": false, "..": false, ".a": false, "a.": false, "a..b": false, } { @@ -351,12 +351,11 @@ func TestEveryShippedPackNameIsAValidSlug(t *testing.T) { } } -// An old link to a set config's page, in the deprecated dotted spelling, is -// sent to the slug's page rather than answering 404. -func TestDeprecatedDottedPackURLRedirectsToTheSlug(t *testing.T) { +// An old link to a set config's page, in the removed dotted spelling, is +// not a pack: it answers 404 rather than redirecting. +func TestDottedPackURLIsNoPack(t *testing.T) { s, _ := newTestServer(t) - rec := signIn(t, s).get("/packs/icon-sets-tabler.x?y=1") - if rec.Code != http.StatusMovedPermanently || rec.Header().Get("Location") != "/packs/icon-sets-tabler-x?y=1" { + if rec := signIn(t, s).get("/packs/icon-sets-tabler.x"); rec.Code != http.StatusNotFound { t.Fatalf("got %d %q", rec.Code, rec.Header().Get("Location")) } }