Skip to content

Commit

Permalink
Merge branch 'master' into jh-func-sock
Browse files Browse the repository at this point in the history
  • Loading branch information
joehan authored Oct 16, 2024
2 parents f04f582 + 1863f91 commit dde3d84
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
- Fixed an issue where the Extensions emulator would fail silently if started with a non-existant project without the `demo-` prefix. (#7779)
- Bumped the Firebase Data Connect local toolkit version to v1.5.1, which adds compatible mode schema migration support to the emulator and fixes an issue with the Timestamp type in Swift codegen. (#7837)
- Fixed an issue during functions discovery where `FUNCTIONS_DISCOVERY_TIMEOUT` wasn't respected. (#6285)
- Improved handling when `emulators:export` cannot read the metadata file.
28 changes: 15 additions & 13 deletions firebase-vscode/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ExtensionBrokerImpl } from "../extension-broker";
import { getRootFolders, registerConfig } from "./config";
import { EmulatorsController } from "./emulators";
import { registerEnv } from "./env";
import { pluginLogger, LogLevel } from '../logger-wrapper';
import { pluginLogger, LogLevel } from "../logger-wrapper";
import { getSettings } from "../utils/settings";
import { setEnabled } from "../../../src/experiments";
import { registerUser } from "./user";
Expand Down Expand Up @@ -55,18 +55,18 @@ export async function registerCore(
return;
}
const workspaceFolder = vscode.workspace.workspaceFolders[0];
const initCommand = currentProjectId.value ?
`${settings.firebasePath} init dataconnect --project ${currentProjectId.value}` :
`${settings.firebasePath} init dataconnect`;
vscode.tasks.executeTask(
new vscode.Task(
{ type: "shell" }, // this is the same type as in tasks.json
workspaceFolder, // The workspace folder
"firebase init dataconnect", // how you name the task
"firebase init dataconnect", // Shows up as MyTask: name
new vscode.ShellExecution(initCommand),
),
const initCommand = currentProjectId.value
? `${settings.firebasePath} init dataconnect --project ${currentProjectId.value}`
: `${settings.firebasePath} init dataconnect`;
const task = new vscode.Task(
{ type: "shell" }, // this is the same type as in tasks.json
workspaceFolder, // The workspace folder
"firebase init dataconnect", // how you name the task
"firebase init dataconnect", // Shows up as MyTask: name
new vscode.ShellExecution(initCommand),
);
task.presentationOptions = { focus: true };
vscode.tasks.executeTask(task);
});

const emulatorsController = new EmulatorsController(broker);
Expand All @@ -84,7 +84,9 @@ export async function registerCore(
"firebase.refresh",
async () => {
await vscode.commands.executeCommand("workbench.action.closeSidebar");
await vscode.commands.executeCommand("workbench.view.extension.firebase-data-connect");
await vscode.commands.executeCommand(
"workbench.view.extension.firebase-data-connect",
);
},
);

Expand Down
19 changes: 11 additions & 8 deletions firebase-vscode/src/data-connect/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export function runCommand(command: string) {
export function runTerminalTask(
taskName: string,
command: string,
presentationOptions: vscode.TaskPresentationOptions = { focus: true },
): Promise<string> {
const type = "firebase-" + Date.now();
return new Promise(async (resolve, reject) => {
Expand All @@ -54,15 +55,15 @@ export function runTerminalTask(
}
}
});
const task = await vscode.tasks.executeTask(
new vscode.Task(
{ type },
vscode.TaskScope.Workspace,
taskName,
"firebase",
new vscode.ShellExecution(command, executionOptions),
),
const task = new vscode.Task(
{ type },
vscode.TaskScope.Workspace,
taskName,
"firebase",
new vscode.ShellExecution(command, executionOptions),
);
task.presentationOptions = presentationOptions;
await vscode.tasks.executeTask(task);
});
}

Expand All @@ -88,6 +89,8 @@ export function registerTerminalTasks(
runTerminalTask(
"firebase emulators",
`${settings.firebasePath} emulators:start --project ${currentProjectId.value}`,
// emulators:start almost never ask interactive questions.
{ focus: false },
);
});

Expand Down
10 changes: 8 additions & 2 deletions src/emulator/hubExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,14 @@ export class HubExport {
if (!fs.existsSync(metadataPath)) {
return undefined;
}

return JSON.parse(fs.readFileSync(metadataPath, "utf8").toString()) as ExportMetadata;
let mdString: string = "";
try {
mdString = fs.readFileSync(metadataPath, "utf8").toString();
return JSON.parse(mdString) as ExportMetadata;
} catch (err: any) {
// JSON parse errors are unreadable. Throw the original.
throw new FirebaseError(`Unable to parse metadata file ${metadataPath}: ${mdString}`);
}
}

public async exportAll(): Promise<void> {
Expand Down

0 comments on commit dde3d84

Please sign in to comment.