function printErrorAndExit(error, messages, extraText) {
  if (Array.isArray(messages) && messages.length > 0) {
    console.warn('---')
    for (const msg of messages) {
      console.error(chalk.red('>>') + ' ' + msg)
    }
  }

  if (extraText) {
    process.stderr.write(extraText)
    process.stderr.write('\n')
  }

  console.warn('---')
  if (error instanceof Error && error?.stack) {
    process.stderr.write(error.stack)
    process.stderr.write('\n')
  }
  process.exit(1)
}
@param {unknown} error
@param {string[]} [messages]
@param {string} [extraText]
@returns {never}