Skip to content

Commit 3ca6474

Browse files
Add command for setting proxy (#2660)
At the moment users can set proxy by manually editing the file `<cli installation dir>/config/config.json`. However this has two issues: - the proxy does not support authentication - if you install newer version of CLI, the file is overwritten, so you have to set it again. Fix both issues by: - creating command that sets the proxy. - (currently) for Windows introduce support for authenticated proxy - username and password are stored via Windows Credential Manager API functions. Expected workflow: `$ tns <command that makes http request>` Your proxy requires a username and password. You can run tns proxy set <hostname> <port> <username> <password> In order to supply NativeScript with the credentials needed. `$ tns proxy set 127.0.0.1 8888 user pass` Sucessfully setup proxy. `$ tns proxy get` Hostname: 127.0.0.1 Port: 8888 Proxy is Enabled `$ tns proxy clear` Sucessfully cleared proxy. `$ tns proxy get` No proxy set
1 parent cc56ed2 commit 3ca6474

16 files changed

+102
-11
lines changed

config/config.json

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
22
"DEBUG": false,
3-
"USE_PROXY": false,
4-
"PROXY_PORT": 8888,
5-
"PROXY_HOSTNAME": "127.0.0.1",
63
"TYPESCRIPT_COMPILER_OPTIONS": {},
74
"CI_LOGGER": false,
85
"ANDROID_DEBUG_UI_MAC": "Google Chrome",

docs/man_pages/general/autocomplete-disable.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ General | `$ tns autocomplete disable`
88
Disables command-line completion for bash and zsh shells. You need to restart the shell to complete the operation.
99

1010
<% if(isHtml) { %>> <% } %>NOTE: This operation might modify the `.bash_profile`, `.bashrc` and `.zshrc` files.
11-
<% if(isHtml) { %>
11+
<% if(isHtml) { %>
1212
### Related Commands
1313

1414
Command | Description
@@ -20,4 +20,7 @@ Command | Description
2020
[error-reporting](error-reporting.html) | Configures anonymous error reporting for the NativeScript CLI.
2121
[help](help.html) | Lists the available commands or shows information about the selected command.
2222
[doctor](doctor.html) | Checks your system for configuration problems which might prevent the NativeScript CLI from working properly.
23+
[proxy](proxy.html) | Displays proxy settings.
24+
[proxy clear](proxy-clear.html) | Clears proxy settings.
25+
[proxy set](proxy-set.html) | Sets proxy settings.
2326
<% } %>

docs/man_pages/general/autocomplete-enable.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ General | `$ tns autocomplete enable`
88
Enables command-line completion for bash and zsh shells. You need to restart the shell to complete the operation.
99

1010
<% if(isHtml) { %>> <% } %>NOTE: This operation might modify the `.bash_profile`, `.bashrc` and `.zshrc` files.
11-
<% if(isHtml) { %>
11+
<% if(isHtml) { %>
1212
### Related Commands
1313

1414
Command | Description
@@ -20,4 +20,7 @@ Command | Description
2020
[error-reporting](error-reporting.html) | Configures anonymous error reporting for the NativeScript CLI.
2121
[help](help.html) | Lists the available commands or shows information about the selected command.
2222
[doctor](doctor.html) | Checks your system for configuration problems which might prevent the NativeScript CLI from working properly.
23+
[proxy](proxy.html) | Displays proxy settings.
24+
[proxy clear](proxy-clear.html) | Clears proxy settings.
25+
[proxy set](proxy-set.html) | Sets proxy settings.
2326
<% } %>

docs/man_pages/general/autocomplete-status.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ General | `$ tns autocomplete status`
77

88
Prints your current command-line completion settings.
99

10-
<% if(isHtml) { %>
10+
<% if(isHtml) { %>
1111
### Related Commands
1212

1313
Command | Description
@@ -19,4 +19,7 @@ Command | Description
1919
[error-reporting](error-reporting.html) | Configures anonymous error reporting for the NativeScript CLI.
2020
[help](help.html) | Lists the available commands or shows information about the selected command.
2121
[doctor](doctor.html) | Checks your system for configuration problems which might prevent the NativeScript CLI from working properly.
22+
[proxy](proxy.html) | Displays proxy settings.
23+
[proxy clear](proxy-clear.html) | Clears proxy settings.
24+
[proxy set](proxy-set.html) | Sets proxy settings.
2225
<% } %>

docs/man_pages/general/autocomplete.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Prints your current command-line completion settings. If disabled, prompts you t
1818
* `enable` - Enables command-line completion. You need to restart the shell to complete the operation.
1919
* `disable` - Disables command-line completion. You need to restart the shell to complete the operation.
2020

21-
<% if(isHtml) { %>
21+
<% if(isHtml) { %>
2222
### Related Commands
2323

2424
Command | Description
@@ -29,4 +29,7 @@ Command | Description
2929
[usage-reporting](usage-reporting.html) | Configures anonymous usage reporting for the NativeScript CLI.
3030
[error-reporting](error-reporting.html) | Configures anonymous error reporting for the NativeScript CLI.
3131
[doctor](doctor.html) | Checks your system for configuration problems which might prevent the NativeScript CLI from working properly.
32+
[proxy](proxy.html) | Displays proxy settings.
33+
[proxy clear](proxy-clear.html) | Clears proxy settings.
34+
[proxy set](proxy-set.html) | Sets proxy settings.
3235
<% } %>

docs/man_pages/general/doctor.md

+3
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@ Command | Description
1717
[autocomplete](autocomplete.html) | Prints your current command-line completion settings. If disabled, prompts you to enable it.
1818
[help](help.html) | Lists the available commands or shows information about the selected command.
1919
[info](info.html) | Displays version information about the NativeScript CLI, core modules, and runtimes.
20+
[proxy](proxy.html) | Displays proxy settings.
21+
[proxy clear](proxy-clear.html) | Clears proxy settings.
22+
[proxy set](proxy-set.html) | Sets proxy settings.
2023
<% } %>

docs/man_pages/general/error-reporting.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ All data gathered is used strictly for improving the product and will never be u
1515
* `enable` - Enables anonymous error reporting.
1616
* `disable` - Disables anonymous error reporting.
1717

18-
<% if(isHtml) { %>
18+
<% if(isHtml) { %>
1919
### Related Commands
2020

2121
Command | Description
@@ -26,4 +26,7 @@ Command | Description
2626
[autocomplete-enable](autocomplete-enable.html) | Enables command-line completion for bash and zsh shells.
2727
[autocomplete-disable](autocomplete-disable.html) | Disables command-line completion for bash and zsh shells.
2828
[doctor](doctor.html) | Checks your system for configuration problems which might prevent the NativeScript CLI from working properly.
29+
[proxy](proxy.html) | Displays proxy settings.
30+
[proxy clear](proxy-clear.html) | Clears proxy settings.
31+
[proxy set](proxy-set.html) | Sets proxy settings.
2932
<% } %>

docs/man_pages/general/help.md

+3
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ Command | Description
2323
[autocomplete](autocomplete.html) | Prints your current command-line completion settings. If disabled, prompts you to enable it.
2424
[doctor](doctor.html) | Checks your system for configuration problems which might prevent the NativeScript CLI from working properly.
2525
[info](info.html) | Displays version information about the NativeScript CLI, core modules, and runtimes.
26+
[proxy](proxy.html) | Displays proxy settings.
27+
[proxy clear](proxy-clear.html) | Clears proxy settings.
28+
[proxy set](proxy-set.html) | Sets proxy settings.
2629
<% } %>

docs/man_pages/general/info.md

+3
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@ Command | Description
1717
[autocomplete](autocomplete.html) | Prints your current command-line completion settings. If disabled, prompts you to enable it.
1818
[help](help.html) | Lists the available commands or shows information about the selected command.
1919
[doctor](doctor.html) | Checks your system for configuration problems which might prevent the NativeScript CLI from working properly.
20+
[proxy](proxy.html) | Displays proxy settings.
21+
[proxy clear](proxy-clear.html) | Clears proxy settings.
22+
[proxy set](proxy-set.html) | Sets proxy settings.
2023
<% } %>

docs/man_pages/general/proxy-clear.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
proxy clear
2+
==========
3+
4+
Usage | Synopsis
5+
------|-------
6+
General | `$ tns proxy clear`
7+
8+
Clears proxy settings.
9+
10+
<% if(isHtml) { %>
11+
### Related Commands
12+
13+
Command | Description
14+
----------|----------
15+
[proxy](proxy.html) | Displays proxy settings.
16+
[proxy set](proxy-set.html) | Sets proxy settings.
17+
<% } %>

docs/man_pages/general/proxy-set.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
proxy set
2+
==========
3+
4+
Usage | Synopsis
5+
------|-------
6+
General | `$ tns proxy set [<Hostname> [<Port><% if(isWindows) {%> [<Username> [<Password>]]<%}%>]]`
7+
8+
Sets proxy settings.
9+
10+
### Attributes
11+
* `<Hostname>` the hostname of the proxy. If you do not provide this when running the command, the NativeScript CLI will prompt you to provide it.
12+
* `<Port>` the port of the proxy. If you do not provide this when running the command, the NativeScript CLI will prompt you to provide it.
13+
<% if(isWindows) {%>
14+
* `<Username>` and `<Password>` are your credentials for the proxy. These are not necessary, however if you provide a `<Username>` you need to provide a `<Password>` too.
15+
<% } %>
16+
17+
<% if(isHtml) { %>
18+
### Command Limitations
19+
20+
* You can set credentials only on Windows Systems.
21+
22+
### Related Commands
23+
24+
Command | Description
25+
----------|----------
26+
[proxy](proxy.html) | Displays proxy settings.
27+
[proxy clear](proxy-clear.html) | Clears proxy settings.
28+
<% } %>

docs/man_pages/general/proxy.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
proxy
2+
==========
3+
4+
Usage | Synopsis
5+
------|-------
6+
General | `$ tns proxy [<Command>]`
7+
8+
Displays proxy settings.
9+
10+
### Attributes
11+
`<Command>` extends the `proxy` command. You can set the following values for this attribute.
12+
* `set` - Sets proxy settings
13+
* `clear` - Clears proxy settings
14+
15+
<% if(isHtml) { %>
16+
### Related Commands
17+
18+
Command | Description
19+
----------|----------
20+
[proxy clear](proxy-clear.html) | Clears proxy settings.
21+
[proxy set](proxy-set.html) | Sets proxy settings.
22+
<% } %>

docs/man_pages/general/usage-reporting.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ All data gathered is used strictly for improving the product and will never be u
1515
* `enable` - Enables anonymous usage reporting.
1616
* `disable` - Disables anonymous usage reporting.
1717

18-
<% if(isHtml) { %>
18+
<% if(isHtml) { %>
1919
### Related Commands
2020

2121
Command | Description
@@ -26,4 +26,7 @@ Command | Description
2626
[autocomplete-enable](autocomplete-enable.html) | Enables command-line completion for bash and zsh shells.
2727
[autocomplete-disable](autocomplete-disable.html) | Disables command-line completion for bash and zsh shells.
2828
[doctor](doctor.html) | Checks your system for configuration problems which might prevent the NativeScript CLI from working properly.
29+
[proxy](proxy.html) | Displays proxy settings.
30+
[proxy clear](proxy-clear.html) | Clears proxy settings.
31+
[proxy set](proxy-set.html) | Sets proxy settings.
2932
<% } %>

docs/man_pages/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Command | Description
1515
[error-reporting](general/error-reporting.html) | Configures anonymous error reporting for the NativeScript CLI.
1616
[doctor](general/doctor.html) | Checks your system for configuration problems which might prevent the NativeScript CLI from working properly.
1717
[info](general/info.html) | Displays version information about the NativeScript CLI, core modules, and runtimes.
18+
[proxy](general/proxy.html) | Displays proxy settings.
1819

1920
## Project Development Commands
2021
Command | Description

lib/config.ts

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export class Configuration extends ConfigBase implements IConfiguration { // Use
66
CI_LOGGER = false;
77
DEBUG = false;
88
TYPESCRIPT_COMPILER_OPTIONS = {};
9-
USE_PROXY = false;
109
ANDROID_DEBUG_UI: string = null;
1110
USE_POD_SANDBOX: boolean = false;
1211
debugLivesync: boolean = false;

0 commit comments

Comments
 (0)