frostney / react-native-create-library

:notebook: Command line tool to create a React Native library with a single command
MIT License
1.45k stars 114 forks source link

Please don't include the prefix in the name #5

Closed stereodenis closed 7 years ago

stereodenis commented 8 years ago
react-native-create-library DFP      
/usr/local/lib/node_modules/react-native-create-library/lib.js:25
    throw new Error('Please don\'t include the prefix in the name');
    ^

Error: Please don't include the prefix in the name
    at module.exports (/usr/local/lib/node_modules/react-native-create-library/lib.js:25:11)
    at Object.<anonymous> (/usr/local/lib/node_modules/react-native-create-library/cli.js:30:1)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.runMain (module.js:575:10)
    at run (bootstrap_node.js:352:7)
    at startup (bootstrap_node.js:144:9)
frostney commented 8 years ago

Hi @stereodenis, thank you for creating an issue. Currently there is a check in place for uppercase characters as the first two characters of the module to avoid developers including a prefix by accident. Is there any way you could not use an abbreviation for your module name? Something like react-native-create-library MyFancyModule instead of react-native-create-library MFM?

Traviskn commented 8 years ago

This is also an issue for me, I am attempting to create a library wrapping the native iOS/Android UUID generators but getting blocked when I try to run react-native-create-library UUIDGenerator. Perhaps there could be a flag to override the prefix check?

frostney commented 8 years ago

@Traviskn: Good point. I agree with passing in an additional option to override the prefix check. I'll try to get that done within the next few hours.

Traviskn commented 8 years ago

@frostney Sounds great! No rush though, I made some manual adjustments to utils/hasPrefix.js to work around for now. Correct me if I'm wrong, but it seems to be the 'RN' prefix specifically we want to guard against, maybe a more specific check for that would work as well?

rigdern commented 7 years ago

@frostney I hit this as well when attempting to create a library with the name "SQLite". What if we change hasPrefix to check if name starts withprefix? That way an error would only get reported if the module name really started with the prefix you are currently using. It would no longer falsely error when a module name begins with a couple of uppercase letters.

frostney commented 7 years ago

I just published version 1.2.0 which allows to override the prefix check with --override-prefix if using the command line. This disables the prefix checking for the name as well as the core module prefix check. Use with caution obviously 🙂

Please let me know if this fixes the issues and re-open if it does not or create a new issue.