@skuba-lib/api 1.0.0 → 1.0.1

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 (41) hide show
  1. package/lib/buildkite/index.d.mts +1 -1
  2. package/lib/buildkite/index.d.ts +1 -1
  3. package/lib/buildkite/index.js +3 -3
  4. package/lib/buildkite/index.mjs +3 -3
  5. package/lib/{buildkite-BXHjSY0I.js → buildkite-CMOS5jTb.js} +5 -6
  6. package/lib/{buildkite-DSHpKA4z.mjs → buildkite-qXXM4AZX.mjs} +5 -6
  7. package/lib/{chunk-odGzh3W-.js → chunk-DoInfA3k.js} +3 -1
  8. package/lib/{chunk-CZCtuq8p.mjs → chunk-xAu0Ykie.mjs} +3 -1
  9. package/lib/{exec-B2akdw0z.js → exec-CTbaRcgu.mjs} +1007 -1413
  10. package/lib/{exec-p0gJ30UO.mjs → exec-DSu2byEV.js} +1026 -1396
  11. package/lib/git/index.d.mts +1 -1
  12. package/lib/git/index.js +1 -1
  13. package/lib/git/index.mjs +1 -1
  14. package/lib/{git-DVG_dHiI.js → git-BvHWj-sM.js} +22 -21
  15. package/lib/{git-DDfcZdbm.mjs → git-DJOzU_mk.mjs} +8 -12
  16. package/lib/github/index.d.mts +2 -2
  17. package/lib/github/index.d.ts +1 -1
  18. package/lib/github/index.js +3 -3
  19. package/lib/github/index.mjs +3 -3
  20. package/lib/{github-xHulZVwZ.js → github-Bz6Z6N4d.js} +16 -21
  21. package/lib/{github-DNNceiUe.mjs → github-CmwBptwe.mjs} +12 -19
  22. package/lib/{index-BbUKGQYi.d.mts → index-B59VsMwH.d.mts} +1 -1
  23. package/lib/{index-CfnlMf_4.d.ts → index-B8JJLTcg.d.mts} +1 -1
  24. package/lib/{index-DKD3ZvXQ.d.mts → index-ByyJ0i6C.d.mts} +3 -3
  25. package/lib/{index-BCtCA5Pc.d.mts → index-CdF8WFQB.d.ts} +1 -1
  26. package/lib/{index-DxmhY0n5.d.ts → index-CnBUagM3.d.mts} +1 -1
  27. package/lib/{index-BTOmI5jA.d.mts → index-DW1Kkdx2.d.ts} +1 -1
  28. package/lib/{index-D6-lpvm-.d.ts → index-V9OAt4zv.d.ts} +2 -2
  29. package/lib/index.d.mts +4 -4
  30. package/lib/index.d.ts +3 -3
  31. package/lib/index.js +6 -6
  32. package/lib/index.mjs +6 -6
  33. package/lib/{logging-6TTEX4U4.js → logging-IUcOf-AC.js} +34 -45
  34. package/lib/{logging-Dr8kuQ_p.mjs → logging-fh84hSbW.mjs} +34 -45
  35. package/lib/net/index.d.mts +1 -1
  36. package/lib/net/index.d.ts +1 -1
  37. package/lib/net/index.js +3 -3
  38. package/lib/net/index.mjs +3 -3
  39. package/lib/{net-BteSPzmU.js → net-6xDDX5lS.js} +7 -9
  40. package/lib/{net-ByUFe0qv.mjs → net-tFSha_r6.mjs} +5 -8
  41. package/package.json +3 -3
@@ -1,2 +1,2 @@
1
- import { ChangedFile, commit$1 as commit, commitAllChanges$1 as commitAllChanges, currentBranch$1 as currentBranch, fastForwardBranch$1 as fastForwardBranch, findRoot$1 as findRoot, getChangedFiles$1 as getChangedFiles, getHeadCommitId$1 as getHeadCommitId, getHeadCommitMessage$1 as getHeadCommitMessage, getOwnerAndRepo$1 as getOwnerAndRepo, isFileGitIgnored$1 as isFileGitIgnored, push$1 as push, reset$1 as reset } from "../index-BbUKGQYi.mjs";
1
+ import { ChangedFile, commit, commitAllChanges, currentBranch, fastForwardBranch, findRoot, getChangedFiles, getHeadCommitId, getHeadCommitMessage, getOwnerAndRepo, isFileGitIgnored, push, reset } from "../index-B59VsMwH.mjs";
2
2
  export { ChangedFile, commit, commitAllChanges, currentBranch, fastForwardBranch, findRoot, getChangedFiles, getHeadCommitId, getHeadCommitMessage, getOwnerAndRepo, isFileGitIgnored, push, reset };
package/lib/git/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const require_git = require('../git-DVG_dHiI.js');
1
+ const require_git = require('../git-BvHWj-sM.js');
2
2
 
3
3
  exports.commit = require_git.commit;
4
4
  exports.commitAllChanges = require_git.commitAllChanges;
package/lib/git/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { commit, commitAllChanges, currentBranch, fastForwardBranch, findRoot, getChangedFiles, getHeadCommitId, getHeadCommitMessage, getOwnerAndRepo, isFileGitIgnored, push, reset } from "../git-DDfcZdbm.mjs";
1
+ import { commit, commitAllChanges, currentBranch, fastForwardBranch, findRoot, getChangedFiles, getHeadCommitId, getHeadCommitMessage, getOwnerAndRepo, isFileGitIgnored, push, reset } from "../git-DJOzU_mk.mjs";
2
2
 
3
3
  export { commit, commitAllChanges, currentBranch, fastForwardBranch, findRoot, getChangedFiles, getHeadCommitId, getHeadCommitMessage, getOwnerAndRepo, isFileGitIgnored, push, reset };
@@ -1,9 +1,14 @@
1
- const require_chunk = require('./chunk-odGzh3W-.js');
2
- const path = require_chunk.__toESM(require("path"));
3
- const fs_extra = require_chunk.__toESM(require("fs-extra"));
4
- const isomorphic_git = require_chunk.__toESM(require("isomorphic-git"));
5
- const ignore = require_chunk.__toESM(require("ignore"));
6
- const isomorphic_git_http_node = require_chunk.__toESM(require("isomorphic-git/http/node"));
1
+ const require_chunk = require('./chunk-DoInfA3k.js');
2
+ let path = require("path");
3
+ path = require_chunk.__toESM(path);
4
+ let fs_extra = require("fs-extra");
5
+ fs_extra = require_chunk.__toESM(fs_extra);
6
+ let isomorphic_git = require("isomorphic-git");
7
+ isomorphic_git = require_chunk.__toESM(isomorphic_git);
8
+ let ignore = require("ignore");
9
+ ignore = require_chunk.__toESM(ignore);
10
+ let isomorphic_git_http_node = require("isomorphic-git/http/node");
11
+ isomorphic_git_http_node = require_chunk.__toESM(isomorphic_git_http_node);
7
12
 
8
13
  //#region src/git/commit.ts
9
14
  /**
@@ -23,7 +28,7 @@ const commit = async ({ author = { name: "skuba" }, committer = { name: "skuba"
23
28
  * Returns the first Git root directory encountered walking up from the provided
24
29
  * `dir`.
25
30
  */
26
- const findRoot$1 = async ({ dir }) => {
31
+ const findRoot = async ({ dir }) => {
27
32
  try {
28
33
  return await isomorphic_git.default.findRoot({
29
34
  filepath: dir,
@@ -89,11 +94,10 @@ const commitAllChanges = async ({ dir, message, author, committer, ignore: ignor
89
94
  ignore: ignore$1
90
95
  });
91
96
  if (!changedFiles.length) return;
92
- const gitRoot = await findRoot$1({ dir });
97
+ const gitRoot = await findRoot({ dir });
93
98
  if (!gitRoot) throw new Error(`Could not find Git root from directory: ${dir}`);
94
99
  await Promise.all(changedFiles.map(async (file) => {
95
- const relativePath = path.default.relative(dir, file.path);
96
- if (relativePath.startsWith("..")) return;
100
+ if (path.default.relative(dir, file.path).startsWith("..")) return;
97
101
  return file.state === "deleted" ? isomorphic_git.default.remove({
98
102
  fs: fs_extra.default,
99
103
  dir: gitRoot,
@@ -130,16 +134,15 @@ const currentBranch = async ({ dir, env = process.env } = {}) => {
130
134
  filepath: dir,
131
135
  fs: fs_extra.default
132
136
  });
133
- const fromRepo = await isomorphic_git.default.currentBranch({
137
+ return await isomorphic_git.default.currentBranch({
134
138
  dir: gitRoot,
135
139
  fs: fs_extra.default
136
- });
137
- return fromRepo ?? void 0;
140
+ }) ?? void 0;
138
141
  };
139
142
 
140
143
  //#endregion
141
144
  //#region src/git/log.ts
142
- const EMPTY_GIT_LOG_ERROR = new Error("Git log does not contain any commits");
145
+ const EMPTY_GIT_LOG_ERROR = /* @__PURE__ */ new Error("Git log does not contain any commits");
143
146
  /**
144
147
  * Gets the object ID of the head commit.
145
148
  *
@@ -334,11 +337,10 @@ const fastForwardBranch = async ({ auth, dir, ref, remote, remoteRef }) => {
334
337
  const reset = async ({ dir, branch, commitId, hard }) => {
335
338
  await fs_extra.default.promises.writeFile(path.default.join(dir, ".git/refs/heads", branch), `${commitId}\n`);
336
339
  if (hard) {
337
- const allFiles = await isomorphic_git.default.statusMatrix({
340
+ const modifiedFiles = (await isomorphic_git.default.statusMatrix({
338
341
  dir,
339
342
  fs: fs_extra.default
340
- });
341
- const modifiedFiles = allFiles.filter((row) => row[WORKDIR] > UNMODIFIED && row[STAGE] > UNMODIFIED).map((row) => row[FILEPATH]);
343
+ })).filter((row) => row[WORKDIR] > UNMODIFIED && row[STAGE] > UNMODIFIED).map((row) => row[FILEPATH]);
342
344
  await Promise.all(modifiedFiles.map((filePath) => fs_extra.default.promises.rm(filePath)));
343
345
  await isomorphic_git.default.checkout({
344
346
  dir,
@@ -359,13 +361,12 @@ const isFileGitIgnored = ({ absolutePath, gitRoot }) => isomorphic_git.default.i
359
361
 
360
362
  //#endregion
361
363
  //#region src/git/index.ts
362
- var git_exports = {};
363
- require_chunk.__export(git_exports, {
364
+ var git_exports = /* @__PURE__ */ require_chunk.__export({
364
365
  commit: () => commit,
365
366
  commitAllChanges: () => commitAllChanges,
366
367
  currentBranch: () => currentBranch,
367
368
  fastForwardBranch: () => fastForwardBranch,
368
- findRoot: () => findRoot$1,
369
+ findRoot: () => findRoot,
369
370
  getChangedFiles: () => getChangedFiles,
370
371
  getHeadCommitId: () => getHeadCommitId,
371
372
  getHeadCommitMessage: () => getHeadCommitMessage,
@@ -421,7 +422,7 @@ Object.defineProperty(exports, 'fastForwardBranch', {
421
422
  Object.defineProperty(exports, 'findRoot', {
422
423
  enumerable: true,
423
424
  get: function () {
424
- return findRoot$1;
425
+ return findRoot;
425
426
  }
426
427
  });
427
428
  Object.defineProperty(exports, 'getChangedFiles', {
@@ -1,4 +1,4 @@
1
- import { __export } from "./chunk-CZCtuq8p.mjs";
1
+ import { __export } from "./chunk-xAu0Ykie.mjs";
2
2
  import path from "path";
3
3
  import fs from "fs-extra";
4
4
  import git, { findRoot } from "isomorphic-git";
@@ -92,8 +92,7 @@ const commitAllChanges = async ({ dir, message, author, committer, ignore }) =>
92
92
  const gitRoot = await findRoot$1({ dir });
93
93
  if (!gitRoot) throw new Error(`Could not find Git root from directory: ${dir}`);
94
94
  await Promise.all(changedFiles.map(async (file) => {
95
- const relativePath = path.relative(dir, file.path);
96
- if (relativePath.startsWith("..")) return;
95
+ if (path.relative(dir, file.path).startsWith("..")) return;
97
96
  return file.state === "deleted" ? git.remove({
98
97
  fs,
99
98
  dir: gitRoot,
@@ -130,16 +129,15 @@ const currentBranch = async ({ dir, env = process.env } = {}) => {
130
129
  filepath: dir,
131
130
  fs
132
131
  });
133
- const fromRepo = await git.currentBranch({
132
+ return await git.currentBranch({
134
133
  dir: gitRoot,
135
134
  fs
136
- });
137
- return fromRepo ?? void 0;
135
+ }) ?? void 0;
138
136
  };
139
137
 
140
138
  //#endregion
141
139
  //#region src/git/log.ts
142
- const EMPTY_GIT_LOG_ERROR = new Error("Git log does not contain any commits");
140
+ const EMPTY_GIT_LOG_ERROR = /* @__PURE__ */ new Error("Git log does not contain any commits");
143
141
  /**
144
142
  * Gets the object ID of the head commit.
145
143
  *
@@ -334,11 +332,10 @@ const fastForwardBranch = async ({ auth, dir, ref, remote, remoteRef }) => {
334
332
  const reset = async ({ dir, branch, commitId, hard }) => {
335
333
  await fs.promises.writeFile(path.join(dir, ".git/refs/heads", branch), `${commitId}\n`);
336
334
  if (hard) {
337
- const allFiles = await git.statusMatrix({
335
+ const modifiedFiles = (await git.statusMatrix({
338
336
  dir,
339
337
  fs
340
- });
341
- const modifiedFiles = allFiles.filter((row) => row[WORKDIR] > UNMODIFIED && row[STAGE] > UNMODIFIED).map((row) => row[FILEPATH]);
338
+ })).filter((row) => row[WORKDIR] > UNMODIFIED && row[STAGE] > UNMODIFIED).map((row) => row[FILEPATH]);
342
339
  await Promise.all(modifiedFiles.map((filePath) => fs.promises.rm(filePath)));
343
340
  await git.checkout({
344
341
  dir,
@@ -359,8 +356,7 @@ const isFileGitIgnored = ({ absolutePath, gitRoot }) => git.isIgnored({
359
356
 
360
357
  //#endregion
361
358
  //#region src/git/index.ts
362
- var git_exports = {};
363
- __export(git_exports, {
359
+ var git_exports = /* @__PURE__ */ __export({
364
360
  commit: () => commit,
365
361
  commitAllChanges: () => commitAllChanges,
366
362
  currentBranch: () => currentBranch,
@@ -1,3 +1,3 @@
1
- import "../index-BbUKGQYi.mjs";
2
- import { Annotation, apiTokenFromEnvironment$1 as apiTokenFromEnvironment, buildNameFromEnvironment$1 as buildNameFromEnvironment, createCheckRun$1 as createCheckRun, enabledFromEnvironment$1 as enabledFromEnvironment, getPullRequestNumber$1 as getPullRequestNumber, putIssueComment$1 as putIssueComment, readFileChanges$1 as readFileChanges, uploadAllFileChanges$1 as uploadAllFileChanges, uploadFileChanges$1 as uploadFileChanges } from "../index-DKD3ZvXQ.mjs";
1
+ import "../index-B59VsMwH.mjs";
2
+ import { Annotation, apiTokenFromEnvironment, buildNameFromEnvironment, createCheckRun, enabledFromEnvironment, getPullRequestNumber, putIssueComment, readFileChanges, uploadAllFileChanges, uploadFileChanges } from "../index-ByyJ0i6C.mjs";
3
3
  export { Annotation, apiTokenFromEnvironment, buildNameFromEnvironment, createCheckRun, enabledFromEnvironment, getPullRequestNumber, putIssueComment, readFileChanges, uploadAllFileChanges, uploadFileChanges };
@@ -1,3 +1,3 @@
1
1
  import "../index-DO8cP0ap.js";
2
- import { Annotation, apiTokenFromEnvironment, buildNameFromEnvironment, createCheckRun, enabledFromEnvironment, getPullRequestNumber, putIssueComment, readFileChanges, uploadAllFileChanges, uploadFileChanges } from "../index-D6-lpvm-.js";
2
+ import { Annotation, apiTokenFromEnvironment, buildNameFromEnvironment, createCheckRun, enabledFromEnvironment, getPullRequestNumber, putIssueComment, readFileChanges, uploadAllFileChanges, uploadFileChanges } from "../index-V9OAt4zv.js";
3
3
  export { Annotation, apiTokenFromEnvironment, buildNameFromEnvironment, createCheckRun, enabledFromEnvironment, getPullRequestNumber, putIssueComment, readFileChanges, uploadAllFileChanges, uploadFileChanges };
@@ -1,6 +1,6 @@
1
- require('../logging-6TTEX4U4.js');
2
- const require_git = require('../git-DVG_dHiI.js');
3
- const require_github = require('../github-xHulZVwZ.js');
1
+ require('../logging-IUcOf-AC.js');
2
+ const require_git = require('../git-BvHWj-sM.js');
3
+ const require_github = require('../github-Bz6Z6N4d.js');
4
4
 
5
5
  exports.apiTokenFromEnvironment = require_git.apiTokenFromEnvironment;
6
6
  exports.buildNameFromEnvironment = require_git.buildNameFromEnvironment;
@@ -1,5 +1,5 @@
1
- import "../logging-Dr8kuQ_p.mjs";
2
- import { apiTokenFromEnvironment, buildNameFromEnvironment, enabledFromEnvironment } from "../git-DDfcZdbm.mjs";
3
- import { createCheckRun, getPullRequestNumber, putIssueComment, readFileChanges, uploadAllFileChanges, uploadFileChanges } from "../github-DNNceiUe.mjs";
1
+ import "../logging-fh84hSbW.mjs";
2
+ import { apiTokenFromEnvironment, buildNameFromEnvironment, enabledFromEnvironment } from "../git-DJOzU_mk.mjs";
3
+ import { createCheckRun, getPullRequestNumber, putIssueComment, readFileChanges, uploadAllFileChanges, uploadFileChanges } from "../github-CmwBptwe.mjs";
4
4
 
5
5
  export { apiTokenFromEnvironment, buildNameFromEnvironment, createCheckRun, enabledFromEnvironment, getPullRequestNumber, putIssueComment, readFileChanges, uploadAllFileChanges, uploadFileChanges };
@@ -1,8 +1,10 @@
1
- const require_chunk = require('./chunk-odGzh3W-.js');
2
- const require_logging = require('./logging-6TTEX4U4.js');
3
- const require_git = require('./git-DVG_dHiI.js');
4
- const path = require_chunk.__toESM(require("path"));
5
- const fs_extra = require_chunk.__toESM(require("fs-extra"));
1
+ const require_chunk = require('./chunk-DoInfA3k.js');
2
+ const require_logging = require('./logging-IUcOf-AC.js');
3
+ const require_git = require('./git-BvHWj-sM.js');
4
+ let path = require("path");
5
+ path = require_chunk.__toESM(path);
6
+ let fs_extra = require("fs-extra");
7
+ fs_extra = require_chunk.__toESM(fs_extra);
6
8
 
7
9
  //#region src/github/octokit.ts
8
10
  const createRestClient = async (options) => new (await (import("@octokit/rest"))).Octokit(options);
@@ -19,8 +21,7 @@ const GITHUB_MAX_ANNOTATIONS = 50;
19
21
  * ```
20
22
  */
21
23
  const suffixTitle = (title, inputAnnotations) => {
22
- const addedAnnotations = inputAnnotations > GITHUB_MAX_ANNOTATIONS ? GITHUB_MAX_ANNOTATIONS : inputAnnotations;
23
- return `${title} (${require_logging.pluralise(addedAnnotations, "annotation")} added)`;
24
+ return `${title} (${require_logging.pluralise(inputAnnotations > GITHUB_MAX_ANNOTATIONS ? GITHUB_MAX_ANNOTATIONS : inputAnnotations, "annotation")} added)`;
24
25
  };
25
26
  /**
26
27
  * Enriches the summary with more context about the check run.
@@ -37,8 +38,7 @@ const createEnrichedSummary = (summary, inputAnnotations) => [summary, ...inputA
37
38
  const createCheckRun = async ({ annotations, conclusion, name, summary, text, title }) => {
38
39
  const dir = process.cwd();
39
40
  const [commitId, { owner, repo }] = await Promise.all([require_git.getHeadCommitId({ dir }), require_git.getOwnerAndRepo({ dir })]);
40
- const client = await createRestClient({ auth: require_git.apiTokenFromEnvironment() });
41
- await client.checks.create({
41
+ await (await createRestClient({ auth: require_git.apiTokenFromEnvironment() })).checks.create({
42
42
  conclusion,
43
43
  head_sha: commitId,
44
44
  name,
@@ -73,13 +73,11 @@ const getPullRequestNumber = async (params = {}) => {
73
73
  dir,
74
74
  env
75
75
  }), require_git.getOwnerAndRepo({ dir })]);
76
- const response = await client.repos.listPullRequestsAssociatedWithCommit({
76
+ const pullRequestData = (await client.repos.listPullRequestsAssociatedWithCommit({
77
77
  commit_sha: commitId,
78
78
  owner,
79
79
  repo
80
- });
81
- const data = response.data.filter((pr) => pr.state === "open" && !pr.locked).sort((a, b) => b.updated_at.localeCompare(a.updated_at));
82
- const pullRequestData = data[0];
80
+ })).data.filter((pr) => pr.state === "open" && !pr.locked).sort((a, b) => b.updated_at.localeCompare(a.updated_at))[0];
83
81
  if (!pullRequestData) throw new Error(`Commit ${commitId} is not associated with an open GitHub pull request`);
84
82
  return pullRequestData.number;
85
83
  };
@@ -128,7 +126,7 @@ const putIssueComment = async (params) => {
128
126
  return null;
129
127
  }
130
128
  const body = params.internalId ? [params.body.trim(), `<!-- ${params.internalId} -->`].join("\n\n") : params.body.trim();
131
- const response = await (commentId ? client.issues.updateComment({
129
+ return { id: (await (commentId ? client.issues.updateComment({
132
130
  body,
133
131
  comment_id: commentId,
134
132
  issue_number: issueNumber,
@@ -139,8 +137,7 @@ const putIssueComment = async (params) => {
139
137
  issue_number: issueNumber,
140
138
  owner,
141
139
  repo
142
- }));
143
- return { id: response.data.id };
140
+ }))).data.id };
144
141
  };
145
142
 
146
143
  //#endregion
@@ -236,7 +233,7 @@ const uploadFileChanges = async ({ dir, branch, messageHeadline, messageBody, fi
236
233
  clientMutationId: "skuba",
237
234
  fileChanges
238
235
  };
239
- const result = await graphql(`
236
+ return (await graphql(`
240
237
  mutation Mutation($input: CreateCommitOnBranchInput!) {
241
238
  createCommitOnBranch(input: $input) {
242
239
  commit {
@@ -247,14 +244,12 @@ const uploadFileChanges = async ({ dir, branch, messageHeadline, messageBody, fi
247
244
  `, {
248
245
  input,
249
246
  headers: { authorization: `Bearer ${authToken}` }
250
- });
251
- return result.createCommitOnBranch.commit.oid;
247
+ })).createCommitOnBranch.commit.oid;
252
248
  };
253
249
 
254
250
  //#endregion
255
251
  //#region src/github/index.ts
256
- var github_exports = {};
257
- require_chunk.__export(github_exports, {
252
+ var github_exports = /* @__PURE__ */ require_chunk.__export({
258
253
  apiTokenFromEnvironment: () => require_git.apiTokenFromEnvironment,
259
254
  buildNameFromEnvironment: () => require_git.buildNameFromEnvironment,
260
255
  createCheckRun: () => createCheckRun,
@@ -1,6 +1,6 @@
1
- import { __export } from "./chunk-CZCtuq8p.mjs";
2
- import { pluralise } from "./logging-Dr8kuQ_p.mjs";
3
- import { apiTokenFromEnvironment, buildNameFromEnvironment, enabledFromEnvironment, fastForwardBranch, findRoot, getChangedFiles, getHeadCommitId, getOwnerAndRepo } from "./git-DDfcZdbm.mjs";
1
+ import { __export } from "./chunk-xAu0Ykie.mjs";
2
+ import { pluralise } from "./logging-fh84hSbW.mjs";
3
+ import { apiTokenFromEnvironment, buildNameFromEnvironment, enabledFromEnvironment, fastForwardBranch, findRoot, getChangedFiles, getHeadCommitId, getOwnerAndRepo } from "./git-DJOzU_mk.mjs";
4
4
  import path from "path";
5
5
  import fs from "fs-extra";
6
6
 
@@ -19,8 +19,7 @@ const GITHUB_MAX_ANNOTATIONS = 50;
19
19
  * ```
20
20
  */
21
21
  const suffixTitle = (title, inputAnnotations) => {
22
- const addedAnnotations = inputAnnotations > GITHUB_MAX_ANNOTATIONS ? GITHUB_MAX_ANNOTATIONS : inputAnnotations;
23
- return `${title} (${pluralise(addedAnnotations, "annotation")} added)`;
22
+ return `${title} (${pluralise(inputAnnotations > GITHUB_MAX_ANNOTATIONS ? GITHUB_MAX_ANNOTATIONS : inputAnnotations, "annotation")} added)`;
24
23
  };
25
24
  /**
26
25
  * Enriches the summary with more context about the check run.
@@ -37,8 +36,7 @@ const createEnrichedSummary = (summary, inputAnnotations) => [summary, ...inputA
37
36
  const createCheckRun = async ({ annotations, conclusion, name, summary, text, title }) => {
38
37
  const dir = process.cwd();
39
38
  const [commitId, { owner, repo }] = await Promise.all([getHeadCommitId({ dir }), getOwnerAndRepo({ dir })]);
40
- const client = await createRestClient({ auth: apiTokenFromEnvironment() });
41
- await client.checks.create({
39
+ await (await createRestClient({ auth: apiTokenFromEnvironment() })).checks.create({
42
40
  conclusion,
43
41
  head_sha: commitId,
44
42
  name,
@@ -73,13 +71,11 @@ const getPullRequestNumber = async (params = {}) => {
73
71
  dir,
74
72
  env
75
73
  }), getOwnerAndRepo({ dir })]);
76
- const response = await client.repos.listPullRequestsAssociatedWithCommit({
74
+ const pullRequestData = (await client.repos.listPullRequestsAssociatedWithCommit({
77
75
  commit_sha: commitId,
78
76
  owner,
79
77
  repo
80
- });
81
- const data = response.data.filter((pr) => pr.state === "open" && !pr.locked).sort((a, b) => b.updated_at.localeCompare(a.updated_at));
82
- const pullRequestData = data[0];
78
+ })).data.filter((pr) => pr.state === "open" && !pr.locked).sort((a, b) => b.updated_at.localeCompare(a.updated_at))[0];
83
79
  if (!pullRequestData) throw new Error(`Commit ${commitId} is not associated with an open GitHub pull request`);
84
80
  return pullRequestData.number;
85
81
  };
@@ -128,7 +124,7 @@ const putIssueComment = async (params) => {
128
124
  return null;
129
125
  }
130
126
  const body = params.internalId ? [params.body.trim(), `<!-- ${params.internalId} -->`].join("\n\n") : params.body.trim();
131
- const response = await (commentId ? client.issues.updateComment({
127
+ return { id: (await (commentId ? client.issues.updateComment({
132
128
  body,
133
129
  comment_id: commentId,
134
130
  issue_number: issueNumber,
@@ -139,8 +135,7 @@ const putIssueComment = async (params) => {
139
135
  issue_number: issueNumber,
140
136
  owner,
141
137
  repo
142
- }));
143
- return { id: response.data.id };
138
+ }))).data.id };
144
139
  };
145
140
 
146
141
  //#endregion
@@ -236,7 +231,7 @@ const uploadFileChanges = async ({ dir, branch, messageHeadline, messageBody, fi
236
231
  clientMutationId: "skuba",
237
232
  fileChanges
238
233
  };
239
- const result = await graphql(`
234
+ return (await graphql(`
240
235
  mutation Mutation($input: CreateCommitOnBranchInput!) {
241
236
  createCommitOnBranch(input: $input) {
242
237
  commit {
@@ -247,14 +242,12 @@ const uploadFileChanges = async ({ dir, branch, messageHeadline, messageBody, fi
247
242
  `, {
248
243
  input,
249
244
  headers: { authorization: `Bearer ${authToken}` }
250
- });
251
- return result.createCommitOnBranch.commit.oid;
245
+ })).createCommitOnBranch.commit.oid;
252
246
  };
253
247
 
254
248
  //#endregion
255
249
  //#region src/github/index.ts
256
- var github_exports = {};
257
- __export(github_exports, {
250
+ var github_exports = /* @__PURE__ */ __export({
258
251
  apiTokenFromEnvironment: () => apiTokenFromEnvironment,
259
252
  buildNameFromEnvironment: () => buildNameFromEnvironment,
260
253
  createCheckRun: () => createCheckRun,
@@ -275,4 +275,4 @@ declare namespace index_d_exports {
275
275
  export { ChangedFile, commit, commitAllChanges, currentBranch, fastForwardBranch, findRoot, getChangedFiles, getHeadCommitId, getHeadCommitMessage, getOwnerAndRepo, isFileGitIgnored, push, reset };
276
276
  }
277
277
  //#endregion
278
- export { type ChangedFile, commit as commit$1, commitAllChanges as commitAllChanges$1, currentBranch as currentBranch$1, fastForwardBranch as fastForwardBranch$1, findRoot as findRoot$1, getChangedFiles as getChangedFiles$1, getHeadCommitId as getHeadCommitId$1, getHeadCommitMessage as getHeadCommitMessage$1, getOwnerAndRepo as getOwnerAndRepo$1, index_d_exports as index_d_exports$1, isFileGitIgnored as isFileGitIgnored$1, push as push$1, reset as reset$1 };
278
+ export { type ChangedFile, commit, commitAllChanges, currentBranch, fastForwardBranch, findRoot, getChangedFiles, getHeadCommitId, getHeadCommitMessage, getOwnerAndRepo, index_d_exports, isFileGitIgnored, push, reset };
@@ -36,4 +36,4 @@ declare namespace index_d_exports {
36
36
  export { AnnotationStyle, annotate, md };
37
37
  }
38
38
  //#endregion
39
- export { type AnnotationStyle, annotate, index_d_exports as index_d_exports$2, md };
39
+ export { type AnnotationStyle, annotate, index_d_exports, md };
@@ -1,5 +1,5 @@
1
- import { ChangedFile } from "./index-BbUKGQYi.mjs";
2
- import { Octokit } from "@octokit/rest";
1
+ import { ChangedFile } from "./index-B59VsMwH.mjs";
2
+ import type { Octokit } from "@octokit/rest" with { "resolution-mode": "import" };
3
3
  import { Endpoints } from "@octokit/types";
4
4
 
5
5
  //#region src/github/checkRun.d.ts
@@ -256,4 +256,4 @@ declare namespace index_d_exports {
256
256
  export { Annotation, apiTokenFromEnvironment, buildNameFromEnvironment, createCheckRun, enabledFromEnvironment, getPullRequestNumber, putIssueComment, readFileChanges, uploadAllFileChanges, uploadFileChanges };
257
257
  }
258
258
  //#endregion
259
- export { type Annotation, apiTokenFromEnvironment as apiTokenFromEnvironment$1, buildNameFromEnvironment as buildNameFromEnvironment$1, createCheckRun as createCheckRun$1, enabledFromEnvironment as enabledFromEnvironment$1, getPullRequestNumber as getPullRequestNumber$1, index_d_exports as index_d_exports$2, putIssueComment as putIssueComment$1, readFileChanges as readFileChanges$1, uploadAllFileChanges as uploadAllFileChanges$1, uploadFileChanges as uploadFileChanges$1 };
259
+ export { type Annotation, apiTokenFromEnvironment, buildNameFromEnvironment, createCheckRun, enabledFromEnvironment, getPullRequestNumber, index_d_exports, putIssueComment, readFileChanges, uploadAllFileChanges, uploadFileChanges };
@@ -36,4 +36,4 @@ declare namespace index_d_exports {
36
36
  export { AnnotationStyle, annotate, md };
37
37
  }
38
38
  //#endregion
39
- export { type AnnotationStyle, annotate as annotate$1, index_d_exports, md as md$1 };
39
+ export { type AnnotationStyle, annotate, index_d_exports, md };
@@ -35,4 +35,4 @@ declare namespace index_d_exports {
35
35
  export { waitFor };
36
36
  }
37
37
  //#endregion
38
- export { index_d_exports as index_d_exports$1, waitFor };
38
+ export { index_d_exports, waitFor };
@@ -35,4 +35,4 @@ declare namespace index_d_exports {
35
35
  export { waitFor };
36
36
  }
37
37
  //#endregion
38
- export { index_d_exports as index_d_exports$3, waitFor as waitFor$1 };
38
+ export { index_d_exports, waitFor };
@@ -1,6 +1,6 @@
1
1
  import { ChangedFile } from "./index-DO8cP0ap.js";
2
2
  import { Endpoints } from "@octokit/types";
3
- import { Octokit } from "@octokit/rest";
3
+ import type { Octokit } from "@octokit/rest" with { "resolution-mode": "import" };
4
4
 
5
5
  //#region src/github/checkRun.d.ts
6
6
  type Output = NonNullable<Endpoints['PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}']['parameters']['output']>;
@@ -256,4 +256,4 @@ declare namespace index_d_exports {
256
256
  export { Annotation, apiTokenFromEnvironment, buildNameFromEnvironment, createCheckRun, enabledFromEnvironment, getPullRequestNumber, putIssueComment, readFileChanges, uploadAllFileChanges, uploadFileChanges };
257
257
  }
258
258
  //#endregion
259
- export { type Annotation, apiTokenFromEnvironment, buildNameFromEnvironment, createCheckRun, enabledFromEnvironment, getPullRequestNumber, index_d_exports as index_d_exports$3, putIssueComment, readFileChanges, uploadAllFileChanges, uploadFileChanges };
259
+ export { type Annotation, apiTokenFromEnvironment, buildNameFromEnvironment, createCheckRun, enabledFromEnvironment, getPullRequestNumber, index_d_exports, putIssueComment, readFileChanges, uploadAllFileChanges, uploadFileChanges };
package/lib/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { index_d_exports } from "./index-BCtCA5Pc.mjs";
2
- import { index_d_exports$1 } from "./index-BbUKGQYi.mjs";
3
- import { index_d_exports$2 } from "./index-DKD3ZvXQ.mjs";
4
- import { index_d_exports$3 } from "./index-BTOmI5jA.mjs";
1
+ import { index_d_exports } from "./index-B8JJLTcg.mjs";
2
+ import { index_d_exports as index_d_exports$1 } from "./index-B59VsMwH.mjs";
3
+ import { index_d_exports as index_d_exports$2 } from "./index-ByyJ0i6C.mjs";
4
+ import { index_d_exports as index_d_exports$3 } from "./index-CnBUagM3.mjs";
5
5
  export { index_d_exports as Buildkite, index_d_exports$1 as Git, index_d_exports$2 as GitHub, index_d_exports$3 as Net };
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { index_d_exports$2 as index_d_exports } from "./index-CfnlMf_4.js";
1
+ import { index_d_exports } from "./index-CdF8WFQB.js";
2
2
  import { index_d_exports as index_d_exports$1 } from "./index-DO8cP0ap.js";
3
- import { index_d_exports$3 as index_d_exports$2 } from "./index-D6-lpvm-.js";
4
- import { index_d_exports$1 as index_d_exports$3 } from "./index-DxmhY0n5.js";
3
+ import { index_d_exports as index_d_exports$2 } from "./index-V9OAt4zv.js";
4
+ import { index_d_exports as index_d_exports$3 } from "./index-DW1Kkdx2.js";
5
5
  export { index_d_exports as Buildkite, index_d_exports$1 as Git, index_d_exports$2 as GitHub, index_d_exports$3 as Net };
package/lib/index.js CHANGED
@@ -1,9 +1,9 @@
1
- require('./exec-B2akdw0z.js');
2
- require('./logging-6TTEX4U4.js');
3
- const require_buildkite = require('./buildkite-BXHjSY0I.js');
4
- const require_git = require('./git-DVG_dHiI.js');
5
- const require_github = require('./github-xHulZVwZ.js');
6
- const require_net = require('./net-BteSPzmU.js');
1
+ require('./exec-DSu2byEV.js');
2
+ require('./logging-IUcOf-AC.js');
3
+ const require_buildkite = require('./buildkite-CMOS5jTb.js');
4
+ const require_git = require('./git-BvHWj-sM.js');
5
+ const require_github = require('./github-Bz6Z6N4d.js');
6
+ const require_net = require('./net-6xDDX5lS.js');
7
7
 
8
8
  Object.defineProperty(exports, 'Buildkite', {
9
9
  enumerable: true,
package/lib/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import "./exec-p0gJ30UO.mjs";
2
- import "./logging-Dr8kuQ_p.mjs";
3
- import { buildkite_exports } from "./buildkite-DSHpKA4z.mjs";
4
- import { git_exports } from "./git-DDfcZdbm.mjs";
5
- import { github_exports } from "./github-DNNceiUe.mjs";
6
- import { net_exports } from "./net-ByUFe0qv.mjs";
1
+ import "./exec-CTbaRcgu.mjs";
2
+ import "./logging-fh84hSbW.mjs";
3
+ import { buildkite_exports } from "./buildkite-qXXM4AZX.mjs";
4
+ import { git_exports } from "./git-DJOzU_mk.mjs";
5
+ import { github_exports } from "./github-CmwBptwe.mjs";
6
+ import { net_exports } from "./net-tFSha_r6.mjs";
7
7
 
8
8
  export { buildkite_exports as Buildkite, git_exports as Git, github_exports as GitHub, net_exports as Net };