@vizzly-testing/cli 0.13.2 → 0.13.3
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.
|
@@ -7,6 +7,8 @@ import { BaseService } from './base-service.js';
|
|
|
7
7
|
import { createHttpServer } from '../server/http-server.js';
|
|
8
8
|
import { createTddHandler } from '../server/handlers/tdd-handler.js';
|
|
9
9
|
import { createApiHandler } from '../server/handlers/api-handler.js';
|
|
10
|
+
import { writeFileSync, mkdirSync } from 'fs';
|
|
11
|
+
import { join } from 'path';
|
|
10
12
|
export class ServerManager extends BaseService {
|
|
11
13
|
constructor(config, options = {}) {
|
|
12
14
|
super(config, options);
|
|
@@ -33,6 +35,32 @@ export class ServerManager extends BaseService {
|
|
|
33
35
|
if (this.httpServer) {
|
|
34
36
|
await this.httpServer.start();
|
|
35
37
|
}
|
|
38
|
+
|
|
39
|
+
// Write server info to .vizzly/server.json for SDK discovery
|
|
40
|
+
// This allows SDKs that can't access environment variables (like Swift/iOS)
|
|
41
|
+
// to discover both the server port and current build ID
|
|
42
|
+
try {
|
|
43
|
+
const vizzlyDir = join(process.cwd(), '.vizzly');
|
|
44
|
+
mkdirSync(vizzlyDir, {
|
|
45
|
+
recursive: true
|
|
46
|
+
});
|
|
47
|
+
const serverFile = join(vizzlyDir, 'server.json');
|
|
48
|
+
const serverInfo = {
|
|
49
|
+
port: port.toString(),
|
|
50
|
+
pid: process.pid,
|
|
51
|
+
startTime: Date.now()
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// Include buildId if we have one (for `vizzly run` mode)
|
|
55
|
+
if (this.buildId) {
|
|
56
|
+
serverInfo.buildId = this.buildId;
|
|
57
|
+
}
|
|
58
|
+
writeFileSync(serverFile, JSON.stringify(serverInfo, null, 2));
|
|
59
|
+
this.logger.debug(`Wrote server info to ${serverFile}`);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
// Non-fatal - SDK can still use health check or environment variables
|
|
62
|
+
this.logger.debug(`Failed to write server.json: ${error.message}`);
|
|
63
|
+
}
|
|
36
64
|
}
|
|
37
65
|
async createApiService() {
|
|
38
66
|
if (!this.config.apiKey) return null;
|