diff --git a/src/checks/codeOfConduct.js b/src/checks/codeOfConduct.js deleted file mode 100644 index d16b3a3..0000000 --- a/src/checks/codeOfConduct.js +++ /dev/null @@ -1,22 +0,0 @@ -export default function codeOfConduct(communityMetrics) { - let response = { - id: "code-of-conduct", - href: "/repo/code-of-conduct", - title: "Code of Conduct", - }; - - if (communityMetrics.files?.code_of_conduct) { - response.status = "success"; - response.description = `You have a CoC ${communityMetrics.files.code_of_conduct.name}.`; - response.extra = "No action required."; - } - - if (!communityMetrics.files || !communityMetrics.files.code_of_conduct) { - response.status = "error"; - response.description = "You do not have a CoC in your repo."; - response.extra = - "This is important for people to know your project and community is safe."; - } - - return response; -} diff --git a/src/checks/codeOfConduct.ts b/src/checks/codeOfConduct.ts new file mode 100644 index 0000000..e77ba7d --- /dev/null +++ b/src/checks/codeOfConduct.ts @@ -0,0 +1,26 @@ +import { Community } from "@/models/github/community"; +import { StatusCheck } from "@/types/checks"; + +export default function codeOfConduct(community: Community) { + const response: StatusCheck = { + title: "Code of Conduct", + status: "unknown", + description: "-", + extra: "-", + }; + + if (community.files?.code_of_conduct) { + response.status = "success"; + response.description = "You have a CoC."; + response.extra = "No action required."; + } + + if (!community.files || !community.files.code_of_conduct) { + response.status = "error"; + response.description = "You do not have a CoC in your repo."; + response.extra = + "This is important for people to know your project and community is safe."; + } + + return response; +} diff --git a/src/checks/contributing.js b/src/checks/contributing.ts similarity index 53% rename from src/checks/contributing.js rename to src/checks/contributing.ts index 0c338cd..2ed7044 100644 --- a/src/checks/contributing.js +++ b/src/checks/contributing.ts @@ -1,17 +1,21 @@ -export default function contributing(communityMetrics) { - let response = { - id: "contributing", - href: "/repo/contributing", +import { Community } from "@/models/github/community"; +import { StatusCheck } from "@/types/checks"; + +export default function contributing(community: Community) { + const response: StatusCheck = { title: "Contributing", + status: "unknown", + description: "-", + extra: "-", }; - if (communityMetrics.files?.contributing) { + if (community.files?.contributing) { response.status = "success"; response.description = "You have a contributing guide."; response.extra = "No action required."; } - if (!communityMetrics.files || !communityMetrics.files.contributing) { + if (!community.files || !community.files.contributing) { response.status = "error"; response.description = "You do not have a contributing guide in your repo."; response.extra = diff --git a/src/checks/index.ts b/src/checks/index.ts index 16e6bf4..3a1ccfa 100644 --- a/src/checks/index.ts +++ b/src/checks/index.ts @@ -29,10 +29,10 @@ export default function checks(data: Data) { // branches(data.branches), // release(data.release), readme(data.community), - // license(data.communityMetrics), - // contributing(data.communityMetrics), - // pullRequestTemplate(data.communityMetrics), - // codeOfConduct(data.communityMetrics), + license(data.community), + contributing(data.community), + pullRequestTemplate(data.community), + codeOfConduct(data.community), // labels(data.labels), ]; diff --git a/src/checks/license.js b/src/checks/license.js deleted file mode 100644 index ad70fc4..0000000 --- a/src/checks/license.js +++ /dev/null @@ -1,21 +0,0 @@ -export default function license(communityMetrics) { - let response = { - id: "license", - href: "/repo/license", - title: "License", - }; - - if (communityMetrics.files?.license) { - response.status = "success"; - response.description = `You have a license ${communityMetrics.files.license.spdx_id}.`; - response.extra = "No action required."; - } - - if (!communityMetrics.files || !communityMetrics.files.license) { - response.status = "error"; - response.description = "You do not have a license in your repo."; - response.extra = "This does not mean it is moe Open Source but less."; - } - - return response; -} diff --git a/src/checks/license.ts b/src/checks/license.ts new file mode 100644 index 0000000..369981d --- /dev/null +++ b/src/checks/license.ts @@ -0,0 +1,25 @@ +import { Community } from "@/models/github/community"; +import { StatusCheck } from "@/types/checks"; + +export default function license(community: Community) { + const response: StatusCheck = { + title: "License", + status: "unknown", + description: "-", + extra: "-", + }; + + if (community.files?.license) { + response.status = "success"; + response.description = "You have a license."; + response.extra = "No action required."; + } + + if (!community.files || !community.files.license) { + response.status = "error"; + response.description = "You do not have a license in your repo."; + response.extra = "This does not mean it is moe Open Source but less."; + } + + return response; +} diff --git a/src/checks/pullRequestTemplate.js b/src/checks/pullRequestTemplate.ts similarity index 51% rename from src/checks/pullRequestTemplate.js rename to src/checks/pullRequestTemplate.ts index a161221..41ccfec 100644 --- a/src/checks/pullRequestTemplate.js +++ b/src/checks/pullRequestTemplate.ts @@ -1,20 +1,21 @@ -export default function pullRequestTemplate(communityMetrics) { - let response = { - id: "pull-request-template", - href: "/repo/pull-request-template", +import { Community } from "@/models/github/community"; +import { StatusCheck } from "@/types/checks"; + +export default function pullRequestTemplate(community: Community) { + const response: StatusCheck = { title: "Pull Request template", + status: "unknown", + description: "-", + extra: "-", }; - if (communityMetrics.files?.pull_request_template) { + if (community.files?.pull_request_template) { response.status = "success"; response.description = "You have a Pull Request template."; response.extra = "No action required."; } - if ( - !communityMetrics.files || - !communityMetrics.files.pull_request_template - ) { + if (!community.files || !community.files.pull_request_template) { response.status = "error"; response.description = "You do not have a pull request template in your repo.";