Skip to content

Conversation

@thorbenprimke
Copy link
Collaborator

Summary:
This adds support for generating the maven package similar to how
React Native core does it.
This allows a brownfield Android project reference this maven package
instead of the project in the node_modules.

This also adds a few new fields to package.json. Do y'all think it's okay to have placeholder values or should I add the ability to provide them to the cli?

@thorbenprimke
Copy link
Collaborator Author

I have updated this PR with config options for the author's github, name and email.
The README is updated as well.

Testing:

  • Verified that placeholders are used with: ./react-native-create-library/cli.js AweDsdTest1
  • Verified that actual values are used with: ./react-native-create-library/cli.js AweDsdTest1 --author-github=thorbenprimke --author-name='Thorben Primke' --author-email='first@lastname.com'

Copy link
Owner

@frostney frostney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great pull request 👍
Looking at this, it would be great to have an interactive mode. Obviously totally out of the scope of this pull request, but do what you think about this idea in general?

return `
{
"name": "${moduleName}",
"title": "${moduleName.split('-').map(word => word[0].toUpperCase() + word.substr(1)).join(' ')}",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we need this property here or if we could prepare this in the templates/android.js file instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I placed it into package.json on purpose. It may only be used by the Android maven config at this time, but for the sake of consistency I think it's good to have it here so that all config values that feed into the maven config can be changed in one place.

"name": "${authorName}",
"email": "${authorEmail}"
},
"license": "Apache-2.0",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Do we need to hardcode the license? Could we get that as a command-line parameter or default value as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Fair point I'll make it configurble as well. 💯

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}
repositories {
maven {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changeset is also in #51, right? 🙂

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it should be gone after #51 or #39 is merged and I rebase. It's necessary in order for the project to build.

const DEFAULT_PLATFORMS = ['android', 'ios', 'windows'];
const DEFAULT_OVERRIDE_PREFIX = false;
const DEFAULT_AUTHOR_GITHUB = 'github_account_name'
const DEFAULT_AUTHOR_NAME = 'Your Name'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be out of the scope of this pull request, but do you think it would be possible to get the default values from the global Git config?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, probably out of scope for this PR but I don't see a reason why that is not possible. Basically we could first default to the git config --global user.name (as well as email) and if those are not set, then only use these secondary default values.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree we should file an issue for it and follow up. Would be a good starter task too imho.

Copy link
Collaborator Author

@thorbenprimke thorbenprimke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestions @frostney - I'll get this PR updated.

const DEFAULT_PLATFORMS = ['android', 'ios', 'windows'];
const DEFAULT_OVERRIDE_PREFIX = false;
const DEFAULT_AUTHOR_GITHUB = 'github_account_name'
const DEFAULT_AUTHOR_NAME = 'Your Name'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, probably out of scope for this PR but I don't see a reason why that is not possible. Basically we could first default to the git config --global user.name (as well as email) and if those are not set, then only use these secondary default values.

}
repositories {
maven {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it should be gone after #51 or #39 is merged and I rebase. It's necessary in order for the project to build.

return `
{
"name": "${moduleName}",
"title": "${moduleName.split('-').map(word => word[0].toUpperCase() + word.substr(1)).join(' ')}",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I placed it into package.json on purpose. It may only be used by the Android maven config at this time, but for the sake of consistency I think it's good to have it here so that all config values that feed into the maven config can be changed in one place.

"name": "${authorName}",
"email": "${authorEmail}"
},
"license": "Apache-2.0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Fair point I'll make it configurble as well. 💯

Summary:
This adds support for generating the maven package similar to how
React Native core does it.
This allows a brownfield Android project reference this maven package
instead of the project in the node_modules.
@thorbenprimke
Copy link
Collaborator Author

@maicki - mind giving this PR a look?

Copy link
Contributor

@maicki maicki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

const DEFAULT_PLATFORMS = ['android', 'ios', 'windows'];
const DEFAULT_OVERRIDE_PREFIX = false;
const DEFAULT_AUTHOR_GITHUB = 'github_account_name'
const DEFAULT_AUTHOR_NAME = 'Your Name'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree we should file an issue for it and follow up. Would be a good starter task too imho.

},
"repository": {
"type": "git",
"url": "git+https://github.com/${authorGithub}/${moduleName}.git",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the url for the repository is at a different place as at the authors github username. Thinking off such libs that are under a organization.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I considered that. Perhaps the naming should be changed to githubAccount or hostingGithubAccount.

I guess that brings up the next thing which is what if you use bitbucket or another service. I think this template / generator will serve most needs out of the box but in some cases a little modification may be necessary as it otherwise would make the options too complex.

@thorbenprimke thorbenprimke merged commit db4549a into frostney:master Mar 17, 2018
@thorbenprimke thorbenprimke deleted the android_maven branch March 17, 2018 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants