-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathenvironment-config.js
More file actions
122 lines (109 loc) · 2.77 KB
/
environment-config.js
File metadata and controls
122 lines (109 loc) · 2.77 KB
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
/**
* Environment Configuration Utility
* Centralized access to environment variables with proper defaults
*/
/**
* Get the Vizzly home directory from environment
* Used to override the default ~/.vizzly directory for storing auth, project mappings, etc.
* Useful for development (separate dev/prod configs) or testing (isolated test configs)
* @returns {string|undefined} Custom home directory path
*/
export function getVizzlyHome() {
return process.env.VIZZLY_HOME;
}
/**
* Get API token from environment
* @returns {string|undefined} API token
*/
export function getApiToken() {
return process.env.VIZZLY_TOKEN;
}
/**
* Get API URL from environment
* @returns {string} API URL with default
*/
export function getApiUrl() {
return process.env.VIZZLY_API_URL || 'https://app.vizzly.dev';
}
/**
* Get log level from environment
* @returns {string} Log level with default
*/
export function getLogLevel() {
return process.env.VIZZLY_LOG_LEVEL || 'info';
}
/**
* Get user agent from environment
* @returns {string|undefined} User agent string
*/
export function getUserAgent() {
return process.env.VIZZLY_USER_AGENT;
}
/**
* Check if Vizzly is enabled in client
* @returns {boolean} Whether Vizzly is enabled
*/
export function isVizzlyEnabled() {
return process.env.VIZZLY_ENABLED === 'true';
}
/**
* Get server URL from environment
* @returns {string|undefined} Server URL
*/
export function getServerUrl() {
return process.env.VIZZLY_SERVER_URL;
}
/**
* Get build ID from environment
* @returns {string|undefined} Build ID
*/
export function getBuildId() {
return process.env.VIZZLY_BUILD_ID;
}
/**
* Get parallel ID from environment
* @returns {string|undefined} Parallel ID
*/
export function getParallelId() {
return process.env.VIZZLY_PARALLEL_ID;
}
/**
* Get build name from environment
* @returns {string|undefined} Build name
*/
export function getBuildName() {
return process.env.VIZZLY_BUILD_NAME;
}
/**
* Check if TDD mode is enabled
* @returns {boolean} Whether TDD mode is enabled
*/
export function isTddMode() {
return process.env.VIZZLY_TDD === 'true';
}
/**
* Set Vizzly enabled state (for client)
* @param {boolean} enabled - Whether to enable Vizzly
*/
export function setVizzlyEnabled(enabled) {
process.env.VIZZLY_ENABLED = enabled ? 'true' : 'false';
}
/**
* Get all Vizzly environment variables
* @returns {Object} All environment configuration
*/
export function getAllEnvironmentConfig() {
return {
home: getVizzlyHome(),
apiToken: getApiToken(),
apiUrl: getApiUrl(),
logLevel: getLogLevel(),
userAgent: getUserAgent(),
enabled: isVizzlyEnabled(),
serverUrl: getServerUrl(),
buildId: getBuildId(),
buildName: getBuildName(),
parallelId: getParallelId(),
tddMode: isTddMode(),
};
}