Skip to content

Commit 76a619f

Browse files
Dimitar KerezovMitko-Kerezov
Dimitar Kerezov
authored andcommitted
Expose service for configuration
1 parent 430200b commit 76a619f

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

PublicAPI.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,45 @@ for (let promise of loadExtensionsPromises) {
180180
}
181181
```
182182
183+
## settings
184+
`settings` module provides a way to configure various settings.
185+
186+
### set
187+
Used to set various settings in order to modify the behavior of some methods.
188+
* Auxiliary interfaces:
189+
```TypeScript
190+
/**
191+
* Describes configuration settings that modify the behavior of some methods.
192+
*/
193+
interface IConfigurationSettings {
194+
/**
195+
* This string will be used when constructing the UserAgent http header.
196+
* @type {string}
197+
*/
198+
userAgentName: string;
199+
}
200+
```
201+
202+
* Definition:
203+
```TypeScript
204+
/**
205+
* Describes service used to confugure various settings.
206+
*/
207+
interface ISettingsService {
208+
/**
209+
* Used to set various settings in order to modify the behavior of some methods.
210+
* @param {IConfigurationSettings} settings Settings which will modify the behaviour of some methods.
211+
* @returns {void}
212+
*/
213+
setSettings(settings: IConfigurationSettings): void;
214+
}
215+
```
216+
217+
* Usage:
218+
```JavaScript
219+
tns.settingsService.setSettings({ userAgentName: "myUserAgent" });
220+
```
221+
183222
## How to add a new method to Public API
184223
CLI is designed as command line tool and when it is used as a library, it does not give you access to all of the methods. This is mainly implementation detail. Most of the CLI's code is created to work in command line, not as a library, so before adding method to public API, most probably it will require some modification.
185224
For example the `$options` injected module contains information about all `--` options passed on the terminal. When the CLI is used as a library, the options are not populated. Before adding method to public API, make sure its implementation does not rely on `$options`.

test/nativescript-cli-lib.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ describe("nativescript-cli-lib", () => {
1313
});
1414

1515
const publicApi: any = {
16+
settingsService: ["setSettings"],
1617
deviceEmitter: null,
1718
projectService: ["createProject", "isValidNativeScriptProject"],
1819
localBuildService: ["build"],

0 commit comments

Comments
 (0)