-
Notifications
You must be signed in to change notification settings - Fork 25k
[CLI] New Library Generator #405
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
Conversation
|
This is awesome!
|
cli.js
Outdated
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.
So, there are multiple things we want to support in the future.
Type:
- Library that is just exposing js functions. We call it API in the docs but I want to find a better name
- Components
Platform:
- ios
- android
Given those, what do you think the command api should look like?
react-native new-library api ios name
react-native new-library component android name
react-native new-library name --type library --platform ios
?
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.
Maybe react-native new-plugin or new-extension
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 think the latter sounds best. How about:
react-native new-libraryreact-native new-component
Both of which could take a --platform option, or just generate a .ios.js and a .android.js file you could delete as appropriate. I think in the spirit of keeping everything cross platform and not instacrashing, it might be better to just generate a stub every time.
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 it, ship it
|
This is precisely the type of pattern I have been looking for :) JG 301.785.6030 :: @moduscreate :: sent from my mobile device ::
|
new-library.sh
Outdated
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.
Can you give more specific steps to teach people how to link it to xcode
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.
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.
Great, I'll wait for #300 to be merged and link to it. Much easier illustrated with some screenshots.
|
Ok - removed the RCT prefix from everything :) Will wait for the docs to be merged around XCode linking instructions, and in the meantime attempt to port both Ruby scripts into Node. |
|
Awesome work, Joe! It's great to have folks like you involved so early with the project.
|
|
👍 I'm looking forward to this getting in to the cli! |
|
Waiting on #440 first, as I have also ported this to Nodejs. Thanks @tadeuzagallo, Will link your documentation. |
|
I used this on #466 :) |
|
So, was there a final decision on the use of Cocoapods? I'm developing a couple of native libraries that have their own dependencies that are available as a pod. Not a huge deal if the native side isn't expected to grow that much, probably best to avoid the complexity. |
[React Native PR #405](facebook/react-native#405)
95f460d to
815383b
Compare
815383b to
65e8b4e
Compare
|
Planning to finish this off tomorrow if you're still interested in merging. cc/@vjeux |
151d478 to
51faf40
Compare
|
Yeah would be awesome, cc @nicklockwood and @sahrens for the review |
51faf40 to
0312c30
Compare
|
Pretty happy with this now, review away when you get time! |
local-cli/new-library.js
Outdated
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.
nit: put showHelp(); on the next line :)
|
It looks good to me. I'm looking at why the unit tests are failing. |
|
Thanks! |
|
Would be nice to update the documentation to mention it as well |
|
👍 @JoeStanton can you write that up? If that's not your kind of thing I can take care of it for you, let me know |
|
Please provide documentation on how to properly use it, perhaps write an article or blog post. I don't understand why it copies here!?
✔ ~/repos/react-projs/FirebaseUI/ios
12:38 $ react-native new-library --name Auth
Command `new-library` unrecognized.Looking at the source, I see it uses Hmm, guess I have to install ✔ ~/repos/react-projs/FirebaseUI/ios
12:42 $ react-native new-library --name Auth
Looks like you installed react-native globally, maybe you meant react-native-cli?
To fix the issue, run:
npm uninstall -g react-native
npm install -g react-native-cliWhat? function newLibrary(libraryName) {
var root = process.cwd();
var libraries = path.resolve(root, 'Libraries');
var libraryDest = path.resolve(libraries, libraryName);I was looking for a convenient way (ie. generator) to facilitate developing custom RN components as separate entities... is there such a generator!? Thanks :)
|
* Zero-cost bindings to TimePickerAndroid * fix response type
* Update scripts to publish react-native-macos-init * Clean up merge markers * Restored ios:macos RNTester parity except for InputAccessoryView. * Revert "Restored ios:macos RNTester parity except for InputAccessoryView." This reverts commit 5a67ae0. * Remove unnecessary android builds and tar file upload. * Fix mouse events Co-authored-by: React-Native Bot <[email protected]>
* List keyboard type decimal-pad as cross platform * BSR: list keyboard type number-pad as cross platform
This PR adds a
react-native new-library <LibraryName>command to the CLI. It's a little rough at the moment, but works pretty well. It does the following:Libraries/LibraryNameLibraries/Sampleinto this dir. This includes an.xcodeprojfile, anRCTLibraryName.h/mwith bridging set up, an iOS implementation and an Android stub.package.jsonfor the module, with areact-nativekeyword. Easing publishing to NPM.It's implemented using the same infrastructure as the
react-native initcommand, now rewritten in Node as of #440.Hopefully this will make it quicker and easier to create small native libraries that can be published to NPM and used as discussed in #230.