@percy/core 1.32.5-beta.1 → 1.32.5
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 =
|
|
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 =
|
|
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: /
|
|
76
|
-
// BrowserStack iOS: /
|
|
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
|
-
|
|
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
|
|
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 /
|
|
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' ?
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/core",
|
|
3
|
-
"version": "1.32.5
|
|
3
|
+
"version": "1.32.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public",
|
|
12
|
-
"tag": "
|
|
12
|
+
"tag": "latest"
|
|
13
13
|
},
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=14"
|
|
@@ -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
|
|
50
|
-
"@percy/config": "1.32.5
|
|
51
|
-
"@percy/dom": "1.32.5
|
|
52
|
-
"@percy/logger": "1.32.5
|
|
53
|
-
"@percy/monitoring": "1.32.5
|
|
54
|
-
"@percy/webdriver-utils": "1.32.5
|
|
49
|
+
"@percy/client": "1.32.5",
|
|
50
|
+
"@percy/config": "1.32.5",
|
|
51
|
+
"@percy/dom": "1.32.5",
|
|
52
|
+
"@percy/logger": "1.32.5",
|
|
53
|
+
"@percy/monitoring": "1.32.5",
|
|
54
|
+
"@percy/webdriver-utils": "1.32.5",
|
|
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
|
|
70
|
+
"@percy/cli-doctor": "1.32.5"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "1c83908c5913e3fab1cdd7207db49a2e0c27a3e9"
|
|
73
73
|
}
|