-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathconfig.ts
105 lines (90 loc) · 3.33 KB
/
config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
///<reference path=".d.ts"/>
"use strict";
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;
DEBUG = false;
TYPESCRIPT_COMPILER_OPTIONS = {};
USE_PROXY = false;
ANDROID_DEBUG_UI: string = null;
USE_POD_SANDBOX: boolean = true;
/*don't require logger and everything that has logger as dependency in config.js due to cyclic dependency*/
constructor(protected $fs: IFileSystem) {
super($fs);
_.extend(this, this.loadConfig("config").wait());
}
}
$injector.register("config", Configuration);
export class StaticConfig extends staticConfigBaseLibPath.StaticConfigBase implements IStaticConfig {
public PROJECT_FILE_NAME = "package.json";
public CLIENT_NAME_KEY_IN_PROJECT_FILE = "nativescript";
public CLIENT_NAME = "tns";
public CLIENT_NAME_ALIAS = "NativeScript";
public ANALYTICS_API_KEY = "5752dabccfc54c4ab82aea9626b7338e";
public TRACK_FEATURE_USAGE_SETTING_NAME = "TrackFeatureUsage";
public ERROR_REPORT_SETTING_NAME = "TrackExceptions";
public ANALYTICS_INSTALLATION_ID_SETTING_NAME = "AnalyticsInstallationID";
public START_PACKAGE_ACTIVITY_NAME = "com.tns.NativeScriptActivity";
constructor($injector: IInjector) {
super($injector);
this.RESOURCE_DIR_PATH = path.join(this.RESOURCE_DIR_PATH, "../../resources");
}
public get disableHooks() {
return true;
}
public get SYS_REQUIREMENTS_LINK(): string {
let linkToSysRequirements: string;
switch(process.platform) {
case "linux":
linkToSysRequirements = "http://docs.nativescript.org/setup/ns-cli-setup/ns-setup-linux.html#system-requirements";
break;
case "win32":
linkToSysRequirements = "http://docs.nativescript.org/setup/ns-cli-setup/ns-setup-win.html#system-requirements";
break;
case "darwin":
linkToSysRequirements = "http://docs.nativescript.org/setup/ns-cli-setup/ns-setup-os-x.html#system-requirements";
break;
default:
linkToSysRequirements = "";
}
return linkToSysRequirements;
}
public version = require("../package.json").version;
public get helpTextPath(): string {
return path.join(__dirname, "../resources/help.txt");
}
public get HTML_CLI_HELPERS_DIR(): string {
return path.join(__dirname, "../docs/helpers");
}
public get pathToPackageJson(): string {
return path.join(__dirname, "..", "package.json");
}
public get PATH_TO_BOOTSTRAP() : string {
return path.join(__dirname, "bootstrap");
}
public getAdbFilePath(): IFuture<string> {
return (() => {
if(!this._adbFilePath) {
let androidHomeEnvVar = process.env.ANDROID_HOME;
if(androidHomeEnvVar) {
let pathToAdb = path.join(androidHomeEnvVar, "platform-tools", "adb");
let childProcess: IChildProcess = this.$injector.resolve("$childProcess");
try {
childProcess.execFile(pathToAdb, ["help"]).wait();
this._adbFilePath = pathToAdb;
} catch (err) {
// adb does not exist, so ANDROID_HOME is not set correctly
// try getting default adb path (included in CLI package)
super.getAdbFilePath().wait();
}
} else {
super.getAdbFilePath().wait();
}
}
return this._adbFilePath;
}).future<string>()();
}
}
$injector.register("staticConfig", StaticConfig);