diff --git a/.idea/misc.xml b/.idea/misc.xml
index 1162f43828..8662aa97f9 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,5 +1,4 @@
-
-
+
\ No newline at end of file
diff --git a/Gruntfile.js b/Gruntfile.js
index 2f347fa181..c824b694d0 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -55,9 +55,20 @@ module.exports = function(grunt) {
sourceMap: false,
removeComments: true
}
- }
+ },
},
-
+
+ tslint: {
+ build: {
+ files: {
+ src: ["lib/**/*.ts", "test/**/*.ts", "!lib/common/node_modules/**/*.ts", "lib/common/test/unit-tests/**/*.ts", "definitions/**/*.ts", "!**/*.d.ts"]
+ },
+ options: {
+ configuration: grunt.file.readJSON("./tslint.json")
+ }
+ }
+ },
+
watch: {
devall: {
files: ["lib/**/*.ts", 'test/**/*.ts', "!lib/common/node_modules/**/*.ts"],
@@ -119,9 +130,9 @@ module.exports = function(grunt) {
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-shell");
grunt.loadNpmTasks("grunt-ts");
+ grunt.loadNpmTasks("grunt-tslint");
grunt.registerTask("set_package_version", function(version) {
- var fs = require("fs");
var buildVersion = version !== undefined ? version : buildNumber;
if (process.env["BUILD_CAUSE_GHPRBCAUSE"]) {
buildVersion = "PR" + buildVersion;
@@ -150,7 +161,6 @@ module.exports = function(grunt) {
grunt.file.write("package.json", JSON.stringify(packageJson, null, " "));
});
-
grunt.registerTask("test", ["ts:devall", "shell:npm_test"]);
grunt.registerTask("pack", [
"clean",
@@ -162,6 +172,7 @@ module.exports = function(grunt) {
"copy:package_to_drop_folder",
"copy:package_to_qa_drop_folder"
]);
+ grunt.registerTask("lint", ["tslint:build"]);
grunt.registerTask("default", "ts:devlib");
};
diff --git a/lib/commands/add-library.ts b/lib/commands/add-library.ts
index f804f99dfd..f012d7577c 100644
--- a/lib/commands/add-library.ts
+++ b/lib/commands/add-library.ts
@@ -1,8 +1,7 @@
///
"use strict";
-import path = require("path");
-import Future = require("fibers/future");
+import * as path from "path";
export class AddLibraryCommand implements ICommand {
constructor(private $platformService: IPlatformService,
@@ -14,8 +13,8 @@ export class AddLibraryCommand implements ICommand {
execute(args: string[]): IFuture {
return (() => {
- var platform = args[0];
- var libraryPath = path.resolve(args[1]);
+ let platform = args[0];
+ let libraryPath = path.resolve(args[1]);
this.$platformService.addLibrary(platform, libraryPath).wait();
this.$logger.info(`Library ${libraryPath} was successfully added for ${platform} platform.`);
}).future()();
@@ -48,4 +47,4 @@ export class AddLibraryCommand implements ICommand {
}).future()();
}
}
-$injector.registerCommand("library|add", AddLibraryCommand);
\ No newline at end of file
+$injector.registerCommand("library|add", AddLibraryCommand);
diff --git a/lib/commands/add-platform.ts b/lib/commands/add-platform.ts
index ad1164df3c..9c78f0e1d8 100644
--- a/lib/commands/add-platform.ts
+++ b/lib/commands/add-platform.ts
@@ -25,4 +25,4 @@ export class AddPlatformCommand implements ICommand {
}).future()();
}
}
-$injector.registerCommand("platform|add", AddPlatformCommand);
\ No newline at end of file
+$injector.registerCommand("platform|add", AddPlatformCommand);
diff --git a/lib/commands/build.ts b/lib/commands/build.ts
index b81bfbe700..23adc6904d 100644
--- a/lib/commands/build.ts
+++ b/lib/commands/build.ts
@@ -23,7 +23,6 @@ export class BuildIosCommand extends BuildCommandBase implements ICommand {
}
$injector.registerCommand("build|ios", BuildIosCommand);
-
export class BuildAndroidCommand extends BuildCommandBase implements ICommand {
constructor($platformService: IPlatformService,
private $platformsData: IPlatformsData) {
diff --git a/lib/commands/create-project.ts b/lib/commands/create-project.ts
index 9fe9b036b2..41a404d0b1 100644
--- a/lib/commands/create-project.ts
+++ b/lib/commands/create-project.ts
@@ -36,6 +36,6 @@ export class CreateProjectCommand implements ICommand {
}).future()();
}
- allowedParameters = [new ProjectCommandParameter(this.$errors, this.$logger, this.$projectNameValidator) ]
+ allowedParameters = [new ProjectCommandParameter(this.$errors, this.$logger, this.$projectNameValidator) ];
}
$injector.registerCommand("create", CreateProjectCommand);
diff --git a/lib/commands/init.ts b/lib/commands/init.ts
index 52a2098f71..0fae9f1502 100644
--- a/lib/commands/init.ts
+++ b/lib/commands/init.ts
@@ -1,8 +1,6 @@
///
"use strict";
-import Future = require("fibers/future");
-
export class InitCommand implements ICommand {
constructor(private $initService: IInitService) { }
@@ -13,4 +11,4 @@ export class InitCommand implements ICommand {
return this.$initService.initialize();
}
}
-$injector.registerCommand("init", InitCommand);
\ No newline at end of file
+$injector.registerCommand("init", InitCommand);
diff --git a/lib/commands/install.ts b/lib/commands/install.ts
index e26e99aca9..2722c11533 100644
--- a/lib/commands/install.ts
+++ b/lib/commands/install.ts
@@ -2,8 +2,6 @@
"use strict";
export class InstallCommand implements ICommand {
- private _projectData: any;
-
constructor(private $platformsData: IPlatformsData,
private $platformService: IPlatformService,
private $projectData: IProjectData,
@@ -41,4 +39,4 @@ export class InstallCommand implements ICommand {
}).future()();
}
}
-$injector.registerCommand("install", InstallCommand);
\ No newline at end of file
+$injector.registerCommand("install", InstallCommand);
diff --git a/lib/commands/list-platforms.ts b/lib/commands/list-platforms.ts
index 7510dd3351..c1de5b5784 100644
--- a/lib/commands/list-platforms.ts
+++ b/lib/commands/list-platforms.ts
@@ -2,7 +2,6 @@
"use strict";
import helpers = require("./../common/helpers");
-import util = require("util")
export class ListPlatformsCommand implements ICommand {
constructor(private $platformService: IPlatformService,
@@ -10,10 +9,10 @@ export class ListPlatformsCommand implements ICommand {
execute(args: string[]): IFuture {
return (() => {
- var installedPlatforms = this.$platformService.getInstalledPlatforms().wait();
+ let installedPlatforms = this.$platformService.getInstalledPlatforms().wait();
if(installedPlatforms.length > 0) {
- var preparedPlatforms = this.$platformService.getPreparedPlatforms().wait();
+ let preparedPlatforms = this.$platformService.getPreparedPlatforms().wait();
if(preparedPlatforms.length > 0) {
this.$logger.out("The project is prepared for: ", helpers.formatListOfNames(preparedPlatforms, "and"));
} else {
diff --git a/lib/commands/livesync.ts b/lib/commands/livesync.ts
index fe29e18c55..f1d81c01de 100644
--- a/lib/commands/livesync.ts
+++ b/lib/commands/livesync.ts
@@ -30,4 +30,4 @@ export class LivesyncCommand implements ICommand {
allowedParameters: ICommandParameter[] = [];
}
-$injector.registerCommand("livesync", LivesyncCommand);
\ No newline at end of file
+$injector.registerCommand("livesync", LivesyncCommand);
diff --git a/lib/commands/plugin/remove-plugin.ts b/lib/commands/plugin/remove-plugin.ts
index b661085110..b5782cd698 100644
--- a/lib/commands/plugin/remove-plugin.ts
+++ b/lib/commands/plugin/remove-plugin.ts
@@ -27,4 +27,4 @@ export class RemovePluginCommand implements ICommand {
public allowedParameters: ICommandParameter[] = [];
}
-$injector.registerCommand("plugin|remove", RemovePluginCommand);
\ No newline at end of file
+$injector.registerCommand("plugin|remove", RemovePluginCommand);
diff --git a/lib/commands/remove-platform.ts b/lib/commands/remove-platform.ts
index e7b34df76a..c24a3ec079 100644
--- a/lib/commands/remove-platform.ts
+++ b/lib/commands/remove-platform.ts
@@ -25,4 +25,4 @@ export class RemovePlatformCommand implements ICommand {
allowedParameters: ICommandParameter[] = [];
}
-$injector.registerCommand("platform|remove", RemovePlatformCommand);
\ No newline at end of file
+$injector.registerCommand("platform|remove", RemovePlatformCommand);
diff --git a/lib/commands/update-platform.ts b/lib/commands/update-platform.ts
index 635027631b..c2e07aabaa 100644
--- a/lib/commands/update-platform.ts
+++ b/lib/commands/update-platform.ts
@@ -25,4 +25,4 @@ export class UpdatePlatformCommand implements ICommand {
allowedParameters: ICommandParameter[] = [];
}
-$injector.registerCommand("platform|update", UpdatePlatformCommand);
\ No newline at end of file
+$injector.registerCommand("platform|update", UpdatePlatformCommand);
diff --git a/lib/common b/lib/common
index adf981dbc2..35f03103af 160000
--- a/lib/common
+++ b/lib/common
@@ -1 +1 @@
-Subproject commit adf981dbc237a2d0d6ffc8f4fcf1f423a2ddcb3c
+Subproject commit 35f03103af87f6a31793aeb183a6ea2d93dfc8d9
diff --git a/lib/config.ts b/lib/config.ts
index 74f26be82c..096640e685 100644
--- a/lib/config.ts
+++ b/lib/config.ts
@@ -1,10 +1,9 @@
///
"use strict";
-import path = require("path");
-import util = require("util");
-import staticConfigBaseLibPath = require("./common/static-config-base");
-import configBaseLib = require("./common/config-base");
+import * as path from "path";
+import * as staticConfigBaseLibPath from "./common/static-config-base";
+import * as configBaseLib from "./common/config-base";
export class Configuration extends configBaseLib.ConfigBase implements IConfiguration { // User specific config
CI_LOGGER = false;
@@ -37,7 +36,7 @@ export class StaticConfig extends staticConfigBaseLibPath.StaticConfigBase imple
}
public get SYS_REQUIREMENTS_LINK(): string {
- var linkToSysRequirements: string;
+ let linkToSysRequirements: string;
switch(process.platform) {
case "linux":
linkToSysRequirements = "http://docs.nativescript.org/setup/ns-cli-setup/ns-setup-linux.html#system-requirements";
diff --git a/lib/constants.ts b/lib/constants.ts
index 032432dc54..da96453d31 100644
--- a/lib/constants.ts
+++ b/lib/constants.ts
@@ -1,14 +1,15 @@
///
+"use strict";
-export var APP_FOLDER_NAME = "app";
-export var APP_RESOURCES_FOLDER_NAME = "App_Resources";
-export var PROJECT_FRAMEWORK_FOLDER_NAME = "framework";
-export var NATIVESCRIPT_KEY_NAME = "nativescript";
-export var NODE_MODULES_FOLDER_NAME = "node_modules";
-export var TNS_CORE_MODULES_NAME = "tns-core-modules";
-export var PACKAGE_JSON_FILE_NAME = "package.json";
-export var NODE_MODULE_CACHE_PATH_KEY_NAME = "node-modules-cache-path";
-export var DEFAULT_APP_IDENTIFIER_PREFIX = "org.nativescript";
+export let APP_FOLDER_NAME = "app";
+export let APP_RESOURCES_FOLDER_NAME = "App_Resources";
+export let PROJECT_FRAMEWORK_FOLDER_NAME = "framework";
+export let NATIVESCRIPT_KEY_NAME = "nativescript";
+export let NODE_MODULES_FOLDER_NAME = "node_modules";
+export let TNS_CORE_MODULES_NAME = "tns-core-modules";
+export let PACKAGE_JSON_FILE_NAME = "package.json";
+export let NODE_MODULE_CACHE_PATH_KEY_NAME = "node-modules-cache-path";
+export let DEFAULT_APP_IDENTIFIER_PREFIX = "org.nativescript";
export class ReleaseType {
static MAJOR = "major";
@@ -19,5 +20,3 @@ export class ReleaseType {
static PREPATCH = "prepatch";
static PRERELEASE = "prerelease";
}
-
-
diff --git a/lib/declarations.ts b/lib/declarations.ts
index 27007e1b81..2e41e6a447 100644
--- a/lib/declarations.ts
+++ b/lib/declarations.ts
@@ -88,4 +88,4 @@ interface IProjectFilesManager {
interface IInitService {
initialize(): IFuture;
-}
\ No newline at end of file
+}
diff --git a/lib/dynamic-help-provider.ts b/lib/dynamic-help-provider.ts
index d163ff9200..0d69c97aee 100644
--- a/lib/dynamic-help-provider.ts
+++ b/lib/dynamic-help-provider.ts
@@ -1,18 +1,15 @@
///
-
"use strict";
import Future = require("fibers/future");
export class DynamicHelpProvider implements IDynamicHelpProvider {
- constructor() { }
-
public isProjectType(args: string[]): IFuture {
return Future.fromResult(true);
}
public getLocalVariables(options: { isHtml: boolean }): IFuture> {
- var localVariables: IDictionary = {};
+ let localVariables: IDictionary = {};
return Future.fromResult(localVariables);
}
}
diff --git a/lib/lockfile.ts b/lib/lockfile.ts
index dd8174dc70..fc68de5511 100644
--- a/lib/lockfile.ts
+++ b/lib/lockfile.ts
@@ -3,7 +3,7 @@
import Future = require("fibers/future");
import lockfile = require("lockfile");
-import path = require("path");
+import * as path from "path";
export class LockFile implements ILockFile {
private lockFilePath: string;
@@ -20,7 +20,7 @@ export class LockFile implements ILockFile {
};
public lock(): IFuture {
- var future = new Future();
+ let future = new Future();
lockfile.lock(this.lockFilePath, LockFile.LOCK_PARAMS, (err: Error) => {
if(err) {
future.throw(err);
@@ -32,7 +32,7 @@ export class LockFile implements ILockFile {
}
public unlock(): IFuture {
- var future = new Future();
+ let future = new Future();
lockfile.unlock(this.lockFilePath, (err: Error) => {
if(err) {
future.throw(err);
@@ -43,4 +43,4 @@ export class LockFile implements ILockFile {
return future;
}
}
-$injector.register("lockfile", LockFile);
\ No newline at end of file
+$injector.register("lockfile", LockFile);
diff --git a/lib/mobile-platforms-capabilities.ts b/lib/mobile-platforms-capabilities.ts
index 55bef0a0f3..b729408473 100644
--- a/lib/mobile-platforms-capabilities.ts
+++ b/lib/mobile-platforms-capabilities.ts
@@ -24,7 +24,7 @@ export class MobilePlatformsCapabilities implements Mobile.IPlatformsCapabilitie
companion: false,
hostPlatformsForDeploy: ["win32", "darwin", "linux"]
}
- }
+ };
return this.platformCapabilities;
}
diff --git a/lib/nativescript-cli.ts b/lib/nativescript-cli.ts
index 9770da7fdb..cd5b3aaceb 100644
--- a/lib/nativescript-cli.ts
+++ b/lib/nativescript-cli.ts
@@ -1,6 +1,5 @@
///
"use strict";
-import path = require("path");
require("./bootstrap");
import fiber = require("fibers");
@@ -9,11 +8,11 @@ import errors = require("./common/errors");
errors.installUncaughtExceptionListener();
fiber(() => {
- var config = $injector.resolve("$config");
- var err = $injector.resolve("$errors");
+ let config = $injector.resolve("$config");
+ let err = $injector.resolve("$errors");
err.printCallStack = config.DEBUG;
- var commandDispatcher: ICommandDispatcher = $injector.resolve("commandDispatcher");
+ let commandDispatcher: ICommandDispatcher = $injector.resolve("commandDispatcher");
if (process.argv[2] === "completion") {
commandDispatcher.completeCommand().wait();
diff --git a/lib/node-package-manager.ts b/lib/node-package-manager.ts
index 452f779cb0..3df980a015 100644
--- a/lib/node-package-manager.ts
+++ b/lib/node-package-manager.ts
@@ -17,7 +17,7 @@ export class NodePackageManager implements INodePackageManager {
}
public load(config?: any): IFuture {
- var future = new Future();
+ let future = new Future();
npm.load(config, (err) => {
if(err) {
future.throw(err);
@@ -75,7 +75,7 @@ export class NodePackageManager implements INodePackageManager {
} else {
future.return(data);
}
- }
+ };
args.push(callback);
let command = subCommandName ? npm.commands[commandName][subCommandName] : npm.commands[commandName];
diff --git a/lib/npm-installation-manager.ts b/lib/npm-installation-manager.ts
index c25c7e66da..c83ec9bb71 100644
--- a/lib/npm-installation-manager.ts
+++ b/lib/npm-installation-manager.ts
@@ -1,10 +1,10 @@
///
"use strict";
-import path = require("path");
+import * as path from "path";
import semver = require("semver");
-import npm = require("npm");
-import constants = require("./constants");
+import * as npm from "npm";
+import * as constants from "./constants";
export class NpmInstallationManager implements INpmInstallationManager {
private static NPM_LOAD_FAILED = "Failed to retrieve data from npm. Please try again a little bit later.";
@@ -63,9 +63,9 @@ export class NpmInstallationManager implements INpmInstallationManager {
this.$lockfile.lock().wait();
try {
- var packageToInstall = packageName;
- var pathToSave = (opts && opts.pathToSave) || npm.cache;
- var version = (opts && opts.version) || null;
+ let packageToInstall = packageName;
+ let pathToSave = (opts && opts.pathToSave) || npm.cache;
+ let version = (opts && opts.version) || null;
return this.installCore(packageToInstall, pathToSave, version).wait();
} catch(error) {
@@ -85,7 +85,7 @@ export class NpmInstallationManager implements INpmInstallationManager {
this.$fs.deleteDirectory(packagePath).wait();
this.addToCacheCore(packageName, version).wait();
if(!this.isShasumOfPackageCorrect(packageName, version).wait()) {
- this.$errors.failWithoutHelp(`Unable to add package ${packageName} with version ${version} to npm cache. Try cleaning your cache and execute the command again.`)
+ this.$errors.failWithoutHelp(`Unable to add package ${packageName} with version ${version} to npm cache. Try cleaning your cache and execute the command again.`);
}
}).future()();
}
@@ -120,14 +120,14 @@ export class NpmInstallationManager implements INpmInstallationManager {
if (this.$options.frameworkPath) {
if (this.$fs.getFsStats(this.$options.frameworkPath).wait().isFile()) {
this.npmInstall(packageName, pathToSave, version).wait();
- var pathToNodeModules = path.join(pathToSave, "node_modules");
- var folders = this.$fs.readDirectory(pathToNodeModules).wait();
+ let pathToNodeModules = path.join(pathToSave, "node_modules");
+ let folders = this.$fs.readDirectory(pathToNodeModules).wait();
return path.join(pathToNodeModules, folders[0]);
}
return this.$options.frameworkPath;
} else {
version = version || this.getLatestVersion(packageName).wait();
- var packagePath = this.getCachedPackagePath(packageName, version);
+ let packagePath = this.getCachedPackagePath(packageName, version);
if (!this.isPackageCached(packagePath).wait()) {
this.$npm.cache(packageName, version).wait();
}
@@ -143,7 +143,7 @@ export class NpmInstallationManager implements INpmInstallationManager {
private npmInstall(packageName: string, pathToSave: string, version: string): IFuture {
this.$logger.out("Installing ", packageName);
- var incrementedVersion = semver.inc(version, constants.ReleaseType.MINOR);
+ let incrementedVersion = semver.inc(version, constants.ReleaseType.MINOR);
if (!this.$options.frameworkPath && packageName.indexOf("@") < 0) {
packageName = packageName + "@<" + incrementedVersion;
}
@@ -163,4 +163,4 @@ export class NpmInstallationManager implements INpmInstallationManager {
}).future()();
}
}
-$injector.register("npmInstallationManager", NpmInstallationManager);
\ No newline at end of file
+$injector.register("npmInstallationManager", NpmInstallationManager);
diff --git a/lib/platform-command-param.ts b/lib/platform-command-param.ts
index ff480fca23..3d5c9200af 100644
--- a/lib/platform-command-param.ts
+++ b/lib/platform-command-param.ts
@@ -11,4 +11,4 @@ export class PlatformCommandParameter implements ICommandParameter {
}).future()();
}
}
-$injector.register("platformCommandParameter", PlatformCommandParameter);
\ No newline at end of file
+$injector.register("platformCommandParameter", PlatformCommandParameter);
diff --git a/lib/platforms-data.ts b/lib/platforms-data.ts
index dd47ecdd1e..8b120d07c2 100644
--- a/lib/platforms-data.ts
+++ b/lib/platforms-data.ts
@@ -10,7 +10,7 @@ export class PlatformsData implements IPlatformsData {
this.platformsData = {
ios: $iOSProjectService.platformData,
android: $androidProjectService.platformData
- }
+ };
}
public get platformsNames() {
@@ -28,4 +28,4 @@ export class PlatformsData implements IPlatformsData {
};
}
}
-$injector.register("platformsData", PlatformsData);
\ No newline at end of file
+$injector.register("platformsData", PlatformsData);
diff --git a/lib/project-data.ts b/lib/project-data.ts
index 891304fa75..9cafb6f06a 100644
--- a/lib/project-data.ts
+++ b/lib/project-data.ts
@@ -1,9 +1,8 @@
///
"use strict";
-import constants = require("./constants");
-import path = require("path");
-import os = require("os");
+import * as path from "path";
+import * as os from "os";
export class ProjectData implements IProjectData {
private static OLD_PROJECT_FILE_NAME = ".tnsproject";
@@ -101,4 +100,4 @@ export class ProjectData implements IProjectData {
this.projectFilePath = path.join(projectDir, this.$staticConfig.PROJECT_FILE_NAME);
}
}
-$injector.register("projectData", ProjectData);
\ No newline at end of file
+$injector.register("projectData", ProjectData);
diff --git a/lib/providers/commands-service-provider.ts b/lib/providers/commands-service-provider.ts
index 88d5571ae6..497a64b2b6 100644
--- a/lib/providers/commands-service-provider.ts
+++ b/lib/providers/commands-service-provider.ts
@@ -14,7 +14,7 @@ export class CommandsServiceProvider implements ICommandsServiceProvider {
}
public registerDynamicSubCommands(): void {
-
+ /* intentionally left blank */
}
}
-$injector.register("commandsServiceProvider", CommandsServiceProvider);
\ No newline at end of file
+$injector.register("commandsServiceProvider", CommandsServiceProvider);
diff --git a/lib/providers/device-app-data-provider.ts b/lib/providers/device-app-data-provider.ts
index 5774e1fe9a..ee6d5dbee1 100644
--- a/lib/providers/device-app-data-provider.ts
+++ b/lib/providers/device-app-data-provider.ts
@@ -1,7 +1,6 @@
///
"use strict";
-import deviceAppDataBaseLib = require("../common/mobile/device-app-data/device-app-data-base");
-import constantsLib = require("../common/mobile/constants");
+import * as deviceAppDataBaseLib from "../common/mobile/device-app-data/device-app-data-base";
import Future = require("fibers/future");
export class IOSAppIdentifier extends deviceAppDataBaseLib.DeviceAppDataBase implements Mobile.IDeviceAppData {
@@ -58,7 +57,7 @@ export class DeviceAppDataProvider implements Mobile.IDeviceAppDataProvider {
vanilla: AndroidAppIdentifier,
companion: AndroidCompanionAppIdentifier
}
- }
+ };
}
}
-$injector.register("deviceAppDataProvider", DeviceAppDataProvider);
\ No newline at end of file
+$injector.register("deviceAppDataProvider", DeviceAppDataProvider);
diff --git a/lib/providers/logcat-printer.ts b/lib/providers/logcat-printer.ts
index 9c03309166..d4cc64e658 100644
--- a/lib/providers/logcat-printer.ts
+++ b/lib/providers/logcat-printer.ts
@@ -9,4 +9,4 @@ export class LogcatPrinter implements Mobile.ILogcatPrinter {
}
}
-$injector.register("logcatPrinter", LogcatPrinter);
\ No newline at end of file
+$injector.register("logcatPrinter", LogcatPrinter);
diff --git a/lib/services/analytics-settings-service.ts b/lib/services/analytics-settings-service.ts
index eed22a8c5e..90ebc1357c 100644
--- a/lib/services/analytics-settings-service.ts
+++ b/lib/services/analytics-settings-service.ts
@@ -22,4 +22,4 @@ class AnalyticsSettingsService implements IAnalyticsSettingsService {
return "http://www.telerik.com/company/privacy-policy";
}
}
-$injector.register("analyticsSettingsService", AnalyticsSettingsService);
\ No newline at end of file
+$injector.register("analyticsSettingsService", AnalyticsSettingsService);
diff --git a/lib/services/android-debug-service.ts b/lib/services/android-debug-service.ts
index a834d10663..dcf490e742 100644
--- a/lib/services/android-debug-service.ts
+++ b/lib/services/android-debug-service.ts
@@ -1,9 +1,8 @@
-import iOSProxyServices = require("./../common/mobile/ios/ios-proxy-services");
-import iOSDevice = require("./../common/mobile/ios/ios-device");
-import helpers = require("../common/helpers");
-import net = require("net");
-import path = require("path");
-import util = require("util");
+///
+"use strict";
+import * as helpers from "../common/helpers";
+import * as path from "path";
+import * as util from "util";
class AndroidDebugService implements IDebugService {
private static ENV_DEBUG_IN_FILENAME = "envDebug.in";
@@ -72,7 +71,7 @@ class AndroidDebugService implements IDebugService {
}
this.$devicesServices.initialize({ platform: this.platform, deviceId: this.$options.device}).wait();
- let action = (device: Mobile.IAndroidDevice): IFuture => { return this.debugCore(device, packageFile, this.$projectData.projectId) };
+ let action = (device: Mobile.IAndroidDevice): IFuture => { return this.debugCore(device, packageFile, this.$projectData.projectId); };
this.$devicesServices.execute(action).wait();
}).future()();
@@ -136,8 +135,6 @@ class AndroidDebugService implements IDebugService {
this.device.applicationManager.uninstallApplication(packageName).wait();
this.device.applicationManager.installApplication(packageFile).wait();
}
-
- let port = this.$options.debugPort;
let packageDir = util.format(AndroidDebugService.PACKAGE_EXTERNAL_DIR_TEMPLATE, packageName);
let envDebugOutFullpath = this.$mobileHelper.buildDevicePath(packageDir, AndroidDebugService.ENV_DEBUG_OUT_FILENAME);
@@ -209,8 +206,9 @@ class AndroidDebugService implements IDebugService {
for (let i = 0; i < timeout; i++) {
helpers.sleep(1000 /* ms */);
isRunning = this.checkIfRunning(packageName);
- if (isRunning)
+ if (isRunning) {
break;
+ }
}
if (isRunning) {
diff --git a/lib/services/android-project-properties-manager.ts b/lib/services/android-project-properties-manager.ts
index d0132534d6..7abba90921 100644
--- a/lib/services/android-project-properties-manager.ts
+++ b/lib/services/android-project-properties-manager.ts
@@ -1,11 +1,9 @@
///
"use strict";
-import path = require("path");
+import * as path from "path";
export class AndroidProjectPropertiesManager implements IAndroidProjectPropertiesManager {
- private static LIBRARY_REFERENCE_KEY_PREFIX = "android.library.reference.";
-
private _editor: IPropertiesParserEditor = null;
private filePath: string = null;
private projectReferences: ILibRef[];
@@ -77,7 +75,7 @@ export class AndroidProjectPropertiesManager implements IAndroidProjectPropertie
key: referenceName,
path: referencePath,
adjustedPath: path.join(path.dirname(this.filePath), referencePath)
- }
+ };
}
private addToPropertyList(key: string, value: string): IFuture {
@@ -115,4 +113,4 @@ export class AndroidProjectPropertiesManager implements IAndroidProjectPropertie
this.dirty = true;
}).future()();
}
-}
\ No newline at end of file
+}
diff --git a/lib/services/android-project-service.ts b/lib/services/android-project-service.ts
index cf257a26dc..c51af00ef6 100644
--- a/lib/services/android-project-service.ts
+++ b/lib/services/android-project-service.ts
@@ -70,7 +70,9 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
this.validatePackageName(this.$projectData.projectId);
this.validateProjectName(this.$projectData.projectName);
- this.checkJava().wait() && this.checkAnt().wait() && this.checkAndroid().wait();
+ this.checkJava().wait();
+ this.checkAnt().wait();
+ this.checkAndroid().wait();
}).future()();
}
@@ -121,7 +123,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
return {
dirName: dir,
sdkNum: parseInt(dir.substr(AndroidProjectService.VALUES_VERSION_DIRNAME_PREFIX.length))
- }
+ };
})
.filter(dir => dir.dirName.match(AndroidProjectService.VALUES_VERSION_DIRNAME_PREFIX) && dir.sdkNum && (!integerFrameworkVersion || (integerFrameworkVersion >= dir.sdkNum)))
.max(dir => dir.sdkNum)
@@ -139,7 +141,6 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
return (() => {
// Interpolate the activity name and package
let manifestPath = path.join(projectRoot, "AndroidManifest.xml");
- let safeActivityName = this.$projectData.projectName.replace(/\W/g, '');
shell.sed('-i', /__PACKAGE__/, this.$projectData.projectId, manifestPath);
shell.sed('-i', /__APILEVEL__/, this.getTarget(projectRoot).wait().split('-')[1], manifestPath);
@@ -176,7 +177,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
}
public updatePlatform(currentVersion: string, newVersion: string): IFuture {
- return (() => { }).future()();
+ return Future.fromResult();
}
public buildProject(projectRoot: string): IFuture {
@@ -253,7 +254,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
}
public prepareProject(): IFuture {
- return (() => { }).future()();
+ return Future.fromResult();
}
public prepareAppResources(appResourcesDirectoryPath: string): IFuture {
@@ -356,7 +357,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
}
if(this.$options.keyStoreAliasPassword) {
- args = args.concat(["-Dkey.alias.password", this.$options.keyStoreAliasPassword])
+ args = args.concat(["-Dkey.alias.password", this.$options.keyStoreAliasPassword]);
}
}
@@ -422,15 +423,14 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
private getLatestValidAndroidTarget(frameworkDir: string): IFuture {
return (() => {
- let validTarget = this.getTarget(frameworkDir).wait();
let installedTargets = this.getInstalledTargets().wait();
// adjust to the latest available version
- var newTarget = _(this.SUPPORTED_TARGETS).sort().findLast(supportedTarget => _.contains(installedTargets, supportedTarget));
+ let newTarget = _(this.SUPPORTED_TARGETS).sort().findLast(supportedTarget => _.contains(installedTargets, supportedTarget));
if (!newTarget) {
this.$errors.failWithoutHelp(`Could not find supported Android target. Please install one of the following: ${this.SUPPORTED_TARGETS.join(", ")}.` +
" Make sure you have the latest Android tools installed as well." +
- ' Run "android" from your command-line to install/update any missing SDKs or tools.')
+ ' Run "android" from your command-line to install/update any missing SDKs or tools.');
}
return newTarget;
diff --git a/lib/services/emulator-settings-service.ts b/lib/services/emulator-settings-service.ts
index 07e476f286..37c50e418d 100644
--- a/lib/services/emulator-settings-service.ts
+++ b/lib/services/emulator-settings-service.ts
@@ -8,9 +8,9 @@ export class EmulatorSettingsService implements Mobile.IEmulatorSettingsService
public canStart(platform: string): IFuture {
return (() => {
- var platformService = this.$injector.resolve("platformService"); // this should be resolved here due to cyclic dependency
+ let platformService = this.$injector.resolve("platformService"); // this should be resolved here due to cyclic dependency
- var installedPlatforms = platformService.getInstalledPlatforms().wait();
+ let installedPlatforms = platformService.getInstalledPlatforms().wait();
return _.contains(installedPlatforms, platform.toLowerCase());
}).future()();
}
@@ -19,4 +19,4 @@ export class EmulatorSettingsService implements Mobile.IEmulatorSettingsService
return EmulatorSettingsService.REQURED_ANDROID_APILEVEL;
}
}
-$injector.register("emulatorSettingsService", EmulatorSettingsService);
\ No newline at end of file
+$injector.register("emulatorSettingsService", EmulatorSettingsService);
diff --git a/lib/services/init-service.ts b/lib/services/init-service.ts
index e30f5963cd..f852ff6fb1 100644
--- a/lib/services/init-service.ts
+++ b/lib/services/init-service.ts
@@ -1,9 +1,9 @@
///
"use strict";
-import constants = require("./../constants");
-import helpers = require("./../common/helpers");
-import path = require("path");
+import constants = require("../constants");
+import * as helpers from "../common/helpers";
+import * as path from "path";
import semver = require("semver");
export class InitService implements IInitService {
@@ -117,4 +117,4 @@ export class InitService implements IInitService {
return !helpers.isInteractive() || this.$options.force;
}
}
-$injector.register("initService", InitService);
\ No newline at end of file
+$injector.register("initService", InitService);
diff --git a/lib/services/ios-debug-service.ts b/lib/services/ios-debug-service.ts
index c4e4857528..90de780397 100644
--- a/lib/services/ios-debug-service.ts
+++ b/lib/services/ios-debug-service.ts
@@ -1,10 +1,12 @@
-import iOSProxyServices = require("./../common/mobile/ios/ios-proxy-services");
-import iOSDevice = require("./../common/mobile/ios/ios-device");
-import net = require("net");
+///
+"use strict";
+
+import * as iOSProxyServices from "../common/mobile/ios/ios-proxy-services";
+import * as iOSDevice from "../common/mobile/ios/ios-device";
+import * as net from "net";
import ws = require("ws");
-import stream = require("stream");
-import path = require("path");
-import http = require("http");
+import * as stream from "stream";
+import * as path from "path";
import Future = require("fibers/future");
import semver = require("semver");
@@ -42,13 +44,13 @@ module notification {
}
}
-var InspectorBackendPort = 18181;
+let InspectorBackendPort = 18181;
-function connectEventually(factory: () => net.Socket, handler: (socket: net.Socket) => void) {
+function connectEventually(factory: () => net.Socket, handler: (_socket: net.Socket) => void) {
function tryConnect() {
- var tryConnectAfterTimeout = setTimeout.bind(undefined, tryConnect, 1000);
+ let tryConnectAfterTimeout = setTimeout.bind(undefined, tryConnect, 1000);
- var socket = factory();
+ let socket = factory();
socket.on("connect", () => {
socket.removeListener("error", tryConnectAfterTimeout);
handler(socket);
@@ -111,9 +113,9 @@ class IOSDebugService implements IDebugService {
private emulatorDebugBrk(): IFuture {
return (() => {
- var platformData = this.$platformsData.getPlatformData(this.platform);
+ let platformData = this.$platformsData.getPlatformData(this.platform);
this.$platformService.buildPlatform(this.platform).wait();
- var emulatorPackage = this.$platformService.getLatestApplicationPackageForEmulator(platformData).wait();
+ let emulatorPackage = this.$platformService.getLatestApplicationPackageForEmulator(platformData).wait();
this.$iOSEmulatorServices.startEmulator(emulatorPackage.packageName, { args: "--nativescript-debug-brk" }).wait();
createWebSocketProxy(this.$logger, (callback) => connectEventually(() => net.connect(InspectorBackendPort), callback));
@@ -125,10 +127,10 @@ class IOSDebugService implements IDebugService {
return (() => {
createWebSocketProxy(this.$logger, (callback) => connectEventually(() => net.connect(InspectorBackendPort), callback));
this.executeOpenDebuggerClient().wait();
- var projectId = this.$projectData.projectId;
- var attachRequestMessage = notification.attachRequest(projectId);
+ let projectId = this.$projectData.projectId;
+ let attachRequestMessage = notification.attachRequest(projectId);
- var iOSEmulator = this.$iOSEmulatorServices;
+ let iOSEmulator = this.$iOSEmulatorServices;
iOSEmulator.postDarwinNotification(attachRequestMessage).wait();
}).future()();
}
@@ -192,15 +194,18 @@ class IOSDebugService implements IDebugService {
switch (receivedNotification) {
case alreadyConnected:
this.$errors.failWithoutHelp("A debugger is already connected.");
+ break;
case attachAvailable:
process.nextTick(() => npc.postNotificationAndAttachForData(notification.attachRequest(projectId)));
try { awaitNotification(npc, notification.readyForAttach(projectId), timeout).wait(); }
catch (e) {
this.$errors.failWithoutHelp(`The application ${projectId} timed out when performing the NativeScript debugger handshake.`);
}
+ break;
case readyForAttach:
createWebSocketProxy(this.$logger, (callback) => connectEventually(() => iosDevice.connectToPort(InspectorBackendPort), callback));
this.executeOpenDebuggerClient().wait();
+ break;
}
}).future()()).wait();
}).future()();
@@ -242,17 +247,17 @@ class IOSDebugService implements IDebugService {
private getInspectorPath(frameworkVersion: string): IFuture {
return (() => {
- var tnsIosPackage = "";
+ let tnsIosPackage = "";
if (this.$options.frameworkPath) {
if (this.$fs.getFsStats(this.$options.frameworkPath).wait().isFile()) {
this.$errors.failWithoutHelp("frameworkPath option must be path to directory which contains tns-ios framework");
}
tnsIosPackage = path.resolve(this.$options.frameworkPath);
} else {
- var platformData = this.$platformsData.getPlatformData(this.platform);
+ let platformData = this.$platformsData.getPlatformData(this.platform);
tnsIosPackage = this.$npmInstallationManager.install(platformData.frameworkPackageName, { version: frameworkVersion }).wait();
}
- var inspectorPath = path.join(tnsIosPackage, "WebInspectorUI/");
+ let inspectorPath = path.join(tnsIosPackage, "WebInspectorUI/");
return inspectorPath;
}).future()();
}
@@ -267,9 +272,9 @@ class IOSDebugService implements IDebugService {
}
$injector.register("iOSDebugService", IOSDebugService);
-function createWebSocketProxy($logger: ILogger, socketFactory: (handler: (socket: net.Socket) => void) => void): ws.Server {
+function createWebSocketProxy($logger: ILogger, socketFactory: (handler: (_socket: net.Socket) => void) => void): ws.Server {
// NOTE: We will try to provide command line options to select ports, at least on the localhost.
- var localPort = 8080;
+ let localPort = 8080;
$logger.info("\nSetting up debugger proxy...\nPress Ctrl + C to terminate, or disconnect.\n");
@@ -278,7 +283,7 @@ function createWebSocketProxy($logger: ILogger, socketFactory: (handler: (socket
// We store the socket that connects us to the device in the upgrade request object itself and later on retrieve it
// in the connection callback.
- var server = ws.createServer({
+ let server = ws.createServer({
port: localPort,
verifyClient: (info: any, callback: any) => {
$logger.info("Frontend client connected.");
@@ -290,8 +295,8 @@ function createWebSocketProxy($logger: ILogger, socketFactory: (handler: (socket
}
});
server.on("connection", (webSocket) => {
- var deviceSocket: net.Socket = (webSocket.upgradeReq)["__deviceSocket"];
- var packets = new PacketStream();
+ let deviceSocket: net.Socket = (webSocket.upgradeReq)["__deviceSocket"];
+ let packets = new PacketStream();
deviceSocket.pipe(packets);
packets.on("data", (buffer: Buffer) => {
@@ -299,8 +304,8 @@ function createWebSocketProxy($logger: ILogger, socketFactory: (handler: (socket
});
webSocket.on("message", (message, flags) => {
- var length = Buffer.byteLength(message, "utf16le");
- var payload = new Buffer(length + 4);
+ let length = Buffer.byteLength(message, "utf16le");
+ let payload = new Buffer(length + 4);
payload.writeInt32BE(length, 0);
payload.write(message, 4, length, "utf16le");
deviceSocket.write(payload);
@@ -329,10 +334,10 @@ function awaitNotification(npc: iOSProxyServices.NotificationProxyClient, notifi
future.throw(new Error(`Timeout receiving ${notification} notification.`));
}, timeout);
- function notificationObserver(notification: string) {
+ function notificationObserver(_notification: string) {
clearTimeout(timeoutObject);
detachObserver();
- future.return(notification);
+ future.return(_notification);
}
function detachObserver() {
@@ -347,16 +352,17 @@ function awaitNotification(npc: iOSProxyServices.NotificationProxyClient, notifi
function whenAny(...futures: IFuture[]): IFuture> {
let resultFuture = new Future>();
let futuresLeft = futures.length;
+ let futureLocal: IFuture;
for (let future of futures) {
- var futureLocal = future;
+ futureLocal = future;
future.resolve((error, result?) => {
futuresLeft--;
if (!resultFuture.isResolved()) {
if (typeof error === "undefined") {
resultFuture.return(futureLocal);
- } else if (futuresLeft == 0) {
+ } else if (futuresLeft === 0) {
resultFuture.throw(new Error("None of the futures succeeded."));
}
}
@@ -378,14 +384,14 @@ class PacketStream extends stream.Transform {
while (packet.length > 0) {
if (!this.buffer) {
// read length
- var length = packet.readInt32BE(0);
+ let length = packet.readInt32BE(0);
this.buffer = new Buffer(length);
this.offset = 0;
packet = packet.slice(4);
}
packet.copy(this.buffer, this.offset);
- var copied = Math.min(this.buffer.length - this.offset, packet.length);
+ let copied = Math.min(this.buffer.length - this.offset, packet.length);
this.offset += copied;
packet = packet.slice(copied);
@@ -396,4 +402,4 @@ class PacketStream extends stream.Transform {
}
done();
}
-}
\ No newline at end of file
+}
diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts
index 2265d7033c..1d298629c7 100644
--- a/lib/services/ios-project-service.ts
+++ b/lib/services/ios-project-service.ts
@@ -1,15 +1,14 @@
///
"use strict";
-import Future = require("fibers/future");
import * as path from "path";
import * as shell from "shelljs";
import * as util from "util";
import * as os from "os";
import * as xcode from "xcode";
-import constants = require("./../constants");
-import helpers = require("./../common/helpers");
-import projectServiceBaseLib = require("./platform-project-service-base");
+import * as constants from "../constants";
+import * as helpers from "../common/helpers";
+import * as projectServiceBaseLib from "./platform-project-service-base";
export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServiceBase implements IPlatformProjectService {
private static XCODE_PROJECT_EXT_NAME = ".xcodeproj";
@@ -34,7 +33,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
}
public get platformData(): IPlatformData {
- var projectRoot = path.join(this.$projectData.platformsDir, "ios");
+ let projectRoot = path.join(this.$projectData.platformsDir, "ios");
return {
frameworkPackageName: "tns-ios",
@@ -70,8 +69,8 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
this.$errors.fail("Xcode is not installed. Make sure you have Xcode installed and added to your PATH");
}
- var xcodeBuildVersion = this.$childProcess.exec("xcodebuild -version | head -n 1 | sed -e 's/Xcode //'").wait();
- var splitedXcodeBuildVersion = xcodeBuildVersion.split(".");
+ let xcodeBuildVersion = this.$childProcess.exec("xcodebuild -version | head -n 1 | sed -e 's/Xcode //'").wait();
+ let splitedXcodeBuildVersion = xcodeBuildVersion.split(".");
if(splitedXcodeBuildVersion.length === 3) {
xcodeBuildVersion = util.format("%s.%s", splitedXcodeBuildVersion[0], splitedXcodeBuildVersion[1]);
}
@@ -87,13 +86,13 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
return (() => {
if(this.$options.symlink) {
this.$fs.ensureDirectoryExists(path.join(projectRoot, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER)).wait();
- var xcodeProjectName = util.format("%s.xcodeproj", IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER);
+ let xcodeProjectName = util.format("%s.xcodeproj", IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER);
shell.cp("-R", path.join(frameworkDir, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER, "*"), path.join(projectRoot, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER));
shell.cp("-R", path.join(frameworkDir, xcodeProjectName), projectRoot);
- var directoryContent = this.$fs.readDirectory(frameworkDir).wait();
- var frameworkFiles = _.difference(directoryContent, [IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER, xcodeProjectName]);
+ let directoryContent = this.$fs.readDirectory(frameworkDir).wait();
+ let frameworkFiles = _.difference(directoryContent, [IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER, xcodeProjectName]);
_.each(frameworkFiles, (file: string) => {
this.$fs.symlink(path.join(frameworkDir, file), path.join(projectRoot, file)).wait();
});
@@ -106,17 +105,17 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
public interpolateData(projectRoot: string): IFuture {
return (() => {
- var infoPlistFilePath = path.join(projectRoot, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER, util.format("%s-%s", IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER, "Info.plist"));
+ let infoPlistFilePath = path.join(projectRoot, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER, util.format("%s-%s", IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER, "Info.plist"));
shell.sed('-i', "__CFBUNDLEIDENTIFIER__", this.$projectData.projectId, infoPlistFilePath);
this.replaceFileName("-Info.plist", path.join(projectRoot, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER)).wait();
this.replaceFileName("-Prefix.pch", path.join(projectRoot, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER)).wait();
this.replaceFileName(IOSProjectService.XCODE_PROJECT_EXT_NAME, projectRoot).wait();
- var pbxprojFilePath = path.join(projectRoot, this.$projectData.projectName + IOSProjectService.XCODE_PROJECT_EXT_NAME, "project.pbxproj");
+ let pbxprojFilePath = path.join(projectRoot, this.$projectData.projectName + IOSProjectService.XCODE_PROJECT_EXT_NAME, "project.pbxproj");
this.replaceFileContent(pbxprojFilePath).wait();
- var mainFilePath = path.join(projectRoot, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER, "main.m");
+ let mainFilePath = path.join(projectRoot, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER, "main.m");
this.replaceFileContent(mainFilePath).wait();
}).future()();
}
@@ -166,10 +165,10 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
this.$childProcess.spawnFromEvent("xcodebuild", args, "exit", {cwd: this.$options, stdio: 'inherit'}).wait();
if(this.$options.forDevice) {
- var buildOutputPath = path.join(projectRoot, "build", "device");
+ let buildOutputPath = path.join(projectRoot, "build", "device");
// Produce ipa file
- var xcrunArgs = [
+ let xcrunArgs = [
"-sdk", "iphoneos",
"PackageApplication",
"-v", path.join(buildOutputPath, this.$projectData.projectName + ".app"),
@@ -188,9 +187,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
public addLibrary(libraryPath: string): IFuture {
return (() => {
this.validateDynamicFramework(libraryPath).wait();
- var umbrellaHeader = this.getUmbrellaHeaderFromDynamicFramework(libraryPath).wait();
- let frameworkName = path.basename(libraryPath, path.extname(libraryPath));
let targetPath = path.join("lib", this.platformData.normalizedPlatformName);
let fullTargetPath = path.join(this.$projectData.projectDir, targetPath);
this.$fs.ensureDirectoryExists(fullTargetPath).wait();
@@ -207,11 +204,11 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
public canUpdatePlatform(currentVersion: string, newVersion: string): IFuture {
return (() => {
- var currentXcodeProjectFile = this.buildPathToXcodeProjectFile(currentVersion);
- var currentXcodeProjectFileContent = this.$fs.readFile(currentXcodeProjectFile).wait();
+ let currentXcodeProjectFile = this.buildPathToXcodeProjectFile(currentVersion);
+ let currentXcodeProjectFileContent = this.$fs.readFile(currentXcodeProjectFile).wait();
- var newXcodeProjectFile = this.buildPathToXcodeProjectFile(newVersion);
- var newXcodeProjectFileContent = this.$fs.readFile(newXcodeProjectFile).wait();
+ let newXcodeProjectFile = this.buildPathToXcodeProjectFile(newVersion);
+ let newXcodeProjectFileContent = this.$fs.readFile(newXcodeProjectFile).wait();
return currentXcodeProjectFileContent === newXcodeProjectFileContent;
@@ -221,19 +218,19 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
public updatePlatform(currentVersion: string, newVersion: string): IFuture {
return (() => {
// Copy old file to options["profile-dir"]
- var sourceFile = path.join(this.platformData.projectRoot, util.format("%s.xcodeproj", this.$projectData.projectName));
- var destinationFile = path.join(this.$options.profileDir, "xcodeproj");
+ let sourceFile = path.join(this.platformData.projectRoot, util.format("%s.xcodeproj", this.$projectData.projectName));
+ let destinationFile = path.join(this.$options.profileDir, "xcodeproj");
this.$fs.deleteDirectory(destinationFile).wait();
shell.cp("-R", path.join(sourceFile, "*"), destinationFile);
this.$logger.info("Backup file %s at location %s", sourceFile, destinationFile);
this.$fs.deleteDirectory(path.join(this.platformData.projectRoot, util.format("%s.xcodeproj", this.$projectData.projectName))).wait();
// Copy xcodeProject file
- var cachedPackagePath = path.join(this.$npmInstallationManager.getCachedPackagePath(this.platformData.frameworkPackageName, newVersion), constants.PROJECT_FRAMEWORK_FOLDER_NAME, util.format("%s.xcodeproj", IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER));
+ let cachedPackagePath = path.join(this.$npmInstallationManager.getCachedPackagePath(this.platformData.frameworkPackageName, newVersion), constants.PROJECT_FRAMEWORK_FOLDER_NAME, util.format("%s.xcodeproj", IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER));
shell.cp("-R", path.join(cachedPackagePath, "*"), path.join(this.platformData.projectRoot, util.format("%s.xcodeproj", this.$projectData.projectName)));
this.$logger.info("Copied from %s at %s.", cachedPackagePath, this.platformData.projectRoot);
- var pbxprojFilePath = path.join(this.platformData.projectRoot, this.$projectData.projectName + IOSProjectService.XCODE_PROJECT_EXT_NAME, "project.pbxproj");
+ let pbxprojFilePath = path.join(this.platformData.projectRoot, this.$projectData.projectName + IOSProjectService.XCODE_PROJECT_EXT_NAME, "project.pbxproj");
this.replaceFileContent(pbxprojFilePath).wait();
}).future()();
}
@@ -357,48 +354,30 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
private validateDynamicFramework(libraryPath: string): IFuture {
return (() => {
- var infoPlistPath = path.join(libraryPath, "Info.plist");
+ let infoPlistPath = path.join(libraryPath, "Info.plist");
if (!this.$fs.exists(infoPlistPath).wait()) {
this.$errors.failWithoutHelp("The bundle at %s does not contain an Info.plist file.", libraryPath);
}
- var packageType = this.$childProcess.exec(`/usr/libexec/PlistBuddy -c "Print :CFBundlePackageType" "${infoPlistPath}"`).wait().trim();
+ let packageType = this.$childProcess.exec(`/usr/libexec/PlistBuddy -c "Print :CFBundlePackageType" "${infoPlistPath}"`).wait().trim();
if (packageType !== "FMWK") {
this.$errors.failWithoutHelp("The bundle at %s does not appear to be a dynamic framework.", libraryPath);
}
}).future()();
}
- private getUmbrellaHeaderFromDynamicFramework(libraryPath: string): IFuture {
- return (() => {
- var modulemapPath = path.join(libraryPath, "Modules", "module.modulemap");
- if (!this.$fs.exists(modulemapPath).wait()) {
- this.$errors.failWithoutHelp("The framework at %s does not contain a module.modulemap file.", modulemapPath);
- }
-
- var modulemap = this.$fs.readText(modulemapPath).wait();
- var umbrellaRegex = /umbrella header "(.+\.h)"/g;
- var match = umbrellaRegex.exec(modulemap);
- if (!match) {
- this.$errors.failWithoutHelp("The modulemap at %s does not specify an umbrella header.", modulemapPath);
- }
-
- return match[1];
- }).future()();
- }
-
private replaceFileContent(file: string): IFuture {
return (() => {
- var fileContent = this.$fs.readText(file).wait();
- var replacedContent = helpers.stringReplaceAll(fileContent, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER, this.$projectData.projectName);
+ let fileContent = this.$fs.readText(file).wait();
+ let replacedContent = helpers.stringReplaceAll(fileContent, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER, this.$projectData.projectName);
this.$fs.writeFile(file, replacedContent).wait();
}).future()();
}
private replaceFileName(fileNamePart: string, fileRootLocation: string): IFuture {
return (() => {
- var oldFileName = IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER + fileNamePart;
- var newFileName = this.$projectData.projectName + fileNamePart;
+ let oldFileName = IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER + fileNamePart;
+ let newFileName = this.$projectData.projectName + fileNamePart;
this.$fs.rename(path.join(fileRootLocation, oldFileName), path.join(fileRootLocation, newFileName)).wait();
}).future()();
@@ -428,7 +407,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
_.each(this.getAllDynamicFrameworksForPlugin(pluginData).wait(), fileName => {
let fullFrameworkPath = path.join(pluginPlatformsFolderPath, fileName);
let relativeFrameworkPath = this.getFrameworkRelativePath(fullFrameworkPath);
- project.removeFramework(relativeFrameworkPath, { customFramework: true, embed: true })
+ project.removeFramework(relativeFrameworkPath, { customFramework: true, embed: true });
});
this.savePbxProj(project).wait();
diff --git a/lib/services/platform-project-service-base.ts b/lib/services/platform-project-service-base.ts
index 008d82550a..550c13ebd9 100644
--- a/lib/services/platform-project-service-base.ts
+++ b/lib/services/platform-project-service-base.ts
@@ -1,6 +1,5 @@
///
"use strict";
-import path = require("path");
export class PlatformProjectServiceBase implements IPlatformProjectServiceBase {
constructor(protected $fs: IFileSystem) { }
@@ -9,7 +8,7 @@ export class PlatformProjectServiceBase implements IPlatformProjectServiceBase {
return pluginData.pluginPlatformsFolderPath(platform);
}
- public getAllNativeLibrariesForPlugin(pluginData: IPluginData, platform: string, filter: (fileName: string, pluginPlatformsFolderPath: string) => boolean): IFuture {
+ public getAllNativeLibrariesForPlugin(pluginData: IPluginData, platform: string, filter: (fileName: string, _pluginPlatformsFolderPath: string) => boolean): IFuture {
return (() => {
let pluginPlatformsFolderPath = this.getPluginPlatformsFolderPath(pluginData, platform),
nativeLibraries: string[] = [];
@@ -23,4 +22,4 @@ export class PlatformProjectServiceBase implements IPlatformProjectServiceBase {
return nativeLibraries;
}).future()();
}
-}
\ No newline at end of file
+}
diff --git a/lib/services/platform-service.ts b/lib/services/platform-service.ts
index 237d8e2de9..83c9661648 100644
--- a/lib/services/platform-service.ts
+++ b/lib/services/platform-service.ts
@@ -6,7 +6,6 @@ import * as shell from "shelljs";
import * as constants from "../constants";
import * as helpers from "../common/helpers";
import * as semver from "semver";
-import Future = require("fibers/future");
export class PlatformService implements IPlatformService {
private static TNS_MODULES_FOLDER_NAME = "tns_modules";
@@ -305,7 +304,7 @@ export class PlatformService implements IPlatformService {
public validatePlatform(platform: string): void {
if(!platform) {
- this.$errors.fail("No platform specified.")
+ this.$errors.fail("No platform specified.");
}
platform = platform.split("@")[0].toLowerCase();
@@ -500,7 +499,7 @@ export class PlatformService implements IPlatformService {
return {
frameworkFiles: this.mapFrameworkFiles(cachedPackagePath, filteredFiles),
frameworkDirectories: this.mapFrameworkFiles(cachedPackagePath, filteredFrameworkDirectories)
- }
+ };
}).future()();
}
@@ -517,7 +516,7 @@ export class PlatformService implements IPlatformService {
}
private mapFrameworkFiles(npmCacheDirectoryPath: string, files: string[]): string[] {
- return _.map(files, file => file.substr(npmCacheDirectoryPath.length + constants.PROJECT_FRAMEWORK_FOLDER_NAME.length + 1))
+ return _.map(files, file => file.substr(npmCacheDirectoryPath.length + constants.PROJECT_FRAMEWORK_FOLDER_NAME.length + 1));
}
}
$injector.register("platformService", PlatformService);
diff --git a/lib/services/plugins-service.ts b/lib/services/plugins-service.ts
index 9838dbb095..a2a19aed7b 100644
--- a/lib/services/plugins-service.ts
+++ b/lib/services/plugins-service.ts
@@ -4,7 +4,7 @@ import * as path from "path";
import * as shelljs from "shelljs";
import * as semver from "semver";
import Future = require("fibers/future");
-import constants = require("./../constants");
+import * as constants from "../constants";
let xmlmerge = require("xmlmerge-js");
let DOMParser = require('xmldom').DOMParser;
@@ -28,10 +28,10 @@ export class PluginsService implements IPluginsService {
public add(plugin: string): IFuture {
return (() => {
- let dependencies = this.getAllInstalledModules().wait();
+ this.ensure().wait();
let dependencyData = this.$npm.cache(plugin, undefined, PluginsService.NPM_CONFIG).wait();
if(dependencyData.nativescript) {
- let pluginName = this.executeNpmCommand(PluginsService.INSTALL_COMMAND_NAME, plugin).wait();
+ this.executeNpmCommand(PluginsService.INSTALL_COMMAND_NAME, plugin).wait();
this.prepare(dependencyData).wait();
this.$logger.out(`Successfully installed plugin ${dependencyData.name}.`);
} else {
@@ -114,7 +114,7 @@ export class PluginsService implements IPluginsService {
this.$projectFilesManager.processPlatformSpecificFiles(pluginDestinationPath, platform).wait();
- pluginData.pluginPlatformsFolderPath = (platform: string) => path.join(pluginData.fullPath, "platforms", platform);
+ pluginData.pluginPlatformsFolderPath = (_platform: string) => path.join(pluginData.fullPath, "platforms", _platform);
platformData.platformProjectService.preparePluginNativeCode(pluginData).wait();
shelljs.rm("-rf", path.join(pluginDestinationPath, pluginData.name, "platforms"));
@@ -202,10 +202,16 @@ export class PluginsService implements IPluginsService {
return pluginData;
}
- private getAllInstalledModules(): IFuture {
+ private ensure(): IFuture {
return (() => {
this.ensureAllDependenciesAreInstalled().wait();
this.$fs.ensureDirectoryExists(this.nodeModulesPath).wait();
+ }).future()();
+ }
+
+ private getAllInstalledModules(): IFuture {
+ return (() => {
+ this.ensure().wait();
let nodeModules = this.getDependencies();
return _.map(nodeModules, nodeModuleName => this.getNodeModuleData(nodeModuleName).wait());
@@ -230,7 +236,7 @@ export class PluginsService implements IPluginsService {
return npmCommandResult[0][0].split("@")[0]; // returns plugin name
}
- private executeForAllInstalledPlatforms(action: (pluginDestinationPath: string, pl: string, platformData: IPlatformData) => IFuture): IFuture {
+ private executeForAllInstalledPlatforms(action: (_pluginDestinationPath: string, pl: string, _platformData: IPlatformData) => IFuture): IFuture {
return (() => {
let availablePlatforms = _.keys(this.$platformsData.availablePlatforms);
_.each(availablePlatforms, platform => {
@@ -272,10 +278,10 @@ export class PluginsService implements IPluginsService {
locator: {},
errorHandler: (level: any, msg: string) => {
let errorMessage = xmlFilePath ? `Invalid xml file ${xmlFilePath}.` : `Invalid xml ${xml}.`;
- this.$errors.fail(errorMessage + ` Additional technical information: ${msg}.` )
+ this.$errors.fail(errorMessage + ` Additional technical information: ${msg}.` );
}
});
doc.parseFromString(xml, 'text/xml');
}
}
-$injector.register("pluginsService", PluginsService);
\ No newline at end of file
+$injector.register("pluginsService", PluginsService);
diff --git a/lib/services/project-data-service.ts b/lib/services/project-data-service.ts
index f369f15b71..7f7bfa2122 100644
--- a/lib/services/project-data-service.ts
+++ b/lib/services/project-data-service.ts
@@ -1,9 +1,8 @@
///
"use strict";
-import constants = require("./../constants");
-import path = require("path");
-import assert = require("assert");
+import * as path from "path";
+import * as assert from "assert";
export class ProjectDataService implements IProjectDataService {
private projectFilePath: string;
@@ -61,4 +60,4 @@ export class ProjectDataService implements IProjectDataService {
}).future()();
}
}
-$injector.register("projectDataService", ProjectDataService);
\ No newline at end of file
+$injector.register("projectDataService", ProjectDataService);
diff --git a/lib/services/project-files-manager.ts b/lib/services/project-files-manager.ts
index 40be8f4336..4efcaa99ee 100644
--- a/lib/services/project-files-manager.ts
+++ b/lib/services/project-files-manager.ts
@@ -9,8 +9,8 @@ export class ProjectFilesManager implements IProjectFilesManager {
public processPlatformSpecificFiles(directoryPath: string, platform: string, excludedDirs?: string[]): IFuture {
return (() => {
- var contents = this.$fs.readDirectory(directoryPath).wait();
- var files: string[] = [];
+ let contents = this.$fs.readDirectory(directoryPath).wait();
+ let files: string[] = [];
_.each(contents, fileName => {
let filePath = path.join(directoryPath, fileName);
@@ -30,8 +30,8 @@ export class ProjectFilesManager implements IProjectFilesManager {
// Renames the files that have `platform` as substring and removes the files from other platform
return (() => {
_.each(files, fileName => {
- var platformInfo = ProjectFilesManager.parsePlatformSpecificFileName(path.basename(fileName), this.$platformsData.platformsNames);
- var shouldExcludeFile = platformInfo && platformInfo.platform !== platform;
+ let platformInfo = ProjectFilesManager.parsePlatformSpecificFileName(path.basename(fileName), this.$platformsData.platformsNames);
+ let shouldExcludeFile = platformInfo && platformInfo.platform !== platform;
if (shouldExcludeFile) {
this.$fs.deleteFile(fileName).wait();
} else if (platformInfo && platformInfo.onDeviceName) {
@@ -42,8 +42,8 @@ export class ProjectFilesManager implements IProjectFilesManager {
}
private static parsePlatformSpecificFileName(fileName: string, platforms: string[]): any {
- var regex = util.format("^(.+?)\\.(%s)(\\..+?)$", platforms.join("|"));
- var parsed = fileName.match(new RegExp(regex, "i"));
+ let regex = util.format("^(.+?)\\.(%s)(\\..+?)$", platforms.join("|"));
+ let parsed = fileName.match(new RegExp(regex, "i"));
if (parsed) {
return {
platform: parsed[2],
diff --git a/lib/services/project-service.ts b/lib/services/project-service.ts
index a8f86d6abf..a65c52743c 100644
--- a/lib/services/project-service.ts
+++ b/lib/services/project-service.ts
@@ -1,12 +1,10 @@
///
"use strict";
-import constants = require("./../constants");
-import helpers = require("../common/helpers");
-import osenv = require("osenv");
-import path = require("path");
-import shell = require("shelljs");
-import util = require("util");
+import constants = require("../constants");
+import * as osenv from "osenv";
+import * as path from "path";
+import * as shell from "shelljs";
export class ProjectService implements IProjectService {
@@ -27,12 +25,12 @@ export class ProjectService implements IProjectService {
}
this.$projectNameValidator.validate(projectName);
- var projectId = this.$options.appid || this.$projectHelper.generateDefaultAppId(projectName, constants.DEFAULT_APP_IDENTIFIER_PREFIX);
+ let projectId = this.$options.appid || this.$projectHelper.generateDefaultAppId(projectName, constants.DEFAULT_APP_IDENTIFIER_PREFIX);
- var projectDir = path.join(path.resolve(this.$options.path || "."), projectName);
+ let projectDir = path.join(path.resolve(this.$options.path || "."), projectName);
this.$fs.createDirectory(projectDir).wait();
- var customAppPath = this.getCustomAppPath();
+ let customAppPath = this.getCustomAppPath();
if(customAppPath) {
customAppPath = path.resolve(customAppPath);
if(!this.$fs.exists(customAppPath).wait()) {
@@ -51,18 +49,18 @@ export class ProjectService implements IProjectService {
this.$logger.trace("Creating a new NativeScript project with name %s and id %s at location %s", projectName, projectId, projectDir);
- var appDirectory = path.join(projectDir, constants.APP_FOLDER_NAME);
- var appPath: string = null;
+ let appDirectory = path.join(projectDir, constants.APP_FOLDER_NAME);
+ let appPath: string = null;
if (customAppPath) {
this.$logger.trace("Using custom app from %s", customAppPath);
// Make sure that the source app/ is not a direct ancestor of a target app/
- var relativePathFromSourceToTarget = path.relative(customAppPath, appDirectory);
+ let relativePathFromSourceToTarget = path.relative(customAppPath, appDirectory);
// path.relative returns second argument if the paths are located on different disks
// so in this case we don't need to make the check for direct ancestor
if (relativePathFromSourceToTarget !== appDirectory) {
- var doesRelativePathGoUpAtLeastOneDir = relativePathFromSourceToTarget.split(path.sep)[0] === "..";
+ let doesRelativePathGoUpAtLeastOneDir = relativePathFromSourceToTarget.split(path.sep)[0] === "..";
if (!doesRelativePathGoUpAtLeastOneDir) {
this.$errors.fail("Project dir %s must not be created at/inside the template used to create the project %s.", projectDir, customAppPath);
}
@@ -72,7 +70,7 @@ export class ProjectService implements IProjectService {
} else {
// No custom app - use nativescript hello world application
this.$logger.trace("Using NativeScript hello world application");
- var defaultTemplatePath = this.$projectTemplatesService.defaultTemplatePath.wait();
+ let defaultTemplatePath = this.$projectTemplatesService.defaultTemplatePath.wait();
this.$logger.trace("Copying NativeScript hello world application into %s", appDirectory);
appPath = defaultTemplatePath;
}
@@ -93,7 +91,7 @@ export class ProjectService implements IProjectService {
return (() => {
this.$fs.ensureDirectoryExists(projectDir).wait();
- var appDestinationPath = path.join(projectDir, constants.APP_FOLDER_NAME);
+ let appDestinationPath = path.join(projectDir, constants.APP_FOLDER_NAME);
this.$fs.createDirectory(appDestinationPath).wait();
if(this.$options.symlink) {
@@ -124,7 +122,7 @@ export class ProjectService implements IProjectService {
}
private getCustomAppPath(): string {
- var customAppPath = this.$options.copyFrom || this.$options.linkTo;
+ let customAppPath = this.$options.copyFrom || this.$options.linkTo;
if(customAppPath) {
if(customAppPath.indexOf("http://") === 0) {
this.$errors.fail("Only local paths for custom app are supported.");
@@ -139,4 +137,3 @@ export class ProjectService implements IProjectService {
}
}
$injector.register("projectService", ProjectService);
-
diff --git a/lib/services/project-templates-service.ts b/lib/services/project-templates-service.ts
index 99728efc96..7d3d11d566 100644
--- a/lib/services/project-templates-service.ts
+++ b/lib/services/project-templates-service.ts
@@ -1,13 +1,6 @@
///
"use strict";
-import util = require("util");
-import path = require("path");
-import shell = require("shelljs");
-import npm = require("npm");
-var helpers = require("../common/helpers");
-import Future = require("fibers/future");
-
export class ProjectTemplatesService implements IProjectTemplatesService {
private static NPM_DEFAULT_TEMPLATE_NAME = "tns-template-hello-world";
@@ -17,4 +10,4 @@ export class ProjectTemplatesService implements IProjectTemplatesService {
return this.$npmInstallationManager.install(ProjectTemplatesService.NPM_DEFAULT_TEMPLATE_NAME);
}
}
-$injector.register("projectTemplatesService", ProjectTemplatesService);
\ No newline at end of file
+$injector.register("projectTemplatesService", ProjectTemplatesService);
diff --git a/lib/services/usb-livesync-service.ts b/lib/services/usb-livesync-service.ts
index a7744ad269..b727116681 100644
--- a/lib/services/usb-livesync-service.ts
+++ b/lib/services/usb-livesync-service.ts
@@ -1,12 +1,11 @@
///
"use strict";
-import androidLiveSyncServiceLib = require("../common/mobile/android/android-livesync-service");
-import constants = require("../constants");
-import helpers = require("../common/helpers");
-import usbLivesyncServiceBaseLib = require("../common/services/usb-livesync-service-base");
-import path = require("path");
-import semver = require("semver");
+import * as androidLiveSyncServiceLib from "../common/mobile/android/android-livesync-service";
+import * as constants from "../constants";
+import * as usbLivesyncServiceBaseLib from "../common/services/usb-livesync-service-base";
+import * as path from "path";
+import * as semver from "semver";
import Future = require("fibers/future");
export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncServiceBase implements IUsbLiveSyncService {
@@ -62,15 +61,15 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
let restartAppOnDeviceAction = (device: Mobile.IDevice, deviceAppData: Mobile.IDeviceAppData, localToDevicePaths?: Mobile.ILocalToDevicePathData[]): IFuture => {
let platformSpecificUsbLiveSyncService = this.resolveUsbLiveSyncService(platform || this.$devicesServices.platform, device);
return platformSpecificUsbLiveSyncService.restartApplication(deviceAppData, localToDevicePaths);
- }
+ };
let notInstalledAppOnDeviceAction = (device: Mobile.IDevice): IFuture => {
return this.$platformService.deployOnDevice(platform);
- }
+ };
let notRunningiOSSimulatorAction = (): IFuture => {
return this.$platformService.deployOnEmulator(this.$devicePlatformsConstants.iOS.toLowerCase());
- }
+ };
let beforeLiveSyncAction = (device: Mobile.IDevice, deviceAppData: Mobile.IDeviceAppData): IFuture => {
let platformSpecificUsbLiveSyncService = this.resolveUsbLiveSyncService(platform || this.$devicesServices.platform, device);
@@ -78,18 +77,18 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
return platformSpecificUsbLiveSyncService.beforeLiveSyncAction(deviceAppData);
}
return Future.fromResult();
- }
+ };
let beforeBatchLiveSyncAction = (filePath: string): IFuture => {
return (() => {
this.$platformService.preparePlatform(platform).wait();
return path.join(projectFilesPath, path.relative(path.join(this.$projectData.projectDir, constants.APP_FOLDER_NAME), filePath));
}).future()();
- }
+ };
let iOSSimulatorRelativeToProjectBasePathAction = (projectFile: string): string => {
return path.join(constants.APP_FOLDER_NAME, path.dirname(projectFile.split(`/${constants.APP_FOLDER_NAME}/`)[1]));
- }
+ };
let watchGlob = path.join(this.$projectData.projectDir, constants.APP_FOLDER_NAME);
@@ -143,8 +142,6 @@ export class IOSUsbLiveSyncService implements IPlatformSpecificUsbLiveSyncServic
}
export class AndroidUsbLiveSyncService extends androidLiveSyncServiceLib.AndroidLiveSyncService implements IPlatformSpecificUsbLiveSyncService {
- private static LIVESYNC_COMMANDS_FILE_NAME = "nativescript.livesync.commands.sh";
-
constructor(_device: Mobile.IDevice,
$fs: IFileSystem,
$mobileHelper: Mobile.IMobileHelper,
diff --git a/lib/services/user-settings-service.ts b/lib/services/user-settings-service.ts
index f365171148..49aef050d8 100644
--- a/lib/services/user-settings-service.ts
+++ b/lib/services/user-settings-service.ts
@@ -7,8 +7,8 @@ import userSettingsServiceBaseLib = require("../common/services/user-settings-se
class UserSettingsService extends userSettingsServiceBaseLib.UserSettingsServiceBase {
constructor($fs: IFileSystem,
$options: IOptions) {
- var userSettingsFilePath = path.join($options.profileDir, "user-settings.json");
+ let userSettingsFilePath = path.join($options.profileDir, "user-settings.json");
super(userSettingsFilePath, $fs);
}
}
-$injector.register("userSettingsService", UserSettingsService);
\ No newline at end of file
+$injector.register("userSettingsService", UserSettingsService);
diff --git a/lib/tools/broccoli/broccoli-plugin-wrapper-factory.ts b/lib/tools/broccoli/broccoli-plugin-wrapper-factory.ts
index 3fac2939d3..af2a3ef40b 100644
--- a/lib/tools/broccoli/broccoli-plugin-wrapper-factory.ts
+++ b/lib/tools/broccoli/broccoli-plugin-wrapper-factory.ts
@@ -17,4 +17,4 @@ type BroccoliPluginWrapperFactory = (inputTree: BroccoliTree, ...options: any[])
export function wrapBroccoliPlugin(pluginClass: any): BroccoliPluginWrapperFactory {
return function() { return new broccoliPluginWrapperLib.BroccoliPluginWrapper(pluginClass, arguments); };
-}
\ No newline at end of file
+}
diff --git a/lib/tools/broccoli/broccoli-plugin-wrapper.ts b/lib/tools/broccoli/broccoli-plugin-wrapper.ts
index a49160690a..8373eef816 100644
--- a/lib/tools/broccoli/broccoli-plugin-wrapper.ts
+++ b/lib/tools/broccoli/broccoli-plugin-wrapper.ts
@@ -1,8 +1,6 @@
///
"use strict";
-import fs = require('fs');
-import path = require('path');
import {TreeDiffer} from './tree-differ';
export class BroccoliPluginWrapper implements BroccoliTree {
@@ -56,4 +54,4 @@ export class BroccoliPluginWrapper implements BroccoliTree {
this.wrappedPlugin.cleanup();
}
}
-}
\ No newline at end of file
+}
diff --git a/lib/tools/broccoli/builder.ts b/lib/tools/broccoli/builder.ts
index b21ef52e32..1736f57469 100644
--- a/lib/tools/broccoli/builder.ts
+++ b/lib/tools/broccoli/builder.ts
@@ -1,15 +1,13 @@
///
"use strict";
-let broccoli = require('broccoli');
-let path = require('path');
+import * as path from "path";
import Future = require("fibers/future");
-import {TreeDiffer} from './tree-differ';
-import destCopyLib = require('./node-modules-dest-copy');
+import destCopyLib = require("./node-modules-dest-copy");
-var gulp = require("gulp");
-var vinylFilterSince = require('vinyl-filter-since')
-var through = require("through2");
+let gulp = require("gulp");
+let vinylFilterSince = require("vinyl-filter-since");
+let through = require("through2");
export class Builder implements IBroccoliBuilder {
private nodeModules: any = {};
@@ -60,7 +58,7 @@ export class Builder implements IBroccoliBuilder {
let currentPreparedTnsModules = this.$fs.readDirectory(absoluteOutputPath).wait();
let tnsModulesInApp = this.$fs.readDirectory(path.join(projectDir, "app", "tns_modules")).wait();
let modulesToDelete = _.difference(currentPreparedTnsModules, tnsModulesInApp);
- _.each(modulesToDelete, moduleName => this.$fs.deleteDirectory(path.join(absoluteOutputPath, moduleName)).wait())
+ _.each(modulesToDelete, moduleName => this.$fs.deleteDirectory(path.join(absoluteOutputPath, moduleName)).wait());
}
if(!lastModifiedTime || isNodeModulesModified) {
@@ -83,34 +81,5 @@ export class Builder implements IBroccoliBuilder {
}).future()();
}
-
- private rebuildNodeModulesTree(outputPath: string, projectDir: string): IFuture {
- let nodeModulesBuilder = this.makeNodeModulesBuilder(outputPath, projectDir);
- return this.rebuild(nodeModulesBuilder);
- }
-
- private makeNodeModulesBuilder(outputPath: string, projectDir: string): BroccoliBuilder {
- let tree = this.$nodeModulesTree.makeNodeModulesTree(outputPath, projectDir);
- return new broccoli.Builder(tree);
- }
-
- private rebuild(builder: any): IFuture {
- let future = new Future();
- builder.build()
- .then((result: any) => {
- future.return(result);
- })
- .catch((err: any) => {
- if(err.file) {
- this.$logger.error("File: " + err.file);
- }
- if(err.stack) {
- this.$logger.error(err.stack);
- }
- future.throw(err);
- });
-
- return future;
- }
}
$injector.register("broccoliBuilder", Builder);
diff --git a/lib/tools/broccoli/node-modules-dest-copy.ts b/lib/tools/broccoli/node-modules-dest-copy.ts
index f34f3bc429..dec415f028 100644
--- a/lib/tools/broccoli/node-modules-dest-copy.ts
+++ b/lib/tools/broccoli/node-modules-dest-copy.ts
@@ -2,12 +2,11 @@
"use strict";
import fs = require("fs");
-import path = require('path');
+import * as path from "path";
import semver = require("semver");
-import util = require("util");
import shelljs = require("shelljs");
import {wrapBroccoliPlugin} from './broccoli-plugin-wrapper-factory';
-import constants = require("./../../constants");
+import constants = require("../../constants");
/**
* Intercepts each directory as it is copied to the destination tempdir,
@@ -114,7 +113,7 @@ export class DestCopy implements IBroccoliPlugin {
foundFiles.push(packageJsonFilePath);
}
- var directoryPath = path.join(nodeModulesDirectoryPath, contents[i], constants.NODE_MODULES_FOLDER_NAME);
+ let directoryPath = path.join(nodeModulesDirectoryPath, contents[i], constants.NODE_MODULES_FOLDER_NAME);
if (fs.existsSync(directoryPath)) {
this.enumeratePackageJsonFilesSync(directoryPath, foundFiles);
}
diff --git a/lib/tools/broccoli/tree-differ.ts b/lib/tools/broccoli/tree-differ.ts
index 934161cbe1..18dfedf3da 100644
--- a/lib/tools/broccoli/tree-differ.ts
+++ b/lib/tools/broccoli/tree-differ.ts
@@ -1,8 +1,8 @@
///
"use strict";
-import fs = require('fs');
-import path = require('path');
+import * as fs from "fs";
+import * as path from "path";
export class TreeDiffer {
private rootDirName: string;
@@ -33,4 +33,4 @@ export class TreeDiffer {
class DirtyCheckingDiffResult implements IDiffResult {
public changedDirectories: string[] = [];
public removedDirectories: string[] = [];
-}
\ No newline at end of file
+}
diff --git a/lib/tools/broccoli/trees/node-modules-tree.ts b/lib/tools/broccoli/trees/node-modules-tree.ts
index 213e8e2c00..a03f3f465c 100644
--- a/lib/tools/broccoli/trees/node-modules-tree.ts
+++ b/lib/tools/broccoli/trees/node-modules-tree.ts
@@ -1,10 +1,9 @@
///
"use strict";
-let Funnel = require('broccoli-funnel');
+let Funnel = require("broccoli-funnel");
-import path = require("path");
-import destCopy from '../node-modules-dest-copy';
+import destCopy from "../node-modules-dest-copy";
export class NodeModulesTree implements INodeModulesTree {
public makeNodeModulesTree(absoluteOutputPath: string, projectDir: string): any {
@@ -13,4 +12,4 @@ export class NodeModulesTree implements INodeModulesTree {
return result;
}
}
-$injector.register("nodeModulesTree", NodeModulesTree);
\ No newline at end of file
+$injector.register("nodeModulesTree", NodeModulesTree);
diff --git a/package.json b/package.json
index d2ea933c9f..d777d4e1b5 100644
--- a/package.json
+++ b/package.json
@@ -87,9 +87,11 @@
"grunt-contrib-watch": "0.6.1",
"grunt-shell": "1.1.2",
"grunt-ts": "4.2.0",
+ "grunt-tslint": "2.4.0",
"mocha": "2.2.5",
"mocha-fibers": "https://github.com/Icenium/mocha-fibers/tarball/master",
"should": "7.0.2",
+ "tslint": "2.4.2",
"typescript": "1.5.3"
},
"license": "Apache-2.0",
diff --git a/test/android-project-properties-manager.ts b/test/android-project-properties-manager.ts
index 22e262e5b7..5539df7680 100644
--- a/test/android-project-properties-manager.ts
+++ b/test/android-project-properties-manager.ts
@@ -1,24 +1,20 @@
///
"use strict";
-import ProjectPropertiesParserLib = require("../lib/common/properties-parser");
-import FsLib = require("../lib/common/file-system");
-import ProjectPropertiesManagerLib = require("../lib/services/android-project-properties-manager");
-import HostInfoLib = require("../lib/common/host-info");
-import StaticConfigLib = require("../lib/config");
-import ErrorsLib = require("../lib/common/errors");
-import LoggerLib = require("../lib/common/logger");
-import ConfigLib = require("../lib/config");
-import OptionsLib = require("../lib/options");
+import * as ProjectPropertiesParserLib from "../lib/common/properties-parser";
+import * as FsLib from "../lib/common/file-system";
+import * as ProjectPropertiesManagerLib from "../lib/services/android-project-properties-manager";
+import * as HostInfoLib from "../lib/common/host-info";
+import * as StaticConfigLib from "../lib/config";
+import * as ErrorsLib from "../lib/common/errors";
+import * as LoggerLib from "../lib/common/logger";
+import * as ConfigLib from "../lib/config";
+import * as OptionsLib from "../lib/options";
import yok = require("../lib/common/yok");
-
-import os = require("os");
-import path = require("path");
-
+import * as path from "path";
import temp = require("temp");
temp.track();
-
-let assert = require("chai").assert;
+import {assert} from "chai";
function createTestInjector(): IInjector {
let testInjector = new yok.Yok();
@@ -141,4 +137,4 @@ describe("Android project properties parser tests", () => {
assert.equal(expectedContent, actualContent);
assert.equal(4, _.keys(projectPropertiesManager.getProjectReferences().wait()).length);
});
-});
\ No newline at end of file
+});
diff --git a/test/ios-project-service.ts b/test/ios-project-service.ts
index e5f6b8090e..a9cee4b7d8 100644
--- a/test/ios-project-service.ts
+++ b/test/ios-project-service.ts
@@ -14,7 +14,6 @@ import HostInfoLib = require("../lib/common/host-info");
import iOSProjectServiceLib = require("../lib/services/ios-project-service");
import LoggerLib = require("../lib/common/logger");
import OptionsLib = require("../lib/options");
-import ProjectDataLib = require("../lib/project-data");
import yok = require("../lib/common/yok");
@@ -43,107 +42,111 @@ function createTestInjector(projectPath: string, projectName: string): IInjector
}
describe("Cocoapods support", () => {
- it("adds plugin with Podfile", () => {
- let projectName = "projectDirectory";
- let projectPath = temp.mkdirSync(projectName);
-
- let testInjector = createTestInjector(projectPath, projectName);
- let fs: IFileSystem = testInjector.resolve("fs");
-
- let packageJsonData = {
- "name": "myProject",
- "version": "0.1.0",
- "nativescript": {
- "id": "org.nativescript.myProject",
- "tns-android": {
- "version": "1.0.0"
+ if (require("os").platform !== "darwin") {
+ console.log("Skipping Cocoapods tests. They cannot work on windows");
+ } else {
+ it("adds plugin with Podfile", () => {
+ let projectName = "projectDirectory";
+ let projectPath = temp.mkdirSync(projectName);
+
+ let testInjector = createTestInjector(projectPath, projectName);
+ let fs: IFileSystem = testInjector.resolve("fs");
+
+ let packageJsonData = {
+ "name": "myProject",
+ "version": "0.1.0",
+ "nativescript": {
+ "id": "org.nativescript.myProject",
+ "tns-android": {
+ "version": "1.0.0"
+ }
}
- }
- };
- fs.writeJson(path.join(projectPath, "package.json"), packageJsonData).wait();
-
- let platformsFolderPath = path.join(projectPath, "ios");
- fs.createDirectory(platformsFolderPath).wait();
-
- let iOSProjectService = testInjector.resolve("iOSProjectService");
- iOSProjectService.prepareDynamicFrameworks = (pluginPlatformsFolderPath: string, pluginData: IPluginData): IFuture => {
- return Future.fromResult();
- };
-
- let pluginPath = temp.mkdirSync("pluginDirectory");
- let pluginPlatformsFolderPath = path.join(pluginPath, "platforms", "ios");
- let pluginPodfilePath = path.join(pluginPlatformsFolderPath, "Podfile");
- let pluginPodfileContent = ["source 'https://github.com/CocoaPods/Specs.git'", "platform :ios, '8.1'", "pod 'GoogleMaps'"].join("\n");
- fs.writeFile(pluginPodfilePath, pluginPodfileContent).wait();
-
- let pluginData = {
- pluginPlatformsFolderPath(platform: string): string {
- return pluginPlatformsFolderPath;
- }
- };
-
- iOSProjectService.preparePluginNativeCode(pluginData).wait();
-
- let projectPodfilePath = path.join(platformsFolderPath, "Podfile");
- assert.isTrue(fs.exists(projectPodfilePath).wait());
-
- let actualProjectPodfileContent = fs.readText(projectPodfilePath).wait();
- let expectedProjectPodfileContent = [`# Begin Podfile - ${pluginPodfilePath} `, ` ${pluginPodfileContent} `, " # End Podfile \n"].join("\n");
- assert.equal(actualProjectPodfileContent, expectedProjectPodfileContent);
- });
- it("adds and removes plugin with Podfile", () => {
- let projectName = "projectDirectory2";
- let projectPath = temp.mkdirSync(projectName);
-
- let testInjector = createTestInjector(projectPath, projectName);
- let fs: IFileSystem = testInjector.resolve("fs");
-
- let packageJsonData = {
- "name": "myProject2",
- "version": "0.1.0",
- "nativescript": {
- "id": "org.nativescript.myProject2",
- "tns-android": {
- "version": "1.0.0"
+ };
+ fs.writeJson(path.join(projectPath, "package.json"), packageJsonData).wait();
+
+ let platformsFolderPath = path.join(projectPath, "ios");
+ fs.createDirectory(platformsFolderPath).wait();
+
+ let iOSProjectService = testInjector.resolve("iOSProjectService");
+ iOSProjectService.prepareDynamicFrameworks = (pluginPlatformsFolderPath: string, pluginData: IPluginData): IFuture => {
+ return Future.fromResult();
+ };
+
+ let pluginPath = temp.mkdirSync("pluginDirectory");
+ let pluginPlatformsFolderPath = path.join(pluginPath, "platforms", "ios");
+ let pluginPodfilePath = path.join(pluginPlatformsFolderPath, "Podfile");
+ let pluginPodfileContent = ["source 'https://github.com/CocoaPods/Specs.git'", "platform :ios, '8.1'", "pod 'GoogleMaps'"].join("\n");
+ fs.writeFile(pluginPodfilePath, pluginPodfileContent).wait();
+
+ let pluginData = {
+ pluginPlatformsFolderPath(platform: string): string {
+ return pluginPlatformsFolderPath;
}
- }
- };
- fs.writeJson(path.join(projectPath, "package.json"), packageJsonData).wait();
-
- let platformsFolderPath = path.join(projectPath, "ios");
- fs.createDirectory(platformsFolderPath).wait();
-
- let iOSProjectService = testInjector.resolve("iOSProjectService");
- iOSProjectService.prepareDynamicFrameworks = (pluginPlatformsFolderPath: string, pluginData: IPluginData): IFuture => {
- return Future.fromResult();
- };
- iOSProjectService.removeDynamicFrameworks = (pluginPlatformsFolderPath: string, pluginData: IPluginData): IFuture => {
- return Future.fromResult();
- }
-
- let pluginPath = temp.mkdirSync("pluginDirectory");
- let pluginPlatformsFolderPath = path.join(pluginPath, "platforms", "ios");
- let pluginPodfilePath = path.join(pluginPlatformsFolderPath, "Podfile");
- let pluginPodfileContent = ["source 'https://github.com/CocoaPods/Specs.git'", "platform :ios, '8.1'", "pod 'GoogleMaps'"].join("\n");
- fs.writeFile(pluginPodfilePath, pluginPodfileContent).wait();
-
- let pluginData = {
- pluginPlatformsFolderPath(platform: string): string {
- return pluginPlatformsFolderPath;
- }
- };
-
- iOSProjectService.preparePluginNativeCode(pluginData).wait();
-
- let projectPodfilePath = path.join(platformsFolderPath, "Podfile");
- assert.isTrue(fs.exists(projectPodfilePath).wait());
-
- let actualProjectPodfileContent = fs.readText(projectPodfilePath).wait();
- let expectedProjectPodfileContent = [`# Begin Podfile - ${pluginPodfilePath} `, ` ${pluginPodfileContent} `, " # End Podfile \n"].join("\n");
- assert.equal(actualProjectPodfileContent, expectedProjectPodfileContent);
-
- iOSProjectService.removePluginNativeCode(pluginData).wait();
-
- assert.isFalse(fs.exists(projectPodfilePath).wait());
- });
-});
\ No newline at end of file
+ };
+
+ iOSProjectService.preparePluginNativeCode(pluginData).wait();
+
+ let projectPodfilePath = path.join(platformsFolderPath, "Podfile");
+ assert.isTrue(fs.exists(projectPodfilePath).wait());
+
+ let actualProjectPodfileContent = fs.readText(projectPodfilePath).wait();
+ let expectedProjectPodfileContent = [`# Begin Podfile - ${pluginPodfilePath} `, ` ${pluginPodfileContent} `, " # End Podfile \n"].join("\n");
+ assert.equal(actualProjectPodfileContent, expectedProjectPodfileContent);
+ });
+ it("adds and removes plugin with Podfile", () => {
+ let projectName = "projectDirectory2";
+ let projectPath = temp.mkdirSync(projectName);
+
+ let testInjector = createTestInjector(projectPath, projectName);
+ let fs: IFileSystem = testInjector.resolve("fs");
+
+ let packageJsonData = {
+ "name": "myProject2",
+ "version": "0.1.0",
+ "nativescript": {
+ "id": "org.nativescript.myProject2",
+ "tns-android": {
+ "version": "1.0.0"
+ }
+ }
+ };
+ fs.writeJson(path.join(projectPath, "package.json"), packageJsonData).wait();
+
+ let platformsFolderPath = path.join(projectPath, "ios");
+ fs.createDirectory(platformsFolderPath).wait();
+
+ let iOSProjectService = testInjector.resolve("iOSProjectService");
+ iOSProjectService.prepareDynamicFrameworks = (pluginPlatformsFolderPath: string, pluginData: IPluginData): IFuture => {
+ return Future.fromResult();
+ };
+ iOSProjectService.removeDynamicFrameworks = (pluginPlatformsFolderPath: string, pluginData: IPluginData): IFuture => {
+ return Future.fromResult();
+ };
+
+ let pluginPath = temp.mkdirSync("pluginDirectory");
+ let pluginPlatformsFolderPath = path.join(pluginPath, "platforms", "ios");
+ let pluginPodfilePath = path.join(pluginPlatformsFolderPath, "Podfile");
+ let pluginPodfileContent = ["source 'https://github.com/CocoaPods/Specs.git'", "platform :ios, '8.1'", "pod 'GoogleMaps'"].join("\n");
+ fs.writeFile(pluginPodfilePath, pluginPodfileContent).wait();
+
+ let pluginData = {
+ pluginPlatformsFolderPath(platform: string): string {
+ return pluginPlatformsFolderPath;
+ }
+ };
+
+ iOSProjectService.preparePluginNativeCode(pluginData).wait();
+
+ let projectPodfilePath = path.join(platformsFolderPath, "Podfile");
+ assert.isTrue(fs.exists(projectPodfilePath).wait());
+
+ let actualProjectPodfileContent = fs.readText(projectPodfilePath).wait();
+ let expectedProjectPodfileContent = [`# Begin Podfile - ${pluginPodfilePath} `, ` ${pluginPodfileContent} `, " # End Podfile \n"].join("\n");
+ assert.equal(actualProjectPodfileContent, expectedProjectPodfileContent);
+
+ iOSProjectService.removePluginNativeCode(pluginData).wait();
+
+ assert.isFalse(fs.exists(projectPodfilePath).wait());
+ });
+ }
+});
diff --git a/test/npm-support.ts b/test/npm-support.ts
index 76d369f348..fe252eded8 100644
--- a/test/npm-support.ts
+++ b/test/npm-support.ts
@@ -58,7 +58,7 @@ function createTestInjector(): IInjector {
testInjector.register("childProcess", ChildProcessLib.ChildProcess);
testInjector.register("projectFilesManager", ProjectFilesManagerLib.ProjectFilesManager);
testInjector.register("commandsServiceProvider", {
- registerDynamicSubCommands: () => {}
+ registerDynamicSubCommands: () => { /* intentionally left blank */ }
});
return testInjector;
@@ -123,7 +123,7 @@ function setupProject(): IFuture {
prepareAppResources: () => Future.fromResult(),
afterPrepareAllPlugins: () => Future.fromResult()
}
- }
+ };
};
return {
@@ -237,4 +237,4 @@ describe("Flatten npm modules tests", () => {
assert.isFalse(fs.exists(path.join(tnsModulesFolderPath, dependency)).wait());
});
});
-});
\ No newline at end of file
+});
diff --git a/test/platform-commands.ts b/test/platform-commands.ts
index d45e9735db..611b059837 100644
--- a/test/platform-commands.ts
+++ b/test/platform-commands.ts
@@ -3,19 +3,18 @@
import yok = require('../lib/common/yok');
import stubs = require('./stubs');
-import PlatformAddCommandLib = require("../lib/commands/add-platform");
-import PlatformRemoveCommandLib = require("../lib/commands/remove-platform");
-import PlatformUpdateCommandLib = require("../lib/commands/update-platform");
-import PlatformServiceLib = require('../lib/services/platform-service');
-import StaticConfigLib = require("../lib/config");
-import CommandsServiceLib = require("../lib/common/services/commands-service");
-import optionsLib = require("../lib/options");
-import hostInfoLib = require("../lib/common/host-info");
-import ProjectFilesManagerLib = require("../lib/services/project-files-manager");
-import path = require("path");
-import Future = require("fibers/future");
-var assert = require("chai").assert;
-var isCommandExecuted = true;
+import * as PlatformAddCommandLib from "../lib/commands/add-platform";
+import * as PlatformRemoveCommandLib from "../lib/commands/remove-platform";
+import * as PlatformUpdateCommandLib from "../lib/commands/update-platform";
+import * as PlatformServiceLib from '../lib/services/platform-service';
+import * as StaticConfigLib from "../lib/config";
+import * as CommandsServiceLib from "../lib/common/services/commands-service";
+import * as optionsLib from "../lib/options";
+import * as hostInfoLib from "../lib/common/host-info";
+import * as ProjectFilesManagerLib from "../lib/services/project-files-manager";
+import {assert} from "chai";
+
+let isCommandExecuted = true;
class PlatformData implements IPlatformData {
frameworkPackageName = "tns-android";
@@ -43,13 +42,14 @@ class ErrorsNoFailStub implements IErrors {
beginCommand(action: () => IFuture, printHelpCommand: () => IFuture): IFuture {
return (() => {
+ let result = false;
try {
- var result = action().wait();
+ result = action().wait();
} catch(ex) {
- return false;
+ /* intentionally left blank */
}
- return result;
+ return result;
}).future()();
}
@@ -57,10 +57,10 @@ class ErrorsNoFailStub implements IErrors {
return action();
}
- verifyHeap(message: string): void { }
+ verifyHeap(message: string): void { /* intentionally left blank */ }
validateArgs(client: string, knownOpts: any, shorthands: any): any { return null; }
- validateYargsArguments(parsed: any, knownOpts: any, shorthands: any, clientName?: string): void { }
+ validateYargsArguments(parsed: any, knownOpts: any, shorthands: any, clientName?: string): void { /* intentionally left blank */ }
}
class PlatformsData implements IPlatformsData {
@@ -79,7 +79,7 @@ class PlatformsData implements IPlatformsData {
}
function createTestInjector() {
- var testInjector = new yok.Yok();
+ let testInjector = new yok.Yok();
testInjector.register("injector", testInjector);
testInjector.register("hooksService", stubs.HooksServiceStub);
@@ -100,15 +100,15 @@ function createTestInjector() {
testInjector.register("lockfile", { });
testInjector.register("resources", {});
testInjector.register("commandsServiceProvider", {
- registerDynamicSubCommands: () => {}
+ registerDynamicSubCommands: () => { /* intentionally left blank */ }
});
testInjector.register("commandsService", {
- tryExecuteCommand: () => {}
+ tryExecuteCommand: () => { /* intentionally left blank */ }
});
testInjector.register("options", optionsLib.Options);
testInjector.register("hostInfo", hostInfoLib.HostInfo);
testInjector.register("broccoliBuilder", {
- prepareNodeModulesFolder: () => {}
+ prepareNodeModulesFolder: () => { /* intentionally left blank */ }
});
testInjector.register("pluginsService", {
getAllInstalledPlugins: () => {
@@ -123,8 +123,8 @@ function createTestInjector() {
}
describe('Platform Service Tests', () => {
- var platformService: IPlatformService, testInjector: IInjector;
- var commandsService: ICommandsService;
+ let platformService: IPlatformService, testInjector: IInjector;
+ let commandsService: ICommandsService;
beforeEach(() => {
testInjector = createTestInjector();
testInjector.register("fs", stubs.FileSystemStub);
@@ -143,7 +143,7 @@ describe('Platform Service Tests', () => {
}
return false;
}).future()();
- }
+ };
commandsService.tryExecuteCommand("platform|add", []).wait();
assert.isFalse(isCommandExecuted);
@@ -160,7 +160,7 @@ describe('Platform Service Tests', () => {
}
return false;
}).future()();
- }
+ };
commandsService.tryExecuteCommand("platform|add", ["invalidPlatform"]).wait();
assert.isFalse(isCommandExecuted);
@@ -175,7 +175,7 @@ describe('Platform Service Tests', () => {
}
return false;
}).future()();
- }
+ };
commandsService.tryExecuteCommand("platform|add", ["android"]).wait();
assert.isTrue(isCommandExecuted);
@@ -190,7 +190,7 @@ describe('Platform Service Tests', () => {
}
return false;
}).future()();
- }
+ };
commandsService.tryExecuteCommand("platform|add", ["android", "ios"]).wait();
assert.isTrue(isCommandExecuted);
@@ -205,7 +205,7 @@ describe('Platform Service Tests', () => {
}
return false;
}).future()();
- }
+ };
commandsService.tryExecuteCommand("platform|add", ["ios", "invalid"]).wait();
assert.isFalse(isCommandExecuted);
@@ -222,7 +222,7 @@ describe('Platform Service Tests', () => {
}
return false;
}).future()();
- }
+ };
commandsService.tryExecuteCommand("platform|remove", []).wait();
assert.isFalse(isCommandExecuted);
@@ -237,7 +237,7 @@ describe('Platform Service Tests', () => {
}
return false;
}).future()();
- }
+ };
commandsService.tryExecuteCommand("platform|remove", ["invalidPlatform"]).wait();
assert.isFalse(isCommandExecuted);
@@ -252,7 +252,7 @@ describe('Platform Service Tests', () => {
}
return false;
}).future()();
- }
+ };
commandsService.tryExecuteCommand("platform|remove", ["android"]).wait();
assert.isTrue(isCommandExecuted);
@@ -267,7 +267,7 @@ describe('Platform Service Tests', () => {
}
return false;
}).future()();
- }
+ };
commandsService.tryExecuteCommand("platform|remove", ["android", "ios"]).wait();
assert.isTrue(isCommandExecuted);
@@ -282,7 +282,7 @@ describe('Platform Service Tests', () => {
}
return false;
}).future()();
- }
+ };
commandsService.tryExecuteCommand("platform|remove", ["ios", "invalid"]).wait();
assert.isFalse(isCommandExecuted);
@@ -299,7 +299,7 @@ describe('Platform Service Tests', () => {
}
return false;
}).future()();
- }
+ };
commandsService.tryExecuteCommand("platform|update", []).wait();
assert.isFalse(isCommandExecuted);
@@ -314,7 +314,7 @@ describe('Platform Service Tests', () => {
}
return false;
}).future()();
- }
+ };
commandsService.tryExecuteCommand("platform|update", ["invalidPlatform"]).wait();
assert.isFalse(isCommandExecuted);
@@ -329,7 +329,7 @@ describe('Platform Service Tests', () => {
}
return false;
}).future()();
- }
+ };
commandsService.tryExecuteCommand("platform|update", ["android"]).wait();
assert.isTrue(isCommandExecuted);
@@ -344,7 +344,7 @@ describe('Platform Service Tests', () => {
}
return false;
}).future()();
- }
+ };
commandsService.tryExecuteCommand("platform|update", ["android", "ios"]).wait();
assert.isTrue(isCommandExecuted);
@@ -359,11 +359,11 @@ describe('Platform Service Tests', () => {
}
return false;
}).future()();
- }
+ };
commandsService.tryExecuteCommand("platform|update", ["ios", "invalid"]).wait();
assert.isFalse(isCommandExecuted);
});
});
});
-});
\ No newline at end of file
+});
diff --git a/test/platform-service.ts b/test/platform-service.ts
index 4a5c195654..0fa242c709 100644
--- a/test/platform-service.ts
+++ b/test/platform-service.ts
@@ -3,34 +3,21 @@
import yok = require('../lib/common/yok');
import stubs = require('./stubs');
-
import PlatformServiceLib = require('../lib/services/platform-service');
-import ProjectServiceLib = require("../lib/services/project-service");
-import NodePackageManagerLib = require('../lib/node-package-manager');
-import ProjectDataServiceLib = require("../lib/services/project-data-service");
import StaticConfigLib = require("../lib/config");
import fsLib = require("../lib/common/file-system");
-import ProjectLib = require('../lib/services/project-service');
-import ProjectServiceTestLib = require('./project-service');
-import NpmLib = require("../lib/node-package-manager");
-import HttpClientLib = require("../lib/common/http-client");
-import ProjectDataLib = require("../lib/project-data");
-import ProjectHelperLib = require("../lib/common/project-helper");
import optionsLib = require("../lib/options");
import hostInfoLib = require("../lib/common/host-info");
import ProjectFilesManagerLib = require("../lib/services/project-files-manager");
-
-import path = require("path");
+import * as path from "path";
import Future = require("fibers/future");
-
-var assert = require("chai").assert;
+import {assert} from "chai";
require('should');
-
let temp = require("temp");
temp.track();
function createTestInjector() {
- var testInjector = new yok.Yok();
+ let testInjector = new yok.Yok();
testInjector.register('platformService', PlatformServiceLib.PlatformService);
testInjector.register('errors', stubs.ErrorsStub);
@@ -44,14 +31,14 @@ function createTestInjector() {
testInjector.register('prompter', {});
testInjector.register('lockfile', stubs.LockFile);
testInjector.register("commandsService", {
- tryExecuteCommand: () => {}
+ tryExecuteCommand: () => { /* intentionally left blank */ }
});
testInjector.register("options", optionsLib.Options);
testInjector.register("hostInfo", hostInfoLib.HostInfo);
testInjector.register("staticConfig", StaticConfigLib.StaticConfig);
testInjector.register("broccoliBuilder", {
prepareNodeModules: () => {
- return (() => { }).future()();
+ return Future.fromResult();
}
});
testInjector.register("pluginsService", {
@@ -61,7 +48,7 @@ function createTestInjector() {
}).future()();
},
ensureAllDependenciesAreInstalled: () => {
- return (() => { }).future()();
+ return Future.fromResult();
}
});
testInjector.register("projectFilesManager", ProjectFilesManagerLib.ProjectFilesManager);
@@ -70,7 +57,7 @@ function createTestInjector() {
}
describe('Platform Service Tests', () => {
- var platformService: IPlatformService, testInjector: IInjector;
+ let platformService: IPlatformService, testInjector: IInjector;
beforeEach(() => {
testInjector = createTestInjector();
testInjector.register("fs", stubs.FileSystemStub);
@@ -80,7 +67,7 @@ describe('Platform Service Tests', () => {
describe("add platform unit tests", () => {
describe("#add platform()", () => {
it("should not fail if platform is not normalized", () => {
- var fs = testInjector.resolve("fs");
+ let fs = testInjector.resolve("fs");
fs.exists = () => Future.fromResult(false);
platformService.addPlatforms(["Android"]).wait();
@@ -99,12 +86,12 @@ describe('Platform Service Tests', () => {
(() => platformService.addPlatforms(["ios"]).wait()).should.throw();
});
it("should fail if npm is unavalible", () => {
- var fs = testInjector.resolve("fs");
+ let fs = testInjector.resolve("fs");
fs.exists = () => Future.fromResult(false);
- var errorMessage = "Npm is unavalible";
- var npmInstallationManager = testInjector.resolve("npmInstallationManager");
- npmInstallationManager.install = () => { throw new Error(errorMessage) };
+ let errorMessage = "Npm is unavalible";
+ let npmInstallationManager = testInjector.resolve("npmInstallationManager");
+ npmInstallationManager.install = () => { throw new Error(errorMessage); };
try {
platformService.addPlatforms(["android"]).wait();
@@ -115,12 +102,12 @@ describe('Platform Service Tests', () => {
});
describe("#add platform(ios)", () => {
it("should call validate method", () => {
- var fs = testInjector.resolve("fs");
+ let fs = testInjector.resolve("fs");
fs.exists = () => Future.fromResult(false);
- var errorMessage = "Xcode is not installed or Xcode version is smaller that 5.0";
- var platformsData = testInjector.resolve("platformsData");
- var platformProjectService = platformsData.getPlatformData().platformProjectService;
+ let errorMessage = "Xcode is not installed or Xcode version is smaller that 5.0";
+ let platformsData = testInjector.resolve("platformsData");
+ let platformProjectService = platformsData.getPlatformData().platformProjectService;
platformProjectService.validate = () => {
throw new Error(errorMessage);
};
@@ -134,12 +121,12 @@ describe('Platform Service Tests', () => {
});
describe("#add platform(android)", () => {
it("should fail if java, ant or android are not installed", () => {
- var fs = testInjector.resolve("fs");
+ let fs = testInjector.resolve("fs");
fs.exists = () => Future.fromResult(false);
- var errorMessage = "Java, ant or android are not installed";
- var platformsData = testInjector.resolve("platformsData");
- var platformProjectService = platformsData.getPlatformData().platformProjectService;
+ let errorMessage = "Java, ant or android are not installed";
+ let platformsData = testInjector.resolve("platformsData");
+ let platformProjectService = platformsData.getPlatformData().platformProjectService;
platformProjectService.validate = () => {
throw new Error(errorMessage);
};
@@ -177,7 +164,7 @@ describe('Platform Service Tests', () => {
describe("update Platform", () => {
describe("#updatePlatform(platform)", () => {
it("should fail when the versions are the same", () => {
- var npmInstallationManager: INpmInstallationManager = testInjector.resolve("npmInstallationManager");
+ let npmInstallationManager: INpmInstallationManager = testInjector.resolve("npmInstallationManager");
npmInstallationManager.getLatestVersion = () => (() => "0.2.0").future()();
npmInstallationManager.getCacheRootPath = () => "";
@@ -187,7 +174,7 @@ describe('Platform Service Tests', () => {
});
describe("prepare platform unit tests", () => {
- let testInjector: IInjector, fs: IFileSystem;
+ let fs: IFileSystem;
beforeEach(() => {
testInjector = createTestInjector();
testInjector.register("fs", fsLib.FileSystem);
@@ -233,13 +220,13 @@ describe('Platform Service Tests', () => {
interpolateData: (projectRoot: string) => Future.fromResult(),
afterCreateProject: (projectRoot: string) => Future.fromResult()
}
- }
+ };
};
let projectData = testInjector.resolve("projectData");
projectData.projectDir = tempFolder;
- let platformService = testInjector.resolve("platformService");
+ platformService = testInjector.resolve("platformService");
platformService.preparePlatform("ios").wait();
// Asserts that the files in app folder are process as platform specific
@@ -291,13 +278,13 @@ describe('Platform Service Tests', () => {
interpolateData: (projectRoot: string) => Future.fromResult(),
afterCreateProject: (projectRoot: string) => Future.fromResult()
}
- }
+ };
};
let projectData = testInjector.resolve("projectData");
projectData.projectDir = tempFolder;
- let platformService = testInjector.resolve("platformService");
+ platformService = testInjector.resolve("platformService");
platformService.preparePlatform("android").wait();
// Asserts that the files in app folder are process as platform specific
diff --git a/test/plugins-service.ts b/test/plugins-service.ts
index 19a24105b8..d6bedebc9c 100644
--- a/test/plugins-service.ts
+++ b/test/plugins-service.ts
@@ -2,6 +2,7 @@
"use strict";
import {Yok} from '../lib/common/yok';
+import future = require("fibers/future");
import * as stubs from './stubs';
import {NodePackageManager} from "../lib/node-package-manager";
import {FileSystem} from "../lib/common/file-system";
@@ -20,11 +21,9 @@ import * as helpers from "../lib/common/helpers";
import {ProjectFilesManager} from "../lib/services/project-files-manager";
import {ResourceLoader} from "../lib/common/resource-loader";
import {EOL} from "os";
-
import {PluginsService} from "../lib/services/plugins-service";
import {AddPluginCommand} from "../lib/commands/plugin/add-plugin";
-
-import {assert} from "chai"
+import {assert} from "chai";
import * as path from "path";
import * as temp from "temp";
temp.track();
@@ -55,7 +54,7 @@ function createTestInjector() {
testInjector.register("hooksService", stubs.HooksServiceStub);
testInjector.register("commandsService", CommandsService);
testInjector.register("commandsServiceProvider", {
- registerDynamicSubCommands: () => {}
+ registerDynamicSubCommands: () => { /* intentionally empty body */ }
});
testInjector.register("hostInfo", HostInfo);
testInjector.register("lockfile", { });
@@ -63,9 +62,9 @@ function createTestInjector() {
testInjector.register("pluginsService", PluginsService);
testInjector.register("analyticsService", {
- trackException: () => { return (() => { }).future()(); },
- checkConsent: () => { return (() => { }).future()(); },
- trackFeature: () => { return (() => { }).future()(); }
+ trackException: () => { return future.fromResult(); },
+ checkConsent: () => { return future.fromResult(); },
+ trackFeature: () => { return future.fromResult(); }
});
testInjector.register("projectFilesManager", ProjectFilesManager);
@@ -118,7 +117,7 @@ function addPluginWhenExpectingToFail(testInjector: IInjector, plugin: string, e
}).future()();
};
pluginsService.ensureAllDependenciesAreInstalled = () => {
- return (() => { }).future()();
+ return future.fromResult();
};
mockBeginCommand(testInjector, "Exception: " + expectedErrorMessage);
@@ -244,7 +243,7 @@ describe("Plugins service", () => {
return {
appDestinationDirectoryPath: path.join(projectFolder, "platforms", "android"),
frameworkPackageName: "tns-android"
- }
+ };
};
pluginsService.add(pluginFolderPath).wait();
@@ -448,7 +447,6 @@ describe("Plugins service", () => {
});
describe("merge xmls tests", () => {
- let testInjector: IInjector;
beforeEach(() => {
testInjector = createTestInjector();
testInjector.registerCommand("plugin|add", AddPluginCommand);
@@ -491,7 +489,7 @@ describe("Plugins service", () => {
appDestinationDirectoryPath: appDestinationDirectoryPath,
frameworkPackageName: "tns-android",
configurationFileName: "AndroidManifest.xml"
- }
+ };
};
// Ensure the pluginDestinationPath folder exists
@@ -556,9 +554,9 @@ describe("Plugins service", () => {
configurationFilePath: path.join(appDestinationDirectoryPath, "AndroidManifest.xml"),
mergeXmlConfig: [{ "nodename": "manifest", "attrname": "*" }],
platformProjectService: {
- preparePluginNativeCode: (pluginData: IPluginData) => (() => {}).future()()
+ preparePluginNativeCode: (pluginData: IPluginData) => future.fromResult()
}
- }
+ };
};
// Ensure the pluginDestinationPath folder exists
@@ -586,4 +584,4 @@ describe("Plugins service", () => {
assert.equal(expectedXml, actualXml);
});
});
-});
\ No newline at end of file
+});
diff --git a/test/project-files-manager.ts b/test/project-files-manager.ts
index 8b4cf41997..9f6780d6ed 100644
--- a/test/project-files-manager.ts
+++ b/test/project-files-manager.ts
@@ -7,11 +7,11 @@ import projectFilesManagerLib = require("../lib/services/project-files-manager")
import hostInfoLib = require("../lib/common/host-info");
import StaticConfigLib = require("../lib/config");
import ErrorsLib = require("../lib/common/errors");
-import path = require("path");
+import * as path from "path";
import temp = require("temp");
temp.track();
-var assert = require("chai").assert;
+let assert = require("chai").assert;
function createTestInjector() {
let testInjector = new yok.Yok();
@@ -78,4 +78,4 @@ describe('Project Files Manager Tests', () => {
assert.isTrue(fs.exists(path.join(directoryPath, "index2.js")).wait());
assert.isTrue(fs.exists(path.join(directoryPath, "index3.js")).wait());
});
-});
\ No newline at end of file
+});
diff --git a/test/project-service.ts b/test/project-service.ts
index 9dcc145bd3..2e48204a37 100644
--- a/test/project-service.ts
+++ b/test/project-service.ts
@@ -5,27 +5,23 @@ import yok = require('../lib/common/yok');
import stubs = require('./stubs');
import * as constants from "./../lib/constants";
import * as ChildProcessLib from "../lib/common/child-process";
-
-import ProjectServiceLib = require("../lib/services/project-service");
-import ProjectDataServiceLib = require("../lib/services/project-data-service");
-import ProjectDataLib = require("../lib/project-data");
-import ProjectHelperLib = require("../lib/common/project-helper");
-import StaticConfigLib = require("../lib/config");
-import NpmLib = require("../lib/node-package-manager");
-import NpmInstallationManagerLib = require("../lib/npm-installation-manager");
-import HttpClientLib = require("../lib/common/http-client");
-import fsLib = require("../lib/common/file-system");
-import platformServiceLib = require("../lib/services/platform-service");
-
-import path = require("path");
+import * as ProjectServiceLib from "../lib/services/project-service";
+import * as ProjectDataServiceLib from "../lib/services/project-data-service";
+import * as ProjectDataLib from "../lib/project-data";
+import * as ProjectHelperLib from "../lib/common/project-helper";
+import * as StaticConfigLib from "../lib/config";
+import * as NpmLib from "../lib/node-package-manager";
+import * as NpmInstallationManagerLib from "../lib/npm-installation-manager";
+import * as HttpClientLib from "../lib/common/http-client";
+import * as fsLib from "../lib/common/file-system";
+import * as path from "path";
import temp = require("temp");
-import util = require("util");
-import helpers = require("../lib/common/helpers");
+import * as helpers from "../lib/common/helpers";
+import {assert} from "chai";
+import * as optionsLib from "../lib/options";
+import * as hostInfoLib from "../lib/common/host-info";
-var assert = require("chai").assert;
-var optionsLib = require("../lib/options");
-var hostInfoLib = require("../lib/common/host-info");
-var mockProjectNameValidator = {
+let mockProjectNameValidator = {
validate: () => { return true; }
};
@@ -39,19 +35,19 @@ class ProjectIntegrationTest {
}
public createProject(projectName: string): IFuture {
- var projectService = this.testInjector.resolve("projectService");
+ let projectService = this.testInjector.resolve("projectService");
return projectService.createProject(projectName);
}
public getDefaultTemplatePath(): IFuture {
return (() => {
- var npmInstallationManager = this.testInjector.resolve("npmInstallationManager");
- var fs = this.testInjector.resolve("fs");
+ let npmInstallationManager = this.testInjector.resolve("npmInstallationManager");
+ let fs = this.testInjector.resolve("fs");
- var defaultTemplatePackageName = "tns-template-hello-world";
- var cacheRoot = npmInstallationManager.getCacheRootPath();
- var defaultTemplatePath = path.join(cacheRoot, defaultTemplatePackageName);
- var latestVersion = npmInstallationManager.getLatestVersion(defaultTemplatePackageName).wait();
+ let defaultTemplatePackageName = "tns-template-hello-world";
+ let cacheRoot = npmInstallationManager.getCacheRootPath();
+ let defaultTemplatePath = path.join(cacheRoot, defaultTemplatePackageName);
+ let latestVersion = npmInstallationManager.getLatestVersion(defaultTemplatePackageName).wait();
if(!fs.exists(path.join(defaultTemplatePath, latestVersion)).wait()) {
npmInstallationManager.addToCache(defaultTemplatePackageName, latestVersion).wait();
@@ -66,14 +62,14 @@ class ProjectIntegrationTest {
public assertProject(tempFolder: string, projectName: string, appId: string): IFuture {
return (() => {
- var fs: IFileSystem = this.testInjector.resolve("fs");
- var projectDir = path.join(tempFolder, projectName);
- var appDirectoryPath = path.join(projectDir, "app");
- var platformsDirectoryPath = path.join(projectDir, "platforms");
+ let fs: IFileSystem = this.testInjector.resolve("fs");
+ let projectDir = path.join(tempFolder, projectName);
+ let appDirectoryPath = path.join(projectDir, "app");
+ let platformsDirectoryPath = path.join(projectDir, "platforms");
let tnsProjectFilePath = path.join(projectDir, "package.json");
let tnsModulesPath = path.join(projectDir, constants.NODE_MODULES_FOLDER_NAME, constants.TNS_CORE_MODULES_NAME);
- var options = this.testInjector.resolve("options");
+ let options = this.testInjector.resolve("options");
assert.isTrue(fs.exists(appDirectoryPath).wait());
assert.isTrue(fs.exists(platformsDirectoryPath).wait());
@@ -83,19 +79,19 @@ class ProjectIntegrationTest {
assert.isFalse(fs.isEmptyDir(appDirectoryPath).wait());
assert.isTrue(fs.isEmptyDir(platformsDirectoryPath).wait());
- var actualAppId = fs.readJson(tnsProjectFilePath).wait()["nativescript"].id;
- var expectedAppId = appId;
+ let actualAppId = fs.readJson(tnsProjectFilePath).wait()["nativescript"].id;
+ let expectedAppId = appId;
assert.equal(actualAppId, expectedAppId);
let tnsCoreModulesRecord = fs.readJson(tnsProjectFilePath).wait()["dependencies"][constants.TNS_CORE_MODULES_NAME];
assert.isTrue(tnsCoreModulesRecord !== null);
- var actualFiles = fs.enumerateFilesInDirectorySync(options.copyFrom);
- var expectedFiles = fs.enumerateFilesInDirectorySync(appDirectoryPath);
+ let actualFiles = fs.enumerateFilesInDirectorySync(options.copyFrom);
+ let expectedFiles = fs.enumerateFilesInDirectorySync(appDirectoryPath);
assert.equal(actualFiles.length, expectedFiles.length);
_.each(actualFiles, file => {
- var relativeToProjectDir = helpers.getRelativeToRootPath(options.copyFrom, file);
+ let relativeToProjectDir = helpers.getRelativeToRootPath(options.copyFrom, file);
assert.isTrue(fs.exists(path.join(appDirectoryPath, relativeToProjectDir)).wait());
});
}).future()();
@@ -133,10 +129,10 @@ class ProjectIntegrationTest {
describe("Project Service Tests", () => {
describe("project service integration tests", () => {
it("creates valid project from default template", () => {
- var projectIntegrationTest = new ProjectIntegrationTest();
- var tempFolder = temp.mkdirSync("project");
- var projectName = "myapp";
- var options = projectIntegrationTest.testInjector.resolve("options");
+ let projectIntegrationTest = new ProjectIntegrationTest();
+ let tempFolder = temp.mkdirSync("project");
+ let projectName = "myapp";
+ let options = projectIntegrationTest.testInjector.resolve("options");
options.path = tempFolder;
options.copyFrom = projectIntegrationTest.getDefaultTemplatePath().wait();
@@ -145,10 +141,10 @@ describe("Project Service Tests", () => {
projectIntegrationTest.assertProject(tempFolder, projectName, "org.nativescript.myapp").wait();
});
it("creates valid project with specified id from default template", () => {
- var projectIntegrationTest = new ProjectIntegrationTest();
- var tempFolder = temp.mkdirSync("project1");
- var projectName = "myapp";
- var options = projectIntegrationTest.testInjector.resolve("options");
+ let projectIntegrationTest = new ProjectIntegrationTest();
+ let tempFolder = temp.mkdirSync("project1");
+ let projectName = "myapp";
+ let options = projectIntegrationTest.testInjector.resolve("options");
options.path = tempFolder;
options.copyFrom = projectIntegrationTest.getDefaultTemplatePath().wait();
@@ -161,7 +157,7 @@ describe("Project Service Tests", () => {
});
function createTestInjector() {
- var testInjector = new yok.Yok();
+ let testInjector = new yok.Yok();
testInjector.register("errors", stubs.ErrorsStub);
testInjector.register('logger', stubs.LoggerStub);
@@ -191,90 +187,90 @@ function createTestInjector() {
describe("project upgrade procedure tests", () => {
it("should throw error when no nativescript project folder specified", () => {
- var testInjector = createTestInjector();
- var tempFolder = temp.mkdirSync("project upgrade");
- var options = testInjector.resolve("options");
+ let testInjector = createTestInjector();
+ let tempFolder = temp.mkdirSync("project upgrade");
+ let options = testInjector.resolve("options");
options.path = tempFolder;
- var isErrorThrown = false;
+ let isErrorThrown = false;
try {
testInjector.resolve("projectData"); // This should trigger upgrade procedure
} catch(err) {
isErrorThrown = true;
- var expectedErrorMessage = "No project found at or above '%s' and neither was a --path specified.," + tempFolder;
+ let expectedErrorMessage = "No project found at or above '%s' and neither was a --path specified.," + tempFolder;
assert.equal(expectedErrorMessage, err.toString());
}
assert.isTrue(isErrorThrown);
});
it("should upgrade project when .tnsproject file exists but package.json file doesn't exist", () => {
- var testInjector = createTestInjector();
- var fs: IFileSystem = testInjector.resolve("fs");
+ let testInjector = createTestInjector();
+ let fs: IFileSystem = testInjector.resolve("fs");
- var tempFolder = temp.mkdirSync("projectUpgradeTest2");
- var options = testInjector.resolve("options");
+ let tempFolder = temp.mkdirSync("projectUpgradeTest2");
+ let options = testInjector.resolve("options");
options.path = tempFolder;
- var tnsProjectData = {
+ let tnsProjectData = {
"id": "org.nativescript.Test",
"tns-ios": {
"version": "1.0.0"
}
};
- var tnsProjectFilePath = path.join(tempFolder, ".tnsproject");
+ let tnsProjectFilePath = path.join(tempFolder, ".tnsproject");
fs.writeJson(tnsProjectFilePath, tnsProjectData).wait();
testInjector.resolve("projectData"); // This should trigger upgrade procedure
- var packageJsonFilePath = path.join(tempFolder, "package.json");
- var packageJsonFileContent = require(packageJsonFilePath);
+ let packageJsonFilePath = path.join(tempFolder, "package.json");
+ let packageJsonFileContent = require(packageJsonFilePath);
assert.isTrue(fs.exists(packageJsonFilePath).wait());
assert.isFalse(fs.exists(tnsProjectFilePath).wait());
assert.deepEqual(tnsProjectData, packageJsonFileContent["nativescript"]);
});
it("should upgrade project when .tnsproject and package.json exist but nativescript key is not presented in package.json file", () => {
- var testInjector = createTestInjector();
- var fs: IFileSystem = testInjector.resolve("fs");
+ let testInjector = createTestInjector();
+ let fs: IFileSystem = testInjector.resolve("fs");
- var tempFolder = temp.mkdirSync("projectUpgradeTest3");
- var options = testInjector.resolve("options");
+ let tempFolder = temp.mkdirSync("projectUpgradeTest3");
+ let options = testInjector.resolve("options");
options.path = tempFolder;
- var tnsProjectData = {
+ let tnsProjectData = {
"id": "org.nativescript.Test",
"tns-ios": {
"version": "1.0.1"
}
};
- var packageJsonData = {
+ let packageJsonData = {
"name": "testModuleName",
"version": "0.0.0",
"dependencies": {
"myFirstDep": "0.0.1"
}
- }
+ };
let tnsProjectFilePath = path.join(tempFolder, ".tnsproject");
fs.writeJson(tnsProjectFilePath, tnsProjectData).wait();
- var packageJsonFilePath = path.join(tempFolder, "package.json");
+ let packageJsonFilePath = path.join(tempFolder, "package.json");
fs.writeJson(packageJsonFilePath, packageJsonData).wait();
testInjector.resolve("projectData"); // This should trigger upgrade procedure
- var packageJsonFileContent = require(packageJsonFilePath);
- var expectedPackageJsonContent: any = packageJsonData;
+ let packageJsonFileContent = require(packageJsonFilePath);
+ let expectedPackageJsonContent: any = packageJsonData;
expectedPackageJsonContent["nativescript"] = tnsProjectData;
assert.deepEqual(expectedPackageJsonContent, packageJsonFileContent);
});
it("shouldn't upgrade project when .tnsproject and package.json exist and nativescript key is presented in package.json file", () => {
- var testInjector = createTestInjector();
- var fs: IFileSystem = testInjector.resolve("fs");
+ let testInjector = createTestInjector();
+ let fs: IFileSystem = testInjector.resolve("fs");
- var tempFolder = temp.mkdirSync("projectUpgradeTest4");
- var options = testInjector.resolve("options");
+ let tempFolder = temp.mkdirSync("projectUpgradeTest4");
+ let options = testInjector.resolve("options");
options.path = tempFolder;
- var tnsProjectData = {
+ let tnsProjectData = {
};
- var packageJsonData = {
+ let packageJsonData = {
"name": "testModuleName",
"version": "0.0.0",
"dependencies": {
@@ -286,15 +282,15 @@ describe("project upgrade procedure tests", () => {
"version": "1.0.2"
}
}
- }
+ };
fs.writeJson(path.join(tempFolder, ".tnsproject"), tnsProjectData).wait();
fs.writeJson(path.join(tempFolder, "package.json"), packageJsonData).wait();
testInjector.resolve("projectData"); // This should trigger upgrade procedure
- var packageJsonFilePath = path.join(tempFolder, "package.json");
- var packageJsonFileContent = require(packageJsonFilePath);
+ let packageJsonFilePath = path.join(tempFolder, "package.json");
+ let packageJsonFileContent = require(packageJsonFilePath);
assert.deepEqual(packageJsonData, packageJsonFileContent);
});
-});
\ No newline at end of file
+});
diff --git a/test/stubs.ts b/test/stubs.ts
index b0fb426a30..87e4b45eef 100644
--- a/test/stubs.ts
+++ b/test/stubs.ts
@@ -1,12 +1,12 @@
///
+/* tslint:disable:no-empty */
"use strict";
import Future = require("fibers/future");
-import util = require("util");
-import path = require("path");
+import * as util from "util";
export class LoggerStub implements ILogger {
- setLevel(level: string): void {}
+ setLevel(level: string): void { }
getLevel(): string { return undefined; }
fatal(...args: string[]): void {}
error(...args: string[]): void {}
@@ -37,7 +37,7 @@ export class FileSystemStub implements IFileSystem {
zipFiles(zipFile: string, files: string[], zipPathCallback: (path: string) => string): IFuture {
return undefined;
}
-
+
unzip(zipFile: string, destination: string): IFuture {
return undefined;
}
@@ -161,7 +161,9 @@ export class FileSystemStub implements IFileSystem {
}
export class ErrorsStub implements IErrors {
- private impl: IErrors = new (require("../lib/common/errors").Errors)();
+ constructor() {
+ new (require("../lib/common/errors").Errors)(); // we need the side effect of require'ing errors
+ }
fail(formatStr:string, ...args: any[]): void;
fail(opts:{formatStr?: string; errorCode?: number; suppressCommandHelp?: boolean}, ...args: any[]): void;
@@ -235,7 +237,7 @@ export class ProjectDataStub implements IProjectData {
}
export class PlatformsDataStub implements IPlatformsData {
- public platformsNames: string[];
+ public platformsNames: string[];
public getPlatformData(platform: string): IPlatformData {
return {
@@ -308,13 +310,13 @@ export class PlatformProjectServiceStub implements IPlatformProjectService {
updatePlatform(currentVersion: string, newVersion: string): IFuture {
return Future.fromResult();
}
- prepareAppResources(appResourcesDirectoryPath: string): IFuture {
+ prepareAppResources(appResourcesDirectoryPath: string): IFuture {
return Future.fromResult();
}
preparePluginNativeCode(pluginData: IPluginData): IFuture {
return Future.fromResult();
}
- removePluginNativeCode(pluginData: IPluginData): IFuture {
+ removePluginNativeCode(pluginData: IPluginData): IFuture {
return Future.fromResult();
}
afterPrepareAllPlugins(): IFuture {
@@ -332,7 +334,7 @@ export class ProjectDataService implements IProjectDataService {
setValue(key: string, value: any): IFuture {
return Future.fromResult();
}
-
+
removeProperty(propertyName: string): IFuture {
return Future.fromResult();
}
diff --git a/tslint.json b/tslint.json
new file mode 100644
index 0000000000..716eaaa3bf
--- /dev/null
+++ b/tslint.json
@@ -0,0 +1,52 @@
+{
+ "rules": {
+ "class-name": true,
+ "curly": true,
+ "eofline": true,
+ "indent": true,
+ "interface-name": true,
+ "jsdoc-format": true,
+ "max-line-length": [false, 140],
+ "no-consecutive-blank-lines": true,
+ "no-construct": true,
+ "no-debugger": true,
+ "no-duplicate-key": true,
+ "no-duplicate-variable": true,
+ "no-shadowed-variable": true,
+ "no-empty": true,
+ "no-eval": true,
+ "no-switch-case-fall-through": true,
+ "no-unreachable": true,
+ "no-unused-expression": true,
+ "no-unused-variable": true,
+ "no-use-before-declare": true,
+ "no-var-keyword": true,
+ "one-line": [
+ false,
+ "check-open-brace",
+ "check-catch",
+ "check-else"
+ ],
+ "quotemark": [false, "double"],
+ "semicolon": true,
+ "switch-default": false,
+ "triple-equals": [true, "allow-null-check"],
+ "use-strict": true,
+ "variable-name": [false, "allow-leading-underscore"],
+ "whitespace": [
+ false,
+ "check-branch",
+ "check-decl",
+ "check-operator",
+ "check-module",
+ "check-separator",
+ "check-type",
+ "check-typecast"
+ ],
+
+
+
+ "no-var-requires": false,
+ "no-trailing-whitespace": false
+ }
+}
\ No newline at end of file