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
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/2.1.2/schema.json",
"$schema": "https://biomejs.dev/schemas/2.1.4/schema.json",
"assist": {
"actions": {
"source": {
Expand Down
780 changes: 236 additions & 544 deletions package-lock.json

Large diffs are not rendered by default.

94 changes: 81 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,79 @@
"contributes": {
"//": "This is kept in alphabetical order. https://code.visualstudio.com/api/references/contribution-points",
"commands": [
{
"command": "buf.build",
"category": "Buf",
"icon": "$(files)",
"title": "Build",
"description": "Run `buf build` across VS Code workspace(s)."
},
{
"command": "buf.configinit",
"category": "Buf",
"icon": "$(file-add)",
"title": "Init",
"description": "Run `buf config init` to initialize a new Buf workspace"
},
{
"command": "buf.configlsbreakingrules",
"category": "Buf",
"icon": "$(list-unordered)",
"title": "List available breaking change detection rules."
},
{
"command": "buf.configlslintrules",
"category": "Buf",
"icon": "$(list-unordered)",
"title": "List available lint rules."
},
{
"command": "buf.configlsmodules",
"category": "Buf",
"icon": "$(folder-library)",
"title": "List modules in workspace."
},
{
"command": "buf.depprune",
"category": "Buf",
"icon": "$(gather)",
"title": "Prune module dependencies.",
"description": "Run `buf dep prune` across VS Code workspace(s) to prune unused buf.lock dependencies."
},
{
"command": "buf.depupdate",
"category": "Buf",
"icon": "$(repo-pull)",
"title": "Update module dependencies.",
"description": "Run `buf dep update` across VS Code workspace(s) to update buf.lock dependencies."
},
{
"command": "buf.generate",
"category": "Buf",
"icon": "$(run)",
"icon": "$(file-submodule)",
"title": "Generate",
"description": "Run Buf to generate code with protoc plugins."
"description": "Run `buf generate` across VS Code workspace(s)."
},
{
"command": "buf.showOutput",
"command": "buf.lsfiles",
"category": "Buf",
"icon": "$(output)",
"title": "Show Buf Output"
"icon": "$(files)",
"title": "List module files.",
"description": "List module files across VS Code workspace(s)."
},
{
"command": "buf.price",
"category": "Buf",
"icon": "$(briefcase)",
"title": "Price for BSR paid plans.",
"description": "Check the price of BSR paid plans across VS Code workspace(s)."
},
{
"command": "buf.stats",
"category": "Buf",
"icon": "$(graph-line)",
"title": "Module stats",
"description": "Get stats for Buf modules across VS Code workspace(s)."
},
{
"command": "buf.install",
Expand All @@ -69,11 +130,10 @@
"description": "Install the Buf CLI from GitHub releases."
},
{
"command": "buf.update",
"command": "buf.showOutput",
"category": "Buf",
"icon": "$(arrow-swap)",
"title": "Update CLI",
"description": "Check for updates and install the latest version of the Buf CLI."
"icon": "$(output)",
"title": "Show Buf Output"
},
{
"command": "buf.startLanguageServer",
Expand All @@ -86,6 +146,13 @@
"category": "Buf",
"icon": "$(debug-stop)",
"title": "Stop Buf Language Server"
},
{
"command": "buf.update",
"category": "Buf",
"icon": "$(sync)",
"title": "Update CLI",
"description": "Check for updates and install the latest version of the Buf CLI."
}
],
"configuration": {
Expand Down Expand Up @@ -234,25 +301,26 @@
"format": "biome format --write ."
},
"devDependencies": {
"@biomejs/biome": "^2.1.2",
"@biomejs/biome": "^2.1.4",
"@playwright/test": "^1.54.2",
"@types/mocha": "^10.0.6",
"@types/node": "^24.2.0",
"@types/mocha": "^10.0.10",
"@types/node": "^24.2.1",
"@types/semver": "^7.7.0",
"@types/vscode": "^1.102.0",
"@types/which": "^3.0.4",
"@vscode/test-cli": "^0.0.11",
"@vscode/test-electron": "^2.5.2",
"@vscode/vsce": "^3.6.0",
"cross-env": "^10.0.0",
"mocha": "^10.8.2",
"mocha": "^11.7.1",
"msw": "^2.10.4",
"typescript": "^5.9.2"
},
"dependencies": {
"@preact/signals-core": "^1.11.0",
"rimraf": "^6.0.1",
"semver": "^7.7.2",
"tmp": "^0.2.4",
"vscode-languageclient": "^9.0.1",
"which": "^5.0.0"
}
Expand Down
35 changes: 35 additions & 0 deletions src/commands/buf-build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as vscode from "vscode";
import { log } from "../log";
import { bufState } from "../state";
import { Command } from "./command";

/**
* bufBuild prompts the user to provide an output path for the `buf build` command, and then
* runs `buf build -o <output path>` at the root of each VS Code workspace folder.
*
* If there are no workspace folders, then bufBuild displays a warning and is a no-op.
*
* The output path is expected to be a relative path and defaults to "out.binpb".
*/
export const bufBuild = new Command(
"buf.build",
"COMMAND_TYPE_BUF",
async () => {
if (!vscode.workspace.workspaceFolders) {
log.warn(`No workspace found, unable to run "buf build".`);
return;
}
const recommendedOutPath = "out.binpb";
const outPath = await vscode.window.showInputBox({
placeHolder: recommendedOutPath,
prompt: `Provide an output path for "buf build", e.g. ${recommendedOutPath}. If none is provided, then "buf build" will output to /dev/null.`,
});
const args = ["build"];
if (outPath) {
args.push("-o", outPath);
}
for (const workspaceFolder of vscode.workspace.workspaceFolders) {
bufState.execBufCommand(args, workspaceFolder.uri.path);
}
}
);
21 changes: 21 additions & 0 deletions src/commands/buf-config-init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as vscode from "vscode";
import { log } from "../log";
import { bufState } from "../state";
import { Command } from "./command";

/**
* bufConfigInit shows the output channel and runs `buf config init`.
*/
export const bufConfigInit = new Command(
"buf.configinit",
"COMMAND_TYPE_BUF",
async () => {
if (!vscode.workspace.workspaceFolders) {
log.warn(`No workspace found, unable to run "buf config init"`);
return;
}
for (const workspaceFolder of vscode.workspace.workspaceFolders) {
bufState.execBufCommand(["config", "init"], workspaceFolder.uri.path);
}
}
);
36 changes: 36 additions & 0 deletions src/commands/buf-config-ls-breaking-rules.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import * as vscode from "vscode";
import { log } from "../log";
import { bufState } from "../state";
import { execFile } from "../util";
import { Command } from "./command";

/**
* bufConfigLsBreakingRules runs `buf config ls-breaking-rules` and shows the output in a
* text document window.
*/
export const bufConfigLsBreakingRules = new Command(
"buf.configlsbreakingrules",
"COMMAND_TYPE_BUF",
async () => {
const bufBinaryPath = bufState.getBufBinaryPath();
try {
const { stdout, stderr } = await execFile(bufBinaryPath ?? "", [
"config",
"ls-breaking-rules",
]);
if (stderr) {
log.error(`Error executing "buf config ls-breaking-rules": ${stderr}`);
}
const document = await vscode.workspace.openTextDocument({
content: stdout,
language: "plainText",
});
await vscode.window.showTextDocument(document, {
viewColumn: vscode.ViewColumn.Active,
preview: true,
});
} catch (e) {
log.error(`Error executing "buf config ls-breaking-rules": ${e}`);
}
}
);
36 changes: 36 additions & 0 deletions src/commands/buf-config-ls-lint-rules.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import * as vscode from "vscode";
import { log } from "../log";
import { bufState } from "../state";
import { execFile } from "../util";
import { Command } from "./command";

/**
* bufConfigLsLintRules runs `buf config ls-lint-rules` and shows the output in a text
* document window.
*/
export const bufConfigLsLintRules = new Command(
"buf.configlslintrules",
"COMMAND_TYPE_BUF",
async () => {
const bufBinaryPath = bufState.getBufBinaryPath();
try {
const { stdout, stderr } = await execFile(bufBinaryPath ?? "", [
"config",
"ls-lint-rules",
]);
if (stderr) {
log.error(`Error executing "buf config ls-lint-rules": ${stderr}`);
}
const document = await vscode.workspace.openTextDocument({
content: stdout,
language: "plainText",
});
await vscode.window.showTextDocument(document, {
viewColumn: vscode.ViewColumn.Active,
preview: true,
});
} catch (e) {
log.error(`Error executing "buf config ls-lint-rules": ${e}`);
}
}
);
39 changes: 39 additions & 0 deletions src/commands/buf-config-ls-modules.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import * as vscode from "vscode";
import { log } from "../log";
import { bufState } from "../state";
import { Command } from "./command";

/**
* Minimum Buf version required for `buf config ls-modules` command.
*/
const minBufVersion = "v1.34.0";

/**
* bufConfigLsModules shows the output channel and runs `buf config ls-modules` at the root
* of each VS Code workspace folder. If there are no workspace folders, then bufConfigLsModules
* displays a warning and is a no-op.
*/
export const bufConfigLsModules = new Command(
"buf.configlsmodules",
"COMMAND_TYPE_BUF",
async () => {
log.show();
if (!vscode.workspace.workspaceFolders) {
log.warn(`No workspace found, unable to run "buf config ls-modules"`);
return;
}
const bufVersion = bufState.getBufBinaryVersion();
if (bufVersion?.compare(minBufVersion) === -1) {
log.warn(
`Current Buf Version ${bufVersion} does not meet minimum required version ${minBufVersion}, unable to run "buf config ls-modules".`
);
return;
}
for (const workspaceFolder of vscode.workspace.workspaceFolders) {
bufState.execBufCommand(
["config", "ls-modules"],
workspaceFolder.uri.path
);
}
}
);
23 changes: 23 additions & 0 deletions src/commands/buf-dep-prune.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as vscode from "vscode";
import { log } from "../log";
import { bufState } from "../state";
import { Command } from "./command";

/**
* bufDepPrune runs `buf dep prune` at the root of each VS Code workspace folder. If there
* are no workspace folders, then bufDepPrune displays a warning and is a no-op.
*/
export const bufDepPrune = new Command(
"buf.depprune",
"COMMAND_TYPE_BUF",
async () => {
log.show();
if (!vscode.workspace.workspaceFolders) {
log.warn(`No workspace found, unable to run "buf dep prune"`);
return;
}
for (const workspaceFolder of vscode.workspace.workspaceFolders) {
bufState.execBufCommand(["dep", "prune"], workspaceFolder.uri.path);
}
}
);
22 changes: 22 additions & 0 deletions src/commands/buf-dep-update.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as vscode from "vscode";
import { log } from "../log";
import { bufState } from "../state";
import { Command } from "./command";

/**
* bufDepUpdate runs `buf dep update` at the root of each VS Code workspace folder. If there
* are no workspace folders, then bufDepUpdate displays a warning and is a no-op.
*/
export const bufDepUpdate = new Command(
"buf.depupdate",
"COMMAND_TYPE_BUF",
async () => {
if (!vscode.workspace.workspaceFolders) {
log.warn(`No workspace found, unable to run "buf dep update"`);
return;
}
for (const workspaceFolder of vscode.workspace.workspaceFolders) {
bufState.execBufCommand(["dep", "update"], workspaceFolder.uri.path);
}
}
);
2 changes: 1 addition & 1 deletion src/commands/buf-generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Command } from "./command";

/**
* bufGenerate runs `buf generate` at the root of each VS Code workspace folder. If there
* are no workspace folders, then `buf generate` displays a warning and is a no-op.
* are no workspace folders, then bufGenerate displays a warning and is a no-op.
*/
export const bufGenerate = new Command(
"buf.generate",
Expand Down
Loading
Loading