@skuba-lib/api 2.2.0 → 3.0.0-add-cdk-NodejsFunction-20260618233139

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 (47) hide show
  1. package/buildkite/package.json +1 -2
  2. package/cdk/nodejsFunction/package.json +5 -0
  3. package/cdk/package.json +1 -2
  4. package/git/package.json +1 -2
  5. package/github/package.json +1 -2
  6. package/lib/buildkite/index.mjs +1 -1
  7. package/lib/{buildkite-DdGh6ljO.mjs → buildkite-DCSmKf_B.mjs} +1 -1
  8. package/lib/cdk/bridges/rolldown.mjs +50 -0
  9. package/lib/cdk/index.d.mts +13 -5
  10. package/lib/cdk/index.mjs +18 -4
  11. package/lib/cdk/nodejsFunction/index.d.mts +2 -0
  12. package/lib/cdk/nodejsFunction/index.mjs +334 -0
  13. package/lib/git/index.mjs +1 -1
  14. package/lib/{git-CmP3a9Z9.mjs → git-BHbneN9r.mjs} +1 -1
  15. package/lib/github/index.mjs +2 -2
  16. package/lib/{github-BUEZ_y2Y.mjs → github-Buehx6Xt.mjs} +2 -2
  17. package/lib/index-DnMMX6Ji.d.mts +32 -0
  18. package/lib/index.d.mts +4 -5
  19. package/lib/index.mjs +5 -6
  20. package/lib/net/index.mjs +1 -1
  21. package/lib/{net-Bi0PXcTy.mjs → net-CbEVAvJj.mjs} +1 -1
  22. package/lib/{rolldown-runtime-D7D4PA-g.mjs → rolldown-runtime-8H4AJuhK.mjs} +1 -0
  23. package/net/package.json +1 -2
  24. package/package.json +28 -29
  25. package/lib/buildkite/index.cjs +0 -4
  26. package/lib/buildkite/index.d.cts +0 -2
  27. package/lib/buildkite-_FU8d_a-.cjs +0 -62
  28. package/lib/cdk/index.cjs +0 -13
  29. package/lib/cdk/index.d.cts +0 -6
  30. package/lib/error-BnrwrJEG.cjs +0 -62
  31. package/lib/exec-Da3EoDZ1.cjs +0 -82
  32. package/lib/git/index.cjs +0 -14
  33. package/lib/git/index.d.cts +0 -2
  34. package/lib/git-D98vomnD.cjs +0 -460
  35. package/lib/github/index.cjs +0 -12
  36. package/lib/github/index.d.cts +0 -2
  37. package/lib/github-D12IboDc.cjs +0 -296
  38. package/lib/index-C9WMO_Y9.d.cts +0 -278
  39. package/lib/index-CNxgBJm_.d.cts +0 -39
  40. package/lib/index-D4JUiy2k.d.cts +0 -259
  41. package/lib/index-Kyp8ZCwF.d.cts +0 -38
  42. package/lib/index.cjs +0 -36
  43. package/lib/index.d.cts +0 -6
  44. package/lib/net/index.cjs +0 -3
  45. package/lib/net/index.d.cts +0 -2
  46. package/lib/net-4Ly1AB2r.cjs +0 -79
  47. package/lib/rolldown-runtime-DakpK96I.cjs +0 -43
@@ -1,460 +0,0 @@
1
- const require_rolldown_runtime = require("./rolldown-runtime-DakpK96I.cjs");
2
- const require_error = require("./error-BnrwrJEG.cjs");
3
- let fs_extra = require("fs-extra");
4
- fs_extra = require_rolldown_runtime.__toESM(fs_extra, 1);
5
- let isomorphic_git = require("isomorphic-git");
6
- isomorphic_git = require_rolldown_runtime.__toESM(isomorphic_git, 1);
7
- let path = require("path");
8
- path = require_rolldown_runtime.__toESM(path, 1);
9
- let ignore = require("ignore");
10
- ignore = require_rolldown_runtime.__toESM(ignore, 1);
11
- let isomorphic_git_http_node = require("isomorphic-git/http/node");
12
- isomorphic_git_http_node = require_rolldown_runtime.__toESM(isomorphic_git_http_node, 1);
13
- //#region src/git/commit.ts
14
- /**
15
- * Writes a commit to the local Git repository.
16
- */
17
- const commit = async ({ author = { name: "skuba" }, committer = { name: "skuba" }, dir, message }) => isomorphic_git.default.commit({
18
- author,
19
- committer,
20
- dir,
21
- fs: fs_extra.default,
22
- message
23
- });
24
- //#endregion
25
- //#region src/git/findRoot.ts
26
- /**
27
- * Returns the first Git root directory encountered walking up from the provided
28
- * `dir`.
29
- */
30
- const findRoot$1 = async ({ dir }) => {
31
- try {
32
- return await isomorphic_git.default.findRoot({
33
- filepath: dir,
34
- fs: fs_extra.default
35
- });
36
- } catch (err) {
37
- if (err instanceof isomorphic_git.default.Errors.NotFoundError) return null;
38
- throw err;
39
- }
40
- };
41
- //#endregion
42
- //#region ../../src/utils/fs.ts
43
- const pathExists = async (filePath) => {
44
- try {
45
- await fs_extra.default.promises.access(filePath);
46
- return true;
47
- } catch (error) {
48
- if (require_error.isErrorWithCode(error, "ENOENT")) return false;
49
- throw error;
50
- }
51
- };
52
- //#endregion
53
- //#region src/git/getChangedFiles.ts
54
- const mapState = (row) => {
55
- if (row[1] === 0) return "added";
56
- if (row[2] === 2) return "modified";
57
- return "deleted";
58
- };
59
- /**
60
- * Returns all the files which have been added, modified or deleted in the
61
- * working directory of the local Git repository since the last commit.
62
- */
63
- const getChangedFiles = async ({ dir, ignore: ignore$1 = [] }) => {
64
- const gitRoot = await (0, isomorphic_git.findRoot)({
65
- fs: fs_extra.default,
66
- filepath: dir
67
- });
68
- const [allFiles, isLfs] = await Promise.all([isomorphic_git.default.statusMatrix({
69
- fs: fs_extra.default,
70
- dir: gitRoot ?? dir
71
- }), createIsLfsFilter(gitRoot)]);
72
- return allFiles.filter((row) => row[1] !== 1 || row[2] !== 1 || row[3] !== 1).map((row) => ({
73
- path: row[0],
74
- state: mapState(row)
75
- })).filter((changedFile) => !ignore$1.some((i) => i.path === changedFile.path && i.state === changedFile.state) && !isLfs(changedFile.path));
76
- };
77
- const createIsLfsFilter = async (gitRoot) => {
78
- if (!gitRoot) return () => false;
79
- const lfsFile = `${gitRoot}/.gitattributes`;
80
- if (!await pathExists(lfsFile)) return () => false;
81
- const filter = (0, ignore.default)().add((await fs_extra.default.promises.readFile(lfsFile, "utf8")).split("\n").map((l) => l.trim()).filter((l) => !l.startsWith("#") && l.includes("filter=lfs")).map((l) => l.split(/\s+/)[0]).flatMap((l) => l ? [l] : []));
82
- return (pathname) => filter.ignores(pathname);
83
- };
84
- //#endregion
85
- //#region src/git/commitAllChanges.ts
86
- /**
87
- * Stages all changes and writes a commit to the local Git repository.
88
- */
89
- const commitAllChanges = async ({ dir, message, author, committer, ignore }) => {
90
- const changedFiles = await getChangedFiles({
91
- dir,
92
- ignore
93
- });
94
- if (!changedFiles.length) return;
95
- const gitRoot = await findRoot$1({ dir });
96
- if (!gitRoot) throw new Error(`Could not find Git root from directory: ${dir}`);
97
- await Promise.all(changedFiles.map(async (file) => {
98
- if (path.default.relative(dir, file.path).startsWith("..")) return;
99
- return file.state === "deleted" ? isomorphic_git.default.remove({
100
- fs: fs_extra.default,
101
- dir: gitRoot,
102
- filepath: file.path
103
- }) : isomorphic_git.default.add({
104
- fs: fs_extra.default,
105
- dir: gitRoot,
106
- filepath: file.path
107
- });
108
- }));
109
- return commit({
110
- dir: gitRoot,
111
- message,
112
- author,
113
- committer
114
- });
115
- };
116
- //#endregion
117
- //#region src/git/currentBranch.ts
118
- /**
119
- * Tries to return a Git branch name from CI environment variables.
120
- */
121
- const currentBranchFromEnvironment = (env = process.env) => env.BUILDKITE_BRANCH ?? env.GITHUB_HEAD_REF ?? env.GITHUB_REF_NAME;
122
- /**
123
- * Tries to return a Git branch name from CI environment variables, falling back
124
- * to the local Git repository when the current working `dir` is supplied.
125
- */
126
- const currentBranch = async ({ dir, env = process.env } = {}) => {
127
- const fromEnv = currentBranchFromEnvironment(env);
128
- if (fromEnv) return fromEnv;
129
- if (!dir) return;
130
- const gitRoot = await isomorphic_git.default.findRoot({
131
- filepath: dir,
132
- fs: fs_extra.default
133
- });
134
- return await isomorphic_git.default.currentBranch({
135
- dir: gitRoot,
136
- fs: fs_extra.default
137
- }) ?? void 0;
138
- };
139
- //#endregion
140
- //#region src/git/log.ts
141
- const EMPTY_GIT_LOG_ERROR = /* @__PURE__ */ new Error("Git log does not contain any commits");
142
- /**
143
- * Gets the object ID of the head commit.
144
- *
145
- * This tries to extract the commit ID from common CI environment variables,
146
- * and falls back to the local Git repository log.
147
- */
148
- const getHeadCommitId = async ({ dir, env = process.env }) => {
149
- const oidFromEnv = env.BUILDKITE_COMMIT ?? env.GITHUB_SHA;
150
- if (oidFromEnv) return oidFromEnv;
151
- const [headResult] = await isomorphic_git.default.log({
152
- depth: 1,
153
- dir,
154
- fs: fs_extra.default
155
- });
156
- if (!headResult) throw EMPTY_GIT_LOG_ERROR;
157
- return headResult.oid;
158
- };
159
- /**
160
- * Gets the message of the head commit.
161
- *
162
- * This tries to extract the message from common CI environment variables,
163
- * and falls back to the local Git repository log.
164
- */
165
- const getHeadCommitMessage = async ({ dir, env = process.env }) => {
166
- const messageFromEnv = env.BUILDKITE_MESSAGE;
167
- if (messageFromEnv) return messageFromEnv;
168
- const [headResult] = await isomorphic_git.default.log({
169
- depth: 1,
170
- dir,
171
- fs: fs_extra.default
172
- });
173
- if (!headResult) throw EMPTY_GIT_LOG_ERROR;
174
- return headResult.commit.message;
175
- };
176
- //#endregion
177
- //#region src/git/remote.ts
178
- /**
179
- * Matches the owner and repository names in a GitHub repository URL.
180
- *
181
- * For example, given the following input strings:
182
- *
183
- * ```console
184
- * git@github.com:seek-oss/skuba.git
185
- * https://github.com/seek-oss/skuba.git
186
- * ```
187
- *
188
- * This pattern will produce the following matches:
189
- *
190
- * 1. seek-oss
191
- * 2. skuba
192
- */
193
- const ownerRepoRegex = /github\.com(?::|\/)([a-zA-Z0-9._-]+)\/([a-zA-Z0-9._-]+)\.git$/;
194
- const ownerAndRepoFromUrl = (url) => {
195
- const match = ownerRepoRegex.exec(url);
196
- return {
197
- owner: match?.[1],
198
- repo: match?.[2]
199
- };
200
- };
201
- /**
202
- * Extracts the owner and repository names from CI environment variables,
203
- * falling back to local Git remotes.
204
- *
205
- * Currently, only GitHub repository URLs are supported:
206
- *
207
- * ```console
208
- * git@github.com:seek-oss/skuba.git
209
- * https://github.com/seek-oss/skuba.git
210
- * ```
211
- */
212
- const getOwnerAndRepo = async ({ dir, env = process.env }) => {
213
- if (env.GITHUB_REPOSITORY) {
214
- const [owner, repo] = env.GITHUB_REPOSITORY.split("/");
215
- if (owner && repo) return {
216
- owner,
217
- repo
218
- };
219
- }
220
- if (env.BUILDKITE_REPO) {
221
- const { owner, repo } = ownerAndRepoFromUrl(env.BUILDKITE_REPO);
222
- if (owner && repo) return {
223
- owner,
224
- repo
225
- };
226
- }
227
- const gitRoot = await isomorphic_git.default.findRoot({
228
- filepath: dir,
229
- fs: fs_extra.default
230
- });
231
- const remotes = await isomorphic_git.default.listRemotes({
232
- dir: gitRoot,
233
- fs: fs_extra.default
234
- });
235
- for (const { url } of remotes) {
236
- const { owner, repo } = ownerAndRepoFromUrl(url);
237
- if (owner && repo) return {
238
- owner,
239
- repo
240
- };
241
- }
242
- throw new Error("Could not find a GitHub remote");
243
- };
244
- //#endregion
245
- //#region ../../src/utils/env.ts
246
- /**
247
- * Whether the code is executing in a CI environment.
248
- */
249
- const isCiEnv = (env = process.env) => Boolean(env.BUILDKITE || env.CI || env.GITHUB_ACTIONS);
250
- //#endregion
251
- //#region src/github/environment.ts
252
- /**
253
- * Returns the name of the build as seen in GitHub status checks.
254
- *
255
- * This is driven off of environment variables and falls back to `Build`.
256
- */
257
- const buildNameFromEnvironment = (env = process.env) => {
258
- if (env.BUILDKITE_BUILD_NUMBER) return `Build #${env.BUILDKITE_BUILD_NUMBER}`;
259
- if (env.GITHUB_RUN_NUMBER) return `${env.GITHUB_WORKFLOW ?? "Build"} #${env.GITHUB_RUN_NUMBER}`;
260
- return "Build";
261
- };
262
- /**
263
- * Whether GitHub API interactions should be enabled.
264
- *
265
- * This checks environment variables to see if the code is executing in a CI
266
- * environment and has access to a GitHub API token.
267
- */
268
- const enabledFromEnvironment = (env = process.env) => isCiEnv(env) && Boolean(apiTokenFromEnvironment(env));
269
- /**
270
- * Tries to return a GitHub API token from the environment.
271
- */
272
- const apiTokenFromEnvironment = (env = process.env) => env.GITHUB_API_TOKEN ?? env.GITHUB_TOKEN;
273
- //#endregion
274
- //#region src/git/push.ts
275
- /**
276
- * Pushes the specified `ref` from the local Git repository to a remote.
277
- */
278
- const push = async ({ auth, dir, ref, remote, remoteRef, force }) => {
279
- const { owner, repo } = await getOwnerAndRepo({ dir });
280
- const url = `https://github.com/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`;
281
- return isomorphic_git.default.push({
282
- onAuth: () => ({
283
- username: "x-access-token",
284
- password: auth.token ?? apiTokenFromEnvironment()
285
- }),
286
- dir,
287
- fs: fs_extra.default,
288
- http: isomorphic_git_http_node.default,
289
- ref,
290
- remote,
291
- remoteRef,
292
- url,
293
- force
294
- });
295
- };
296
- //#endregion
297
- //#region src/git/pull.ts
298
- /**
299
- * Fast forwards the specified `ref` on the local Git repository to match the remote branch.
300
- */
301
- const fastForwardBranch = async ({ auth, dir, ref, remote, remoteRef }) => {
302
- const { owner, repo } = await getOwnerAndRepo({ dir });
303
- const url = `https://github.com/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`;
304
- return isomorphic_git.default.fastForward({
305
- onAuth: () => ({
306
- username: "x-access-token",
307
- password: auth.token ?? apiTokenFromEnvironment()
308
- }),
309
- dir,
310
- fs: fs_extra.default,
311
- http: isomorphic_git_http_node.default,
312
- ref,
313
- remote,
314
- remoteRef,
315
- url,
316
- singleBranch: true
317
- });
318
- };
319
- //#endregion
320
- //#region src/git/reset.ts
321
- /**
322
- * Resets the specified branch in the local Git repository to a particular
323
- * commit.
324
- */
325
- const reset = async ({ dir, branch, commitId, hard }) => {
326
- await fs_extra.default.promises.writeFile(path.default.join(dir, ".git/refs/heads", branch), `${commitId}\n`);
327
- if (hard) {
328
- const modifiedFiles = (await isomorphic_git.default.statusMatrix({
329
- dir,
330
- fs: fs_extra.default
331
- })).filter((row) => row[2] > 1 && row[3] > 1).map((row) => row[0]);
332
- await Promise.all(modifiedFiles.map((filePath) => fs_extra.default.promises.rm(filePath)));
333
- await isomorphic_git.default.checkout({
334
- dir,
335
- fs: fs_extra.default,
336
- ref: branch,
337
- force: true
338
- });
339
- }
340
- };
341
- //#endregion
342
- //#region src/git/isFileGitIgnored.ts
343
- const isFileGitIgnored = ({ absolutePath, gitRoot }) => isomorphic_git.default.isIgnored({
344
- dir: gitRoot,
345
- filepath: path.default.relative(gitRoot, absolutePath),
346
- fs: fs_extra.default
347
- });
348
- //#endregion
349
- //#region src/git/index.ts
350
- var git_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
351
- commit: () => commit,
352
- commitAllChanges: () => commitAllChanges,
353
- currentBranch: () => currentBranch,
354
- fastForwardBranch: () => fastForwardBranch,
355
- findRoot: () => findRoot$1,
356
- getChangedFiles: () => getChangedFiles,
357
- getHeadCommitId: () => getHeadCommitId,
358
- getHeadCommitMessage: () => getHeadCommitMessage,
359
- getOwnerAndRepo: () => getOwnerAndRepo,
360
- isFileGitIgnored: () => isFileGitIgnored,
361
- push: () => push,
362
- reset: () => reset
363
- });
364
- //#endregion
365
- Object.defineProperty(exports, "apiTokenFromEnvironment", {
366
- enumerable: true,
367
- get: function() {
368
- return apiTokenFromEnvironment;
369
- }
370
- });
371
- Object.defineProperty(exports, "buildNameFromEnvironment", {
372
- enumerable: true,
373
- get: function() {
374
- return buildNameFromEnvironment;
375
- }
376
- });
377
- Object.defineProperty(exports, "commit", {
378
- enumerable: true,
379
- get: function() {
380
- return commit;
381
- }
382
- });
383
- Object.defineProperty(exports, "commitAllChanges", {
384
- enumerable: true,
385
- get: function() {
386
- return commitAllChanges;
387
- }
388
- });
389
- Object.defineProperty(exports, "currentBranch", {
390
- enumerable: true,
391
- get: function() {
392
- return currentBranch;
393
- }
394
- });
395
- Object.defineProperty(exports, "enabledFromEnvironment", {
396
- enumerable: true,
397
- get: function() {
398
- return enabledFromEnvironment;
399
- }
400
- });
401
- Object.defineProperty(exports, "fastForwardBranch", {
402
- enumerable: true,
403
- get: function() {
404
- return fastForwardBranch;
405
- }
406
- });
407
- Object.defineProperty(exports, "findRoot", {
408
- enumerable: true,
409
- get: function() {
410
- return findRoot$1;
411
- }
412
- });
413
- Object.defineProperty(exports, "getChangedFiles", {
414
- enumerable: true,
415
- get: function() {
416
- return getChangedFiles;
417
- }
418
- });
419
- Object.defineProperty(exports, "getHeadCommitId", {
420
- enumerable: true,
421
- get: function() {
422
- return getHeadCommitId;
423
- }
424
- });
425
- Object.defineProperty(exports, "getHeadCommitMessage", {
426
- enumerable: true,
427
- get: function() {
428
- return getHeadCommitMessage;
429
- }
430
- });
431
- Object.defineProperty(exports, "getOwnerAndRepo", {
432
- enumerable: true,
433
- get: function() {
434
- return getOwnerAndRepo;
435
- }
436
- });
437
- Object.defineProperty(exports, "git_exports", {
438
- enumerable: true,
439
- get: function() {
440
- return git_exports;
441
- }
442
- });
443
- Object.defineProperty(exports, "isFileGitIgnored", {
444
- enumerable: true,
445
- get: function() {
446
- return isFileGitIgnored;
447
- }
448
- });
449
- Object.defineProperty(exports, "push", {
450
- enumerable: true,
451
- get: function() {
452
- return push;
453
- }
454
- });
455
- Object.defineProperty(exports, "reset", {
456
- enumerable: true,
457
- get: function() {
458
- return reset;
459
- }
460
- });
@@ -1,12 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_git = require("../git-D98vomnD.cjs");
3
- const require_github = require("../github-D12IboDc.cjs");
4
- exports.apiTokenFromEnvironment = require_git.apiTokenFromEnvironment;
5
- exports.buildNameFromEnvironment = require_git.buildNameFromEnvironment;
6
- exports.createCheckRun = require_github.createCheckRun;
7
- exports.enabledFromEnvironment = require_git.enabledFromEnvironment;
8
- exports.getPullRequestNumber = require_github.getPullRequestNumber;
9
- exports.putIssueComment = require_github.putIssueComment;
10
- exports.readFileChanges = require_github.readFileChanges;
11
- exports.uploadAllFileChanges = require_github.uploadAllFileChanges;
12
- exports.uploadFileChanges = require_github.uploadFileChanges;
@@ -1,2 +0,0 @@
1
- import { a as putIssueComment, c as buildNameFromEnvironment, d as createCheckRun, i as uploadFileChanges, l as enabledFromEnvironment, n as readFileChanges, o as getPullRequestNumber, r as uploadAllFileChanges, s as apiTokenFromEnvironment, u as Annotation } from "../index-D4JUiy2k.cjs";
2
- export { type Annotation, apiTokenFromEnvironment, buildNameFromEnvironment, createCheckRun, enabledFromEnvironment, getPullRequestNumber, putIssueComment, readFileChanges, uploadAllFileChanges, uploadFileChanges };