Skip to content

Commit

Permalink
merging
Browse files Browse the repository at this point in the history
  • Loading branch information
joehan committed Apr 26, 2024
2 parents 3838504 + d069eef commit 5e8be0e
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 28 deletions.
3 changes: 3 additions & 0 deletions firebase-vscode/common/messaging/protocol.ts
Expand Up @@ -107,6 +107,9 @@ export interface WebviewToExtensionParamsMap {

/** Deploy connectors/services to production */
"fdc.deploy": void;

/** Deploy all connectors/services to production */
"fdc.deploy-all": void;
}

export interface DataConnectResults {
Expand Down
2 changes: 1 addition & 1 deletion firebase-vscode/src/core/emulators.ts
Expand Up @@ -149,7 +149,7 @@ export class EmulatorsController implements Disposable {
if (!projectId) {
return "demo-something";
}
if (mode === "hosting") {
if (mode === "hosting" || mode === "dataconnect") {
return projectId;
}
return "demo-" + projectId;
Expand Down
2 changes: 1 addition & 1 deletion firebase-vscode/src/core/index.ts
Expand Up @@ -66,7 +66,7 @@ export async function registerCore({
{ dispose: sub1 },
{ dispose: sub2 },
{ dispose: sub3 },
{ dispose: sub4 },,
{ dispose: sub4 },
),
];
}
57 changes: 34 additions & 23 deletions firebase-vscode/src/data-connect/deploy.ts
Expand Up @@ -33,36 +33,47 @@ export function registerFdcDeploy(
async () => {},
);

const deployCmd = vscode.commands.registerCommand(
"fdc.deploy",
async () => {
const configs = await firstWhereDefined(dataConnectConfigs).then(
(c) => c.requireValue,
const deployAllCmd = vscode.commands.registerCommand("fdc.deploy-all", () => {
runCommand("firebase deploy --only dataconnect");
});

const deployCmd = vscode.commands.registerCommand("fdc.deploy", async () => {
const configs = await firstWhereDefined(dataConnectConfigs).then(
(c) => c.requireValue,
);

const pickedServices = await pickServices(configs.serviceIds);
if (!pickedServices.length) {
return;
}

const serviceConnectorMap: { [key: string]: string[] } = {};
for (const serviceId of pickedServices) {
const connectorIds = configs.findById(serviceId)?.connectorIds;
serviceConnectorMap[serviceId] = await pickConnectors(
connectorIds,
serviceId,
);
}

const pickedServices = await pickServices(configs.serviceIds);
if (!pickedServices) {
return;
}

const serviceConnectorMap: { [key: string]: string[] } = {};
for (const serviceId of pickedServices) {
const connectorIds = configs.findById(serviceId)?.connectorIds;
serviceConnectorMap[serviceId] = await pickConnectors(
connectorIds,
serviceId,
);
}

runCommand(createDeployOnlyCommand(serviceConnectorMap)); // run from terminal
},
runCommand(createDeployOnlyCommand(serviceConnectorMap)); // run from terminal
});

const deployAllSub = broker.on("fdc.deploy-all", async () =>
vscode.commands.executeCommand("fdc.deploy-all"),
);

const sub1 = broker.on("fdc.deploy", async () =>
const deploySub = broker.on("fdc.deploy", async () =>
vscode.commands.executeCommand("fdc.deploy"),
);

return vscode.Disposable.from(deploySpy, deployCmd, { dispose: sub1 });
return vscode.Disposable.from(
deploySpy,
deployAllCmd,
deployCmd,
{ dispose: deployAllSub },
{ dispose: deploySub },
);
}

async function pickServices(
Expand Down
5 changes: 4 additions & 1 deletion firebase-vscode/webviews/SidebarApp.tsx
Expand Up @@ -168,13 +168,16 @@ function SidebarContent(props: {
/>
)}
{
// disable emulator panel for now, as we have an individual emulator panel in the FDC section
}
{/* {
// Only load the emulator panel if we have a user, firebase.json and this isn't Monospace
// The user login requirement can be removed in the future but the panel will have to
// be restricted to full-offline emulation only.
!!user && firebaseJson && firebaseJson.value && (
<EmulatorPanel firebaseJson={firebaseJson.value} />
)
}
} */}
</>
);
}
2 changes: 1 addition & 1 deletion firebase-vscode/webviews/data-connect.entry.tsx
Expand Up @@ -59,7 +59,7 @@ function DataConnect() {
<Spacer size="small" />
<VSCodeButton
appearance="secondary"
onClick={() => broker.send("fdc.deploy")}
onClick={() => broker.send("fdc.deploy-all")}
>
Deploy all
</VSCodeButton>
Expand Down
1 change: 1 addition & 0 deletions src/emulator/dataconnectEmulator.ts
Expand Up @@ -31,6 +31,7 @@ export class DataConnectEmulator implements EmulatorInstance {
grpc_port: port + 1,
config_dir: this.args.configDir,
local_connection_string: this.getLocalConectionString(),
project_id: this.args.projectId,
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/emulator/downloadableEmulators.ts
Expand Up @@ -281,7 +281,7 @@ const Commands: { [s in DownloadableEmulators]: DownloadableEmulatorCommand } =
dataconnect: {
binary: getExecPath(Emulators.DATACONNECT),
args: ["dev"],
optionalArgs: ["http_port", "grpc_port", "config_dir", "local_connection_string"],
optionalArgs: ["http_port", "grpc_port", "config_dir", "local_connection_string", "project_id"],
joinArgs: true,
},
};
Expand Down

0 comments on commit 5e8be0e

Please sign in to comment.