@skuba-lib/api 3.0.0-add-cdk-NodejsFunction-20260620003026 → 3.0.0-add-sigterm-patch-20261005222523

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 (67) hide show
  1. package/lib/buildkite/index.cjs +4 -0
  2. package/lib/buildkite/index.d.cts +2 -0
  3. package/lib/buildkite/index.mjs +1 -1
  4. package/lib/{buildkite-DCSmKf_B.mjs → buildkite-C7bwlxiU.mjs} +4 -6
  5. package/lib/buildkite-z4owathk.cjs +60 -0
  6. package/lib/cdk/index.cjs +13 -0
  7. package/lib/cdk/index.d.cts +6 -0
  8. package/lib/cdk/index.d.mts +5 -13
  9. package/lib/cdk/index.mjs +5 -19
  10. package/lib/error-CxiNRw9A.mjs +15 -0
  11. package/lib/error-CzNs0bXO.cjs +23 -0
  12. package/lib/{exec-CbhqWxN4.mjs → exec-Csi1HI7c.mjs} +1 -2
  13. package/lib/exec-DCUB5Shx.cjs +81 -0
  14. package/lib/fs-BrQNZY8y.mjs +14 -0
  15. package/lib/fs-DS2eIMxA.cjs +21 -0
  16. package/lib/git/index.cjs +14 -0
  17. package/lib/git/index.d.cts +2 -0
  18. package/lib/git/index.d.mts +1 -1
  19. package/lib/git/index.mjs +1 -1
  20. package/lib/{git-BHbneN9r.mjs → git-DKqd7R1V.mjs} +73 -21
  21. package/lib/git-DMONyZI2.cjs +512 -0
  22. package/lib/github/index.cjs +12 -0
  23. package/lib/github/index.d.cts +2 -0
  24. package/lib/github/index.d.mts +1 -1
  25. package/lib/github/index.mjs +2 -2
  26. package/lib/github-AhCiyYZt.cjs +297 -0
  27. package/lib/{github-Buehx6Xt.mjs → github-DsrERrG3.mjs} +19 -17
  28. package/lib/{index-DbjgHTTm.d.mts → index--hWvZI6b.d.cts} +4 -25
  29. package/lib/index-BKHTGdUP.d.cts +97 -0
  30. package/lib/index-BKHTGdUP.d.mts +97 -0
  31. package/lib/{index-Kyp8ZCwF.d.mts → index-C9lVo3vU.d.cts} +1 -6
  32. package/lib/index-C9lVo3vU.d.mts +33 -0
  33. package/lib/{index-C9WMO_Y9.d.mts → index-CLEYcnJY.d.cts} +35 -65
  34. package/lib/index-CLEYcnJY.d.mts +248 -0
  35. package/lib/index-CNxgBJm_.d.cts +39 -0
  36. package/lib/index-J0PI37zH.d.mts +238 -0
  37. package/lib/index.cjs +43 -0
  38. package/lib/index.d.cts +7 -0
  39. package/lib/index.d.mts +6 -4
  40. package/lib/index.mjs +7 -5
  41. package/lib/{error-BYLsj5YU.mjs → logging-BQNEupxh.mjs} +1 -15
  42. package/lib/logging-BqpzZfsF.cjs +39 -0
  43. package/lib/net/index.cjs +3 -0
  44. package/lib/net/index.d.cts +2 -0
  45. package/lib/net/index.d.mts +1 -1
  46. package/lib/net/index.mjs +1 -1
  47. package/lib/{net-CbEVAvJj.mjs → net-Bf2HV_vG.mjs} +2 -2
  48. package/lib/net-HILKQTAq.cjs +79 -0
  49. package/lib/rolldown/index.cjs +3 -0
  50. package/lib/rolldown/index.d.cts +2 -0
  51. package/lib/rolldown/index.d.mts +2 -0
  52. package/lib/rolldown/index.mjs +2 -0
  53. package/lib/rolldown-CH9krqYt.mjs +265 -0
  54. package/lib/rolldown-CV08omMx.cjs +278 -0
  55. package/lib/rolldown-runtime-C0BPl7ul.cjs +43 -0
  56. package/lib/{rolldown-runtime-8H4AJuhK.mjs → rolldown-runtime-D7D4PA-g.mjs} +0 -1
  57. package/package.json +45 -28
  58. package/buildkite/package.json +0 -5
  59. package/cdk/nodejsFunction/package.json +0 -5
  60. package/cdk/package.json +0 -5
  61. package/git/package.json +0 -5
  62. package/github/package.json +0 -5
  63. package/lib/cdk/bridges/rolldown.mjs +0 -50
  64. package/lib/cdk/nodejsFunction/index.d.mts +0 -2
  65. package/lib/cdk/nodejsFunction/index.mjs +0 -334
  66. package/lib/index-DnMMX6Ji.d.mts +0 -32
  67. package/net/package.json +0 -5
@@ -0,0 +1,4 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_buildkite = require("../buildkite-z4owathk.cjs");
3
+ exports.annotate = require_buildkite.annotate;
4
+ exports.md = require_buildkite.md;
@@ -0,0 +1,2 @@
1
+ import { i as annotate, n as md, r as AnnotationStyle } from "../index-CNxgBJm_.cjs";
2
+ export { type AnnotationStyle, annotate, md };
@@ -1,2 +1,2 @@
1
- import { n as md, r as annotate } from "../buildkite-DCSmKf_B.mjs";
1
+ import { n as md, r as annotate } from "../buildkite-C7bwlxiU.mjs";
2
2
  export { annotate, md };
@@ -1,9 +1,8 @@
1
- import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
2
- import { n as log } from "./error-BYLsj5YU.mjs";
3
- import { n as exec, r as hasCommand } from "./exec-CbhqWxN4.mjs";
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
+ import { t as log } from "./logging-BQNEupxh.mjs";
3
+ import { n as exec, r as hasCommand } from "./exec-Csi1HI7c.mjs";
4
4
  //#region src/buildkite/annotate.ts
5
5
  const isAnnotationEnabled = async () => Boolean(process.env.BUILDKITE && process.env.BUILDKITE_AGENT_ACCESS_TOKEN && process.env.BUILDKITE_JOB_ID && await hasCommand("buildkite-agent"));
6
- const MAX_SIZE = 1024 * 1024;
7
6
  const TRUNCATION_WARNING = "... [Truncated due to size limit]";
8
7
  /**
9
8
  * Asynchronously uploads a Buildkite annotation.
@@ -21,8 +20,7 @@ const annotate = async (markdown, opts = {}) => {
21
20
  if (!await isAnnotationEnabled()) return;
22
21
  let truncatedMarkdown = markdown;
23
22
  if (markdown.length > 1048576) {
24
- const remainingSpace = MAX_SIZE - 33;
25
- truncatedMarkdown = markdown.slice(0, remainingSpace) + TRUNCATION_WARNING;
23
+ truncatedMarkdown = markdown.slice(0, 1048543) + TRUNCATION_WARNING;
26
24
  log.warn(`Annotation truncated, full message is: ${markdown}`);
27
25
  }
28
26
  const context = [opts.scopeContextToStep && process.env.BUILDKITE_STEP_ID, opts.context].filter(Boolean).join("|");
@@ -0,0 +1,60 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
2
+ const require_logging = require("./logging-BqpzZfsF.cjs");
3
+ const require_exec = require("./exec-DCUB5Shx.cjs");
4
+ //#region src/buildkite/annotate.ts
5
+ const isAnnotationEnabled = async () => Boolean(process.env.BUILDKITE && process.env.BUILDKITE_AGENT_ACCESS_TOKEN && process.env.BUILDKITE_JOB_ID && await require_exec.hasCommand("buildkite-agent"));
6
+ const TRUNCATION_WARNING = "... [Truncated due to size limit]";
7
+ /**
8
+ * Asynchronously uploads a Buildkite annotation.
9
+ *
10
+ * If the following environment variables are not present,
11
+ * the function will silently return without attempting to annotate:
12
+ *
13
+ * - `BUILDKITE`
14
+ * - `BUILDKITE_AGENT_ACCESS_TOKEN`
15
+ * - `BUILDKITE_JOB_ID`
16
+ *
17
+ * The `buildkite-agent` binary must also be on your `PATH`.
18
+ */
19
+ const annotate = async (markdown, opts = {}) => {
20
+ if (!await isAnnotationEnabled()) return;
21
+ let truncatedMarkdown = markdown;
22
+ if (markdown.length > 1048576) {
23
+ truncatedMarkdown = markdown.slice(0, 1048543) + TRUNCATION_WARNING;
24
+ require_logging.log.warn(`Annotation truncated, full message is: ${markdown}`);
25
+ }
26
+ const context = [opts.scopeContextToStep && process.env.BUILDKITE_STEP_ID, opts.context].filter(Boolean).join("|");
27
+ const { style } = opts;
28
+ await require_exec.exec("buildkite-agent", "annotate", ...context ? ["--context", context] : [], ...style ? ["--style", style] : [], truncatedMarkdown);
29
+ };
30
+ //#endregion
31
+ //#region src/buildkite/md.ts
32
+ /**
33
+ * @internal
34
+ */
35
+ const md = { terminal: (code) => `\`\`\`term\n${code.replace(/```/g, "\\`\\`\\`")}\n\`\`\`` };
36
+ //#endregion
37
+ //#region src/buildkite/index.ts
38
+ var buildkite_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
39
+ annotate: () => annotate,
40
+ md: () => md
41
+ });
42
+ //#endregion
43
+ Object.defineProperty(exports, "annotate", {
44
+ enumerable: true,
45
+ get: function() {
46
+ return annotate;
47
+ }
48
+ });
49
+ Object.defineProperty(exports, "buildkite_exports", {
50
+ enumerable: true,
51
+ get: function() {
52
+ return buildkite_exports;
53
+ }
54
+ });
55
+ Object.defineProperty(exports, "md", {
56
+ enumerable: true,
57
+ get: function() {
58
+ return md;
59
+ }
60
+ });
@@ -0,0 +1,13 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/cdk/index.ts
3
+ var cdk_exports = /* @__PURE__ */ require("../rolldown-runtime-C0BPl7ul.cjs").__exportAll({ normaliseTemplate: () => normaliseTemplate });
4
+ const normaliseTemplateJsonString = (json) => json.replace(/"S3Key":"([0-9a-f]+)\.zip"/g, (_, hash) => `"S3Key":"${"x".repeat(hash.length)}.zip"`).replace(/CurrentVersion([0-9a-zA-Z]+)"/g, (_, hash) => `CurrentVersion${"x".repeat(hash.length)}"`).replaceAll(/"Value":"\d+\.\d+\.\d+-([^"]+)"/g, (_, hash) => `"Value": "x.x.x-${"x".repeat(hash.length)}"`).replaceAll(/"Value":"v\d+\.\d+\.\d+"/g, (_) => "\"Value\": \"vx.x.x\"").replace(/"DD_TAGS":"git.commit.sha:([0-9a-f]+),git.repository_url:([^\"]+)",/g, "").replaceAll(/(layer:Datadog-[^-]+-.+?:)\d+/g, (_, layer) => `${layer}x`);
5
+ const normaliseTemplate = (template) => JSON.parse(normaliseTemplateJsonString(JSON.stringify(template)));
6
+ //#endregion
7
+ Object.defineProperty(exports, "cdk_exports", {
8
+ enumerable: true,
9
+ get: function() {
10
+ return cdk_exports;
11
+ }
12
+ });
13
+ exports.normaliseTemplate = normaliseTemplate;
@@ -0,0 +1,6 @@
1
+ declare namespace index_d_exports {
2
+ export { normaliseTemplate };
3
+ }
4
+ export declare const normaliseTemplate: (template: object) => unknown;
5
+ //#endregion
6
+ export { index_d_exports as t };
@@ -1,14 +1,6 @@
1
- import { i as ICommandHooks, n as NodejsFunctionProps, r as BundlingOptions, t as NodejsFunction } from "../index-DnMMX6Ji.mjs";
2
-
3
- //#region src/cdk/index.d.ts
4
- declare const Cdk: {
5
- normaliseTemplate: (template: object) => unknown;
6
- /**
7
- * Lazily loads {@link NodejsFunction} on first access so that the optional
8
- * `aws-cdk-lib` and `constructs` peer dependencies are only required by
9
- * consumers that actually use the construct.
10
- */
11
- readonly NodejsFunction: typeof NodejsFunction;
12
- };
1
+ declare namespace index_d_exports {
2
+ export { normaliseTemplate };
3
+ }
4
+ export declare const normaliseTemplate: (template: object) => unknown;
13
5
  //#endregion
14
- export { type BundlingOptions, Cdk, type ICommandHooks, type NodejsFunctionProps };
6
+ export { index_d_exports as t };
package/lib/cdk/index.mjs CHANGED
@@ -1,21 +1,7 @@
1
- import { createRequire } from "node:module";
2
- //#region src/cdk/normaliseTemplate/index.ts
3
- const normaliseTemplateJsonString = (json) => json.replace(/"S3Key":"([0-9a-f]+)\.zip"/g, (_, hash) => `"S3Key":"${"x".repeat(hash.length)}.zip"`).replace(/workerCurrentVersion([0-9a-zA-Z]+)"/g, (_, hash) => `workerCurrentVersion${"x".repeat(hash.length)}"`).replaceAll(/"Value":"\d+\.\d+\.\d+-([^"]+)"/g, (_, hash) => `"Value": "x.x.x-${"x".repeat(hash.length)}"`).replaceAll(/"Value":"v\d+\.\d+\.\d+"/g, (_) => "\"Value\": \"vx.x.x\"").replace(/"DD_TAGS":"git.commit.sha:([0-9a-f]+),git.repository_url:([^\"]+)",/g, "").replaceAll(/(layer:Datadog-[^-]+-.+?:)\d+/g, (_, layer) => `${layer}x`);
4
- const normaliseTemplate = (template) => JSON.parse(normaliseTemplateJsonString(JSON.stringify(template)));
5
- //#endregion
1
+ import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
6
2
  //#region src/cdk/index.ts
7
- const require = createRequire(import.meta.url);
8
- let cached;
9
- const Cdk = {
10
- normaliseTemplate,
11
- /**
12
- * Lazily loads {@link NodejsFunction} on first access so that the optional
13
- * `aws-cdk-lib` and `constructs` peer dependencies are only required by
14
- * consumers that actually use the construct.
15
- */
16
- get NodejsFunction() {
17
- return cached ??= require("@skuba-lib/api/cdk/nodejsFunction").NodejsFunction;
18
- }
19
- };
3
+ var cdk_exports = /* @__PURE__ */ __exportAll({ normaliseTemplate: () => normaliseTemplate });
4
+ const normaliseTemplateJsonString = (json) => json.replace(/"S3Key":"([0-9a-f]+)\.zip"/g, (_, hash) => `"S3Key":"${"x".repeat(hash.length)}.zip"`).replace(/CurrentVersion([0-9a-zA-Z]+)"/g, (_, hash) => `CurrentVersion${"x".repeat(hash.length)}"`).replaceAll(/"Value":"\d+\.\d+\.\d+-([^"]+)"/g, (_, hash) => `"Value": "x.x.x-${"x".repeat(hash.length)}"`).replaceAll(/"Value":"v\d+\.\d+\.\d+"/g, (_) => "\"Value\": \"vx.x.x\"").replace(/"DD_TAGS":"git.commit.sha:([0-9a-f]+),git.repository_url:([^\"]+)",/g, "").replaceAll(/(layer:Datadog-[^-]+-.+?:)\d+/g, (_, layer) => `${layer}x`);
5
+ const normaliseTemplate = (template) => JSON.parse(normaliseTemplateJsonString(JSON.stringify(template)));
20
6
  //#endregion
21
- export { Cdk };
7
+ export { normaliseTemplate, cdk_exports as t };
@@ -0,0 +1,15 @@
1
+ import * as z from "zod/v4";
2
+ //#region ../../src/utils/validation.ts
3
+ const isObject = (value) => typeof value === "object" && value !== null;
4
+ const hasProp = (value, prop) => isObject(value) && value.hasOwnProperty(prop);
5
+ z.array(z.object({
6
+ command: z.object({
7
+ command: z.string(),
8
+ name: z.string()
9
+ }),
10
+ index: z.number(),
11
+ exitCode: z.number()
12
+ }));
13
+ const isErrorWithCode = (err, code) => hasProp(err, "code") && err.code === code;
14
+ //#endregion
15
+ export { isErrorWithCode as t };
@@ -0,0 +1,23 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
2
+ require("util");
3
+ let zod_v4 = require("zod/v4");
4
+ zod_v4 = require_rolldown_runtime.__toESM(zod_v4, 1);
5
+ //#region ../../src/utils/validation.ts
6
+ const isObject = (value) => typeof value === "object" && value !== null;
7
+ const hasProp = (value, prop) => isObject(value) && value.hasOwnProperty(prop);
8
+ zod_v4.array(zod_v4.object({
9
+ command: zod_v4.object({
10
+ command: zod_v4.string(),
11
+ name: zod_v4.string()
12
+ }),
13
+ index: zod_v4.number(),
14
+ exitCode: zod_v4.number()
15
+ }));
16
+ const isErrorWithCode = (err, code) => hasProp(err, "code") && err.code === code;
17
+ //#endregion
18
+ Object.defineProperty(exports, "isErrorWithCode", {
19
+ enumerable: true,
20
+ get: function() {
21
+ return isErrorWithCode;
22
+ }
23
+ });
@@ -1,4 +1,4 @@
1
- import { t as isErrorWithCode } from "./error-BYLsj5YU.mjs";
1
+ import { t as isErrorWithCode } from "./error-CxiNRw9A.mjs";
2
2
  import stream from "stream";
3
3
  import util from "util";
4
4
  import "concurrently";
@@ -40,7 +40,6 @@ const runCommand = (command, args, { streamStdio, ...execaOptions } = {}) => {
40
40
  case true:
41
41
  subprocess.stderr?.pipe(process.stderr);
42
42
  subprocess.stdout?.pipe(process.stdout);
43
- break;
44
43
  }
45
44
  return subprocess;
46
45
  };
@@ -0,0 +1,81 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
2
+ const require_error = require("./error-CzNs0bXO.cjs");
3
+ let stream = require("stream");
4
+ stream = require_rolldown_runtime.__toESM(stream, 1);
5
+ let util = require("util");
6
+ util = require_rolldown_runtime.__toESM(util, 1);
7
+ require("concurrently");
8
+ let execa = require("execa");
9
+ let npm_run_path = require("npm-run-path");
10
+ let npm_which = require("npm-which");
11
+ npm_which = require_rolldown_runtime.__toESM(npm_which, 1);
12
+ //#region ../../src/utils/exec.ts
13
+ var YarnSpamFilter = class extends stream.default.Transform {
14
+ silenced = false;
15
+ _transform(chunk, _encoding, callback) {
16
+ const str = Buffer.from(chunk).toString();
17
+ if (str.startsWith("info Direct dependencies")) this.silenced = true;
18
+ if (!this.silenced && !str.startsWith("info No lockfile found")) this.push(chunk);
19
+ callback();
20
+ }
21
+ };
22
+ var YarnWarningFilter = class extends stream.default.Transform {
23
+ _transform(chunk, _encoding, callback) {
24
+ if (!Buffer.from(chunk).toString().startsWith("warning skuba >")) this.push(chunk);
25
+ callback();
26
+ }
27
+ };
28
+ (0, npm_run_path.npmRunPath)({ cwd: __dirname });
29
+ const runCommand = (command, args, { streamStdio, ...execaOptions } = {}) => {
30
+ const subprocess = (0, execa.execa)(command, args, {
31
+ localDir: execaOptions?.localDir ?? __dirname,
32
+ preferLocal: true,
33
+ stdio: "inherit",
34
+ ...execaOptions
35
+ });
36
+ switch (streamStdio) {
37
+ case "yarn":
38
+ const stderrFilter = new YarnWarningFilter();
39
+ const stdoutFilter = new YarnSpamFilter();
40
+ subprocess.stderr?.pipe(stderrFilter).pipe(process.stderr);
41
+ subprocess.stdout?.pipe(stdoutFilter).pipe(process.stdout);
42
+ break;
43
+ case "pnpm":
44
+ case true:
45
+ subprocess.stderr?.pipe(process.stderr);
46
+ subprocess.stdout?.pipe(process.stdout);
47
+ }
48
+ return subprocess;
49
+ };
50
+ const whichCallback = (0, npm_which.default)(__dirname);
51
+ const which = util.default.promisify(whichCallback);
52
+ const createExec = (opts) => (command, ...args) => runCommand(command, args, opts);
53
+ const exec = (command, ...args) => runCommand(command, args);
54
+ const hasCommand = async (name) => {
55
+ try {
56
+ await which(name);
57
+ return true;
58
+ } catch (err) {
59
+ if (require_error.isErrorWithCode(err, "ENOENT")) return false;
60
+ throw err;
61
+ }
62
+ };
63
+ //#endregion
64
+ Object.defineProperty(exports, "createExec", {
65
+ enumerable: true,
66
+ get: function() {
67
+ return createExec;
68
+ }
69
+ });
70
+ Object.defineProperty(exports, "exec", {
71
+ enumerable: true,
72
+ get: function() {
73
+ return exec;
74
+ }
75
+ });
76
+ Object.defineProperty(exports, "hasCommand", {
77
+ enumerable: true,
78
+ get: function() {
79
+ return hasCommand;
80
+ }
81
+ });
@@ -0,0 +1,14 @@
1
+ import { t as isErrorWithCode } from "./error-CxiNRw9A.mjs";
2
+ import fs from "fs-extra";
3
+ //#region ../../src/utils/fs.ts
4
+ const pathExists = async (filePath) => {
5
+ try {
6
+ await fs.promises.access(filePath);
7
+ return true;
8
+ } catch (error) {
9
+ if (isErrorWithCode(error, "ENOENT")) return false;
10
+ throw error;
11
+ }
12
+ };
13
+ //#endregion
14
+ export { pathExists as t };
@@ -0,0 +1,21 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
2
+ const require_error = require("./error-CzNs0bXO.cjs");
3
+ let fs_extra = require("fs-extra");
4
+ fs_extra = require_rolldown_runtime.__toESM(fs_extra, 1);
5
+ //#region ../../src/utils/fs.ts
6
+ const pathExists = async (filePath) => {
7
+ try {
8
+ await fs_extra.default.promises.access(filePath);
9
+ return true;
10
+ } catch (error) {
11
+ if (require_error.isErrorWithCode(error, "ENOENT")) return false;
12
+ throw error;
13
+ }
14
+ };
15
+ //#endregion
16
+ Object.defineProperty(exports, "pathExists", {
17
+ enumerable: true,
18
+ get: function() {
19
+ return pathExists;
20
+ }
21
+ });
@@ -0,0 +1,14 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_git = require("../git-DMONyZI2.cjs");
3
+ exports.commit = require_git.commit;
4
+ exports.commitAllChanges = require_git.commitAllChanges;
5
+ exports.currentBranch = require_git.currentBranch;
6
+ exports.fastForwardBranch = require_git.fastForwardBranch;
7
+ exports.findRoot = require_git.findRoot;
8
+ exports.getChangedFiles = require_git.getChangedFiles;
9
+ exports.getHeadCommitId = require_git.getHeadCommitId;
10
+ exports.getHeadCommitMessage = require_git.getHeadCommitMessage;
11
+ exports.getOwnerAndRepo = require_git.getOwnerAndRepo;
12
+ exports.isFileGitIgnored = require_git.isFileGitIgnored;
13
+ exports.push = require_git.push;
14
+ exports.reset = require_git.reset;
@@ -0,0 +1,2 @@
1
+ import { a as push, c as getHeadCommitMessage, d as commitAllChanges, f as ChangedFile, i as fastForwardBranch, l as findRoot, m as commit, n as isFileGitIgnored, o as getOwnerAndRepo, p as getChangedFiles, r as reset, s as getHeadCommitId, u as currentBranch } from "../index-CLEYcnJY.cjs";
2
+ export { type ChangedFile, commit, commitAllChanges, currentBranch, fastForwardBranch, findRoot, getChangedFiles, getHeadCommitId, getHeadCommitMessage, getOwnerAndRepo, isFileGitIgnored, push, reset };
@@ -1,2 +1,2 @@
1
- import { a as push, c as getHeadCommitMessage, d as commitAllChanges, f as ChangedFile, i as fastForwardBranch, l as findRoot, m as commit, n as isFileGitIgnored, o as getOwnerAndRepo, p as getChangedFiles, r as reset, s as getHeadCommitId, u as currentBranch } from "../index-C9WMO_Y9.mjs";
1
+ import { a as push, c as getHeadCommitMessage, d as commitAllChanges, f as ChangedFile, i as fastForwardBranch, l as findRoot, m as commit, n as isFileGitIgnored, o as getOwnerAndRepo, p as getChangedFiles, r as reset, s as getHeadCommitId, u as currentBranch } from "../index-CLEYcnJY.mjs";
2
2
  export { type ChangedFile, commit, commitAllChanges, currentBranch, fastForwardBranch, findRoot, getChangedFiles, getHeadCommitId, getHeadCommitMessage, getOwnerAndRepo, isFileGitIgnored, push, reset };
package/lib/git/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as push, d as getHeadCommitMessage, f as currentBranch, g as commit, h as findRoot, i as fastForwardBranch, l as getOwnerAndRepo, m as getChangedFiles, n as isFileGitIgnored, p as commitAllChanges, r as reset, u as getHeadCommitId } from "../git-BHbneN9r.mjs";
1
+ import { a as push, d as getHeadCommitMessage, f as currentBranch, g as commit, h as findRoot, i as fastForwardBranch, l as getOwnerAndRepo, m as getChangedFiles, n as isFileGitIgnored, p as commitAllChanges, r as reset, u as getHeadCommitId } from "../git-DKqd7R1V.mjs";
2
2
  export { commit, commitAllChanges, currentBranch, fastForwardBranch, findRoot, getChangedFiles, getHeadCommitId, getHeadCommitMessage, getOwnerAndRepo, isFileGitIgnored, push, reset };
@@ -1,5 +1,5 @@
1
- import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
2
- import { t as isErrorWithCode } from "./error-BYLsj5YU.mjs";
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
+ import { t as pathExists } from "./fs-BrQNZY8y.mjs";
3
3
  import fs from "fs-extra";
4
4
  import git, { findRoot } from "isomorphic-git";
5
5
  import path from "path";
@@ -34,17 +34,6 @@ const findRoot$1 = async ({ dir }) => {
34
34
  }
35
35
  };
36
36
  //#endregion
37
- //#region ../../src/utils/fs.ts
38
- const pathExists = async (filePath) => {
39
- try {
40
- await fs.promises.access(filePath);
41
- return true;
42
- } catch (error) {
43
- if (isErrorWithCode(error, "ENOENT")) return false;
44
- throw error;
45
- }
46
- };
47
- //#endregion
48
37
  //#region src/git/getChangedFiles.ts
49
38
  const mapState = (row) => {
50
39
  if (row[1] === 0) return "added";
@@ -52,22 +41,85 @@ const mapState = (row) => {
52
41
  return "deleted";
53
42
  };
54
43
  /**
55
- * Returns all the files which have been added, modified or deleted in the
56
- * working directory of the local Git repository since the last commit.
44
+ * Returns all the files which have been added, modified or deleted.
45
+ *
46
+ * Defaults to file changes in the working directory of the local Git repository
47
+ * since the last commit, but can also look at a specific `dst` reference, or
48
+ * the changes between `src` and `dst` references.
57
49
  */
58
- const getChangedFiles = async ({ dir, ignore = [] }) => {
50
+ const getChangedFiles = async ({ dir, src, dst, ignore = [] }) => {
59
51
  const gitRoot = await findRoot({
60
52
  fs,
61
53
  filepath: dir
62
54
  });
63
- const [allFiles, isLfs] = await Promise.all([git.statusMatrix({
55
+ const repoDir = gitRoot ?? dir;
56
+ const [allFiles, isLfs] = await Promise.all([dst ? getChangedFilesFromRefs({
57
+ dir: repoDir,
58
+ src,
59
+ dst
60
+ }) : getChangedFilesInWorkingDirectory(repoDir), createIsLfsFilter(gitRoot)]);
61
+ return allFiles.filter((changedFile) => !ignore.some((i) => i.path === changedFile.path && i.state === changedFile.state) && !isLfs(changedFile.path));
62
+ };
63
+ const getChangedFilesInWorkingDirectory = async (dir) => {
64
+ return (await git.statusMatrix({
64
65
  fs,
65
- dir: gitRoot ?? dir
66
- }), createIsLfsFilter(gitRoot)]);
67
- return allFiles.filter((row) => row[1] !== 1 || row[2] !== 1 || row[3] !== 1).map((row) => ({
66
+ dir
67
+ })).filter((row) => row[1] !== 1 || row[2] !== 1 || row[3] !== 1).map((row) => ({
68
68
  path: row[0],
69
69
  state: mapState(row)
70
- })).filter((changedFile) => !ignore.some((i) => i.path === changedFile.path && i.state === changedFile.state) && !isLfs(changedFile.path));
70
+ }));
71
+ };
72
+ const getChangedFilesFromRefs = async ({ dir, src, dst }) => {
73
+ const dstOid = await git.resolveRef({
74
+ fs,
75
+ dir,
76
+ ref: dst
77
+ });
78
+ let ref = src;
79
+ if (!ref) {
80
+ const { commit } = await git.readCommit({
81
+ fs,
82
+ dir,
83
+ oid: dstOid
84
+ });
85
+ if (!commit.parent[0]) throw new Error(`Failed to determine changed files in Git: src parameter was omitted but dst (${dst} -> ${dstOid}) has no parent`);
86
+ ref = `${commit.parent[0]}`;
87
+ }
88
+ const srcOid = await git.resolveRef({
89
+ fs,
90
+ dir,
91
+ ref
92
+ });
93
+ const files = [];
94
+ await git.walk({
95
+ fs,
96
+ dir,
97
+ trees: [git.TREE({ ref: srcOid }), git.TREE({ ref: dstOid })],
98
+ map: async (filepath, entries) => {
99
+ if (filepath === ".") return;
100
+ const [srcEntry, dstEntry] = entries;
101
+ const srcTypePromise = srcEntry?.type?.();
102
+ const dstTypePromise = dstEntry?.type?.();
103
+ const [srcType, dstType] = await Promise.all([srcTypePromise, dstTypePromise]);
104
+ if (srcType === "tree" || dstType === "tree") return;
105
+ const srcOidPromise = srcEntry?.oid?.();
106
+ const dstOidPromise = dstEntry?.oid?.();
107
+ const [srcEntryOid, dstEntryOid] = await Promise.all([srcOidPromise, dstOidPromise]);
108
+ if (!srcEntryOid && dstEntryOid) return files.push({
109
+ path: filepath,
110
+ state: "added"
111
+ });
112
+ if (srcEntryOid && !dstEntryOid) return files.push({
113
+ path: filepath,
114
+ state: "deleted"
115
+ });
116
+ if (srcEntryOid !== dstEntryOid) return files.push({
117
+ path: filepath,
118
+ state: "modified"
119
+ });
120
+ }
121
+ });
122
+ return files;
71
123
  };
72
124
  const createIsLfsFilter = async (gitRoot) => {
73
125
  if (!gitRoot) return () => false;