import { ValidationResult } from './validate' ; const START_GENERATED = 'Result of scan' ; const STOP_GENERATED = 'address these problems' ; const SCHEMA_URL = 'https://github.com/googleapis/repo-automation-bots/blob/main/packages/repo-metadata-lint/src/repo-metadata-schema.json' ; const APIS_INDEX = 'https://github.com/googleapis/googleapis/blob/master/api-index-v1.json' ; export class ErrorMessageText { static forIssueBody ( results ) { let body = `You have a problem with your .repo-metadata.json file${ results . length > 1 ? 's' : '' }:

${ START_GENERATED } 📈:

` ; body += ErrorMessageText . resultsErrors ( results ) ; body += `\n\n ☝️ Once you ${ STOP_GENERATED }, you can close this issue.\n\n` ; body += '### Need help?' ; body += `\n* [Schema definition](${ SCHEMA_URL }): lists valid options for each field.\n* [API index](${ APIS_INDEX }): for gRPC libraries **api_shortname** should match the subdomain of an API's **hostName**.` ; body += '\n* Reach out to **go/github-automation** if you have any questions.' ; return body ; } private static resultsErrors ( results ) { let body = '' ; for ( const result of results ) { for ( const error of result . errors ) { body += `* ${ error }\n` ; } body += '\n' ; } return body . trim ( ) ; } static eql ( issueBody , results ) { const resultsErrors = ErrorMessageText . resultsErrors ( results ) ; const issueErrors = [ ] ; let collecting = false ; for ( const line of issueBody . split ( /\r?\n/ ) ) { if ( line . includes ( START_GENERATED ) && ! collecting ) { collecting = true ; continue ; } if ( line . includes ( STOP_GENERATED ) ) { break ; } if ( collecting ) issueErrors . push ( line ) ; } return resultsErrors . trim ( ) === issueErrors . join ( '\n' ) . trim ( ) ; } }