Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,15 @@ src
├── $ComponentName.test.tsx (optional)
├── $ComponentName.stories.tsx (optional)
├── $ComponentName.styles.tsx (optional)
├── $ComponentName.custom.ts (optional see additionalTemplates)
└── index.tsx (optional)
```

## Configuration

```typescript
export interface GeneratorConfig {
additionalTemplates?: { extension: string; template: string }[]; //custom template extension eg. custom.ts, & template path to the corresponding files, need to be an absolute path
createIndex: boolean; //create an index file
functional: boolean; //should the template be functional or class based?
basePath: string; //where do you want to store the generated files
Expand Down
15 changes: 15 additions & 0 deletions src/atomicComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,21 @@ const atomicComponent = (
data,
});

if (fullConfig.additionalTemplates !== undefined) {
fullConfig.additionalTemplates.forEach(({ extension, template }) => {
if (fs.existsSync(template)) {
actions.push({
type: "add",
path:
fullConfig.basePath +
`/${formattedType}/${formattedDirName}/${formattedFileName}.${extension}`,
templateFile: template,
data,
});
}
});
}

return {
description: "⚛ react component",
prompts,
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import atomicComponent from "./atomicComponent";
import { FileNameFormatters } from "./types";

export interface GeneratorConfig {
additionalTemplates?: { extension: string; template: string }[];
createIndex: boolean;
functional: boolean;
basePath: string;
Expand Down