@percy/core 1.30.2 → 1.30.3-alpha.1
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/api.js +10 -3
- package/dist/findRevision.sh +37 -0
- package/dist/timing.js +21 -0
- package/package.json +8 -8
package/dist/api.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { createRequire } from 'module';
|
|
4
3
|
import logger from '@percy/logger';
|
|
5
4
|
import { normalize } from '@percy/config/utils';
|
|
6
5
|
import { getPackageJSON, Server, percyAutomateRequestHandler, percyBuildEventHandler } from './utils.js';
|
|
7
6
|
import WebdriverUtils from '@percy/webdriver-utils';
|
|
8
7
|
import { handleSyncJob } from './snapshot.js';
|
|
9
|
-
//
|
|
10
|
-
|
|
8
|
+
// Previously, we used `createRequire(import.meta.url).resolve` to resolve the path to the module.
|
|
9
|
+
// This approach relied on `createRequire`, which is Node.js-specific and less compatible with modern ESM (ECMAScript Module) standards.
|
|
10
|
+
// This was leading to hard coded paths when CLI is used as a dependency in another project.
|
|
11
|
+
// Now, we use `fileURLToPath` and `path.resolve` to determine the absolute path in a way that's more aligned with ESM conventions.
|
|
12
|
+
// This change ensures better compatibility and avoids relying on Node.js-specific APIs that might cause issues in ESM environments.
|
|
13
|
+
import { fileURLToPath } from 'url';
|
|
14
|
+
import { dirname, resolve } from 'path';
|
|
15
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
+
const __dirname = dirname(__filename);
|
|
17
|
+
export const PERCY_DOM = resolve(__dirname, 'node_modules/@percy/dom');
|
|
11
18
|
|
|
12
19
|
// Returns a URL encoded string of nested query params
|
|
13
20
|
function encodeURLSearchParams(subj, prefix) {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
function download_url {
|
|
4
|
+
if [[ "$OS" == "Linux" ]]; then
|
|
5
|
+
echo "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2F${1}%2Fchrome-linux.zip?alt=media"
|
|
6
|
+
elif [[ "$OS" == "Mac" ]] || [[ "$OS" == "Mac_Arm" ]]; then
|
|
7
|
+
echo "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/$OS%2F${1}%2Fchrome-mac.zip?alt=media"
|
|
8
|
+
elif [[ "$OS" == "Win" ]] || [[ "$OS" == "Win_x64" ]]; then
|
|
9
|
+
echo "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/$OS%2F${1}%2Fchrome-win.zip?alt=media"
|
|
10
|
+
fi
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function get_closest_rev {
|
|
14
|
+
while true; do
|
|
15
|
+
curl -I 2>/dev/null `download_url $REVISION` | head -1 | grep 404 >/dev/null
|
|
16
|
+
if (($? == 1)); then
|
|
17
|
+
break
|
|
18
|
+
fi
|
|
19
|
+
REVISION=$(($REVISION-1))
|
|
20
|
+
done
|
|
21
|
+
echo $REVISION
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
if (($# < 1)); then
|
|
26
|
+
printf "usage: \n"
|
|
27
|
+
printf " ./get_chromuim [-r] rev - will get chromium by revision\n"
|
|
28
|
+
exit 1
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
export REVISION=$1
|
|
32
|
+
|
|
33
|
+
for os in "Linux" "Mac" "Mac_Arm" "Win" "Win_x64";
|
|
34
|
+
do
|
|
35
|
+
export OS=$os
|
|
36
|
+
echo "$OS" `get_closest_rev`
|
|
37
|
+
done
|
package/dist/timing.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import logger from '@percy/logger';
|
|
2
|
+
export default class TimeIt {
|
|
3
|
+
log = logger('timer');
|
|
4
|
+
// returns a singleton instance
|
|
5
|
+
constructor() {
|
|
6
|
+
let {
|
|
7
|
+
instance = this
|
|
8
|
+
} = this.constructor;
|
|
9
|
+
this.constructor.instance = instance;
|
|
10
|
+
return instance;
|
|
11
|
+
}
|
|
12
|
+
async measure(name, identifier, callback) {
|
|
13
|
+
const startTime = Date.now();
|
|
14
|
+
try {
|
|
15
|
+
return await callback();
|
|
16
|
+
} finally {
|
|
17
|
+
const duration = Date.now() - startTime;
|
|
18
|
+
this.log.debug(`${name} - ${identifier} - ${duration / 1000}s`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/core",
|
|
3
|
-
"version": "1.30.
|
|
3
|
+
"version": "1.30.3-alpha.1",
|
|
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": "alpha"
|
|
13
13
|
},
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=14"
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"test:types": "tsd"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@percy/client": "1.30.
|
|
47
|
-
"@percy/config": "1.30.
|
|
48
|
-
"@percy/dom": "1.30.
|
|
49
|
-
"@percy/logger": "1.30.
|
|
50
|
-
"@percy/webdriver-utils": "1.30.
|
|
46
|
+
"@percy/client": "1.30.3-alpha.1",
|
|
47
|
+
"@percy/config": "1.30.3-alpha.1",
|
|
48
|
+
"@percy/dom": "1.30.3-alpha.1",
|
|
49
|
+
"@percy/logger": "1.30.3-alpha.1",
|
|
50
|
+
"@percy/webdriver-utils": "1.30.3-alpha.1",
|
|
51
51
|
"content-disposition": "^0.5.4",
|
|
52
52
|
"cross-spawn": "^7.0.3",
|
|
53
53
|
"extract-zip": "^2.0.1",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"ws": "^8.17.1",
|
|
61
61
|
"yaml": "^2.4.1"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "e342330feb6be33e7234149a344faa50d1903da7"
|
|
64
64
|
}
|