Skip to content

Commit

Permalink
Add debug configuration option and fix ajv types
Browse files Browse the repository at this point in the history
  • Loading branch information
joehan committed Jan 3, 2025
1 parent ba3fa99 commit 65c61af
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions firebase-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
"default": true,
"markdownDescription": "%ext.config.idx.viewMetricNotice%",
"scope": "application"
},
"firebase.debug": {
"type": "boolean",
"default": false,
"markdownDescription": "%ext.config.debug%"
}
}
},
Expand Down
1 change: 1 addition & 0 deletions firebase-vscode/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"ext.config.firebasePath": "Path to the `Firebase` module, e.g. `./node_modules/firebase`",
"ext.config.hosting.useFrameworks": "Enable web frameworks",
"ext.config.npmPath": "Path to NPM executable in local environment",
"ext.config.debug": "When true, add the --debug flag to any commands run by the extension",
"ext.config.title": "Prettier",
"ext.config.idx.viewMetricNotice": "Show data collection notice on next startup (IDX Only)"
}
7 changes: 6 additions & 1 deletion firebase-vscode/src/data-connect/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function setTerminalEnvVars(envVar: string, value: string) {
}

export function runCommand(command: string) {
const settings = getSettings();
const terminalOptions: TerminalOptions = {
name: "Data Connect Terminal",
env: environmentVariables,
Expand All @@ -30,6 +31,9 @@ export function runCommand(command: string) {
if (currentProjectId.value) {
command = `${command} --project ${currentProjectId.value}`;
}
if (settings.debug) {
command = `${command} --debug`;
}
terminal.sendText(command);
}

Expand All @@ -38,6 +42,7 @@ export function runTerminalTask(
command: string,
presentationOptions: vscode.TaskPresentationOptions = { focus: true },
): Promise<string> {
const settings = getSettings();
const type = "firebase-" + Date.now();
return new Promise(async (resolve, reject) => {
vscode.tasks.onDidEndTaskProcess(async (e) => {
Expand All @@ -60,7 +65,7 @@ export function runTerminalTask(
vscode.TaskScope.Workspace,
taskName,
"firebase",
new vscode.ShellExecution(command, executionOptions),
new vscode.ShellExecution(`${command} ${settings.debug ? "--debug" : ""}`, executionOptions),
);
task.presentationOptions = presentationOptions;
await vscode.tasks.executeTask(task);
Expand Down
2 changes: 2 additions & 0 deletions firebase-vscode/src/utils/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface Settings {
readonly npmPath: string;
readonly useFrameworks: boolean;
readonly shouldShowIdxMetricNotice: boolean;
readonly debug: boolean;
}

// TODO: Temporary fallback for bashing, this should probably point to the global firebase binary on the system
Expand Down Expand Up @@ -37,6 +38,7 @@ export function getSettings(): Settings {
"idx.viewMetricNotice",
true,
),
debug: config.get<boolean>("debug", false),
};
}

Expand Down
6 changes: 3 additions & 3 deletions src/firebaseConfigValidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ export function getValidator(): ValidateFunction {

export function getErrorMessage(e: ErrorObject) {
if (e.keyword === "additionalProperties") {
return `Object "${e.instancePath}" in "firebase.json" has unknown property: ${JSON.stringify(
return `Object "${e.dataPath}" in "firebase.json" has unknown property: ${JSON.stringify(
e.params,
)}`;
} else if (e.keyword === "required") {
return `Object "${
e.instancePath
e.dataPath
}" in "firebase.json" is missing required property: ${JSON.stringify(e.params)}`;
} else {
return `Field "${e.instancePath}" in "firebase.json" is possibly invalid: ${e.message}`;
return `Field "${e.dataPath}" in "firebase.json" is possibly invalid: ${e.message}`;
}
}

0 comments on commit 65c61af

Please sign in to comment.