Skip to content

Commit 0ede13d

Browse files
authored
Dependency update (#16)
* build: updated vulnerable dependencies * build: updated non-lint dev dependencies * update: updated prettier and moved out of eslint to check non-linted files * update: switched type to module * update: updated typescript-eslint and switched to new format * test: switched to fixed resolve pattern in test setup * build: updated vitest * build: switched package.json import method during build to cover supported node versions
1 parent 453c4a9 commit 0ede13d

16 files changed

+1852
-3724
lines changed

.eslintrc.js

-30
This file was deleted.

.github/workflows/check-code.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
node: [ 18, 20, 21, 22 ]
18+
node: [18, 20, 21, 22]
1919
name: Check Code (Node ${{ matrix.node }})
2020

2121
steps:

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bin

.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all"
4+
}

.prettierrc.js

-4
This file was deleted.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Node commands to add an overlay badge, inset to the non-transparent area.
44

55
| ![](https://github.com/sourcetoad/add-badge/raw/master/samples/output/ic_launcher-xxxhdpi.png) | ![](https://github.com/sourcetoad/add-badge/raw/master/samples/output/ic_launcher_round-xxxhdpi.png) |
6-
|------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|
6+
| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
77

88
## Installation
99

SAMPLES.md

+39-39
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
## Samples
2-
3-
### Gravity
4-
5-
| `--gravity=northwest` | `--gravity=north` | `--gravity=northeast` |
6-
|:--------------------------------------------------------------|:----------------------------------------------------------|:--------------------------------------------------------------|
7-
| ![](./samples/output/ic_launcher-xxxhdpi-northwest.png) | ![](./samples/output/ic_launcher-xxxhdpi-north.png) | ![](./samples/output/ic_launcher-xxxhdpi-northeast.png) |
8-
| ![](./samples/output/ic_launcher_round-xxxhdpi-northwest.png) | ![](./samples/output/ic_launcher_round-xxxhdpi-north.png) | ![](./samples/output/ic_launcher_round-xxxhdpi-northeast.png) |
9-
10-
| `--gravity=southwest` | `--gravity=south` | `--gravity=southeast` |
11-
|:--------------------------------------------------------------|:----------------------------------------------------------|:----------------------------------------------------|
12-
| ![](./samples/output/ic_launcher-xxxhdpi-southwest.png) | ![](./samples/output/ic_launcher-xxxhdpi-south.png) | ![](./samples/output/ic_launcher-xxxhdpi.png) |
13-
| ![](./samples/output/ic_launcher_round-xxxhdpi-southwest.png) | ![](./samples/output/ic_launcher_round-xxxhdpi-south.png) | ![](./samples/output/ic_launcher_round-xxxhdpi.png) |
14-
15-
### Position
16-
17-
| `--position=0` <br/> `--gravity=northeast` | `--position=50` <br/> `--gravity=northeast` | `--position=100` <br/> `--gravity=northeast` |
18-
|:-------------------------------------------------------------------------|:--------------------------------------------------------------------------|:---------------------------------------------------------------------------|
19-
| ![](./samples/output/ic_launcher_round-xxxhdpi-position-northeast-0.png) | ![](./samples/output/ic_launcher_round-xxxhdpi-position-northeast-50.png) | ![](./samples/output/ic_launcher_round-xxxhdpi-position-northeast-100.png) |
20-
21-
| `--position=10` <br/> `--gravity=north` | `--position=10,50` <br/> `--gravity=north` |
22-
|:----------------------------------------------------------------------|:-------------------------------------------------------------------------|
23-
| ![](./samples/output/ic_launcher_round-xxxhdpi-position-north-10.png) | ![](./samples/output/ic_launcher_round-xxxhdpi-position-north-10x50.png) |
24-
25-
### Appearance
26-
27-
| `--background-color="rgba(0,0,0,0.75)"` <br/> `--text-color=transparent` | `--shadow-color="hsl(78,100%,37%)"` <br/> `--text-color=transparent` |
28-
|:-------------------------------------------------------------------------|:---------------------------------------------------------------------|
29-
| ![](./samples/output/ic_launcher-xxxhdpi-dark-transparent.png) | ![](./samples/output/ic_launcher-xxxhdpi-shadow.png) |
30-
31-
| `--font-size=50` |
32-
|:-----------------------------------------------------------|
33-
| ![](./samples/output/ic_launcher_round-xxxhdpi-larger.png) |
34-
35-
### Size
36-
37-
| Adaptive | MDPI | MDPI Round |
38-
|:--------------------------------------------------|:-------------------------------------------|:-------------------------------------------------|
39-
| ![](./samples/output/ic_launcher_foreground.webp) | ![](./samples/output/ic_launcher-mdpi.png) | ![](./samples/output/ic_launcher_round-mdpi.png) |
1+
## Samples
2+
3+
### Gravity
4+
5+
| `--gravity=northwest` | `--gravity=north` | `--gravity=northeast` |
6+
| :------------------------------------------------------------ | :-------------------------------------------------------- | :------------------------------------------------------------ |
7+
| ![](./samples/output/ic_launcher-xxxhdpi-northwest.png) | ![](./samples/output/ic_launcher-xxxhdpi-north.png) | ![](./samples/output/ic_launcher-xxxhdpi-northeast.png) |
8+
| ![](./samples/output/ic_launcher_round-xxxhdpi-northwest.png) | ![](./samples/output/ic_launcher_round-xxxhdpi-north.png) | ![](./samples/output/ic_launcher_round-xxxhdpi-northeast.png) |
9+
10+
| `--gravity=southwest` | `--gravity=south` | `--gravity=southeast` |
11+
| :------------------------------------------------------------ | :-------------------------------------------------------- | :-------------------------------------------------- |
12+
| ![](./samples/output/ic_launcher-xxxhdpi-southwest.png) | ![](./samples/output/ic_launcher-xxxhdpi-south.png) | ![](./samples/output/ic_launcher-xxxhdpi.png) |
13+
| ![](./samples/output/ic_launcher_round-xxxhdpi-southwest.png) | ![](./samples/output/ic_launcher_round-xxxhdpi-south.png) | ![](./samples/output/ic_launcher_round-xxxhdpi.png) |
14+
15+
### Position
16+
17+
| `--position=0` <br/> `--gravity=northeast` | `--position=50` <br/> `--gravity=northeast` | `--position=100` <br/> `--gravity=northeast` |
18+
| :----------------------------------------------------------------------- | :------------------------------------------------------------------------ | :------------------------------------------------------------------------- |
19+
| ![](./samples/output/ic_launcher_round-xxxhdpi-position-northeast-0.png) | ![](./samples/output/ic_launcher_round-xxxhdpi-position-northeast-50.png) | ![](./samples/output/ic_launcher_round-xxxhdpi-position-northeast-100.png) |
20+
21+
| `--position=10` <br/> `--gravity=north` | `--position=10,50` <br/> `--gravity=north` |
22+
| :-------------------------------------------------------------------- | :----------------------------------------------------------------------- |
23+
| ![](./samples/output/ic_launcher_round-xxxhdpi-position-north-10.png) | ![](./samples/output/ic_launcher_round-xxxhdpi-position-north-10x50.png) |
24+
25+
### Appearance
26+
27+
| `--background-color="rgba(0,0,0,0.75)"` <br/> `--text-color=transparent` | `--shadow-color="hsl(78,100%,37%)"` <br/> `--text-color=transparent` |
28+
| :----------------------------------------------------------------------- | :------------------------------------------------------------------- |
29+
| ![](./samples/output/ic_launcher-xxxhdpi-dark-transparent.png) | ![](./samples/output/ic_launcher-xxxhdpi-shadow.png) |
30+
31+
| `--font-size=50` |
32+
| :--------------------------------------------------------- |
33+
| ![](./samples/output/ic_launcher_round-xxxhdpi-larger.png) |
34+
35+
### Size
36+
37+
| Adaptive | MDPI | MDPI Round |
38+
| :------------------------------------------------ | :----------------------------------------- | :----------------------------------------------- |
39+
| ![](./samples/output/ic_launcher_foreground.webp) | ![](./samples/output/ic_launcher-mdpi.png) | ![](./samples/output/ic_launcher_round-mdpi.png) |

__tests__/setup.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { readFileSync } from 'node:fs';
22
import { createRequire } from 'node:module';
3-
import { dirname, resolve } from 'node:path';
3+
import { dirname } from 'node:path';
44
import { fileURLToPath } from 'node:url';
55

66
import { initializeImageMagick } from '@imagemagick/magick-wasm';
@@ -10,6 +10,6 @@ global.__dirname = dirname(__filename);
1010
global.require = createRequire(import.meta.url);
1111

1212
const wasmBytes = readFileSync(
13-
resolve('node_modules/@imagemagick/magick-wasm/dist/magick.wasm'),
13+
require.resolve('@imagemagick/magick-wasm/magick.wasm'),
1414
);
1515
await initializeImageMagick(wasmBytes);

__tests__/utils/calculateCircularBadgePosition.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ describe('calculateManualBadgePosition', () => {
6262
expect(result.rotation).toEqual(expected.rotation);
6363
expect(
6464
Math.round(result.point.x),
65-
`Expected x to be ${expected.point.x} but was ${Math.round(result.point.x)}`,
65+
`Expected x to be ${expected.point.x.toString()} but was ${Math.round(result.point.x).toString()}`,
6666
).toEqual(expected.point.x);
6767
expect(
6868
Math.round(result.point.y),
69-
`Expected y to be ${expected.point.y} but was ${Math.round(result.point.y)}`,
69+
`Expected y to be ${expected.point.y.toString()} but was ${Math.round(result.point.y).toString()}`,
7070
).toEqual(expected.point.y);
7171
});
7272
});

__tests__/utils/calculateManualBadgePosition.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,11 @@ describe('calculateManualBadgePosition', () => {
211211
expect(result.rotation).toEqual(expected.rotation);
212212
expect(
213213
Math.round(result.point.x),
214-
`Expected x to be ${expected.point.x} but was ${Math.round(result.point.x)}`,
214+
`Expected x to be ${expected.point.x.toString()} but was ${Math.round(result.point.x).toString()}`,
215215
).toEqual(expected.point.x);
216216
expect(
217217
Math.round(result.point.y),
218-
`Expected y to be ${expected.point.y} but was ${Math.round(result.point.y)}`,
218+
`Expected y to be ${expected.point.y.toString()} but was ${Math.round(result.point.y).toString()}`,
219219
).toEqual(expected.point.y);
220220
});
221221
});

build.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
const { build } = require('esbuild');
1+
import { createRequire } from 'node:module';
2+
3+
import { build } from 'esbuild';
4+
5+
const require = createRequire(import.meta.url);
26
const { version } = require('./package.json');
37

48
const banners = [
@@ -9,6 +13,7 @@ const banners = [
913
const config = {
1014
bundle: true,
1115
minify: false,
16+
format: 'cjs',
1217
packages: 'external',
1318
platform: 'node',
1419
banner: {
@@ -19,17 +24,17 @@ const config = {
1924
build({
2025
...config,
2126
entryPoints: ['src/commands/addBadge.ts'],
22-
outfile: 'bin/add-badge.js',
27+
outfile: 'bin/add-badge.cjs',
2328
}).catch(() => process.exit(1));
2429

2530
build({
2631
...config,
2732
entryPoints: ['src/commands/addBadges.ts'],
28-
outfile: 'bin/add-badges.js',
33+
outfile: 'bin/add-badges.cjs',
2934
}).catch(() => process.exit(1));
3035

3136
build({
3237
...config,
3338
entryPoints: ['src/commands/generateSamples.ts'],
34-
outfile: 'bin/generate-samples.js',
39+
outfile: 'bin/generate-samples.cjs',
3540
}).catch(() => process.exit(1));

eslint.config.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import eslint from '@eslint/js';
2+
import simpleImportSort from 'eslint-plugin-simple-import-sort';
3+
import globals from 'globals';
4+
import tsEslint from 'typescript-eslint';
5+
6+
export default tsEslint.config(
7+
eslint.configs.recommended,
8+
...tsEslint.configs.strictTypeChecked,
9+
{
10+
ignores: ['bin'],
11+
},
12+
{
13+
languageOptions: {
14+
globals: {
15+
...globals.node,
16+
},
17+
parserOptions: {
18+
project: true,
19+
tsconfigDirName: import.meta.dirname,
20+
},
21+
},
22+
plugins: {
23+
'simple-import-sort': simpleImportSort,
24+
},
25+
rules: {
26+
'simple-import-sort/imports': 'error',
27+
'no-console': ['error', { allow: ['error', 'info', 'warn'] }],
28+
},
29+
},
30+
{
31+
files: ['**/*.js', '**/*.cjs', '**/*.mjs'],
32+
...tsEslint.configs.disableTypeChecked,
33+
},
34+
);

0 commit comments

Comments
 (0)