bdy 1.10.14 → 1.11.0-dev
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/distTs/bin/cli.js +1 -1
- package/distTs/package.json +1 -1
- package/distTs/src/agent/agent.js +302 -0
- package/distTs/src/agent/manager.js +41 -41
- package/distTs/src/agent/socket/client.js +159 -0
- package/distTs/src/agent/socket/tunnel.js +3 -3
- package/distTs/src/agent/wait.js +2 -2
- package/distTs/src/command/agent/disable.js +1 -1
- package/distTs/src/command/agent/enable.js +1 -1
- package/distTs/src/command/agent/install.js +45 -45
- package/distTs/src/command/agent/restart.js +8 -8
- package/distTs/src/command/agent/start.js +8 -8
- package/distTs/src/command/agent/status.js +15 -15
- package/distTs/src/command/agent/stop.js +8 -8
- package/distTs/src/command/agent/target/disable.js +1 -1
- package/distTs/src/command/agent/target/enable.js +1 -1
- package/distTs/src/command/agent/target/status.js +1 -1
- package/distTs/src/command/agent/tunnel/http.js +18 -18
- package/distTs/src/command/agent/tunnel/list.js +7 -7
- package/distTs/src/command/agent/tunnel/remove.js +9 -9
- package/distTs/src/command/agent/tunnel/start.js +14 -14
- package/distTs/src/command/agent/tunnel/status.js +11 -11
- package/distTs/src/command/agent/tunnel/tcp.js +19 -19
- package/distTs/src/command/agent/tunnel/tls.js +17 -17
- package/distTs/src/command/agent/tunnel.js +16 -16
- package/distTs/src/command/agent/uninstall.js +13 -13
- package/distTs/src/command/agent/update.js +12 -12
- package/distTs/src/command/agent/version.js +6 -6
- package/distTs/src/command/agent.js +18 -18
- package/distTs/src/command/config/add/http.js +15 -15
- package/distTs/src/command/config/add/tcp.js +15 -15
- package/distTs/src/command/config/add/tls.js +15 -15
- package/distTs/src/command/config/add.js +8 -8
- package/distTs/src/command/config/get/region.js +5 -5
- package/distTs/src/command/config/get/timeout.js +5 -5
- package/distTs/src/command/config/get/token.js +5 -5
- package/distTs/src/command/config/get/tunnel.js +9 -9
- package/distTs/src/command/config/get/tunnels.js +6 -6
- package/distTs/src/command/config/get/whitelist.js +5 -5
- package/distTs/src/command/config/get.js +14 -14
- package/distTs/src/command/config/remove/tunnel.js +9 -9
- package/distTs/src/command/config/remove.js +4 -4
- package/distTs/src/command/config/set/region.js +8 -8
- package/distTs/src/command/config/set/timeout.js +9 -9
- package/distTs/src/command/config/set/token.js +7 -7
- package/distTs/src/command/config/set/whitelist.js +8 -8
- package/distTs/src/command/config/set.js +10 -10
- package/distTs/src/command/pre.js +14 -14
- package/distTs/src/command/tunnel/config.js +17 -0
- package/distTs/src/command/tunnel/http.js +30 -0
- package/distTs/src/command/tunnel/start.js +28 -0
- package/distTs/src/command/tunnel/tcp.js +30 -0
- package/distTs/src/command/tunnel/tls.js +30 -0
- package/distTs/src/command/tunnel.js +19 -0
- package/distTs/src/command/ut/upload.js +6 -6
- package/distTs/src/command/ut.js +3 -2
- package/distTs/src/command/version.js +4 -4
- package/distTs/src/command/vt/close.js +4 -4
- package/distTs/src/command/vt/compare.js +16 -16
- package/distTs/src/command/vt/exec.js +12 -12
- package/distTs/src/command/vt/installBrowser.js +2 -2
- package/distTs/src/command/vt/scrap.js +17 -17
- package/distTs/src/command/vt/storybook.js +8 -8
- package/distTs/src/command/vt.js +5 -4
- package/distTs/src/index.js +12 -20
- package/distTs/src/input.js +38 -38
- package/distTs/src/logger.js +2 -2
- package/distTs/src/output.js +14 -14
- package/distTs/src/texts.js +5 -4
- package/distTs/src/tunnel/agent.js +3 -3
- package/distTs/src/tunnel/api/agent.js +99 -0
- package/distTs/src/tunnel/api/buddy.js +139 -0
- package/distTs/src/tunnel/cfg.js +234 -0
- package/distTs/src/tunnel/http/log.js +3 -3
- package/distTs/src/tunnel/http.js +29 -29
- package/distTs/src/tunnel/identification.js +13 -13
- package/distTs/src/tunnel/latency.js +3 -3
- package/distTs/src/tunnel/output/interactive/tunnel.js +860 -0
- package/distTs/src/tunnel/output/noninteractive/agent/tunnels.js +43 -0
- package/distTs/src/tunnel/output/noninteractive/config/tunnel.js +65 -0
- package/distTs/src/tunnel/output/noninteractive/config/tunnels.js +18 -0
- package/distTs/src/tunnel/output/noninteractive/tunnel.js +59 -0
- package/distTs/src/tunnel/server/cert.js +52 -0
- package/distTs/src/tunnel/server/http1.js +75 -0
- package/distTs/src/tunnel/server/http2.js +78 -0
- package/distTs/src/tunnel/server/sftp.js +497 -0
- package/distTs/src/tunnel/server/ssh.js +446 -0
- package/distTs/src/tunnel/server/tls.js +41 -0
- package/distTs/src/tunnel/ssh/client.js +197 -0
- package/distTs/src/tunnel/tcp.js +3 -3
- package/distTs/src/tunnel/tunnel.js +656 -0
- package/distTs/src/utils.js +2 -2
- package/distTs/src/visualTest/ci.js +10 -10
- package/distTs/src/visualTest/context.js +4 -4
- package/distTs/src/visualTest/requests.js +71 -71
- package/distTs/src/visualTest/resources.js +5 -5
- package/distTs/src/visualTest/server.js +9 -9
- package/distTs/src/visualTest/snapshots.js +18 -18
- package/distTs/src/visualTest/validation.js +3 -3
- package/package.json +1 -1
|
@@ -8,8 +8,8 @@ exports.getCommitHash = getCommitHash;
|
|
|
8
8
|
exports.getCiAndGitInfo = getCiAndGitInfo;
|
|
9
9
|
exports.logCiInfo = logCiInfo;
|
|
10
10
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const exec_1 = require("./exec");
|
|
12
|
+
const ciInfo_1 = require("../types/ciInfo");
|
|
13
13
|
const output_1 = __importDefault(require("../output"));
|
|
14
14
|
const texts_1 = require("../texts");
|
|
15
15
|
async function getGithubPullRequestCommit() {
|
|
@@ -43,7 +43,7 @@ async function getGithubPullRequestCommit() {
|
|
|
43
43
|
async function getBranchName(optional) {
|
|
44
44
|
let branch = '';
|
|
45
45
|
try {
|
|
46
|
-
branch = await (0,
|
|
46
|
+
branch = await (0, exec_1.gitExec)(['rev-parse', '--abbrev-ref', 'HEAD']);
|
|
47
47
|
}
|
|
48
48
|
catch (error) {
|
|
49
49
|
if (!optional) {
|
|
@@ -62,7 +62,7 @@ async function getBranchName(optional) {
|
|
|
62
62
|
async function getCommitHash(optional) {
|
|
63
63
|
let commit = '';
|
|
64
64
|
try {
|
|
65
|
-
commit = await (0,
|
|
65
|
+
commit = await (0, exec_1.gitExec)(['rev-parse', '--verify', 'HEAD']);
|
|
66
66
|
}
|
|
67
67
|
catch (error) {
|
|
68
68
|
if (!optional) {
|
|
@@ -95,7 +95,7 @@ async function getBaseCommit(baseBranch, headBranch, requiredOriginPrefix) {
|
|
|
95
95
|
const preparedBaseBranch = requiredOriginPrefix && !baseBranch.includes('origin/')
|
|
96
96
|
? `origin/${baseBranch}`
|
|
97
97
|
: baseBranch;
|
|
98
|
-
commit = await (0,
|
|
98
|
+
commit = await (0, exec_1.gitExec)(['merge-base', preparedBranch, preparedBaseBranch]);
|
|
99
99
|
}
|
|
100
100
|
catch (error) {
|
|
101
101
|
output_1.default.warning((0, texts_1.ERR_GETTING_BASE_COMMIT)(baseBranch, headBranch, JSON.stringify(error)));
|
|
@@ -110,7 +110,7 @@ async function getBaseCommit(baseBranch, headBranch, requiredOriginPrefix) {
|
|
|
110
110
|
async function getCommitDetails(commitHash) {
|
|
111
111
|
if (commitHash) {
|
|
112
112
|
try {
|
|
113
|
-
const commitDetails = await (0,
|
|
113
|
+
const commitDetails = await (0, exec_1.gitExec)([
|
|
114
114
|
'show',
|
|
115
115
|
'--no-patch',
|
|
116
116
|
'--pretty=%an%n%ae%n%ct%n%B',
|
|
@@ -159,7 +159,7 @@ async function getCiAndGitInfo({ baseBranch, skipBaseCommitDiscovery, }) {
|
|
|
159
159
|
const actionId = Number(process.env.BUDDY_ACTION_ID);
|
|
160
160
|
const executionId = process.env.BUDDY_RUN_HASH;
|
|
161
161
|
return {
|
|
162
|
-
ci:
|
|
162
|
+
ci: ciInfo_1.CI.BUDDY,
|
|
163
163
|
branch,
|
|
164
164
|
tag,
|
|
165
165
|
pullRequestNumber: isPR ? pullRequestNumber : undefined,
|
|
@@ -189,7 +189,7 @@ async function getCiAndGitInfo({ baseBranch, skipBaseCommitDiscovery, }) {
|
|
|
189
189
|
: forceBaseCommit ||
|
|
190
190
|
(isPR ? await getBaseCommit(baseBranch, branch, true) : undefined);
|
|
191
191
|
return {
|
|
192
|
-
ci:
|
|
192
|
+
ci: ciInfo_1.CI.GITHUB_ACTION,
|
|
193
193
|
branch,
|
|
194
194
|
tag,
|
|
195
195
|
pullRequestNumber,
|
|
@@ -212,7 +212,7 @@ async function getCiAndGitInfo({ baseBranch, skipBaseCommitDiscovery, }) {
|
|
|
212
212
|
: forceBaseCommit ||
|
|
213
213
|
(isPR ? await getBaseCommit(baseBranch, branch) : undefined);
|
|
214
214
|
return {
|
|
215
|
-
ci:
|
|
215
|
+
ci: ciInfo_1.CI.CIRCLE_CI,
|
|
216
216
|
branch,
|
|
217
217
|
tag,
|
|
218
218
|
pullRequestNumber,
|
|
@@ -225,7 +225,7 @@ async function getCiAndGitInfo({ baseBranch, skipBaseCommitDiscovery, }) {
|
|
|
225
225
|
const branch = forceBranch || (await getBranchName(withoutBaseCommit));
|
|
226
226
|
const commit = forceCommit || (await getCommitHash(withoutBaseCommit));
|
|
227
227
|
return {
|
|
228
|
-
ci:
|
|
228
|
+
ci: ciInfo_1.CI.NONE,
|
|
229
229
|
branch,
|
|
230
230
|
commit,
|
|
231
231
|
baseCommit: withoutBaseCommit
|
|
@@ -5,7 +5,7 @@ exports.setExecOptions = setExecOptions;
|
|
|
5
5
|
exports.setBrowserPath = setBrowserPath;
|
|
6
6
|
exports.setCiAndCommitInfo = setCiAndCommitInfo;
|
|
7
7
|
const uuid_1 = require("uuid");
|
|
8
|
-
const
|
|
8
|
+
const ciInfo_1 = require("../types/ciInfo");
|
|
9
9
|
const utils_1 = require("../utils");
|
|
10
10
|
exports.cliVersion = (0, utils_1.getVersion)();
|
|
11
11
|
exports.oneByOne = false;
|
|
@@ -15,7 +15,7 @@ exports.token = process.env.BUDDY_VT_TOKEN || '';
|
|
|
15
15
|
exports.buildId = process.env.SNAPSHOTS_BUILD_ID || (0, uuid_1.v4)();
|
|
16
16
|
exports.cliId = (0, uuid_1.v4)();
|
|
17
17
|
exports.defaultTimeout = Number(process.env.SNAPSHOTS_DEFAULT_TIMEOUT) || 60_000;
|
|
18
|
-
exports.ci =
|
|
18
|
+
exports.ci = ciInfo_1.CI.NONE;
|
|
19
19
|
exports.debug = process.env.DEBUG === '1';
|
|
20
20
|
function setExecOptions(options) {
|
|
21
21
|
if (options.oneByOne) {
|
|
@@ -39,14 +39,14 @@ function setCiAndCommitInfo(ciInfo) {
|
|
|
39
39
|
exports.commit = ciInfo.commit;
|
|
40
40
|
exports.baseCommit = ciInfo.baseCommit;
|
|
41
41
|
exports.commitDetails = ciInfo.commitDetails;
|
|
42
|
-
if (ciInfo.ci ===
|
|
42
|
+
if (ciInfo.ci === ciInfo_1.CI.BUDDY) {
|
|
43
43
|
exports.pipelineId = ciInfo.pipelineId;
|
|
44
44
|
exports.actionId = ciInfo.actionId;
|
|
45
45
|
exports.executionId = ciInfo.executionId;
|
|
46
46
|
exports.invokerId = ciInfo.invokerId;
|
|
47
47
|
exports.pipelineName = ciInfo.pipelineName;
|
|
48
48
|
}
|
|
49
|
-
if (ciInfo.ci ===
|
|
49
|
+
if (ciInfo.ci === ciInfo_1.CI.GITHUB_ACTION || ciInfo.ci === ciInfo_1.CI.CIRCLE_CI) {
|
|
50
50
|
exports.executionUrl = ciInfo.executionUrl;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -12,7 +12,7 @@ exports.sendCompareLinks = sendCompareLinks;
|
|
|
12
12
|
exports.sendScrap = sendScrap;
|
|
13
13
|
exports.downloadScrapPackage = downloadScrapPackage;
|
|
14
14
|
exports.connectToScrapSession = connectToScrapSession;
|
|
15
|
-
const
|
|
15
|
+
const context_1 = require("./context");
|
|
16
16
|
const undici_1 = require("undici");
|
|
17
17
|
const uuid_1 = require("uuid");
|
|
18
18
|
const node_fs_1 = require("node:fs");
|
|
@@ -24,7 +24,7 @@ function getServiceUrl() {
|
|
|
24
24
|
if (customServiceUrl) {
|
|
25
25
|
return customServiceUrl;
|
|
26
26
|
}
|
|
27
|
-
if (
|
|
27
|
+
if (context_1.token.startsWith('bud_vt_eu')) {
|
|
28
28
|
return 'https://vt.eu.buddy.works';
|
|
29
29
|
}
|
|
30
30
|
return 'https://vt.buddy.works';
|
|
@@ -71,22 +71,22 @@ async function sendSnapshot(snapshot, firstSnapshot) {
|
|
|
71
71
|
const preparedSnapshot = prepareSnapshot(snapshot, files);
|
|
72
72
|
const info = {
|
|
73
73
|
snapshot: preparedSnapshot,
|
|
74
|
-
buildId:
|
|
75
|
-
parallel:
|
|
76
|
-
ci:
|
|
77
|
-
branch:
|
|
78
|
-
tag:
|
|
79
|
-
pullRequestNumber:
|
|
80
|
-
commit:
|
|
81
|
-
baseCommit:
|
|
82
|
-
pipelineId:
|
|
83
|
-
pipelineName:
|
|
84
|
-
actionId:
|
|
85
|
-
executionId:
|
|
86
|
-
invokerId:
|
|
87
|
-
commitDetails:
|
|
88
|
-
cliId:
|
|
89
|
-
executionUrl:
|
|
74
|
+
buildId: context_1.buildId,
|
|
75
|
+
parallel: context_1.parallel,
|
|
76
|
+
ci: context_1.ci,
|
|
77
|
+
branch: context_1.branch,
|
|
78
|
+
tag: context_1.tag,
|
|
79
|
+
pullRequestNumber: context_1.pullRequestNumber,
|
|
80
|
+
commit: context_1.commit,
|
|
81
|
+
baseCommit: context_1.baseCommit,
|
|
82
|
+
pipelineId: context_1.pipelineId,
|
|
83
|
+
pipelineName: context_1.pipelineName,
|
|
84
|
+
actionId: context_1.actionId,
|
|
85
|
+
executionId: context_1.executionId,
|
|
86
|
+
invokerId: context_1.invokerId,
|
|
87
|
+
commitDetails: context_1.commitDetails,
|
|
88
|
+
cliId: context_1.cliId,
|
|
89
|
+
executionUrl: context_1.executionUrl,
|
|
90
90
|
firstSnapshot,
|
|
91
91
|
};
|
|
92
92
|
const formData = createFormData(info, files);
|
|
@@ -105,22 +105,22 @@ async function sendSnapshots(snapshots) {
|
|
|
105
105
|
const preparedSnapshots = snapshots.map((snapshot) => prepareSnapshot(snapshot, files));
|
|
106
106
|
const info = {
|
|
107
107
|
snapshots: preparedSnapshots,
|
|
108
|
-
buildId:
|
|
109
|
-
parallel:
|
|
110
|
-
ci:
|
|
111
|
-
branch:
|
|
112
|
-
tag:
|
|
113
|
-
pullRequestNumber:
|
|
114
|
-
commit:
|
|
115
|
-
baseCommit:
|
|
116
|
-
pipelineId:
|
|
117
|
-
pipelineName:
|
|
118
|
-
actionId:
|
|
119
|
-
executionId:
|
|
120
|
-
invokerId:
|
|
121
|
-
commitDetails:
|
|
122
|
-
cliId:
|
|
123
|
-
executionUrl:
|
|
108
|
+
buildId: context_1.buildId,
|
|
109
|
+
parallel: context_1.parallel,
|
|
110
|
+
ci: context_1.ci,
|
|
111
|
+
branch: context_1.branch,
|
|
112
|
+
tag: context_1.tag,
|
|
113
|
+
pullRequestNumber: context_1.pullRequestNumber,
|
|
114
|
+
commit: context_1.commit,
|
|
115
|
+
baseCommit: context_1.baseCommit,
|
|
116
|
+
pipelineId: context_1.pipelineId,
|
|
117
|
+
pipelineName: context_1.pipelineName,
|
|
118
|
+
actionId: context_1.actionId,
|
|
119
|
+
executionId: context_1.executionId,
|
|
120
|
+
invokerId: context_1.invokerId,
|
|
121
|
+
commitDetails: context_1.commitDetails,
|
|
122
|
+
cliId: context_1.cliId,
|
|
123
|
+
executionUrl: context_1.executionUrl,
|
|
124
124
|
firstSnapshot: true,
|
|
125
125
|
};
|
|
126
126
|
const formData = createFormData(info, files);
|
|
@@ -136,8 +136,8 @@ async function sendSnapshots(snapshots) {
|
|
|
136
136
|
}
|
|
137
137
|
async function closeSession() {
|
|
138
138
|
const payload = {
|
|
139
|
-
token:
|
|
140
|
-
buildId:
|
|
139
|
+
token: context_1.token,
|
|
140
|
+
buildId: context_1.buildId,
|
|
141
141
|
};
|
|
142
142
|
const [message] = await sendRequest({ url: '/close', payload });
|
|
143
143
|
if (!message) {
|
|
@@ -160,21 +160,21 @@ async function getDefaultSettings() {
|
|
|
160
160
|
async function sendStorybook(snapshots, filePaths) {
|
|
161
161
|
const info = {
|
|
162
162
|
snapshots,
|
|
163
|
-
buildId:
|
|
164
|
-
ci:
|
|
165
|
-
branch:
|
|
166
|
-
tag:
|
|
167
|
-
pullRequestNumber:
|
|
168
|
-
commit:
|
|
169
|
-
baseCommit:
|
|
170
|
-
pipelineId:
|
|
171
|
-
pipelineName:
|
|
172
|
-
actionId:
|
|
173
|
-
executionId:
|
|
174
|
-
invokerId:
|
|
175
|
-
commitDetails:
|
|
176
|
-
cliId:
|
|
177
|
-
executionUrl:
|
|
163
|
+
buildId: context_1.buildId,
|
|
164
|
+
ci: context_1.ci,
|
|
165
|
+
branch: context_1.branch,
|
|
166
|
+
tag: context_1.tag,
|
|
167
|
+
pullRequestNumber: context_1.pullRequestNumber,
|
|
168
|
+
commit: context_1.commit,
|
|
169
|
+
baseCommit: context_1.baseCommit,
|
|
170
|
+
pipelineId: context_1.pipelineId,
|
|
171
|
+
pipelineName: context_1.pipelineName,
|
|
172
|
+
actionId: context_1.actionId,
|
|
173
|
+
executionId: context_1.executionId,
|
|
174
|
+
invokerId: context_1.invokerId,
|
|
175
|
+
commitDetails: context_1.commitDetails,
|
|
176
|
+
cliId: context_1.cliId,
|
|
177
|
+
executionUrl: context_1.executionUrl,
|
|
178
178
|
};
|
|
179
179
|
const files = filePaths.map((file) => ({
|
|
180
180
|
id: file,
|
|
@@ -203,19 +203,19 @@ async function sendCompareLinks(urls, validatedOptions, sitemapSource) {
|
|
|
203
203
|
follow: validatedOptions.follow,
|
|
204
204
|
respectRobots: validatedOptions.respectRobots,
|
|
205
205
|
ignoreUrls: validatedOptions.ignoreUrls ?? [],
|
|
206
|
-
buildId:
|
|
207
|
-
ci:
|
|
208
|
-
branch:
|
|
209
|
-
tag:
|
|
210
|
-
commit:
|
|
211
|
-
baseCommit:
|
|
212
|
-
pipelineId:
|
|
213
|
-
pipelineName:
|
|
214
|
-
actionId:
|
|
215
|
-
executionId:
|
|
216
|
-
invokerId:
|
|
217
|
-
commitDetails:
|
|
218
|
-
cliId:
|
|
206
|
+
buildId: context_1.buildId,
|
|
207
|
+
ci: context_1.ci,
|
|
208
|
+
branch: context_1.branch,
|
|
209
|
+
tag: context_1.tag,
|
|
210
|
+
commit: context_1.commit,
|
|
211
|
+
baseCommit: context_1.baseCommit,
|
|
212
|
+
pipelineId: context_1.pipelineId,
|
|
213
|
+
pipelineName: context_1.pipelineName,
|
|
214
|
+
actionId: context_1.actionId,
|
|
215
|
+
executionId: context_1.executionId,
|
|
216
|
+
invokerId: context_1.invokerId,
|
|
217
|
+
commitDetails: context_1.commitDetails,
|
|
218
|
+
cliId: context_1.cliId,
|
|
219
219
|
};
|
|
220
220
|
const [message] = await sendRequest({
|
|
221
221
|
url: '/compareLinks',
|
|
@@ -257,7 +257,7 @@ async function sendScrap(url, outputType, follow, quality, fullPage, cssSelector
|
|
|
257
257
|
async function downloadScrapPackage(buildId) {
|
|
258
258
|
const [message, response] = await sendRequest({
|
|
259
259
|
url: '/download',
|
|
260
|
-
payload: { token:
|
|
260
|
+
payload: { token: context_1.token, buildId },
|
|
261
261
|
});
|
|
262
262
|
if (message) {
|
|
263
263
|
throw new Error(message);
|
|
@@ -273,16 +273,16 @@ async function sendRequest({ url, payload, multipart, }) {
|
|
|
273
273
|
method: 'GET',
|
|
274
274
|
redirect: 'follow',
|
|
275
275
|
headers: {
|
|
276
|
-
'X-CLI-VERSION':
|
|
277
|
-
'X-TOKEN':
|
|
276
|
+
'X-CLI-VERSION': context_1.cliVersion,
|
|
277
|
+
'X-TOKEN': context_1.token,
|
|
278
278
|
},
|
|
279
279
|
};
|
|
280
280
|
if (payload && !multipart) {
|
|
281
281
|
init.method = 'POST';
|
|
282
282
|
init.headers = {
|
|
283
283
|
'Content-Type': 'application/json',
|
|
284
|
-
'X-TOKEN':
|
|
285
|
-
'X-CLI-VERSION':
|
|
284
|
+
'X-TOKEN': context_1.token,
|
|
285
|
+
'X-CLI-VERSION': context_1.cliVersion,
|
|
286
286
|
};
|
|
287
287
|
init.body = JSON.stringify(payload);
|
|
288
288
|
}
|
|
@@ -315,8 +315,8 @@ function connectToScrapSession(buildId) {
|
|
|
315
315
|
...options,
|
|
316
316
|
headers: {
|
|
317
317
|
...options?.headers,
|
|
318
|
-
'x-token':
|
|
319
|
-
'x-cli-version':
|
|
318
|
+
'x-token': context_1.token,
|
|
319
|
+
'x-cli-version': context_1.cliVersion,
|
|
320
320
|
'x-build-id': buildId,
|
|
321
321
|
},
|
|
322
322
|
});
|
|
@@ -28,7 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.collectResources = collectResources;
|
|
30
30
|
const puppeteer_core_1 = __importStar(require("puppeteer-core"));
|
|
31
|
-
const
|
|
31
|
+
const context_1 = require("./context");
|
|
32
32
|
const output_1 = __importDefault(require("../output"));
|
|
33
33
|
const texts_1 = require("../texts");
|
|
34
34
|
const utils_1 = require("../utils");
|
|
@@ -133,7 +133,7 @@ async function scrapeResources({ url, devices, resourceDiscoveryTimeout, cookies
|
|
|
133
133
|
args: ['--no-sandbox'],
|
|
134
134
|
acceptInsecureCerts: true,
|
|
135
135
|
timeout: 120_000,
|
|
136
|
-
executablePath:
|
|
136
|
+
executablePath: context_1.browserPath,
|
|
137
137
|
};
|
|
138
138
|
const browser = await puppeteer_core_1.default.launch(launchOptions);
|
|
139
139
|
if (!showedBrowserVersionWarning) {
|
|
@@ -144,7 +144,7 @@ async function scrapeResources({ url, devices, resourceDiscoveryTimeout, cookies
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
const page = await browser.newPage();
|
|
147
|
-
page.setDefaultTimeout(
|
|
147
|
+
page.setDefaultTimeout(context_1.defaultTimeout);
|
|
148
148
|
const initWidth = devices[0].viewport.width;
|
|
149
149
|
await page.setViewport({
|
|
150
150
|
width: initWidth,
|
|
@@ -197,7 +197,7 @@ async function scrapeResources({ url, devices, resourceDiscoveryTimeout, cookies
|
|
|
197
197
|
await output_1.default.debugAction(texts_1.DEBUG_AUTO_WIDTH, autoWidths(page, devices));
|
|
198
198
|
if (resourceDiscoveryTimeout > 0) {
|
|
199
199
|
await new Promise((resolve) => setTimeout(resolve, resourceDiscoveryTimeout));
|
|
200
|
-
if (
|
|
200
|
+
if (context_1.debug) {
|
|
201
201
|
output_1.default.warning((0, texts_1.DEBUG_RESOURCE_DISCOVERY_TIMEOUT)(resourceDiscoveryTimeout));
|
|
202
202
|
}
|
|
203
203
|
}
|
|
@@ -206,7 +206,7 @@ async function scrapeResources({ url, devices, resourceDiscoveryTimeout, cookies
|
|
|
206
206
|
}
|
|
207
207
|
catch (error) {
|
|
208
208
|
if (error instanceof puppeteer_core_1.TimeoutError) {
|
|
209
|
-
output_1.default.warning((0, texts_1.DEBUG_WAIT_FOR_IDLE_TIMEOUT)(
|
|
209
|
+
output_1.default.warning((0, texts_1.DEBUG_WAIT_FOR_IDLE_TIMEOUT)(context_1.defaultTimeout));
|
|
210
210
|
}
|
|
211
211
|
else {
|
|
212
212
|
throw error;
|
|
@@ -6,15 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.createServer = createServer;
|
|
7
7
|
const fastify_1 = __importDefault(require("fastify"));
|
|
8
8
|
const cors_1 = __importDefault(require("@fastify/cors"));
|
|
9
|
-
const
|
|
9
|
+
const snapshots_1 = require("./snapshots");
|
|
10
10
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
11
11
|
const node_path_1 = __importDefault(require("node:path"));
|
|
12
12
|
const node_sea_1 = require("node:sea");
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
13
|
+
const utils_1 = require("../utils");
|
|
14
|
+
const output_1 = __importDefault(require("../output"));
|
|
15
|
+
const schemas_1 = require("../types/schemas");
|
|
16
16
|
const zod_1 = require("zod");
|
|
17
|
-
const
|
|
17
|
+
const texts_1 = require("../texts");
|
|
18
18
|
const port = 1337;
|
|
19
19
|
let cachedParseDom = '';
|
|
20
20
|
function prepareParseDom(parseDom) {
|
|
@@ -28,7 +28,7 @@ async function getParseDom() {
|
|
|
28
28
|
cachedParseDom = await prepareParseDom((0, node_sea_1.getAsset)('parseDom.js', 'utf8'));
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
|
-
const filePath = node_path_1.default.resolve((0,
|
|
31
|
+
const filePath = node_path_1.default.resolve((0, utils_1.getRootDir)(), 'parseDom.js');
|
|
32
32
|
cachedParseDom = await prepareParseDom(await promises_1.default.readFile(filePath, 'utf-8'));
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -36,7 +36,7 @@ async function getParseDom() {
|
|
|
36
36
|
}
|
|
37
37
|
function prepareSnapshotPlugin(data) {
|
|
38
38
|
try {
|
|
39
|
-
const validatedData =
|
|
39
|
+
const validatedData = schemas_1.snapshotSchema.parse(data);
|
|
40
40
|
const { version, ...snapshot } = validatedData;
|
|
41
41
|
const cookies = snapshot.cookies.map((cookie) => {
|
|
42
42
|
if (cookie.domain) {
|
|
@@ -70,7 +70,7 @@ function prepareSnapshotPlugin(data) {
|
|
|
70
70
|
? data.name
|
|
71
71
|
: 'Unknown name';
|
|
72
72
|
if (error instanceof zod_1.ZodError) {
|
|
73
|
-
|
|
73
|
+
output_1.default.error((0, texts_1.ERR_INVALID_SNAPSHOT)(name, error.errors
|
|
74
74
|
.map((e) => `${e.path.join('.')} - ${e.message}`)
|
|
75
75
|
.join(', ')));
|
|
76
76
|
}
|
|
@@ -94,7 +94,7 @@ async function createServer() {
|
|
|
94
94
|
const data = request.body;
|
|
95
95
|
const preparedSnapshot = prepareSnapshotPlugin(data);
|
|
96
96
|
if (preparedSnapshot) {
|
|
97
|
-
(0,
|
|
97
|
+
(0, snapshots_1.addSnapshot)(preparedSnapshot);
|
|
98
98
|
reply.send('Snapshot received');
|
|
99
99
|
}
|
|
100
100
|
else {
|
|
@@ -7,10 +7,10 @@ exports.setDefaultSettings = setDefaultSettings;
|
|
|
7
7
|
exports.addSnapshot = addSnapshot;
|
|
8
8
|
exports.finishProcessingSnapshots = finishProcessingSnapshots;
|
|
9
9
|
exports.showSessionLink = showSessionLink;
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
10
|
+
const resources_1 = require("./resources");
|
|
11
|
+
const context_1 = require("./context");
|
|
12
|
+
const requests_1 = require("./requests");
|
|
13
|
+
const queue_1 = require("./queue");
|
|
14
14
|
const output_1 = __importDefault(require("../output"));
|
|
15
15
|
const texts_1 = require("../texts");
|
|
16
16
|
const snapshots = [];
|
|
@@ -25,8 +25,8 @@ function addSnapshot(snapshot) {
|
|
|
25
25
|
...snapshot,
|
|
26
26
|
devices: snapshot.devices.length > 0 ? snapshot.devices : defaultDevices,
|
|
27
27
|
};
|
|
28
|
-
if (
|
|
29
|
-
(0,
|
|
28
|
+
if (context_1.oneByOne) {
|
|
29
|
+
(0, queue_1.addToQueue)(() => processSnapshot(preparedSnapshot, firstSnapshot));
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
32
|
snapshots.push(preparedSnapshot);
|
|
@@ -36,8 +36,8 @@ function addSnapshot(snapshot) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
async function finishProcessingSnapshots(spawnedProcessExitCode) {
|
|
39
|
-
if (
|
|
40
|
-
return await (0,
|
|
39
|
+
if (context_1.oneByOne) {
|
|
40
|
+
return await (0, queue_1.isQueueEmpty)();
|
|
41
41
|
}
|
|
42
42
|
if (spawnedProcessExitCode === 0) {
|
|
43
43
|
return await processSnapshots();
|
|
@@ -50,32 +50,32 @@ function showSessionLink() {
|
|
|
50
50
|
}
|
|
51
51
|
async function processSnapshot(snapshot, firstSnapshot) {
|
|
52
52
|
let t1;
|
|
53
|
-
if (
|
|
53
|
+
if (context_1.debug) {
|
|
54
54
|
t1 = performance.now();
|
|
55
55
|
}
|
|
56
|
-
const preparedSnapshot =
|
|
56
|
+
const preparedSnapshot = context_1.skipDiscovery
|
|
57
57
|
? snapshot
|
|
58
58
|
: await getSnapshotWithResources(snapshot);
|
|
59
59
|
try {
|
|
60
60
|
output_1.default.normal(texts_1.LOG_SENDING_DATA);
|
|
61
|
-
const response = await (0,
|
|
61
|
+
const response = await (0, requests_1.sendSnapshot)(preparedSnapshot, firstSnapshot);
|
|
62
62
|
sessionLink = response;
|
|
63
63
|
}
|
|
64
64
|
catch (error) {
|
|
65
65
|
output_1.default.error(`${error}`);
|
|
66
66
|
}
|
|
67
|
-
if (
|
|
67
|
+
if (context_1.debug && t1) {
|
|
68
68
|
const t2 = performance.now();
|
|
69
69
|
output_1.default.normal((0, texts_1.DEBUG_SNAPSHOT_PROCESSING)(snapshot.name, t2 - t1));
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
async function processSnapshots() {
|
|
73
73
|
let t1;
|
|
74
|
-
if (
|
|
74
|
+
if (context_1.debug) {
|
|
75
75
|
t1 = performance.now();
|
|
76
76
|
}
|
|
77
77
|
output_1.default.normal((0, texts_1.LOG_PROCESSING_SNAPSHOTS)(snapshots.length));
|
|
78
|
-
const preparedSnapshots =
|
|
78
|
+
const preparedSnapshots = context_1.skipDiscovery
|
|
79
79
|
? snapshots
|
|
80
80
|
: await getSnapshotsWithResources(snapshots);
|
|
81
81
|
if (preparedSnapshots.length === 0) {
|
|
@@ -84,27 +84,27 @@ async function processSnapshots() {
|
|
|
84
84
|
else {
|
|
85
85
|
try {
|
|
86
86
|
output_1.default.normal(texts_1.LOG_SENDING_DATA);
|
|
87
|
-
const response = await (0,
|
|
87
|
+
const response = await (0, requests_1.sendSnapshots)(preparedSnapshots);
|
|
88
88
|
sessionLink = response;
|
|
89
89
|
}
|
|
90
90
|
catch (error) {
|
|
91
91
|
output_1.default.error(`${error}`);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
if (
|
|
94
|
+
if (context_1.debug && t1) {
|
|
95
95
|
const t2 = performance.now();
|
|
96
96
|
output_1.default.normal((0, texts_1.DEBUG_SNAPSHOTS_PROCESSING)(t2 - t1));
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
async function getSnapshotWithResources(snapshot) {
|
|
100
100
|
const { url, devices, resourceDiscoveryTimeout, cookies } = snapshot;
|
|
101
|
-
const resources = await (0,
|
|
101
|
+
const resources = await (0, resources_1.collectResources)({
|
|
102
102
|
url,
|
|
103
103
|
devices,
|
|
104
104
|
resourceDiscoveryTimeout,
|
|
105
105
|
cookies,
|
|
106
106
|
});
|
|
107
|
-
if (
|
|
107
|
+
if (context_1.debug) {
|
|
108
108
|
output_1.default.normal(`Collected resources for snapshot: ${snapshot.name}`);
|
|
109
109
|
for (const resource of resources) {
|
|
110
110
|
output_1.default.normal(`- url: ${resource.url} status: ${resource.status} headers: ${JSON.stringify(resource.headers)} duplicate: ${resource.duplicate} hasBody: ${!!resource.body} bodySize: ${typeof resource.body === 'string' ? resource.body.length : resource.body?.size}`);
|
|
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.checkToken = checkToken;
|
|
4
4
|
exports.checkBuildId = checkBuildId;
|
|
5
5
|
exports.checkParallel = checkParallel;
|
|
6
|
-
const
|
|
6
|
+
const context_1 = require("./context");
|
|
7
7
|
function checkToken() {
|
|
8
|
-
return !!
|
|
8
|
+
return !!context_1.token;
|
|
9
9
|
}
|
|
10
10
|
function checkBuildId() {
|
|
11
11
|
return !!process.env.SNAPSHOTS_BUILD_ID;
|
|
12
12
|
}
|
|
13
13
|
function checkParallel() {
|
|
14
|
-
if (
|
|
14
|
+
if (context_1.parallel) {
|
|
15
15
|
return checkBuildId();
|
|
16
16
|
}
|
|
17
17
|
return true;
|