Skip to content

Commit f81499d

Browse files
authored
feat: add config to help menu (#5916)
1 parent cc94b80 commit f81499d

File tree

21 files changed

+1197
-1547
lines changed

21 files changed

+1197
-1547
lines changed

docs/build-jekyll-md.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ set -e
44
rm -rf docs-cli
55
npm install --ignore-scripts
66

7-
grunt docs-jekyll
7+
npx grunt docs-jekyll
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<% if (isJekyll) { %>---
2+
title: ns config get
3+
position: 2
4+
---<% } %>
5+
6+
# ns config get
7+
8+
### Description
9+
10+
Prints the value for a specific key from the project's NativeScript configuration.
11+
12+
### Commands
13+
14+
Usage | Synopsis
15+
------|-------
16+
General | `$ ns config get <key>`
17+
18+
### Arguments
19+
20+
* `<key>` — The configuration key in dot-notation. Examples: `ios.id`, `android.codeCache`, `bundler`.
21+
22+
### Examples
23+
24+
* `$ ns config get ios.id`
25+
* `$ ns config get android.codeCache`
26+
* `$ ns config get bundler`
27+
28+
<% if(isHtml) { %>
29+
30+
### Related Commands
31+
32+
Command | Description
33+
----------|----------
34+
[config](config.html) | Lists all configuration values for the current project.
35+
[config set](config-set.html) | Sets the value for the specified configuration key.
36+
<% } %>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<% if (isJekyll) { %>---
2+
title: ns config set
3+
position: 3
4+
---<% } %>
5+
6+
# ns config set
7+
8+
### Description
9+
10+
Sets the value for a specific key in the project's NativeScript configuration.
11+
12+
### Commands
13+
14+
Usage | Synopsis
15+
------|-------
16+
General | `$ ns config set <key> <value>`
17+
18+
### Arguments
19+
20+
* `<key>` — The configuration key in dot-notation. Examples: `ios.id`, `android.codeCache`, `bundler`.
21+
* `<value>` — The value to set. Parsed as JSON when possible (e.g. `true`, `42`, `{ "foo": "bar" }`). Otherwise treated as a string.
22+
23+
### Examples
24+
25+
* `$ ns config set ios.id org.nativescript.myapp`
26+
* `$ ns config set android.codeCache true`
27+
* `$ ns config set bundler vite`
28+
29+
### Notes
30+
31+
* Setting whole objects is not supported. Update individual keys instead. For example, use:
32+
`$ ns config set android.codeCache true`
33+
34+
### Related Commands
35+
36+
Command | Description
37+
----------|----------
38+
[config](config.html) | Lists all configuration values for the current project.
39+
[config get](config-get.html) | Prints the value for the specified configuration key.
40+
<% } %>

docs/man_pages/config/config.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<% if (isJekyll) { %>---
2+
title: ns config
3+
position: 1
4+
---<% } %>
5+
6+
# ns config
7+
8+
### Description
9+
10+
View and manage your project's NativeScript configuration stored in `nativescript.config.(js|ts)` (or legacy `nsconfig.json`).
11+
12+
### Commands
13+
14+
Usage | Synopsis
15+
------|---------
16+
List all config | `$ ns config`
17+
Get a value | `$ ns config get <key>`
18+
Set a value | `$ ns config set <key> <value>`
19+
20+
### Examples
21+
22+
* `$ ns config` — prints all configuration values.
23+
* `$ ns config get ios.id` — prints the iOS bundle identifier.
24+
* `$ ns config set android.codeCache true` — enables Android V8 code cache.
25+
26+
### Notes
27+
28+
* Keys use dot-notation, for example: `ios.id`, `android.codeCache`, `bundler`.
29+
* Values are parsed as JSON when possible. Use quotes for strings with spaces.
30+
31+
<% if(isHtml) { %>
32+
33+
### Related Commands
34+
35+
Command | Description
36+
----------|----------
37+
[config get](config-get.html) | Prints the value for the specified configuration key.
38+
[config set](config-set.html) | Sets the value for the specified configuration key.
39+
<% } %>

lib/commands/debug.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import * as _ from "lodash";
2020

2121
export class DebugPlatformCommand
2222
extends ValidatePlatformCommandBase
23-
implements ICommand {
23+
implements ICommand
24+
{
2425
public allowedParameters: ICommandParameter[] = [];
2526

2627
constructor(
@@ -36,13 +37,13 @@ export class DebugPlatformCommand
3637
private $debugDataService: IDebugDataService,
3738
private $debugController: IDebugController,
3839
private $liveSyncCommandHelper: ILiveSyncCommandHelper,
39-
private $migrateController: IMigrateController
40+
private $migrateController: IMigrateController,
4041
) {
4142
super(
4243
$options,
4344
$platformsDataService,
4445
$platformValidationService,
45-
$projectData
46+
$projectData,
4647
);
4748
$cleanupService.setShouldDispose(false);
4849
}
@@ -66,10 +67,10 @@ export class DebugPlatformCommand
6667
const debugData = this.$debugDataService.getDebugData(
6768
selectedDeviceForDebug.deviceInfo.identifier,
6869
this.$projectData,
69-
debugOptions
70+
debugOptions,
7071
);
7172
await this.$debugController.printDebugInformation(
72-
await this.$debugController.startDebug(debugData)
73+
await this.$debugController.startDebug(debugData),
7374
);
7475
return;
7576
}
@@ -83,7 +84,7 @@ export class DebugPlatformCommand
8384
},
8485
buildPlatform: undefined,
8586
skipNativePrepare: false,
86-
}
87+
},
8788
);
8889
}
8990

@@ -98,17 +99,17 @@ export class DebugPlatformCommand
9899
if (
99100
!this.$platformValidationService.isPlatformSupportedForOS(
100101
this.platform,
101-
this.$projectData
102+
this.$projectData,
102103
)
103104
) {
104105
this.$errors.fail(
105-
`Applications for platform ${this.platform} can not be built on this OS`
106+
`Applications for platform ${this.platform} can not be built on this OS`,
106107
);
107108
}
108109

109110
if (this.$options.release) {
110111
this.$errors.failWithHelp(
111-
"--release flag is not applicable to this command."
112+
"--release flag is not applicable to this command.",
112113
);
113114
}
114115

@@ -138,12 +139,12 @@ export class DebugIOSCommand implements ICommand {
138139
private $sysInfo: ISysInfo,
139140
private $projectData: IProjectData,
140141
$iosDeviceOperations: IIOSDeviceOperations,
141-
$iOSSimulatorLogProvider: Mobile.IiOSSimulatorLogProvider
142+
$iOSSimulatorLogProvider: Mobile.IiOSSimulatorLogProvider,
142143
) {
143144
this.$projectData.initializeProjectData();
144145
// Do not dispose ios-device-lib, so the process will remain alive and the debug application (NativeScript Inspector or Chrome DevTools) will be able to connect to the socket.
145146
// In case we dispose ios-device-lib, the socket will be closed and the code will fail when the debug application tries to read/send data to device socket.
146-
// That's why the `$ tns debug ios --justlaunch` command will not release the terminal.
147+
// That's why the `$ ns debug ios --justlaunch` command will not release the terminal.
147148
// In case we do not set it to false, the dispose will be called once the command finishes its execution, which will prevent the debugging.
148149
$iosDeviceOperations.setShouldDispose(false);
149150
$iOSSimulatorLogProvider.setShouldDispose(false);
@@ -157,18 +158,18 @@ export class DebugIOSCommand implements ICommand {
157158
if (
158159
!this.$platformValidationService.isPlatformSupportedForOS(
159160
this.$devicePlatformsConstants.iOS,
160-
this.$projectData
161+
this.$projectData,
161162
)
162163
) {
163164
this.$errors.fail(
164-
`Applications for platform ${this.$devicePlatformsConstants.iOS} can not be built on this OS`
165+
`Applications for platform ${this.$devicePlatformsConstants.iOS} can not be built on this OS`,
165166
);
166167
}
167168

168169
const isValidTimeoutOption = this.isValidTimeoutOption();
169170
if (!isValidTimeoutOption) {
170171
this.$errors.fail(
171-
`Timeout option specifies the seconds NativeScript CLI will wait to find the inspector socket port from device's logs. Must be a number.`
172+
`Timeout option specifies the seconds NativeScript CLI will wait to find the inspector socket port from device's logs. Must be a number.`,
172173
);
173174
}
174175

@@ -179,7 +180,7 @@ export class DebugIOSCommand implements ICommand {
179180
macOSWarning.severity === SystemWarningsSeverity.high
180181
) {
181182
this.$errors.fail(
182-
`You cannot use NativeScript Inspector on this OS. To use it, please update your OS.`
183+
`You cannot use NativeScript Inspector on this OS. To use it, please update your OS.`,
183184
);
184185
}
185186
}
@@ -224,7 +225,7 @@ export class DebugAndroidCommand implements ICommand {
224225
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
225226
private $injector: IInjector,
226227
private $projectData: IProjectData,
227-
private $options: IOptions
228+
private $options: IOptions,
228229
) {
229230
this.$projectData.initializeProjectData();
230231
}

lib/common/definitions/extensibility.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,15 @@ interface IExtensibilityService {
124124
* Gives the name of the extension that contains a required command.
125125
* The method finds all extensions from npm and checks the command property defined in the nativescript key of the package.json.
126126
* Based on specified input array, the method tries to find a suitable command that is defined in the extension.
127-
* @example In case the input is `tns execute this command now`, the array will be ["execute", "this", "command", "now"].
127+
* @example In case the input is `ns execute this command now`, the array will be ["execute", "this", "command", "now"].
128128
* There may be an extension that defines execute|this as a command. The method will check each extension for the following commands:
129129
* execute|this|command|now, execute|this|command, execute|this, execute
130130
* In case it finds any of this commands, the method will return the extension name and the command name.
131131
* @param {string[]} inputStrings All strings written on the terminal.
132132
* @returns {IExtensionCommandInfo} Information about the extension and the registered command.
133133
*/
134134
getExtensionNameWhereCommandIsRegistered(
135-
inputOpts: IGetExtensionCommandInfoParams
135+
inputOpts: IGetExtensionCommandInfoParams,
136136
): Promise<IExtensionCommandInfo>;
137137

138138
/**

0 commit comments

Comments
 (0)