-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix-#64 - Add option to avoid new folder #69
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @kavinkuma6, thanks for taking the time to contribute to GRC! 👏
This pr looks good, just a few minor changes. First, we can remove all the extra logic around checkIsFlat
as it is unnecessary. We can use cmd.flat
directly within the generateComponentUtils.js
file, and it will automatically handle the -f
alias case.
Once those changes are in, I would be more than happy to merge your PR. 😃
src/commands/generateComponent.js
Outdated
@@ -2,10 +2,12 @@ const { | |||
generateComponent, | |||
getComponentByType, | |||
getCorrespondingComponentFileTypes, | |||
checkIsFlat, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the checkIsFlat
import. This function will not be needed as we can use cmd.flat
directly within the generateComponentUtils.js
file, and it will handle the -f
alias for us automatically.
checkIsFlat, |
src/commands/generateComponent.js
Outdated
} = require('../utils/generateComponentUtils'); | ||
|
||
function initGenerateComponentCommand(args, cliConfigFile, program) { | ||
const selectedComponentType = getComponentByType(args, cliConfigFile); | ||
const isFlat = checkIsFlat(args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this line for the reason mentioned above.
const isFlat = checkIsFlat(args); |
src/commands/generateComponent.js
Outdated
@@ -37,7 +40,7 @@ function initGenerateComponentCommand(args, cliConfigFile, program) { | |||
// Component command action. | |||
|
|||
componentCommand.action((componentNames, cmd) => | |||
componentNames.forEach((componentName) => generateComponent(componentName, cmd, cliConfigFile)) | |||
componentNames.forEach((componentName) => generateComponent(componentName, cmd, cliConfigFile, isFlat)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to pass isFlat
to generateComponent
for the reason mentioned above.
componentNames.forEach((componentName) => generateComponent(componentName, cmd, cliConfigFile, isFlat)) | |
componentNames.forEach((componentName) => generateComponent(componentName, cmd, cliConfigFile)) |
src/utils/generateComponentUtils.js
Outdated
@@ -74,7 +74,7 @@ Please make sure you're pointing to the right custom template path in your gener | |||
} | |||
} | |||
|
|||
function componentTemplateGenerator({ cmd, componentName, cliConfigFile }) { | |||
function componentTemplateGenerator({ cmd, componentName, cliConfigFile, isFlat }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function componentTemplateGenerator({ cmd, componentName, cliConfigFile, isFlat }) { | |
function componentTemplateGenerator({ cmd, componentName, cliConfigFile }) { |
src/utils/generateComponentUtils.js
Outdated
@@ -127,13 +127,13 @@ function componentTemplateGenerator({ cmd, componentName, cliConfigFile }) { | |||
} | |||
|
|||
return { | |||
componentPath: `${cmd.path}/${componentName}/${filename}`, | |||
componentPath: `${cmd.path}${isFlat ? '' : `/${componentName}`}/${filename}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
componentPath: `${cmd.path}${isFlat ? '' : `/${componentName}`}/${filename}`, | |
componentPath: `${cmd.path}${cmd.flat ? '' : `/${componentName}`}/${filename}`, |
src/utils/generateComponentUtils.js
Outdated
@@ -303,7 +303,7 @@ Please make sure you're pointing to the right custom template path in your gener | |||
filename = customTemplateFilename; | |||
|
|||
return { | |||
componentPath: `${cmd.path}/${componentName}/${filename}`, | |||
componentPath: `${cmd.path}${isFlat ? '' : `/${componentName}`}/${filename}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
componentPath: `${cmd.path}${isFlat ? '' : `/${componentName}`}/${filename}`, | |
componentPath: `${cmd.path}${cmd.flat ? '' : `/${componentName}`}/${filename}`, |
src/utils/generateComponentUtils.js
Outdated
@@ -329,7 +329,7 @@ const componentTemplateGeneratorMap = { | |||
[buildInComponentFileTypes.LAZY]: componentLazyTemplateGenerator, | |||
}; | |||
|
|||
function generateComponent(componentName, cmd, cliConfigFile) { | |||
function generateComponent(componentName, cmd, cliConfigFile, isFlat) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function generateComponent(componentName, cmd, cliConfigFile, isFlat) { | |
function generateComponent(componentName, cmd, cliConfigFile) { |
src/utils/generateComponentUtils.js
Outdated
@@ -347,6 +347,7 @@ function generateComponent(componentName, cmd, cliConfigFile) { | |||
componentName, | |||
cliConfigFile, | |||
componentFileType, | |||
isFlat, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isFlat, |
src/utils/generateComponentUtils.js
Outdated
function checkIsFlat(args) { | ||
return args.find((arg) => arg.includes('-f') || arg.includes('--flat')); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function checkIsFlat(args) { | |
return args.find((arg) => arg.includes('-f') || arg.includes('--flat')); | |
} |
src/utils/generateComponentUtils.js
Outdated
module.exports = { | ||
generateComponent, | ||
getComponentByType, | ||
getCorrespondingComponentFileTypes, | ||
checkIsFlat, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkIsFlat, |
hey @arminbro, I have done the changes as per your suggestions. Please review them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. Thanks again for contributing, @kavinkuma6.
🎉 This PR is included in version 7.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Added an extra option
-f
or--flat
to create the files in the same folder without creating new folder in the name of the component.This will fix the feature request of #64