Skip to content

chore: Merge release in master #3569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
0eadbc4
fix(analytics): Message for tracking in GA is always printed
rosen-vladimirov Apr 18, 2018
f88549c
Merge pull request #3537 from NativeScript/vladimirov/fix-analytics-logs
rosen-vladimirov Apr 19, 2018
6bb40de
feat(API): Expose androidProcessService - getAppProcessId
rosen-vladimirov Apr 18, 2018
044cda8
Merge pull request #3535 from NativeScript/vladimirov/expose-android-…
Apr 23, 2018
5ec29b1
Update common lib and ios-sim version
Fatme Apr 23, 2018
932da4b
Merge pull request #3543 from NativeScript/fatme/update-common-and-io…
Apr 23, 2018
3291e30
Add docs for device name and sdk options
Fatme Apr 29, 2018
d4d98f1
fix: Support Node.js 10.x.x
rosen-vladimirov May 2, 2018
06ebba9
Merge pull request #3556 from NativeScript/vladimirov/support-node10
rosen-vladimirov May 2, 2018
391eb84
fix(assets-generation): Do not fail in case some App_Resources are mi…
rosen-vladimirov May 2, 2018
238eb06
Merge pull request #3557 from NativeScript/vladimirov/fix-assets-stru…
rosen-vladimirov May 2, 2018
b7ae6dd
fix: Build plugins when path to project has space
rosen-vladimirov May 4, 2018
bbcf9bc
Merge pull request #3562 from NativeScript/vladimirov/build-plugin-hooks
rosen-vladimirov May 8, 2018
ab81558
Merge pull request #3553 from NativeScript/fatme/docs-simulator-name-…
rosen-vladimirov May 9, 2018
daadc64
Merge remote-tracking branch 'origin/release' into vladimirov/merge-r…
rosen-vladimirov May 9, 2018
b0d076e
chore: Update to latest common lib
rosen-vladimirov May 9, 2018
cfca813
chore: Fix shrinkwrap after incorrect merge
rosen-vladimirov May 9, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions PublicAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const tns = require("nativescript");
* [assetsGenerationService](#assetsgenerationservice)
* [generateIcons](#generateicons)
* [generateSplashScreens](#generatesplashscreens)
* [androidProcessService](#androidprocessservice)
* [getAppProcessId](#getappprocessid)

## Module projectService

Expand Down Expand Up @@ -1125,6 +1127,29 @@ tns.assetsGenerationService.generateSplashScreens({ projectDir: "/Users/username
});
```

## androidProcessService
The `androidProcessService` exposes methods for getting information about the applications working on Android devices.

### getAppProcessId
The `getAppProcessId` returns the PID of the specified application. If the app is not running on device, the method will return null.

* Definition
```TypeScript
/**
* Gets the PID of a running application.
* @param deviceIdentifier {string} The identifier of the device.
* @param appIdentifier The identifier of the application.
* @return {string} Returns the process id matching the application identifier in the device process list.
*/
getAppProcessId(deviceIdentifier: string, appIdentifier: string): Promise<string>;
```

* Usage
```JavaScript
tns.androidProcessService.getAppProcessId("4df18f307d8a8f1b", "org.nativescript.demoapp")
.then(pid => console.log(`The PID is ${pid}`))
.catch(err => console.error(`Error while checking for PID: ${err}`));
```


## How to add a new method to Public API
Expand Down
6 changes: 5 additions & 1 deletion docs/man_pages/project/testing/run-ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ position: 11
Usage | Synopsis
---|---
Run on all connected devices | `$ tns run ios [--release] [--justlaunch] [--bundle [<value>] [--env.*]]`
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.*]]`
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.*]]`
Start an emulator and run the app inside it | `$ tns run ios --emulator [--release] [--bundle [<value>] [--env.*]]`
Start an emulator with specified device name and sdk | `$ tns run ios [--device <Device Name>] [--sdk <sdk>]`
Start an emulator with specified device identifier and sdk | `$ tns run ios [--device <Device Identifier>] [--sdk <sdk>]`

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.

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

### Attributes
* `<Device ID>` is the index or `Device Identifier` of the target device as listed by `$ tns device ios --available-devices`
* `<Device Name>` is the name of the target simulator as listed by `$ tns device ios --available-devices`
<% } %>
<% if(isHtml) { %>
### Prerequisites
Expand Down
22 changes: 22 additions & 0 deletions lib/definitions/android-plugin-migrator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,25 @@ interface IAndroidPluginBuildService {
buildAar(options: IBuildOptions): Promise<boolean>;
migrateIncludeGradle(options: IBuildOptions): boolean;
}

/**
* Describes data required for building plugin for Android.
* The data can be consumed in the buildAndroidPlugin hook.
*/
interface IBuildAndroidPluginData {
/**
* Directory where the plugin will be build.
* Usually this is the `<project dir>/platforms/tempPlugin/<plugin name>` dir.
*/
pluginDir: string;

/**
* The name of the plugin.
*/
pluginName: string;

/**
* Information about tools that will be used to build the plugin, for example compile SDK version, build tools version, etc.
*/
androidToolsInfo: IAndroidToolsInfoData;
}
3 changes: 1 addition & 2 deletions lib/services/analytics/analytics-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class AnalyticsService extends AnalyticsServiceBase {
gaSettings.customDimensions[GoogleAnalyticsCustomDimensions.client] = this.$options.analyticsClient || (isInteractive() ? AnalyticsClients.Cli : AnalyticsClients.Unknown);

const googleAnalyticsData: IGoogleAnalyticsTrackingInformation = _.merge({ type: TrackingTypes.GoogleAnalyticsData, category: AnalyticsClients.Cli }, gaSettings);
this.$logger.trace("Will send the following information to Google Analytics:", googleAnalyticsData);
return this.sendMessageToBroker(googleAnalyticsData);
}
}
Expand Down Expand Up @@ -99,8 +100,6 @@ export class AnalyticsService extends AnalyticsServiceBase {
customDimensions
};

this.$logger.trace("Will send the following information to Google Analytics:", googleAnalyticsEventData);

await this.trackInGoogleAnalytics(googleAnalyticsEventData);
}

Expand Down
55 changes: 31 additions & 24 deletions lib/services/android-plugin-build-service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import * as path from "path";
import { MANIFEST_FILE_NAME, INCLUDE_GRADLE_NAME, ASSETS_DIR, RESOURCES_DIR } from "../constants";
import { getShortPluginName } from "../common/helpers";
import { getShortPluginName, hook } from "../common/helpers";
import { Builder, parseString } from "xml2js";
import { ILogger } from "log4js";

export class AndroidPluginBuildService implements IAndroidPluginBuildService {

constructor(private $fs: IFileSystem,
/**
* Required for hooks execution to work.
*/
private get $hooksService(): IHooksService {
return this.$injector.resolve("hooksService");
}

constructor(private $injector: IInjector,
private $fs: IFileSystem,
private $childProcess: IChildProcess,
private $hostInfo: IHostInfo,
private $androidToolsInfo: IAndroidToolsInfo,
Expand Down Expand Up @@ -240,30 +248,9 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
}

// finally build the plugin
const gradlew = this.$hostInfo.isWindows ? "gradlew.bat" : "./gradlew";
const localArgs = [
gradlew,
"-p",
newPluginDir,
"assembleRelease"
];

this.$androidToolsInfo.validateInfo({ showWarningsAsErrors: true, validateTargetSdk: true });

const androidToolsInfo = this.$androidToolsInfo.getToolsInfo();
const compileSdk = androidToolsInfo.compileSdkVersion;
const buildToolsVersion = androidToolsInfo.buildToolsVersion;
const supportVersion = androidToolsInfo.supportRepositoryVersion;

localArgs.push(`-PcompileSdk=android-${compileSdk}`);
localArgs.push(`-PbuildToolsVersion=${buildToolsVersion}`);
localArgs.push(`-PsupportVersion=${supportVersion}`);

try {
await this.$childProcess.exec(localArgs.join(" "), { cwd: newPluginDir });
} catch (err) {
throw new Error(`Failed to build plugin ${options.pluginName} : \n${err}`);
}
await this.buildPlugin( { pluginDir: newPluginDir, pluginName: options.pluginName, androidToolsInfo });

const finalAarName = `${shortPluginName}-release.aar`;
const pathToBuiltAar = path.join(newPluginDir, "build", "outputs", "aar", finalAarName);
Expand Down Expand Up @@ -318,6 +305,26 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
return false;
}

@hook("buildAndroidPlugin")
private async buildPlugin(pluginBuildSettings: IBuildAndroidPluginData): Promise<void> {
const gradlew = this.$hostInfo.isWindows ? "gradlew.bat" : "./gradlew";

const localArgs = [
"-p",
pluginBuildSettings.pluginDir,
"assembleRelease",
`-PcompileSdk=android-${pluginBuildSettings.androidToolsInfo.compileSdkVersion}`,
`-PbuildToolsVersion=${pluginBuildSettings.androidToolsInfo.buildToolsVersion}`,
`-PsupportVersion=${pluginBuildSettings.androidToolsInfo.supportRepositoryVersion}`
];

try {
await this.$childProcess.spawnFromEvent(gradlew, localArgs, "close", { cwd: pluginBuildSettings.pluginDir });
} catch (err) {
throw new Error(`Failed to build plugin ${pluginBuildSettings.pluginName} : \n${err}`);
}
}

private validateOptions(options: IBuildOptions): void {
if (!options) {
throw new Error("Android plugin cannot be built without passing an 'options' object.");
Expand Down
2 changes: 1 addition & 1 deletion lib/services/project-data-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class ProjectDataService implements IProjectDataService {

private async getIOSAssetSubGroup(dirPath: string): Promise<IAssetSubGroup> {
const pathToContentJson = path.join(dirPath, AssetConstants.iOSResourcesFileName);
const content = <IAssetSubGroup>this.$fs.readJson(pathToContentJson);
const content = this.$fs.exists(pathToContentJson) && <IAssetSubGroup>this.$fs.readJson(pathToContentJson) || { images: [] };

const imageDefinitions = this.getImageDefinitions().ios;

Expand Down
Loading