Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Updated `cross-env` and `cross-spawn` dependencies to avoid vulnerable versions. (#7979)
- Fixed an issue with the Data Connect emulator where `dataDir` and `--export` were relative to the current directory insead of `firebase.json`.
2 changes: 1 addition & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions src/emulator/dataconnectEmulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@

export class DataConnectEmulator implements EmulatorInstance {
private emulatorClient: DataConnectEmulatorClient;
private usingExistingEmulator: boolean = false;

Check warning on line 62 in src/emulator/dataconnectEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Type boolean trivially inferred from a boolean literal, remove type annotation
private postgresServer: PostgresServer | undefined;

constructor(private args: DataConnectEmulatorArgs) {
this.emulatorClient = new DataConnectEmulatorClient();

Check warning on line 66 in src/emulator/dataconnectEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

'DataConnectEmulatorClient' was used before it was defined
}
private logger = EmulatorLogger.forEmulator(Emulators.DATACONNECT);

Expand All @@ -88,8 +88,8 @@
);
}
}
} catch (err: any) {

Check warning on line 91 in src/emulator/dataconnectEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
this.logger.log("DEBUG", `'fdc build' failed with error: ${err.message}`);

Check warning on line 92 in src/emulator/dataconnectEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "any" of template literal expression

Check warning on line 92 in src/emulator/dataconnectEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .message on an `any` value
}
await start(Emulators.DATACONNECT, {
auto_download: this.args.auto_download,
Expand All @@ -114,21 +114,24 @@
`FIREBASE_DATACONNECT_POSTGRESQL_STRING is set to ${clc.bold(connStr)} - using that instead of starting a new database`,
);
} else if (pgHost && pgPort) {
const dataDirectory = this.args.config.get("emulators.dataconnect.dataDir");
let dataDirectory = this.args.config.get("emulators.dataconnect.dataDir");

Check warning on line 117 in src/emulator/dataconnectEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
if (dataDirectory) {
dataDirectory = this.args.config.path(dataDirectory);

Check warning on line 119 in src/emulator/dataconnectEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `string`
}
const postgresDumpPath = this.args.importPath
? path.join(this.args.importPath, "postgres.tar.gz")
? path.join(this.args.config.path(this.args.importPath), "postgres.tar.gz")
: undefined;
this.postgresServer = new PostgresServer({
dataDirectory,

Check warning on line 125 in src/emulator/dataconnectEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
importPath: postgresDumpPath,
debug: this.args.debug,
});
const server = await this.postgresServer.createPGServer(pgHost, pgPort);
const connectableHost = connectableHostname(pgHost);
connStr = `postgres://${connectableHost}:${pgPort}/${dbId}?sslmode=disable`;
server.on("error", (err: any) => {

Check warning on line 132 in src/emulator/dataconnectEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
if (err instanceof FirebaseError) {
this.logger.logLabeled("ERROR", "Data Connect", `${err}`);

Check warning on line 134 in src/emulator/dataconnectEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "FirebaseError" of template literal expression
} else {
this.logger.logLabeled(
"ERROR",
Expand Down Expand Up @@ -205,7 +208,9 @@

async exportData(exportPath: string): Promise<void> {
if (this.postgresServer) {
await this.postgresServer.exportData(path.join(exportPath, "postgres.tar.gz"));
await this.postgresServer.exportData(
path.join(this.args.config.path(exportPath), "postgres.tar.gz"),
);
} else {
throw new FirebaseError(
"The Data Connect emulator is currently connected to a separate Postgres instance. Export is not supported.",
Expand Down
Loading