@vizzly-testing/cli 0.24.1 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/plugin-api.js
CHANGED
|
@@ -9,10 +9,13 @@
|
|
|
9
9
|
* exposed to plugins to prevent coupling to implementation details.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import { detectBranch, detectCommit, detectCommitMessage, detectPullRequestNumber, generateBuildNameWithGit } from './utils/git.js';
|
|
13
|
+
|
|
12
14
|
/**
|
|
13
15
|
* Creates a stable plugin services object from the internal services
|
|
14
16
|
*
|
|
15
17
|
* Only exposes:
|
|
18
|
+
* - git: Git information detection (branch, commit, PR number, etc.)
|
|
16
19
|
* - testRunner: Build lifecycle management (createBuild, finalizeBuild, events)
|
|
17
20
|
* - serverManager: Screenshot server control (start, stop)
|
|
18
21
|
*
|
|
@@ -25,6 +28,29 @@ export function createPluginServices(services) {
|
|
|
25
28
|
serverManager
|
|
26
29
|
} = services;
|
|
27
30
|
return Object.freeze({
|
|
31
|
+
// Git detection utilities - provides correct git info from CI environments
|
|
32
|
+
git: Object.freeze({
|
|
33
|
+
/**
|
|
34
|
+
* Detect git information for build creation
|
|
35
|
+
* Handles CI environment variables correctly (GitHub Actions, GitLab, etc.)
|
|
36
|
+
*
|
|
37
|
+
* @param {Object} [options] - Detection options
|
|
38
|
+
* @param {string} [options.buildPrefix] - Prefix for generated build name
|
|
39
|
+
* @returns {Promise<Object>} Git info: { branch, commit, message, prNumber, buildName }
|
|
40
|
+
*/
|
|
41
|
+
async detect(options = {}) {
|
|
42
|
+
let [branch, commit, message] = await Promise.all([detectBranch(), detectCommit(), detectCommitMessage()]);
|
|
43
|
+
let prNumber = detectPullRequestNumber();
|
|
44
|
+
let buildName = await generateBuildNameWithGit(options.buildPrefix);
|
|
45
|
+
return {
|
|
46
|
+
branch,
|
|
47
|
+
commit,
|
|
48
|
+
message,
|
|
49
|
+
prNumber,
|
|
50
|
+
buildName
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}),
|
|
28
54
|
testRunner: Object.freeze({
|
|
29
55
|
// EventEmitter methods for build lifecycle events
|
|
30
56
|
once: testRunner.once.bind(testRunner),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
2
|
import { cosmiconfigSync } from 'cosmiconfig';
|
|
3
3
|
import { validateVizzlyConfigWithDefaults } from './config-schema.js';
|
|
4
|
-
import { getApiToken, getApiUrl, getParallelId } from './environment-config.js';
|
|
4
|
+
import { getApiToken, getApiUrl, getBuildName, getParallelId } from './environment-config.js';
|
|
5
5
|
import { getProjectMapping } from './global-config.js';
|
|
6
6
|
import * as output from './output.js';
|
|
7
7
|
const DEFAULT_CONFIG = {
|
|
@@ -98,12 +98,17 @@ export async function loadConfig(configPath = null, cliOverrides = {}) {
|
|
|
98
98
|
// 4. Override with environment variables (higher priority than fallbacks)
|
|
99
99
|
const envApiKey = getApiToken();
|
|
100
100
|
const envApiUrl = getApiUrl();
|
|
101
|
+
const envBuildName = getBuildName();
|
|
101
102
|
const envParallelId = getParallelId();
|
|
102
103
|
if (envApiKey) {
|
|
103
104
|
config.apiKey = envApiKey;
|
|
104
105
|
output.debug('config', 'using token from environment');
|
|
105
106
|
}
|
|
106
107
|
if (envApiUrl !== 'https://app.vizzly.dev') config.apiUrl = envApiUrl;
|
|
108
|
+
if (envBuildName) {
|
|
109
|
+
config.build.name = envBuildName;
|
|
110
|
+
output.debug('config', 'using build name from environment');
|
|
111
|
+
}
|
|
107
112
|
if (envParallelId) config.parallelId = envParallelId;
|
|
108
113
|
|
|
109
114
|
// 5. Apply CLI overrides (highest priority)
|
|
@@ -77,6 +77,14 @@ export function getParallelId() {
|
|
|
77
77
|
return process.env.VIZZLY_PARALLEL_ID;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Get build name from environment
|
|
82
|
+
* @returns {string|undefined} Build name
|
|
83
|
+
*/
|
|
84
|
+
export function getBuildName() {
|
|
85
|
+
return process.env.VIZZLY_BUILD_NAME;
|
|
86
|
+
}
|
|
87
|
+
|
|
80
88
|
/**
|
|
81
89
|
* Check if TDD mode is enabled
|
|
82
90
|
* @returns {boolean} Whether TDD mode is enabled
|
|
@@ -107,6 +115,7 @@ export function getAllEnvironmentConfig() {
|
|
|
107
115
|
enabled: isVizzlyEnabled(),
|
|
108
116
|
serverUrl: getServerUrl(),
|
|
109
117
|
buildId: getBuildId(),
|
|
118
|
+
buildName: getBuildName(),
|
|
110
119
|
parallelId: getParallelId(),
|
|
111
120
|
tddMode: isTddMode()
|
|
112
121
|
};
|