react-community / reason-react-native-scripts

BSD 3-Clause "New" or "Revised" License
78 stars 12 forks source link

Add shortcut flag to CRNA for using reason-scripts #4

Open brentvatne opened 7 years ago

brentvatne commented 7 years ago

create-react-native-app MyProject --scripts-version reason-react-native-scripts is fairly verbose and difficult to remember.

We could simplify this to create-react-native-app MyProject --reason

anp commented 6 years ago

Do we also want to do that for the TS, cljs, and scalajs forks?

brentvatne commented 6 years ago

@dikaiosune - if they have their own react-native-scripts then possibly!

anp commented 6 years ago

https://github.com/mathieudutour/create-react-native-app-typescript

anp commented 6 years ago

Can't find the others though.

cem2ran commented 6 years ago

A few proposals:

  1. Rename scripts-version to with, and overload it to match on certain keywords before delegating to getInstallPackage such that reason maps to reason-react-native-scripts, etc. etc.:
const getScriptVersion = arg => {
  const normalized = String(arg).toLowerCase();
  switch(normalized) {
    case 'reason':
    case 'reasonml':
      return 'reason-react-native-scripts'
    case 'typescript':
    case 'ts':
      return 'react-native-scripts-ts'
    default: return arg
  } 
};

createApp(commands[0], !!argv.verbose, getScriptVersion(argv['with'])).then(() => {});

The following: yarn create react-native-app MyProject --with reason reads pretty imo.

This could also be implemented on top of create-react-native-app as a separate library/binary, but seems a bit overkill.

  1. Have a separate argument --language | --kind doing pretty much the same as 1.

  2. Use --reason, --typescript... directly as in my PR.