npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

generator-retax

v2.2.1

Published

retax seed production ready.

Downloads

5

Readme

generator-retax NPM version Build Status Dependency Status Coverage percentage

Fullstack react boilerplate production ready.

This is the official generator to scaffold a retax app.

Getting started

npm install -g yo generator-retax

Generators

retax-seed

To generate a retax-seed based on this project run:

yo retax MyAppName

The first argument of this generator is the project name (dash case). It is required.

The generator will prompt for:

  • The repo url
  • The author name

actions-creator

yo retax:actions-creator blog

The first argument of this generator is the actions creator name (camel case). It is required.

The generator will prompt for:

  • The first action name created by the generated actions creator. (default: DEFAULT_ACTION)

This actions creator uses retax-components element.

The previous command will generate:

// actions/blog.js

import { actionsCreatorFactory } from 'retax';
import { annotator, AbstractActionsCreator } from 'retax-components';

import {
  DEFAULT_ACTION,
} from 'constants/actions/blog';

@annotator.ActionsCreator() // eslint-disable-line
export default class BlogActionsCreator extends AbstractActionsCreator {
  @annotator.action()
  defaultAction = actionsCreatorFactory(DEFAULT_ACTION);
}
// actions/__tests__/blog-test.js

import chai, { expect } from 'chai';
import sinonChai from 'sinon-chai';
import dirtyChai from 'dirty-chai';
chai.use(sinonChai);
chai.use(dirtyChai);

import {
  DEFAULT_ACTION,
} from 'constants/actions/blog';

describe('blogActionsCreator', () => {
  it('should exists', () => {
    const BlogActionsCreator = require('../blog');
    expect(BlogActionsCreator).to.be.ok();
  });

  it('should test the defaultAction creator', () => {
    const BlogActionsCreator = require('../blog');

    const ac = new BlogActionsCreator();

    expect(ac).to.be.ok();

    expect(ac.defaultAction(1)).to.deep.equal({
      type: DEFAULT_ACTION,
      payload: 1,
    });
  });
});

/// constants/actions/blog.js
export const DEFAULT_ACTION = 'DEFAULT_ACTION';

And update all folder index.js accordingly.

reducer

yo retax:reducer blog

The first argument of this generator is the reducer name (camel case). It is required.

The generator will prompt for:

  • The first action name handled by the generated reducer. (default: DEFAULT_ACTION)

The previous command will generate:

// reducers/blog.js

import { reducerFactory } from 'retax';
import { fromJS } from 'immutable';

import {
  DEFAULT_ACTION,
} from 'constants/actions/blog';

function getInitialState() {
  return fromJS({
    value: {},
  });
}

export default reducerFactory(
  getInitialState(),
  {
    [DEFAULT_ACTION](state, action) {
      return state.setIn(['value'], action.payload);
    },
  }
);
// reducers/__tests__/blog-test.js

import chai, { expect } from 'chai';
import dirtyChai from 'dirty-chai';
chai.use(dirtyChai);

import { fromJS } from 'immutable';

import {
  DEFAULT_ACTION,
} from 'constants/actions/blog';

import blog from '../blog';

describe('Blog Reducer', () => {
  it('should exists', () => {
    expect(blog).to.be.ok();
  });

  it('should handle the DEFAULT_ACTION', () => {
    let state = fromJS({ value: 0 });
    const action = {
      type: DEFAULT_ACTION,
      payload: 1,
    };

    expect(state.get('value')).to.equal(0);
    state = blog(state, action);
    expect(state.get('value')).to.equal(1);
  });
});

And update all folder index.js accordingly.

selector

yo retax:selector blog

The first argument of this generator is the selector name (camel case). It is required.

This selector is an idiomatic reselect selector.

The previous command will generate:

// selectors/blog.js

import { createSelector } from 'reselect';

export function blogSelector(state) {
  return state.blog;
}

export const blogMapSelector = createSelector(
  blogSelector,
  blog => blog.get('value')
);
// selectors/__tests__/blog-test.js

import chai, { expect } from 'chai';
import sinonChai from 'sinon-chai';
import dirtyChai from 'dirty-chai';
chai.use(sinonChai);
chai.use(dirtyChai);

import { fromJS } from 'immutable';

describe('blog Selector', () => {
  it('should exists', () => {
    const blog = require('../blog');
    expect(blog).to.be.ok();
  });

  it('should test the blogMapSelector selector', () => {
    const blog = require('../blog');

    expect(blog.blogMapSelector({
      blog: fromJS({
        value: 0,
      }),
    })).to.equal(0);
  });
});

And update all folder index.js accordingly.

component

yo retax:component BlogPost

The first argument of this generator is the component name (Upper camel case). It is required.

The generator will prompt for:

The previous command will generate:

// components/BlogPost/BlogPost.js

import React, { Component } from 'react';
import pureRender from 'pure-render-decorator';

@pureRender
export default class BlogPost extends Component {
  static propTypes = {

  };

  render() {
    return (
      <div className="flex layout vertical">
        Yay!
      </div>
    );
  }
}
// components/BlogPost/__tests__/BlogPost-test.js

import chai, { expect } from 'chai';
import dirtyChai from 'dirty-chai';
chai.use(dirtyChai);

import { shallow } from 'enzyme';

import React from 'react';

describe('BlogPost', () => {
  it('should exists', () => {
    const BlogPost = require('../BlogPost');

    const wrapper = shallow((
      <BlogPost />
    ));

    expect(wrapper).to.have.length(1);
  });

  it('should render inner components', () => {
    const BlogPost = require('../BlogPost');

    const wrapper = shallow((
      <BlogPost />
    ));

    expect(wrapper.find('div')).to.have.length(1);
  });
});

And update all folder index.js accordingly.

route

yo retax:route blog

The first argument of this generator is the route name (camel case). It is required.

The generator will prompt for:

  • The url of the route (default /lowercase(routeName))
  • Should this route be asynchronous dynamic-routing
  • The require access level to access this route (public, user, admin) (this is defined in here in retax-seed)
  • Should this route have child routes
  • Should this route have an index route
  • Should this route be pure (ie: use pure-render-decorator)
  • Should this route use redux
  • Should this route use reselect

It will generate a lot of files in the folder: routes/blog.

A route folder has the following structure:

  • index.js: the react-router route definition
  • container/{page,index}: these are container components (smart components that connect to redux store) for the page and the index page.
  • component/{page,index}: dumb components called by the smart component respectively. These components should use only presentationnal components from the folder src/components
  • selector/{page,index}: reselect selectors for the smart component.

seed-component

This generator should not be used in a retax-seed project. It should be called in am empty folder.

It generates a standalone component that could be exported to github/npm. See react-component-seed.

yo retax:seed-component BlogPost

The first argument of this generator is the component name (Upper camel case). It is required.

The generator will prompt for:

  • The repo url
  • The author

License

MIT © retaxJS