chore: Fix freshness check script + update Linear SDK (#12991)

* chore: update Linear SDK in docs tools

* fix script

* use relative file path

* use relative file path
This commit is contained in:
Shahed Nasser
2025-07-18 15:56:02 +03:00
committed by GitHub
parent 2e5b648f64
commit fc29fc66d2
3 changed files with 22 additions and 34 deletions

View File

@@ -15,6 +15,7 @@ const linearClient = new LinearClient({
})
const __dirname = getDirname(import.meta.url)
const monorepoRoot = path.join(__dirname, "..", "..", "..", "..", "..")
let freshnessCheckLabelId = ""
let documentationTeamId = ""
@@ -28,7 +29,7 @@ async function scanDirectory(startPath: string) {
const filePath = path.join(startPath, file.name)
if (file.isDirectory()) {
//if it's references directory, skip
if (file.name !== "references" && file.name !== "upgrade-guides") {
if (file.name !== "references") {
await scanDirectory(filePath)
}
continue
@@ -40,12 +41,14 @@ async function scanDirectory(startPath: string) {
}
//if it is a file, check its commits in GitHub
// retrieve relative path to monorepo root
const relativeFilePath = path.relative(monorepoRoot, filePath)
const commitResponse = await octokit.request(
"GET /repos/{owner}/{repo}/commits",
{
owner: "medusajs",
repo: "medusa",
path: filePath,
path: relativeFilePath,
per_page: 1,
}
)
@@ -62,7 +65,7 @@ async function scanDirectory(startPath: string) {
commitResponse.data[0].commit.committer.date
)
const monthsSinceEdited = getMonthDifference(lastEditedDate, today)
const monthsThreshold = 2
const monthsThreshold = 6
if (monthsSinceEdited > monthsThreshold) {
//file was edited more than 6 months ago.
@@ -73,7 +76,7 @@ async function scanDirectory(startPath: string) {
gte: subtractMonths(monthsSinceEdited - monthsThreshold, today),
},
title: {
containsIgnoreCase: `Freshness check for ${filePath}`,
containsIgnoreCase: relativeFilePath,
},
labels: {
some: {
@@ -91,14 +94,14 @@ async function scanDirectory(startPath: string) {
continue
}
console.log(`Creating an issue for ${filePath}...`)
console.log(`Creating an issue for ${relativeFilePath}...`)
//there are no issues in the past 6 months. Create an issue
await linearClient.issueCreate({
await linearClient.createIssue({
teamId: documentationTeamId,
title: `Freshness check for ${filePath}`,
title: `Freshness check for ${relativeFilePath}`,
labelIds: [freshnessCheckLabelId],
description: `File \`${filePath}\` was last edited on ${lastEditedDate.toDateString()}.`,
description: `File \`${relativeFilePath}\` was last edited on ${lastEditedDate.toDateString()}. Please review and update the content if necessary.`,
})
}
}
@@ -145,32 +148,17 @@ async function main() {
freshnessCheckLabelId = freshnessCheckLabel.nodes[0].id
await scanDirectory(path.join(monorepoRoot, "www", "apps", "book", "app"))
await scanDirectory(
path.join(__dirname, "..", "..", "..", "..", "apps", "book", "app")
path.join(monorepoRoot, "www", "apps", "resources", "app")
)
await scanDirectory(
path.join(__dirname, "..", "..", "..", "..", "apps", "resources", "app")
path.join(monorepoRoot, "www", "apps", "user-guide", "app")
)
await scanDirectory(
path.join(__dirname, "..", "..", "..", "..", "apps", "user-guide", "app")
)
await scanDirectory(
path.join(
__dirname,
"..",
"..",
"..",
"..",
"apps",
"ui",
"src",
"content",
"docs"
)
)
await scanDirectory(
path.join(__dirname, "..", "..", "..", "..", "apps", "cloud", "app")
path.join(monorepoRoot, "www", "apps", "ui", "src", "content", "docs")
)
await scanDirectory(path.join(monorepoRoot, "www", "apps", "cloud", "app"))
}
function getMonthDifference(startDate: Date, endDate: Date) {

View File

@@ -19,7 +19,7 @@
"type": "module",
"dependencies": {
"@actions/core": "^1.10.1",
"@linear/sdk": "^1.22.0",
"@linear/sdk": "^52.0.0",
"@octokit/core": "^4.0.5",
"chalk": "^5.3.0",
"glob": "^10.3.10",

View File

@@ -736,14 +736,14 @@ __metadata:
languageName: node
linkType: hard
"@linear/sdk@npm:^1.22.0":
version: 1.22.0
resolution: "@linear/sdk@npm:1.22.0"
"@linear/sdk@npm:^52.0.0":
version: 52.0.0
resolution: "@linear/sdk@npm:52.0.0"
dependencies:
"@graphql-typed-document-node/core": ^3.1.0
graphql: ^15.4.0
isomorphic-unfetch: ^3.1.0
checksum: 7e8f24f617631d027fd606334a498b04014d4c33603bcb3e08073d14f86260d116597983567f8bc147a935e4557180158175b52b9a9a8a270a234b946894a82b
checksum: 438a11988a79ebe85a2d621f32d444640faf467f3014f7626dab55f12fd6c5b787cd69e3075357987d174e20a2985f28992ad8251fdf6e8736c860e1a00b8c18
languageName: node
linkType: hard
@@ -5477,7 +5477,7 @@ __metadata:
resolution: "scripts@workspace:packages/scripts"
dependencies:
"@actions/core": ^1.10.1
"@linear/sdk": ^1.22.0
"@linear/sdk": ^52.0.0
"@octokit/core": ^4.0.5
"@types/node": ^20.12.10
"@types/randomcolor": ^0.5.8