@percy/core 1.32.5-beta.1 → 1.32.6-beta.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.
@@ -2,6 +2,19 @@ import fs from 'fs';
2
2
  import path from 'path';
3
3
  import { ServerError } from './server.js';
4
4
 
5
+ // Root under which BrowserStack App Automate hosts write Maestro session
6
+ // artifacts (screenshots + debug output). Historically /tmp; hosts that
7
+ // relocate it inject PERCY_APP_AUTOMATE_TMP_DIR with the new root, so the
8
+ // location is never hardcoded here and can move again without a CLI release.
9
+ // Trailing separators are trimmed so glob patterns and the realpath prefix
10
+ // check compose cleanly; a non-absolute value falls back to /tmp rather than
11
+ // producing a cwd-relative glob. BrowserStack-mode only — self-hosted scoping
12
+ // stays on PERCY_MAESTRO_SCREENSHOT_DIR.
13
+ export function appAutomateTmpDir() {
14
+ let dir = (process.env.PERCY_APP_AUTOMATE_TMP_DIR || '/tmp').replace(/[/\\]+$/, '');
15
+ return path.isAbsolute(dir) ? dir : '/tmp';
16
+ }
17
+
5
18
  /* istanbul ignore next — defensive manual directory walker invoked only when
6
19
  fast-glob import fails (broken install / FS corruption). Unit tests
7
20
  exercise the primary glob path; integration tests on BS hosts exercise
@@ -12,7 +25,7 @@ async function manualScreenshotWalk(platform, sessionId, name) {
12
25
  const files = [];
13
26
  try {
14
27
  if (platform === 'ios') {
15
- const sessionDir = `/tmp/${sessionId}`;
28
+ const sessionDir = `${appAutomateTmpDir()}/${sessionId}`;
16
29
  const walk = async (dir, depth) => {
17
30
  if (depth > 15) return; // sanity cap
18
31
  let entries;
@@ -34,7 +47,7 @@ async function manualScreenshotWalk(platform, sessionId, name) {
34
47
  };
35
48
  await walk(sessionDir, 0);
36
49
  } else {
37
- const baseDir = `/tmp/${sessionId}_test_suite/logs`;
50
+ const baseDir = `${appAutomateTmpDir()}/${sessionId}_test_suite/logs`;
38
51
  const logDirs = await fs.promises.readdir(baseDir);
39
52
  for (const dir of logDirs) {
40
53
  const screenshotPath = path.join(baseDir, dir, 'screenshots', `${name}.png`);
@@ -71,9 +84,9 @@ export async function locateScreenshot({
71
84
  if (filePath) {
72
85
  chosenFile = filePath;
73
86
  } else {
74
- // Glob pattern depends on deployment shape:
75
- // BrowserStack Android: /tmp/{sid}_test_suite/logs/*/screenshots/{name}.png
76
- // BrowserStack iOS: /tmp/{sid}/<maestro_debug_dir>/**/{name}.png
87
+ // Glob pattern depends on deployment shape (TMP = appAutomateTmpDir()):
88
+ // BrowserStack Android: {TMP}/{sid}_test_suite/logs/*/screenshots/{name}.png
89
+ // BrowserStack iOS: {TMP}/{sid}/<maestro_debug_dir>/**/{name}.png
77
90
  // (realmobile builds a deeply nested {device}_maestro_debug_ tree; `**`
78
91
  // handles any depth, exact {name}.png filters Maestro's emoji-prefixed
79
92
  // debug frames, e.g. `screenshot-❌-<timestamp>-(flow).png`).
@@ -88,7 +101,10 @@ export async function locateScreenshot({
88
101
  const globRoot = scopeRoot.replace(/\\/g, '/');
89
102
  searchPattern = `${globRoot}/**/${name}.png`;
90
103
  } else {
91
- searchPattern = platform === 'ios' ? `/tmp/${sessionId}/*_maestro_debug_*/**/${name}.png` : `/tmp/${sessionId}_test_suite/logs/*/screenshots/${name}.png`;
104
+ // Same forward-slash normalization as the self-hosted branch — the env
105
+ // override could carry backslashes when exercised on Windows CI.
106
+ const tmpRoot = appAutomateTmpDir().replace(/\\/g, '/');
107
+ searchPattern = platform === 'ios' ? `${tmpRoot}/${sessionId}/*_maestro_debug_*/**/${name}.png` : `${tmpRoot}/${sessionId}_test_suite/logs/*/screenshots/${name}.png`;
92
108
  }
93
109
  let files;
94
110
  try {
@@ -145,7 +161,8 @@ export async function locateScreenshot({
145
161
 
146
162
  // Canonicalize and confirm the resolved path still lives under scopeRoot.
147
163
  // Defeats symlink swaps where the root points elsewhere. Both ends are
148
- // realpath'd because /tmp is a symlink on macOS (where iOS hosts run). The
164
+ // realpath'd because the tmp root can resolve through a symlink (as /tmp
165
+ // does on macOS, where iOS hosts run). The
149
166
  // trailing `/` on the prefix is load-bearing — it prevents sibling-prefix
150
167
  // bypass (e.g. /x/.maestro vs /x/.maestro-secrets). Both sides are
151
168
  // normalized to forward-slashes so the check works on Windows (real-fs
@@ -4,7 +4,7 @@ import { normalize } from '@percy/config/utils';
4
4
  import { ServerError } from './server.js';
5
5
  import { encodeURLSearchParams } from './utils.js';
6
6
  import { handleSyncJob } from './snapshot.js';
7
- import { locateScreenshot } from './maestro-screenshot-file.js';
7
+ import { locateScreenshot, appAutomateTmpDir } from './maestro-screenshot-file.js';
8
8
  import { validateRegionInputs, resolveRegions } from './maestro-regions.js';
9
9
  import { deriveDeviceInsets } from './maestro-hierarchy.js';
10
10
 
@@ -95,7 +95,8 @@ export async function handleMaestroScreenshot(req, res, percy) {
95
95
  }
96
96
 
97
97
  // Resolve the file-find scope root. On BrowserStack (sessionId present), the
98
- // root is the BS host's /tmp/{sessionId}{_test_suite} convention. Self-hosted
98
+ // root is the BS host's {appAutomateTmpDir()}/{sessionId}{_test_suite}
99
+ // convention (PERCY_APP_AUTOMATE_TMP_DIR, defaulting to /tmp). Self-hosted
99
100
  // (sessionId absent) requires PERCY_MAESTRO_SCREENSHOT_DIR (read from
100
101
  // process.env, never the request body) to be an absolute, existing directory
101
102
  // — typically the customer's `maestro test --test-output-dir <DIR>` path. The
@@ -133,7 +134,7 @@ export async function handleMaestroScreenshot(req, res, percy) {
133
134
  }
134
135
  scopeRoot = dir;
135
136
  } else {
136
- scopeRoot = platform === 'ios' ? `/tmp/${sessionId}` : `/tmp/${sessionId}_test_suite`;
137
+ scopeRoot = platform === 'ios' ? `${appAutomateTmpDir()}/${sessionId}` : `${appAutomateTmpDir()}/${sessionId}_test_suite`;
137
138
  }
138
139
 
139
140
  // Validate regions input shape early (before file I/O and ADB work) so
package/dist/snapshot.js CHANGED
@@ -449,13 +449,19 @@ export function createSnapshotsQueue(percy) {
449
449
  });
450
450
  let url = data.attributes['web-url'];
451
451
  let number = data.attributes['build-number'];
452
+ // Server-decided build source, exposed via /percy/healthcheck so SDKs can key on it.
453
+ // Only assigned when the API returned one — a `source: undefined` key would drop out
454
+ // of JSON responses, breaking shape equality for clients.
455
+ let source = data.attributes.source;
452
456
  let usageWarning = data.attributes['usage-warning'];
453
457
  percy.client.buildType = (_data$attributes = data.attributes) === null || _data$attributes === void 0 ? void 0 : _data$attributes.type;
454
458
  Object.assign(build, {
455
459
  id: data.id,
456
460
  url,
457
461
  number
458
- });
462
+ }, source ? {
463
+ source
464
+ } : {});
459
465
 
460
466
  // Display usage warning if present
461
467
  if (usageWarning) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/core",
3
- "version": "1.32.5-beta.1",
3
+ "version": "1.32.6-beta.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,12 +46,12 @@
46
46
  "dependencies": {
47
47
  "@grpc/grpc-js": "^1.14.3",
48
48
  "@grpc/proto-loader": "^0.8.0",
49
- "@percy/client": "1.32.5-beta.1",
50
- "@percy/config": "1.32.5-beta.1",
51
- "@percy/dom": "1.32.5-beta.1",
52
- "@percy/logger": "1.32.5-beta.1",
53
- "@percy/monitoring": "1.32.5-beta.1",
54
- "@percy/webdriver-utils": "1.32.5-beta.1",
49
+ "@percy/client": "1.32.6-beta.0",
50
+ "@percy/config": "1.32.6-beta.0",
51
+ "@percy/dom": "1.32.6-beta.0",
52
+ "@percy/logger": "1.32.6-beta.0",
53
+ "@percy/monitoring": "1.32.6-beta.0",
54
+ "@percy/webdriver-utils": "1.32.6-beta.0",
55
55
  "adm-zip": "^0.6.0",
56
56
  "busboy": "^1.6.0",
57
57
  "content-disposition": "^0.5.4",
@@ -67,7 +67,7 @@
67
67
  "yaml": "^2.4.1"
68
68
  },
69
69
  "optionalDependencies": {
70
- "@percy/cli-doctor": "1.32.5-beta.1"
70
+ "@percy/cli-doctor": "1.32.6-beta.0"
71
71
  },
72
- "gitHead": "ef91ddef69f7e693bff6cfa3d4136e38450d635a"
72
+ "gitHead": "735e1589b696e9b74f52d9cb0944c6bc0af889b2"
73
73
  }