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

Add .html to the fast-sync files #2823

Merged
merged 1 commit into from
May 22, 2017
Merged

Conversation

yyosifov
Copy link
Contributor

The Angular issue with refreshing the App is now resolved and we can again sync .css/.html files.

@dtopuzov dtopuzov merged commit 94a3132 into master May 22, 2017
dtopuzov added a commit to NativeScript/nativescript-cli-tests that referenced this pull request May 29, 2017
@pkoleva pkoleva deleted the yosifov/add-html-to-fast-sync branch May 31, 2017 14:01
etabakov added a commit that referenced this pull request Sep 8, 2017
* Yosifov/add test (#2710)

* Setup Project Changes Service test suite

* Add tests for GetPrepareInfo from ProjectChangesService

* Add test to verify changes on a sync file has been applied.

* Make ios/android lower case folder names, as it seems like in Linux the case-sensitivity plays a role

* Fix platform names casing

* Clone the test for Android for file changes

* fix lint errors

* Add tests for issue #2697

* Adding Tests to verify that the App_Resources have been reloaded

* Adding tests for new/deleted platform/common files

* Refactor the changes tests and add some more tests

* Improve assertions to include message what was wrong with the directory structure

* Minor messages improvement

* remove delete file tests - seems we do not support this currently.

* Adding tests to verify new files in App_Resources are detected and copied to destination.

* Remove .only() which was used only for debugging purposes on the Travis CI

* Fix installation scripts for Mac (#2714)

* Fix android sdk commands to use sdkmanager

* Replace brew install with brew cask

* Fix installation for haxm

* Change brew formulae repository before installing android sdk

* Fix setting the ENV variable missing cast

* Fix debug on iOS simulator with watch (#2721)

During `tns debug ios`, in case you make changes, the application must be restarted and the debugger must attached again. However, in many cases we kill the old lldb process and immediately try to start the new one. The childProcess.kill operation finishes, but lldb process does not die immedietely. So in some occasions, the attach of new debugger fails. This leads to multiple errors - you cannot start this application on simulator anymore, you cannot exit CLI's process with `Ctrl + C`, etc.
Fix this by attaching to "close" event of the processes and waiting for them to be really finish their execution.

* Implement extensibility model for CLI (#2724)

Implement extensibilty of CLI that allows anyone to add easily create packages that add new functionality to NativeScript CLI. The packages are installed in a specific directory, so they are persisted through CLI's updated.
The directory where extensions are installed contains a package.json and each extension is npm package installed there.
The extensions can be mainatined in two different ways:
- navigate to the directory where extensions are installed and use `npm` for install/uninstall/update of packages.
- use CLI's commands to update them: `tns extension install <name>`, `tns extension uninstall <name>`, `tns extension`

Implement extensibilityService that executes all operations and expose it to public API. In {N} CLI the extensions are loaded in the entry point, before parsing command line arguments. This way extensions can add new commands.
In Fusion, after CLI is required as a library, the `extensibilityService.loadExtensions` method should be called. It returns array of Promises - one for each installed extension.

Add help for the new commands, but do not link the new commands in other commands help for the moment.

Add unit tests for the new service.

* Do not start emulator when `--available-devices` is passed (#2736)

In case there's no devices attached and no emulators running, trying `<cli name> devices <platform> --available-devices` will start emulator.
In order to fix this, modify the `startEmulatorIfNecessary` method to skip the starting in case `skipInferPlatform` option is passed. This option indicates that we are not concerned of specific platform, so the method does not know which is the target platform for which to start emulator.
Add unit test for this behavior.

* Install karma peer dependencies on `test init` (#2693)

* implicitly install karma-<testingFramework>'s peer dependencies on test init command

* add exception handling when installing packages already present in the project

* log warning instead of throwing errors when a package's name couldn't be determined when installed using the node-package-manager service

* Update to latest common

* Expose service for configuration

* Expose npm operations

Expose node-package-manager functonality to be usable when CLI is `require`-d.
* Remove occurrences of `this.$options` in node-package-manager
* Start using `--dry-run` and `--json` for parsing output

* Docs and tests

* Fix comments

* Rebase

* Final fix

* Improve debugService public API

When using Chrome DevTools to debug iOS applications, CLI returns a url that points to a specific commit of the dev tools. This way, in case a new version of the dev tools introduces a breaking change, the debugging will still work.
However, in some cases (inside Electron app), we cannot use the remote url, so we must use the bundled one. So introduce a new option (only available when requiring CLI as a library), that defines that the returned url will use the bundled dev tools.
The default behavior (used in CLI), will still return the url that includes remote url.
Also change the definition of `debug` method in the interface, so now the DebugService can safely implement it.
Add a new check in the debug service - in case the device's status is not Connected, we are unable to start debug operation. So fail with correct error message in this case.
Add JSDocs for all debug related interfaces.
Add documentation in PublicAPI.md for the `debugService`.
Add debugService to tests of public API.

* Add tests for debugService

Add tests for debugService.
Add verification that in case device's OS is not supported (for example WP8), we'll throw correct error.

* Fix emulate command (#2743)

During refactoring we've decided to pass the whole `$options` object from commands to services. However we've forgotten to change the emulate command.
Pass correct argument which will fix the issue.

* Fix some issues about the provision switch (#2705)

* Freeze mocha-typescript to 1.0.23 (#2746)

* Merge release in master (#2749)

* Fix debug on iOS simulator with watch (#2721)

During `tns debug ios`, in case you make changes, the application must be restarted and the debugger must attached again. However, in many cases we kill the old lldb process and immediately try to start the new one. The childProcess.kill operation finishes, but lldb process does not die immedietely. So in some occasions, the attach of new debugger fails. This leads to multiple errors - you cannot start this application on simulator anymore, you cannot exit CLI's process with `Ctrl + C`, etc.
Fix this by attaching to "close" event of the processes and waiting for them to be really finish their execution.

* Implement extensibility model for CLI (#2724)

Implement extensibilty of CLI that allows anyone to add easily create packages that add new functionality to NativeScript CLI. The packages are installed in a specific directory, so they are persisted through CLI's updated.
The directory where extensions are installed contains a package.json and each extension is npm package installed there.
The extensions can be mainatined in two different ways:
- navigate to the directory where extensions are installed and use `npm` for install/uninstall/update of packages.
- use CLI's commands to update them: `tns extension install <name>`, `tns extension uninstall <name>`, `tns extension`

Implement extensibilityService that executes all operations and expose it to public API. In {N} CLI the extensions are loaded in the entry point, before parsing command line arguments. This way extensions can add new commands.
In Fusion, after CLI is required as a library, the `extensibilityService.loadExtensions` method should be called. It returns array of Promises - one for each installed extension.

Add help for the new commands, but do not link the new commands in other commands help for the moment.

Add unit tests for the new service.

* Fix installation scripts for Mac (#2714)

* Fix android sdk commands to use sdkmanager

* Replace brew install with brew cask

* Fix installation for haxm

* Change brew formulae repository before installing android sdk

* Fix setting the ENV variable missing cast

* Do not start emulator when `--available-devices` is passed (#2736)

In case there's no devices attached and no emulators running, trying `<cli name> devices <platform> --available-devices` will start emulator.
In order to fix this, modify the `startEmulatorIfNecessary` method to skip the starting in case `skipInferPlatform` option is passed. This option indicates that we are not concerned of specific platform, so the method does not know which is the target platform for which to start emulator.
Add unit test for this behavior.

* Install karma peer dependencies on `test init` (#2693)

* implicitly install karma-<testingFramework>'s peer dependencies on test init command

* add exception handling when installing packages already present in the project

* log warning instead of throwing errors when a package's name couldn't be determined when installed using the node-package-manager service

* Freeze mocha-typescript to 1.0.23 (#2746)

* Freeze mocha-typescript to 1.0.23 (#2746)

* Fix the six package detection in release (#2748)

* Revert "Merge release in master (#2749)" (#2750)

This reverts commit 3e8ddcf9a54a18ee5f56c0425309437e82f7a175.

* Update the mobile-cli-lib to latest version (#2760)

* Fix getting production dependencies code (#2789)

* Fix getting production dependencies code

CLI has logic to find which are the "production" dependencies, i.e. which should be copied from `node_modules` to `platforms` dir.
However, when the project has a lot of dependencies (more than 15), on some machines the code leads to error: "Maximum callstack size exceeded". On other machines the code tooks significant time to execute.
After investigation, it turned out the recursion inside `node-modules-dependencies-builder` is incorrect and it adds each package many times to the result array.
Fix the recursion and change the class NodeModulesDependenciesBuilder to be stateless - instead of using properties in `this` object when calculating the production dependencies, the methods will persist the results through the passed args.
This way the whole class can be safely added to `$injector` and used whenever we need the production dependencies. Each time the calculation is started from the beginning, which is the requirement for long living process, where the project may change.
Fix the type of the result, which leads to fix in several other services, where the result has been expected as `IDictionary<smth>`. However it's never been dictionary, it's always been an array. The code, that expected dictionary has been working because the `_.values` method of lodash (used all over the places where the incorrect type of data has been expected), returns the same array when the passed argument is array.
Fix the tests that incorrectly expected dictionary with keys "0", "1", "2", etc.
Remove the usage of Node.js's `fs` module from `NodeModulesDependenciesBuilder` - replace it with `$fs` which allows easir writing of tests.
Require the `nodeModulesDependenciesBuilder` in bootstrap, so it can be correctly resolved by `$injector`.

Add unit tests for `nodeModulesDependenciesBuilder`.

* Use breadth-first search for getting production dependencies

Replace the recursion with breadth-first search algorithm in order to make the code easier for understanding and debugging.
Fix some incorrect code in the tests.

* Add checks before adding new elements to queue of production dependencies

Add check before adding new elements to queue of production dependencies - do not add elements, which are already added and do not read package.json of elements that are already added to "resolvedModules".

* Use qr-image for qr code generation (#2803)

* Update to latest common lib

* Merge release in master (#2808)

* Update Travis CI Scripts (#2799)

Set `rc` tag to the publishConfig section for the release branch.

* Remove .html from the files included in the fast-livesync to force full reload (#2802)

* Update Travis CI Scripts (#2804)

* Fix UserId passing to Analytics Service (#2806)

* Release notes for 3.0.1 (#2807)

* Update to latest common lib

* Update Travis CI Scripts (#2805)

Set `rc` tag to the publishConfig section for the release branch.

* Fix getting information for installed npm package (#2813)

Some npm versions (like 3.9.6) do not report result when package is already installed and `--dry-run` is passed.
This breaks the `JSON.parse()` of the result as it is an empty string.
In this case just parse the original output of `npm install` and search for a result like:
```
<project dir>
`-- nativescript-barcodescanner@1.0.0
```

In case this operation also fails to find which is the installed package, try to find the name from the user specified value.
For example:
```
$ tns plugin add nativescript-barcodescanner@1.0.0
```
The name is `nativescript-barcodescanner` and the version is `1.0.0`.

In case a scoped package is passed, the parsing should also work correctly.

In case a package, that is not NativeScript plugin, is installed via `tns plugin add` command, we have logic to revert the installation.
However the promise that should uninstall the app had never been awaited, so the package was still declared and installed.

When `--json` is passed to `npm install` command, it generates `/etc` dir in the project where npm command is executed.
We have logic to delete it after finishing our command, but it's been executed too early. Fix the code, so command to remove `/etc` will be executed no matter if any of the other operations fails.

* Add support for Custom entitlements files (#2753)

* Extract entitlements and xcconfig services.

* Fix tests setup with the new services in ios-project-service tests

* Adding newline in xcconfig-service to fix lint error

* Add Tests for XCConfig-Service

* First test for the merging of the Build XCConfig files

* trying to add gems to the Travis CI machine setup

* Adding patching the xcconfig file with a default entitlements file location if the user hasn't set one

* Fix default empty entitlements file - was needless and caused errors.

* Extract entitlements and xcconfig services.

* Fix tests setup with the new services in ios-project-service tests

* Adding newline in xcconfig-service to fix lint error

* Add Tests for XCConfig-Service

* First test for the merging of the Build XCConfig files

* trying to add gems to the Travis CI machine setup

* Adding patching the xcconfig file with a default entitlements file location if the user hasn't set one

* Fix default empty entitlements file - was needless and caused errors.

* Adding merge entitlements tests

* Add merge from App_Resources and Plugin integration test

* Fix PR comments

* Fix posting notification to iOS Simulator (#2824)

In case there are spaces in path to the executable (node) or in the args, we are unable to send notification. Replace the usage of childProcess.exec with childProcess.spawn, which handles the spaces correctly.

* Add .html to the fast-sync files (#2823)

* Add awaitWriteFinish option to choki in livesync to wait file to be r… (#2817)

* Add awaitWriteFinish option to choki in livesync to wait file to be ready to be read

* set the threshold for 500ms

* Fix unit tests on non-macOS (#2827)

Currently unit tests from master branch are failing on Windows and Linux. Fix them by applying the following:
- Fix expected path in entitlements test - use `path.join` instead of hardcoded `/` - on Windows the path separator is `\`
- Ignore tests for merging xcconfig files as they can work only on macOS, where ruby is installed. The tests will be ran only in case you are executing them on macOS.
- Require "colors" module in test-bootstrap. During test execution I've noticed some "undefined" statements printed on the terminal. It turned out these are `logger.warn` statements. However the logic in the logger is to print `<message>.yellow`.
When `colors` is not required, the strings do not have `yellow` property, so instead of seeing the real message, the loggger has been printing "undefined".

* Add a section for Entitlements (#2834)

* Add a section for Entitlements

Adding a small section describing the default behavior of the Entitlements.

* Fix the path to the entitlements file

* Prevent starting a simulator when build --forDevice (#2833)

* Pass option to build not to launch the Simulator as it's build only

* Updating the mobile-cli-lib version

* Don't create/update the bash_profile when turning autocomplete on (#2840)

* After fix .html can again be synced correctly without restart (#2839)

* Fix ios logs with logLevel INFO (#2843)

Whenever an ios device log is triggered with logLevel INFO `console.log` statements are not seen on the console for ios 8 and ios 9 devices due to a difference in their formats.
Fix this and add tests.

* Increase version to 3.0.2 and add changelog (#2849)

* Fix UserId passing to Analytics Service

* Add changelog for 3.0.2

* Fix deviceLogs emitted for all attached ios devices (#2845)

* Remove reference to Google groups in README (#2838)

Changing it with a link to the forums.

* Fix permissions on ~/.local/share/.nativescript-cli with Sudo runs (#2848)

* Fix permissions on ~/.local/share with Sudo runs

* Update the common library

* Updated md files for the debug command. (#2836)

* Updated md files for the debug command.

* In Debug docs changed verbs to agreed form and added prerequisites for Android command

* Remove the emulate command (#2844)

* Remove the emulate command.

* Remove unused method and interface.

* Fix prepare for android when building with webpack (#2852)

When switching between release, debug and bundle builds, the android
build artifacts should be cleaned.

fixes https://github.com/NativeScript/android-runtime/issues/759

* Update CHANGELOG.md

* Expose a way to set projectApiKey for analytics (#2859)

* Update Android SDK packages in macOS setup script (#2857)

* Update ios-device-lib (#2861)

Update version of ios-device-lib, in order to fix https://github.com/NativeScript/nativescript-cli/issues/2860

* Add the available devices option to the help #2850 (#2854)

* Conform ios inspector code with npm 5 (#2862)

* Add the available devices option to the help #2850 (#2854)

* Update Android SDK packages in macOS setup script (#2857)

* Updated md files for the debug command. (#2836)

* Updated md files for the debug command.

* In Debug docs changed verbs to agreed form and added prerequisites for Android command

* Remove reference to Google groups in README (#2838)

Changing it with a link to the forums.

* Bump version and add release notes (#2866)

* Update CHANGELOG.md and bump version

* Update date

* Update CocoaPods.md (#2867)

* Expose loadExtension to fix double loading of packages (#2868)

* Expose loadExtension to fix double loading of packages

In case you install extension, the method automatically loads it. However calling `loadExtensions` after that loads it again, so our `$injector` fails.
In order to fix this, remove the loading from the `installExtension` method and expose `loadExtension(name)` method.
So in the future in case someone wants to load a new an extension after calling `loadExtensions`, they'll be able to use the new method.

* Update ios-device-lib

Update `ios-device-lib` to 0.4.3. The new version includes a fix for long living processes where detaching iOS device causes a huge memory consuption and core dump.

* Fix analytics (#2869)

Fix analytics, so we'll no longer track information for users, who have not allowed us to do so. There are several problems:
* Whenever the terminal is not interactive and we do not know if user allows us to track them, we set the value of TrackExceptions to true. Also we immediately send information to Analytics that we've set the value to true. So all CI builds are tracked as new users, as we start a session for them and send the value of TrackExceptions (enabled).
* `setStatus` method almost always sends data to Analytics. This method should not send information. It does not care if we have allowed to be tracked - it always sends data. Remove this logic.
* `tns usage-reporting <value>` and `tns error-reporting <values>` always send information to Analytics - in fact the commands are calling "setStatus", that's why they send information. In order to track them, use the "trackFeature" method which will track information ONLY when user had allowed this.
* Fix `getStatus` method which had incorrect behavior - the if has been using the values of the enum (0,1,2) and we were getting in the body of the if statement in a very inaccurate cases.
* Remove unit tests for `setStatus` and add new ones for checkConsent logic.

* Update submodule to latest version

* Bump version to 3.1.0 (#2878)

* Add CFBundleURLSchemes when building for iOS in debug. (#2863)

* Flatten scoped module when copying into android/src (#2837)

* fix path when removing  dir in a scoped dependency during prepare

* flatten android plugins with native code when copying into main/src

* Add Content-Length to the itunes request applications service request (#2882)

* #2856 Remove non-production dependencies which break npm links (#2880)

* Fix unit tests (#2886)

* WIP

* Move OS compatibility check to commands

* New LiveSync

* WIP

* WIP next

* Add useLiveEdit option

* Update Public API interfaces

* Add events for LiveSync

* Add correct events for LiveSync

* Add docs and improve liveSync operations when called multiple times for same dir

* Fix liveSync - add correct check for deviceDescriptors

* Delete AndroidAppIdentifier

* Remove device-path-provider

* Fix multiple rebuilds for the same platform

* Fix unit tests

* Extract all common logic of livesync services to platform-livesync-service-base

* Remove livesync-provider

Remove livesyncProvider and introduce a base class for device specific livesync services.

* Add notify event during LiveSync

* Rename error event to liveSyncError

Rename the error event to liveSyncError as EventEmitter expects instance of Error when event named `error` is raised.
So it fails to parse our object. Also it automatically raised Uncaught error in CLI when noone has added a handler for error event:`Uncaught, unspecified "error" event. ([object Object])`.
Fix incorrect message in an error where deviceIdentifier was not printed correctly.

* Do not kill ios-device-lib in `tns run`

* WIP

* Expose saveBuildInfoFile

Expose
* saveBuildInfoFile - method which should be used in cloud builds
* livesyncService - which can be used to perform livesync with require-d tns

* Fix always reinstalling apps during livesync

In case the app is not installed on a device when `tns run <platform>` is started, each change reinstalls the application.
The problem is in the "isApplicationInstalled" check which was relying on the result of the first execution (when the app has not been installed).
Fix this by always checking if the app is installed.

* Minor bugfixes

* Move notification service to common

* Fix Success livesync and run fail messages

* Implement tracking

* Fix lint errors

* Fix message for tests

* Fix comments vol. I

* Cache sockets per app per device

* Fix run

* Fix run not starting emulator

* Pass emulator flag and fix process.platform messages

* Fix chrome debug message

* Do not determine dynamic dependencies on Windows

We need to explicitly skip this step on Windows due to lack of tooling that is properly licensed.

* Restart app upon debugging

* Update common to latest master

* Remove obsolete vendor directory

* Fix run with --release and --clean

* Fix unit tests

* Fix debug-service unit tests

* Update ios-device-lib to 0.4.4

* Update ios-device-lib (#2893)

Update ios-device-lib where the following changes are applied:
* uninstall application is changed to use `AMDeviceSecureUninstallApplication` instead of `AMDeviceUninstallApplication`. The `secure` function is guarded against some racing issues that might happen when usign the insecure variant.
* Guard against errors when polling for installed applications - fixes issue when checking for currently installed apps is called during uninstalling of application.

* Pass mobileProvisionData to prepare (#2895)

On Windows and Linux we are unable to execute macOS specific commands. During project preparation for iOS we need to know the data from specified provison. In this scenario, pass the data from it as a non mandatory parameter.
This way the default behavior will be kept, but we'll have a way to skip the `security` command which fails on Windows.

* Return information about the error if loadExtension fails (#2899)

* Add actual error when loading extension

* PR comments

* Emit liveSyncStopped for every device (#2900)

* Revert "Restart app upon debugging" (#2898)

This reverts commit 5b1141c1bcc8362acce97d2b69422de19959942e.
In case a second debug attempt fails just throw the error.

* Allow prepare for Android without ANDROID_HOME (#2904)

* Allow prepare for Android without ANDROID_HOME

Allow preparing Android project without the requirement to have ANDROID_HOME set.
The change is in the required services, which should work without ANDROID_HOME in some cases.
However the commands should not allow this, so move the validation in the commands.

* Fix unable to uninstall application on macOS

Update ios-device-lib where a fix for uninstalling application on macOS was not working.
Update common lib where the following fixes are applied:
* Fix `tns devices` not showing attached iOS devices.
* Do not call uninstall of application when it is not installed - this produces some confusing warnings.

* Fix execution of livesync hooks when there are no node_modules

In case `node_modules` are deleted from the project and `tns run <platform>` or `tns debug <platform>` is executed, the livesync hook fails as the package that's required in it is not installed.
In order to fix this, extract the logic of the liveSync method in a separate method and decorate it with the hook. In the public method make sure all dependencies are installed and call the private method.
This way the hook will be executed correctly.

* Pass correct release arguments to run command (#2906)

* Pass correct release arguments to run command

https://github.com/NativeScript/nativescript-cli/issues/2903

* Fix merge of options during `tns run`

The `$options` object has the required information for all passed `--` args, but all of them are in `get` methods.
Calling `merge` does not get functions (like `get`ers), so we do not receive expected options (like `--release, --keyStorePath`, etc.) in the merged object.
In order to fix this just use the `this.$options.argv` which contains the information we need.

* Fix adding specific platform (#2907)

When trying to execute `tns platform add <platform>@<version>` we fail with message: `Cannot read property 'platformProjectService' of undefined`
The reason is incorrect check when getting platforms-data where we do not expect the version. Split the incoming string by `@` and use the real platform when trying to get the platforms data.

* Fix platform update command (#2910)

`tns platform update` command should install the latest platform in case it is not installed. Currently this fails (regression from previous commit).
Fix this by calling correct validate method.

* Add changelog for 3.1.0 (#2912)

* Add changelog for 3.1.0

* Update CHANGELOG.md

* Fix snapshot (#2918)

* Fix merging of CFBundleURLSchemes in debug builds (#2913)

In debug builds we add CFBundleURLSchemes that's required to restart the app on Windows.
However, in case the Info.plist of the application already has the same key, the module we are using is not merging the values correctly.
Fix this by manually merging the values.

* Fix starting of emulator on `tns debug <platform>` when device is not attached

`tns debug <platform>` command should start emulator in case device is not attached. The current command does not start emulator as we have passed `skipInferPlatform` - when this option is used, devicesService does not know for which platform to start the emulator.
Fix this by passing correct options.

* Fix asking for user email on postinstall

On postinstall CLI asks the users if they want to subscribe for NativeScript's newsletter. This check has been broken in 3.0.0 because of incorrect await.
In order to add tests for this functionality, introduce a new service that handles the check and sending of information about the user's mail.
Add the following tests:
 - ensure postinstall.js calls correct CLI command
 - ensure the post-install-cli command calls the new service
 - ensure the new service works correctly

* Update .travis.yml

* Update ios-device-lib to 0.4.7

Update ios-device-lib to 0.4.7, which will fix livesync of `.css` files on iOS Device after application has been restarted.

* Update to latest common lib

* Set version to 3.1.1 and prepare CHANGELOG

* Set version to 3.2.0

* Add Android 26 as verified version

* fix android with webpack (#2925)

* Different npm install result from npm 5. (#2926)

* Cherry-pick "fix android with webpack" from master (#2930)

* fix android with webpack (#2925)

* Update CHANGELOG

* Update Travis CI Scripts (#2915)

Fix publish to S3

* Update TS to latest release (#2928)

* Update TS to latest release

Fix correcponding tests

* Update TS to 2.4

 *Update dependencies
 *Fix errors due to new TS rules
 *Change debug on device logic - there wil be no multiple devicxes debug supported.
 *Update lib reference

* Track exceptions in separate Analytics project (#2948)

* Track exceptions in separate Analytics project

Track all exceptions from CLI in a separate analytics project.
Also track the result of `tns error-reporting enable/disable` in the same project where the exceptions are tracked.

Update common-lib where the following changes had been applied:
Allow tracking exceptions in a different Analytics project. In case the specified CLI wants to track exceptions to a separeate project, it can do it by setting the new property in staticConfig - `ANALYTICS_EXCEPTIONS_API_KEY`.
Allow tracking the result of `tns error-reporting enable/disable` to the same project where exceptions tracking is sent.
Speed up check if current Analytics request is sent - we check on 1000ms, while in fact it takes between 150 and 400ms. So make the check on 100ms.

* Bump CLI version to 3.1.2

* Error handling fixes. (#2938)

* Removing files that now live in the {N}/docs repo. (#2937)

Previously, these files were automatically committed from this repo to the {N}/docs repo by a bot. That workflow confused people (mostly me), so the bot no longer does this. The canonical source of these files is now directly in the {N}/docs repo (specifically in https://github.com/NativeScript/docs/tree/master/plugins), so the files in this repo are no longer necessary.

* Fix plugins prompts on postinstall (#2949)

* Fix plugins prompts on postinstall

In case some plugins (like `nativescript-plugin-firebase`) try to prompt the user on postinstall, users are unable to answer the question when `tns plugin add <name>` is used.
The reason is that the stdin of current process is not passed to the stdin of the `npm install` process and the user has no way to input the result.
Fix this by using "inherit" of current stdio when the console is interactive.

* Update CHANGELOG for 3.1.2

* Upate to latest common-lib

* Fix LICENSE years (#2953)

* Replace grunt-tslint with direct calling to tslint (#2954)

Some rules in our tslint.json require passing `--type-check` flag to `tslint` executable.
However grunt-tslint does not support it. So remove the `grunt-tslint` and spawn the `tslint` via npm script.
Add the new `tslint` script, so now the project can be linted by calling:
* grunt lint
* grunt tslint:build /for backwards compatibility/
* npm run tslint

Fix the errors that are received after passing `--type-check` flag.
Disable all linter errors for all automatically generated files (for messages).

* Fix remove of non-production dependencies. (#2959)

* Debug on emulator by default when multiple devices/emulators attached (#2957)

When there are multiple devices/emulators, calling `tns debug android` will fail that multiple devices are attached.
This break VS Code as previous code of CLI has been using emulators by default.
Fix this by using the most recent version (highest API Level) of running emulators, i.e. in case you have three Android emulators with version 5.1, 6.0 and 7.0, the one with 7.0 will be used for debugging.

In case the terminal is interactive, CLI will prompt the user for selecting a device on which to start debug operation.
In case the terminal is not interactive and there's no emulator running, the device with highest API level will be used.

* Fix CFBundleURLTypes merging. (#2961)

* Fix unmet peer dependency break adding of platform. (#2969)

* Fix LiveSync calls cosecutive times (#2973)

When CLI is used as a library, the LiveSync method can be called consecutive times for the same projects, but with different device identifiers. For example we may want to start LiveSync on devices with identifiers [ A, B, C ] and later we would like to add devices with identifiers [ D, E ].
In the second call, CLI should detect that LiveSync is already running and execute initial sync only for newly added devices. However the current check for unique device identifiers is not correct and it always returns empty array as we first add the new devices to the old ones and then compare the new array with the already modified old array of devices.
Check the difference before adding new device identifiers to the old ones.

* Remove emulator launch from ios-provision-service. (#2971)

* Fix recursive calling of actions. (#2976)

* Emit `liveSyncStarted` when the application is really livesynced (#2977)

`liveSyncStarted` event is currently raised before starting initial LiveSync operation. However this makes sense if the name was `liveSyncStarting`.
So move the event at the end of the initialSync logic - this way it will be raised for each device when the LiveSync is really started.

* Do not attach to the device log on every application start. (#2978)

* Add official support for Node.js 8 (#2979)

* Add official support for Node.js 8

Add npm-shrinkwrap.json that is required for building CLI's package with npm 5. By default npm 5 creates package-lock.json, but it cannot be published. So in case we use `package-lock.json`, we'll always have exact dependency tree when using the repository, but end-users will have different dependency tree. So instead of using package-lock.json we'll use npm-shrinkwrap.json that can be published in npm.

Update engine's tag in package.json, so in case Node.js 8 is used, we'll no longer show warning to the users.

* Ensure symlinks from plugins are copied from realpath to platforms dir

In case a plugin is symlinked or it has symlink files/directories, we do not want to copy the symlink to platforms dir, but the real files. This is required as the symlink may be relative to the current location and copying it makes it invalid.
So pass `-L` option to `shelljs.cp`, so the symlinked files will be followed and the real ones will be copied.

This also fixes unit tests with npm5.

* Fix debug when using CLI as library (#2984)

When CLI is used as a library, the method for debug returns incorrect result - previously the return type of the method we are calling was `string[]`, we've changed it to `string` but forgot to remove the `_.first(result)`.
So now the debug returns incorrect URL. Remove the `_.first` and return the result directly.

*  Separate preparation of JS from native code (#2983)

* Separate preparation of JS from native code

* Introduce new parameter prepareNative to indicate that native code preparation is explicitly required.
* Cache additional data in .nsprepareinfo file:
  * nativePlatformStatus - indicates whether native platform should be added, prepared or there's no need to do so;
  * projectFileHash - saves package.json file's contents hash for the current platform. We use this for better heuristics for checking whether package.json is changed.
* Re-factoring i.e. extract common code to methods

* Fix debug command and unit tests

* Fix npm support tests

Fix the tests by modifying current logic:
 - stop using ensurePrepareInfo for setting `nativePlatformStatus` property - introduce new method for setting it. The problem with using `ensurePrepareInfo` is that it saves the prepareInfo and calling checkForChanges after that is incorrect in case we modify the `bundle` option. Check test: `Ensures that tns_modules absent when bundling` - the last case was failing because when we call ensurePrepareInfo last time, bundle is false, we overwrite the prepareInfo in the file and checkForChanges says that bundle is currently false and has been false in the previous case.
 - in case prepareInfo is missing, we should not call addPlatform again - the else in `ensurePlatformInstalled` is not correct in case we execute `tns platform add <platform>` and then try `tns run/build/prepare <platform>` - in this case we do not have prepareInfo, so we try adding platform again. However, due to current implementation, we are sure that when we do not have prepareInfo, we've called platform add from CLI, so the platform is already added correctly.
 - fix a strange if inside `preparePlatformCoreNative` - we must prepare the node_modules in case `--bundle` is passed or the modulesChanged property of `changesInfo` is true.

* Fix tests requiring package.json at the root of the project

As projectChangesService now checks the package.json at the root of the project, several tests are failing as they are mocking the project creation and there's no package.json at the specified place.
Fix this by creating the package.json in the tests.

* Remove incorrect passing of skipNativePrepare

* Cache instances of "base" commands in debug and run

* Fix run android and run ios - set the platform correctly

* Fix run command

Fix run command by setting correct platform.

* Update common lib

* Fix PR comments

* Fix EPIPE during livesync on iOS (#2987)

In case during `tns run ios` the application is uninstalled manually and after that a change is applied, CLI should install the app and continue with livesync operation. However it fails with EPIPE. The problem was in ios-device-lib - it is fixed in 0.4.8 version.

* Fix error handling during fast sync (#2991)

During fast sync we shouldn't clear all listeners handling `error` event. If we do then any error raised is treated as unhandled and leads to a crash.

* Move skipNativePrepare to deviceDescriptors (#2990)

* Move skipNativePrepare to deviceDescriptors

Each device can use different build types - cloud or local. So the `skipNativePrepare` option should be passed per each device, not for the whole livesync operation.

* Validate native plugin prepare only when skipNativePrepare is not true

* Fix itunes error after run android (#2994)

* Add error handling for debug sockets (#2995)

* Set correct timeout on LiveSync (#2996)

* Fix run without platform on ios. (#2982)

* Fix run without platform on ios.

* Make `tns run` without platform working

Introduce new method in livesync-command-helper to get platforms on which to execute action.
Rename a method in the helper as its purpose is to execute livesync, not to get params for livesync operation.
Pass correct args to detectCurrentlyAttachedDevices in debug command.
Make `tns run` to fail in case there's no running emulators and no devices attached as we are unable to determine for which platform to stat emulator.

* Set version to 3.1.3 and update CHANGELOG

* Fix rebuilding application every time when a change is applied (#3002)

In case you have built your application and you add a new npm package as dependency, the LiveSync will always rebuild the app, no matter of the change applied afterwards. The problem is in our project-changes-service that persists shasum of the package.json. However it is never reset, so we always have the hashed shasum of the package.json when the applcation has been build for the first time. Fix this by setting the correct value for projectFileHash - this way the checks are correct and applying change in .js (.xml, .css) files will not trigger rebuild of app.

* Set version to 3.2.0

* Fix LiveSync on iOS when app is uninstalled manually (#3005)

Whenever application is reinstalled on iOS device, we have to execute full sync operation due to iOS runtime requirements.
However, in case the application is uninstalled manually during LiveSync, CLI will reinstall it, but the code that checks if a full sync is required will return false. The problem is that the `isRebuilt` property (renamed to `isReinstalled` now) really checks if the application has been rebuild during current check and expectedly this returns false.
In order to fix this, change the return type of `ensureLatestAppPackageIsInstalledOnDevice`, so it will give the required information if a full sync should be executed.

Also improve the information that we emit in liveSyncExecuted event:
* add new property - `isFullSync` - it can be used to indicate the current operation
* ensure the `syncedFiles` property contains the really synced files - for Android devices the full sync is not always a full sync - it checks the shasums of files and uploads only the modified ones. At the moment we've been returning all project files in the array, even when we upload only a few (or event none) of them. In order to fix this respect the return type of the `transferDirectory` method and use it in LiveSync operations.

* Respect configuration when preparing project files (#2958)

* "This" is not the correct property invoker in current context (#3013)

Options are passed az function argument and should not be called with this.

* Ensure platforms directory exists prior to preparing (#3014)

* Emit liveSyncStopped event when LiveSync operation is really stopped (#3011)

In case `stopLiveSync` is called during livesync, we should await the current action and emit `liveSyncStopped` event. At the moment, we have the following behavior:
1. In case stopLiveSync is called with deviceIdentifiers, we emit `liveSyncStopped` immediately for all of them. However there may be pending actions, for example build + deploy for current device. We cannot stop the actions, so you receive `liveSyncStopped` and application is installed/updated on device after that.
Fix this by persisting the current action and await it before emitting `liveSyncStopped` event.
2. In case we are currently rebuilding the application and some changes are applied during build, we'll update the `actionsChain`. At this point we'll have several actions in the chain. In case stopLiveSync method is called (without deviceIdentifiers), we will await all pending actions, which will result in awaiting the build, deploy and all other actions and we'll emit the `liveSyncStopped` after that. However we should not execute all pending actions - we should just execute the current one and skip the rest.
In order to fix this, just set isStopped to true before awaiting the actions. This way only the current action will be executed.

* move device discovery to debug command as it is done for run command (#3008)

* move device discovery to debug command as it is done for run command

* update after review

* Emit liveSyncStopped properly when stopping on all devices (#3030)

Whenever stopping on all devices we should emit `liveSyncStopped` for each device.

* livesync deletes files and cleans temp folder afterwards (#3027)

* livesync deletes files and cleans temp folder afterwards

* Add await for livesync reload files.

* Add check for application identifier ios (#3033)

* Fix tns run ios on case sensitive file system (#3045)

In case the file system is case sensitive, `tns run ios` command fails to execute as the `entitlements` file from `app/App_Resources/iOS/` (in case there's such file) is copied to `<project dir>/platforms/ios` dir (the name of iOS dir inside platforms  is lowercased). However the entitlements service expects it to be inside `<project dir>/platforms/iOS` dir. On case sensitive file systems we fail with ENOENT error, as there's no iOS directory. Fix this inside `entitlements service` to use lowercased value. This way it will successfully find the entitlements file inside platforms dir.

* Fix `tns debug <platform> --start` inconsistent behavior (#3047)

`tns debug <platform>` will check all available devices and will prompt the user to select device for debugging. In case the terminal is not interactive, it will select the emulator/device with highest API level.
However, adding `--start` causes failure as the described logic is not used. So ensure we have this behavior even when `--start` is used.

* doctor doesn't crash on missing xcode tools (#3043)

* doctor doesn't crash on missing xcode tools
set a better message when components are up to date

* renamed method and fixed check

* added method return type

* Update .travis.yml (#3050)

* Fix IPA export (#3036)

* fixes #3020

* changes requested from review

* require new version of ios-mobileprovision-finder module

* Update shrinkwrap, so ios-mobileprovision-finder 1.0.10 will be used

* don't restart application twice on crash (#3051)

* Fix message when unable to find devices for LiveSync (#3058)

In case there are attached, but not trusted devices, `tns run <platform>` command prints error that it is unable to find devices and cannot start emulator when platform is not specified.
But the platform has been specified, so improve the error message in such cases.

* Update ios-project-service.ts (#3056)

Fix small typo

* Improve get latest compatible version to search for major.minor.*x* versions (#3052)

* Improve get latest compatible version to search for major.minor.*any* versions

* Update submodule

* Fix the error handling in hooks execution (#3055)

* Fix the error handling in hooks execution

Some hooks can reject their promises without error. We need to check if we have an error before we try to get some information from it.

* Update submodule SHA

* Update ios-sim-portable to 3.1.0 (#3060)

This will fix issue with starting iOS Simulator when a fake device id is passed. Instead we will fail with correct error from now on.

* Fix tns run ios when no simulator is running (#3064)

In case when there's no device attached and no simulator running, `tns run ios` should start default iOS Simulator. However, this fails. The problem is resolved in `ios-sim-portable` 3.1.1.
Bump the version, so the issue will be resolved.

* make livesync work with renamed files and folders (#3042)

* added special check for file changes on Mac

* fix missing imports in tests

* add dir check, modified file check

* check isDirModified before anything else to save time

* updates after review

* bring back check for symlinks

* add check for modification in bot files and folders

* fixed lint

* Fix setup script for Windows #3048 (#3049)

* Change android command line tool

* Fix the default path to android tools to the actual installation point

* Replace x86 image with ARM, when HAXM is not available

* Install x86 with HAMX and otherwise arm image

* Fix passing provision to `tns run ios` and passsing `--teamId` (#3069)

Passing `--provision` to `tns run <ios>` is not respected. Fix this by including additional option in the deviceDescriptors. This allows us to pass different provisions for each device, however in CLI's commands we'll set one provision for all devices.

Also fix passing `--teamId` option - during previous refactoring we've broken the code for it and it has not been respected. Remove the unused alias `teamIdentifier` and use `teamId` in all cases.

* Documented `--provision` option in build-ios.md (#3068)

Documented `--provision` option in build-ios.md

* Add option to use chrome-devtools fronted from appspot (#3071)

* Add option to use chrome-devtools fronted from appspot

URLs starting with `chrome-devtools://devtools/` cannot be opened in chrome with code.
However, we can open the urls in https://chrome-devtools-frontend.appspot.com/, so add new option in Public API that allows using the remote version.

Keep the current default behavior, i.e. for Android we are using the `bundled` DevTools, for iOS we are using a commit pointing to Chrome 55.
In case both `useBundledDevTools` and `useHttpUrl` are passed, the value of `useBundledDevTools` is disregarded.

Add unit tests for all of the cases.

* Add `devToolsCommit` to debug options (and public API)

Currently CLI uses specific SHA of dev tools, that corresponds to Chrome 55. However, we may need different version for Android or iOS, so add new option. This will also allow specifying it from public API, so external calls may pass the commit SHA.

* Fix stopLiveSync method (#3077)

* Fix stopLiveSync method

Currently stopLiveSync method does not emit correct events in some cases. For example, when there's only one attached device and its identifier is passed to `stopLiveSync` method, we do not emit `liveSyncStopped` event.
Fix the code and add unit tests to assure `liveSyncStopped` event is raised correctly.

* Expose getLiveSyncDeviceDescriptors method

Add new public method `getLiveSyncDeviceDescriptors` to `liveSyncService` - its purpose is to get information for current LiveSync operation.

* Fix typo in the messages (#3078)

* Fix native platform add after cloud build. (#3075)

When we prepare the platform for cloud build we skip the native prepare.
After this partial prepare, the platform directory contains only .js files.
In order to make a local build we should add the native part of the platform
which fails with `ENOTEMPTY: directory not empty, rename`.

* Fix simultaneous livesync error (#3074)

* Fix prepare of scoped plugins (#3080)

In case a plugin depends on a scoped package, for example `@angular/core`, trying to use the plugin from local path with npm 5 will fail.
The recommended approach is to declare the scoped package (`@angular/core`) as a devDependency of the plugin. After that, declare both the plugin and the scoped package as dependencies of your project. In case the plugin is installed from local directory, npm 5 creates symlink in node_modules. This means that all files inside `<plugins dir>/node_modules` will be visible for CLI, including the dev dependencies. During project preparation CLI copies `node_modules` from the project to `<project dir>/platforms/<platform>...` directory. We have a specific logic to process only dependencies of each package, i.e. we should remove `@angular/core` from the plugin's node_modules direcotry. However, the logic is not working correctly as instead of using the name `@angular/core` it's been trying to remove `core` only.
Fix getting names of the dependencies, so we'll be able to remove the scoped packages as well.

* Improve iOS log filter regex. (#3079)

* Install correct emulators if/not HAMX is supported (#3072)

* Fix xcode9 provision, provide --quiet by default, enable -allowProvisioningUpdates (#3070)

* Setup the provisioningProfiles in the exportOptions plist, provide quiet flags to xcodebuild and gradle, provide -allowProvisioningUpdates to xcodebuild > 9.0

* Using teamId without arg will print all teams, teamId and provision are mutually exclusive, teamId now should work with name if a provision that has the team id for the provided team name is found

* Add documentation on --team-id near --provision

* Fix versionCompare for the '8.0' and '9.0' versions we compare in ios-project-service

* Address PR review

* Address another PR comment, native builds will now print short friendly message...

* Expose enable/disable debugging (#3065)

Expose enable/disable debugging when CLI is required as a library.
Includes:
* Unify `debug-livesync-service` and `livesync-service` into one class. Enable said class to attach a debugger at runtime during LiveSync
* Remove redundant `debugLivesync` property from `$config` and its every usage
* Remove redundant `debugStop` code in `android-debug-service`
* Raise events in the event of inability to start/stop the app on iOS

* Fix unit-tests on Windows (#3086)

Due to recent changes in `ios-project-service`, some unit tests cannot work on Windows and Linux, so ignore them in case the OS is not macOS.

* Add prefer-const rule to tslint (#3090)

Enable `prefer-const` rule in tslint and fix the errors:
The rule requires that variable declarations use const instead of let and var if possible.

If a variable is only assigned to once when it is declared, it should be declared using `const`

Add new npm script for automatic fix of tslint: `npm run tslint-fix`.
NOTE: In case you have 3 errors that the script can fix, when you execute `npm run tslint-fix`, it will fix them, but will print them as errors again. Run the command again to verify everything is ok.

* Updated changelog for 3.2.0 RC (#3093)

* Updated changelog for 3.2.0 RC

* Update CHANGELOG.md

* update proxy-set command manual to contain information about setting up npm and gradle proxies (#3004)

* Set version to 3.3.0 (#3095)

* Debug improvements (#3094)

* Debug improvements

Includes but is not limited to:
* `enableDebugging` - each promise is now resolved with an object
* added docs for `debuggerAttached` event
* added `debuggerDetached` event and docs for it

* PR Fixes

* Only return debugInfo if url is passed (#3103)

* Enable silent mode setup for Windows #3076 (#3082)

* Add option to skip the questions during setup

* Initialize correctly the answer variable

* Install platform tools api level 25 (#3083)

* Install Google Chrome on Mac for debugging purpose (#3102)

* Emit deviceIdentifier in debuggerAttached event (#3104)

`debuggerAttached` event should emit full information required for debugging. However, the deviceIdentifier is missing, so add it.
Update PublicAPI.md according to latest changes.

* Improve analytics (#3088)

* Improve analytics

We have a requirement to track information in several different providers. However, this may slow down CLI's operations as each track (at least for some of the providers) may last around 100-300ms.
In order to track in multiple analytics provider without slowing down CLI commands, move the tracking to a new process. The process is detached from CLI, so when CLI finishes its work it will exit, while the child process will remain alive until it sends all required information. The new process is called `analytics-broker-process`, it is detached from CLI, but it there's IPC channel between them, so CLI can send information to be tracked. Just before CLI dies, it will send "finish" message to the `broker` process and the IPC channel will be closed.

In CLI implement a new `analytics-service`, so when the methods `track`, `trackFeature` and `trackException` are called, instead of tracking directly in CLI's process (i.e. the old implementation), to send information to the broker process.
The only exception is tracking of the answer if user allows us to send anonymous statistics. As this action requires user interaction, it is executed in CLI's process, a new eqatec analytics monitor is started and the answer is sent to it. After that the analytics is stopped. In case the answer is "yes" and there is more information that we want to track in the current process, it will be send to broker and tracked in all providers. In case the answer is "no", no other data will be tracked.

The broker process is started from analytics process once per process, i.e. on each CLI process (which have something to track) there's a corresponding `analytics-broker-process`. Once it is initialized, it sends BrokerReadyToReceive message to CLI and CLI knows that it can start sending tracking information. Initialization phase is creating a new instance of AnalyticsBroker and attaching handlers for `message` and `disconnect` events. The AnalyitcsBroker itself has a single purpose - sends tracking data to all available prociders. Currently the only provider is `eqatecAnalyticsProvider`. Once CLI sends "finish" message (or `analytics-broker-process` receives `disconnect` event), the process sends information to all providers that there's nothing more to be tracked. When all providers finish their work, they should disocnnect themselves from the broker process and it will exit gracefully.

`EqatecAnalyticsProvider` is used to track features and exceptions in Progress Telerik Analytics. Our requirement is to track features in two projects (same data should be send to both of them) and exceptions in another project. Each of them should be in a separate child process, so failure in one of them will not reflect the others. So the provider starts all required processes. When broker sends information to the provider, it sends it to all required child processes, for example if a feature should be tracked, the provider will send information for it to the two processes used for feature tracking.

Each eqatec child process is a new Node.js  process runnign `eqatec-analytics-process`. Again - this is a detached process. Once it is initialized, it sends "EqatecAnalyticsReadyToReceive" message to the `EqatecAnalyitcsProvider` and it knows it can send information to the new child process. The initialization phase is creation of new instance of `EqatectAnalyticsService`, attaching to "message" and "disconnect" events. Once `EqatecAnalyitcsProvider` receives `EqatecAnalyticsReadyToReceive` message, it sends initialization data for the eqatec monitor. It includes the analytics project API key, user id, current sessions count, etc. The information is persisted in a file on user's machine, so this file should be updated from a single process. As we might have 3 eqatec analytics processes, the provider is the only place where the file should be read and updated.

When `eqatec-analytics-process` receives initialization data, it creates a new instance of the `EqatectAnalyticsService` class with it. However a monitor is not started yet. It will be started when there's something to be tracked, i.e. once `eqatec-analytics-process` receives feature or exception to be tracked.

When `eqatec-analytics-process` receives "finish" message, it awaits all pending requests and after that disconnets itself from the parent. In case this operation fails, the process just exits, which will allow the parent to exit gracefully.

Remove the public `startEqatecMonitor` method from API - it has not been used.

* Craete all eqatec analytics monitors in the broker process

Eqatec Analytics monitors can be created in the broker process directly instead of starting multiple child processes. So delete some unneeded files and move tracking of `AcceptUsageReporting` out of CLI process.

* Add tracking to Google Analytics

Add new methods to track information in Google Analytics(GA). As the data that we want to track is different than the one we track in Eqatec Analytics, call the new methods whenever we want to send some information to GA.
Change the broker process to send information to Eqatec Analytics when we want to track feature or exception and to GA only when the new method for tracking there is called.

In Google Analytics (GA) we track two types of data - pages (called pageviews) and events. Each command is tracked as a page - we only track the name of the command as a page:
* `tns build android` will be tracked as visited page - `build android`
* `tns run` will be tracked as visited page - `run`

When we want to track some additional actions that happen during execution of each command, we send events to GA. Each event has the following data:
* category - currently we do not have a specific category for each action, so it is hardcoded to "CLI".
* action - this is the real action that will be tracked, for example `Build`, `LiveSync`, `Deploy`, etc.
* label - contains specific inforamation for the current action, for example what is the platform, device type, etc. In many cases we send labels with a lot of information, but as the value must be string, we use `_` as a separator. For example:
  * Action `Build` may have the following label: `Android_Debug_Incremental`. This is `<platform>_<build configuration>_<build type>`.
  * Action `LiveSync` may have the following label: `Android_Emulator_5.1`. This is `<platform>_<device type>_<device os version>`.

Custom dimensions
For each additional data may be send to GA via Custom Dimensions. More about them can be found [here](https://support.google.com/analytics/answer/2709828). We are using several custom dimensions, most of them have hit scope, i.e. their values are saved for the current hit (event or page), but may be changed for the next time. The only exclusion is `session id` - it has session scope, so whenever it is sent, the new value overwrites the values of the "session id" property in all hits of the current session.
One interesting custom dimension is `Client` - it will be set to the value of `--analyticsClient` in case it is passed. In case not, we'll set it to "CLI" when terminal is interactive and "Unknown" when terminal is not interactive.

Sessions - what is session for GA
In Eqatec Analytics we call `stopMonitor` at the end of each command. So the session there is one command. In GA we've decided to keep the default way of measuring a session - a session is stopped when there are 30 inactive minutes, i.e. no data is sent from 30 minutes. This allows us to investigate the behavior and the flow of commands a user is executing in a single session (during the day for example).

Client ID and User ID:
Currently we do not send User ID to GA, we use Client ID instead as sending User IDs requires different logic and agreements. For us all users are anonymous.

User-Agent
When sending requests to GA, we need to set correct User-Agent, so GA will be able to understand the Operating System. For each OS the string is painfully specific... Current implementation works fine for Windows, Linux and macOS.

Implementation
In order to send data to GA, we are using a `universal-analytics` npm package. We cannot use Google's default libraries (`analytics.js`, `gtag.js`) as they are written for browser. So the only way to track data is to use the Measurement Protocol (directly send http requests). However, `universal-analytics` package provides a very good abstraction over the Measurement Protocol, so we are using it instead of implementing each call.

More information about Measurement protocol:
https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters

* Fix hanging commands

In case the command is not related to LiveSync, once it finishes its work, CLI process should end. However, this works only on Windows, as the broker child process there is really detached from the parent. On macOS and Linux, the 'ipc' channel between the broker process and CLI, keeps both alive. So use the 'dispose' method, which is called at the end of command execution and disconnect the broker process. In case we are in LiveSync case, set shouldDispose to false and this way the broker will be kept alive. Once Ctrl + C is used to end the CLI process, send the finish message to broker and it will disconnect itself from CLI.

* Update ios-device-lib and plist-merge-patch (#3107)

Update two of the dependencies to their latest versions.
ios-device-lib has a fix that causes hanging in a very rare cases when trying to get installed applications on iOS device: https://github.com/telerik/ios-device-lib/releases/tag/v0.4.9
plist-merge-patch has a fix for merging `LSApplicationQueriesSchemes` values: https://github.com/NativeScript/plist-merge-patch/releases/tag/v0.1.1

* Minor LiveSync+Debug fixes (#3109)

* Analytics fixes (#3110)

Move lockfile service to common and lock operation for writing user settings file

Add new lockfile service (use lockfile npm package) and lock all operations for reading/writing user-settings.json.
These operations may be executed in different pro…
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.

3 participants