Skip to content

Commit

Permalink
Add comment to generated files
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Nov 10, 2024
1 parent 811af53 commit 39a77ba
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/knip/scripts/generate-plugin-defs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { EOL } from 'node:os';
// biome-ignore lint/nursery/noRestrictedImports: script
import path from 'node:path';

const HEADER = '// This file is generated (no need to edit)';
const cc = str => str.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g, (_m, char) => char.toUpperCase());

const pluginsDir = path.resolve('src/plugins');
Expand All @@ -19,11 +20,11 @@ const typeDefinition = `export type PluginName = ${pluginNames.map(name => `'${n

const values = `export const pluginNames = [${pluginNames.map(name => `'${name}'`).join(',')}] as const;`;

fs.writeFileSync(outputFileTypes, typeDefinition + EOL + EOL + values);
fs.writeFileSync(outputFileTypes, HEADER + EOL + typeDefinition + EOL + EOL + values);

const imports = pluginNames.map(name => `import { default as ${cc(name)} } from './${name}/index.js';`).join(EOL);
const pluginsObj = `export const Plugins = {${pluginNames
.map(name => (name === cc(name) ? `${name},` : `'${name}': ${cc(name)},`))
.join(EOL)} };`;

fs.writeFileSync(outputFilePlugins, imports + EOL + EOL + pluginsObj);
fs.writeFileSync(outputFilePlugins, HEADER + EOL + imports + EOL + EOL + pluginsObj);
1 change: 1 addition & 0 deletions packages/knip/src/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file is generated (no need to edit)
import { default as angular } from './angular/index.js';
import { default as astro } from './astro/index.js';
import { default as ava } from './ava/index.js';
Expand Down
1 change: 1 addition & 0 deletions packages/knip/src/types/PluginNames.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file is generated (no need to edit)
export type PluginName =
| 'angular'
| 'astro'
Expand Down

0 comments on commit 39a77ba

Please sign in to comment.