Skip to content

Commit fc29fc6

Browse files
authored
chore: Fix freshness check script + update Linear SDK (medusajs#12991)
* chore: update Linear SDK in docs tools * fix script * use relative file path * use relative file path
1 parent 2e5b648 commit fc29fc6

File tree

3 files changed

+22
-34
lines changed

3 files changed

+22
-34
lines changed

www/utils/packages/scripts/freshness-check.ts

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const linearClient = new LinearClient({
1515
})
1616

1717
const __dirname = getDirname(import.meta.url)
18+
const monorepoRoot = path.join(__dirname, "..", "..", "..", "..", "..")
1819

1920
let freshnessCheckLabelId = ""
2021
let documentationTeamId = ""
@@ -28,7 +29,7 @@ async function scanDirectory(startPath: string) {
2829
const filePath = path.join(startPath, file.name)
2930
if (file.isDirectory()) {
3031
//if it's references directory, skip
31-
if (file.name !== "references" && file.name !== "upgrade-guides") {
32+
if (file.name !== "references") {
3233
await scanDirectory(filePath)
3334
}
3435
continue
@@ -40,12 +41,14 @@ async function scanDirectory(startPath: string) {
4041
}
4142

4243
//if it is a file, check its commits in GitHub
44+
// retrieve relative path to monorepo root
45+
const relativeFilePath = path.relative(monorepoRoot, filePath)
4346
const commitResponse = await octokit.request(
4447
"GET /repos/{owner}/{repo}/commits",
4548
{
4649
owner: "medusajs",
4750
repo: "medusa",
48-
path: filePath,
51+
path: relativeFilePath,
4952
per_page: 1,
5053
}
5154
)
@@ -62,7 +65,7 @@ async function scanDirectory(startPath: string) {
6265
commitResponse.data[0].commit.committer.date
6366
)
6467
const monthsSinceEdited = getMonthDifference(lastEditedDate, today)
65-
const monthsThreshold = 2
68+
const monthsThreshold = 6
6669

6770
if (monthsSinceEdited > monthsThreshold) {
6871
//file was edited more than 6 months ago.
@@ -73,7 +76,7 @@ async function scanDirectory(startPath: string) {
7376
gte: subtractMonths(monthsSinceEdited - monthsThreshold, today),
7477
},
7578
title: {
76-
containsIgnoreCase: `Freshness check for ${filePath}`,
79+
containsIgnoreCase: relativeFilePath,
7780
},
7881
labels: {
7982
some: {
@@ -91,14 +94,14 @@ async function scanDirectory(startPath: string) {
9194
continue
9295
}
9396

94-
console.log(`Creating an issue for ${filePath}...`)
97+
console.log(`Creating an issue for ${relativeFilePath}...`)
9598

9699
//there are no issues in the past 6 months. Create an issue
97-
await linearClient.issueCreate({
100+
await linearClient.createIssue({
98101
teamId: documentationTeamId,
99-
title: `Freshness check for ${filePath}`,
102+
title: `Freshness check for ${relativeFilePath}`,
100103
labelIds: [freshnessCheckLabelId],
101-
description: `File \`${filePath}\` was last edited on ${lastEditedDate.toDateString()}.`,
104+
description: `File \`${relativeFilePath}\` was last edited on ${lastEditedDate.toDateString()}. Please review and update the content if necessary.`,
102105
})
103106
}
104107
}
@@ -145,32 +148,17 @@ async function main() {
145148

146149
freshnessCheckLabelId = freshnessCheckLabel.nodes[0].id
147150

151+
await scanDirectory(path.join(monorepoRoot, "www", "apps", "book", "app"))
148152
await scanDirectory(
149-
path.join(__dirname, "..", "..", "..", "..", "apps", "book", "app")
153+
path.join(monorepoRoot, "www", "apps", "resources", "app")
150154
)
151155
await scanDirectory(
152-
path.join(__dirname, "..", "..", "..", "..", "apps", "resources", "app")
156+
path.join(monorepoRoot, "www", "apps", "user-guide", "app")
153157
)
154158
await scanDirectory(
155-
path.join(__dirname, "..", "..", "..", "..", "apps", "user-guide", "app")
156-
)
157-
await scanDirectory(
158-
path.join(
159-
__dirname,
160-
"..",
161-
"..",
162-
"..",
163-
"..",
164-
"apps",
165-
"ui",
166-
"src",
167-
"content",
168-
"docs"
169-
)
170-
)
171-
await scanDirectory(
172-
path.join(__dirname, "..", "..", "..", "..", "apps", "cloud", "app")
159+
path.join(monorepoRoot, "www", "apps", "ui", "src", "content", "docs")
173160
)
161+
await scanDirectory(path.join(monorepoRoot, "www", "apps", "cloud", "app"))
174162
}
175163

176164
function getMonthDifference(startDate: Date, endDate: Date) {

www/utils/packages/scripts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"type": "module",
2020
"dependencies": {
2121
"@actions/core": "^1.10.1",
22-
"@linear/sdk": "^1.22.0",
22+
"@linear/sdk": "^52.0.0",
2323
"@octokit/core": "^4.0.5",
2424
"chalk": "^5.3.0",
2525
"glob": "^10.3.10",

www/utils/yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -736,14 +736,14 @@ __metadata:
736736
languageName: node
737737
linkType: hard
738738

739-
"@linear/sdk@npm:^1.22.0":
740-
version: 1.22.0
741-
resolution: "@linear/sdk@npm:1.22.0"
739+
"@linear/sdk@npm:^52.0.0":
740+
version: 52.0.0
741+
resolution: "@linear/sdk@npm:52.0.0"
742742
dependencies:
743743
"@graphql-typed-document-node/core": ^3.1.0
744744
graphql: ^15.4.0
745745
isomorphic-unfetch: ^3.1.0
746-
checksum: 7e8f24f617631d027fd606334a498b04014d4c33603bcb3e08073d14f86260d116597983567f8bc147a935e4557180158175b52b9a9a8a270a234b946894a82b
746+
checksum: 438a11988a79ebe85a2d621f32d444640faf467f3014f7626dab55f12fd6c5b787cd69e3075357987d174e20a2985f28992ad8251fdf6e8736c860e1a00b8c18
747747
languageName: node
748748
linkType: hard
749749

@@ -5477,7 +5477,7 @@ __metadata:
54775477
resolution: "scripts@workspace:packages/scripts"
54785478
dependencies:
54795479
"@actions/core": ^1.10.1
5480-
"@linear/sdk": ^1.22.0
5480+
"@linear/sdk": ^52.0.0
54815481
"@octokit/core": ^4.0.5
54825482
"@types/node": ^20.12.10
54835483
"@types/randomcolor": ^0.5.8

0 commit comments

Comments
 (0)