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

Plamen5kov/move emulate to run #2647

Merged
merged 2 commits into from
Mar 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions docs/man_pages/project/testing/run-android.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ run android
Usage | Synopsis
---|---
Run on all connected devices and running emulators | `$ tns run android [--key-store-path <File Path> --key-store-password <Password> --key-store-alias <Name> --key-store-alias-password <Password>] [--release] [--justlaunch]`
Run on a selected connected device or running emulator | `$ tns run android --device <Device ID> [--key-store-path <File Path> --key-store-password <Password> --key-store-alias <Name> --key-store-alias-password <Password>] [--release] [--justlaunch]`
Start an emulator and run the app inside it | `$ tns run android --emulator [<Emulator Options>] [--key-store-path <File Path> --key-store-password <Password> --key-store-alias <Name> --key-store-alias-password <Password>] [--release] [--justlaunch]`
Run on a selected connected device or running emulator. Will start emulator with specified `Device Identifier`, if not already running. | `$ tns run android --device <Device ID> [--key-store-path <File Path> --key-store-password <Password> --key-store-alias <Name> --key-store-alias-password <Password>] [--release] [--justlaunch]`
Start a default emulator if none are running, or run application on all connected emulators. | `$ tns run android --emulator [--key-store-path <File Path> --key-store-password <Password> --key-store-alias <Name> --key-store-alias-password <Password>] [--release] [--justlaunch]`

Runs your project on a connected Android device or in a native Android emulator, if configured. This is shorthand for prepare, build and deploy. While your app is running, prints the output from the application in the console and watches for changes in your code. Once a change is detected, it synchronizes the change with all selected devices and restarts/refreshes the application.

### Options
* `--available-devices` - Shows a list of available emulators to be started and a list of already connected devices.
Copy link
Contributor

Choose a reason for hiding this comment

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

this is very very weird to me? So you're telling me I have to run tns run android --available-devices to get the available devices and not run the android app?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The emulate command had this behavior, and we decided to move the functionality to the run command. If it were up to me, I'd advise the user to use tns device command.

Copy link
Contributor

Choose a reason for hiding this comment

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

who are we then?

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 with @yyosifov, --available-devices should be removed, and users should use tns devices instead. IF you think it would affect users, then put a to-be-deprecated message when --available-devices is used so we can remove it in a following release.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, no problem. Will move the functionality to the tns device command.

* `--device` - Specifies a connected device/emulator to start and run the app.
* `--emulator` - If set, runs the app in all available and configured android emulators. It will start an emulator if none are already running.
Copy link
Contributor

Choose a reason for hiding this comment

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

what does "runs the app in all available and configured android emulators"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

runs app on all running emulators

* `--justlaunch` - If set, does not print the application output in the console.
Copy link
Contributor

Choose a reason for hiding this comment

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

besides that, this works for both emulator on device right?

I'd suggest: "--justlaunch - when specified starts the application on the emulator/device and omits all the application output in the console"

Copy link
Contributor Author

@Plamen5kov Plamen5kov Mar 24, 2017

Choose a reason for hiding this comment

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

besides that, this works for both emulator on device right?

this?

  • the --device flag works with emulators/simulators/real devices
  • the --emulator flag works only with emulators/simulators

--justlaunch doesn't start the application, it only cuts off the console, once the application is running.

Copy link
Contributor

Choose a reason for hiding this comment

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

That sounds strange to me. My doubt would be what exactly am I launching? Anyway, you can leave it as is for now.

* `--clean` - If set, forces rebuilding the native application.
* `--no-watch` - If set, changes in your code will not be reflected during the execution of this command.
* `--device` - Specifies a connected device/emulator on which to run the app.
* `--emulator` - If set, runs the app in a native emulator for the target platform, if configured. When set, you can also set any other valid combination of emulator options as listed by `$ tns help emulate android`.
* `--release` - If set, produces a release build. Otherwise, produces a debug build. When set, you must also specify the `--key-store-*` options.
* `--key-store-path` - Specifies the file path to the keystore file (P12) which you want to use to code sign your APK. You can use the `--key-store-*` options along with `--release` to produce a signed release build. You need to specify all `--key-store-*` options.
* `--key-store-password` - Provides the password for the keystore file specified with `--key-store-path`. You can use the `--key-store-*` options along with `--release` to produce a signed release build. You need to specify all `--key-store-*` options.
* `--key-store-alias` - Provides the alias for the keystore file specified with `--key-store-path`. You can use the `--key-store-*` options along with `--release` to produce a signed release build. You need to specify all `--key-store-*` options.
* `--key-store-alias-password` - Provides the password for the alias specified with `--key-store-alias-password`. You can use the `--key-store-*` options along with `--release` to produce a signed release build. You need to specify all `--key-store-*` options.
* `--justlaunch` - If set, does not print the application output in the console.
* `--clean` - If set, forces rebuilding the native application.

### Attributes
* `<Device ID>` is the index or name of the target device as listed by `$ tns device android`
* `<Emulator Options>` is any valid combination of options as listed by `$ tns help emulate android`
* `<Device ID>` is the index or `Device Identifier` of the target device as listed by `$ tns run android --available-devices`

<% if(isHtml) { %>
### Prerequisites:
Expand Down Expand Up @@ -57,4 +57,4 @@ Command | Description
[test init](test-init.html) | Configures your project for unit testing with a selected framework.
[test android](test-android.html) | Runs the tests in your project on Android devices or native emulators.
[test ios](test-ios.html) | Runs the tests in your project on iOS devices or the iOS Simulator.
<% } %>
<% } %>
18 changes: 9 additions & 9 deletions docs/man_pages/project/testing/run-ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ run ios
Usage | Synopsis
---|---
Run on all connected devices | `$ tns run ios [--release] [--justlaunch]`
Run on a selected connected device | `$ tns run ios [--device <Device ID>] [--release] [--justlaunch]`
Start an emulator and run the app inside it | `$ tns run ios --emulator [<Emulator Options>] [--release]`
Run on a selected connected device. Will start simulator with specified `Device Identifier`, if not already running. | `$ tns run ios [--device <Device ID>] [--release] [--justlaunch]`
Start an emulator and run the app inside it | `$ tns run ios --emulator [--release]`

Runs your project on a connected iOS device or in the iOS Simulator, if configured. This is shorthand for prepare, build and deploy. While your app is running, prints the output from the application in the console and watches for changes in your code. Once a change is detected, it synchronizes the change with all selected devices and restarts/refreshes the application.

Expand All @@ -14,16 +14,16 @@ Runs your project on a connected iOS device or in the iOS Simulator, if configur
<% if(isHtml) { %>> <% } %>IMPORTANT: Before building for iOS device, verify that you have configured a valid pair of certificate and provisioning profile on your OS X system. <% if(isHtml) { %>For more information, see [Obtaining Signing Identities and Downloading Provisioning Profiles](https://developer.apple.com/library/mac/recipes/xcode_help-accounts_preferences/articles/obtain_certificates_and_provisioning_profiles.html).<% } %>

### Options
* `--no-watch` - If set, changes in your code will not be reflected during the execution of this command.
* `--device` - Specifies a connected device on which to run the app.
* `--emulator` - If set, runs the app in a native emulator for the target platform, if configured. When set, you can also set any other valid combination of emulator options as listed by `$ tns help emulate ios`. You cannot use `--device` and `--emulator` simultaneously.
* `--release` - If set, produces a release build. Otherwise, produces a debug build.
* `--available-devices` - Shows a list of available simulators to be started and a list of already connected devices.
* `--device` - Specifies a connected device/simulator to start and run the app.
* `--emulator` - If set, runs the app in all available and configured ios simulators. It will start a simulator if none are already running.
* `--justlaunch` - If set, does not print the application output in the console.
* `--clean` - If set, forces rebuilding the native application.
* `--no-watch` - If set, changes in your code will not be reflected during the execution of this command.
* `--release` - If set, produces a release build. Otherwise, produces a debug build.

### Attributes
* `<Device ID>` is the index or name of the target device as listed by `$ tns device ios`
* `<Emulator Options>` is any valid combination of options as listed by `$ tns help emulate ios`
* `<Device ID>` is the index or `Device Identifier` of the target device as listed by `$ tns run ios --available-devices`
<% } %>
<% if(isHtml) { %>
### Prerequisites
Expand Down Expand Up @@ -56,4 +56,4 @@ Command | Description
[test init](test-init.html) | Configures your project for unit testing with a selected framework.
[test android](test-android.html) | Runs the tests in your project on Android devices or native emulators.
[test ios](test-ios.html) | Runs the tests in your project on iOS devices or the iOS Simulator.
<% } %>
<% } %>
1 change: 0 additions & 1 deletion lib/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ $injector.require("iOSSocketRequestExecutor", "./device-sockets/ios/socket-reque
$injector.require("messages", "./common/messages/messages");
$injector.require("xmlValidator", "./xml-validator");

$injector.requireCommand("devices", "./commands/devices");
$injector.requireCommand("post-install-cli", "./commands/post-install");
$injector.requireCommand("update", "./commands/update");

Expand Down
17 changes: 0 additions & 17 deletions lib/commands/devices.ts

This file was deleted.

8 changes: 6 additions & 2 deletions lib/commands/emulate.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
export class EmulateCommandBase {
constructor(private $options: IOptions,
private $projectData: IProjectData,
private $logger: ILogger,
private $platformService: IPlatformService) {
this.$projectData.initializeProjectData();
}

public async executeCore(args: string[]): Promise<void> {
this.$logger.warn(`Emulate command is deprecated and will soon be removed. Please use "tns run <platform>" instead. All options available for emulate are present in "tns run" command.`);
this.$options.emulator = true;
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: this.$options.bundle, release: this.$options.release };
const emulateOptions: IEmulatePlatformOptions = {
Expand Down Expand Up @@ -34,9 +36,10 @@ export class EmulateIosCommand extends EmulateCommandBase implements ICommand {

constructor($options: IOptions,
$projectData: IProjectData,
$logger: ILogger,
$platformService: IPlatformService,
private $platformsData: IPlatformsData) {
super($options, $projectData, $platformService);
super($options, $projectData, $logger, $platformService);
}

public async execute(args: string[]): Promise<void> {
Expand All @@ -49,9 +52,10 @@ $injector.registerCommand("emulate|ios", EmulateIosCommand);
export class EmulateAndroidCommand extends EmulateCommandBase implements ICommand {
constructor($options: IOptions,
$projectData: IProjectData,
$logger: ILogger,
$platformService: IPlatformService,
private $platformsData: IPlatformsData) {
super($options, $projectData, $platformService);
super($options, $projectData, $logger, $platformService);
}

public allowedParameters: ICommandParameter[] = [];
Expand Down
15 changes: 4 additions & 11 deletions lib/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@ export class RunCommandBase {
protected $usbLiveSyncService: ILiveSyncService,
protected $projectData: IProjectData,
protected $options: IOptions,
protected $emulatorPlatformService: IEmulatorPlatformService,
private $mobileHelper: Mobile.IMobileHelper) {
protected $emulatorPlatformService: IEmulatorPlatformService) {
this.$projectData.initializeProjectData();
}

public async executeCore(args: string[]): Promise<void> {

if (this.$options.availableDevices) {
return this.$emulatorPlatformService.listAvailableEmulators(this.$mobileHelper.validatePlatformName(args[0]));
}

const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: this.$options.bundle, release: this.$options.release };
const deployOptions: IDeployPlatformOptions = {
clean: this.$options.clean,
Expand Down Expand Up @@ -58,9 +53,8 @@ export class RunIosCommand extends RunCommandBase implements ICommand {
$usbLiveSyncService: ILiveSyncService,
$projectData: IProjectData,
$options: IOptions,
$emulatorPlatformService: IEmulatorPlatformService,
$mobileHelper: Mobile.IMobileHelper) {
super($platformService, $usbLiveSyncService, $projectData, $options, $emulatorPlatformService, $mobileHelper);
$emulatorPlatformService: IEmulatorPlatformService) {
super($platformService, $usbLiveSyncService, $projectData, $options, $emulatorPlatformService);
}

public async execute(args: string[]): Promise<void> {
Expand All @@ -83,9 +77,8 @@ export class RunAndroidCommand extends RunCommandBase implements ICommand {
$projectData: IProjectData,
$options: IOptions,
$emulatorPlatformService: IEmulatorPlatformService,
$mobileHelper: Mobile.IMobileHelper,
private $errors: IErrors) {
super($platformService, $usbLiveSyncService, $projectData, $options, $emulatorPlatformService, $mobileHelper);
super($platformService, $usbLiveSyncService, $projectData, $options, $emulatorPlatformService);
}

public async execute(args: string[]): Promise<void> {
Expand Down
2 changes: 0 additions & 2 deletions lib/services/emulator-platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ export class EmulatorPlatformService implements IEmulatorPlatformService {
}

this.outputEmulators("\nAvailable emulators", emulators);
this.$logger.out("\nConnected devices & emulators");
await $injector.resolveCommand("device").execute(platform ? [platform] : []);
}

public async getiOSEmulators(): Promise<IEmulatorInfo[]> {
Expand Down
6 changes: 4 additions & 2 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,10 @@ export class PlatformService extends EventEmitter implements IPlatformService {

public async deployPlatform(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, deployOptions: IDeployPlatformOptions, projectData: IProjectData, platformSpecificData: IPlatformSpecificData): Promise<void> {
await this.preparePlatform(platform, appFilesUpdaterOptions, deployOptions.platformTemplate, projectData, platformSpecificData);
this.$logger.out("Searching for devices...");
await this.$devicesService.initialize({ platform: platform, deviceId: deployOptions.device });
let options: Mobile.IDevicesServicesInitializationOptions = {
platform: platform, deviceId: deployOptions.device, emulator: deployOptions.emulator
};
await this.$devicesService.initialize(options);
let action = async (device: Mobile.IDevice): Promise<void> => {
let buildConfig: IBuildConfig = {
buildForDevice: !this.$devicesService.isiOSSimulator(device),
Expand Down