10000 Cherry-pick commits for {N} CLI 3.3.1 release by rosen-vladimirov · Pull Request #1027 · telerik/mobile-cli-lib · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Cherry-pick commits for {N} CLI 3.3.1 release #1027

Merged
merged 8 commits into from
Nov 15, 2017

Conversation

rosen-vladimirov
Copy link
Collaborator
@rosen-vladimirov rosen-vladimirov commented Nov 13, 2017

Cherry-picked in release:

rosen-vladimirov and others added 8 commits November 13, 2017 11:42
Currently unit tests fail on Windows as the `type` command used in the tests is not a real executable - it is integrated in the `cmd`. So spawning `type` fails and the tests fail as well.
In order to fix this, pass `shell` option to child process, so the child process will spawn CMD and after that type command will succeed.
In case iOS Device is detached, the `IOSDevice` instance is kept alive. The reason is the handler for device logs, that `IOSDevice` passes to `iOSDeviceOperations`.
As `iOSDeviceOperations` is still alive, the `IOSDevice` instance is also alive. Reattaching the same device will cause duplicate logs. Detaching and attaching it again will lead to additional logs.

In order to fix the issue, convert `iOSDeviceOpertations` to event emitter and emit event when there's data for logging. Each `IOSDevice` will add handler for the event and will do its logic.
In case device is detached (i.e. `DeviceLost` event is fired in `DevicesService`), call a newly added method to the specific `IDevice` instance. It's purpose is to clean the used resource.
For iOS device, this method will remove the handler for `devceLogData` event of `iOSDeviceOperations`.
In case any command fails, we execute help command in order to show the help content. This leads to multiple trackings, i.e. - user executes only one command, but in Analytics we see two commands.
Instead of executing help command, introduce new method in htmlHelpService, that prints the help to the terminal and call it instead. Use the same method in the help command itself.
Rename htmlHelpService to helpService - it has been incorrectly named from the beginning.
Remove `helpTextPath` from staticConfig interface - this property is not used for more than 2 years.
Introduce tests for `helpService` - get the tests from AppBuilder CLI.
As the injected dependency, class and interface have been renamed, rename the file as well.
Currently CLI's configuration directory is used from `$options.profileDir`. When user passes `--profileDir <path>`, the `$options.profileDir` value is populated.
In case user does not pass anything, a default value is set. All services that require configuration directory use the `$options.profileDir`. However, this causes several issues:
- `$options` is intended for use only when CLI is used as a standalone command line. In case you are using it as a library, the `$options` object will not be populated.
- Unable to test local installations of extensions when CLI is used as library - there's no way to set the custom profileDir when using CLI as a library. So the extensions are always loaded from the default location.

In order to resolve these issues, move the logic for profileDir in `settingsService` and introduce a new method to get the profileDir. In order to ensure code is backwards compatible (i.e. extensions that use `$options.profileDir` should still work), modify `$options` to set the value of `profileDir` in `settingsService`.
Whenever you want to test local extensions you can use:
```JavaScript
const tns = require("nativescript");
tns.settingsService.setSettings({ profileDir: "my custom dir" });
Promise.all(tns.extensibilityService.loadExtensions())
	.then((result) => {
		console.log("Loaded extensions:", result);
		// write your code here
	});
```

Replace all places where `$options.profileDir` is used with `$settingsService.getProfileDir()`.
In case user executes:
- `tns help` - we should show the default index.html help with all commands
- `tns --help` - we should show the default command line help generated from index.md file with all commands

This has been broken during changing html-help-service to help-service.
Fix the default behavior and add tests for it.
In case you need a hook to be executed outside of process, you should place correct shebang at the beginning of the file and CLI should spawn it.
However, this is not working at the moment, as when CLI detects that the hook should be spawned, it just does nothing. The code is incorrectly placed inside the `if` for in process execution. This causes another issue - in case a hook returns a function, which returns falsey value, we decide the hook should be executed outside of process and spawn a new Node.js process to execute the hook. So we execute it twice.

Fix the if-else logic, so the hooks will work correctly.
@rosen-vladimirov rosen-vladimirov merged commit 6fbcb97 into release Nov 15, 2017
@rosen-vladimirov rosen-vladimirov deleted the vladimirov/release-331 branch November 15, 2017 11:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0