Skip to content

Commit

Permalink
update netlify status logic & exit early if no token
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidWells committed Jul 17, 2019
1 parent 82fb06d commit 2ead87f
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions src/commands/status/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,41 @@ class StatusCommand extends Command {
async run() {
const { globalConfig, api, site } = this.netlify
const current = globalConfig.get('userId')
const accessToken = this.configToken
const [ accessToken, location ] = this.getConfigToken()

if (!accessToken) {
this.log(`Not logged in. Please log in to see site status.`)
this.log()
this.log('Login with "netlify login" command')
this.exit()
}

const siteId = site.id

this.log(`──────────────────────┐
Current Netlify User │
──────────────────────┘`)
let accountData
if (accessToken) {
const accounts = await api.listAccountsForUser()
const user = await this.netlify.api.getCurrentUser()
const accounts = await api.listAccountsForUser()
const user = await this.netlify.api.getCurrentUser()

const ghuser = this.netlify.globalConfig.get(`users.${current}.auth.github.user`)
accountData = {
Name: get(user, 'full_name'),
// 'Account slug': get(personal, 'slug'),
// 'Account id': get(personal, 'id'),
// Name: get(personal, 'billing_name'),
Email: get(user, 'email'),
Github: ghuser
}
const teamsData = {}
const ghuser = this.netlify.globalConfig.get(`users.${current}.auth.github.user`)
accountData = {
Name: get(user, 'full_name'),
// 'Account slug': get(personal, 'slug'),
// 'Account id': get(personal, 'id'),
// Name: get(personal, 'billing_name'),
Email: get(user, 'email'),
Github: ghuser
}
const teamsData = {}

accounts.forEach(team => {
return (teamsData[team.name] = team.roles_allowed.join(' '))
})
accounts.forEach(team => {
return (teamsData[team.name] = team.roles_allowed.join(' '))
})

accountData.Teams = teamsData

accountData.Teams = teamsData
} else {
this.error(`Not logged in. Log in to see site status.`)
}

this.log(prettyjson.render(clean(accountData)))

Expand Down

0 comments on commit 2ead87f

Please sign in to comment.