File tree 6 files changed +113
-0
lines changed
6 files changed +113
-0
lines changed Original file line number Diff line number Diff line change 22
22
"propList" : [" testProp" , " testProp2" ]
23
23
}
24
24
},
25
+ " storybook" ,
25
26
" materialUI" ,
26
27
{
27
28
"name" : " chakraUI" ,
Original file line number Diff line number Diff line change
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ import {
3
+ PluginInitParams ,
4
+ PluginInitReturn ,
5
+ PluginRunParams ,
6
+ PluginRunReturn ,
7
+ } from "../../creatorSettings/creatorSettings.type" ;
8
+ import { IPluginOptions , ISettings , OutAnswers } from "./interfaces" ;
9
+ import inquirer from "inquirer" ;
10
+ import { questions } from "./questions" ;
11
+ import { compileTemplate } from "@/internalFeatures/templatesLibrary" ;
12
+ import { createFile } from "@/internalFeatures/fsLibrary" ;
13
+
14
+ export { questions } from "./questions" ;
15
+ export { defaultSettings } from "./interfaces" ;
16
+
17
+ export const pluginName = "storybook" ;
18
+
19
+ export async function initPlugin ( {
20
+ options,
21
+ globalOptions,
22
+ } : PluginInitParams < IPluginOptions > ) : Promise <
23
+ PluginInitReturn < IPluginOptions >
24
+ > {
25
+ const answers = ( await inquirer . prompt (
26
+ questions ,
27
+ options
28
+ ) ) as Required < ISettings > ;
29
+
30
+ return {
31
+ answers,
32
+ } ;
33
+ }
34
+
35
+ export async function runPlugin ( {
36
+ pluginSettings,
37
+ globalSettings,
38
+ allAnswers,
39
+ } : PluginRunParams < ISettings , OutAnswers > ) : Promise < PluginRunReturn > {
40
+ const answers = allAnswers . storybook ?. answers as Required < ISettings > ;
41
+ const cssContent = await compileTemplate (
42
+ answers . templateName ,
43
+ answers . templateFolder ,
44
+ globalSettings ,
45
+ allAnswers
46
+ ) ;
47
+
48
+ createFile ( allAnswers , `.stories.tsx` , cssContent ) ;
49
+ }
Original file line number Diff line number Diff line change
1
+ import { PluginInitReturn } from "@/creatorSettings/creatorSettings.type" ;
2
+
3
+ export interface IPluginOptions {
4
+ storybookSupport ?: boolean ;
5
+ }
6
+
7
+ export interface ISettings extends IPluginOptions {
8
+ templateName : string ;
9
+ templateFolder : string ;
10
+ }
11
+
12
+ export type OutAnswers = {
13
+ storybook : PluginInitReturn < ISettings > ;
14
+ } ;
15
+
16
+ export const defaultSettings : ISettings = {
17
+ templateName : "main" ,
18
+ templateFolder : "storybook" ,
19
+ } ;
Original file line number Diff line number Diff line change
1
+ import { Question } from "inquirer" ;
2
+ // import { IPluginOptions } from "./interfaces";
3
+
4
+ export const questions : Question [ ] = [ ] ;
Original file line number Diff line number Diff line change
1
+ ## Storybook module
2
+
3
+ ### Usage
4
+
5
+ Please create a new json file called ` .hayde.json ` in your project root. This file will be used to configure the Hayde.
6
+
7
+ And then add ` storybook ` to the plugins array.
8
+
9
+ ``` json
10
+ {
11
+ "plugins" : [
12
+ " general" ,
13
+ " storybook" ,
14
+ " reactJS" ,
15
+ " materialUI" ,
16
+ " chakraUI"
17
+ ]
18
+ }
19
+ ```
20
+
21
+ ### Options
22
+
23
+ | Option | Description | Default | Type |
24
+ | -------------- | ----------- | --------- | ------ |
25
+ | templateName | - | cssModule | string |
26
+ | templateFolder | - | css | string |
Original file line number Diff line number Diff line change
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+
3
+ import {{ general.answers.componentName }} from "./{{ general.answers.componentName }} ";
4
+
5
+ const meta: Meta<typeof {{ general.answers.componentName }} > = {
6
+ component: {{ general.answers.componentName }} ,
7
+ };
8
+
9
+ export default meta;
10
+ type Story = StoryObj<typeof {{ general.answers.componentName }} >;
11
+
12
+ export const General: Story = {
13
+ render: () => <{{ general.answers.componentName }} />,
14
+ };
You can’t perform that action at this time.
0 commit comments