Skip to content

Commit 68a2b7b

Browse files
committed
chore: merge 'release' into 'master'
2 parents 32bec2f + d3e1fe2 commit 68a2b7b

Some content is hidden

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

50 files changed

+3142
-1907
lines changed

Gruntfile.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ var travis = process.env["TRAVIS"];
2929
var buildNumber = process.env["PACKAGE_VERSION"] || process.env["BUILD_NUMBER"] || "non-ci";
3030

3131
module.exports = function (grunt) {
32-
var path = require("path");
33-
var commonLibNodeModules = path.join("lib", "common", "node_modules");
34-
if (require("fs").existsSync(commonLibNodeModules)) {
35-
grunt.file.delete(commonLibNodeModules);
36-
}
37-
grunt.file.write(path.join("lib", "common", ".d.ts"), "");
38-
3932
grunt.initConfig({
4033
copyPackageTo: process.env["CopyPackageTo"] || ".",
4134

@@ -229,7 +222,7 @@ module.exports = function (grunt) {
229222
if (travis && process.env.TRAVIS_PULL_REQUEST_BRANCH) {
230223
return grunt.task.run("pack");
231224
}
232-
225+
233226
// Set correct version in Travis job, so the deploy will not publish strict version (for example 5.2.0).
234227
grunt.task.run("set_package_version");
235228
console.log(`Skipping pack step as the current build is not from PR, so it will be packed from the deploy provider.`);

docs/man_pages/project/testing/build-android.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ General | `$ tns build android [--compileSdk <API Level>] [--key-store-path <Fil
2424
* `--key-store-password` - Provides the password for the keystore file specified with `--key-store-path`. You can use the `--key-store-*` options along with `--release` to produce a signed release build. You need to specify all `--key-store-*` options.
2525
* `--key-store-alias` - Provides the alias for the keystore file specified with `--key-store-path`. You can use the `--key-store-*` options along with `--release` to produce a signed release build. You need to specify all `--key-store-*` options.
2626
* `--key-store-alias-password` - Provides the password for the alias specified with `--key-store-alias-password`. You can use the `--key-store-*` options along with `--release` to produce a signed release build. You need to specify all `--key-store-*` options.
27-
* `--copy-to` - Specifies the file path where the built `.apk` will be copied. If it points to a non-existent directory, it will be created. If the specified value is directory, the original file name will be used.
27+
* `--copy-to` - Specifies the file path where the built `.apk` will be copied. If it points to a non-existent directory path, it will be created. If the specified value is existing directory, the original file name will be used.
2828
* `--bundle` - Specifies that the `webpack` bundler will be used to bundle the application.
2929
* `--env.*` - Specifies additional flags that the bundler may process. May be passed multiple times. For example: `--env.uglify --env.snapshot`.
3030
* `--aab` - Specifies that the build will produce an Android App Bundle(`.aab`) file.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ General | `$ tns build ios [--for-device] [--release] [--copy-to <File Path>] [-
2323

2424
* `--release` - If set, produces a release build. Otherwise, produces a debug build.
2525
* `--for-device` - If set, produces an application package that you can deploy on device. Otherwise, produces a build that you can run only in the native iOS Simulator.
26-
* `--copy-to` - Specifies the file path where the built `.ipa` will be copied. If it points to a non-existent directory, it will be created. If the specified value is directory, the original file name will be used.
26+
* `--copy-to` - Specifies the file path where the built `.ipa` will be copied. If it points to a non-existent directory path, it will be created. If the specified value is existing directory, the original file name will be used.
2727
* `--team-id` - If used without parameter, lists all team names and ids. If used with team name or id, it will switch to automatic signing mode and configure the .xcodeproj file of your app. In this case .xcconfig should not contain any provisioning/team id flags. This team id will be further used for codesigning the app. For Xcode 9.0+, xcodebuild will be allowed to update and modify automatically managed provisioning profiles.
2828
* `--provision` - If used without parameter, lists all eligible provisioning profiles. If used with UUID or name of your provisioning profile, it will switch to manual signing mode and configure the .xcodeproj file of your app. In this case xcconfig should not contain any provisioning/team id flags. This provisioning profile will be further used for codesigning the app.
2929
* `--bundle` - Specifies that the `webpack` bundler will be used to bundle the application.

lib/bootstrap.ts

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ $injector.require("iOSProvisionService", "./services/ios-provision-service");
1717
$injector.require("xcconfigService", "./services/xcconfig-service");
1818

1919
$injector.require("cocoapodsService", "./services/cocoapods-service");
20+
$injector.require("cocoaPodsPlatformManager", "./services/cocoapods-platform-manager");
2021

2122
$injector.require("projectTemplatesService", "./services/project-templates-service");
2223
$injector.require("projectNameService", "./services/project-name-service");

lib/commands/test.ts

+68-23
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,75 @@
11
import * as helpers from "../common/helpers";
22

3-
function RunKarmaTestCommandFactory(platform: string) {
4-
return function RunKarmaTestCommand($options: IOptions, $testExecutionService: ITestExecutionService, $projectData: IProjectData, $analyticsService: IAnalyticsService, $platformEnvironmentRequirements: IPlatformEnvironmentRequirements) {
5-
$projectData.initializeProjectData();
6-
$analyticsService.setShouldDispose($options.justlaunch || !$options.watch);
7-
const projectFilesConfig = helpers.getProjectFilesConfig({ isReleaseBuild: $options.release });
8-
this.execute = (args: string[]): Promise<void> => $testExecutionService.startKarmaServer(platform, $projectData, projectFilesConfig);
9-
this.canExecute = (args: string[]): Promise<boolean> => canExecute({ $platformEnvironmentRequirements, $projectData, $options, platform });
10-
this.allowedParameters = [];
11-
};
12-
}
3+
abstract class TestCommandBase {
4+
public allowedParameters: ICommandParameter[] = [];
5+
private projectFilesConfig: IProjectFilesConfig;
6+
protected abstract platform: string;
7+
protected abstract $projectData: IProjectData;
8+
protected abstract $testExecutionService: ITestExecutionService;
9+
protected abstract $analyticsService: IAnalyticsService;
10+
protected abstract $options: IOptions;
11+
protected abstract $platformEnvironmentRequirements: IPlatformEnvironmentRequirements;
12+
protected abstract $errors: IErrors;
13+
14+
async execute(args: string[]): Promise<void> {
15+
await this.$testExecutionService.startKarmaServer(this.platform, this.$projectData, this.projectFilesConfig);
16+
}
17+
18+
async canExecute(args: string[]): Promise<boolean | ICanExecuteCommandOutput> {
19+
this.$projectData.initializeProjectData();
20+
this.$analyticsService.setShouldDispose(this.$options.justlaunch || !this.$options.watch);
21+
this.projectFilesConfig = helpers.getProjectFilesConfig({ isReleaseBuild: this.$options.release });
1322

14-
async function canExecute(input: { $platformEnvironmentRequirements: IPlatformEnvironmentRequirements, $projectData: IProjectData, $options: IOptions, platform: string }): Promise<boolean> {
15-
const { $platformEnvironmentRequirements, $projectData, $options, platform } = input;
16-
const output = await $platformEnvironmentRequirements.checkEnvironmentRequirements({
17-
platform,
18-
projectDir: $projectData.projectDir,
19-
options: $options,
20-
notConfiguredEnvOptions: {
21-
hideSyncToPreviewAppOption: true,
22-
hideCloudBuildOption: true
23+
const output = await this.$platformEnvironmentRequirements.checkEnvironmentRequirements({
24+
platform: this.platform,
25+
projectDir: this.$projectData.projectDir,
26+
options: this.$options,
27+
notConfiguredEnvOptions: {
28+
hideSyncToPreviewAppOption: true,
29+
hideCloudBuildOption: true
30+
}
31+
});
32+
33+
const canStartKarmaServer = await this.$testExecutionService.canStartKarmaServer(this.$projectData);
34+
if (!canStartKarmaServer) {
35+
this.$errors.fail({
36+
formatStr: "Error: In order to run unit tests, your project must already be configured by running $ tns test init.",
37+
suppressCommandHelp: true,
38+
errorCode: ErrorCodes.TESTS_INIT_REQUIRED
39+
});
2340
}
24-
});
2541

26-
return output.canExecute;
42+
return output.canExecute && canStartKarmaServer;
43+
}
44+
}
45+
46+
class TestAndroidCommand extends TestCommandBase implements ICommand {
47+
protected platform = "android";
48+
49+
constructor(protected $projectData: IProjectData,
50+
protected $testExecutionService: ITestExecutionService,
51+
protected $analyticsService: IAnalyticsService,
52+
protected $options: IOptions,
53+
protected $platformEnvironmentRequirements: IPlatformEnvironmentRequirements,
54+
protected $errors: IErrors) {
55+
super();
56+
}
57+
58+
}
59+
60+
class TestIosCommand extends TestCommandBase implements ICommand {
61+
protected platform = "iOS";
62+
63+
constructor(protected $projectData: IProjectData,
64+
protected $testExecutionService: ITestExecutionService,
65+
protected $analyticsService: IAnalyticsService,
66+
protected $options: IOptions,
67+
protected $platformEnvironmentRequirements: IPlatformEnvironmentRequirements,
68+
protected $errors: IErrors) {
69+
super();
70+
}
71+
2772
}
2873

29-
$injector.registerCommand("test|android", RunKarmaTestCommandFactory('android'));
30-
$injector.registerCommand("test|ios", RunKarmaTestCommandFactory('iOS'));
74+
$injector.registerCommand("test|android", TestAndroidCommand);
75+
$injector.registerCommand("test|ios", TestIosCommand);

lib/common/Gruntfile.js

-179
This file was deleted.

lib/common/declarations.d.ts

+8
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ declare const enum ErrorCodes {
596596
KARMA_FAIL = 130,
597597
UNHANDLED_REJECTION_FAILURE = 131,
598598
DELETED_KILL_FILE = 132,
599+
TESTS_INIT_REQUIRED = 133
599600
}
600601

601602
interface IFutureDispatcher {
@@ -1168,6 +1169,13 @@ interface IDoctorService {
11681169
* @returns {Promise<boolean>} true if the environment is properly configured for local builds
11691170
*/
11701171
canExecuteLocalBuild(platform?: string, projectDir?: string, runtimeVersion?: string): Promise<boolean>;
1172+
1173+
/**
1174+
* Checks and notifies users for deprecated short imports in their applications.
1175+
* @param {string} projectDir Path to the application.
1176+
* @returns {void}
1177+
*/
1178+
checkForDeprecatedShortImportsInAppDir(projectDir: string): void;
11711179
}
11721180

11731181
interface IUtils {

lib/common/definitions/mobile.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ declare module Mobile {
107107

108108
interface IiOSDevice extends IDevice {
109109
getDebugSocket(appId: string, projectName: string): Promise<any>;
110-
destroyDebugSocket(appId: string): void;
110+
destroyDebugSocket(appId: string): Promise<void>;
111111
openDeviceLogStream(options?: IiOSLogStreamOptions): Promise<void>;
112-
destroyAllSockets(): void;
112+
destroyAllSockets(): Promise<void>;
113113
}
114114

115115
interface IAndroidDevice extends IDevice {

lib/common/errors.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as util from "util";
22
import * as path from "path";
33
import { SourceMapConsumer } from "source-map";
4+
import { isInteractive } from "./helpers";
45

56
// we need this to overwrite .stack property (read-only in Error)
67
function Exception() {
@@ -159,7 +160,7 @@ export class Errors implements IErrors {
159160
} catch (ex) {
160161
const loggerLevel: string = $injector.resolve("logger").getLevel().toUpperCase();
161162
const printCallStack = this.printCallStack || loggerLevel === "TRACE" || loggerLevel === "DEBUG";
162-
const message = printCallStack ? resolveCallStack(ex) : `\x1B[31;1m${ex.message}\x1B[0m`;
163+
const message = printCallStack ? resolveCallStack(ex) : isInteractive() ? `\x1B[31;1m${ex.message}\x1B[0m` : ex.message;
163164

164165
if (ex.printOnStdout) {
165166
this.$injector.resolve("logger").out(message);

0 commit comments

Comments
 (0)