-
Notifications
You must be signed in to change notification settings - Fork 3
/
environmentSettings.ts
162 lines (138 loc) · 5.11 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
* 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 path from 'path';
import { fileURLToPath } from 'url';
import { LOG_LEVELS, LogLevel } from './utilities/constants.ts';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export class EnvironmentSettings {
private static _instance: EnvironmentSettings;
private _vscodeVersion = 'stable';
private _specFiles = [
'./specs/**/*.e2e.ts'
// OR
// './specs/**/anInitialSuite.e2e.ts',
// './specs/**/apexLsp.e2e.ts',
// './specs/**/apexReplayDebugger.e2e.ts',
// './specs/**/auraLsp.e2e.ts',
// './specs/**/authentication.e2e.ts',
// './specs/**/debugApexTests.e2e.ts',
// './specs/**/debugLwcTests.e2e.ts',
// './specs/**/deployAndRetrieve.e2e.ts',
// './specs/**/lwcLsp.e2e.ts',
// './specs/**/manifestBuilder.e2e.ts',
// './specs/**/miscellaneous.e2e.ts',
// './specs/**/orgBrowser.e2e.ts',
// './specs/**/pushAndPull.e2e.ts',
// './specs/**/runApexTests.e2e.ts',
// './specs/**/runLwcTests.e2e.ts',
// './specs/**/soql.e2e.ts',
// './specs/**/sfdxProjectJson.e2e.ts',
// './specs/**/sObjectsDefinitions.e2e.ts',
// './specs/**/templates.e2e.ts',
// './specs/**/trailApexReplayDebugger.e2e.ts',
// './specs/**/visualforceLsp.e2e.ts',
// './specs/**/createProjectTest.e2e.ts',
// './specs/**/metadataDeployRetrieve.e2e.ts',
];
private _devHubAliasName = 'vscodeOrg';
private _devHubUserName = '[email protected]';
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 _localProjectPath: string | undefined;
private _githubProjectUrl: string | undefined;
private _logLevel: LogLevel = 'warn';
private constructor() {
this._vscodeVersion = process.env.VSCODE_VERSION || this._vscodeVersion;
if (process.env.SPEC_FILES) {
this._specFiles = ['./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.localProjectPath = process.env.LOCAL_PROJECT_PATH;
this.githubProjectUrl = process.env.GITHUB_PROJECT_URL;
}
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 localProjectPath(): string | undefined {
return this._localProjectPath;
}
public get githubProjectUrl(): string | undefined {
return this._githubProjectUrl;
}
public set localProjectPath(localPath: string | undefined) {
const projectPath = localPath ?? process.env.LOCAL_PROJECT_PATH;
if (!projectPath) {
this._localProjectPath = undefined;
return;
}
if (!fs.existsSync(projectPath)) {
throw new Error(`Project path for "${projectPath}" does not exist`);
}
this._localProjectPath = projectPath;
}
public set githubProjectUrl(githubUrl: string | undefined) {
const repoUrl = githubUrl ?? process.env.GITHUB_PROJECT_URL;
if (!repoUrl) {
this._githubProjectUrl = undefined;
return;
}
this._githubProjectUrl = repoUrl;
}
public get logLevel(): LogLevel {
return this._logLevel;
}
}