-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Add object enum #36
Add object enum #36
Conversation
felipeplets
commented
Apr 5, 2020
- This PR depends on Adopt DRY principle and enhance performance #35
- This implement an enum like object in order to suffice the discussion in Enable the type to be an enumerator instead of a type. #25
export type ${iconTypeName} = ${svgDefinitions | ||
.map(({ typeName }, index) => `'${typeName}'${index === svgDefinitions.length - 1 ? '' : ' | '}`) | ||
.join('')};`; | ||
const typeObject = ` |
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 means that currently, we would always generate both, an object for iteration and also a type and there's no option to disable it. I am just thinking of the best way to do this.
I personally would prefer to generate types by default. Then I would also offer the possibility to generate only the const or const and type. Some options like this
generateTypes: boolean (default: true);
generateTypeObject:boolean (default: false);
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.
@felipeplets what do you think?
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.
I like the idea. Will push the change later today.
@kreuzerk the options are created and work as we aligned. The only point is that reading about commander I understood that to work as a boolean you can set Also if --generateTypeObject is defined it will always generate the type as the object need it. |
src/lib/options/args-collector.ts
Outdated
@@ -10,6 +10,8 @@ export const setupCommander = () => { | |||
commander | |||
.version(packgeJSON.version) | |||
.option('-t --typeName <string>', 'name of the generated enumeration type', DEFAULT_OPTIONS.typeName) | |||
.option('--no-generateType', 'prevent generating enumeration type', DEFAULT_OPTIONS.generateType) |
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.
--generateType instead of --no-generateType
README.md
Outdated
@@ -201,6 +201,8 @@ Available configurations: | |||
| --version | type | default | output the version number | | |||
| ------------------------- | ----------------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | |||
| typeName | string | myIcons | name of the generated type | | |||
| no-generateType | boolean | false | prevent generating enumeration type | |
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.
generateType
instead of no-generateType
and it defaults to true
); | ||
return typeHeader + types.join(''); | ||
|
||
if (convertionOptions.generateType || convertionOptions.generateTypeObject) { |
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.
I would remove the or check - I would say that the user should be able to generate either a type or an object or both.
Sorry, I just saw your comment now. All my comments in the PR correspond to your comment. 😅 I would still prefer to have the public flags like discussed. Users could still set the Why are the types needed if you generate the options? |
Actually we can generate the object with the type, it's just less strict but can be done. I will change the code accordingly. |
Regarding the config parameters, I've read the guide from commander before implementing and had a couple of findings that I would address in another PR, but I can list them bellow because I believe they can be beneficial to this topic. The commander way of setting boolean parameters is:
I understand this is different from Angular CLI syntax, which uses it's own parser: https://github.com/angular/angular-cli/blob/master/packages/angular/cli/models/parser.ts If we want to implement following the same Angular syntax Also If you agree I can change this implementation to parse the same way Angular parses, have them both as |
@felipeplets Wow! Thanks a lot for that detailed explanation. 👍 Didn't know about this commander conventions. I would prefer to parse them in the way Angular parses them. I think most developers are familiar with the Angular way and less with the commander way. |
So, this means that once we change the parsing to the way Angular parses we have to do a breaking change? Are there still changes open for this branch or are we good to merge? |
I don't see any breaking change.
|
👍 So in order to merge this PR I would still adjust the following points:
|
That is right @kreuzerk , this week is a bit busy for me so I will only be able to implement the changes over the weekend. |
@felipeplets no stress - I can also help if you want - just let me know |
@kreuzerk I've implemented the changes we agreed. |
@felipeplets Awesome will go through them today and release the version today. Thanks a lot for the great work 👍 |
🎉 This PR is included in version 4.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |