@@ -15,6 +15,7 @@ const linearClient = new LinearClient({
1515} )
1616
1717const __dirname = getDirname ( import . meta. url )
18+ const monorepoRoot = path . join ( __dirname , ".." , ".." , ".." , ".." , ".." )
1819
1920let freshnessCheckLabelId = ""
2021let 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
176164function getMonthDifference ( startDate : Date , endDate : Date ) {
0 commit comments