Product
Introducing Socket Optimize
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.
boilersuit
Advanced tools
A CLI tool for generating selectors, reducers, actions, constants and sagas in react-boilerplate
npm i boilersuit
Add "suit": "suit up"
to the "scripts"
object in your package.json.
npm i -g boilersuit
Once it's installed, go into the folder of a container and add a suit.json
file.
suit.json
files always belong in the FOLDER OF THE CONTAINER YOU WANT TO SUIT UP - alongside index.js, reducers.js, actions.js etc.
actions.js
constants.js
index.js
reducer.js
saga.js
selectors.js
suit.json
This file acts as the manifest for boilersuit to make changes. Copy the one below if you fancy it.
Once it's set up, run suit up
in the root directory of your project. It will watch for changes in any suit.json file and reflect those changes in the surrounding container.
// suit.json
{
"getFields": {
"initialState": {
"isLoading": false,
"hasSucceeded": true,
"data": null,
"errorMessage": "",
"hasError": false
},
"actions": {
"getFieldsStarted": {
"saga": true,
"payload": true,
"passAsProp": true,
"set": { "isLoading": true }
},
"getFieldsFailed": {
"set": {
"isLoading": false,
"errorMessage": "payload",
"hasError": true
}
},
"getFieldsSucceeded": {
"set": {
"isLoading": false,
"hasError": false,
"hasSucceeded": true,
"data": "payload"
}
}
}
}
}
Run this command in the root directory of your project. This will recursively check for changes in any directory below it.
Usage: suit up
Either generates or adds an ajax call to a suit.json.
Usage: suit ajax <folder> <name>
Example: suit ajax app/containers/HomePage getPosts
This is an object which defines the initial data structure of the reducer's state.
{
"initialState": {
"isLoading": false,
"hasSucceeded": true,
"data": null,
"errorMessage": "",
"hasError": false
}
}
type: object
Defines how you want the data to be changed after the action is run.
{
"actions": {
"getFieldsStarted": {
"set": { "isLoading": true }
}
}
}
type: bool
Whether or not you want the action to carry a payload.
{
"actions": {
"getFieldsStarted": {
"payload": true,
"set": { "isLoading": true }
}
}
}
type: bool
Whether or not you want to pass this action to the container component as a dispatch.
{
"actions": {
"getFieldsStarted": {
"passAsProp": true,
"set": { "isLoading": true }
}
}
}
type: bool
Whether or not you want to generate a saga that is fired from this action.
Sagas are interesting in boilersuit - because they are so complex, and can be used in so many divergent ways, we don't control them in the same way that we do with other files. Specifying "saga": true
on an action will generate some boilerplate in the sagas file which you will then have to customise and manage.
{
"actions": {
"getFieldsStarted": {
"saga": true,
"set": { "isLoading": true }
}
}
}
FAQs
A CLI tool for generating selectors, reducers, actions, constants and sagas in react-boilerplate
The npm package boilersuit receives a total of 2 weekly downloads. As such, boilersuit popularity was classified as not popular.
We found that boilersuit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.
Product
We're excited to announce that Socket now supports the Java programming language.
Security News
Socket detected a malicious Python package impersonating a popular browser cookie library to steal passwords, screenshots, webcam images, and Discord tokens.