Create file from Template
npm install gvegas-cfcnpm:
bash
npm install --save-dev gvegas-cfc
`
yarn:
`bash
yarn add -D gvegas-cfc
`
$3
Создайте в корне проекта папку с любым удобным для вас названием.
Например, создадим родительскую папку templates.
В папке templates создадим две папки с шаблонами: PageComponent и UIComponent.
Структура директорий должна получится следующей:
`bash
│
├── templates
│ ├── PageComponent
│ └── UIComponent
`
Далее заполним папки шаблонов:
`bash
│
├── templates
│ │
│ ├── PageComponent
│ │ ├── UI
│ │ │ ├── Template.async.tsx
│ │ │ ├── Template.stories.tsx
│ │ │ └── Template.tsx
│ │ └── index.ts
│ │
│ └── UIComponent
│ ├── UI
│ │ ├── Template.module.scss
│ │ ├── Template.stories.tsx
│ │ ├── Template.test.tsx
│ │ └── Template.tsx
│ └── index.ts
│
`
$3
"create:ui": "npx gvegas-cfc create -t ./templates/UITemplate -o ./output UITest"
Скрипт принимает 3 аргумента:
- -t | --template.
Название шаблона (Название папки шаблона, например UIComponent).
- -o | --output
Путь, куда должны сгенерироваться файлы.
- Название сгенерированного файла
Запускаем:
`bash
npx gvegas-cfc create -t ./templates/UITemplate -o ./output UITest
`
Но проще будет добавить scripts в package.json:
`json
{
...
"scripts": {
"create:ui": "npx gvegas-cfc create -t ./templates/UITemplate -o ./output"
},
...
}
`
После этого мы можем запустить:
npm:
`bash
npm run create:ui UITest
`
или
yarn:
`bash
yarn create:ui UITest
`
Настройка gvegas-cfc` завершена!