@@ -53,7 +53,6 @@ function findBufGenTemplate(protoPath: string, outDir: string): string {
5353
5454 for ( const file of candidates ) {
5555 if ( fs . existsSync ( file ) ) {
56- console . log ( `[qwikGrpc] Using ${ path . relative ( process . cwd ( ) , file ) } ` ) ;
5756 return fs . readFileSync ( file , 'utf8' ) ;
5857 }
5958 }
@@ -74,9 +73,6 @@ function runBufGenerate(protoPath: string, outDir: string, flags: string): strin
7473 execSync ( `buf generate ${ protoPath } --template ${ tmpPath } ${ flags } ` , {
7574 stdio : 'inherit' ,
7675 } ) ;
77- } catch ( err ) {
78- console . error ( '[qwikGrpc] buf generate failed:' , err ) ;
79- throw err ;
8076 } finally {
8177 fs . unlinkSync ( tmpPath ) ;
8278 }
@@ -86,8 +82,11 @@ function runBufGenerate(protoPath: string, outDir: string, flags: string): strin
8682 for ( const entry of fs . readdirSync ( dir ) ) {
8783 const full = path . join ( dir , entry ) ;
8884 const stat = fs . statSync ( full ) ;
89- if ( stat . isDirectory ( ) ) walk ( full ) ;
90- else if ( entry . endsWith ( '_pb.ts' ) ) files . push ( full ) ;
85+ if ( stat . isDirectory ( ) ) {
86+ walk ( full ) ;
87+ } else if ( entry . endsWith ( '_pb.ts' ) ) {
88+ files . push ( full ) ;
89+ }
9190 }
9291 } ;
9392 walk ( outDir ) ;
@@ -97,26 +96,22 @@ function runBufGenerate(protoPath: string, outDir: string, flags: string): strin
9796
9897// Creates a list of Services by reading the generated clients
9998function getServices ( outDir : string , files : string [ ] ) : Service [ ] {
100- return files
101- . map ( ( filePath ) => {
102- const fileContent = fs . readFileSync ( filePath , 'utf8' ) ;
103-
104- // Match pattern: export const FooService: GenService<...
105- const match = fileContent . match ( / e x p o r t \s + c o n s t \s + ( \w + ) S e r v i c e \s * : \s * G e n S e r v i c e \s * < / ) ;
106- if ( ! match ) {
107- console . warn ( `[qwikGrpc] No service export found in ${ filePath } ` ) ;
108- return null ;
109- }
99+ return files . map ( ( filePath ) => {
100+ const fileContent = fs . readFileSync ( filePath , 'utf8' ) ;
101+
102+ // Match pattern: export const FooService: GenService<...
103+ const match = fileContent . match ( / e x p o r t \s + c o n s t \s + ( \w + ) S e r v i c e \s * : \s * G e n S e r v i c e \s * < / ) ;
104+ if ( ! match ) {
105+ throw new Error ( `[qwikGrpc] No service export found in ${ filePath } ` ) ;
106+ }
110107
111- const name = match [ 1 ] ; // e.g. "Foo"
112- const instanceName = name [ 0 ] . toLowerCase ( ) + name . slice ( 1 ) ; // e.g. "foo"
113- const serviceName = `${ name } Service` ; // e.g. "FooService"
114- const relPath =
115- './' + path . relative ( outDir , filePath ) . replace ( / \\ / g, '/' ) . replace ( / \. t s $ / , '' ) ;
108+ const name = match [ 1 ] ; // e.g. "Foo"
109+ const instanceName = name [ 0 ] . toLowerCase ( ) + name . slice ( 1 ) ; // e.g. "foo"
110+ const serviceName = `${ name } Service` ; // e.g. "FooService"
111+ const relPath = './' + path . relative ( outDir , filePath ) . replace ( / \\ / g, '/' ) . replace ( / \. t s $ / , '' ) ;
116112
117- return { serviceName, name, instanceName, path : relPath } ;
118- } )
119- . filter ( ( s ) : s is Service => ! ! s ) ;
113+ return { serviceName, name, instanceName, path : relPath } ;
114+ } ) ;
120115}
121116
122117// Generates the client.ts file which registers the clients
0 commit comments