Comments (3)
Ahh good catch! Will fix as soon as I have time. Unless you want to submit a PR 😉
from cra-generate.
Hmm.
The Problem
The way I see it this is the order of importance:
- User explicitly
X
via the cli command X
is taken frompackages.json
X
is taken fromdefaultOptions
(inconfig.js
)
Given that X
= whether or not to use semicolons,
Always take the option from 1, if it doesn't exist there than take the option from 2 and so on.
Solutions?
use_semicolons
: user specifies via cli that he wants semicolons
skip_semicolons
: user specifies via cli that he doesn't want semicolons
default
: user wants to use the settings from packages.json
or defaultOptions
Commander boolean flag options:
option('-s, --semi, 'use semicolons)
use_semicolons
:cra-generate -s demo
skip_semicolons
: ... not possible!default
:cra-generate demo
option('--no-semi', 'skip semicolons)
use_semicolons
: ... not possible!skip_semicolons
:cra-generate --no-semi demo
default
:cra-generate demo
option('-s, --semi [bool]', 'either true or false')
use_semicolons
:cra-generate -s true demo
skip_semicolons
:cra-generate -s false demo
default
:cra-generate demo
option('-s, --semicolons, 'use semicolons')
andoption('--no-semi', 'skip semicolons')
use_semicolons
:cra-generate -s demo
skip_semicolons
:cra-generate --no-semi demo
default
:cra-generate demo
Issues
- No way to explicitly state that the user doesn't want semicolons
- No way to explicitly state that the user wants semicolons
- Solves the problem, but isn't really pretty.
- Solves the problem, is prettier, but introduces a new issue
cra-generate -s --no-semi demo
...
And of course we get the same problem for -f
...
What solution would you go with?
Or is there some other better solution that I am missing?
The way I see it solution 3
is the best solution, even though it is quite unusual. People are probably used to boolean flags to work like 1
or 2
. But if we go with either of those, then we have to either always ignore packages.json
or not offer the user to specify all options via cli...
from cra-generate.
I think it would be better to keep certain config values only in package.json
. F.ex. the semicolon thing is something that you want to set globally for the entire project and you don't want any one component behaving differently.
Regarding the --functional
flag. Maybe it should be possible to set a default type in the config, eg functional/classical
and the explicitly pick a type in the cli tool. Eg
{
"craGenerate": {
"defaultType": "functional",
"semi": false
}
}
$ cra-generate --classical FooBar
This way, the semicolon thing will be config/default only, and we'll remove it from the flags list. And the functional flag will now adhere to the config/defaults but can be overridden explicitly if need be.
from cra-generate.
Related Issues (13)
- Add tests
- Improve documentation
- Support TypeScript templates
- Improve code quality
- [RFC] Decouple the CLI and the component templates
- Support creating flow components? HOT 4
- Allow customizable component root dir
- Add Update Notifier
- Skipping css file HOT 2
- Should css file have component name
- It would be nice to create css files with a different extension HOT 1
- Should create a test file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cra-generate.