* feat: add service tabs refactor with GitHub, GitLab, Supabase, Vercel, and Netlify integration This commit introduces a comprehensive refactor of the connections system, replacing the single connections tab with dedicated service integration tabs: ✨ New Service Tabs: - GitHub Tab: Complete integration with repository management, stats, and API - GitLab Tab: GitLab project integration and management - Supabase Tab: Database project management with comprehensive analytics - Vercel Tab: Project deployment management and monitoring - Netlify Tab: Site deployment and build management 🔧 Supporting Infrastructure: - Enhanced store management for each service with auto-connect via env vars - API routes for secure server-side token handling and data fetching - Updated TypeScript types with missing properties and interfaces - Comprehensive hooks for service connections and state management - Security utilities for API endpoint validation 🎨 UI/UX Improvements: - Individual service tabs with tailored functionality - Motion animations and improved loading states - Connection testing and health monitoring - Advanced analytics dashboards for each service - Consistent design patterns across all service tabs 🛠️ Technical Changes: - Removed legacy connection tab in favor of individual service tabs - Updated tab configuration and routing system - Added comprehensive error handling and loading states - Enhanced type safety with extended interfaces - Implemented environment variable auto-connection features Note: Some TypeScript errors remain and will need to be resolved in follow-up commits. The dev server runs successfully and the service tabs are functional. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: comprehensive service integration refactor with enhanced tabs architecture Major architectural improvements to service integrations: **Service Integration Refactor:** - Complete restructure of service connection tabs (GitHub, GitLab, Vercel, Netlify, Supabase) - Migrated from centralized ConnectionsTab to dedicated service-specific tabs - Added shared service integration components for consistent UX - Implemented auto-connection feature using environment variables **New Components & Architecture:** - ServiceIntegrationLayout for consistent service tab structure - ConnectionStatus, ServiceCard components for reusable UI patterns - BranchSelector component for repository branch management - Enhanced authentication dialogs with improved error handling **API & Backend Enhancements:** - New API endpoints: github-branches, gitlab-branches, gitlab-projects, vercel-user - Enhanced GitLab API service with comprehensive project management - Improved connection testing hooks (useConnectionTest) - Better error handling and rate limiting across all services **Configuration & Environment:** - Updated .env.example with comprehensive service integration guides - Added auto-connection support for all major services - Improved development and production environment configurations - Enhanced tab management with proper service icons **Code Quality & TypeScript:** - Fixed all TypeScript errors across service integration components - Enhanced type definitions for Vercel, Supabase, and other service integrations - Improved type safety with proper optional chaining and type assertions - Better separation of concerns between UI and business logic **Removed Legacy Code:** - Removed redundant connection components and consolidated into service tabs - Cleaned up unused imports and deprecated connection patterns - Streamlined authentication flows across all services This refactor provides a more maintainable, scalable architecture for service integrations while significantly improving the user experience for managing external connections. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: clean up dead code and consolidate utilities - Remove legacy .eslintrc.json (replaced by flat config) - Remove duplicate app/utils/types.ts (unused type definitions) - Remove app/utils/cn.ts and consolidate with classNames utility - Clean up unused ServiceErrorHandler class implementation - Enhance classNames utility to support boolean values - Update GlowingEffect.tsx to use consolidated classNames utility Removes ~150+ lines of unused code while maintaining all functionality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Simplify terminal health checks and improve project setup Removed aggressive health checking and reconnection logic from TerminalManager to prevent issues with terminal responsiveness. Updated TerminalTabs to remove onReconnect handlers. Enhanced projectCommands utility to generate non-interactive setup commands and detect shadcn projects, improving automation and reliability of project setup. * fix: resolve GitLab deployment issues and enhance GitHub deployment reliability GitLab Deployment Fixes: - Fix COEP header issue for avatar images by adding crossOrigin and referrerPolicy attributes - Implement repository name sanitization to handle special characters and ensure GitLab compliance - Enhance error handling with detailed validation error parsing and user-friendly messages - Add explicit path field and description to project creation requests - Improve URL encoding and project path resolution for proper API calls - Add graceful file commit handling with timeout and error recovery GitHub Deployment Enhancements: - Add comprehensive repository name validation and sanitization - Implement real-time feedback for invalid characters in repository name input - Enhance error handling with specific error types and retry suggestions - Improve user experience with better error messages and validation feedback - Add repository name length limits and character restrictions - Show sanitized name preview to users before submission General Improvements: - Add GitLabAuthDialog component for improved authentication flow - Enhance logging and debugging capabilities for deployment operations - Improve accessibility with proper dialog titles and descriptions - Add better user notifications for name sanitization and validation issues 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
328 lines
14 KiB
TypeScript
328 lines
14 KiB
TypeScript
import ignore from 'ignore';
|
|
import { useGit } from '~/lib/hooks/useGit';
|
|
import type { Message } from 'ai';
|
|
import { detectProjectCommands, createCommandsMessage, escapeBoltTags } from '~/utils/projectCommands';
|
|
import { generateId } from '~/utils/fileUtils';
|
|
import { useState } from 'react';
|
|
import { toast } from 'react-toastify';
|
|
import { LoadingOverlay } from '~/components/ui/LoadingOverlay';
|
|
|
|
import { classNames } from '~/utils/classNames';
|
|
import { Button } from '~/components/ui/Button';
|
|
import type { IChatMetadata } from '~/lib/persistence/db';
|
|
import { X, Github, GitBranch } from 'lucide-react';
|
|
|
|
// Import the new repository selector components
|
|
import { GitHubRepositorySelector } from '~/components/@settings/tabs/github/components/GitHubRepositorySelector';
|
|
import { GitLabRepositorySelector } from '~/components/@settings/tabs/gitlab/components/GitLabRepositorySelector';
|
|
|
|
const IGNORE_PATTERNS = [
|
|
'node_modules/**',
|
|
'.git/**',
|
|
'.github/**',
|
|
'.vscode/**',
|
|
'dist/**',
|
|
'build/**',
|
|
'.next/**',
|
|
'coverage/**',
|
|
'.cache/**',
|
|
'.idea/**',
|
|
'**/*.log',
|
|
'**/.DS_Store',
|
|
'**/npm-debug.log*',
|
|
'**/yarn-debug.log*',
|
|
'**/yarn-error.log*',
|
|
|
|
// Include this so npm install runs much faster '**/*lock.json',
|
|
'**/*lock.yaml',
|
|
];
|
|
|
|
const ig = ignore().add(IGNORE_PATTERNS);
|
|
|
|
const MAX_FILE_SIZE = 100 * 1024; // 100KB limit per file
|
|
const MAX_TOTAL_SIZE = 500 * 1024; // 500KB total limit
|
|
|
|
interface GitCloneButtonProps {
|
|
className?: string;
|
|
importChat?: (description: string, messages: Message[], metadata?: IChatMetadata) => Promise<void>;
|
|
}
|
|
|
|
export default function GitCloneButton({ importChat, className }: GitCloneButtonProps) {
|
|
const { ready, gitClone } = useGit();
|
|
const [loading, setLoading] = useState(false);
|
|
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
|
const [selectedProvider, setSelectedProvider] = useState<'github' | 'gitlab' | null>(null);
|
|
|
|
const handleClone = async (repoUrl: string) => {
|
|
if (!ready) {
|
|
return;
|
|
}
|
|
|
|
setLoading(true);
|
|
setIsDialogOpen(false);
|
|
setSelectedProvider(null);
|
|
|
|
try {
|
|
const { workdir, data } = await gitClone(repoUrl);
|
|
|
|
if (importChat) {
|
|
const filePaths = Object.keys(data).filter((filePath) => !ig.ignores(filePath));
|
|
const textDecoder = new TextDecoder('utf-8');
|
|
|
|
let totalSize = 0;
|
|
const skippedFiles: string[] = [];
|
|
const fileContents = [];
|
|
|
|
for (const filePath of filePaths) {
|
|
const { data: content, encoding } = data[filePath];
|
|
|
|
// Skip binary files
|
|
if (
|
|
content instanceof Uint8Array &&
|
|
!filePath.match(/\.(txt|md|astro|mjs|js|jsx|ts|tsx|json|html|css|scss|less|yml|yaml|xml|svg|vue|svelte)$/i)
|
|
) {
|
|
skippedFiles.push(filePath);
|
|
continue;
|
|
}
|
|
|
|
try {
|
|
const textContent =
|
|
encoding === 'utf8' ? content : content instanceof Uint8Array ? textDecoder.decode(content) : '';
|
|
|
|
if (!textContent) {
|
|
continue;
|
|
}
|
|
|
|
// Check file size
|
|
const fileSize = new TextEncoder().encode(textContent).length;
|
|
|
|
if (fileSize > MAX_FILE_SIZE) {
|
|
skippedFiles.push(`${filePath} (too large: ${Math.round(fileSize / 1024)}KB)`);
|
|
continue;
|
|
}
|
|
|
|
// Check total size
|
|
if (totalSize + fileSize > MAX_TOTAL_SIZE) {
|
|
skippedFiles.push(`${filePath} (would exceed total size limit)`);
|
|
continue;
|
|
}
|
|
|
|
totalSize += fileSize;
|
|
fileContents.push({
|
|
path: filePath,
|
|
content: textContent,
|
|
});
|
|
} catch (e: any) {
|
|
skippedFiles.push(`${filePath} (error: ${e.message})`);
|
|
}
|
|
}
|
|
|
|
const commands = await detectProjectCommands(fileContents);
|
|
const commandsMessage = createCommandsMessage(commands);
|
|
|
|
const filesMessage: Message = {
|
|
role: 'assistant',
|
|
content: `Cloning the repo ${repoUrl} into ${workdir}
|
|
${
|
|
skippedFiles.length > 0
|
|
? `\nSkipped files (${skippedFiles.length}):
|
|
${skippedFiles.map((f) => `- ${f}`).join('\n')}`
|
|
: ''
|
|
}
|
|
|
|
<boltArtifact id="imported-files" title="Git Cloned Files" type="bundled">
|
|
${fileContents
|
|
.map(
|
|
(file) =>
|
|
`<boltAction type="file" filePath="${file.path}">
|
|
${escapeBoltTags(file.content)}
|
|
</boltAction>`,
|
|
)
|
|
.join('\n')}
|
|
</boltArtifact>`,
|
|
id: generateId(),
|
|
createdAt: new Date(),
|
|
};
|
|
|
|
const messages = [filesMessage];
|
|
|
|
if (commandsMessage) {
|
|
messages.push(commandsMessage);
|
|
}
|
|
|
|
await importChat(`Git Project:${repoUrl.split('/').slice(-1)[0]}`, messages);
|
|
}
|
|
} catch (error) {
|
|
console.error('Error during import:', error);
|
|
toast.error('Failed to import repository');
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<Button
|
|
onClick={() => {
|
|
setSelectedProvider(null);
|
|
setIsDialogOpen(true);
|
|
}}
|
|
title="Clone a repo"
|
|
variant="default"
|
|
size="lg"
|
|
className={classNames(
|
|
'gap-2 bg-bolt-elements-background-depth-1',
|
|
'text-bolt-elements-textPrimary',
|
|
'hover:bg-bolt-elements-background-depth-2',
|
|
'border border-bolt-elements-borderColor',
|
|
'h-10 px-4 py-2 min-w-[120px] justify-center',
|
|
'transition-all duration-200 ease-in-out',
|
|
className,
|
|
)}
|
|
disabled={!ready || loading}
|
|
>
|
|
Clone a repo
|
|
<div className="flex items-center gap-1 ml-2">
|
|
<Github className="w-4 h-4" />
|
|
<GitBranch className="w-4 h-4" />
|
|
</div>
|
|
</Button>
|
|
|
|
{/* Provider Selection Dialog */}
|
|
{isDialogOpen && !selectedProvider && (
|
|
<div className="fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center p-4">
|
|
<div className="bg-white dark:bg-gray-950 rounded-xl shadow-xl border border-bolt-elements-borderColor dark:border-bolt-elements-borderColor max-w-md w-full">
|
|
<div className="p-6">
|
|
<div className="flex items-center justify-between mb-4">
|
|
<h3 className="text-lg font-semibold text-bolt-elements-textPrimary dark:text-bolt-elements-textPrimary">
|
|
Choose Repository Provider
|
|
</h3>
|
|
<button
|
|
onClick={() => setIsDialogOpen(false)}
|
|
className="p-2 rounded-lg bg-transparent hover:bg-bolt-elements-background-depth-1 dark:hover:bg-bolt-elements-background-depth-1 text-bolt-elements-textSecondary dark:text-bolt-elements-textSecondary hover:text-bolt-elements-textPrimary dark:hover:text-bolt-elements-textPrimary transition-all duration-200 hover:scale-105 active:scale-95"
|
|
>
|
|
<X className="w-5 h-5 transition-transform duration-200 hover:rotate-90" />
|
|
</button>
|
|
</div>
|
|
|
|
<div className="space-y-3">
|
|
<button
|
|
onClick={() => setSelectedProvider('github')}
|
|
className="w-full p-4 rounded-lg bg-bolt-elements-background-depth-1 dark:bg-bolt-elements-background-depth-1 hover:bg-bolt-elements-background-depth-2 dark:hover:bg-bolt-elements-background-depth-2 border border-bolt-elements-borderColor dark:border-bolt-elements-borderColor hover:border-bolt-elements-borderColorActive dark:hover:border-bolt-elements-borderColorActive transition-all duration-200 text-left group"
|
|
>
|
|
<div className="flex items-center gap-3">
|
|
<div className="w-10 h-10 rounded-lg bg-blue-500/10 dark:bg-blue-500/20 flex items-center justify-center group-hover:bg-blue-500/20 dark:group-hover:bg-blue-500/30 transition-colors">
|
|
<Github className="w-6 h-6 text-blue-600 dark:text-blue-400" />
|
|
</div>
|
|
<div>
|
|
<div className="font-medium text-bolt-elements-textPrimary dark:text-bolt-elements-textPrimary">
|
|
GitHub
|
|
</div>
|
|
<div className="text-sm text-bolt-elements-textSecondary dark:text-bolt-elements-textSecondary">
|
|
Clone from GitHub repositories
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</button>
|
|
|
|
<button
|
|
onClick={() => setSelectedProvider('gitlab')}
|
|
className="w-full p-4 rounded-lg bg-bolt-elements-background-depth-1 dark:bg-bolt-elements-background-depth-1 hover:bg-bolt-elements-background-depth-2 dark:hover:bg-bolt-elements-background-depth-2 border border-bolt-elements-borderColor dark:border-bolt-elements-borderColor hover:border-bolt-elements-borderColorActive dark:hover:border-bolt-elements-borderColorActive transition-all duration-200 text-left group"
|
|
>
|
|
<div className="flex items-center gap-3">
|
|
<div className="w-10 h-10 rounded-lg bg-orange-500/10 dark:bg-orange-500/20 flex items-center justify-center group-hover:bg-orange-500/20 dark:group-hover:bg-orange-500/30 transition-colors">
|
|
<GitBranch className="w-6 h-6 text-orange-600 dark:text-orange-400" />
|
|
</div>
|
|
<div>
|
|
<div className="font-medium text-bolt-elements-textPrimary dark:text-bolt-elements-textPrimary">
|
|
GitLab
|
|
</div>
|
|
<div className="text-sm text-bolt-elements-textSecondary dark:text-bolt-elements-textSecondary">
|
|
Clone from GitLab repositories
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
{/* GitHub Repository Selection */}
|
|
{isDialogOpen && selectedProvider === 'github' && (
|
|
<div className="fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center p-4">
|
|
<div className="bg-white dark:bg-gray-950 rounded-xl shadow-xl border border-bolt-elements-borderColor dark:border-bolt-elements-borderColor w-full max-w-4xl max-h-[90vh] overflow-hidden">
|
|
<div className="p-6 border-b border-bolt-elements-borderColor dark:border-bolt-elements-borderColor flex items-center justify-between">
|
|
<div className="flex items-center gap-3">
|
|
<div className="w-10 h-10 rounded-lg bg-blue-500/10 dark:bg-blue-500/20 flex items-center justify-center">
|
|
<Github className="w-6 h-6 text-blue-600 dark:text-blue-400" />
|
|
</div>
|
|
<div>
|
|
<h3 className="text-lg font-semibold text-bolt-elements-textPrimary dark:text-bolt-elements-textPrimary">
|
|
Import GitHub Repository
|
|
</h3>
|
|
<p className="text-sm text-bolt-elements-textSecondary dark:text-bolt-elements-textSecondary">
|
|
Clone a repository from GitHub to your workspace
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<button
|
|
onClick={() => {
|
|
setIsDialogOpen(false);
|
|
setSelectedProvider(null);
|
|
}}
|
|
className="p-2 rounded-lg bg-transparent hover:bg-bolt-elements-background-depth-1 dark:hover:bg-bolt-elements-background-depth-1 text-bolt-elements-textSecondary dark:text-bolt-elements-textSecondary hover:text-bolt-elements-textPrimary dark:hover:text-bolt-elements-textPrimary transition-all duration-200 hover:scale-105 active:scale-95"
|
|
>
|
|
<X className="w-5 h-5 transition-transform duration-200 hover:rotate-90" />
|
|
</button>
|
|
</div>
|
|
|
|
<div className="p-6 max-h-[calc(90vh-140px)] overflow-y-auto">
|
|
<GitHubRepositorySelector onClone={handleClone} />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
{/* GitLab Repository Selection */}
|
|
{isDialogOpen && selectedProvider === 'gitlab' && (
|
|
<div className="fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center p-4">
|
|
<div className="bg-white dark:bg-gray-950 rounded-xl shadow-xl border border-bolt-elements-borderColor dark:border-bolt-elements-borderColor w-full max-w-4xl max-h-[90vh] overflow-hidden">
|
|
<div className="p-6 border-b border-bolt-elements-borderColor dark:border-bolt-elements-borderColor flex items-center justify-between">
|
|
<div className="flex items-center gap-3">
|
|
<div className="w-10 h-10 rounded-lg bg-orange-500/10 dark:bg-orange-500/20 flex items-center justify-center">
|
|
<GitBranch className="w-6 h-6 text-orange-600 dark:text-orange-400" />
|
|
</div>
|
|
<div>
|
|
<h3 className="text-lg font-semibold text-bolt-elements-textPrimary dark:text-bolt-elements-textPrimary">
|
|
Import GitLab Repository
|
|
</h3>
|
|
<p className="text-sm text-bolt-elements-textSecondary dark:text-bolt-elements-textSecondary">
|
|
Clone a repository from GitLab to your workspace
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<button
|
|
onClick={() => {
|
|
setIsDialogOpen(false);
|
|
setSelectedProvider(null);
|
|
}}
|
|
className="p-2 rounded-lg bg-transparent hover:bg-bolt-elements-background-depth-1 dark:hover:bg-bolt-elements-background-depth-1 text-bolt-elements-textSecondary dark:text-bolt-elements-textSecondary hover:text-bolt-elements-textPrimary dark:hover:text-bolt-elements-textPrimary transition-all duration-200 hover:scale-105 active:scale-95"
|
|
>
|
|
<X className="w-5 h-5 transition-transform duration-200 hover:rotate-90" />
|
|
</button>
|
|
</div>
|
|
|
|
<div className="p-6 max-h-[calc(90vh-140px)] overflow-y-auto">
|
|
<GitLabRepositorySelector onClone={handleClone} />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
{loading && <LoadingOverlay message="Please wait while we clone the repository..." />}
|
|
</>
|
|
);
|
|
}
|