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

Unify and simplify workflows of build-related commands #475

Closed
teobugslayer opened this issue May 12, 2015 · 7 comments
Closed

Unify and simplify workflows of build-related commands #475

teobugslayer opened this issue May 12, 2015 · 7 comments
Assignees
Labels

Comments

@teobugslayer
Copy link
Contributor

Problem: Currently, the commands which include build - related steps differ slightly in their semantics, parameters and work flows.

Solution: Unify as much as possible but only where make sense.

Remark: All commands should work without specifying a platform if it is already added to the project. If more than one platform is added we should execute the command on all of them. If a user wants to run a particular platform she will be able to specify it as it currently works.

Prepare - stays as is

Build - stays as is

Deploy - does not work for emulators, does not run the app
-- device

Run - based on deploy
-- device
-- emulator android (device)
-- emulator ios

by default - build for simulator. Can be overridden by command line parameter. run [ios] --device. For android, running --geny instance must be reused

Debug = run + start debugger. works for android & ios, devices & emulators

Emulate = run --emulator. emulate --geny = run --geny

@teobugslayer teobugslayer added this to the 1.1 milestone May 12, 2015
@rosen-vladimirov rosen-vladimirov self-assigned this May 19, 2015
@ligaz ligaz modified the milestones: 1.2.0, 1.1.0 Jun 8, 2015
@rosen-vladimirov
Copy link
Contributor

Based on the description above, I've prepared the exepected behavior of the commands.
I've found some cases, that are confusing and I'm not sure what is the expected behavior (check the table at the end).

platform add

Usage:

  • platform add <platform1> - add specified platform
  • platform add <platform1> <platform2> - add all specified platforms

prepare

Usage:

  • tns prepare - prepares the project for all installed platforms, for example if the project is targeting android and ios, this command will prepare it for both of them
  • tns prepare <platform> - prepares the project for all specified platforms. In case the specified platform is not added, add it and prepare it.

build

Usage:

  • tns build - prepare and build the project for all installed platforms
  • tns build <platform> - prepare and build the project for specified platform

build for device or for emulator

check the table at the end for information which build should be executed.

deploy

Usage:

  • tns deploy - prepare and build the project for all installed platforms. After that deploy the project on all currently running devices and emulators.
  • tns build <platform> - prepare and build the project for specified platform. After that deploy the project on all currently running devices and emulators of specified platform.
  • tns build <platform> --device <deviceId> - prepare and build the project for specified device (for Android make sure to check is this device or emulator). Deploy the project on the specified device.

run

Usage:

  • tns run - prepare and build the project for all installed platforms. After that deploy the project on all currently running devices and emulators. Finally run the project on all of them.
  • tns run <platform> - prepare and build the project for specified platform. After that deploy the project on all currently running devices and emulators of specified platform. Finally run the project on all of them.
  • tns run <platform> --device <deviceId> - prepare and build the project for specified device (for Android make sure to check is this device or emulator). Deploy the project on the specified device and start it.

debug

We have to select device for debugging, we cannot debug on all devices.

  • tns debug - if there are more than one device attached, prompt the user to select device on which to debug. If there are no devices attached, prompt user to select platform and start debugging on emulator.
  • tns debug <platform> - prompt user to select device and if such is not found, start debugging on emulator.

Building for emulator or for device

The table below illustrates different use cases when both Android and iOS platforms are added to your project.

# Commands(right) \ scenario(below) run run android run ios
1. no devices attached, no emulators running build Android and ios for emulator and run each of them in emulator build only for android and run in emulator build only for ios and run in emulator
2. At least one Android device and at least one iOS device attached buld Android and iOS for device and run on the devices build only for Android and run on android devices build only for iOS and run on iOS devices
3. At least one Android device build for iOS emulator and run in it, build for Android and run on device or build only for Android and run on devices build for Android and run on the attached devices build for iOS emulator and run in it
4. At least one iOS device build for iOS device and run in it, build for Android and run in emulator or build only for iOS device and run in it build for Android emulator and run in it build and run on iOS devices
5. Many Android and iOS device buld Android and iOS for device and run on the devices build only for Android and run on android devices build only for iOS and run on iOS devices
6. At least one iOS device and iOS emulator For iOS: build for device or build for emulator or build for device and for emulator Should we build for Android and run in emulator? build for Android and run in emulator build for device or build for emulator or build for device and for emulator
7. At least one iOS device and at least one Android emulator build iOS for device and run in it, build for Android and run in emulator build for Android and run in emulator build for iOS device and run on the device
8. At least one Android device and iOS emulator build for Android and run on the device, build iOS for emulator and run in it build for Android and run on the device build iOS for emulator and run in it

As you can see there are some "critical" points here. First one is what to do in case user had not specified platform and there's a device attached from only one platform - should we use only the platform from the device attached or we should execute the command for both platforms (using emulator for the second one).
Also if there are iOS device and iOS emulator currently running, should we build two times (one for each of them) and deploy on both devices.

NOTE: When we run the app on multiple platforms, we must disable console logging (set justlaunch to true).

@Fatme
Copy link
Contributor

Fatme commented Jun 9, 2015

I'm voting for the following workflow:

  • tns build ios - builds only for ios. If the user has not added ios platform, CLI should add the platform.
  • tns build android - builds only for android. If the user has not added android platform, CLI should add the platform.
  • tns build ios android - builds for ios and android. If the user has not added the platforms, CLI should add the platforms.
  • tns build - looks for attached devices/emulators. If any builds for the corresponding platform/platforms. If no devies/emulators found, builds for added platforms.

@Mitko-Kerezov
Copy link
Contributor

Neatly organized table - well done!
IMO when a user runs such a command without specifying a platform tns CLI should execute the command for all platforms, meaning - even if you don't have a device or an emulator running for a particular platform, the CLI should start an emulator up for you.
My view of this derives from the fact that if one would want to build/run/deploy only for a specific platform, one should type in the command name, along with that platform's name - else there would be no difference between run and run <platform> behavior in some cases.

As for the case with an iOS device along with an emulator my vote goes to building for all of them.
When users have both a device attached and an emulator running my guess is they want to test out the functionality for different iOS versions, hence we should execute for both.

@ikoevska
Copy link
Contributor

ikoevska commented Jun 9, 2015

My vote goes for the following.

When no platform is specified but there is at least one physical device/emulator connected/running - build, deploy or run for the attached device/process only.
In such cases, I would consider not specifying a platform a shortcut for executing the command on all my connected/running devices/emulators whatever they are. Also, I wouldn't want emulators popping up all over the place slowing down my machine and moving the focus away from my console.

In the cases where we don't find a connected device and choose to launch the emulator, we should log a message that no physical devices were detected, so we're launching the emulator.

@teobugslayer
Copy link
Contributor Author

I second @ikoevska. In my experience, although I have many attached device, my attention is always at a particular task at hand and I ignore devices of the "wrong" kind.

Also, building for android, ios device and ios emulator is a very slow operation. That's why I prefer an approach "when in doubt, ask the user". I.e. when there are 2 platforms added and 2 kind of devices, just ask the user which one to use, either interactively or by requiring a special command line parameter.

@teobugslayer teobugslayer modified the milestones: 1.3.0, 1.2.0 Jul 14, 2015
@teobugslayer teobugslayer removed this from the 1.3.0 milestone Jul 29, 2015
rosen-vladimirov added a commit that referenced this issue Aug 13, 2015
When you execute `tns run <platform>`, but you have forgotten to add the platform before that, you go in inconsistent state. Make sure to add the platform for the user when one of the following is executed:
* `tns prepare <platform>`
* `tns build <platform>`
* `tns run <platform>`
* `tns update <platform>@<version>` - this will add the specified version in case you have not added the platform before that.
* `tns emulate <platform>`

This way we simplify the workflow, now you can just do:
1) `tns create app1`
2) `tns run android --path app1`
And the application will run on your attached device.

Resolves #774
Part of the implementation of: #475
@emiloberg
Copy link

Do we also need a way of specifying which iOS version to start the emulator with? E.g.

tns run ios --emulator --device iPhone-6 --ios 8.1
# or
tns run ios --emulator --device iPhone-6 --ios 9.0
# or maybe
tns run ios --emulator --device iPhone-6/9.0

I've made a small writeup of the problem in this issue: NativeScript/NativeScript#794

@rosen-vladimirov
Copy link
Contributor

Ok, I'm closing this one, as most of the described behavior has been implemented. The current behavior of tns build related commands is:

For iOS

  • In case there's device attached, all build related commands will build the application for device.
  • In case there's no device attached, the build will be for simulator and some of the commands (like run, deploy) will start the app on iOS Simulator.
    You can specify explicit build operation with --for-device and --emulator flags.

For Android

  • There's no difference between device and emulator, so build and deploy on everything possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants