knip
Version:
Find unused files, dependencies and exports in your TypeScript and JavaScript projects
31 lines (30 loc) • 936 B
JavaScript
import { toDependency } from '../../util/input.js';
import { hasDependency } from '../../util/plugin.js';
const title = 'Astro';
const enablers = ['astro'];
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
const entry = ['astro.config.{js,cjs,mjs,ts}', 'src/content/config.ts', 'src/content.config.ts'];
const production = [
'src/pages/**/*.{astro,mdx,js,ts}',
'src/content/**/*.mdx',
'src/middleware.{js,ts}',
'src/actions/index.{js,ts}',
];
const resolve = options => {
const { manifest, isProduction } = options;
const inputs = [];
if (!isProduction &&
manifest.scripts &&
Object.values(manifest.scripts).some(script => /(?<=^|\s)astro(\s|\s.+\s)check(?=\s|$)/.test(script))) {
inputs.push(toDependency('@astrojs/check'));
}
return inputs;
};
export default {
title,
enablers,
isEnabled,
entry,
production,
resolve,
};