Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PKief committed Nov 8, 2023
0 parents commit c831a5e
Show file tree
Hide file tree
Showing 42 changed files with 10,798 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/**
*.spec.ts
51 changes: 51 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"extends": ["plugin:prettier/recommended"],
"env": {
"browser": true,
"es6": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "variable",
"format": ["camelCase"]
}
],
"@typescript-eslint/prefer-namespace-keyword": "error",
"no-trailing-spaces": "error",
"camelcase": "error",
"prefer-const": "error",
"eqeqeq": ["error", "smart"],
"id-blacklist": [
"error",
"any",
"Number",
"number",
"String",
"string",
"Boolean",
"boolean",
"Undefined"
],
"id-match": "error",
"no-eval": "error",
"no-underscore-dangle": "error",
"no-unsafe-finally": "error",
"no-var": "error",
"spaced-comment": "error",
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
]
}
}
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms
github: [pkief]
custom: ['https://paypal.me/philippkief', 'https://buymeacoffee.com/pkief']
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build + Test

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
- name: Setup Node.js ⚙️
uses: actions/setup-node@v2
with:
node-version: 'lts/*'
- name: Install node_modules 📦
run: npm ci
- name: Cache node_modules 💾
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Test + Build ⚒️
run: |
npm test
npm run lint
npm run build
60 changes: 60 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Release + Publish

on:
workflow_dispatch:
inputs:
versionChange:
type: choice
description: Select the version change
requried: true
options:
- major
- minor
- patch

jobs:
release:
runs-on: ubuntu-latest
env:
VERSION_CHANGE: ${{ github.event.inputs.versionChange }}
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js ⚙️
uses: actions/setup-node@v2
with:
node-version: 'lts/*'
registry-url: 'https://registry.npmjs.org'
- name: Install node_modules 📦
run: |
npm ci
- name: Update version ↗
run: |
git config --global user.name 'Philipp Kief'
git config --global user.email '[email protected]'
git config --global push.followTags true
npm version ${{ env.VERSION_CHANGE }} -m "Release %s"
- name: Get meta data 🔍
run: |
NODE_VERSION=$(node -p -e "require('./package.json').version")
echo VERSION=$NODE_VERSION >> $GITHUB_ENV
NODE_NAME=$(node -p -e "require('./package.json').name")
echo NAME=$NODE_NAME >> $GITHUB_ENV
NODE_DISPLAY_NAME=$(node -p -e "require('./package.json').displayName")
echo DISPLAY_NAME=$NODE_DISPLAY_NAME >> $GITHUB_ENV
- name: Build ⚒️
run: npm run build
- name: Push tags 📌
run: git push
- name: Release ${{ env.VERSION }} 🔆
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ env.VERSION }}
name: ${{ env.DISPLAY_NAME }} v${{ env.VERSION }}
generate_release_notes: true
- name: Publish to NPM Registry 🚀
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Dependencies
node_modules

# Build
lib
out
dist

# Tests
coverage
9 changes: 9 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Ignore everything
*
*/**

# Whitelist what you need
!lib/*
!bin/*
!LICENSE.md
!logo.png
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"endOfLine": "auto"
}
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": ["typescript"],
"editor.formatOnSave": true
}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Changelog

All notable changes to this project will be documented in this file. Dates are displayed in UTC.
8 changes: 8 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2022 Philipp Kief

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<h1 align="center">
<br>
<img src="https://github.com/PKief/vscode-icon-theme-reviewer/raw/main/logo.png" alt="logo" width="200">
<br><br>
SVG Color Linter
<br>
<br>
</h1>

<h4 align="center">Linting tool to check if SVG files only use colors of a given color palette.</h4>

## CLI Command

The tool can be executed with this command:

```
npx vscode-icon-theme-reviewer file1.svg file2.svg
```

It will fetch all the colors of a YAML file which must have the following structure:

```yaml
colors:
- '#FFEBEE'
- '#FFCDD2'
- '#EF9A9A'
- '#E57373'
- '#EF5350'
- '#F44336'
```
It also supports glob file patterns to check multiple files matching the pattern like this:
```
npx vscode-icon-theme-reviewer --colors colors.yml ./images/**/*.svg ./another-dir/*.svg test.svg
```

## Programmatic use

The tool can be imported as module into existing JavaScript or TypeScript code. Therefor it is necessary to install it via npm or yarn:

NPM:

```
npm install --save-dev vscode-icon-theme-reviewer
```

Yarn:

```
yarn add --dev vscode-icon-theme-reviewer
```

The module can be imported like this:

```ts
import { isColorInPalette, getSuggestions } from 'vscode-icon-theme-reviewer';

isColorInPalette('#FFFFFF', ['#EEEEEE', '#121212']);
// false

getSuggestions('#C0CA35', ['#EEEEEE', '#121212']);
// [
// { hex: '#C0CA33', distance: 0.160467661071053 },
// { hex: '#CDDC39', distance: 4.307076277707079 },
// { hex: '#D4E157', distance: 5.606714639567858 },
// { hex: '#AFB42B', distance: 5.713845679863578 },
// { hex: '#DCE775', distance: 8.065940911169271 }
// ]
```
2 changes: 2 additions & 0 deletions bin/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
require('../lib/cli/index.js');
4 changes: 4 additions & 0 deletions changelog.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"repositoryUrl": "https://github.com/PKief/vscode-icon-theme-reviewer",
"blacklistPattern": "^Release \\d+\\.\\d+\\.\\d+|^\\d+\\.\\d+\\.\\d+$"
}
Loading

0 comments on commit c831a5e

Please sign in to comment.