Skip to content

Commit dc10658

Browse files
committed
Merge remote-tracking branch 'origin/master' into tdermendzhiev/objc-source-support
2 parents de78502 + acb7030 commit dc10658

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1590
-1847
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!--
2+
We, the rest of the NativeScript community, thank you for your
3+
contribution!
4+
To help the rest of the community review your change, please follow the instructions in the template.
5+
-->
6+
7+
<!-- PULL REQUEST TEMPLATE -->
8+
<!-- (Update "[ ]" to "[x]" to check a box) -->
9+
10+
## PR Checklist
11+
12+
- [ ] The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/CONTRIBUTING.md#commit-messages.
13+
- [ ] There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it.
14+
- [ ] You have signed the [CLA](http://www.nativescript.org/cla).
15+
- [ ] All existing tests are passing: https://github.com/NativeScript/nativescript-cli/blob/master/CONTRIBUTING.md#contribute-to-the-code-base
16+
- [ ] Tests for the changes are included.
17+
18+
## What is the current behavior?
19+
<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->
20+
21+
## What is the new behavior?
22+
<!-- Describe the changes. -->
23+
24+
Fixes/Implements/Closes #[Issue Number].
25+
26+
<!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below. -->
27+
28+
<!--
29+
BREAKING CHANGES:
30+
31+
32+
[Describe the impact of the changes here.]
33+
34+
Migration steps:
35+
[Provide a migration path for existing applications.]
36+
-->
37+

CHANGELOG.md

+23
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
11
NativeScript CLI Changelog
22
================
33

4+
4.0.0 (2018, April 10)
5+
==
6+
7+
### New
8+
* [Implemented #2632](https://github.com/NativeScript/nativescript-cli/issues/2632) Guidance for new CLI users
9+
* [Implemented #3243](https://github.com/NativeScript/nativescript-cli/issues/3243) 'Scss' file changes trigger app refresh instead reloading the view and apply generated 'css'
10+
* [Implemented #3248](https://github.com/NativeScript/nativescript-cli/issues/3248) Support JDK_HOME and JAVA_HOME
11+
* [Implemented #3257](https://github.com/NativeScript/nativescript-cli/issues/3257) Make {N} project structure configurable
12+
* [Implemented #3317](https://github.com/NativeScript/nativescript-cli/issues/3317) Support livesync with webpack
13+
* [Implemented #3449](https://github.com/NativeScript/nativescript-cli/pull/3449) Track Vue.js project type
14+
* [Implemented #3496](https://github.com/NativeScript/nativescript-cli/issues/3496) Generate assets for the mobile application
15+
* [Implemented #3497](https://github.com/NativeScript/nativescript-cli/issues/3497) Command to migrate Android resources to 4.0.0 structure
16+
* [Implemented #3516](https://github.com/NativeScript/nativescript-cli/issues/3516) Improve Getting Started Experience
17+
18+
### Fixed
19+
* [Fixed #3151](https://github.com/NativeScript/nativescript-cli/issues/3151): Install fails if user setting file is not valid json
20+
* [Fixed #3324](https://github.com/NativeScript/nativescript-cli/issues/3324): Error when iOS simulator's window is closed
21+
* [Fixed #3442](https://github.com/NativeScript/nativescript-cli/issues/3442): Unnecessary second build upon `tns run android`
22+
* [Fixed #3451](https://github.com/NativeScript/nativescript-cli/issues/3451): `tns plugin remove` fails with : Cannot convert undefined or null to object
23+
* [Fixed #3470](https://github.com/NativeScript/nativescript-cli/issues/3470): Error when we are publishing to AppStore
24+
* [Fixed #3481](https://github.com/NativeScript/nativescript-cli/issues/3481): Cannot log in users on iOS simulator with kinvey-nativescript-sdk
25+
* [Fixed #3514](https://github.com/NativeScript/nativescript-cli/pull/3514): Incorrect error is shown when xcrun simctl is not configured
26+
427
3.4.3 (2018, March 02)
528
==
629

PublicAPI.md

+25
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ const tns = require("nativescript");
4848
* [assetsGenerationService](#assetsgenerationservice)
4949
* [generateIcons](#generateicons)
5050
* [generateSplashScreens](#generatesplashscreens)
51+
* [androidProcessService](#androidprocessservice)
52+
* [getAppProcessId](#getappprocessid)
5153

5254
## Module projectService
5355

@@ -1125,6 +1127,29 @@ tns.assetsGenerationService.generateSplashScreens({ projectDir: "/Users/username
11251127
});
11261128
```
11271129
1130+
## androidProcessService
1131+
The `androidProcessService` exposes methods for getting information about the applications working on Android devices.
1132+
1133+
### getAppProcessId
1134+
The `getAppProcessId` returns the PID of the specified application. If the app is not running on device, the method will return null.
1135+
1136+
* Definition
1137+
```TypeScript
1138+
/**
1139+
* Gets the PID of a running application.
1140+
* @param deviceIdentifier {string} The identifier of the device.
1141+
* @param appIdentifier The identifier of the application.
1142+
* @return {string} Returns the process id matching the application identifier in the device process list.
1143+
*/
1144+
getAppProcessId(deviceIdentifier: string, appIdentifier: string): Promise<string>;
1145+
```
1146+
1147+
* Usage
1148+
```JavaScript
1149+
tns.androidProcessService.getAppProcessId("4df18f307d8a8f1b", "org.nativescript.demoapp")
1150+
.then(pid => console.log(`The PID is ${pid}`))
1151+
.catch(err => console.error(`Error while checking for PID: ${err}`));
1152+
```
11281153
11291154
11301155
## How to add a new method to Public API

docs/man_pages/project/configuration/resources/resources-generate-splashes.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ position: 12
66

77
Usage | Synopsis
88
------|-------
9-
`$ tns resources generate splashes <Path to image> [<background>]` | Generate all splashscreens for Android and iOS based on the specified image.
9+
`$ tns resources generate splashes <Path to image> [--background <Color>]` | Generate all splashscreens for Android and iOS based on the specified image.
1010

11-
Generates all icons for Android and iOS platforms and places the generated images in the correct directories under `App_Resources/<platform>` directory.
11+
Generates all splashscreens for Android and iOS platforms and places the generated images in the correct directories under `App_Resources/<platform>` directory.
12+
13+
### Options
14+
* `--background` Sets the background color of the splashscreen. Defaults to white in case it is not specified.
1215

1316
### Attributes
1417
* `<Path to image>` is a valid path to an image that will be used to generate all splashscreens.
15-
* `<background>` is a valid path to an image that will be used as a background of the splashscreen. Defaults to white in case it is not specified.
18+
* `<Color>` is a valid color. It can be represented with string, like `white`, `black`, `blue`, etc. or its HEX representation, for example `#FFFFFF`, `#000000`, `#0000FF`. NOTE: As the `#` is special symbol in some terminals, make sure to place the value in quotes, for example `$ tns resources generate splashes ../myImage.png --background "#FF00FF"`.
1619

1720
<% if(isHtml) { %>
1821
### Related Commands

docs/man_pages/project/testing/run-ios.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ position: 11
88
Usage | Synopsis
99
---|---
1010
Run on all connected devices | `$ tns run ios [--release] [--justlaunch] [--bundle [<value>] [--env.*]]`
11-
Run on a selected connected device. Will start simulator with specified `Device Identifier`, if not already running. | `$ tns run ios [--device <Device ID>] [--release] [--justlaunch] [--bundle [<value>] [--env.*]]`
11+
Run on a selected connected device. Will start simulator with specified `Device Identifier` or `Device Name`, if not already running. | `$ tns run ios [--device <Device ID>] [--release] [--justlaunch] [--bundle [<value>] [--env.*]]`
1212
Start an emulator and run the app inside it | `$ tns run ios --emulator [--release] [--bundle [<value>] [--env.*]]`
13+
Start an emulator with specified device name and sdk | `$ tns run ios [--device <Device Name>] [--sdk <sdk>]`
14+
Start an emulator with specified device identifier and sdk | `$ tns run ios [--device <Device Identifier>] [--sdk <sdk>]`
1315

1416
Runs your project on a connected iOS device or in the iOS Simulator, if configured. This is shorthand for prepare, build and deploy. While your app is running, prints the output from the application in the console and watches for changes in your code. Once a change is detected, it synchronizes the change with all selected devices and restarts/refreshes the application.
1517

@@ -20,6 +22,7 @@ Runs your project on a connected iOS device or in the iOS Simulator, if configur
2022
### Options
2123
* `--device` - Specifies a connected device/simulator to start and run the app.
2224
* `--emulator` - If set, runs the app in all available and configured ios simulators. It will start a simulator if none are already running.
25+
* `--sdk` - Specifies the target simulator's sdk.
2326
* `--justlaunch` - If set, does not print the application output in the console.
2427
* `--clean` - If set, forces rebuilding the native application.
2528
* `--no-watch` - If set, changes in your code will not be reflected during the execution of this command.
@@ -30,6 +33,7 @@ Runs your project on a connected iOS device or in the iOS Simulator, if configur
3033

3134
### Attributes
3235
* `<Device ID>` is the index or `Device Identifier` of the target device as listed by `$ tns device ios --available-devices`
36+
* `<Device Name>` is the name of the target simulator as listed by `$ tns device ios --available-devices`
3337
<% } %>
3438
<% if(isHtml) { %>
3539
### Prerequisites

lib/bootstrap.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ $injector.require("terminalSpinnerService", "./services/terminal-spinner-service
160160

161161
$injector.require('playgroundService', './services/playground-service');
162162
$injector.require("platformEnvironmentRequirements", "./services/platform-environment-requirements");
163-
$injector.require("nativescriptCloudExtensionService", "./services/nativescript-cloud-extension-service");
163+
$injector.require("nativeScriptCloudExtensionService", "./services/nativescript-cloud-extension-service");
164164

165165
$injector.requireCommand("resources|generate|icons", "./commands/generate-assets");
166166
$injector.requireCommand("resources|generate|splashes", "./commands/generate-assets");

lib/commands/create-project.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import * as constants from "../constants";
2+
import * as path from "path";
23

34
export class CreateProjectCommand implements ICommand {
45
public enableHooks = false;
56
public allowedParameters: ICommandParameter[] = [this.$stringParameterBuilder.createMandatoryParameter("Project name cannot be empty.")];
67

8+
private createdProjecData: ICreateProjectData;
9+
710
constructor(private $projectService: IProjectService,
11+
private $logger: ILogger,
812
private $errors: IErrors,
913
private $options: IOptions,
1014
private $stringParameterBuilder: IStringParameterBuilder) { }
@@ -23,7 +27,7 @@ export class CreateProjectCommand implements ICommand {
2327
selectedTemplate = this.$options.template;
2428
}
2529

26-
await this.$projectService.createProject({
30+
this.createdProjecData = await this.$projectService.createProject({
2731
projectName: args[0],
2832
template: selectedTemplate,
2933
appId: this.$options.appid,
@@ -32,6 +36,13 @@ export class CreateProjectCommand implements ICommand {
3236
ignoreScripts: this.$options.ignoreScripts
3337
});
3438
}
39+
40+
public async postCommandAction(args: string[]): Promise<void> {
41+
const { projectDir } = this.createdProjecData;
42+
const relativePath = path.relative(process.cwd(), projectDir);
43+
this.$logger.printMarkdown(`Now you can navigate to your project with \`$ cd ${relativePath}\``);
44+
this.$logger.printMarkdown(`After that you can run it on device/emulator by executing \`$ tns run <platform>\``);
45+
}
3546
}
3647

3748
$injector.registerCommand("create", CreateProjectCommand);

lib/commands/post-install.ts

+21
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,27 @@ export class PostInstallCliCommand extends PostInstallCommand {
1818

1919
await this.$subscriptionService.subscribeForNewsletter();
2020
}
21+
22+
public async postCommandAction(args: string[]): Promise<void> {
23+
this.$logger.info("You have successfully installed NativeScript CLI.");
24+
this.$logger.info("In order to create a new project, you can use:".green);
25+
this.$logger.printMarkdown("`tns create <app name>`");
26+
this.$logger.info("To build your project locally you can use:".green);
27+
this.$logger.printMarkdown("`tns build <platform>`");
28+
this.$logger.printMarkdown("NOTE: Local builds require additional setup of your environment. You can find more information here: `https://docs.nativescript.org/start/quick-setup`");
29+
30+
// Add a new line just to ensure separation between local builds and cloud builds info.
31+
this.$logger.info("");
32+
this.$logger.info("To build your project in the cloud you can use:".green);
33+
this.$logger.printMarkdown("`tns cloud build <platform>`");
34+
this.$logger.printMarkdown("NOTE: Cloud builds require Telerik account. You can find more information here: `https://docs.nativescript.org/sidekick/intro/requirements`");
35+
36+
this.$logger.info("");
37+
this.$logger.printMarkdown("In case you want to experiment quickly with NativeScript, you can try the Playground: `https://play.nativescript.org`");
38+
39+
this.$logger.info("");
40+
this.$logger.printMarkdown("In case you have any questions, you can check our forum: `https://forum.nativescript.org` and our public Slack channel: `https://nativescriptcommunity.slack.com/`");
41+
}
2142
}
2243

2344
$injector.registerCommand("post-install-cli", PostInstallCliCommand);

lib/commands/run.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class RunCommandBase implements ICommand {
2828
this.platform = this.$devicePlatformsConstants.Android;
2929
}
3030

31-
this.$liveSyncCommandHelper.validatePlatform(this.platform);
31+
await this.$liveSyncCommandHelper.validatePlatform(this.platform);
3232

3333
return true;
3434
}

lib/commands/setup.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ $injector.registerCommand("setup|*", SetupCommand);
1212
export class CloudSetupCommand implements ICommand {
1313
public allowedParameters: ICommandParameter[] = [];
1414

15-
constructor(private $nativescriptCloudExtensionService: INativescriptCloudExtensionService) { }
15+
constructor(private $nativeScriptCloudExtensionService: INativeScriptCloudExtensionService) { }
1616

1717
public execute(args: string[]): Promise<any> {
18-
return this.$nativescriptCloudExtensionService.install();
18+
return this.$nativeScriptCloudExtensionService.install();
1919
}
2020
}
2121
$injector.registerCommand(["setup|cloud", "cloud|setup"], CloudSetupCommand);

lib/constants.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,10 @@ export const enum TrackActionNames {
135135
CreateProject = "Create project",
136136
Debug = "Debug",
137137
Deploy = "Deploy",
138-
LiveSync = "LiveSync"
138+
LiveSync = "LiveSync",
139+
RunSetupScript = "Run Setup Script",
140+
CheckLocalBuildSetup = "Check Local Build Setup",
141+
CheckEnvironmentRequirements = "Check Environment Requirements"
139142
}
140143

141144
export const enum BuildStates {

lib/declarations.d.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -788,12 +788,17 @@ interface IBundleValidatorHelper {
788788
validate(): void;
789789
}
790790

791-
interface INativescriptCloudExtensionService {
791+
interface INativeScriptCloudExtensionService {
792792
/**
793793
* Installs nativescript-cloud extension
794794
* @return {Promise<IExtensionData>} returns the extension data
795795
*/
796796
install(): Promise<IExtensionData>;
797+
/**
798+
* Checks if nativescript-cloud extension is installed
799+
* @return {boolean} returns true in case when nativescript-cloud extension is installed, false otherwise
800+
*/
801+
isInstalled(): boolean
797802
}
798803

799804
/**

lib/definitions/android-plugin-migrator.d.ts

+22
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,25 @@ interface IAndroidPluginBuildService {
1313
buildAar(options: IBuildOptions): Promise<boolean>;
1414
migrateIncludeGradle(options: IBuildOptions): boolean;
1515
}
16+
17+
/**
18+
* Describes data required for building plugin for Android.
19+
* The data can be consumed in the buildAndroidPlugin hook.
20+
*/
21+
interface IBuildAndroidPluginData {
22+
/**
23+
* Directory where the plugin will be build.
24+
* Usually this is the `<project dir>/platforms/tempPlugin/<plugin name>` dir.
25+
*/
26+
pluginDir: string;
27+
28+
/**
29+
* The name of the plugin.
30+
*/
31+
pluginName: string;
32+
33+
/**
34+
* Information about tools that will be used to build the plugin, for example compile SDK version, build tools version, etc.
35+
*/
36+
androidToolsInfo: IAndroidToolsInfoData;
37+
}

lib/definitions/platform.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,5 +381,5 @@ interface IUpdateAppOptions extends IOptionalFilesToSync, IOptionalFilesToRemove
381381
}
382382

383383
interface IPlatformEnvironmentRequirements {
384-
checkEnvironmentRequirements(platform: string): Promise<boolean>;
384+
checkEnvironmentRequirements(platform?: string): Promise<boolean>;
385385
}

lib/definitions/project.d.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,21 @@ interface IProjectSettings {
3737
ignoreScripts?: boolean;
3838
}
3939

40+
interface IProjectName {
41+
projectName: string;
42+
}
43+
44+
interface ICreateProjectData extends IProjectDir, IProjectName {
45+
46+
}
47+
4048
interface IProjectService {
4149
/**
4250
* Creates new NativeScript application.
4351
* @param {any} projectSettings Options describing new project - its name, appId, path and template from which to be created.
4452
* @returns {Promise<void>}
4553
*/
46-
createProject(projectSettings: IProjectSettings): Promise<void>;
54+
createProject(projectSettings: IProjectSettings): Promise<ICreateProjectData>;
4755

4856
/**
4957
* Checks if the specified project is valid NativeScript project.
@@ -58,8 +66,7 @@ interface INsConfig {
5866
appResourcesPath?: string;
5967
}
6068

61-
interface IProjectData extends IProjectDir {
62-
projectName: string;
69+
interface IProjectData extends ICreateProjectData {
6370
platformsDir: string;
6471
projectFilePath: string;
6572
projectId?: string;
@@ -394,12 +401,6 @@ interface IPlatformProjectService extends NodeJS.EventEmitter {
394401
executeCommand(projectRoot: string, args: any, childProcessOpts?: any, spawnFromEventOptions?: ISpawnFromEventOptions): Promise<ISpawnResult>;
395402
}
396403

397-
interface IAndroidProjectPropertiesManager {
398-
getProjectReferences(): Promise<ILibRef[]>;
399-
addProjectReference(referencePath: string): Promise<void>;
400-
removeProjectReference(referencePath: string): Promise<void>;
401-
}
402-
403404
interface ITestExecutionService {
404405
startTestRunner(platform: string, projectData: IProjectData, projectFilesConfig: IProjectFilesConfig): Promise<void>;
405406
startKarmaServer(platform: string, projectData: IProjectData, projectFilesConfig: IProjectFilesConfig): Promise<void>;

lib/definitions/simple-plist.d.ts

-4
This file was deleted.

lib/services/analytics/analytics-service.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export class AnalyticsService extends AnalyticsServiceBase {
5858
gaSettings.customDimensions[GoogleAnalyticsCustomDimensions.client] = this.$options.analyticsClient || (isInteractive() ? AnalyticsClients.Cli : AnalyticsClients.Unknown);
5959

6060
const googleAnalyticsData: IGoogleAnalyticsTrackingInformation = _.merge({ type: TrackingTypes.GoogleAnalyticsData, category: AnalyticsClients.Cli }, gaSettings);
61+
this.$logger.trace("Will send the following information to Google Analytics:", googleAnalyticsData);
6162
return this.sendMessageToBroker(googleAnalyticsData);
6263
}
6364
}
@@ -73,7 +74,7 @@ export class AnalyticsService extends AnalyticsServiceBase {
7374

7475
// In some cases (like in case action is Build and platform is Android), we do not know if the deviceType is emulator or device.
7576
// Just exclude the device_type in this case.
76-
if (isForDevice !== null) {
77+
if (isForDevice !== null && isForDevice !== undefined) {
7778
const deviceType = isForDevice ? DeviceTypes.Device : (this.$mobileHelper.isAndroidPlatform(platform) ? DeviceTypes.Emulator : DeviceTypes.Simulator);
7879
label = this.addDataToLabel(label, deviceType);
7980
}
@@ -99,8 +100,6 @@ export class AnalyticsService extends AnalyticsServiceBase {
99100
customDimensions
100101
};
101102

102-
this.$logger.trace("Will send the following information to Google Analytics:", googleAnalyticsEventData);
103-
104103
await this.trackInGoogleAnalytics(googleAnalyticsEventData);
105104
}
106105

0 commit comments

Comments
 (0)