Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/darmikon/plop-decorators
Helpers for plopjs generator
https://github.com/darmikon/plop-decorators
cli generator javascript plop
Last synced: 16 days ago
JSON representation
Helpers for plopjs generator
- Host: GitHub
- URL: https://github.com/darmikon/plop-decorators
- Owner: Darmikon
- Created: 2020-04-14T09:43:28.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T03:47:55.000Z (about 2 years ago)
- Last Synced: 2024-12-22T20:47:30.058Z (25 days ago)
- Topics: cli, generator, javascript, plop
- Language: TypeScript
- Homepage: http://plopjs.com
- Size: 1.55 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
![GitHub package.json version](https://img.shields.io/github/package-json/v/darmikon/plop-decorators) ![npm](https://img.shields.io/npm/v/plop-decorators) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
### plop-decorators
Helpers for [plopjs generator](http://plopjs.com/)
Inculde 3 decorators: `withHelpers`, `withActions`, `withGenerators`
- `withHelpers` - to add extra functions to .hbs templates
- `withActions` - automatically adds `prepend` action and allows to add custom actions.
If you created customHelpers don't forget to add them to `withActions` so that `prepend`
action could work properly with your functions.
- `withGenerators` - by default searches for every files in `.plop/generators` folderInclude 1 custom action `prepend`
The action injects the replacement before the market and not after### Installation
```
yarn add --dev plop plop-decorators
```#### API
1. Create `index.js` inside `.plop` folder of root directory
```
const { withHelpers, withActions, withGenerators } = require('plop-helpers');global.cwd = process.cwd();
const customHelpers = {};
const customActions = {};module.exports = plop => {
withHelpers(plop, customHelpers);
withActions(plop, customActions, customHelpers);
withGenerators(plop);
};
```2. Create generator files inside `.plop/generators` folder e.g.
```
module.exports = plop =>
plop.setGenerator('epic', {
description: 'Epic Injection',
prompts: [
{
type: 'input',
name: 'name',
message: 'Epic Name',
},
{
type: 'input',
name: 'moduleName',
message: 'Into module:',
},
],
actions: [
// EPIC
{
type: 'prepend',
path: `${cwd}/src/{{moduleName}}/epics.js`,
pattern: '//†epic',
template: `export const {{camelCase name}}Epic = (action$, state$) =>
of('MOCK').pipe(ignoreElements());`,
},
],
});
```3. In `package.json` add the next command to `scripts` section:
```
"scripts": {
"gen": "plop --plopfile .plop/index.js",
...
}
```4. Run
```
yarn gen
```