-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
231 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const generateAction = require('../fileTypes/action.js'); | ||
const generateBase = require('../fileTypes/base.js'); | ||
const generateComponent = require('../fileTypes/component.js'); | ||
const generateReducer = require('../fileTypes/reducer.js'); | ||
const generateStore = require('../fileTypes/store.js'); | ||
const generateUtil = require('../fileTypes/util.js'); | ||
|
||
const generator = (type, name, actions) => { | ||
|
||
switch(type) { | ||
case (type.match(/reducers?/) || {}).input: | ||
generateReducer(name, actions); | ||
break; | ||
case (type.match(/stores?/) || {}).input: | ||
generateStore(); | ||
break; | ||
case (type.match(/actions?/) || {}).input: | ||
generateAction(name, actions); | ||
break; | ||
case (type.match(/utils?/) || {}).input: | ||
generateUtil(name, actions); | ||
break; | ||
case (type.match(/components?/) || {}).input: | ||
generateComponent(name, actions); | ||
break; | ||
case (type.match(/bases?/) || {}).input: | ||
generateBase(name); | ||
generateStore(); | ||
break; | ||
} | ||
|
||
} | ||
|
||
module.exports = generator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const fs = require('fs'); | ||
|
||
const logFunctions = require('../helpers/logs.js'); | ||
|
||
// function to delete a single file | ||
const deleteFile = (path) => { | ||
fs.unlink(path, function(err) { | ||
if (err) { | ||
logFunctions.noExistFileErrorLog(path); | ||
} else { | ||
logFunctions.removedFileLog(path); | ||
} | ||
}); | ||
} | ||
|
||
const removeFile = (type, name) => { | ||
if(type[type.length -1] === 's') { | ||
type = type.slice(0, type.length - 1); | ||
} | ||
|
||
if (type === 'component') { | ||
let componentPath = `frontend/components/${name}/${name}.jsx`; | ||
let containerPath = `frontend/components/${name}/${name}_container.jsx`; | ||
deleteFile(containerPath); | ||
deleteFile(componentPath); | ||
} else { | ||
let fileEnding = type; | ||
if (type === 'action') { | ||
fileEnding += 's'; | ||
} | ||
let path = `frontend/${type}s/${name}_${fileEnding}.js`; | ||
deleteFile(path); | ||
} | ||
} | ||
|
||
const remover = (type, name) => { | ||
if( /bases?/.test(type) ) { | ||
deleteFile(`frontend/${name}.jsx`); | ||
deleteFile(`frontend/components/app.jsx`); | ||
deleteFile(`frontend/components/root.jsx`); | ||
deleteFile(`frontend/store/store.js`); | ||
} else { | ||
path = removeFile(type, name); | ||
} | ||
} | ||
|
||
module.exports = remover; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## New features in version 1.1 | ||
- [Component](docs/component.md) generator can accept `-f`/`--functional` and `-nc`/`--no-container` flags. | ||
- When generating `root_reducer.js`, all existing [reducers](docs/reducer.md) will be imported and added to `combineReducers`. | ||
- `root_reducer.js` will update with import statement and key-value pairs whenever a new [reducer](docs/reducer.md) is created. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.