@schibstedspain/generator-sui-react
v7.0.1
Published
A generator for react components
Downloads
79
Maintainers
Readme
generator-sui-react
A yeoman generator for Schibsted User Interface (sui) ReactJS components. By using this generator, you can create components to work as a part of a complex application (atoms or mollecules) or stand-alone components, ready for production.. For more information about atomic design, read the following blog post: http://bradfrost.com/blog/post/atomic-web-design/.
Features
The generator provides a basic structure to start developing a component, including coding standard rules, naming conventions and a unit testing suite.
- A basic structure for your component, prepared for publishing in npm or deploying to production
- Automatic installation of all npm dependencies
- Linting rules for all
js
,jsx
,s(c|a)ss
andcss
files - Support for ES2015
- Unit testing suite
- A local development environment with webpack
- A
docs
folder to generate the component's documentation and a deployment task to create a Github page. - A set of pre-commit rules for launching linting and tests before commiting changes in Github
- Common editor config rules
Previous steps
The SUI Generator for React.JS components is a Yeoman generator, so make sure to have already installed Node.JS and Yeoman first:
- Install Node.JS: nodejs.org/download
- Install Yeoman: http://yeoman.io/
You can install yeoman using npm:
$ npm install -g yo
Installation
To install the generator, just type in your terminal:
$ npm install -g @schibstedspain/generator-sui-react
To make sure it's installed correctly, type yo
in your terminal. A list of options should appear, including the installation of the generator:
~ ❯ yo
? 'Allo [your-username]! What would you like to do? (Use arrow keys)
Run a generator
❯ @schibstedspain/sui React
──────────────
Update your generators
Install a generator
Find some help
Get me out of here!
Create your first React.JS component
First of all, let's create a folder for your component in the desired path with:
$ mkdir your-component-name
Once created, enter the folder and aunch the generator by typing:
$ cd your-component-name
$ yo @schibstedspain/sui-react
You will be prompted about the component name, the prefix you want to use and the Github repository url (which you should be created already), and that's it!
Folder structure
The generator will generate the following structure:
├── README.md
├── docs
│ ├── index.html
│ ├── index.jsx
│ └── style.scss
├── package.json
├── src
│ ├── index.jsx
│ ├── index.scss
│ └── sui-test
│ ├── _sui-test.scss
│ └── index.jsx
├── test
│ └── sui-test-test.js
└── webpack.config.js
Publishing
When you are ready to publish your component, a npm package will be generated, including the following folders: A lib
folder with the same structure as the src
folder, but with the js
and jsx
preprocessed with babel
:
lib
├── index.js
├── index.scss
└── component-name
├── _component-name.scss
└── index.js
And a dist
folder, with the js
and css
bundle.
dist
├── index.css
└── index.js
Commands allowed
clean:lib
: cleans thelib
folderclean:dist
: cleans thedist
folderpredist
: executes the tasknpm run clean:dist
dist
: creates ajs
andcss
bundle usingwebpack
prelib
: executes the tasknpm run clean:lib
lib
: executes both tasksnpm run lib:scripts
andnpm run lib:styles
lib:scripts
: transpiles the code in thesrc
folder usingbabel
and outputs the result in thelib
folderlib:styles
: just copies the.scss
files from thesrc
folder to thelib
folderprepublish
: executes both tasksnpm run lib
andnpm run dist
lint
: executes both tasksnpm run lint:eslint
andnpm run lint:sass
lint:eslint
: lints your javascript files usingeslint
lint:sass
: lints your sass style files usingsass-lint
test
: executes your tests usingmocha
test:watch
: executes the tasknpm run test
in watch mode, watching for changes in your source filesstart
: executes bothnpm run start:open
andnpm run start:server
start:server
: launcheswebpack-dev-server
in http://localhost:8080 with your application runningstart:open
: opens a browser with http://localhost:8080predoc
: cleans yourdocs/dist
folderdoc
: executesnpm run dist
,npm run doc:copy
andnpm run doc:publish
tasksdoc:copy
: copies the files generated in thedist
folder into yourdocs
folderdoc:publish
: publishes your documentation in your repository's Github pagephoenix
: cleans yournode_modules
folder and launchesnpm install
to restore all your dependencies