Skip to content

Commit c8c9c89

Browse files
feat(cli): Show running VMs in CLI dashboard (#129)
* organize code and add view context to manage views * better types for views * add list of running VMs * Install chalk and date-fns packages * Update CLI tool look and feel a bit * Create custom components and show vms on dashboard
1 parent a460cf0 commit c8c9c89

File tree

13 files changed

+831
-345
lines changed

13 files changed

+831
-345
lines changed

package-lock.json

Lines changed: 33 additions & 82 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@
9999
"blessed": "^0.1.81",
100100
"blessed-contrib": "^4.11.0",
101101
"cli-table3": "^0.6.3",
102+
"chalk": "^5.4.1",
103+
"date-fns": "^4.1.0",
102104
"isbinaryfile": "^5.0.4",
103105
"isomorphic-ws": "^5.0.0",
104106
"ora": "^8.2.0",

src/bin/main.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,24 @@ import { buildCommand } from "./commands/build";
66
import { sandboxesCommand } from "./commands/sandbox";
77
import { previewHostsCommand } from "./commands/previewHosts";
88
import { hostTokensCommand } from "./commands/hostTokens";
9-
import { Dashboard } from "./ui/Dashboard";
9+
import { App } from "./ui/App";
1010
import React from "react";
1111
import { SDKProvider } from "./ui/sdkContext";
1212
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
13+
import { ViewProvider } from "./ui/viewContext";
1314

1415
if (process.argv.length === 2) {
15-
// Clear the screen before rendering the dashboard
16+
// Clear the screen before rendering the App
1617
process.stdout.write("\x1Bc");
1718

1819
const queryClient = new QueryClient();
1920

2021
render(
2122
<QueryClientProvider client={queryClient}>
2223
<SDKProvider>
23-
<Dashboard />
24+
<ViewProvider>
25+
<App />
26+
</ViewProvider>
2427
</SDKProvider>
2528
</QueryClientProvider>,
2629
{

src/bin/ui/App.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from "react";
2+
import { Box, Text } from "ink";
3+
import { Dashboard } from "./views/Dashboard";
4+
import { useView } from "./viewContext";
5+
import { Sandbox } from "./views/Sandbox";
6+
import { useTerminalSize } from "./hooks/useTerminalSize";
7+
8+
export function App() {
9+
const [stdoutWidth, stdoutHeight] = useTerminalSize();
10+
const { view } = useView();
11+
12+
return (
13+
<Box flexDirection="column" width={stdoutWidth} height={stdoutHeight} padding={1}>
14+
<Box marginBottom={1}>
15+
<Text bold>□ CodeSandbox SDK</Text>
16+
</Box>
17+
{view.name === "dashboard" && <Dashboard />}
18+
{view.name === "sandbox" && <Sandbox />}
19+
</Box>
20+
);
21+
}

0 commit comments

Comments
 (0)