Skip to content

Commit

Permalink
fix: knip, test
Browse files Browse the repository at this point in the history
  • Loading branch information
whilefoo committed Jul 24, 2024
1 parent 34adce1 commit 6018c59
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .github/knip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import type { KnipConfig } from "knip";
const config: KnipConfig = {
entry: ["src/worker.ts", "deploy/setup-kv-namespace.ts"],
project: ["src/**/*.ts"],
ignore: ["jest.config.js"],
ignore: ["jest.config.ts"],
ignoreBinaries: ["i"],
ignoreExportsUsedInFile: true,
ignoreDependencies: ["@mswjs/data", "esbuild", "eslint-config-prettier", "eslint-plugin-prettier", "msw"],
ignoreDependencies: ["@mswjs/data", "esbuild", "eslint-config-prettier", "eslint-plugin-prettier", "msw", "ts-node"],
};

export default config;
Binary file modified bun.lockb
Binary file not shown.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,12 @@
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-sonarjs": "1.0.3",
"husky": "9.0.11",
"jest-md-dashboard": "0.8.0",
"knip": "5.26.0",
"lint-staged": "15.2.7",
"npm-run-all": "4.1.5",
"prettier": "3.3.3",
"toml": "3.0.0",
"tomlify-j0.4": "3.0.0",
"ts-jest": "29.2.2",
"tsx": "4.16.2",
"typescript": "5.5.3",
"typescript-eslint": "7.16.0",
Expand Down
1 change: 1 addition & 0 deletions src/github/handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async function shouldSkipPlugin(event: EmitterWebhookEvent, context: GitHubConte
if (
context.key === "issue_comment.created" &&
manifest &&
manifest.commands &&
!Object.keys(manifest.commands).some(
(command) => "comment" in context.payload && typeof context.payload.comment !== "string" && context.payload.comment?.body.startsWith(`/${command}`)
)
Expand Down
2 changes: 1 addition & 1 deletion src/github/utils/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async function fetchActionManifest(context: GitHubContext<"issue_comment.created
return _manifestCache[manifestKey];
}
try {
const { data } = await context.octokit.repos.getContent({
const { data } = await context.octokit.rest.repos.getContent({
owner,
repo,
path: "manifest.json",
Expand Down
67 changes: 34 additions & 33 deletions tests/events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,42 +60,43 @@ describe("Event related tests", () => {
rest: {
issues,
repos: {
getContent() {
return {
data: `
plugins:
- name: "Run on comment created"
uses:
- id: plugin-A
plugin: https://plugin-a.internal
- name: "Some Action plugin"
uses:
- id: plugin-B
plugin: ubiquibot/plugin-b
`,
};
getContent(params?: RestEndpointMethodTypes["repos"]["getContent"]["parameters"]) {
if (params?.path === ".github/.ubiquibot-config.yml") {
return {
data: `
plugins:
- name: "Run on comment created"
uses:
- id: plugin-A
plugin: https://plugin-a.internal
- name: "Some Action plugin"
uses:
- id: plugin-B
plugin: ubiquibot/plugin-b
`,
};
} else if (params?.path === "manifest.json") {
return {
data: {
content: btoa(
JSON.stringify({
name: "plugin",
commands: {
action: {
description: "action",
"ubiquity:example": "/action",
},
},
})
),
},
};
} else {
throw new Error("Not found");
}
},
},
},
repos: {
getContent() {
return {
data: {
content: btoa(
JSON.stringify({
name: "plugin",
commands: {
action: {
description: "action",
"ubiquity:example": "/action",
},
},
})
),
},
};
},
},
},
eventHandler: {} as GitHubEventHandler,
payload: {
Expand Down

0 comments on commit 6018c59

Please sign in to comment.