Skip to content
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

fix(android): fix JS error when RN version is a github URL #38

Closed
wants to merge 5 commits into from

Conversation

douglowder
Copy link

What:

In file-operations.js parseFile(), validate the RN version string before doing the version check.

Why:

A developer using this tool will see a crash if importing react-native directly from github instead of using a release version.

How:

See changes in file-operations.js

Checklist:

package.json Outdated
"dependencies": {
"babel-runtime": "^6.20.0",
"compare-versions": "^3.0.1",
"inquirer": "^2.0.0",
"is-valid-path": "^0.1.1",
"jest-cli": "^21.2.1",
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this necessary?

Copy link
Author

Choose a reason for hiding this comment

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

It was needed in my environment.

@jarretmoses
Copy link
Collaborator

This is a nice catch. There seems to be some overlap with #37. Maybe we can combine the 2.

@douglowder
Copy link
Author

@jarretmoses if you want to add the fix and the new test to #37 that is fine with me

@jarretmoses
Copy link
Collaborator

@dlowder-salesforce I think separate is fine. Mine is actually a WIP when I can get back to fixing 1 thing. This PR shows a nice way of handling the tests though thanks!

@jarretmoses
Copy link
Collaborator

@dlowder-salesforce please fix merge conflicts.

@douglowder
Copy link
Author

@jarretmoses merge conflicts resolved, tests are passing

@@ -1,6 +1,7 @@
const path = require("path");
const fs = require("mz/fs");
const compareVersions = require("compare-versions");
const validate = require("compare-versions");
Copy link
Collaborator

Choose a reason for hiding this comment

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

@dlowder-salesforce There looks to be a duplicate import here. This package is being imported above.

@@ -17,9 +17,15 @@ function readFile(file, readDirPath) {
function parseFile(fileData, { templateName, packageName, app, rnVersion }) {
let kotlinPackage;
let javaPackage;

var version = rnVersion;
debugger;
Copy link
Collaborator

Choose a reason for hiding this comment

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

@dlowder-salesforce this should be removed

Copy link
Author

Choose a reason for hiding this comment

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

oops sorry

// TODO: figure out a better way to handle one off breaking changes
if (rnVersion && compareVersions(rnVersion, "0.47.2") < 0) {
if (version && compareVersions(version, "0.47.2") < 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@dlowder-salesforce I am realizing that your version check just validates a github repo as a valid source, however you don't get the actual version from it. How will compareVersions work since I don't see support for github repos in the package.

Copy link
Author

Choose a reason for hiding this comment

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

Actually a github repo string will fail the validation check, so version will be set to null in that case.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see...so I am actually wondering if this PR will cover this issue too and just needs a test https://github.com/peggyrayzis/react-native-create-bridge/pull/37/files

Copy link
Author

Choose a reason for hiding this comment

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

Yeah that looks like a similar fix

Copy link
Collaborator

Choose a reason for hiding this comment

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

@dlowder-salesforce Since there are redundancies Im going to add add you test into the other PR and make sure it is still working as expected. I'll add you as a reviewer when it's done.

Copy link
Author

Choose a reason for hiding this comment

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

@jarretmoses sounds good, I'll close this PR then

@douglowder douglowder closed this Feb 16, 2018
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.

2 participants