<commit_before>const { italic, bold } = require('chalk')

const error = require('../../lib/utils/output/error')
const wait = require('../../lib/utils/output/wait')
const cmd = require('../../lib/utils/output/cmd')
const param = require('../../lib/utils/output/param')
const info = require('../../lib/utils/output/info')
const uid = require('../../lib/utils/output/uid')
const success = require('../../lib/utils/output/success')
const stamp = require('../../lib/utils/output/stamp')
const promptBool = require('../../lib/utils/input/prompt-bool')
const eraseLines = require('../../lib/utils/output/erase-lines')
const treatBuyError = require('../../lib/utils/domains/treat-buy-error')

module.exports = async function({ domains, args, currentTeam, user }) {
  const name = args[0]
  let elapsed

  if (!name) {
    return error(`Missing domain name. Run ${cmd('now domains help')}`)
  }

  const nameParam = param(name)
  elapsed = stamp()
  let stopSpinner = wait(`Checking availability for ${nameParam}`)

  let price
  let period
  try {
    const json = await domains.price(name)
    price = json.price
    period = json.period
  } catch (err) {
    stopSpinner()
    return error(err.message)
  }

  const available = await domains.status(name)

  stopSpinner()

  if (!available) {
    return error(
      `The domain ${nameParam} is ${italic('unavailable')}! ${elapsed()}`
    )
  }
  const periodMsg = `${period}yr${period > 1 ? 's' : ''}`
  info(
    `The domain ${nameParam} is ${italic('available')} to buy under ${bold((currentTeam && currentTeam.slug) || user.username || user.email)}! ${elapsed()}`
  )
  const confirmation = await promptBool(
    `Buy now for ${bold(`$${price}`)} (${periodMsg})?`
  )

  eraseLines(1)
  if (!confirmation) {
    return info('Aborted')
  }

  stopSpinner = wait('Purchasing')
  elapsed = stamp()
  let domain
  try {
    domain = await domains.buy(name)
  } catch (err) {
    stopSpinner()
    return treatBuyError(err)
  }

  stopSpinner()

  success(`Domain purchased and created ${uid(domain.uid)} ${elapsed()}`)
  info(
    `You may now use your domain as an alias to your deployments. Run ${cmd('now alias help')}`
  )
}<commit_msg>Fixed help message for `now alias` (#578)<commit_after>const { italic, bold } = require('chalk')

const error = require('../../lib/utils/output/error')
const wait = require('../../lib/utils/output/wait')
const cmd = require('../../lib/utils/output/cmd')
const param = require('../../lib/utils/output/param')
const info = require('../../lib/utils/output/info')
const uid = require('../../lib/utils/output/uid')
const success = require('../../lib/utils/output/success')
const stamp = require('../../lib/utils/output/stamp')
const promptBool = require('../../lib/utils/input/prompt-bool')
const eraseLines = require('../../lib/utils/output/erase-lines')
const treatBuyError = require('../../lib/utils/domains/treat-buy-error')

module.exports = async function({ domains, args, currentTeam, user }) {
  const name = args[0]
  let elapsed

  if (!name) {
    return error(`Missing domain name. Run ${cmd('now domains help')}`)
  }

  const nameParam = param(name)
  elapsed = stamp()
  let stopSpinner = wait(`Checking availability for ${nameParam}`)

  let price
  let period
  try {
    const json = await domains.price(name)
    price = json.price
    period = json.period
  } catch (err) {
    stopSpinner()
    return error(err.message)
  }

  const available = await domains.status(name)

  stopSpinner()

  if (!available) {
    return error(
      `The domain ${nameParam} is ${italic('unavailable')}! ${elapsed()}`
    )
  }
  const periodMsg = `${period}yr${period > 1 ? 's' : ''}`
  info(
    `The domain ${nameParam} is ${italic('available')} to buy under ${bold((currentTeam && currentTeam.slug) || user.username || user.email)}! ${elapsed()}`
  )
  const confirmation = await promptBool(
    `Buy now for ${bold(`$${price}`)} (${periodMsg})?`
  )

  eraseLines(1)
  if (!confirmation) {
    return info('Aborted')
  }

  stopSpinner = wait('Purchasing')
  elapsed = stamp()
  let domain
  try {
    domain = await domains.buy(name)
  } catch (err) {
    stopSpinner()
    return treatBuyError(err)
  }

  stopSpinner()

  success(`Domain purchased and created ${uid(domain.uid)} ${elapsed()}`)
  info(
    `You may now use your domain as an alias to your deployments. Run ${cmd('now alias --help')}`
  )
}
{'fraction_non_alphanumeric': 0.1834924965893588, 'fraction_numerical': 0.0020463847203274215, 'mean_word_length': 3.430010070493454, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6769699', 'n_tokens_mistral': 1417, 'n_tokens_neox': 1385, 'n_words': 356}