-
Notifications
You must be signed in to change notification settings - Fork 455
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Description - Allows users to configure team in CLI - Allows specify team for following commands: `list`, `kill`, `delete`
- Loading branch information
Showing
23 changed files
with
526 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"e2b": patch | ||
"@e2b/cli": patch | ||
--- | ||
|
||
Add end at and team handling |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import { Footer } from '@/components/Footer' | ||
|
||
export default async function Layout({ children }) { | ||
return ( | ||
<div className="pt-12"> | ||
{children} | ||
<Footer /> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,7 +85,6 @@ export function Layout({ | |
"> | ||
{children} | ||
</main> | ||
<Footer /> | ||
</div> | ||
)} | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import * as commander from 'commander' | ||
import * as fs from 'fs' | ||
import * as chalk from 'chalk' | ||
import * as e2b from 'e2b' | ||
import * as path from 'path' | ||
|
||
import { USER_CONFIG_PATH } from 'src/user' | ||
import { client, ensureAccessToken, ensureUserConfig } from 'src/api' | ||
import { asFormattedTeam } from '../../utils/format' | ||
|
||
const getTeams = e2b.withAccessToken(client.api.path('/teams').method('get').create()) | ||
|
||
export const configureCommand = new commander.Command('configure') | ||
.description('configure user') | ||
.action(async () => { | ||
const inquirer = await import('inquirer') | ||
|
||
console.log('Configuring user...\n') | ||
|
||
if (!fs.existsSync(USER_CONFIG_PATH)) { | ||
console.log('No user config found, run `e2b auth login` to log in first.') | ||
return | ||
} | ||
|
||
const userConfig = ensureUserConfig() | ||
const accessToken = ensureAccessToken() | ||
const res = await getTeams(accessToken, {}) | ||
if (!res.ok) { | ||
const error: e2b.paths['/teams']['get']['responses']['500']['content']['application/json'] = res.data as any | ||
|
||
throw new Error( | ||
`Error getting user teams: ${res.statusText}, ${error.message ?? 'no message' | ||
}`, | ||
) | ||
} | ||
|
||
const team = (await inquirer.default.prompt([ | ||
{ | ||
name: 'team', | ||
message: chalk.default.underline('Select team'), | ||
type: 'list', | ||
pageSize: 50, | ||
choices: res.data.map(team => ({ | ||
name: asFormattedTeam(team), | ||
value: team, | ||
})), | ||
}, | ||
]))['team'] | ||
|
||
userConfig.teamName = team.name | ||
userConfig.teamId = team.teamID | ||
userConfig.teamApiKey = team.apiKey | ||
fs.mkdirSync(path.dirname(USER_CONFIG_PATH), {recursive: true}) | ||
fs.writeFileSync(USER_CONFIG_PATH, JSON.stringify(userConfig, null, 2)) | ||
|
||
console.log(`Team ${asFormattedTeam(team)} selected.\n`) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.