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
33 changes: 1 addition & 32 deletions firebase-vscode/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,13 @@ import { requireAuth } from "../../src/requireAuth";
import { deploy } from "../../src/deploy";
import { getDefaultHostingSite } from "../../src/getDefaultHostingSite";
import { initAction } from "../../src/commands/init";
import { startAll as startAllEmulators, cleanShutdown as stopAllEmulators } from "../../src/emulator/controller";
import { EmulatorRegistry } from "../../src/emulator/registry";
import { EmulatorInfo, Emulators } from "../../src/emulator/types";
import { Account, User } from "../../src/types/auth";
import { Options } from "../../src/options";
import { currentOptions, getCommandOptions } from "./options";
import { setInquirerOptions } from "./stubs/inquirer-stub";
import { ServiceAccount } from "../common/types";
import { listChannels } from "../../src/hosting/api";
import * as commandUtils from "../../src/emulator/commandUtils";
import { EmulatorUiSelections, ChannelWithId } from "../common/messaging/types";
import { ChannelWithId } from "../common/messaging/types";
import { pluginLogger } from "./logger-wrapper";
import { Config } from "../../src/config";

Expand Down Expand Up @@ -170,33 +166,6 @@ export async function initHosting(
setInquirerOptions(inquirerOptions);
await initAction("hosting", commandOptions);
}

export async function emulatorsStart(emulatorUiSelections: EmulatorUiSelections) {
const commandOptions = await getCommandOptions(undefined, {
...currentOptions,
project: emulatorUiSelections.projectId,
exportOnExit: emulatorUiSelections.exportStateOnExit,
import: emulatorUiSelections.importStateFolderPath,
only: emulatorUiSelections.mode === "hosting" ? "hosting" : ""
});
// Adjusts some options, export on exit can be a boolean or a path.
commandUtils.setExportOnExitOptions(commandOptions as commandUtils.ExportOnExitOptions);
return startAllEmulators(commandOptions, /*showUi=*/ true);
}

export async function stopEmulators() {
await stopAllEmulators();
}

export function listRunningEmulators(): EmulatorInfo[] {
return EmulatorRegistry.listRunningWithInfo();
}

export function getEmulatorUiUrl(): string | undefined {
const url: URL = EmulatorRegistry.url(Emulators.UI);
return url.hostname === "unknown" ? undefined : url.toString();
}

export async function deployToHosting(
firebaseJSON: Config,
deployTarget: string
Expand Down
7 changes: 0 additions & 7 deletions firebase-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
import { setupSidebar } from "./sidebar";
import { setupWorkflow } from "./workflow";
import { pluginLogger } from "./logger-wrapper";
import { onShutdown } from "./workflow";

const broker = createBroker<
ExtensionToWebviewParamsMap,
Expand All @@ -26,9 +25,3 @@ export function activate(context: vscode.ExtensionContext) {
setupWorkflow(context, broker);
setupSidebar(context, broker);
}

// This method is called when the extension is deactivated
export async function deactivate() {
// This await is optimistic but it might wait for a moment longer while we run cleanup activities
await onShutdown();
}
47 changes: 0 additions & 47 deletions firebase-vscode/src/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@ import { FirebaseProjectMetadata } from "../../src/types/project";
import { ExtensionBrokerImpl } from "./extension-broker";
import {
deployToHosting,
emulatorsStart,
getAccounts,
getChannels,
getEmulatorUiUrl,
initHosting,
listProjects,
listRunningEmulators,
login,
logoutUser,
stopEmulators,
} from "./cli";
import { User } from "../../src/types/auth";
import { currentOptions } from "./options";
Expand Down Expand Up @@ -364,47 +360,4 @@ export async function setupWorkflow(
{ projectId, folderPath: currentOptions.cwd });
await fetchChannels(true);
}
broker.on(
"launchEmulators",
async ({ emulatorUiSelections }) => {
await emulatorsStart(emulatorUiSelections);
broker.send("notifyRunningEmulatorInfo", { uiUrl: getEmulatorUiUrl(), displayInfo: listRunningEmulators() });
}
);

broker.on(
"stopEmulators",
async () => {
await stopEmulators();
// Update the UI
broker.send("notifyEmulatorsStopped");
}
);

broker.on(
"selectEmulatorImportFolder",
async () => {
const options: vscode.OpenDialogOptions = {
canSelectMany: false,
openLabel: `Pick an import folder`,
title: `Pick an import folder`,
canSelectFiles: false,
canSelectFolders: true,
};
const fileUri = await vscode.window.showOpenDialog(options);
// Update the UI of the selection
if (!fileUri || fileUri.length < 1) {
vscode.window.showErrorMessage("Invalid import folder selected.");
return;
}
broker.send("notifyEmulatorImportFolder", { folder: fileUri[0].fsPath });
}
);
}

/**
* Cleans up any open resources before shutting down.
*/
export async function onShutdown() {
await stopEmulators();
}
2 changes: 0 additions & 2 deletions firebase-vscode/webviews/SidebarApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { ServiceAccountUser } from "../common/types";
import { DeployPanel } from "./components/DeployPanel";
import { HostingState } from "./webview-types";
import { ChannelWithId } from "./messaging/types";
import { EmulatorPanel } from "./components/EmulatorPanel";

import { webLogger } from "./globals/web-logger";
import { InitFirebasePanel } from "./components/InitPanel";
Expand Down Expand Up @@ -146,7 +145,6 @@ export function SidebarApp() {
}}
/>
)}
{(!!userEmail && !!firebaseJson) && <EmulatorPanel firebaseJson={firebaseJson} projectId={projectId} />}
</>
);
}