Skip to content

Commit bb93a2b

Browse files
Add astro-og-canvas plugin (#1445)
Co-authored-by: Lars Kappert <oss@webpro.nl>
1 parent 3a99050 commit bb93a2b

7 files changed

Lines changed: 56 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import 'astro-og-canvas';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"dependencies": {
3+
"astro-og-canvas": "^0.10.0",
4+
"canvaskit-wasm": "^0.40.0"
5+
},
6+
"name": "@plugins/astro-og-canvas"
7+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type { IsPluginEnabled, Plugin, Resolve } from '../../types/config.js';
2+
import { toDependency } from '../../util/input.js';
3+
import { hasDependency } from '../../util/plugin.js';
4+
5+
// https://github.com/delucis/astro-og-canvas
6+
7+
const title = 'astro-og-canvas';
8+
9+
const enablers = ['astro-og-canvas'];
10+
11+
const isEnabled: IsPluginEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
12+
13+
const resolve: Resolve = async () => {
14+
return [toDependency('canvaskit-wasm', { optional: true })];
15+
};
16+
17+
const plugin: Plugin = {
18+
title,
19+
enablers,
20+
isEnabled,
21+
resolve,
22+
};
23+
24+
export default plugin;

packages/knip/src/plugins/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { default as angular } from './angular/index.js';
33
import { default as astro } from './astro/index.js';
44
import { default as astroDb } from './astro-db/index.js';
5+
import { default as astroOgCanvas } from './astro-og-canvas/index.js';
56
import { default as ava } from './ava/index.js';
67
import { default as babel } from './babel/index.js';
78
import { default as biome } from './biome/index.js';
@@ -131,6 +132,7 @@ export const Plugins = {
131132
angular,
132133
astro,
133134
'astro-db': astroDb,
135+
'astro-og-canvas': astroOgCanvas,
134136
ava,
135137
babel,
136138
biome,

packages/knip/src/schema/plugins.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const pluginsSchema = z.object({
1616
angular: pluginSchema,
1717
astro: pluginSchema,
1818
'astro-db': pluginSchema,
19+
'astro-og-canvas': pluginSchema,
1920
ava: pluginSchema,
2021
babel: pluginSchema,
2122
biome: pluginSchema,

packages/knip/src/types/PluginNames.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export type PluginName =
33
| 'angular'
44
| 'astro'
55
| 'astro-db'
6+
| 'astro-og-canvas'
67
| 'ava'
78
| 'babel'
89
| 'biome'
@@ -132,6 +133,7 @@ export const pluginNames = [
132133
'angular',
133134
'astro',
134135
'astro-db',
136+
'astro-og-canvas',
135137
'ava',
136138
'babel',
137139
'biome',
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import assert from 'node:assert/strict';
2+
import test from 'node:test';
3+
import { main } from '../../src/index.js';
4+
import baseCounters from '../helpers/baseCounters.js';
5+
import { createOptions } from '../helpers/create-options.js';
6+
import { resolve } from '../helpers/resolve.js';
7+
8+
const cwd = resolve('fixtures/plugins/astro-og-canvas');
9+
10+
test('Find dependencies with the astro-og-canvas plugin', async () => {
11+
const options = await createOptions({ cwd });
12+
const { counters } = await main(options);
13+
14+
assert.deepEqual(counters, {
15+
...baseCounters,
16+
processed: 1,
17+
total: 1,
18+
});
19+
});

0 commit comments

Comments
 (0)