Comparing version 1.0.3 to 1.0.4
@@ -9,2 +9,3 @@ import program from 'commander' | ||
import handleCreateReduxScreen from '../commands/reduxscreenOptions' | ||
import checkOptions from '../commands/options'; | ||
@@ -42,4 +43,6 @@ export function main () { | ||
} | ||
// const res = await checkOptions(program) | ||
// return; | ||
if(program.export){ | ||
viewQuestions(name, { export: program.export }) | ||
} | ||
viewQuestions(name) | ||
@@ -46,0 +49,0 @@ }) |
@@ -23,3 +23,3 @@ | ||
} | ||
const viewQuestions = (name, res) => { | ||
const viewQuestions = (name, obj) => { | ||
inquirer.prompt([{ | ||
@@ -32,3 +32,3 @@ type: 'list', | ||
}]).then(listAnswers => { | ||
getAnswers(listAnswers, name, res) | ||
getAnswers(listAnswers, name, obj) | ||
}) | ||
@@ -35,0 +35,0 @@ } |
@@ -26,4 +26,13 @@ import ls from '../lib/listFiles' | ||
await replaceFileContentWith(onlineStyleContent, 'Screen', name, createdStyle) | ||
const sPath = handle.getPath(`App/screens/${name}/index.js`) | ||
importInto(sPath.path, `import { ${name.toLowerCase()} } from 'redux-actions'`) | ||
await handle.appendToFile( | ||
'actions = {', // occurance | ||
`${name.toLowerCase()}`, // value to replace | ||
sPath.path // path of file | ||
) | ||
if (comps) { | ||
const sPath = handle.getPath(`App/screens/${name}/index.js`) | ||
map(comps.Components, comp => { | ||
@@ -41,10 +50,10 @@ importInto(sPath.path, `import ${comp.slice(0, -3)} from 'components/${comp.slice(0, -3)}'`) | ||
const impCasesStmt = casses.join(', ') | ||
const createdAction = await createFile('App/redux/actions', `${name}`) | ||
const createdAction = await createFile('App/redux/actions', `${name.toLowerCase()}`) | ||
const onlineActionContent = await getOnlineFileContent('action') | ||
await replaceFileContentWith(onlineActionContent, 'Action', name, createdAction) | ||
await replaceFileContentWith(onlineActionContent, 'Action', name.toLowerCase(), createdAction) | ||
const actionIndexPath = await handle.getPath('App/redux/actions/index.js') | ||
await importInto(`App/redux/actions/${name}.js`, `import { ${impCasesStmt} } from 'redux-types'`, ';') | ||
await importInto(`App/redux/actions/${name.toLowerCase()}.js`, `import { ${impCasesStmt} } from 'redux-types'`, ';') | ||
await handle.appendToFile( | ||
';', | ||
`export * from './${name}'`, | ||
`export * from './${name.toLowerCase()}'`, | ||
actionIndexPath.path, | ||
@@ -57,13 +66,13 @@ ) | ||
const onlineActionContent = await getOnlineFileContent('saga') | ||
const wUpdated = await onlineActionContent.replace('watch()', `watch${name}()`) | ||
const wUpdated = await onlineActionContent.replace('watch()', `watch${name.toLowerCase()}()`) | ||
const sUpdated = await wUpdated.replace('SUCCESS', casses[0]) | ||
const fUpdated = await sUpdated.replace('FAILED', casses[1]) | ||
const tUpdated = await fUpdated.replace('//type', casses[2]) | ||
const weUpdated = await tUpdated.replace('//handle', `handle`) | ||
await handle.writeFileSync(`App/redux/sagas/${name}.js`, JSON.parse(weUpdated)) | ||
const tUpdated = await fUpdated.replace(`'TYPE'`, casses[2]) | ||
// const weUpdated = await tUpdated.replace('//handle', `handle`) | ||
await handle.writeFileSync(`App/redux/sagas/${name.toLowerCase()}.js`, JSON.parse(tUpdated)) | ||
const sagasIndexPath = await handle.getPath('App/redux/sagas/index.js') | ||
await importInto(`App/redux/sagas/${name}.js`, `import { ${impCasesStmt} } from 'redux-types'`, ';') | ||
await importInto(`App/redux/sagas/${name.toLowerCase()}.js`, `import { ${impCasesStmt} } from 'redux-types'`, ';') | ||
await handle.appendToFile( | ||
';', | ||
`import watch${name} from './${name}'`, | ||
`import watch${name.toLowerCase()} from './${name.toLowerCase()}'`, | ||
sagasIndexPath.path | ||
@@ -73,3 +82,3 @@ ) | ||
'yield all([', | ||
`fork(watch${name}),`, | ||
`fork(watch${name.toLowerCase()}),`, | ||
sagasIndexPath.path | ||
@@ -81,10 +90,10 @@ ) | ||
const impCasesStmt = casses.join(', ') | ||
const createdReducer = await createFile('App/redux/reducers', `${name}Reducer`) | ||
const createdReducer = await createFile('App/redux/reducers', `${name.toLowerCase()}Reducer`) | ||
const onlineFile = await getOnlineFileContent('reducer') | ||
await replaceFileContentWith(onlineFile, '', '', createdReducer) | ||
const reducerIndexPath = await handle.getPath('App/redux/reducers/index.js') | ||
await importInto(`App/redux/reducers/${name}Reducer.js`, `import { ${impCasesStmt} } from 'redux-types'`, ';') | ||
await importInto(`App/redux/reducers/${name.toLowerCase()}Reducer.js`, `import { ${impCasesStmt} } from 'redux-types'`, ';') | ||
await handle.appendToFile( | ||
';', // occurance | ||
`import ${name.toLowerCase()} from './${name}Reducer';`, // value to replace | ||
`import ${name.toLowerCase()} from './${name.toLowerCase()}Reducer';`, // value to replace | ||
reducerIndexPath.path // path of file | ||
@@ -91,0 +100,0 @@ ) |
@@ -23,3 +23,3 @@ import _ from 'lodash' | ||
const add = async (path, name) => { | ||
const add = async (path, name, obj) => { | ||
const spin = ora(); | ||
@@ -61,3 +61,3 @@ switch (path) { | ||
} | ||
if (res.export) { | ||
if (obj && obj.export) { | ||
const sPath = handle.getPath(res.export) | ||
@@ -151,3 +151,3 @@ importInto(sPath.path, `import ${name} from 'screens/${name}'`, ';') | ||
';', | ||
`import { watch${name} } from './${name}';`, | ||
`import watch${name} from './${name}';`, | ||
sagasIndexPath.path | ||
@@ -186,6 +186,6 @@ ) | ||
const getAnswers = (list, input) => { | ||
add(list.selected, input) | ||
const getAnswers = (list, input, obj) => { | ||
add(list.selected, input, obj) | ||
} | ||
module.exports = { getAnswers } |
import inquirer from 'inquirer' | ||
const options = [ | ||
{ name: 'Navigation', value: 'App/navigation/AppNavigation.js' } | ||
{ name: 'Routes', value: 'App/navigation/AppNavigation.js' }, | ||
{ name: 'Drawer', value: 'App/navigation/AppNavigation.js' }, | ||
{ name: 'Bottom', value: 'App/navigation/AppNavigation.js' }, | ||
] | ||
@@ -6,0 +8,0 @@ |
@@ -9,3 +9,3 @@ { | ||
}, | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"license": "MIT", | ||
@@ -12,0 +12,0 @@ "dependencies": { |
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
27721
758