@@ -7,6 +7,8 @@ import { execFile } from "child_process"
77import { promisify } from "util"
88import { isPythonModuleInstalled } from "../python"
99import fs from "fs"
10+ import { ErrorType } from "../errors"
11+ import { isSignedIntoTobikoCloud } from "../../auth/auth"
1012
1113export type sqlmesh_exec = {
1214 workspacePath : string ;
@@ -51,7 +53,7 @@ export const get_tcloud_bin = async (): Promise<Result<string, string>> => {
5153 *
5254 * @returns The sqlmesh executable for the current workspace.
5355 */
54- export const sqlmesh_exec = async ( ) : Promise < Result < sqlmesh_exec , string > > => {
56+ export const sqlmesh_exec = async ( ) : Promise < Result < sqlmesh_exec , ErrorType > > => {
5557 const projectRoot = await getProjectRoot ( )
5658 const workspacePath = projectRoot . uri . fsPath
5759 const interpreterDetails = await getInterpreterDetails ( )
@@ -67,12 +69,24 @@ export const sqlmesh_exec = async (): Promise<Result<sqlmesh_exec, string>> => {
6769 traceLog ( "Using virtual environment" )
6870 const tcloudInstalled = await isTcloudProject ( )
6971 if ( isErr ( tcloudInstalled ) ) {
70- return tcloudInstalled
72+ return err ( {
73+ type : "generic" ,
74+ message : tcloudInstalled . error ,
75+ } )
7176 }
7277 if ( tcloudInstalled . value ) {
7378 const tcloudBin = await get_tcloud_bin ( )
7479 if ( isErr ( tcloudBin ) ) {
75- return tcloudBin
80+ return err ( {
81+ type : "generic" ,
82+ message : tcloudBin . error ,
83+ } )
84+ }
85+ const isSignedIn = await isSignedIntoTobikoCloud ( )
86+ if ( ! isSignedIn ) {
87+ return err ( {
88+ type : "not_signed_in" ,
89+ } )
7690 }
7791 return ok ( {
7892 bin : `${ tcloudBin . value } sqlmesh` ,
@@ -113,7 +127,7 @@ export const sqlmesh_exec = async (): Promise<Result<sqlmesh_exec, string>> => {
113127 * @returns The sqlmesh_lsp executable for the current workspace.
114128 */
115129export const sqlmesh_lsp_exec = async ( ) : Promise <
116- Result < sqlmesh_exec , string >
130+ Result < sqlmesh_exec , ErrorType >
117131> => {
118132 const projectRoot = await getProjectRoot ( )
119133 const workspacePath = projectRoot . uri . fsPath
@@ -130,13 +144,25 @@ export const sqlmesh_lsp_exec = async (): Promise<
130144 traceLog ( "Using virtual environment" )
131145 const tcloudInstalled = await isTcloudProject ( )
132146 if ( isErr ( tcloudInstalled ) ) {
133- return tcloudInstalled
147+ return err ( {
148+ type : "generic" ,
149+ message : tcloudInstalled . error ,
150+ } )
134151 }
135152 if ( tcloudInstalled . value ) {
136153 traceLog ( "Tcloud installed, installing sqlmesh" )
137154 const tcloudBin = await get_tcloud_bin ( )
138155 if ( isErr ( tcloudBin ) ) {
139- return tcloudBin
156+ return err ( {
157+ type : "generic" ,
158+ message : tcloudBin . error ,
159+ } )
160+ }
161+ const isSignedIn = await isSignedIntoTobikoCloud ( )
162+ if ( ! isSignedIn ) {
163+ return err ( {
164+ type : "not_signed_in" ,
165+ } )
140166 }
141167 const execFileAsync = promisify ( execFile )
142168 await execFileAsync ( tcloudBin . value , [ "install_sqlmesh" ] , {
0 commit comments