mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
Add VSCode git confirmation extension
This commit is contained in:
parent
c514b563f5
commit
58ba6b03c8
@ -86,7 +86,7 @@ project, please check the [project management guide](./PROJECT.md) to get starte
|
||||
- ✅ Deploy directly to Netlify (@xKevIsDev)
|
||||
- ✅ Supabase Integration (@xKevIsDev)
|
||||
- ⬜ Have LLM plan the project in a MD file for better results/transparency
|
||||
- ⬜ VSCode Integration with git-like confirmations
|
||||
- ✅ VSCode Integration with git-like confirmations
|
||||
- ⬜ Upload documents for knowledge - UI design templates, a code base to reference coding style, etc.
|
||||
- ✅ Voice prompting
|
||||
- ⬜ Azure Open AI API Integration
|
||||
|
24
vscode-extension/package.json
Normal file
24
vscode-extension/package.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "bolt-diy-git-confirmation",
|
||||
"displayName": "Bolt.diy Git Confirmation",
|
||||
"description": "Show git-like confirmations for file changes inside VS Code",
|
||||
"version": "0.0.1",
|
||||
"publisher": "bolt-diy",
|
||||
"engines": {
|
||||
"vscode": "^1.90.0"
|
||||
},
|
||||
"activationEvents": [
|
||||
"onCommand:bolt.gitConfirm"
|
||||
],
|
||||
"main": "./dist/extension.js",
|
||||
"scripts": {
|
||||
"compile": "tsc -p ./",
|
||||
"watch": "tsc -watch -p ./",
|
||||
"prepublishOnly": "npm run compile"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.7.2",
|
||||
"@types/node": "^20.0.0",
|
||||
"vscode": "^1.1.39"
|
||||
}
|
||||
}
|
56
vscode-extension/src/extension.ts
Normal file
56
vscode-extension/src/extension.ts
Normal file
@ -0,0 +1,56 @@
|
||||
import * as vscode from 'vscode';
|
||||
import { exec } from 'child_process';
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
const disposable = vscode.commands.registerCommand('bolt.gitConfirm', () => {
|
||||
const folders = vscode.workspace.workspaceFolders;
|
||||
if (!folders || folders.length === 0) {
|
||||
vscode.window.showErrorMessage('No workspace folder found.');
|
||||
return;
|
||||
}
|
||||
|
||||
const cwd = folders[0].uri.fsPath;
|
||||
exec('git status --porcelain', { cwd }, (err, stdout) => {
|
||||
if (err) {
|
||||
vscode.window.showErrorMessage('Failed to run git.');
|
||||
return;
|
||||
}
|
||||
|
||||
const lines = stdout.trim().split(/\r?\n/).filter(Boolean);
|
||||
if (lines.length === 0) {
|
||||
vscode.window.showInformationMessage('No changes to confirm.');
|
||||
return;
|
||||
}
|
||||
|
||||
const files = lines.map((l) => l.slice(3));
|
||||
vscode.window.showQuickPick(files, { placeHolder: 'Select a file to review' }).then((file) => {
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
|
||||
exec(`git diff -- ${file}`, { cwd }, (diffErr, diff) => {
|
||||
if (diffErr) {
|
||||
vscode.window.showErrorMessage('Failed to get diff.');
|
||||
return;
|
||||
}
|
||||
|
||||
vscode.workspace.openTextDocument({ content: diff, language: 'diff' }).then((doc) => {
|
||||
vscode.window.showTextDocument(doc, { preview: true }).then(() => {
|
||||
vscode.window.showInformationMessage(`Stage ${file}?`, 'Yes', 'No').then((answer) => {
|
||||
if (answer === 'Yes') {
|
||||
exec(`git add ${file}`, { cwd }, () => {
|
||||
vscode.window.showInformationMessage(`Staged ${file}`);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context.subscriptions.push(disposable);
|
||||
}
|
||||
|
||||
export function deactivate() {}
|
13
vscode-extension/tsconfig.json
Normal file
13
vscode-extension/tsconfig.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es2022",
|
||||
"lib": ["ES2022"],
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"sourceMap": true
|
||||
},
|
||||
"exclude": ["node_modules", ".vscode-test"]
|
||||
}
|
Loading…
Reference in New Issue
Block a user