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-electrode

v6.0.2

Published

Generate Electrode React App

Downloads

102

Readme

generator-electrode

NPM version Dependency Status devDependency Status npm downloads

Generate Electrode ~~Isomorphic~~ Universal React App with NodeJS backend or a React component with useful clap tasks for development, building and publishing.

Installation

First, install Yeoman, xclap-cli, and generator-electrode using npm(<we assume you have pre-installed node.js(<> 4.2.x required>)>).

$ npm install -g yo xclap-cli generator-electrode

Note: You may need add sudo to the command.

Then generate your new project:

$ mkdir your-project-name
$ cd your-project-name
$ yo electrode

Note: If the app is not properly generated at the correct destination, make sure you do not have a .yo-rc.json file hidden in your CWD.

Here is a sample screen capture the app generation process.

Running the app

Once the application is generated and npm install is completed, you are ready to try it out.

$ npm start

Wait for webpack to be ready and navigate to http://localhost:3000 with your browser.

You can run [clap] to see the list of tasks available.

Some common ones:

  • clap dev - start in webpack-dev-server development mode
  • clap hot - start in webpack-dev-server hot mode
  • clap build - build production dist files
  • clap server-prod - start server in production mode
  • clap check - run unit tests with coverage

Generating a React Component

Install the generator if you haven't already:

npm install -g generator-electrode

Then run the generator:

yo electrode:component

...and follow the prompts.

Developing Your Component

Source

Your component source code is in packages/componentName/src. You can use JSX and ES6 syntax freely in your component source; it will be transpiled to lib with Babel before being published to npm so that your users will simply be able to include it.

It's a great idea to add a description, documentation and other information to your README.md file, to help people who are interested in using your component.

The component project structure uses a Lerna structure, which can help manage multiple repos within your packages directory. Your initial project structure will be :

test-component/
├── README.md
├── demo-app
│   ├── LICENSE
│   ├── README.md
│   ├── config
│   │   ├── default.js
│   │   ├── development.json
│   │   ├── production.js
│   │   └── production.json
│   ├── xclap.js
│   ├── package.json
│   ├── src
│   │   ├── client
│   │   │   ├── actions
│   │   │   │   └── index.jsx
│   │   │   ├── app.jsx
│   │   │   ├── components
│   │   │   │   └── home.jsx
│   │   │   ├── images
│   │   │   │   └── electrode.png
│   │   │   ├── reducers
│   │   │   │   └── index.jsx
│   │   │   ├── routes.jsx
│   │   │   └── styles
│   │   │       └── base.css
│   │   └── server
│   │       ├── index.js
│   │       └── views
│   │           └── index-view.jsx
│   └── test
│       ├── client
│       │   └── components
│       │       └── home.spec.jsx
│       └── server
├── lerna.json
├── package.json
└── packages
    └── test-component
        ├── README.md
        ├── xclap.js
        ├── package.json
        ├── src
        │   ├── components
        │   │   └── test-component.jsx
        │   ├── index.js
        │   ├── lang
        │   │   ├── default-messages.js
        │   │   ├── en.json
        │   │   └── tenants
        │   │       └── electrodeio
        │   │           └── default-messages.js
        │   └── styles
        │       └── test-component.css
        └── test
            └── client
                └── components
                    ├── helpers
                    │   └── intl-enzyme-test-helper.js
                    └── test-component.spec.jsx

Adding Components to the Repo

The component structure shown above supports multiple packages under the packages folder. You can add another component to your project by running yo electrode:component-add from within the packages directory.

$ cd packages
$ yo electrode:component-add

And follow the prompts.

This will generate a new package and also update the demo-app. The demo-app/src/client/components/home.jsx and demo-app/package.json will be overwritten during the update.

Here is a sample screen capture the component generation process.

Example and Preview

Preview your component by using the demo-app. This is an electrode app which uses your newly created component:

$ cd demo-app
$ clap demo

A webserver will be started on localhost:3000. Your new component will be used in demo-app/src/client/components/home.jsx

You can use this demo-app to test your component, then publish it to let potential users try out your component and see what it can do.

Getting To Know Yeoman

  • Yeoman has a heart of gold.
  • Yeoman is a person with feelings and opinions, but is very easy to work with.
  • Yeoman can be too opinionated at times but is easily convinced not to be.
  • Feel free to learn more about Yeoman.

Built with :heart: by Team Electrode @WalmartLabs.

License

Apache-2.0 © WalmartLabs