Skip to content

Conversation

@rosen-vladimirov
Copy link
Contributor

@rosen-vladimirov rosen-vladimirov commented Nov 8, 2017

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:

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().

NOTE: Merge after telerik/mobile-cli-lib#1023

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()`.
@rosen-vladimirov rosen-vladimirov force-pushed the vladimirov/profile-dir-setting branch from 8b85f96 to c4c4152 Compare November 8, 2017 12:09
@rosen-vladimirov rosen-vladimirov merged commit be3d4f1 into master Nov 8, 2017
@rosen-vladimirov rosen-vladimirov deleted the vladimirov/profile-dir-setting branch November 8, 2017 15:13
rosen-vladimirov added a commit that referenced this pull request Nov 13, 2017
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()`.
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