mirror of
https://github.com/zhigang1992/now-deployment.git
synced 2026-06-15 02:09:11 +08:00
31 lines
652 B
TypeScript
31 lines
652 B
TypeScript
import Client from './client';
|
|
import getUser from './get-user';
|
|
import getTeamById from './get-team-by-id';
|
|
import { TeamDeleted } from './errors-ts';
|
|
|
|
export default async function getScope(client: Client) {
|
|
const user = await getUser(client);
|
|
|
|
if (client.currentTeam) {
|
|
const team = await getTeamById(client, client.currentTeam);
|
|
|
|
if (!team) {
|
|
throw new TeamDeleted();
|
|
}
|
|
|
|
return {
|
|
contextName: team.slug,
|
|
platformVersion: team.platformVersion,
|
|
team,
|
|
user
|
|
};
|
|
}
|
|
|
|
return {
|
|
contextName: user.username || user.email,
|
|
platformVersion: user.platformVersion,
|
|
team: null,
|
|
user
|
|
};
|
|
}
|