@@ -22,7 +22,6 @@ import { BuildResult, requiresVector } from "../dataconnect/types";
2222import { listenSpecsToString } from "./portUtils" ;
2323import { Client , ClientResponse } from "../apiv2" ;
2424import { EmulatorRegistry } from "./registry" ;
25- import { logger } from "../logger" ;
2625import { load } from "../dataconnect/load" ;
2726import { Config } from "../config" ;
2827import { PostgresServer , TRUNCATE_TABLES_SQL } from "./dataconnect/pgliteServer" ;
@@ -51,7 +50,6 @@ export interface DataConnectEmulatorArgs {
5150
5251export interface DataConnectGenerateArgs {
5352 configDir : string ;
54- connectorId : string ;
5553 watch ?: boolean ;
5654 account ?: Account ;
5755}
@@ -238,39 +236,44 @@ export class DataConnectEmulator implements EmulatorInstance {
238236 }
239237 }
240238
241- static async generate ( args : DataConnectGenerateArgs ) : Promise < string > {
239+ static async generate ( args : DataConnectGenerateArgs ) : Promise < void > {
242240 const commandInfo = await downloadIfNecessary ( Emulators . DATACONNECT ) ;
243- const cmd = [
244- "--logtostderr" ,
245- "-v=2" ,
246- "generate" ,
247- `--config_dir=${ args . configDir } ` ,
248- `--connector_id=${ args . connectorId } ` ,
249- ] ;
241+ const cmd = [ "--logtostderr" , "-v=2" , "sdk" , "generate" , `--config_dir=${ args . configDir } ` ] ;
250242 if ( args . watch ) {
251243 cmd . push ( "--watch" ) ;
252244 }
253245 const env = await DataConnectEmulator . getEnv ( args . account ) ;
254- const res = childProcess . spawnSync ( commandInfo . binary , cmd , { encoding : "utf-8" , env } ) ;
255- if ( isIncomaptibleArchError ( res . error ) ) {
256- throw new FirebaseError (
257- `Unknown system error when running the Data Connect toolkit. ` +
258- `You may be able to fix this by installing Rosetta: ` +
259- `softwareupdate --install-rosetta` ,
260- ) ;
261- }
262- logger . info ( res . stderr ) ;
263- if ( res . error ) {
264- throw new FirebaseError ( `Error starting up Data Connect generate: ${ res . error . message } ` , {
265- original : res . error ,
266- } ) ;
267- }
268- if ( res . status !== 0 ) {
269- throw new FirebaseError (
270- `Unable to generate your Data Connect SDKs (exit code ${ res . status } ): ${ res . stderr } ` ,
271- ) ;
272- }
273- return res . stdout ;
246+ return new Promise ( ( resolve , reject ) => {
247+ try {
248+ const proc = childProcess . spawn ( commandInfo . binary , cmd , { stdio : "inherit" , env } ) ;
249+ proc . on ( "close" , ( code ) => {
250+ if ( code === 0 ) {
251+ // Command executed successfully
252+ resolve ( ) ;
253+ } else {
254+ // Command failed
255+ reject ( new Error ( `Command failed with exit code ${ code } ` ) ) ;
256+ }
257+ } ) ;
258+
259+ proc . on ( "error" , ( err ) => {
260+ // Handle errors like command not found
261+ reject ( err ) ;
262+ } ) ;
263+ } catch ( e : any ) {
264+ if ( isIncomaptibleArchError ( e ) ) {
265+ reject (
266+ new FirebaseError (
267+ `Unknown system error when running the Data Connect toolkit. ` +
268+ `You may be able to fix this by installing Rosetta: ` +
269+ `softwareupdate --install-rosetta` ,
270+ ) ,
271+ ) ;
272+ } else {
273+ reject ( e ) ;
274+ }
275+ }
276+ } ) ;
274277 }
275278
276279 static async build ( args : DataConnectBuildArgs ) : Promise < BuildResult > {
0 commit comments