@applitools/core-base
Advanced tools
Comparing version 1.13.0 to 1.14.0
# Changelog | ||
## [1.14.0](https://github.com/Applitools-Dev/sdk/compare/js/core-base@1.13.0...js/core-base@1.14.0) (2024-05-07) | ||
### Features | ||
* expose git latest commit info in env vars ([#2349](https://github.com/Applitools-Dev/sdk/issues/2349)) ([1db248c](https://github.com/Applitools-Dev/sdk/commit/1db248c83ee1cbc83f905163fe5bd63dd5e293c2)) | ||
* long eyes requests with custom domain ([#2343](https://github.com/Applitools-Dev/sdk/issues/2343)) ([d54beea](https://github.com/Applitools-Dev/sdk/commit/d54beea8c33a56a0516904773daaa5095340fd12)) | ||
## [1.13.0](https://github.com/Applitools-Dev/sdk/compare/js/core-base@1.12.1...js/core-base@1.13.0) (2024-05-01) | ||
@@ -4,0 +12,0 @@ |
@@ -43,6 +43,10 @@ "use strict"; | ||
return async function openEyes({ settings, logger = mainLogger, }) { | ||
var _a, _b; | ||
var _a, _b, _c; | ||
logger = logger.extend(mainLogger, { tags: [`eyes-base-${utils.general.shortid()}`] }); | ||
settings.latestCommitInfo = await (0, extract_current_commit_1.extractLatestCommitInfo)({ execOptions: { cwd }, logger }); | ||
(_a = settings.processId) !== null && _a !== void 0 ? _a : (settings.processId = heartbeat.processId); | ||
(_a = settings.latestCommitInfo) !== null && _a !== void 0 ? _a : (settings.latestCommitInfo = await (0, extract_current_commit_1.extractLatestCommitInfo)({ execOptions: { cwd }, logger })); | ||
if (settings.latestCommitInfo && !isISODate(settings.latestCommitInfo.timestamp)) { | ||
logger.warn(`latestCommitInfo.timestamp is an invalid ISO date string: ${settings.latestCommitInfo.timestamp}`); | ||
settings.latestCommitInfo = undefined; | ||
} | ||
(_b = settings.processId) !== null && _b !== void 0 ? _b : (settings.processId = heartbeat.processId); | ||
if (settings.ignoreGitBranching) { | ||
@@ -55,3 +59,3 @@ settings.gitBranchingTimestamp = undefined; | ||
try { | ||
if (!branchName && !parentBranchName && ((_b = settings.batch) === null || _b === void 0 ? void 0 : _b.id) && !settings.batch.id.startsWith('generated')) { | ||
if (!branchName && !parentBranchName && ((_c = settings.batch) === null || _c === void 0 ? void 0 : _c.id) && !settings.batch.id.startsWith('generated')) { | ||
const branches = await requests.getBatchBranches({ settings: { ...settings, batchId: settings.batch.id } }); | ||
@@ -75,2 +79,6 @@ branchName = branches.branchName; | ||
} | ||
if (settings.gitBranchingTimestamp && !isISODate(settings.gitBranchingTimestamp)) { | ||
logger.warn(`gitBranchingTimestamp is an invalid ISO date string: ${settings.gitBranchingTimestamp}`); | ||
settings.gitBranchingTimestamp = undefined; | ||
} | ||
settings.agentId = `${defaultAgentId} ${settings.agentId ? `[${settings.agentId}]` : ''}`.trim(); | ||
@@ -107,1 +115,4 @@ logger.log('Command "openEyes" is called with settings', settings); | ||
exports.makeOpenEyes = makeOpenEyes; | ||
function isISODate(str) { | ||
return /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\+\d{2}:\d{2})?/.test(str); | ||
} |
@@ -26,5 +26,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.makeReqEyes = void 0; | ||
exports.updateOriginAndPath = exports.makeReqEyes = void 0; | ||
const req_1 = __importStar(require("@applitools/req")); | ||
const utils = __importStar(require("@applitools/utils")); | ||
const path = __importStar(require("path")); | ||
function makeReqEyes({ settings, fetch, logger }) { | ||
@@ -54,3 +55,3 @@ var _a; | ||
], | ||
hooks: [handleLongRequests({ req: req_1.default }), handleLogs({ logger }), handleUnexpectedResponse()], | ||
hooks: [handleLongRequests({ req: req_1.default, settings }), handleLogs({ logger }), handleUnexpectedResponse()], | ||
fetch, | ||
@@ -110,3 +111,3 @@ }); | ||
} | ||
function handleLongRequests({ req }) { | ||
function handleLongRequests({ req, settings }) { | ||
return { | ||
@@ -124,3 +125,4 @@ beforeRequest({ request }) { | ||
// polling for result | ||
const pollResponse = await req(response.headers.get('Location'), options !== null && options !== void 0 ? options : {}, { | ||
const location = updateOriginAndPath(response.headers.get('Location'), settings.eyesServerUrl); | ||
const pollResponse = await req(location, options !== null && options !== void 0 ? options : {}, { | ||
method: 'GET', | ||
@@ -138,3 +140,4 @@ body: undefined, | ||
if (response && response.status === 200 && response.headers.has('Location')) { | ||
return { request, url: response.headers.get('Location') }; | ||
const location = updateOriginAndPath(response.headers.get('Location'), settings.eyesServerUrl); | ||
return { request, url: location }; | ||
} | ||
@@ -147,3 +150,4 @@ }, | ||
// getting result of the initial request | ||
return await req(pollResponse.headers.get('Location'), options !== null && options !== void 0 ? options : {}, { | ||
const resultLocation = updateOriginAndPath(pollResponse.headers.get('Location'), settings.eyesServerUrl); | ||
return await req(resultLocation, options !== null && options !== void 0 ? options : {}, { | ||
method: 'DELETE', | ||
@@ -156,1 +160,12 @@ expected: undefined, | ||
} | ||
function updateOriginAndPath(url, originalUrl) { | ||
const updatedUrl = new URL(url); | ||
const originalURL = new URL(originalUrl); | ||
if (updatedUrl.host === originalURL.host) | ||
return url; | ||
updatedUrl.protocol = originalURL.protocol; | ||
updatedUrl.host = originalURL.host; | ||
updatedUrl.pathname = path.posix.join(originalURL.pathname, updatedUrl.pathname); | ||
return updatedUrl.href; | ||
} | ||
exports.updateOriginAndPath = updateOriginAndPath; |
{ | ||
"name": "@applitools/core-base", | ||
"version": "1.13.0", | ||
"version": "1.14.0", | ||
"homepage": "https://applitools.com", | ||
@@ -5,0 +5,0 @@ "bugs": { |
@@ -19,1 +19,2 @@ import type { EyesServerSettings } from '../types'; | ||
}): Req<ReqEyesOptions>; | ||
export declare function updateOriginAndPath(url: string, originalUrl: string): string; |
178426
3031
30