feat: coming soon
This commit is contained in:
15
generators/component/Component.stories.tsx.hbs
Normal file
15
generators/component/Component.stories.tsx.hbs
Normal file
@ -0,0 +1,15 @@
|
||||
import { Meta, Story } from '@storybook/react'
|
||||
|
||||
import { {{ properCase name }} as Component, {{ properCase name }}Props } from './{{ properCase name }}'
|
||||
|
||||
const Stories: Meta = {
|
||||
title: '{{ properCase name }}',
|
||||
component: Component
|
||||
}
|
||||
|
||||
export default Stories
|
||||
|
||||
export const {{ properCase name }}: Story<{{ properCase name }}Props> = (arguments_) => {
|
||||
return <Component {...arguments_} />
|
||||
}
|
||||
{{ properCase name }}.args = { className: 'text-center' }
|
10
generators/component/Component.test.tsx.hbs
Normal file
10
generators/component/Component.test.tsx.hbs
Normal file
@ -0,0 +1,10 @@
|
||||
import { render } from '@testing-library/react'
|
||||
|
||||
import { {{ properCase name }} } from './{{ properCase name }}'
|
||||
|
||||
describe('<{{ properCase name }} />', () => {
|
||||
it('should render successfully', () => {
|
||||
const { baseElement } = render(<{{ properCase name }} />)
|
||||
expect(baseElement).toBeTruthy()
|
||||
})
|
||||
})
|
11
generators/component/Component.tsx.hbs
Normal file
11
generators/component/Component.tsx.hbs
Normal file
@ -0,0 +1,11 @@
|
||||
import classNames from 'classnames'
|
||||
|
||||
export interface {{ properCase name }}Props {
|
||||
className?: string
|
||||
}
|
||||
|
||||
export const {{ properCase name }}: React.FC<{{ properCase name }}Props> = (props) => {
|
||||
const { children, className } = props
|
||||
|
||||
return <main className={classNames(className, '')}>{children}</main>
|
||||
}
|
43
generators/component/index.js
Normal file
43
generators/component/index.js
Normal file
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* @param {import('plop').NodePlopAPI} plop
|
||||
* @returns {import('node-plop').PlopGeneratorConfig}
|
||||
*/
|
||||
exports.componentGenerator = () => {
|
||||
return {
|
||||
description: 'Component Generator',
|
||||
prompts: [
|
||||
{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'component name'
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'folder',
|
||||
message: 'folder in components'
|
||||
}
|
||||
],
|
||||
actions: [
|
||||
{
|
||||
type: 'add',
|
||||
path: 'components/{{folder}}/{{properCase name}}/{{properCase name}}.stories.tsx',
|
||||
templateFile: 'generators/component/Component.stories.tsx.hbs'
|
||||
},
|
||||
{
|
||||
type: 'add',
|
||||
path: 'components/{{folder}}/{{properCase name}}/{{properCase name}}.test.tsx',
|
||||
templateFile: 'generators/component/Component.test.tsx.hbs'
|
||||
},
|
||||
{
|
||||
type: 'add',
|
||||
path: 'components/{{folder}}/{{properCase name}}/{{properCase name}}.tsx',
|
||||
templateFile: 'generators/component/Component.tsx.hbs'
|
||||
},
|
||||
{
|
||||
type: 'add',
|
||||
path: 'components/{{folder}}/{{properCase name}}/index.ts',
|
||||
templateFile: 'generators/component/index.ts.hbs'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
1
generators/component/index.ts.hbs
Normal file
1
generators/component/index.ts.hbs
Normal file
@ -0,0 +1 @@
|
||||
export * from './{{ properCase name }}'
|
48
generators/language/index.js
Normal file
48
generators/language/index.js
Normal file
@ -0,0 +1,48 @@
|
||||
const fs = require('node:fs')
|
||||
|
||||
const prettier = require('prettier')
|
||||
|
||||
/**
|
||||
* @param {import('plop').NodePlopAPI} plop
|
||||
* @returns {import('node-plop').PlopGeneratorConfig}
|
||||
*/
|
||||
exports.languageGenerator = (plop) => {
|
||||
return {
|
||||
description: 'Add a new language for translations',
|
||||
prompts: [
|
||||
{
|
||||
type: 'input',
|
||||
name: 'locale',
|
||||
message: 'locale'
|
||||
}
|
||||
],
|
||||
actions: [
|
||||
{
|
||||
type: 'addMany',
|
||||
base: 'locales/en',
|
||||
destination: 'locales/{{locale}}',
|
||||
templateFiles: 'locales/en/**'
|
||||
},
|
||||
async (answers) => {
|
||||
process.chdir(plop.getPlopfilePath())
|
||||
const data = JSON.parse(
|
||||
await fs.promises.readFile('i18n.json', { encoding: 'utf-8' })
|
||||
)
|
||||
data.locales.push(answers.locale)
|
||||
const formatted = prettier.format(JSON.stringify(data, null, 2), {
|
||||
filepath: 'i18n.json'
|
||||
})
|
||||
await fs.promises.writeFile('i18n.json', formatted, {
|
||||
encoding: 'utf-8'
|
||||
})
|
||||
return plop.renderString(
|
||||
`
|
||||
Added '{{locale}}' to the 'locales' array inside 'i18n.json'
|
||||
Don't forget to add the flag at 'public/images/svg/languages/{{locale}}.svg'
|
||||
`,
|
||||
answers
|
||||
)
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user