Skip to content

Commit

Permalink
refactor(core): complete rewrite with Typescript and modern node APIs
Browse files Browse the repository at this point in the history
use esm, TypeScript, node apis, jest and promises where possible

BREAKING CHANGE: Requires Node 20.11+ and ESM

fix #169 fix #129 concerns #91
  • Loading branch information
nfroidure committed Jul 29, 2024
1 parent 7bafaf3 commit e84a5ce
Show file tree
Hide file tree
Showing 190 changed files with 9,127 additions and 7,809 deletions.
7 changes: 4 additions & 3 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# This file is automatically generated by a `metapak`
# module. Do not change it elsewhere, changes would
# module. Do not change it here, your changes would
# be overridden.

engines:
eslint:
enabled: true

ratings:
paths:
- "src/*.js bin/*.js tests/*.mocha.js"
- "'src/**/*.ts'"
## Exclude test files.
exclude_patterns:
- "dist/"
- "**/node_modules/"
- "tests/*.mocha.js"
- "src/**/*.test.ts"
5 changes: 2 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
*.md text eol=lf
*.html text eol=lf
*.js text eol=lf
# Enforce Unix newlines
* text=auto eol=lf
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [nfroidure]
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ I'm a gentledev I:
```
<paste here>
```
If the result is lower than 16.15.0, there is
If the result is lower than 20.11.1, there is
poor chances I even have a look to it. Please,
use the last [NodeJS LTS version](https://nodejs.org/en/).

Expand Down
48 changes: 22 additions & 26 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
# This file is automatically generated by a `metapak`
# module. Do not change it here, your changes would
# be overridden.

name: Node.js CI

on:
push:
branches-ignore:
- "dependabot/**"
branches: [main]
pull_request:
workflow_dispatch:
name: Run tests
branches: [main]

jobs:
test:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node: [12, 14, 16, 18]
node-version: [20.x]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: npm
- run: npm ci
- run: npm test
- uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: run-${{ matrix.node }}
parallel: true
finish:
needs: test
runs-on: ubuntu-latest
steps:
- uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run pre-commit tests
run: npm run precz
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,5 @@ Temporary Items
.coveralls.yml

# Project custom ignored file
tests/results
dist
src/tests/results
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"gruntfuggly.todo-tree"
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
[//]: # (be overridden.)
[//]: # ( )
# svgicons2svgfont
> Read a set of SVG icons and ouput a SVG font
> Read a set of SVG icons and output a SVG font
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nfroidure/svgicons2svgfont/blob/master/LICENSE)
[![Coverage Status](https://coveralls.io/repos/github/git://github.com/nfroidure/svgicons2svgfont/badge.svg?branch=master)](https://coveralls.io/github/git://github.com/nfroidure/svgicons2svgfont?branch=master)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nfroidure/svgicons2svgfont/blob/main/LICENSE)


[//]: # (::contents:start)
Expand Down Expand Up @@ -302,4 +301,4 @@ Feel free to push your code if you agree with publishing under the MIT license.
- [Vinicius Teixeira](https://github.com/vinicius0026)

# License
[MIT](https://github.com/nfroidure/svgicons2svgfont/blob/master/LICENSE)
[MIT](https://github.com/nfroidure/svgicons2svgfont/blob/main/LICENSE)
25 changes: 13 additions & 12 deletions bin/svgicons2svgfont.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#! /usr/bin/env node
/* eslint-disable prefer-reflect */

'use strict';
import { program } from 'commander';
import { createWriteStream } from 'node:fs';
import { join } from 'node:path';
import { readFile } from 'node:fs/promises';
import { glob } from 'glob';

const program = require('commander');
const fs = require('fs');
const glob = require('glob');
import SVGIcons2SVGFontStream from '../dist/index.js';
import SVGIconsDirStream from '../dist/iconsdir.js';

const SVGIcons2SVGFontStream = require('../src/index.js');
const SVGIconsDirStream = require('../src/iconsdir.js');
const { version } = JSON.parse((await readFile(join(import.meta.dirname, '..', 'package.json'))).toString());

program
.storeOptionsAsProperties(true)
.version(require('../package').version)
.version(version)
.usage('[options] <icons ...>')
.option('-v, --verbose', 'tell me everything!')
.option('-o, --output [/dev/stdout]', 'file to write output to')
Expand Down Expand Up @@ -62,7 +63,7 @@ program
parseInt
)
.option(
'-a, --prependUnicode',
'-u, --prependUnicode',
'prefix files with their automatically' + ' allocated unicode code point',
parseInt
)
Expand All @@ -80,7 +81,7 @@ const options = program.opts();
new SVGIconsDirStream(files, {
startUnicode: options.startunicode,
prependUnicode: options.prependUnicode,
log: options.v ? console.log : function () {}, // eslint-disable-line
log: options.v ? console.log : function () { }, // eslint-disable-line
})
.pipe(
new SVGIcons2SVGFontStream({
Expand All @@ -96,7 +97,7 @@ new SVGIconsDirStream(files, {
descent: options.descent,
ascent: options.ascent,
metadata: options.metadata,
log: options.v ? console.log : function () {}, // eslint-disable-line
log: options.v ? console.log : function () { }, // eslint-disable-line
})
)
.pipe(options.output ? fs.createWriteStream(options.output) : process.stdout);
.pipe(options.output ? createWriteStream(options.output) : process.stdout);
28 changes: 28 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// @ts-check
// This file is automatically generated by a `metapak`
// module. Do not change it elsewhere, changes would
// be overridden.

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslintConfigPrettier from 'eslint-config-prettier';
import eslintPluginJest from 'eslint-plugin-jest';

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
{
files: ['*.test.ts'],
...eslintPluginJest.configs['flat/recommended'],
},
eslintConfigPrettier,
{
name: 'Project config',
languageOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
ignores: ['*.d.ts'],
},
);

Loading

0 comments on commit e84a5ce

Please sign in to comment.