boilersuit
Advanced tools
Comparing version 0.1.14 to 0.1.15
@@ -22,4 +22,5 @@ const Parser = require('../../tools/parser'); | ||
transforms(buffer, [ | ||
/** Adds in boilerplate if domain does not exist */ | ||
ensureImport('fromJS', 'immutable', { destructure: true }), | ||
/** Adds in boilerplate if domain does not exist */ | ||
ensureImport('combineReducers', 'redux', { destructure: true }), | ||
b => { | ||
@@ -63,3 +64,2 @@ const index = b.lastIndexOf('export default'); | ||
}, | ||
ensureImport('combineReducers', 'redux', { destructure: true }), | ||
/** Adds actions */ | ||
@@ -66,0 +66,0 @@ b => { |
@@ -10,2 +10,5 @@ const { | ||
transforms(buffer, [ | ||
ensureImport('takeLatest', 'redux-saga/effects', { destructure: true }), | ||
ensureImport('call', 'redux-saga/effects', { destructure: true }), | ||
ensureImport('put', 'redux-saga/effects', { destructure: true }), | ||
b => { | ||
@@ -20,9 +23,4 @@ const index = b.indexOf('{', b.indexOf('export default function*')) + 1; | ||
}, | ||
ensureImport(actionCases.constant, './constants', { destructure: true }), | ||
ensureImport('takeLatest', 'redux-saga/effects', { destructure: true }), | ||
ensureImport('call', 'redux-saga/effects', { destructure: true }), | ||
ensureImport('put', 'redux-saga/effects', { destructure: true }), | ||
b => { | ||
const sagaPresent = | ||
b.indexOf(`export function* ${cases.camel}`) !== -1; | ||
const sagaPresent = b.indexOf(`export function* ${cases.camel}`) !== -1; | ||
if (sagaPresent) { | ||
@@ -54,6 +52,10 @@ console.log( | ||
` */`, | ||
`export function* ${cases.camel}(${action.payload ? '{ payload }' : ''}) {`, | ||
`export function* ${cases.camel}(${ | ||
action.payload ? '{ payload }' : '' | ||
}) {`, | ||
` let data = '';`, | ||
` try {`, | ||
` data = yield call(${cases.camel}AjaxCall${action.payload ? ', payload' : ''});`, | ||
` data = yield call(${cases.camel}AjaxCall${ | ||
action.payload ? ', payload' : '' | ||
});`, | ||
` } catch (err) {`, | ||
@@ -75,3 +77,4 @@ ` console.log(err); // eslint-disable-line`, | ||
}, | ||
ensureImport(actionCases.constant, './constants', { destructure: true }), | ||
prettify, | ||
]); |
@@ -8,3 +8,3 @@ #!/usr/bin/env node | ||
program.version('0.1.14'); | ||
program.version('0.1.15'); | ||
@@ -11,0 +11,0 @@ program.command('up').action(() => { |
{ | ||
"name": "boilersuit", | ||
"description": "A CLI tool for generating selectors, reducers, actions, constants and sagas in react-boilerplate", | ||
"version": "0.1.14", | ||
"version": "0.1.15", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "author": "matt <matt.pocock@thevirtualforge.com>", |
@@ -73,6 +73,11 @@ const concat = array => array.filter(line => line !== null).join(`\n`); | ||
if (!hasImportsFromFileName) { | ||
const firstImportLineIndex = buffer.lastIndexOf('import'); | ||
/** We need to know if there are any imports. If not, add it to the top of the file */ | ||
const hasPrevImports = buffer.indexOf('import') !== -1; | ||
let index = 0; | ||
if (hasPrevImports) { | ||
index = buffer.lastIndexOf('import'); | ||
} | ||
if (destructure) { | ||
return ( | ||
buffer.slice(0, firstImportLineIndex) + | ||
buffer.slice(0, index) + | ||
concat([ | ||
@@ -82,3 +87,3 @@ `import {`, | ||
`} from '${fileName}';`, | ||
buffer.slice(firstImportLineIndex), | ||
buffer.slice(index), | ||
]) | ||
@@ -88,5 +93,5 @@ ); | ||
return concat([ | ||
buffer.slice(0, firstImportLineIndex), | ||
buffer.slice(0, index), | ||
`import ${property} from '${fileName}'; // @suit-line`, | ||
buffer.slice(firstImportLineIndex), | ||
buffer.slice(index), | ||
]); | ||
@@ -93,0 +98,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
313439
3540