-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[VS Code] Fix the no project emulator experience #9072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
eecb596
1a3dd24
cbd646c
e8565dc
ec21799
95ad006
e7b7a7e
8a33cf2
92a0df9
4622456
d28c59d
0d9552b
4299a0b
24cae69
82e0e67
764ed09
f796243
1bdb3dc
b887d00
2e45fa6
61abeb5
abb98ba
6ce63a9
31adc23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -305,27 +305,35 @@ export class ResolvedDataConnectConfig { | |||||
| export class ResolvedDataConnectConfigs { | ||||||
| constructor(readonly values: DeepReadOnly<ResolvedDataConnectConfig[]>) {} | ||||||
|
|
||||||
| get serviceIds() { | ||||||
| get serviceIds(): string[] { | ||||||
| return this.values.map((config) => config.value.serviceId); | ||||||
| } | ||||||
|
|
||||||
| get allConnectors() { | ||||||
| get allConnectors(): ResolvedConnectorYaml[] { | ||||||
| return this.values.flatMap((dc) => dc.resolvedConnectors); | ||||||
| } | ||||||
|
|
||||||
| findById(serviceId: string) { | ||||||
| return this.values.find((dc) => dc.value.serviceId === serviceId); | ||||||
| findById(serviceId: string): ResolvedDataConnectConfig { | ||||||
| const dc = this.values.find((dc) => dc.value.serviceId === serviceId); | ||||||
| if (!dc) { | ||||||
| throw new Error(`No dataconnect.yaml with serviceId ${serviceId}. Available: ${this.serviceIds.join(", ")}`); | ||||||
| } | ||||||
| return dc; | ||||||
| } | ||||||
|
|
||||||
| findEnclosingServiceForPath(filePath: string) { | ||||||
| return this.values.find((dc) => dc.containsPath(filePath)); | ||||||
| findEnclosingServiceForPath(filePath: string): ResolvedDataConnectConfig { | ||||||
| const dc = this.values.find((dc) => dc.containsPath(filePath)); | ||||||
| if (!dc) { | ||||||
| throw new Error(`No enclosing dataconnect.yaml found for path ${filePath}. Available Paths: ${this.values.map((dc) => dc.path).join(", ")}`); | ||||||
| } | ||||||
| return dc; | ||||||
| } | ||||||
|
|
||||||
| getApiServicePathByPath(projectId: string, path: string) { | ||||||
| getApiServicePathByPath(projectId: string | undefined, path: string): string { | ||||||
| const dataConnectConfig = this.findEnclosingServiceForPath(path); | ||||||
| const serviceId = dataConnectConfig?.value.serviceId; | ||||||
| const locationId = dataConnectConfig?.dataConnectLocation; | ||||||
fredzqm marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| return `projects/${projectId}/locations/${locationId}/services/${serviceId}`; | ||||||
| return `projects/${projectId || "p"}/locations/${locationId}/services/${serviceId}`; | ||||||
|
||||||
| return `projects/${projectId || "p"}/locations/${locationId}/services/${serviceId}`; | |
| return `projects/${projectId || "demo-ignored"}/locations/${locationId}/services/${serviceId}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, when .firebaserc is missing. project is undefined here.
Sure, I will use the no-project placeholder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just add a comment that the Data Connect emulator ignores the project ID and will return the right response pretending that there's only one project
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,7 +73,7 @@ | |
|
|
||
| /** | ||
| * Exports emulator data on clean exit (SIGINT or process end) | ||
| * @param options | ||
|
Check warning on line 76 in src/emulator/controller.ts
|
||
| */ | ||
| export async function exportOnExit(options: Options): Promise<void> { | ||
| // Note: options.exportOnExit is coerced to a string before this point in commandUtils.ts#setExportOnExitOptions | ||
|
|
@@ -86,7 +86,7 @@ | |
| ); | ||
| await exportEmulatorData(exportOnExitDir, options, /* initiatedBy= */ "exit"); | ||
| } catch (e: unknown) { | ||
| utils.logWarning(`${e}`); | ||
| utils.logWarning(`Automatic export to "${exportOnExitDir}" failed, going to exit now...`); | ||
| } | ||
| } | ||
|
|
@@ -94,7 +94,7 @@ | |
|
|
||
| /** | ||
| * Hook to do things when we're exiting cleanly (this does not include errors). Will be skipped on a second SIGINT | ||
| * @param options | ||
|
Check warning on line 97 in src/emulator/controller.ts
|
||
| */ | ||
| export async function onExit(options: any) { | ||
| await exportOnExit(options); | ||
|
|
@@ -148,8 +148,8 @@ | |
| */ | ||
| export function shouldStart(options: Options, name: Emulators): boolean { | ||
| if (name === Emulators.HUB) { | ||
| // The hub only starts if we know the project ID. | ||
| return !!options.project; | ||
| // The emulator hub always starts. | ||
| return true; | ||
| } | ||
| const targets = filterEmulatorTargets(options); | ||
| const emulatorInTargets = targets.includes(name); | ||
|
|
@@ -882,7 +882,6 @@ | |
| projectId, | ||
| auto_download: true, | ||
| configDir: config[0].source, | ||
| rc: options.rc, | ||
| config: options.config, | ||
| autoconnectToPostgres: true, | ||
| postgresListen: listenForEmulator["dataconnect.postgres"], | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.