11import { format } from "date-fns" ;
2- import { GitHubTrackerSettings , RepositoryTracking } from "./types" ;
2+ import { GitHubTrackerSettings , RepositoryTracking , ProjectData } from "./types" ;
33import { escapeBody , escapeYamlString } from "./util/escapeUtils" ;
44import {
55 createIssueTemplateData ,
@@ -21,6 +21,7 @@ export class ContentGenerator {
2121 repo : RepositoryTracking ,
2222 comments : any [ ] ,
2323 settings : GitHubTrackerSettings ,
24+ projectData ?: ProjectData [ ] ,
2425 ) : Promise < string > {
2526 // Determine whether to escape hash tags (repo setting takes precedence if ignoreGlobalSettings is true)
2627 const shouldEscapeHashTags = repo . ignoreGlobalSettings ? repo . escapeHashTags : settings . escapeHashTags ;
@@ -35,17 +36,19 @@ export class ContentGenerator {
3536 comments ,
3637 settings . dateFormat ,
3738 settings . escapeMode ,
38- shouldEscapeHashTags
39+ shouldEscapeHashTags ,
40+ projectData
3941 ) ;
4042 return processContentTemplate ( templateContent , templateData , settings . dateFormat ) ;
4143 }
4244 }
4345
4446 // Fallback to default template
45- return `---
47+ let frontmatter = `---
4648title: "${ escapeYamlString ( issue . title ) } "
4749number: ${ issue . number }
48- status: "${ issue . state } "
50+ state: "${ issue . state } "
51+ type: "issue"
4952created: "${
5053 settings . dateFormat !== ""
5154 ? format ( new Date ( issue . created_at ) , settings . dateFormat )
@@ -69,7 +72,19 @@ labels: [${(
6972 ) || [ ]
7073 ) . join ( ", " ) } ]
7174updateMode: "${ repo . issueUpdateMode } "
72- allowDelete: ${ repo . allowDeleteIssue ? true : false }
75+ allowDelete: ${ repo . allowDeleteIssue ? true : false } ` ;
76+
77+ // Add projectData if available
78+ if ( projectData && projectData . length > 0 ) {
79+ frontmatter += `
80+ projectData:` ;
81+ for ( const project of projectData ) {
82+ frontmatter += `
83+ - projectId: "${ project . projectId } "` ;
84+ }
85+ }
86+
87+ frontmatter += `
7388---
7489
7590# ${ escapeBody ( issue . title , settings . escapeMode , false ) }
7994 : "No description found"
8095}
8196
82- ${ this . fileHelpers . formatComments ( comments , settings . escapeMode , settings . dateFormat , shouldEscapeHashTags ) }
83- ` ;
97+ ${ this . fileHelpers . formatComments ( comments , settings . escapeMode , settings . dateFormat , shouldEscapeHashTags ) } `;
98+
99+ return frontmatter ;
84100 }
85101
86102 /**
@@ -91,6 +107,7 @@ ${this.fileHelpers.formatComments(comments, settings.escapeMode, settings.dateFo
91107 repo : RepositoryTracking ,
92108 comments : any [ ] ,
93109 settings : GitHubTrackerSettings ,
110+ projectData ?: ProjectData [ ] ,
94111 ) : Promise < string > {
95112 // Determine whether to escape hash tags (repo setting takes precedence if ignoreGlobalSettings is true)
96113 const shouldEscapeHashTags = repo . ignoreGlobalSettings ? repo . escapeHashTags : settings . escapeHashTags ;
@@ -105,17 +122,19 @@ ${this.fileHelpers.formatComments(comments, settings.escapeMode, settings.dateFo
105122 comments ,
106123 settings . dateFormat ,
107124 settings . escapeMode ,
108- shouldEscapeHashTags
125+ shouldEscapeHashTags ,
126+ projectData
109127 ) ;
110128 return processContentTemplate ( templateContent , templateData , settings . dateFormat ) ;
111129 }
112130 }
113131
114132 // Fallback to default template
115- return `---
133+ let frontmatter = `---
116134title: "${ escapeYamlString ( pr . title ) } "
117135number: ${ pr . number }
118- status: "${ pr . state } "
136+ state: "${ pr . state } "
137+ type: "pr"
119138created: "${
120139 settings . dateFormat !== ""
121140 ? format ( new Date ( pr . created_at ) , settings . dateFormat )
@@ -144,7 +163,19 @@ labels: [${(
144163 ) || [ ]
145164 ) . join ( ", " ) } ]
146165updateMode: "${ repo . pullRequestUpdateMode } "
147- allowDelete: ${ repo . allowDeletePullRequest ? true : false }
166+ allowDelete: ${ repo . allowDeletePullRequest ? true : false } ` ;
167+
168+ // Add projectData if available
169+ if ( projectData && projectData . length > 0 ) {
170+ frontmatter += `
171+ projectData:` ;
172+ for ( const project of projectData ) {
173+ frontmatter += `
174+ - projectId: "${ project . projectId } "` ;
175+ }
176+ }
177+
178+ frontmatter += `
148179---
149180
150181# ${ escapeBody ( pr . title , settings . escapeMode , false ) }
154185 : "No description found"
155186}
156187
157- ${ this . fileHelpers . formatComments ( comments , settings . escapeMode , settings . dateFormat , shouldEscapeHashTags ) }
158- ` ;
188+ ${ this . fileHelpers . formatComments ( comments , settings . escapeMode , settings . dateFormat , shouldEscapeHashTags ) } `;
189+
190+ return frontmatter ;
159191 }
160192}
0 commit comments