1
1
import { ChildProcessWithoutNullStreams , spawn } from "node:child_process" ;
2
2
import path from "node:path" ;
3
3
4
- import { getProjectWorkingDir } from "./context" ;
5
- import { outputChannel } from "./utils" ;
4
+ import { getProjectWorkingDir } from "../.. /context" ;
5
+ import { outputChannel } from "../.. /utils" ;
6
6
7
7
/* Local state */
8
8
let $port : string | undefined = undefined ;
@@ -13,14 +13,16 @@ let $configPath: string | undefined = undefined;
13
13
/* Constants */
14
14
const OutputKey = "[App]" ;
15
15
const extensionCwd = path . dirname ( __dirname ) ;
16
- const binPath = path . join ( extensionCwd , "visualizer" , "server" , "index.mjs" ) ;
16
+ const appsCwd = path . join ( extensionCwd , "apps" ) ;
17
+ const binPath = path . join ( appsCwd , "visualizer" , "server" , "index.mjs" ) ;
17
18
18
19
interface ServerStartResult {
19
20
port : string ;
20
21
}
21
22
22
- export async function start ( configPath : string ) {
23
+ export async function startVisualizer ( configPath : string ) {
23
24
outputChannel . appendLine ( `${ OutputKey } extension cwd: ${ extensionCwd } ` ) ;
25
+ outputChannel . appendLine ( `${ OutputKey } apps cwd: ${ appsCwd } ` ) ;
24
26
outputChannel . appendLine (
25
27
`${ OutputKey } Using drizzle visualizer from: ${ binPath } ` ,
26
28
) ;
@@ -31,7 +33,7 @@ export async function start(configPath: string) {
31
33
outputChannel . appendLine (
32
34
`${ OutputKey } Config path changed. Killing server and restarting on port ${ $port } with new config path: ${ configPath } ` ,
33
35
) ;
34
- stop ( ) ;
36
+ stopVisualizer ( ) ;
35
37
}
36
38
37
39
if ( ! $port ) {
@@ -66,7 +68,7 @@ export async function start(configPath: string) {
66
68
stdio : "pipe" ,
67
69
detached : true ,
68
70
shell : false ,
69
- cwd : extensionCwd ,
71
+ cwd : appsCwd ,
70
72
env : {
71
73
...process . env ,
72
74
...drizzleEnvs ,
@@ -92,12 +94,17 @@ export async function start(configPath: string) {
92
94
93
95
// error from the server
94
96
$app . stderr . on ( "data" , ( error ) => {
95
- return reject ( error ) ;
97
+ outputChannel . appendLine ( `${ OutputKey } [stderr] ${ String ( error ) } ` ) ;
98
+ reject ( error ) ;
99
+ } ) ;
100
+
101
+ $app . on ( "error" , ( error ) => {
102
+ console . error ( "app error" , error ) ;
96
103
} ) ;
97
104
} ) ;
98
105
}
99
106
100
- export function stop ( ) {
107
+ export function stopVisualizer ( ) {
101
108
outputChannel . appendLine (
102
109
`${ OutputKey } Stopping Drizzle Visualizer server...` ,
103
110
) ;
0 commit comments