Skip to content

Commit

Permalink
fix: build output as nodejs to allow using it inside .js file (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
nmerget authored Jan 14, 2025
1 parent c4fbaf5 commit 26a0e2d
Show file tree
Hide file tree
Showing 40 changed files with 235 additions and 8,463 deletions.
77 changes: 39 additions & 38 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,56 @@ CLI for generating or manipulating icon fonts from SVG files.

Clean svgs for icon fonts to work

> You can use `clean-icons.json` as a config file.
> By default it tries to search for the configuration otherwise use a correct path by passing `--config=./clean-icons.json`.
> You can use `clean-icons.json` as a config file.
By default it tries to search for the configuration otherwise use a correct path by passing `--config=./clean-icons.json`.

| long | short | description | required | defaultValue |
| :------------------ | :---: | :-------------------------------------------------------------------------------------------------- | :------: | :----------- |
| `--src` | `-s` | Source folder with all svgs | `` | |
| `--traceResolution` | `-r` | Change the default resolution of the trace | `` | `"600"` |
| `--out` | `-o` | Relative path where the files should be written to. Empty string will overwrite the original files. | `` | |
| `--dry` | `-d` | Do a dry run with this command - prints/returns output | `` | |
| `--ignoreGlobs` | `-i` | Path icon glob to exclude from the fonts | `` | `[]` |
| `--debug` | | Extra logging | `` | |
| `--config` | `-c` | Path to configuration file | `` | |
| `--src` | `-s` | Source folder with all svgs | `` | |
| `--traceResolution` | `-r` | Change the default resolution of the trace | `` | `"600"` |
| `--out` | `-o` | Relative path where the files should be written to. Empty string will overwrite the original files. | `` | |
| `--dry` | `-d` | Do a dry run with this command - prints/returns output | `` | |
| `--ignore` | `-i` | Glob or path like to exclude from files | `` | `[]` |
| `--debug` | | Extra logging | `` | |
| `--config` | `-c` | Path to configuration file | `` | |

## generate-icon-fonts

Generate icon fonts from SVG files

> You can use `generate-icon-fonts.json` as a config file.
> By default it tries to search for the configuration otherwise use a correct path by passing `--config=./generate-icon-fonts.json`.
> You can use `generate-icon-fonts.json` as a config file.
By default it tries to search for the configuration otherwise use a correct path by passing `--config=./generate-icon-fonts.json`.

| long | short | description | required | defaultValue |
| :------------------- | :---: | :------------------------------------------------------------------------------------ | :------: | :----------- |
| `--fontName` | `-f` | The name of your font | `` | |
| `--src` | `-s` | Source folder with all svgs | `` | |
| `--variants` | `-v` | Font variants e.g. solid, inverted, etc. We always add a "default" variant for icons. | `` | `[]` |
| `--withSizes` | `-w` | Splits the font into different sizes | `` | |
| `--prefix` | `-p` | Prefix of icons to delete for icons | `` | |
| `--overwriteSources` | `-o` | Overwrite all svgs inside src directory | `` | |
| `--dry` | `-d` | Do a dry run with this command - prints/returns output | `` | |
| `--ignoreGlobs` | `-i` | Path icon glob to exclude from the fonts | `` | `[]` |
| `--debug` | | Extra logging | `` | |
| `--config` | `-c` | Path to configuration file | `` | |
| `--fontName` | `-f` | The name of your font | `` | |
| `--src` | `-s` | Source folder with all svgs | `` | |
| `--variants` | `-v` | Font variants e.g. solid, inverted, etc. We always add a "default" variant for icons. | `` | `[]` |
| `--withSizes` | `-w` | Splits the font into different sizes | `` | |
| `--prefix` | `-p` | Prefix of icons to delete for icons | `` | |
| `--overwriteSources` | `-o` | Overwrite all svgs inside src directory | `` | |
| `--dry` | `-d` | Do a dry run with this command - prints/returns output | `` | |
| `--ignore` | `-i` | Glob or path like to exclude from files | `` | `[]` |
| `--debug` | | Extra logging | `` | |
| `--config` | `-c` | Path to configuration file | `` | |

## icon-subset

Creates new icon font (woff2) by passing a safelist/blocklist with icon literals. Requires <https://github.com/fonttools/fonttools> to be installed.

> You can use `icon-subset.json` as a config file.
> By default it tries to search for the configuration otherwise use a correct path by passing `--config=./icon-subset.json`.
| long | short | description | required | defaultValue |
| :-------------- | :---: | :----------------------------------------------------------------------------- | :------: | :----------- |
| `--safeList` | `-l` | Includes only icons from provided list. Priority over 'blockList'. | `` | |
| `--blockList` | `-b` | Excludes all icons from provided list. Can't be used together with 'safeList'. | `` | |
| `--overwrite` | `-w` | If the source file should be overwritten. Disables 'out' option. | `` | `true` |
| `--src` | `-s` | Source folder with all woff2 files | `` | |
| `--filePaths` | `-f` | File paths to woff2 file which should be subsetted. | `` | |
| `--out` | `-o` | Relative path where the file should be written | `` | `"."` |
| `--dry` | `-d` | Do a dry run with this command - prints/returns output | `` | |
| `--debug` | | Extra logging | `` | |
| `--config` | `-c` | Path to configuration file | `` | |
| `--ignoreGlobs` | `-i` | Path icon glob to exclude from the fonts | `` | `[]` |
Creates new icon font (woff2) by passing a safelist/blocklist with icon literals. Requires https://github.com/fonttools/fonttools to be installed.

> You can use `icon-subset.json` as a config file.
By default it tries to search for the configuration otherwise use a correct path by passing `--config=./icon-subset.json`.

| long | short | description | required | defaultValue |
| :------------ | :---: | :----------------------------------------------------------------------------- | :------: | :----------- |
| `--safeList` | `-l` | Includes only icons from provided list. Priority over 'blockList'. | `` | |
| `--blockList` | `-b` | Excludes all icons from provided list. Can't be used together with 'safeList'. | `` | |
| `--overwrite` | `-w` | If the source file should be overwritten. Disables 'out' option. | `` | `true` |
| `--src` | `-s` | Source folder with all woff2 files | `` | |
| `--filePaths` | `-f` | File paths to woff2 file which should be subsetted. | `` | |
| `--out` | `-o` | Relative path where the file should be written | `` | `"."` |
| `--dry` | `-d` | Do a dry run with this command - prints/returns output | `` | |
| `--debug` | | Extra logging | `` | |
| `--config` | `-c` | Path to configuration file | `` | |
| `--ignore` | `-i` | Glob or path like to exclude from files | `` | `[]` |

4 changes: 2 additions & 2 deletions docs/GenerateIconFonts.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ Here is an example for a JS file `index.js`:

```js
// index.js
import { generateIconFonts } from "@db-ux/icon-font-tools/dist/commands/generate-icon-fonts";
import { generateIconFonts } from "@db-ux/icon-font-tools";

void generateIconFonts({
fontName,
src: "./icons",
ignoreGlobs: ["**/node_modules/**"],
ignore: ["**/node_modules/**"],
variants: ["filled"],
withSizes: true,
});
Expand Down
5 changes: 4 additions & 1 deletion docs/IconSubset.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ Here is an example for a JS file `index.(js|ts)`:

```js
// index.(js|ts)
import { iconSubset } from "@db-ux/icon-font-tools/dist/commands/icon-subset";
import { iconSubset } from "@db-ux/icon-font-tools";

void iconSubset({
src: "./my-path-to/icons",
safeList: ["airplane", "bell"],
ignore: {
ignored: (p) => p.name.startsWith("NotoSans"),
},
});
```

Expand Down
12 changes: 12 additions & 0 deletions hygen/_templates/command/new/src/commands/command/index.ejs.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
force: true
to: ../src/commands/<%= name %>/index.ts
---
import { <%= h.changeCase.pascal(name) %>ConfigType } from "./data";

export const <%= h.changeCase.camel(name) %> = async (config: <%= h.changeCase.pascal(name) %>ConfigType) => {
const { debug, dry } = config;
// TODO: Add you logic here

return false;
}
14 changes: 4 additions & 10 deletions hygen/_templates/command/new/src/commands/index.ejs.t
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
---
force: true
to: ../src/commands/<%= name %>/index.ts
to: ../src/commands/index.ts
inject: true
append: true
---
import { <%= h.changeCase.pascal(name) %>ConfigType } from "./data";

export const <%= h.changeCase.camel(name) %> = async (config: <%= h.changeCase.pascal(name) %>ConfigType) => {
const { debug, dry } = config;
// TODO: Add you logic here

return false;
}
export * from "./<%= name %>";
Loading

0 comments on commit 26a0e2d

Please sign in to comment.