@pokedotdev/iconify
v0.3.0
Published
`@pokedotdev/iconify` is a small Bun-based build tool that converts SVG icon collections into Iconify-style JSON bundles.
Readme
iconify
@pokedotdev/iconify is a small Bun-based build tool that converts SVG icon collections into Iconify-style JSON bundles.
It scans svgs/, discovers icon set directories automatically, normalizes SVGs with @iconify/tools, and writes the generated output to json/. The published package contains only encrypted collections (json/*.json.enc) plus a dependency-free postinstall that decrypts them with ICONIFY_KEY.
What It Does
For each discovered icon set, the generator:
- imports SVG files from
svgs/<set> - cleans and optimizes SVG markup
- converts non-empty colors to
currentColor - exports a single
json/<prefix>.jsonbundle
Project Layout
src/index.ts Main generator
icon-sets.json Optional prefix alias configuration
svgs/ Source SVG collections
json/ Generated output filesInstall
bun installGenerate Icon Sets
bun run src/index.tsThis clears json/ first, rescans svgs/, and regenerates every output file.
Source Directory Conventions
Directories inside svgs/ become icon-set paths. By default, path segments are joined with -:
svgs/iconic->json/iconic.jsonsvgs/fa/solid->json/fa-solid.json
If a directory contains .svg files, it is treated as a leaf set and subdirectories under it are not scanned further.
Aliases
Use icon-sets.json to override generated prefixes. Aliases are optional; this package currently ships with no active aliases configured.
Exact aliases:
{
"aliases": {
"iconic": "iconic"
}
}Pattern aliases with placeholders:
{
"aliases": {
"fa/brands": "fa-brand",
"fa/duotone-{weight}": "fa-duo-{weight}",
"fa/{set}-duotone-{weight}": "fa-{set}-duo-{weight}"
}
}Verification
Before committing logic changes, run:
bunx tsc --noEmit
bun run src/index.ts
git diff -- jsonKeep generator changes and regenerated json/ output in separate commits when practical.
Encrypted Distribution
The package is public, but the Font Awesome Pro icon data is not: every json/<prefix>.json is gzipped and encrypted with AES-256-GCM (random IV per file, auth tag stored, file name bound as AAD) into json/<prefix>.json.enc. The tarball contains no plaintext icon data. On install, scripts/postinstall.mjs (node:crypto only) reads ICONIFY_KEY (32 bytes, base64 or hex) and writes json/<prefix>.json next to the .enc files. Without a key, or with a wrong one, it prints a one-line error and exits 1. It never prints the key.
Consumers need ICONIFY_KEY set in the environment at install time.
Publish
The key lives in ~/.config/iconify/key (mode 600) or in ICONIFY_KEY.
bun test
bun run encrypt # json/*.json -> json/*.json.enc (run again after regenerating icons)
npm pack --dry-run # must list only json/*.json.enc, scripts/*.mjs, package.json, README.md
npm publishAlways run bun run encrypt before packing: files only whitelists .enc files, so a stale or missing set would publish old or no icons. Unpack the tarball and check that it has no plaintext before publishing.
Rotate the key
Published versions stay public forever, so a leaked key exposes every version encrypted with it. To rotate: generate a new key (node -e 'console.log(require("crypto").randomBytes(32).toString("base64"))'), save it to ~/.config/iconify/key, run bun run encrypt, publish a new version, and move consumers to it with the new ICONIFY_KEY. Old versions remain decryptable with the old key.
pnpm 10+
pnpm 10+ does not run dependency lifecycle scripts by default. Allow this package to build, otherwise postinstall is skipped and json/*.json is never created (onlyBuiltDependencies / pnpm approve-builds):
{ "pnpm": { "onlyBuiltDependencies": ["@pokedotdev/iconify"] } }pnpm 8 runs the script without extra configuration. Also make sure ignore-scripts is not enabled.
