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.
Files changed (100) hide show
  1. package/distTs/bin/cli.js +1 -1
  2. package/distTs/package.json +1 -1
  3. package/distTs/src/agent/agent.js +302 -0
  4. package/distTs/src/agent/manager.js +41 -41
  5. package/distTs/src/agent/socket/client.js +159 -0
  6. package/distTs/src/agent/socket/tunnel.js +3 -3
  7. package/distTs/src/agent/wait.js +2 -2
  8. package/distTs/src/command/agent/disable.js +1 -1
  9. package/distTs/src/command/agent/enable.js +1 -1
  10. package/distTs/src/command/agent/install.js +45 -45
  11. package/distTs/src/command/agent/restart.js +8 -8
  12. package/distTs/src/command/agent/start.js +8 -8
  13. package/distTs/src/command/agent/status.js +15 -15
  14. package/distTs/src/command/agent/stop.js +8 -8
  15. package/distTs/src/command/agent/target/disable.js +1 -1
  16. package/distTs/src/command/agent/target/enable.js +1 -1
  17. package/distTs/src/command/agent/target/status.js +1 -1
  18. package/distTs/src/command/agent/tunnel/http.js +18 -18
  19. package/distTs/src/command/agent/tunnel/list.js +7 -7
  20. package/distTs/src/command/agent/tunnel/remove.js +9 -9
  21. package/distTs/src/command/agent/tunnel/start.js +14 -14
  22. package/distTs/src/command/agent/tunnel/status.js +11 -11
  23. package/distTs/src/command/agent/tunnel/tcp.js +19 -19
  24. package/distTs/src/command/agent/tunnel/tls.js +17 -17
  25. package/distTs/src/command/agent/tunnel.js +16 -16
  26. package/distTs/src/command/agent/uninstall.js +13 -13
  27. package/distTs/src/command/agent/update.js +12 -12
  28. package/distTs/src/command/agent/version.js +6 -6
  29. package/distTs/src/command/agent.js +18 -18
  30. package/distTs/src/command/config/add/http.js +15 -15
  31. package/distTs/src/command/config/add/tcp.js +15 -15
  32. package/distTs/src/command/config/add/tls.js +15 -15
  33. package/distTs/src/command/config/add.js +8 -8
  34. package/distTs/src/command/config/get/region.js +5 -5
  35. package/distTs/src/command/config/get/timeout.js +5 -5
  36. package/distTs/src/command/config/get/token.js +5 -5
  37. package/distTs/src/command/config/get/tunnel.js +9 -9
  38. package/distTs/src/command/config/get/tunnels.js +6 -6
  39. package/distTs/src/command/config/get/whitelist.js +5 -5
  40. package/distTs/src/command/config/get.js +14 -14
  41. package/distTs/src/command/config/remove/tunnel.js +9 -9
  42. package/distTs/src/command/config/remove.js +4 -4
  43. package/distTs/src/command/config/set/region.js +8 -8
  44. package/distTs/src/command/config/set/timeout.js +9 -9
  45. package/distTs/src/command/config/set/token.js +7 -7
  46. package/distTs/src/command/config/set/whitelist.js +8 -8
  47. package/distTs/src/command/config/set.js +10 -10
  48. package/distTs/src/command/pre.js +14 -14
  49. package/distTs/src/command/tunnel/config.js +17 -0
  50. package/distTs/src/command/tunnel/http.js +30 -0
  51. package/distTs/src/command/tunnel/start.js +28 -0
  52. package/distTs/src/command/tunnel/tcp.js +30 -0
  53. package/distTs/src/command/tunnel/tls.js +30 -0
  54. package/distTs/src/command/tunnel.js +19 -0
  55. package/distTs/src/command/ut/upload.js +6 -6
  56. package/distTs/src/command/ut.js +3 -2
  57. package/distTs/src/command/version.js +4 -4
  58. package/distTs/src/command/vt/close.js +4 -4
  59. package/distTs/src/command/vt/compare.js +16 -16
  60. package/distTs/src/command/vt/exec.js +12 -12
  61. package/distTs/src/command/vt/installBrowser.js +2 -2
  62. package/distTs/src/command/vt/scrap.js +17 -17
  63. package/distTs/src/command/vt/storybook.js +8 -8
  64. package/distTs/src/command/vt.js +5 -4
  65. package/distTs/src/index.js +12 -20
  66. package/distTs/src/input.js +38 -38
  67. package/distTs/src/logger.js +2 -2
  68. package/distTs/src/output.js +14 -14
  69. package/distTs/src/texts.js +5 -4
  70. package/distTs/src/tunnel/agent.js +3 -3
  71. package/distTs/src/tunnel/api/agent.js +99 -0
  72. package/distTs/src/tunnel/api/buddy.js +139 -0
  73. package/distTs/src/tunnel/cfg.js +234 -0
  74. package/distTs/src/tunnel/http/log.js +3 -3
  75. package/distTs/src/tunnel/http.js +29 -29
  76. package/distTs/src/tunnel/identification.js +13 -13
  77. package/distTs/src/tunnel/latency.js +3 -3
  78. package/distTs/src/tunnel/output/interactive/tunnel.js +860 -0
  79. package/distTs/src/tunnel/output/noninteractive/agent/tunnels.js +43 -0
  80. package/distTs/src/tunnel/output/noninteractive/config/tunnel.js +65 -0
  81. package/distTs/src/tunnel/output/noninteractive/config/tunnels.js +18 -0
  82. package/distTs/src/tunnel/output/noninteractive/tunnel.js +59 -0
  83. package/distTs/src/tunnel/server/cert.js +52 -0
  84. package/distTs/src/tunnel/server/http1.js +75 -0
  85. package/distTs/src/tunnel/server/http2.js +78 -0
  86. package/distTs/src/tunnel/server/sftp.js +497 -0
  87. package/distTs/src/tunnel/server/ssh.js +446 -0
  88. package/distTs/src/tunnel/server/tls.js +41 -0
  89. package/distTs/src/tunnel/ssh/client.js +197 -0
  90. package/distTs/src/tunnel/tcp.js +3 -3
  91. package/distTs/src/tunnel/tunnel.js +656 -0
  92. package/distTs/src/utils.js +2 -2
  93. package/distTs/src/visualTest/ci.js +10 -10
  94. package/distTs/src/visualTest/context.js +4 -4
  95. package/distTs/src/visualTest/requests.js +71 -71
  96. package/distTs/src/visualTest/resources.js +5 -5
  97. package/distTs/src/visualTest/server.js +9 -9
  98. package/distTs/src/visualTest/snapshots.js +18 -18
  99. package/distTs/src/visualTest/validation.js +3 -3
  100. 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 exec_js_1 = require("./exec.js");
12
- const ciInfo_js_1 = require("../types/ciInfo.js");
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, exec_js_1.gitExec)(['rev-parse', '--abbrev-ref', 'HEAD']);
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, exec_js_1.gitExec)(['rev-parse', '--verify', 'HEAD']);
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, exec_js_1.gitExec)(['merge-base', preparedBranch, preparedBaseBranch]);
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, exec_js_1.gitExec)([
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: ciInfo_js_1.CI.BUDDY,
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: ciInfo_js_1.CI.GITHUB_ACTION,
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: ciInfo_js_1.CI.CIRCLE_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: ciInfo_js_1.CI.NONE,
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 ciInfo_js_1 = require("../types/ciInfo.js");
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 = ciInfo_js_1.CI.NONE;
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 === ciInfo_js_1.CI.BUDDY) {
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 === ciInfo_js_1.CI.GITHUB_ACTION || ciInfo.ci === ciInfo_js_1.CI.CIRCLE_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 context_js_1 = require("./context.js");
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 (context_js_1.token.startsWith('bud_vt_eu')) {
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: context_js_1.buildId,
75
- parallel: context_js_1.parallel,
76
- ci: context_js_1.ci,
77
- branch: context_js_1.branch,
78
- tag: context_js_1.tag,
79
- pullRequestNumber: context_js_1.pullRequestNumber,
80
- commit: context_js_1.commit,
81
- baseCommit: context_js_1.baseCommit,
82
- pipelineId: context_js_1.pipelineId,
83
- pipelineName: context_js_1.pipelineName,
84
- actionId: context_js_1.actionId,
85
- executionId: context_js_1.executionId,
86
- invokerId: context_js_1.invokerId,
87
- commitDetails: context_js_1.commitDetails,
88
- cliId: context_js_1.cliId,
89
- executionUrl: context_js_1.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: context_js_1.buildId,
109
- parallel: context_js_1.parallel,
110
- ci: context_js_1.ci,
111
- branch: context_js_1.branch,
112
- tag: context_js_1.tag,
113
- pullRequestNumber: context_js_1.pullRequestNumber,
114
- commit: context_js_1.commit,
115
- baseCommit: context_js_1.baseCommit,
116
- pipelineId: context_js_1.pipelineId,
117
- pipelineName: context_js_1.pipelineName,
118
- actionId: context_js_1.actionId,
119
- executionId: context_js_1.executionId,
120
- invokerId: context_js_1.invokerId,
121
- commitDetails: context_js_1.commitDetails,
122
- cliId: context_js_1.cliId,
123
- executionUrl: context_js_1.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: context_js_1.token,
140
- buildId: context_js_1.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: context_js_1.buildId,
164
- ci: context_js_1.ci,
165
- branch: context_js_1.branch,
166
- tag: context_js_1.tag,
167
- pullRequestNumber: context_js_1.pullRequestNumber,
168
- commit: context_js_1.commit,
169
- baseCommit: context_js_1.baseCommit,
170
- pipelineId: context_js_1.pipelineId,
171
- pipelineName: context_js_1.pipelineName,
172
- actionId: context_js_1.actionId,
173
- executionId: context_js_1.executionId,
174
- invokerId: context_js_1.invokerId,
175
- commitDetails: context_js_1.commitDetails,
176
- cliId: context_js_1.cliId,
177
- executionUrl: context_js_1.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: context_js_1.buildId,
207
- ci: context_js_1.ci,
208
- branch: context_js_1.branch,
209
- tag: context_js_1.tag,
210
- commit: context_js_1.commit,
211
- baseCommit: context_js_1.baseCommit,
212
- pipelineId: context_js_1.pipelineId,
213
- pipelineName: context_js_1.pipelineName,
214
- actionId: context_js_1.actionId,
215
- executionId: context_js_1.executionId,
216
- invokerId: context_js_1.invokerId,
217
- commitDetails: context_js_1.commitDetails,
218
- cliId: context_js_1.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: context_js_1.token, buildId },
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': context_js_1.cliVersion,
277
- 'X-TOKEN': context_js_1.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': context_js_1.token,
285
- 'X-CLI-VERSION': context_js_1.cliVersion,
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': context_js_1.token,
319
- 'x-cli-version': context_js_1.cliVersion,
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 context_js_1 = require("./context.js");
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: context_js_1.browserPath,
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(context_js_1.defaultTimeout);
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 (context_js_1.debug) {
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)(context_js_1.defaultTimeout));
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 snapshots_js_1 = require("./snapshots.js");
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 utils_js_1 = require("../utils.js");
14
- const output_js_1 = __importDefault(require("../output.js"));
15
- const schemas_js_1 = require("../types/schemas.js");
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 texts_js_1 = require("../texts.js");
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, utils_js_1.getRootDir)(), 'parseDom.js');
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 = schemas_js_1.snapshotSchema.parse(data);
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
- output_js_1.default.error((0, texts_js_1.ERR_INVALID_SNAPSHOT)(name, error.errors
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, snapshots_js_1.addSnapshot)(preparedSnapshot);
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 resources_js_1 = require("./resources.js");
11
- const context_js_1 = require("./context.js");
12
- const requests_js_1 = require("./requests.js");
13
- const queue_js_1 = require("./queue.js");
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 (context_js_1.oneByOne) {
29
- (0, queue_js_1.addToQueue)(() => processSnapshot(preparedSnapshot, firstSnapshot));
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 (context_js_1.oneByOne) {
40
- return await (0, queue_js_1.isQueueEmpty)();
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 (context_js_1.debug) {
53
+ if (context_1.debug) {
54
54
  t1 = performance.now();
55
55
  }
56
- const preparedSnapshot = context_js_1.skipDiscovery
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, requests_js_1.sendSnapshot)(preparedSnapshot, firstSnapshot);
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 (context_js_1.debug && t1) {
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 (context_js_1.debug) {
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 = context_js_1.skipDiscovery
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, requests_js_1.sendSnapshots)(preparedSnapshots);
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 (context_js_1.debug && t1) {
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, resources_js_1.collectResources)({
101
+ const resources = await (0, resources_1.collectResources)({
102
102
  url,
103
103
  devices,
104
104
  resourceDiscoveryTimeout,
105
105
  cookies,
106
106
  });
107
- if (context_js_1.debug) {
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 context_js_1 = require("./context.js");
6
+ const context_1 = require("./context");
7
7
  function checkToken() {
8
- return !!context_js_1.token;
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 (context_js_1.parallel) {
14
+ if (context_1.parallel) {
15
15
  return checkBuildId();
16
16
  }
17
17
  return true;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.10.14",
4
+ "version": "1.11.0-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {