Skip to content

Commit 011b02b

Browse files
NathanWalkerrigor789
authored andcommitted
feat: config file handling
1 parent 2cda1e6 commit 011b02b

25 files changed

+204
-151
lines changed

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ When the patch is reviewed and merged, you can safely delete your branch and pul
9595
Updating the CLI Documentation
9696
===
9797

98-
The CLI documentation is what you see when running the `tns help` command.
98+
The CLI documentation is what you see when running the `ns help` command.
9999
This documentation is distributed as part of the CLI package and is generated from the *.md files that can be found in <a href="https://github.com/NativeScript/nativescript-cli/tree/master/docs/man_pages" target="_blank">man_pages folder</a>
100100
The output of the documentation is html static pages that are generated on post install hook of the CLI installation.
101101
In addition, documentation generation is triggered every time there is no html article for the respective help command that is executed.
102102

103-
In order to see a change applied in your development workspace after editing the *.md files, you can use the `tns dev-generate-help` command.
103+
In order to see a change applied in your development workspace after editing the *.md files, you can use the `ns dev-generate-help` command.
104104
This will trigger regeneration of all html files on your local environment. Mind that you need to run from the /bin folder of the nativescript_cli.
105105

106106
[Back to Top][1]

PublicAPI.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -1514,8 +1514,8 @@ setCleanupLogFile(filePath: string): void;
15141514
15151515
* Usage
15161516
```JavaScript
1517-
const tns = require("nativescript");
1518-
tns.cleanupService.setCleanupLogFile("/Users/username/cleanup-logs.txt");
1517+
const ns = require("nativescript");
1518+
ns.cleanupService.setCleanupLogFile("/Users/username/cleanup-logs.txt");
15191519
```
15201520
15211521
## initializeService
@@ -1544,18 +1544,18 @@ interface IInitializeService {
15441544
* Usage
15451545
* Initialization without passing any data - `logger` will be initialized with default CLI settings. Warnings will be printed if there are any.
15461546
```JavaScript
1547-
const tns = require("nativescript");
1548-
tns.initializeService.initialize();
1547+
const ns = require("nativescript");
1548+
ns.initializeService.initialize();
15491549
```
15501550
* Initialize with custom settings service options:
15511551
```JavaScript
1552-
const tns = require("nativescript");
1553-
tns.initializeService.initialize({ settingsServiceOptions: { profileDir: "/Users/username/customDir", userAgentName: "MyApp" } });
1552+
const ns = require("nativescript");
1553+
ns.initializeService.initialize({ settingsServiceOptions: { profileDir: "/Users/username/customDir", userAgentName: "MyApp" } });
15541554
```
15551555
* Initialize with custom extensibility path:
15561556
```JavaScript
1557-
const tns = require("nativescript");
1558-
tns.initializeService.initialize({ extensibilityOptions: { pathToExtensions: "/Users/username/customDir/extensions" } });
1557+
const ns = require("nativescript");
1558+
ns.initializeService.initialize({ extensibilityOptions: { pathToExtensions: "/Users/username/customDir/extensions" } });
15591559
```
15601560
15611561
## logger
@@ -1633,7 +1633,7 @@ The `emit-appender` is used to emit the log events through a passed emitter inst
16331633
16341634
* Usage:
16351635
```JavaScript
1636-
const tns = require("nativescript");
1636+
const ns = require("nativescript");
16371637
const { EventEmitter } = require("events");
16381638
const { EMIT_APPENDER_EVENT_NAME, LoggerAppenders } = tns.constants;
16391639
const emitter = new EventEmitter();
@@ -1646,7 +1646,7 @@ emitter.on(EMIT_APPENDER_EVENT_NAME, (logData) => {
16461646
}
16471647
});
16481648

1649-
const logger = tns.logger;
1649+
const logger = ns.logger;
16501650
logger.initialize({
16511651
appenderOptions: {
16521652
type: LoggerAppenders.emitAppender,
@@ -1655,18 +1655,18 @@ logger.initialize({
16551655
});
16561656
```
16571657
1658-
> NOTE: In several cases CLI passes additional configuration properties in the `context` of the `loggingEvent`. Full list is available in the `tns.constants.LoggerConfigData` object. These properties are used by CLI's layout and appender to change the way the message is printed on the terminal and if it should be on stderr or stdout.
1658+
> NOTE: In several cases CLI passes additional configuration properties in the `context` of the `loggingEvent`. Full list is available in the `ns.constants.LoggerConfigData` object. These properties are used by CLI's layout and appender to change the way the message is printed on the terminal and if it should be on stderr or stdout.
16591659
16601660
#### cli-appender
16611661
`cli-appender` prints messages to stdout or stderr based on the passed options for the message.
16621662
16631663
* Usage
16641664
```JavaScript
1665-
const tns = require("nativescript");
1665+
const ns = require("nativescript");
16661666
const { EventEmitter } = require("events");
1667-
const { EMIT_APPENDER_EVENT_NAME, LoggerAppenders } = tns.constants;
1667+
const { EMIT_APPENDER_EVENT_NAME, LoggerAppenders } = ns.constants;
16681668

1669-
const logger = tns.logger;
1669+
const logger = ns.logger;
16701670
logger.initialize({
16711671
appenderOptions: {
16721672
type: LoggerAppenders.cliAppender,
@@ -1685,7 +1685,7 @@ log4js.addLayout("myCustomLayout", (config) => {
16851685
}
16861686
});
16871687

1688-
tns.logger.initialize({ appenderOptions: { layout: { type: "myCustomLayout" } } });
1688+
ns.logger.initialize({ appenderOptions: { layout: { type: "myCustomLayout" } } });
16891689
```
16901690
16911691
## How to add a new method to Public API

README.md

+20-20
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Linux | `sudo npm install nativescript -g --unsafe-perm` | `npm install nativesc
106106
To check if your system is configured properly, run the following command.
107107

108108
```Shell
109-
tns doctor
109+
ns doctor
110110
```
111111

112112
## Configure Proxy Settings
@@ -116,7 +116,7 @@ If you are working with the NativeScript CLI behind a web proxy, you need to con
116116
### Set Proxy Settings
117117

118118
```Shell
119-
tns proxy set <Url> <Username> <Password>
119+
ns proxy set <Url> <Username> <Password>
120120
```
121121

122122
#### Attributes
@@ -143,13 +143,13 @@ The <code>--insecure</code> flag allows you to perform insecure SSL connections
143143
### Display Current Proxy Settings
144144

145145
```Shell
146-
tns proxy
146+
ns proxy
147147
```
148148

149149
### Clear Proxy Settings
150150

151151
```Shell
152-
tns proxy clear
152+
ns proxy clear
153153
```
154154

155155
[Back to Top][1]
@@ -165,7 +165,7 @@ Quick Start
165165

166166
## The Commands
167167

168-
Run `tns help` to view all available commands in the browser. Run `tns help <Command>` to view more information about a selected command in the browser. `tns --help` opens console help, where help information is shown in the console.
168+
Run `ns help` to view all available commands in the browser. Run `ns help <Command>` to view more information about a selected command in the browser. `ns --help` opens console help, where help information is shown in the console.
169169

170170
[Back to Top][1]
171171

@@ -174,28 +174,28 @@ Run `tns help` to view all available commands in the browser. Run `tns help <Com
174174
To create a new cross-platform project from the default JavaScript template, run the following command.
175175

176176
```Shell
177-
tns create MyApp --js
177+
ns create MyApp --js
178178
```
179179

180180
To create a new cross-platform project from the default TypeScript, Angular or Vue template, use the `template` option followed by either `typescript`, `angular` or `vue`.
181181

182182
```Shell
183-
tns create MyApp --template typescript
184-
tns create MyApp --template angular
185-
tns create MyApp --template vue
183+
ns create MyApp --template typescript
184+
ns create MyApp --template angular
185+
ns create MyApp --template vue
186186
```
187187

188188
Or you can simply use the shorthand `tsc` and `ng` options.
189189

190190
```Shell
191-
tns create MyApp --tsc
192-
tns create MyApp --ng
191+
ns create MyApp --tsc
192+
ns create MyApp --ng
193193
```
194194
With the `template` option you can also specify a local or a remote path to the template that you want to use to create your project.
195195
For example, if you want to create a React template, run the following command.
196196

197197
```Shell
198-
tns create MyApp --template https://github.com/shirakaba/tns-template-blank-react.git
198+
ns create MyApp --template https://github.com/shirakaba/tns-template-blank-react.git
199199
```
200200

201201
The NativeScript CLI creates a new project and sets the application identifier to `org.nativescript.myapp`.
@@ -258,8 +258,8 @@ You can always override the generated entitlements file, by pointing to your own
258258
You can build it for your target mobile platforms.
259259

260260
```Shell
261-
tns build android
262-
tns build ios
261+
ns build android
262+
ns build ios
263263
```
264264

265265
The NativeScript CLI calls the SDK for the selected target platform and uses it to build your app locally.
@@ -277,16 +277,16 @@ You can test your work in progress on connected Android or iOS devices.
277277
To verify that the NativeScript CLI recognizes your connected devices, run the following command.
278278

279279
```Shell
280-
tns devices
280+
ns devices
281281
```
282282

283283
The NativeScript CLI lists all connected physical devices and running emulators/simulators.
284284

285285
After you have listed the available devices, you can quickly run your app on connected devices by executing:
286286

287287
```Shell
288-
tns run android
289-
tns run ios
288+
ns run android
289+
ns run ios
290290
```
291291

292292
[Back to Top][1]
@@ -296,7 +296,7 @@ Extending the CLI
296296

297297
The NativeScript CLI lets you extend its behavior and customize it to fit your needs by using [hooks](https://en.wikipedia.org/wiki/Hooking).
298298

299-
When you run one of the extendable commands (for example, `tns build`), the CLI checks for hooks and executes them. Plugins can also use hooks to control the compilation of the application package.
299+
When you run one of the extendable commands (for example, `ns build`), the CLI checks for hooks and executes them. Plugins can also use hooks to control the compilation of the application package.
300300

301301
For more information, see the [Extending the CLI document](https://github.com/NativeScript/nativescript-cli/blob/master/extending-cli.md)
302302

@@ -308,7 +308,7 @@ Troubleshooting
308308
If the NativeScript CLI does not behave as expected, you might be facing a configuration issue. For example, a missing `JAVA` path. To check if your system is configured properly for the NativeScript CLI, run the following command.
309309

310310
```bash
311-
tns doctor
311+
ns doctor
312312
```
313313

314314
This command prints warnings about current configuration issues and provides basic information about how to resolve them.
@@ -337,7 +337,7 @@ npm run setup
337337
```
338338

339339
To use the locally built CLI instead `tns` you can call `PATH_TO_CLI_FOLDER/bin/tns`. For example:
340-
`PATH_TO_CLI_FOLDER/bin/tns run ios|android`
340+
`PATH_TO_CLI_FOLDER/bin/ns run ios|android`
341341

342342
[Back to Top][1]
343343

extending-cli.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Extending the CLI
33

44
The NativeScript CLI lets you extend its behavior and customize it to fit your needs by using [hooks](https://en.wikipedia.org/wiki/Hooking).
55

6-
When you run one of the [extendable commands](#commands-with-hooking-support) (for example, `tns build`), the CLI checks for hooks and executes them. Plugins can also use hooks to control the compilation of the application package.
6+
When you run one of the [extendable commands](#commands-with-hooking-support) (for example, `ns build`), the CLI checks for hooks and executes them. Plugins can also use hooks to control the compilation of the application package.
77

88
## Hooks in the NativeScript CLI
99

@@ -105,14 +105,14 @@ The only two operations to which you can attach hooks are `prepare` operations a
105105
106106
The NativeScriot CLI executes hooks attached to `prepare` when you run the following commands:
107107
108-
* `tns prepare <Platform>`
109-
* `tns build <Platform>`
110-
* `tns deploy <Platform>`
111-
* `tns run <Platform>`
112-
* `tns livesync <Platform>`
113-
* `tns test <Platform>`
108+
* `ns prepare <Platform>`
109+
* `ns build <Platform>`
110+
* `ns deploy <Platform>`
111+
* `ns run <Platform>`
112+
* `ns livesync <Platform>`
113+
* `ns test <Platform>`
114114
115115
The NativeScriot CLI executes hooks attached to `--watch` operations when you run the following commands:
116116
117-
* `tns test <Platform>` with the `--watch` option.
118-
* `tns livesync <Platform>` with the `--watch` option.
117+
* `ns test <Platform>` with the `--watch` option.
118+
* `ns livesync <Platform>` with the `--watch` option.

lib/android-tools-info.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as path from "path";
22
import * as _ from 'lodash';
33
import { cache } from "./common/decorators";
4-
import { androidToolsInfo } from "nativescript-doctor";
4+
import { androidToolsInfo } from "@nativescript/doctor";
55
import { injector } from './common/yok';
66
import { IAndroidToolsInfo, IOptions, IAndroidToolsInfoData, IAndroidToolsInfoValidateInput, IAndroidToolsInfoOptions } from "./declarations";
77
import { IErrors, IProjectDir } from "./common/declarations";

lib/commands/install.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { IPluginsService } from "../definitions/plugins";
66
import { ICommand, ICommandParameter } from "../common/definitions/commands";
77
import { IFileSystem } from "../common/declarations";
88
import { injector } from "../common/yok";
9+
import { PlatformTypes } from "../constants";
910

1011
export class InstallCommand implements ICommand {
1112
public enableHooks = false;
@@ -35,8 +36,8 @@ export class InstallCommand implements ICommand {
3536
await this.$pluginsService.ensureAllDependenciesAreInstalled(this.$projectData);
3637

3738
for (const platform of this.$mobileHelper.platformNames) {
38-
const platformData = this.$platformsDataService.getPlatformData(platform, this.$projectData);
39-
const frameworkPackageData = this.$projectDataService.getNSValue(this.$projectData.projectDir, platformData.frameworkPackageName);
39+
const platformData = this.$platformsDataService.getPlatformData(platform, this.$projectData);
40+
const frameworkPackageData = this.$projectDataService.getRuntimePackage(this.$projectData.projectDir, <PlatformTypes>platformData.platformNameLowerCase);
4041
if (frameworkPackageData && frameworkPackageData.version) {
4142
try {
4243
const platformProjectService = platformData.platformProjectService;

lib/commands/update-platform.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class UpdatePlatformCommand implements ICommand {
3939
const checkEnvironmentRequirementsInput: ICheckEnvironmentRequirementsInput = { platform, options: this.$options };
4040
// If version is not specified, we know the command will install the latest compatible Android runtime.
4141
// The latest compatible Android runtime supports Java version, so we do not need to pass it here.
42-
// Passing projectDir to the nativescript-doctor validation will cause it to check the runtime from the current package.json
42+
// Passing projectDir to the @nativescript/doctor validation will cause it to check the runtime from the current package.json
4343
// So in this case, where we do not want to validate the runtime, just do not pass both projectDir and runtimeVersion.
4444
if (versionToBeInstalled) {
4545
checkEnvironmentRequirementsInput.projectDir = this.$projectData.projectDir;

lib/common/doctor.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as doctor from "nativescript-doctor";
1+
import * as doctor from "@nativescript/doctor";
22

33
declare global {
44
interface ISysInfoConfig extends NativeScriptDoctor.ISysInfoConfig { }

0 commit comments

Comments
 (0)