Skip to content

Commit

Permalink
Merge branch 'pac-file-support' into tests-pac-file
Browse files Browse the repository at this point in the history
  • Loading branch information
surya91521 committed Nov 26, 2024
2 parents a83b690 + 4d36bd8 commit a341324
Show file tree
Hide file tree
Showing 20 changed files with 102 additions and 54 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.30.3-alpha.0",
"version": "1.30.3-alpha.3",
"packages": [
"packages/*"
],
Expand Down
6 changes: 3 additions & 3 deletions packages/cli-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/cli-app",
"version": "1.30.3-alpha.0",
"version": "1.30.3-alpha.3",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -33,7 +33,7 @@
]
},
"dependencies": {
"@percy/cli-command": "1.30.3-alpha.0",
"@percy/cli-exec": "1.30.3-alpha.0"
"@percy/cli-command": "1.30.3-alpha.3",
"@percy/cli-exec": "1.30.3-alpha.3"
}
}
4 changes: 2 additions & 2 deletions packages/cli-build/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/cli-build",
"version": "1.30.3-alpha.0",
"version": "1.30.3-alpha.3",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -33,6 +33,6 @@
]
},
"dependencies": {
"@percy/cli-command": "1.30.3-alpha.0"
"@percy/cli-command": "1.30.3-alpha.3"
}
}
8 changes: 4 additions & 4 deletions packages/cli-command/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/cli-command",
"version": "1.30.3-alpha.0",
"version": "1.30.3-alpha.3",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -36,8 +36,8 @@
"test:coverage": "yarn test --coverage"
},
"dependencies": {
"@percy/config": "1.30.3-alpha.0",
"@percy/core": "1.30.3-alpha.0",
"@percy/logger": "1.30.3-alpha.0"
"@percy/config": "1.30.3-alpha.3",
"@percy/core": "1.30.3-alpha.3",
"@percy/logger": "1.30.3-alpha.3"
}
}
4 changes: 2 additions & 2 deletions packages/cli-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/cli-config",
"version": "1.30.3-alpha.0",
"version": "1.30.3-alpha.3",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -33,6 +33,6 @@
]
},
"dependencies": {
"@percy/cli-command": "1.30.3-alpha.0"
"@percy/cli-command": "1.30.3-alpha.3"
}
}
6 changes: 3 additions & 3 deletions packages/cli-exec/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/cli-exec",
"version": "1.30.3-alpha.0",
"version": "1.30.3-alpha.3",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -33,8 +33,8 @@
]
},
"dependencies": {
"@percy/cli-command": "1.30.3-alpha.0",
"@percy/logger": "1.30.3-alpha.0",
"@percy/cli-command": "1.30.3-alpha.3",
"@percy/logger": "1.30.3-alpha.3",
"cross-spawn": "^7.0.3",
"which": "^2.0.2"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/cli-snapshot/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/cli-snapshot",
"version": "1.30.3-alpha.0",
"version": "1.30.3-alpha.3",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -33,7 +33,7 @@
]
},
"dependencies": {
"@percy/cli-command": "1.30.3-alpha.0",
"@percy/cli-command": "1.30.3-alpha.3",
"yaml": "^2.0.0"
}
}
4 changes: 2 additions & 2 deletions packages/cli-upload/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/cli-upload",
"version": "1.30.3-alpha.0",
"version": "1.30.3-alpha.3",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -33,7 +33,7 @@
]
},
"dependencies": {
"@percy/cli-command": "1.30.3-alpha.0",
"@percy/cli-command": "1.30.3-alpha.3",
"fast-glob": "^3.2.11",
"image-size": "^1.0.0"
}
Expand Down
20 changes: 10 additions & 10 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/cli",
"version": "1.30.3-alpha.0",
"version": "1.30.3-alpha.3",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -31,14 +31,14 @@
"test:coverage": "yarn test --coverage"
},
"dependencies": {
"@percy/cli-app": "1.30.3-alpha.0",
"@percy/cli-build": "1.30.3-alpha.0",
"@percy/cli-command": "1.30.3-alpha.0",
"@percy/cli-config": "1.30.3-alpha.0",
"@percy/cli-exec": "1.30.3-alpha.0",
"@percy/cli-snapshot": "1.30.3-alpha.0",
"@percy/cli-upload": "1.30.3-alpha.0",
"@percy/client": "1.30.3-alpha.0",
"@percy/logger": "1.30.3-alpha.0"
"@percy/cli-app": "1.30.3-alpha.3",
"@percy/cli-build": "1.30.3-alpha.3",
"@percy/cli-command": "1.30.3-alpha.3",
"@percy/cli-config": "1.30.3-alpha.3",
"@percy/cli-exec": "1.30.3-alpha.3",
"@percy/cli-snapshot": "1.30.3-alpha.3",
"@percy/cli-upload": "1.30.3-alpha.3",
"@percy/client": "1.30.3-alpha.3",
"@percy/logger": "1.30.3-alpha.3"
}
}
6 changes: 3 additions & 3 deletions packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/client",
"version": "1.30.3-alpha.0",
"version": "1.30.3-alpha.3",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -33,8 +33,8 @@
"test:coverage": "yarn test --coverage"
},
"dependencies": {
"@percy/env": "1.30.3-alpha.0",
"@percy/logger": "1.30.3-alpha.0",
"@percy/env": "1.30.3-alpha.3",
"@percy/logger": "1.30.3-alpha.3",
"pac-proxy-agent": "^7.0.2",
"pako": "^2.1.0"
}
Expand Down
7 changes: 5 additions & 2 deletions packages/client/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export function waitForTimeout() {

// Returns the package.json content at the package path.
export function getPackageJSON(rel) {
/* istanbul ignore else: sanity check */
if (process.env.PERCY_FORCE_EXECUTABLE_DIRNAME) rel = __dirname;

/* istanbul ignore else: sanity check */
if (rel.startsWith('file:')) rel = url.fileURLToPath(rel);

Expand Down Expand Up @@ -135,8 +138,8 @@ export async function request(url, options = {}, callback) {
let { protocol, hostname, port, pathname, search, hash } = new URL(url);

// reference the default export so tests can mock it
// bundling cli inside electron (LCNC) fails if we import it like
// this: await import(protocol === 'https:' ? 'https' : 'http');
// bundling cli inside electron or another package fails if we import it
// like this: await import(protocol === 'https:' ? 'https' : 'http');
let { default: http } = protocol === 'https:' ? await import('https') : await import('http');
let { proxyAgentFor } = await import('./proxy.js');

Expand Down
4 changes: 2 additions & 2 deletions packages/config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/config",
"version": "1.30.3-alpha.0",
"version": "1.30.3-alpha.3",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -38,7 +38,7 @@
"test:types": "tsd"
},
"dependencies": {
"@percy/logger": "1.30.3-alpha.0",
"@percy/logger": "1.30.3-alpha.3",
"ajv": "^8.6.2",
"cosmiconfig": "^8.0.0",
"yaml": "^2.0.0"
Expand Down
12 changes: 6 additions & 6 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/core",
"version": "1.30.3-alpha.0",
"version": "1.30.3-alpha.3",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -43,11 +43,11 @@
"test:types": "tsd"
},
"dependencies": {
"@percy/client": "1.30.3-alpha.0",
"@percy/config": "1.30.3-alpha.0",
"@percy/dom": "1.30.3-alpha.0",
"@percy/logger": "1.30.3-alpha.0",
"@percy/webdriver-utils": "1.30.3-alpha.0",
"@percy/client": "1.30.3-alpha.3",
"@percy/config": "1.30.3-alpha.3",
"@percy/dom": "1.30.3-alpha.3",
"@percy/logger": "1.30.3-alpha.3",
"@percy/webdriver-utils": "1.30.3-alpha.3",
"content-disposition": "^0.5.4",
"cross-spawn": "^7.0.3",
"extract-zip": "^2.0.1",
Expand Down
16 changes: 12 additions & 4 deletions packages/core/src/api.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import fs from 'fs';
import path from 'path';
import { createRequire } from 'module';
import path, { dirname, resolve } from 'path';
import logger from '@percy/logger';
import { normalize } from '@percy/config/utils';
import { getPackageJSON, Server, percyAutomateRequestHandler, percyBuildEventHandler } from './utils.js';
import WebdriverUtils from '@percy/webdriver-utils';
import { handleSyncJob } from './snapshot.js';
// need require.resolve until import.meta.resolve can be transpiled
export const PERCY_DOM = createRequire(import.meta.url).resolve('@percy/dom');
// Previously, we used `createRequire(import.meta.url).resolve` to resolve the path to the module.
// This approach relied on `createRequire`, which is Node.js-specific and less compatible with modern ESM (ECMAScript Module) standards.
// This was leading to hard coded paths when CLI is used as a dependency in another project.
// Now, we use `fileURLToPath` and `path.resolve` to determine the absolute path in a way that's more aligned with ESM conventions.
// This change ensures better compatibility and avoids relying on Node.js-specific APIs that might cause issues in ESM environments.
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

export const PERCY_DOM = resolve(__dirname, 'node_modules/@percy/dom');

// Returns a URL encoded string of nested query params
function encodeURLSearchParams(subj, prefix) {
Expand Down
37 changes: 37 additions & 0 deletions packages/core/src/findRevision.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

function download_url {
if [[ "$OS" == "Linux" ]]; then
echo "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2F${1}%2Fchrome-linux.zip?alt=media"
elif [[ "$OS" == "Mac" ]] || [[ "$OS" == "Mac_Arm" ]]; then
echo "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/$OS%2F${1}%2Fchrome-mac.zip?alt=media"
elif [[ "$OS" == "Win" ]] || [[ "$OS" == "Win_x64" ]]; then
echo "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/$OS%2F${1}%2Fchrome-win.zip?alt=media"
fi
}

function get_closest_rev {
while true; do
curl -I 2>/dev/null `download_url $REVISION` | head -1 | grep 404 >/dev/null
if (($? == 1)); then
break
fi
REVISION=$(($REVISION-1))
done
echo $REVISION
}


if (($# < 1)); then
printf "usage: \n"
printf " ./get_chromuim [-r] rev - will get chromium by revision\n"
exit 1
fi

export REVISION=$1

for os in "Linux" "Mac" "Mac_Arm" "Win" "Win_x64";
do
export OS=$os
echo "$OS" `get_closest_rev`
done
2 changes: 1 addition & 1 deletion packages/dom/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/dom",
"version": "1.30.3-alpha.0",
"version": "1.30.3-alpha.3",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions packages/env/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/env",
"version": "1.30.3-alpha.0",
"version": "1.30.3-alpha.3",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -32,6 +32,6 @@
"test:coverage": "yarn test --coverage"
},
"dependencies": {
"@percy/logger": "1.30.3-alpha.0"
"@percy/logger": "1.30.3-alpha.3"
}
}
2 changes: 1 addition & 1 deletion packages/logger/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/logger",
"version": "1.30.3-alpha.0",
"version": "1.30.3-alpha.3",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/sdk-utils",
"version": "1.30.3-alpha.0",
"version": "1.30.3-alpha.3",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
6 changes: 3 additions & 3 deletions packages/webdriver-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@percy/webdriver-utils",
"version": "1.30.3-alpha.0",
"version": "1.30.3-alpha.3",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -29,7 +29,7 @@
"test:coverage": "yarn test --coverage"
},
"dependencies": {
"@percy/config": "1.30.3-alpha.0",
"@percy/sdk-utils": "1.30.3-alpha.0"
"@percy/config": "1.30.3-alpha.3",
"@percy/sdk-utils": "1.30.3-alpha.3"
}
}

0 comments on commit a341324

Please sign in to comment.