# generator-spock

> React/Redux Yeoman Generators

Latest version **1.0.3** (published 2019-08-17) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install generator-spock
pnpm add generator-spock
yarn add generator-spock
bun add generator-spock
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2019-08-17 |
| First published | 2019-07-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 20.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Rafael Rozon |
| Maintainers | rafaelrozon |
| Keywords | react, redux, reselect, generator, yeoman, yo, spock, yeoman-generator |

## Links

- npm: https://www.npmjs.com/package/generator-spock
- Repository: https://github.com/rafaelrozon/generator-spock
- Homepage: https://github.com/rafaelrozon/generator-spock#readme
- Issues: https://github.com/rafaelrozon/generator-spock/issues
- npm.io page: https://npm.io/package/generator-spock

## Dependencies (4)

- [chalk](https://npm.io/package/chalk.md) ^2.4.2
- [yosay](https://npm.io/package/yosay.md) ^2.0.2
- [change-case](https://npm.io/package/change-case.md) ^3.1.0
- [yeoman-generator](https://npm.io/package/yeoman-generator.md) ^4.0.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2019-08-17
- 1.0.2 — 2019-07-27
- 1.0.0 — 2019-07-21

## README

# generator-spock

![Spock - Star Trek](https://upload.wikimedia.org/wikipedia/commons/thumb/e/eb/Leonard_Nimoy_as_Spock_Star_Trek.jpg/374px-Leonard_Nimoy_as_Spock_Star_Trek.jpg)

## Installation

First, install [Yeoman](http://yeoman.io) and generator-spock using [npm](https://www.npmjs.com/) (we assume you have pre-installed [node.js](https://nodejs.org/)).

```bash
npm install -g yo
npm install -g generator-spock
```

## Available Generators
- Action
- Component
- Reducer
- Selector
- Story

## Options
All generators take these options:
- destinationFolder: where to create the file, defaults to current directory
- moduleName: the name of what you want to create, e.g.: MyComponent, reducer, CartActions, etc
- filename: unless specified the filename is the module name. You don't need to pass the extension

### Action Generator

```bash
yo spock:action
```

Actions example output:

```jsx
/**
 * ShoppingCart Actions
 */

//  Action Types

// Action Creators

// Async Actions
```

### Component Generator

```bash
yo spock:component
```

Options: class, functional, connected, native, class typescript, functional typescript

Class option example output:

```jsx
/**
 * ShoppingCart
 */
import React from 'react';

export default class ShoppingCart extends React.Component {
    render() {
        return (
            <div className="shopping-cart">
                ShoppingCart component
            </div>
        );
    }
}
```

Functional option example output:

```jsx
/**
 * ShoppingCart
 */
import React from 'react';

const ShoppingCart = () => {
    return (
        <div className="shopping-cart">
            ShoppingCart component
        </div>
    );
};

export default ShoppingCart;
```

Connected option example output:

```jsx
/**
 * ShoppingCart
 */
import React from 'react';
import { connect } from 'react-redux';
import ShoppingCart from './ShoppingCart';

const makeMapToStateProps = (state) => ({})

const mapDispatchToProps = (dispath) => ({});

export default connect(makeMapToStateProps, mapDispatchToProps)(ShoppingCart);
```


Functional Native option example output:

```jsx
/**
 * ShoppingCart
 */
import React from 'react';
import { View } from 'react-native';

const ShoppingCart = () => {
    return (
        <View>
            ShoppingCart component
        </View>
    );
};

export default ShoppingCart;
```

Class Typescript option example output:

```tsx
/**
 * ShoppingCart
 */
import * as React from 'react';

interface Props {

}

export default class ShoppingCart extends React.Component<Props, {}> {
    render() {
        return (
            <div className="shopping-cart">
                ShoppingCart component
            </div>
        );
    }
}
```

Functional Typescript option example output:

```tsx
/**
 * ShoppingCart
 */
import * as React from 'react';

interface Props {

}

const ShoppingCart: React.FC = (props: Props) => {
    return (
        <div className="shopping-cart">
            ShoppingCart component
        </div>
    );
};

export default ShoppingCart;
```

### Reducer Generator

```bash
yo spock:reducer
```

The reducer generator also supports typescript. The only difference will be the file extension.

Options: page, module

Page option example output:

```jsx
/**
* ShoppingCart Reducer
*/
import { combineReducers } from 'redux';

export default combineReducers({

});
```

Module option example output:

```jsx
/**
 * ShoppingCart Reducer
 */
export default (state = {}, action) => {
    switch (action.type) {
        default:
            return state;
    }
};
```

### Selector Generator

```bash
yo spock:selector
```

The selector generator also supports typescript. The only difference will be the file extension.

Example output:

```jsx
/**
 * ShoppingCart Selectors
 */
import { createSelector } from 'reselect';

const rootSelector = state => state;

export const sampleSelector = createSelector(
    [rootSelector],
    state => state
);
```


### Story Generator

```bash
yo spock:story
```

Example output

```jsx
/**
 * ShoppingCart Stories
 */
import React from 'react';
import { storiesOf } from '@storybook/react';

const stories = storiesOf('ShoppingCart', module);

stories.add('ShoppingCart', () => (
    <div>
        ShoppingCart
    </div>
));
```

Example typescript output

```tsx
/**
 * ShoppingCart Stories
 */
import * as React from 'react';
import { storiesOf } from '@storybook/react';

const stories = storiesOf('ShoppingCart', module);

stories.add('ShoppingCart', () => (
    <div>
        ShoppingCart
    </div>
));
```

## License

MIT © [Rafael Rozon](rafaelrozon.com)


[npm-image]: https://badge.fury.io/js/generator-spock-2.svg
[npm-url]: https://npmjs.org/package/generator-spock-2
[daviddm-image]: https://david-dm.org/rafaelrozon/generator-spock-2.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/rafaelrozon/generator-spock-2

---
_Source: https://npm.io/package/generator-spock · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
