1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const axios_1 = require("axios");
|
4 | const path = require("path");
|
5 | const constants_1 = require("../services/constants");
|
6 | const logger_1 = require("./logger");
|
7 | function agentJsFilename() {
|
8 | try {
|
9 | return require.resolve('@percy/agent/dist/public/percy-agent.js');
|
10 | }
|
11 | catch (_a) {
|
12 | return path.resolve(__dirname, '../../dist/public/percy-agent.js');
|
13 | }
|
14 | }
|
15 | exports.agentJsFilename = agentJsFilename;
|
16 | async function isAgentRunning() {
|
17 | return axios_1.default({
|
18 | method: 'get',
|
19 | url: `http://localhost:${constants_1.default.PORT}${constants_1.default.HEALTHCHECK_PATH}`,
|
20 | }).then(() => {
|
21 | return true;
|
22 | }).catch((error) => {
|
23 | return false;
|
24 | });
|
25 | }
|
26 | exports.isAgentRunning = isAgentRunning;
|
27 | async function postSnapshot(body) {
|
28 | const URL = `http://localhost:${constants_1.default.PORT}${constants_1.default.SNAPSHOT_PATH}`;
|
29 | const ONE_HUNDRED_MB_IN_BYTES = 100000000;
|
30 | return axios_1.default({
|
31 | method: 'post',
|
32 | maxContentLength: ONE_HUNDRED_MB_IN_BYTES,
|
33 | url: URL,
|
34 | data: body,
|
35 | }).then(() => {
|
36 | return true;
|
37 | }).catch((error) => {
|
38 | logger_1.logError(error);
|
39 | return false;
|
40 | });
|
41 | }
|
42 | exports.postSnapshot = postSnapshot;
|