Skip to content

changes link file on Android to MainApplication.java for 0.29 update#8612

Closed
GantMan wants to merge 5 commits into
react:masterfrom
GantMan:fix_npm_link
Closed

changes link file on Android to MainApplication.java for 0.29 update#8612
GantMan wants to merge 5 commits into
react:masterfrom
GantMan:fix_npm_link

Conversation

@GantMan

@GantMan GantMan commented Jul 6, 2016

Copy link
Copy Markdown
Contributor

rnpm aka react-native link is broken with Android 0.29 - #8603

This gets it back to working again by checking for new MyApplication.java file, and curtailing the path when needed.

@ghost

ghost commented Jul 6, 2016

Copy link
Copy Markdown

By analyzing the blame information on this pull request, we identified @grabbou to be a potential reviewer.

@ghost ghost added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Jul 6, 2016
@GantMan

GantMan commented Jul 6, 2016

Copy link
Copy Markdown
Contributor Author

note, the methodology for checking the file is the latest method: http://stackoverflow.com/questions/4482686/check-synchronously-if-file-directory-exists-in-node-js

@satya164

satya164 commented Jul 6, 2016

Copy link
Copy Markdown
Contributor

cc @Kureev

@Kureev

Kureev commented Jul 6, 2016

Copy link
Copy Markdown
Contributor

Hi @GantMan! Thanks for proposing this PR! I have a few small questions in order to process it faster :)
As I see, you're checking for a MainApplication.java and "roll back" to MainActivity.java in a case if it's not found. But taking into account that rnpm is now a part of react-native cli, I don't think we have any reasons to maintain previous versions. Does it make any sense?

@GantMan

GantMan commented Jul 6, 2016

Copy link
Copy Markdown
Contributor Author

Hi @Kureev! My guess use case where someone would care is this: "I created project X in RN 0.28 and I created project Y in 0.29". I should be able to still work on my 0.28 project and even use react-native link to add new features to it. It shouldn't break functionality on my non-updated project. I might have good reason for not bringing it to 0.29 just yet.

@satya164

satya164 commented Jul 6, 2016

Copy link
Copy Markdown
Contributor

May be support old versions for few releases and then drop the support.

@GantMan

GantMan commented Jul 6, 2016

Copy link
Copy Markdown
Contributor Author

Yeah, ideal would be 3 phases.

  1. this goes through as hotfix.
  2. deprecate, and warn
  3. remove

I'm happy to help with all 3 steps.

@Kureev

Kureev commented Jul 7, 2016

Copy link
Copy Markdown
Contributor

@GantMan For your case with 0.28 & 0.29: if I understand correctly, app scaffolded by 0.28 will have a react-native@0.28 with current react-native link implementation under the hood. Same is fair for 0.29: it'll have a new 0.29 react-native with new link for MainApplication. The only controversial point is about react-native upgrade. Does it convert your MainActivity to MainApplication? If so, then I don't see a reason why we need prev. versions.

If 0.28 to 0.29 migration by using react-native upgrade wouldn't rename MainActivity to MainApplication, then we need to add it as a part of the migration (which is a desired behavior imo) or support N releases behind the last one (for react-native link).

userConfig.mainApplicationPath || `src/main/java/${packageFolder}/MainApplication.java`
);

fs.accessSync(mainApplicationPath, fs.F_OK, function(err) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There should be no callback (it's Sync):

try {
  fs.accessSync(mainApplicationPath, fs.F_OK);
} catch (e) {
  //...error
}
//...success

@satya164

satya164 commented Jul 7, 2016

Copy link
Copy Markdown
Contributor

if I understand correctly, app scaffolded by 0.28 will have a react-native@0.28 with current react-native link implementation under the hood

@Kureev is right. I forgot that the cli just forwards the commands to locally installed react-native. So we should not need check for older versions in the code.

@GantMan

GantMan commented Jul 7, 2016

Copy link
Copy Markdown
Contributor Author

I will update accordingly, you'll see code soon :)

@GantMan

GantMan commented Jul 7, 2016

Copy link
Copy Markdown
Contributor Author

@Kureev and @satya164 - Thanks for the feedback.

I wasn't sure what the userConfig variable should be, but I figured consistency with the internal name would be best. We don't want users setting userConfig.mainActivityPath and thinking that's correct.

I did a quick test, and upgrade from 0.28-> 0.29 does NOT create the application file. It's set as manual steps in the release: https://github.com/facebook/react-native/releases/tag/v0.29.0

@satya164

satya164 commented Jul 7, 2016

Copy link
Copy Markdown
Contributor

@GantMan Can you also update the commit title to reflect the actual change?

@GantMan GantMan changed the title adds check for 0.29 MainApplication.java changes link file on Android to MainApplication.java for 0.29 update Jul 7, 2016
@satya164

satya164 commented Jul 7, 2016

Copy link
Copy Markdown
Contributor

@GantMan Yes, react-native upgrade doesn't work for 0.28 -> 0.29 and it'll probably be very complex to fix this since we're using yeoman for this.

@GantMan

GantMan commented Jul 7, 2016

Copy link
Copy Markdown
Contributor Author

@satya164 - title is updated.

Hah yes, yeoman is quite tricky. Fortunately it's a separate concern. I was just checking for @Kureev as he seemed to inquire specifically on this upgrade path. Let me know if there's more on this ticket that needs attention.

@Kureev

Kureev commented Jul 7, 2016

Copy link
Copy Markdown
Contributor

I don't think there is anything else. Seems you covered everything, @GantMan 😉

@Kureev

Kureev commented Jul 7, 2016

Copy link
Copy Markdown
Contributor

So, I'm going to check it on my local machine today and if everything is fine, I'm about to merge it

@grabbou

grabbou commented Jul 7, 2016

Copy link
Copy Markdown
Contributor

Great work! I like it. Another thing is that we remove mainActivityPath now, which could potentially break plugins, but since there's no need to use main activity anymore on the Android side, I think it's fine.

@Kureev

Kureev commented Jul 8, 2016

Copy link
Copy Markdown
Contributor

@facebook-github-bot shipit

@ghost

ghost commented Jul 8, 2016

Copy link
Copy Markdown

Thanks for importing. If you are an FB employee go to Phabricator to review.

@ghost ghost closed this in c3f4d79 Jul 8, 2016
@grabbou

grabbou commented Jul 10, 2016

Copy link
Copy Markdown
Contributor

@mkonicek shall we release a 0.29.1 and also cherry-pick that into 0.30rc? @Kureev

@satya164

Copy link
Copy Markdown
Contributor

@grabbou There was a bug in InteractionManager which we should also include. cc @sahrens

@grabbou

grabbou commented Jul 10, 2016

Copy link
Copy Markdown
Contributor

@satya164 into the 0.29 or 0.30 branch?

@satya164

Copy link
Copy Markdown
Contributor

@grabbou Both

@grabbou

grabbou commented Jul 10, 2016

Copy link
Copy Markdown
Contributor

Ping me on Messagner later just in case

@satya164

Copy link
Copy Markdown
Contributor

@grabbou Will do. Waiting for @sahrens to push it into OSS. He said the fix is up internally.

@sahrens

sahrens commented Jul 10, 2016

Copy link
Copy Markdown
Contributor

Sorry, still waiting on review. If you need to patch locally, the fix is a one-liner, just change the filter call in TaskQueue#cancelTasks from .filter((queue) => queue.tasks.length > 0); to:

.filter((queue, idx) => (queue.tasks.length > 0 || idx === 0));

grabbou pushed a commit that referenced this pull request Jul 13, 2016
Summary:
rnpm aka `react-native link` is broken with Android 0.29 - #8603

This gets it back to working again by checking for new MyApplication.java file, and curtailing the path when needed.
Closes #8612

Differential Revision: D3533960

fbshipit-source-id: 95d799eaebb26ba1d876c88107ccd2af72427f55
@Kureev

Kureev commented Jul 15, 2016

Copy link
Copy Markdown
Contributor

We missed one change here! Since we renamed mainActivityPath to mainFilePath, it should be also changed in the userConfig object. Want to hotfix, @GantMan?

@Kureev

Kureev commented Jul 15, 2016

Copy link
Copy Markdown
Contributor

Seems this is a real scope of the change: https://github.com/facebook/react-native/search?utf8=%E2%9C%93&q=mainActivityPath. Hopefully, it's just about

find . -name '*.js' -type f -exec sed -i '' 's/mainActivityPath/mainFilePath/g' {} +

@Kureev

Kureev commented Jul 15, 2016

Copy link
Copy Markdown
Contributor

see referenced PR for more info.

@rclai

rclai commented Jul 15, 2016

Copy link
Copy Markdown
Contributor

Glad to know I wasn't insane. When are you guys going to finish fixing this?

@GantMan

GantMan commented Jul 16, 2016

Copy link
Copy Markdown
Contributor Author

Looks good @Kureev.

@rclai - look at PR #8807

Let me know if I can help any further.

@GantMan GantMan deleted the fix_npm_link branch July 16, 2016 00:40
ghost pushed a commit that referenced this pull request Jul 16, 2016
Summary:
Attempt to fix #8612

We re-named `mainActivityPath` by `mainFilePath` in the `link` code, but we forgot to rename config parameters. Currently, link is broken.

- [x] `react-native link` should work for react-native 0.29+
Closes #8807

Differential Revision: D3576176

fbshipit-source-id: 60ecbd660563923696bbef1ed3b0900a7d58469f
grabbou pushed a commit that referenced this pull request Jul 17, 2016
Summary:
Attempt to fix #8612

We re-named `mainActivityPath` by `mainFilePath` in the `link` code, but we forgot to rename config parameters. Currently, link is broken.

- [x] `react-native link` should work for react-native 0.29+
Closes #8807

Differential Revision: D3576176

fbshipit-source-id: 60ecbd660563923696bbef1ed3b0900a7d58469f
grabbou pushed a commit that referenced this pull request Jul 21, 2016
Summary:
Attempt to fix #8612

We re-named `mainActivityPath` by `mainFilePath` in the `link` code, but we forgot to rename config parameters. Currently, link is broken.

- [x] `react-native link` should work for react-native 0.29+
Closes #8807

Differential Revision: D3576176

fbshipit-source-id: 60ecbd660563923696bbef1ed3b0900a7d58469f
grabbou pushed a commit that referenced this pull request Jul 21, 2016
Summary:
rnpm aka `react-native link` is broken with Android 0.29 - #8603

This gets it back to working again by checking for new MyApplication.java file, and curtailing the path when needed.
Closes #8612

Differential Revision: D3533960

fbshipit-source-id: 95d799eaebb26ba1d876c88107ccd2af72427f55
grabbou pushed a commit to react-native-community/cli that referenced this pull request Sep 26, 2018
Summary:
rnpm aka `react-native link` is broken with Android 0.29 - #8603

This gets it back to working again by checking for new MyApplication.java file, and curtailing the path when needed.
Closes react/react-native#8612

Differential Revision: D3533960

fbshipit-source-id: 95d799eaebb26ba1d876c88107ccd2af72427f55
grabbou pushed a commit to react-native-community/cli that referenced this pull request Sep 26, 2018
Summary:
Attempt to fix react/react-native#8612

We re-named `mainActivityPath` by `mainFilePath` in the `link` code, but we forgot to rename config parameters. Currently, link is broken.

- [x] `react-native link` should work for react-native 0.29+
Closes react/react-native#8807

Differential Revision: D3576176

fbshipit-source-id: 60ecbd660563923696bbef1ed3b0900a7d58469f
tungdo194 pushed a commit to tungdo194/rn-test that referenced this pull request Apr 28, 2024
Summary:
rnpm aka `react-native link` is broken with Android 0.29 - #8603

This gets it back to working again by checking for new MyApplication.java file, and curtailing the path when needed.
Closes react/react-native#8612

Differential Revision: D3533960

fbshipit-source-id: 95d799eaebb26ba1d876c88107ccd2af72427f55
tungdo194 pushed a commit to tungdo194/rn-test that referenced this pull request Apr 28, 2024
Summary:
Attempt to fix react/react-native#8612

We re-named `mainActivityPath` by `mainFilePath` in the `link` code, but we forgot to rename config parameters. Currently, link is broken.

- [x] `react-native link` should work for react-native 0.29+
Closes react/react-native#8807

Differential Revision: D3576176

fbshipit-source-id: 60ecbd660563923696bbef1ed3b0900a7d58469f
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Import Started This pull request has been imported. This does not imply the PR has been approved.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants