bdy 1.9.52-dev → 1.9.53-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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.9.52-dev",
4
+ "version": "1.9.53-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -11,6 +11,8 @@ const linkUtils_1 = require("../../visualTest/linkUtils");
11
11
  const node_fs_1 = require("node:fs");
12
12
  const requests_1 = require("../../visualTest/requests");
13
13
  const validation_2 = require("./compare/validation");
14
+ const ci_1 = require("../../visualTest/ci");
15
+ const context_1 = require("../../visualTest/context");
14
16
  const commandVtCompare = (0, utils_1.newCommand)('compare', texts_js_1.DESC_COMMAND_VT_COMPARE);
15
17
  commandVtCompare.option('--urls <urls>', texts_js_1.OPTION_COMPARE_URLS);
16
18
  commandVtCompare.option('--sitemap <sitemap>', texts_js_1.OPTION_COMPARE_SITEMAP);
@@ -55,6 +57,8 @@ commandVtCompare.action(async (options) => {
55
57
  else if (filteredUrls.length > 1) {
56
58
  output_1.default.normal(`List of urls:\n${filteredUrls.join('\n')}`);
57
59
  }
60
+ const ciAndGitInfo = await (0, ci_1.getCiAndGitInfo)(undefined);
61
+ (0, context_1.setCiAndCommitInfo)(ciAndGitInfo);
58
62
  try {
59
63
  const response = await (0, requests_1.sendCompareLinks)(filteredUrls, validatedOptions, sitemapSource);
60
64
  output_1.default.exitSuccess(response);
@@ -38,32 +38,40 @@ async function getGithubPullRequestCommit() {
38
38
  }
39
39
  return payload.pull_request.head.sha;
40
40
  }
41
- async function getBranchName() {
41
+ async function getBranchName(optional) {
42
42
  let branch = '';
43
43
  try {
44
44
  branch = await (0, exec_js_1.gitExec)(['rev-parse', '--abbrev-ref', 'HEAD']);
45
45
  }
46
46
  catch (error) {
47
- output_1.default.warning((0, texts_1.ERR_GETTING_BRANCH_NAME)(JSON.stringify(error)));
47
+ if (!optional) {
48
+ output_1.default.warning((0, texts_1.ERR_GETTING_BRANCH_NAME)(JSON.stringify(error)));
49
+ }
48
50
  }
49
51
  branch = branch.trim();
50
52
  if (!branch) {
51
- output_1.default.warning(texts_1.ERR_INVALID_BRANCH_NAME);
53
+ if (!optional) {
54
+ output_1.default.warning(texts_1.ERR_INVALID_BRANCH_NAME);
55
+ }
52
56
  return;
53
57
  }
54
58
  return branch?.trim();
55
59
  }
56
- async function getCommitHash() {
60
+ async function getCommitHash(optional) {
57
61
  let commit = '';
58
62
  try {
59
63
  commit = await (0, exec_js_1.gitExec)(['rev-parse', '--verify', 'HEAD']);
60
64
  }
61
65
  catch (error) {
62
- output_1.default.warning((0, texts_1.ERR_GETTING_COMMIT_HASH)(JSON.stringify(error)));
66
+ if (!optional) {
67
+ output_1.default.warning((0, texts_1.ERR_GETTING_COMMIT_HASH)(JSON.stringify(error)));
68
+ }
63
69
  }
64
70
  commit = commit.trim();
65
71
  if (!commit || commit.length !== 40) {
66
- output_1.default.warning((0, texts_1.ERR_INVALID_COMMIT_HASH)(commit));
72
+ if (!optional) {
73
+ output_1.default.warning((0, texts_1.ERR_INVALID_COMMIT_HASH)(commit));
74
+ }
67
75
  return;
68
76
  }
69
77
  return commit;
@@ -129,6 +137,7 @@ async function getCiAndGitInfo(baseBranch) {
129
137
  const forceBranch = process.env.SNAPSHOTS_BRANCH;
130
138
  const forceCommit = process.env.SNAPSHOTS_COMMIT;
131
139
  const forceBaseCommit = process.env.SNAPSHOTS_BASE_COMMIT;
140
+ const withoutBaseCommit = baseBranch === undefined;
132
141
  if (isBuddy) {
133
142
  const pullRequestNumber = Number(process.env.BUDDY_RUN_PR_NO);
134
143
  const isPR = !!pullRequestNumber;
@@ -137,8 +146,10 @@ async function getCiAndGitInfo(baseBranch) {
137
146
  ? process.env.BUDDY_RUN_PR_HEAD_BRANCH
138
147
  : process.env.BUDDY_EXECUTION_BRANCH);
139
148
  const commit = forceCommit || process.env.BUDDY_EXECUTION_REVISION;
140
- const baseCommit = forceBaseCommit ||
141
- (isPR ? await getBaseCommit(baseBranch, branch, true) : undefined);
149
+ const baseCommit = withoutBaseCommit
150
+ ? undefined
151
+ : forceBaseCommit ||
152
+ (isPR ? await getBaseCommit(baseBranch, branch, true) : undefined);
142
153
  const invokerId = Number(process.env.BUDDY_INVOKER_ID);
143
154
  const pipelineId = Number(process.env.BUDDY_PIPELINE_ID);
144
155
  const actionId = Number(process.env.BUDDY_ACTION_ID);
@@ -168,8 +179,10 @@ async function getCiAndGitInfo(baseBranch) {
168
179
  (isPR ? process.env.GITHUB_HEAD_REF : process.env.GITHUB_REF_NAME);
169
180
  const commit = forceCommit ||
170
181
  (isPR ? await getGithubPullRequestCommit() : process.env.GITHUB_SHA);
171
- const baseCommit = forceBaseCommit ||
172
- (isPR ? await getBaseCommit(baseBranch, branch, true) : undefined);
182
+ const baseCommit = withoutBaseCommit
183
+ ? undefined
184
+ : forceBaseCommit ||
185
+ (isPR ? await getBaseCommit(baseBranch, branch, true) : undefined);
173
186
  return {
174
187
  ci: ciInfo_js_1.CI.GITHUB_ACTION,
175
188
  branch,
@@ -187,8 +200,10 @@ async function getCiAndGitInfo(baseBranch) {
187
200
  : undefined;
188
201
  const branch = forceBranch || process.env.CIRCLE_BRANCH;
189
202
  const commit = forceCommit || process.env.CIRCLE_SHA1;
190
- const baseCommit = forceBaseCommit ||
191
- (isPR ? await getBaseCommit(baseBranch, branch) : undefined);
203
+ const baseCommit = withoutBaseCommit
204
+ ? undefined
205
+ : forceBaseCommit ||
206
+ (isPR ? await getBaseCommit(baseBranch, branch) : undefined);
192
207
  return {
193
208
  ci: ciInfo_js_1.CI.CIRCLE_CI,
194
209
  branch: process.env.CIRCLE_BRANCH,
@@ -199,15 +214,17 @@ async function getCiAndGitInfo(baseBranch) {
199
214
  executionUrl: `${process.env.CIRCLE_BUILD_URL}`,
200
215
  };
201
216
  }
202
- const branch = forceBranch || (await getBranchName());
203
- const commit = forceCommit || (await getCommitHash());
217
+ const branch = forceBranch || (await getBranchName(withoutBaseCommit));
218
+ const commit = forceCommit || (await getCommitHash(withoutBaseCommit));
204
219
  return {
205
220
  ci: ciInfo_js_1.CI.NONE,
206
221
  branch,
207
222
  commit,
208
- baseCommit: branch && branch !== baseBranch
209
- ? forceBaseCommit || (await getBaseCommit(baseBranch, branch))
210
- : undefined,
223
+ baseCommit: withoutBaseCommit
224
+ ? undefined
225
+ : branch && branch !== baseBranch
226
+ ? forceBaseCommit || (await getBaseCommit(baseBranch, branch))
227
+ : undefined,
211
228
  commitDetails: await getCommitDetails(commit),
212
229
  };
213
230
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.9.52-dev",
4
+ "version": "1.9.53-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {