@@ -2,19 +2,22 @@ import { IGitHubClient, PullRequestFile } from "@/common"
22import { getBaseFilename } from "@/common/utils"
33
44export default class PullRequestCommenter {
5+ private readonly domain : string
56 private readonly siteName : string
67 private readonly repositoryNameSuffix : string
78 private readonly projectConfigurationFilename : string
89 private readonly gitHubAppId : string
910 private readonly gitHubClient : IGitHubClient
1011
1112 constructor ( config : {
13+ domain : string
1214 siteName : string
1315 repositoryNameSuffix : string
1416 projectConfigurationFilename : string
1517 gitHubAppId : string
1618 gitHubClient : IGitHubClient
1719 } ) {
20+ this . domain = config . domain
1821 this . siteName = config . siteName
1922 this . repositoryNameSuffix = config . repositoryNameSuffix
2023 this . projectConfigurationFilename = config . projectConfigurationFilename
@@ -23,7 +26,6 @@ export default class PullRequestCommenter {
2326 }
2427
2528 async commentPullRequest ( request : {
26- hostURL : string
2729 appInstallationId : number
2830 repositoryOwner : string
2931 repositoryName : string
@@ -33,7 +35,6 @@ export default class PullRequestCommenter {
3335 const files = this . getChangedFiles ( await this . getYamlFiles ( request ) )
3436 const commentBody = this . makeCommentBody ( {
3537 files,
36- hostURL : request . hostURL ,
3738 owner : request . repositoryOwner ,
3839 repositoryName : request . repositoryName ,
3940 ref : request . ref
@@ -72,7 +73,7 @@ export default class PullRequestCommenter {
7273 }
7374
7475 private async getYamlFiles ( request : {
75- appInstallationId : number
76+ appInstallationId : number ,
7677 repositoryOwner : string
7778 repositoryName : string
7879 pullRequestNumber : number
@@ -87,7 +88,7 @@ export default class PullRequestCommenter {
8788 }
8889
8990 private async getExistingComment ( request : {
90- appInstallationId : number
91+ appInstallationId : number ,
9192 repositoryOwner : string
9293 repositoryName : string
9394 pullRequestNumber : number
@@ -104,40 +105,38 @@ export default class PullRequestCommenter {
104105 }
105106
106107 private makeCommentBody ( params : {
107- hostURL : string
108108 files : PullRequestFile [ ]
109109 owner : string
110110 repositoryName : string
111111 ref : string
112112 } ) : string {
113- const { hostURL , owner, repositoryName, ref } = params
113+ const { owner, repositoryName, ref } = params
114114 const projectId = this . getProjectId ( { repositoryName } )
115115 const tableHTML = this . makeFileTableHTML ( params )
116116 let result = "### 📖 Documentation Preview"
117117 result += "\n\n"
118- result += `The changes are now ready to previewed on <a href="${ hostURL } /${ owner } /${ projectId } /${ ref } ">${ this . siteName } </a> 🚀`
118+ result += `The changes are now ready to previewed on <a href="${ this . domain } /${ owner } /${ projectId } /${ ref } ">${ this . siteName } </a> 🚀`
119119 if ( tableHTML ) {
120120 result += "\n\n" + tableHTML
121121 }
122122 return result
123123 }
124124
125125 private makeFileTableHTML ( params : {
126- hostURL : string
127126 files : PullRequestFile [ ]
128127 owner : string
129128 repositoryName : string
130129 ref : string
131130 } ) {
132- const { hostURL , files, owner, repositoryName, ref } = params
131+ const { files, owner, repositoryName, ref } = params
133132 const rows : { filename : string , status : string , button : string } [ ] = [ ]
134133 const projectId = this . getProjectId ( { repositoryName } )
135134 // Create rows for each file
136135 for ( const file of files ) {
137136 const status = this . getStatusText ( file )
138137 let button = ""
139138 if ( file . status != "removed" ) {
140- let link = `${ hostURL } /${ owner } /${ projectId } /${ ref } `
139+ let link = `${ this . domain } /${ owner } /${ projectId } /${ ref } `
141140 if ( ! this . isProjectConfigurationFile ( file . filename ) ) {
142141 link += `/${ file . filename } `
143142 }
0 commit comments