-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathenvironmentSettings.ts
137 lines (115 loc) · 4.37 KB
/
environmentSettings.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import * as fs from 'fs';
import { join } from 'path';
import { LOG_LEVELS, LogLevel } from './utilities/constants';
export class EnvironmentSettings {
private static _instance: EnvironmentSettings;
private _vscodeVersion = 'latest';
private _specFiles = [
'./lib/specs/**/*.e2e.js'
// OR
// './lib/specs/**/anInitialSuite.e2e.js',
// './lib/specs/**/apexLsp.e2e.js',
// './lib/specs/**/apexReplayDebugger.e2e.js',
// './lib/specs/**/auraLsp.e2e.js',
// './lib/specs/**/authentication.e2e.js',
// './lib/specs/**/debugApexTests.e2e.js',
// './lib/specs/**/deployAndRetrieve.e2e.js',
// './lib/specs/**/lwcLsp.e2e.js',
// './lib/specs/**/manifestBuilder.e2e.js',
// './lib/specs/**/orgBrowser.e2e.js',
// './lib/specs/**/pushAndPull.e2e.js'
// './lib/specs/**/runApexTests.e2e.js',
// './lib/specs/**/sObjectsDefinitions.e2e.js',
// './lib/specs/**/templates.e2e.js',
// './lib/specs/**/trailApexReplayDebugger.e2e.js',
// './lib/specs/**/visualforceLsp.e2e.js',
// './lib/specs/**/sfdxProjectJson.e2e.js'
];
private _devHubAliasName = 'vscodeOrg';
private _devHubUserName = 'svcideebot@salesforce.com';
private _sfdxAuthUrl = process.env.SFDX_AUTH_URL;
private _orgId = process.env.ORG_ID;
private _extensionPath = join(__dirname, '..', '..', 'salesforcedx-vscode', 'extensions');
private _startTime = new Date(Date.now()).toLocaleTimeString([], { timeStyle: 'short' });
private _throttleFactor = 1;
private _javaHome = process.env.JAVA_HOME;
private _useExistingProject: string | undefined;
private _logLevel: LogLevel = 'info';
private constructor() {
this._vscodeVersion = process.env.CODE_VERSION || this._vscodeVersion;
if (process.env.SPEC_FILES) {
this._specFiles = ['lib/specs/' + process.env.SPEC_FILES];
}
this._devHubAliasName = process.env.DEV_HUB_ALIAS_NAME || this._devHubAliasName;
this._devHubUserName = process.env.DEV_HUB_USER_NAME || this._devHubUserName;
this._extensionPath = process.env.EXTENSION_PATH || this._extensionPath;
this._throttleFactor = parseInt(process.env.THROTTLE_FACTOR!) || this._throttleFactor;
this._sfdxAuthUrl = process.env.SFDX_AUTH_URL || this._sfdxAuthUrl;
this._orgId = process.env.ORG_ID || this._orgId;
this._extensionPath = process.env.SALESFORCEDX_VSCODE_EXTENSIONS_PATH || this._extensionPath;
this._logLevel = LOG_LEVELS.some(l => l === process.env.E2E_LOG_LEVEL)
? (process.env.E2E_LOG_LEVEL as LogLevel)
: this._logLevel;
this._javaHome = process.env.JAVA_HOME || this._javaHome;
this.useExistingProject = process.env.USE_EXISTING_PROJECT_PATH;
}
public static getInstance(): EnvironmentSettings {
if (!EnvironmentSettings._instance) {
EnvironmentSettings._instance = new EnvironmentSettings();
}
return EnvironmentSettings._instance;
}
public get vscodeVersion(): string {
return this._vscodeVersion;
}
public get specFiles(): string[] {
return this._specFiles;
}
public get devHubAliasName(): string {
return this._devHubAliasName;
}
public get devHubUserName(): string {
return this._devHubUserName;
}
public get extensionPath(): string {
return this._extensionPath;
}
public get throttleFactor(): number {
return this._throttleFactor;
}
public get startTime(): string {
return this._startTime;
}
public get sfdxAuthUrl(): string | undefined {
return this._sfdxAuthUrl;
}
public get orgId(): string | undefined {
return this._orgId;
}
public get javaHome(): string | undefined {
return this._javaHome;
}
public get useExistingProject(): string | undefined {
return this._useExistingProject;
}
public set useExistingProject(existingProject: string | undefined) {
const projectPath = existingProject ?? process.env.USE_EXISTING_PROJECT_PATH;
if (!projectPath) {
this._useExistingProject = undefined;
return;
}
if (!fs.existsSync(projectPath)) {
throw new Error(`Project path for "${projectPath}" does not exist`);
}
this._useExistingProject = projectPath;
}
public get logLevel(): LogLevel {
return this._logLevel;
}
}