mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 22:44:13 +08:00
tsc
This commit is contained in:
@@ -207,7 +207,7 @@ async function run() {
|
|||||||
|
|
||||||
// Update the comment using the extracted updateClaudeComment function
|
// Update the comment using the extracted updateClaudeComment function
|
||||||
try {
|
try {
|
||||||
await updateClaudeComment(octokit, {
|
await updateClaudeComment(octokit.rest, {
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
commentId,
|
commentId,
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export async function updateTrackingComment(
|
|||||||
try {
|
try {
|
||||||
const isPRReviewComment = isPullRequestReviewCommentEvent(context);
|
const isPRReviewComment = isPullRequestReviewCommentEvent(context);
|
||||||
|
|
||||||
await updateClaudeComment(octokit, {
|
await updateClaudeComment(octokit.rest, {
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
commentId,
|
commentId,
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ describe("prepareMcpConfig", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("should return base config when no additional config is provided", async () => {
|
test("should return base config when no additional config is provided", async () => {
|
||||||
const result = await prepareMcpConfig(
|
const result = await prepareMcpConfig({
|
||||||
"test-token",
|
githubToken: "test-token",
|
||||||
"test-owner",
|
owner: "test-owner",
|
||||||
"test-repo",
|
repo: "test-repo",
|
||||||
"test-branch",
|
branch: "test-branch",
|
||||||
);
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
expect(parsed.mcpServers).toBeDefined();
|
expect(parsed.mcpServers).toBeDefined();
|
||||||
@@ -50,13 +50,13 @@ describe("prepareMcpConfig", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("should return base config when additional config is empty string", async () => {
|
test("should return base config when additional config is empty string", async () => {
|
||||||
const result = await prepareMcpConfig(
|
const result = await prepareMcpConfig({
|
||||||
"test-token",
|
githubToken: "test-token",
|
||||||
"test-owner",
|
owner: "test-owner",
|
||||||
"test-repo",
|
repo: "test-repo",
|
||||||
"test-branch",
|
branch: "test-branch",
|
||||||
"",
|
additionalMcpConfig: "",
|
||||||
);
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
expect(parsed.mcpServers).toBeDefined();
|
expect(parsed.mcpServers).toBeDefined();
|
||||||
@@ -66,13 +66,13 @@ describe("prepareMcpConfig", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("should return base config when additional config is whitespace only", async () => {
|
test("should return base config when additional config is whitespace only", async () => {
|
||||||
const result = await prepareMcpConfig(
|
const result = await prepareMcpConfig({
|
||||||
"test-token",
|
githubToken: "test-token",
|
||||||
"test-owner",
|
owner: "test-owner",
|
||||||
"test-repo",
|
repo: "test-repo",
|
||||||
"test-branch",
|
branch: "test-branch",
|
||||||
" \n\t ",
|
additionalMcpConfig: " \n\t ",
|
||||||
);
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
expect(parsed.mcpServers).toBeDefined();
|
expect(parsed.mcpServers).toBeDefined();
|
||||||
@@ -94,13 +94,13 @@ describe("prepareMcpConfig", () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await prepareMcpConfig(
|
const result = await prepareMcpConfig({
|
||||||
"test-token",
|
githubToken: "test-token",
|
||||||
"test-owner",
|
owner: "test-owner",
|
||||||
"test-repo",
|
repo: "test-repo",
|
||||||
"test-branch",
|
branch: "test-branch",
|
||||||
additionalConfig,
|
additionalMcpConfig: additionalConfig,
|
||||||
);
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
expect(consoleInfoSpy).toHaveBeenCalledWith(
|
expect(consoleInfoSpy).toHaveBeenCalledWith(
|
||||||
@@ -127,13 +127,13 @@ describe("prepareMcpConfig", () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await prepareMcpConfig(
|
const result = await prepareMcpConfig({
|
||||||
"test-token",
|
githubToken: "test-token",
|
||||||
"test-owner",
|
owner: "test-owner",
|
||||||
"test-repo",
|
repo: "test-repo",
|
||||||
"test-branch",
|
branch: "test-branch",
|
||||||
additionalConfig,
|
additionalMcpConfig: additionalConfig,
|
||||||
);
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
expect(consoleInfoSpy).toHaveBeenCalledWith(
|
expect(consoleInfoSpy).toHaveBeenCalledWith(
|
||||||
@@ -163,13 +163,13 @@ describe("prepareMcpConfig", () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await prepareMcpConfig(
|
const result = await prepareMcpConfig({
|
||||||
"test-token",
|
githubToken: "test-token",
|
||||||
"test-owner",
|
owner: "test-owner",
|
||||||
"test-repo",
|
repo: "test-repo",
|
||||||
"test-branch",
|
branch: "test-branch",
|
||||||
additionalConfig,
|
additionalMcpConfig: additionalConfig,
|
||||||
);
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
expect(parsed.customProperty).toBe("custom-value");
|
expect(parsed.customProperty).toBe("custom-value");
|
||||||
@@ -181,13 +181,13 @@ describe("prepareMcpConfig", () => {
|
|||||||
test("should handle invalid JSON gracefully", async () => {
|
test("should handle invalid JSON gracefully", async () => {
|
||||||
const invalidJson = "{ invalid json }";
|
const invalidJson = "{ invalid json }";
|
||||||
|
|
||||||
const result = await prepareMcpConfig(
|
const result = await prepareMcpConfig({
|
||||||
"test-token",
|
githubToken: "test-token",
|
||||||
"test-owner",
|
owner: "test-owner",
|
||||||
"test-repo",
|
repo: "test-repo",
|
||||||
"test-branch",
|
branch: "test-branch",
|
||||||
invalidJson,
|
additionalMcpConfig: invalidJson,
|
||||||
);
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
expect(consoleWarningSpy).toHaveBeenCalledWith(
|
expect(consoleWarningSpy).toHaveBeenCalledWith(
|
||||||
@@ -200,13 +200,13 @@ describe("prepareMcpConfig", () => {
|
|||||||
test("should handle non-object JSON values", async () => {
|
test("should handle non-object JSON values", async () => {
|
||||||
const nonObjectJson = JSON.stringify("string value");
|
const nonObjectJson = JSON.stringify("string value");
|
||||||
|
|
||||||
const result = await prepareMcpConfig(
|
const result = await prepareMcpConfig({
|
||||||
"test-token",
|
githubToken: "test-token",
|
||||||
"test-owner",
|
owner: "test-owner",
|
||||||
"test-repo",
|
repo: "test-repo",
|
||||||
"test-branch",
|
branch: "test-branch",
|
||||||
nonObjectJson,
|
additionalMcpConfig: nonObjectJson,
|
||||||
);
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
expect(consoleWarningSpy).toHaveBeenCalledWith(
|
expect(consoleWarningSpy).toHaveBeenCalledWith(
|
||||||
@@ -222,13 +222,13 @@ describe("prepareMcpConfig", () => {
|
|||||||
test("should handle null JSON value", async () => {
|
test("should handle null JSON value", async () => {
|
||||||
const nullJson = JSON.stringify(null);
|
const nullJson = JSON.stringify(null);
|
||||||
|
|
||||||
const result = await prepareMcpConfig(
|
const result = await prepareMcpConfig({
|
||||||
"test-token",
|
githubToken: "test-token",
|
||||||
"test-owner",
|
owner: "test-owner",
|
||||||
"test-repo",
|
repo: "test-repo",
|
||||||
"test-branch",
|
branch: "test-branch",
|
||||||
nullJson,
|
additionalMcpConfig: nullJson,
|
||||||
);
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
expect(consoleWarningSpy).toHaveBeenCalledWith(
|
expect(consoleWarningSpy).toHaveBeenCalledWith(
|
||||||
@@ -244,13 +244,13 @@ describe("prepareMcpConfig", () => {
|
|||||||
test("should handle array JSON value", async () => {
|
test("should handle array JSON value", async () => {
|
||||||
const arrayJson = JSON.stringify([1, 2, 3]);
|
const arrayJson = JSON.stringify([1, 2, 3]);
|
||||||
|
|
||||||
const result = await prepareMcpConfig(
|
const result = await prepareMcpConfig({
|
||||||
"test-token",
|
githubToken: "test-token",
|
||||||
"test-owner",
|
owner: "test-owner",
|
||||||
"test-repo",
|
repo: "test-repo",
|
||||||
"test-branch",
|
branch: "test-branch",
|
||||||
arrayJson,
|
additionalMcpConfig: arrayJson,
|
||||||
);
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
// Arrays are objects in JavaScript, so they pass the object check
|
// Arrays are objects in JavaScript, so they pass the object check
|
||||||
@@ -289,13 +289,13 @@ describe("prepareMcpConfig", () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await prepareMcpConfig(
|
const result = await prepareMcpConfig({
|
||||||
"test-token",
|
githubToken: "test-token",
|
||||||
"test-owner",
|
owner: "test-owner",
|
||||||
"test-repo",
|
repo: "test-repo",
|
||||||
"test-branch",
|
branch: "test-branch",
|
||||||
additionalConfig,
|
additionalMcpConfig: additionalConfig,
|
||||||
);
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
expect(parsed.mcpServers.server1).toBeDefined();
|
expect(parsed.mcpServers.server1).toBeDefined();
|
||||||
@@ -310,12 +310,12 @@ describe("prepareMcpConfig", () => {
|
|||||||
const oldEnv = process.env.GITHUB_ACTION_PATH;
|
const oldEnv = process.env.GITHUB_ACTION_PATH;
|
||||||
process.env.GITHUB_ACTION_PATH = "/test/action/path";
|
process.env.GITHUB_ACTION_PATH = "/test/action/path";
|
||||||
|
|
||||||
const result = await prepareMcpConfig(
|
const result = await prepareMcpConfig({
|
||||||
"test-token",
|
githubToken: "test-token",
|
||||||
"test-owner",
|
owner: "test-owner",
|
||||||
"test-repo",
|
repo: "test-repo",
|
||||||
"test-branch",
|
branch: "test-branch",
|
||||||
);
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
expect(parsed.mcpServers.github_file_ops.args[1]).toBe(
|
expect(parsed.mcpServers.github_file_ops.args[1]).toBe(
|
||||||
@@ -329,12 +329,12 @@ describe("prepareMcpConfig", () => {
|
|||||||
const oldEnv = process.env.GITHUB_WORKSPACE;
|
const oldEnv = process.env.GITHUB_WORKSPACE;
|
||||||
delete process.env.GITHUB_WORKSPACE;
|
delete process.env.GITHUB_WORKSPACE;
|
||||||
|
|
||||||
const result = await prepareMcpConfig(
|
const result = await prepareMcpConfig({
|
||||||
"test-token",
|
githubToken: "test-token",
|
||||||
"test-owner",
|
owner: "test-owner",
|
||||||
"test-repo",
|
repo: "test-repo",
|
||||||
"test-branch",
|
branch: "test-branch",
|
||||||
);
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
expect(parsed.mcpServers.github_file_ops.env.REPO_DIR).toBe(process.cwd());
|
expect(parsed.mcpServers.github_file_ops.env.REPO_DIR).toBe(process.cwd());
|
||||||
|
|||||||
Reference in New Issue
Block a user