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

feat: run app on iOS and Android with a hotkey #1779

Merged

Conversation

TMisiukiewicz
Copy link
Collaborator

Summary:

This PR introduces running an app from terminal using Metro watch mode. The run-ios and run-android commands are running when i or a keys are pressed in the Terminal.

iOS:

Screen.Recording.2022-12-15.at.12.20.56.mov

Android:

Screen.Recording.2022-12-15.at.12.22.34.mov

Test Plan:

  1. Clone the repository and do all the required steps from the Contributing guide
  2. Run yarn start --watchFolders path/to/cloned/cli
  3. Press a to run the app on Android
  4. Press i to run the app on iOS

.readdirSync(`${process.cwd()}`)
.includes('yarn.lock');
logger.info(`Opening the app on ${name === 'i' ? 'iOS' : 'Android'}...`);
execa(isUsingYarn ? 'yarn' : 'npm run', [
Copy link
Member

Choose a reason for hiding this comment

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

We're using npx to run regardless npm/yarn

@liamjones
Copy link
Contributor

Oh, nice! ❤️

Is there potentially a way for "default command line options to use" to be exposed to these commands?

For example, in our mono-repo we have app package.jsons setup like:

{
    "scripts": {
        "android": "react-native run-android --no-jetifier --appIdSuffix 'dev' --port 9081 --active-arch-only",
        "ios": "react-native run-ios --port 9081"
    }
}

So I'm assuming this wouldn't work for us currently - it'd be like running react-native run-android, etc with no parameters?

@TMisiukiewicz
Copy link
Collaborator Author

Oh, nice! ❤️

Is there potentially a way for "default command line options to use" to be exposed to these commands?

For example, in our mono-repo we have app package.jsons setup like:

{
    "scripts": {
        "android": "react-native run-android --no-jetifier --appIdSuffix 'dev' --port 9081 --active-arch-only",
        "ios": "react-native run-ios --port 9081"
    }
}

So I'm assuming this wouldn't work for us currently - it'd be like running react-native run-android, etc with no parameters?

hi @liamjones , thanks for your comment! Since the user might not have android and ios commands at all, using npx react-native run-ios/android under the hood seems like a better option there. Unfortunately, it also means the script is going to run with the default options. I'm going to think if there is any possibility to make it work the way you want, happy to hear any suggestions if anyone has an idea!

@liamjones
Copy link
Contributor

@TMisiukiewicz yeah, I appreciate most people probably(?) just use the default commands. 😄

I'm going to think if there is any possibility to make it work the way you want, happy to hear any suggestions if anyone has an idea!

Maybe defaults could be configured via the react-native.config.js? I can see that requiring more discussion/being a bigger change so maybe that should be saved for another time/PR? 🤔 I don't want to hold this up and potentially generate a bunch of extra work for something that will already be useful to a lot of people in its current state.

@adamTrz
Copy link
Collaborator

adamTrz commented Dec 20, 2022

@TMisiukiewicz yeah, I appreciate most people probably(?) just use the default commands. 😄

I'm going to think if there is any possibility to make it work the way you want, happy to hear any suggestions if anyone has an idea!

Maybe defaults could be configured via the react-native.config.js? I can see that requiring more discussion/being a bigger change so maybe that should be saved for another time/PR? 🤔 I don't want to hold this up and potentially generate a bunch of extra work for something that will already be useful to a lot of people in its current state.

Super agree this would be useful :)

@adamTrz adamTrz merged commit c58e5b9 into react-native-community:main Dec 22, 2022
@TMisiukiewicz TMisiukiewicz deleted the feat/run-app-with-hotkey branch December 22, 2022 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants