Skip to content
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

Set FIREBASE_BINARY as "firebasePath" user setting #7857

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions firebase-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## NEXT

- [Added] Persist FIREBASE_BINARY env variable to settings.

## 0.10.5

- [Fixed] Fixed an issue where multiple instances of the extension would break the toolkit.
Expand Down
3 changes: 2 additions & 1 deletion firebase-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
},
"firebase.firebasePath": {
"type": "string",
"markdownDescription": "%ext.config.firebasePath%"
"markdownDescription": "%ext.config.firebasePath%",
"scope": "application"
Copy link
Member

@yuchenshi yuchenshi Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upon a closer look, I think we want machine-overridable. To quote the scope section in the schema, emphasis mine:

machine - Machine specific settings that can be set only in user settings or only in remote settings. For example, an installation path which shouldn't be shared across machines.
machine-overridable - Machine specific settings that can be overridden by workspace or folder settings.

The -overridable is mostly so that developers can pin to a different CLI / Node.js version for a certain workspace folder if they really want to. We won't programatically set workspace-level overrides though, it's all up to the developer

},
"firebase.hosting.useFrameworks": {
"type": "boolean",
Expand Down
24 changes: 17 additions & 7 deletions firebase-vscode/src/utils/settings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ConfigurationTarget, workspace } from "vscode";
import { ConfigurationTarget, window, workspace } from "vscode";

export interface Settings {
readonly firebasePath: string;
Expand All @@ -7,17 +7,27 @@ export interface Settings {
readonly shouldShowIdxMetricNotice: boolean;
}

const FIREBASE_BINARY =
// Allow defaults via env var. Useful when starting VS Code from command line or Monospace.
process.env.FIREBASE_BINARY ||
// TODO: Temporary fallback for bashing, this should probably point to the global firebase binary on the system
"npx -y firebase-tools@latest";
// TODO: Temporary fallback for bashing, this should probably point to the global firebase binary on the system
const DEFAULT_FIREBASE_BINARY = "npx -y firebase-tools@latest";

export function getSettings(): Settings {
const config = workspace.getConfiguration("firebase");

// TODO: Consider moving side effect out of getSettings
// Persist env var as path setting when path setting doesn't exist
if (process.env.FIREBASE_BINARY && !config.get<string>("firebasePath")) {
config.update(
yuchenshi marked this conversation as resolved.
Show resolved Hide resolved
"firebasePath",
process.env.FIREBASE_BINARY,
ConfigurationTarget.Global,
);
window.showInformationMessage(
"Detected FIREBASE_BINARY env var. Saving to `Firebase Path` setting.",
);
}

return {
firebasePath: config.get<string>("firebasePath") || FIREBASE_BINARY,
firebasePath: config.get<string>("firebasePath") || DEFAULT_FIREBASE_BINARY,
npmPath: config.get<string>("npmPath", "npm"),
useFrameworks: config.get<boolean>("hosting.useFrameworks", false),
shouldShowIdxMetricNotice: config.get<boolean>(
Expand Down
Loading