@vizzly-testing/cli 0.13.2 → 0.13.4

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.
@@ -9,6 +9,7 @@ const PROJECT_ROOT = join(__dirname, '..', '..');
9
9
  const logger = createServiceLogger('HTTP-SERVER');
10
10
  export const createHttpServer = (port, screenshotHandler, services = {}) => {
11
11
  let server = null;
12
+ let defaultBuildId = services.buildId || null;
12
13
 
13
14
  // Extract services for config/auth/project management
14
15
  let configService = services.configService;
@@ -355,8 +356,9 @@ export const createHttpServer = (port, screenshotHandler, services = {}) => {
355
356
  return;
356
357
  }
357
358
 
358
- // Use default buildId if none provided
359
- const effectiveBuildId = buildId || 'default';
359
+ // Use buildId from request body, or fall back to server's buildId (set during server creation)
360
+ // If neither is available, this is an error - buildId is required for cloud uploads
361
+ const effectiveBuildId = buildId || defaultBuildId;
360
362
  const result = await screenshotHandler.handleScreenshot(effectiveBuildId, name, image, properties);
361
363
  res.statusCode = result.statusCode;
362
364
  res.end(JSON.stringify(result.body));
@@ -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);
@@ -29,10 +31,42 @@ export class ServerManager extends BaseService {
29
31
  const apiService = await this.createApiService();
30
32
  this.handler = createApiHandler(apiService);
31
33
  }
32
- this.httpServer = createHttpServer(port, this.handler, this.services);
34
+
35
+ // Pass buildId in services so http-server can use it as default
36
+ const servicesWithBuildId = {
37
+ ...this.services,
38
+ buildId: this.buildId
39
+ };
40
+ this.httpServer = createHttpServer(port, this.handler, servicesWithBuildId);
33
41
  if (this.httpServer) {
34
42
  await this.httpServer.start();
35
43
  }
44
+
45
+ // Write server info to .vizzly/server.json for SDK discovery
46
+ // This allows SDKs that can't access environment variables (like Swift/iOS)
47
+ // to discover both the server port and current build ID
48
+ try {
49
+ const vizzlyDir = join(process.cwd(), '.vizzly');
50
+ mkdirSync(vizzlyDir, {
51
+ recursive: true
52
+ });
53
+ const serverFile = join(vizzlyDir, 'server.json');
54
+ const serverInfo = {
55
+ port: port.toString(),
56
+ pid: process.pid,
57
+ startTime: Date.now()
58
+ };
59
+
60
+ // Include buildId if we have one (for `vizzly run` mode)
61
+ if (this.buildId) {
62
+ serverInfo.buildId = this.buildId;
63
+ }
64
+ writeFileSync(serverFile, JSON.stringify(serverInfo, null, 2));
65
+ this.logger.debug(`Wrote server info to ${serverFile}`);
66
+ } catch (error) {
67
+ // Non-fatal - SDK can still use health check or environment variables
68
+ this.logger.debug(`Failed to write server.json: ${error.message}`);
69
+ }
36
70
  }
37
71
  async createApiService() {
38
72
  if (!this.config.apiKey) return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizzly-testing/cli",
3
- "version": "0.13.2",
3
+ "version": "0.13.4",
4
4
  "description": "Visual review platform for UI developers and designers",
5
5
  "keywords": [
6
6
  "visual-testing",