'use strict';

const open = require('open');
const chalk = require('chalk');
const User = require('../models/User');

module.exports = async (config, cli) => {
  cli.logLogo();
  cli.sessionStart('opening browser', { timer: false });

  // todo
  // cli.log();
  // cli.log('click 👇 if browser did not open\nhttps://go.serverless.com/u9g1gp');

  const user = new User();

  const loginUrl = await user.startLogin();

  open(loginUrl);

  cli.sessionStatus('awaiting login');

  await user.endLogin();

  cli.sessionStop('login successful');
};
