Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix status command to accommodate teams changes #288

Merged
merged 4 commits into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/commands/sites/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class SitesCreateCommand extends Command {
await this.authenticate()

const accounts = await api.listAccountsForUser()
const personal = accounts.find(account => account.type === 'PERSONAL')

let name = flags.name
if (!name) {
Expand All @@ -39,11 +38,10 @@ class SitesCreateCommand extends Command {
{
type: 'list',
name: 'accountSlug',
message: 'Account:',
default: personal.slug,
message: 'Team:',
choices: accounts.map(account => ({
value: account.slug,
name: `${account.name || account.slug} ${account.slug === personal.slug ? ' (personal)' : ''}`
name: account.name
}))
}
])
Expand All @@ -57,7 +55,7 @@ class SitesCreateCommand extends Command {
}
try {
site = await api.createSiteInTeam({
accountSlug: accountSlug || personal.slug,
accountSlug: accountSlug,
body
})
} catch (error) {
Expand Down
12 changes: 5 additions & 7 deletions src/commands/status/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,24 @@ class StatusCommand extends Command {
let accountData
if (accessToken) {
const accounts = await api.listAccountsForUser()
const personal = accounts.find(account => account.type === 'PERSONAL')
const user = this.netlify.api.getCurrentUser()
const teams = accounts.filter(account => account.type !== 'PERSONAL')
const user = await this.netlify.api.getCurrentUser()

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

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

accountData.Teams = teamsData
// TODO: use users endpoint
} else {
this.error(`Not logged in. Log in to see site status.`)
}
Expand Down