Merge origin/main into feature/apk-builder

Resolves merge conflicts by integrating APK Builder support with the
new PresetDeployProvider type system from main. Adds 'apkbuilder' type
to the PresetDeployProvider union and includes APK Builder in the
PRESET_DEPLOY_PROVIDERS array.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
Derek RossandClaude Opus 4.5 committed 2026-01-04 01:13:15 -05:00
commit 75502fdb7f
8 files changed
+215 -383

No files matched your search

+30 -7
View File
@@ -1,4 +1,4 @@
import { useState, useEffect, useCallback } from 'react';
import { useState, useEffect, useCallback, useRef } from 'react';
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import QRCode from 'qrcode';
import { Trash2, Bot, CreditCard, Zap, ExternalLink, RefreshCw, Check, X, Clock, AlertCircle, Copy, RotateCcw, ArrowLeft, Gift, Plus, History, DollarSign, Printer, Download } from 'lucide-react';
@@ -352,10 +352,13 @@ export function AIProviderConfigDialog({
// Credits state
const [amount, setAmount] = useState<number>(10);
const [debouncedAmount, setDebouncedAmount] = useState<number>(10);
const [paymentMethod, setPaymentMethod] = useState<'stripe' | 'lightning'>('stripe');
const [lightningInvoice, setLightningInvoice] = useState<string | null>(null);
const [lightningPaymentId, setLightningPaymentId] = useState<string | null>(null);
const [lightningTotal, setLightningTotal] = useState<number>(10);
const [refreshingPayments, setRefreshingPayments] = useState<Set<string>>(new Set());
const amountDebounceTimer = useRef<NodeJS.Timeout | null>(null);
const [giftcardAmount, setGiftcardAmount] = useState<number>(10);
const [giftcardQuantity, setGiftcardQuantity] = useState<number>(1);
const [redeemCode, setRedeemCode] = useState<string>('');
@@ -383,13 +386,30 @@ export function AIProviderConfigDialog({
}
}, [open, supportsCredits, isLoadingCredits]);
// Debounce amount changes to avoid excessive API calls
useEffect(() => {
if (amountDebounceTimer.current) {
clearTimeout(amountDebounceTimer.current);
}
amountDebounceTimer.current = setTimeout(() => {
setDebouncedAmount(amount);
}, 500); // Wait 500ms after user stops typing
return () => {
if (amountDebounceTimer.current) {
clearTimeout(amountDebounceTimer.current);
}
};
}, [amount]);
// Query for payment preview (to get fee information)
const { data: paymentPreview, isLoading: isLoadingPreview } = useQuery({
queryKey: ['ai-payment-preview', provider.nostr ? user?.pubkey ?? '' : '', provider.id, amount, paymentMethod],
queryKey: ['ai-payment-preview', provider.nostr ? user?.pubkey ?? '' : '', provider.id, debouncedAmount, paymentMethod],
queryFn: async (): Promise<Payment> => {
const ai = createAIClient(provider, user, config.corsProxy);
const request: AddCreditsRequest = {
amount,
amount: debouncedAmount,
method: paymentMethod,
};
@@ -401,7 +421,7 @@ export function AIProviderConfigDialog({
body: request,
}) as Payment;
},
enabled: open && supportsCredits && amount > 0,
enabled: open && supportsCredits && debouncedAmount > 0,
retry: false,
refetchOnWindowFocus: false,
staleTime: Infinity,
@@ -452,6 +472,7 @@ export function AIProviderConfigDialog({
} else if (payment.method === 'lightning') {
setLightningInvoice(payment.url);
setLightningPaymentId(payment.id);
setLightningTotal(payment.total);
}
queryClient.invalidateQueries({
@@ -632,6 +653,7 @@ export function AIProviderConfigDialog({
} else if (paymentPreview.method === 'lightning') {
setLightningInvoice(paymentPreview.url);
setLightningPaymentId(paymentPreview.id);
setLightningTotal(paymentPreview.total);
}
queryClient.invalidateQueries({
@@ -1094,8 +1116,8 @@ export function AIProviderConfigDialog({
id="amount"
type="number"
step="0.01"
value={amount}
onChange={(e) => setAmount(Number(e.target.value))}
value={amount || ''}
onChange={(e) => setAmount(Number(e.target.value) || 0)}
placeholder={t('enterAmount')}
className="text-center text-lg font-medium"
/>
@@ -1238,6 +1260,7 @@ export function AIProviderConfigDialog({
if (payment.method === 'lightning') {
setLightningInvoice(payment.url);
setLightningPaymentId(payment.id);
setLightningTotal(payment.total);
} else {
window.open(payment.url, '_blank');
}
@@ -1512,7 +1535,7 @@ export function AIProviderConfigDialog({
<div className="flex-1 overflow-y-auto px-1 -mx-1">
<LightningPayment
invoice={lightningInvoice}
amount={amount}
amount={lightningTotal}
paymentId={lightningPaymentId!}
provider={provider}
onClose={() => {
+12 -58
View File
@@ -22,22 +22,7 @@ import { Link } from 'react-router-dom';
import { useCurrentUser } from '@/hooks/useCurrentUser';
import { useAppContext } from '@/hooks/useAppContext';
import { requestBuildServerApiKey } from '@/lib/nip98';
interface PresetProvider {
id: string;
type: 'shakespeare' | 'netlify' | 'vercel' | 'nsite' | 'cloudflare' | 'deno' | 'apkbuilder';
name: string;
description: string;
requiresNostr?: boolean;
apiKeyLabel?: string;
apiKeyURL?: string;
accountIdLabel?: string;
accountIdURL?: string;
organizationIdLabel?: string;
organizationIdURL?: string;
buildServerUrlLabel?: string;
proxy?: boolean;
}
import type { PresetDeployProvider } from '@/lib/deploy/types';
interface OAuthHook {
isOAuthConfigured: boolean;
@@ -49,7 +34,7 @@ interface OAuthHook {
interface AddProviderDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
preset: PresetProvider;
preset: PresetDeployProvider;
isLoggedIntoNostr: boolean;
oauthHook: OAuthHook | null;
forceManualEntry: boolean;
@@ -57,27 +42,6 @@ interface AddProviderDialogProps {
onAdd: (apiKey: string, accountId?: string, organizationId?: string, buildServerUrl?: string) => void;
}
function getProviderUrl(preset: PresetProvider): string | null {
switch (preset.type) {
case 'shakespeare':
return 'https://shakespeare.diy';
case 'netlify':
return 'https://netlify.com';
case 'vercel':
return 'https://vercel.com';
case 'cloudflare':
return 'https://cloudflare.com';
case 'deno':
return 'https://deno.com';
case 'nsite':
return null;
case 'apkbuilder':
return 'https://android.com';
default:
return null;
}
}
export function AddProviderDialog({
open,
onOpenChange,
@@ -136,22 +100,16 @@ export function AddProviderDialog({
}
};
const url = getProviderUrl(preset);
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-md">
<DialogHeader>
<div className="flex items-center gap-2">
{url ? (
<ExternalFavicon
url={url}
size={20}
fallback={<Rocket size={20} />}
/>
) : (
<Rocket size={20} />
)}
<ExternalFavicon
url={preset.baseURL}
size={20}
fallback={<Rocket size={20} />}
/>
<DialogTitle>{preset.name}</DialogTitle>
</div>
<DialogDescription>
@@ -188,15 +146,11 @@ export function AddProviderDialog({
</>
) : (
<>
{url ? (
<ExternalFavicon
url={url}
size={16}
fallback={<Rocket size={16} />}
/>
) : (
<Rocket size={16} />
)}
<ExternalFavicon
url={preset.baseURL}
size={16}
fallback={<Rocket size={16} />}
/>
<span className="truncate text-ellipsis overflow-hidden">
Connect to {preset.name}
</span>
+8 -2
View File
@@ -5,7 +5,7 @@ import { ReactNode, useMemo } from 'react';
interface ExternalFaviconProps {
/** The URL to fetch the favicon for */
url: string | URL;
url: string | URL | undefined;
/** Size of the favicon in pixels */
size?: number;
/** Fallback element to display if favicon fails to load */
@@ -28,9 +28,15 @@ export function ExternalFavicon({
// Generate the favicon URL using the configured template
const faviconSrc = useMemo(() => {
if (!url) return;
try {
const parsedUrl = new URL(url);
// Strip `ai.` and `api.` subdomains for a better chance at finding a favicon
parsedUrl.hostname = parsedUrl.hostname.replace(/^(ai\.|api\.)/, '');
// Normalize the URL to ensure it has a protocol
return faviconUrl(config.faviconUrl, url);
return faviconUrl(config.faviconUrl, parsedUrl);
} catch {
return;
}
+14 -77
View File
@@ -15,29 +15,14 @@ import {
DialogFooter,
} from '@/components/ui/dialog';
import type { DeployProvider } from '@/contexts/DeploySettingsContext';
import type { PresetDeployProvider } from '@/lib/deploy/types';
import { ExternalFavicon } from '@/components/ExternalFavicon';
interface PresetProvider {
id: string;
type: 'shakespeare' | 'netlify' | 'vercel' | 'nsite' | 'cloudflare' | 'deno' | 'apkbuilder';
name: string;
description: string;
requiresNostr?: boolean;
apiKeyLabel?: string;
apiKeyURL?: string;
accountIdLabel?: string;
accountIdURL?: string;
organizationIdLabel?: string;
organizationIdURL?: string;
buildServerUrlLabel?: string;
proxy?: boolean;
}
interface ProviderConfigDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
provider: DeployProvider;
preset?: PresetProvider;
preset?: PresetDeployProvider;
onUpdate: (provider: DeployProvider) => void;
onRemove: () => void;
}
@@ -57,56 +42,6 @@ function normalizeUrl(url: string): string {
return `https://${url}`;
}
function getProviderUrl(provider: DeployProvider | PresetProvider): string | null {
switch (provider.type) {
case 'shakespeare':
// For Shakespeare providers, check for custom host first, then use default
if ('host' in provider && provider.host) {
return normalizeUrl(provider.host);
}
return 'https://shakespeare.diy';
case 'netlify':
// For Netlify providers, check for custom baseURL first, then use default
if ('baseURL' in provider && provider.baseURL) {
return provider.baseURL;
}
return 'https://netlify.com';
case 'vercel':
// For Vercel providers, check for custom baseURL first, then use default
if ('baseURL' in provider && provider.baseURL) {
return provider.baseURL;
}
return 'https://vercel.com';
case 'cloudflare':
// For Cloudflare providers, check for custom baseURL first, then use default
if ('baseURL' in provider && provider.baseURL) {
return provider.baseURL;
}
return 'https://cloudflare.com';
case 'deno':
// For Deno Deploy providers, check for custom baseURL first, then use default
if ('baseURL' in provider && provider.baseURL) {
return provider.baseURL;
}
return 'https://deno.com';
case 'nsite':
// nsite uses Rocket icon fallback
return null;
case 'apkbuilder':
// Use Android's favicon
return 'https://android.com';
default:
return null;
}
}
export function ProviderConfigDialog({
open,
onOpenChange,
@@ -135,22 +70,24 @@ export function ProviderConfigDialog({
onOpenChange(false);
};
const url = getProviderUrl(localProvider);
// Use baseURL from configured provider, falling back to preset baseURL
const baseURL = ('baseURL' in localProvider && localProvider.baseURL) || preset?.baseURL;
// For Shakespeare, special handling for host field
const shakespeareUrl = localProvider.type === 'shakespeare' && 'host' in localProvider && localProvider.host
? normalizeUrl(localProvider.host)
: undefined;
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-md">
<DialogHeader>
<div className="flex items-center gap-2">
{url ? (
<ExternalFavicon
url={url}
size={20}
fallback={<Rocket size={20} />}
/>
) : (
<Rocket size={20} />
)}
<ExternalFavicon
url={shakespeareUrl || baseURL}
size={20}
fallback={<Rocket size={20} />}
/>
<DialogTitle>{localProvider.name}</DialogTitle>
</div>
<DialogDescription>
+37 -62
View File
@@ -15,7 +15,8 @@ import { useAppContext } from '@/hooks/useAppContext';
import { useNostr } from '@nostrify/react';
import { Link } from 'react-router-dom';
import type { DeployProvider } from '@/contexts/DeploySettingsContext';
import type { APKBuildType } from '@/lib/deploy/types';
import type { APKBuildType, PresetDeployProvider } from '@/lib/deploy/types';
import { PRESET_DEPLOY_PROVIDERS } from '@/lib/deployProviderPresets';
import { ShakespeareDeployForm } from '@/components/deploy/ShakespeareDeployForm';
import { NetlifyDeployForm } from '@/components/deploy/NetlifyDeployForm';
import { VercelDeployForm } from '@/components/deploy/VercelDeployForm';
@@ -35,57 +36,28 @@ import { DenoDeployAdapter } from '@/lib/deploy/DenoDeployAdapter';
import { APKBuilderAdapter } from '@/lib/deploy/APKBuilderAdapter';
/**
* Helper function to get provider URL for favicon
* Normalize a URL string to ensure it has a protocol
*/
function getProviderUrl(provider: DeployProvider): string | null {
switch (provider.type) {
case 'shakespeare':
if (provider.host) {
return `https://${provider.host}`;
}
return 'https://shakespeare.diy';
case 'netlify':
if (provider.baseURL) {
return provider.baseURL;
}
return 'https://netlify.com';
case 'vercel':
if (provider.baseURL) {
return provider.baseURL;
}
return 'https://vercel.com';
case 'cloudflare':
if (provider.baseURL) {
return provider.baseURL;
}
return 'https://cloudflare.com';
case 'deno':
if (provider.baseURL) {
return provider.baseURL;
}
return 'https://deno.com';
case 'nsite':
return null;
case 'apkbuilder':
// Use Android's favicon
return 'https://android.com';
default:
return null;
function normalizeUrl(url: string): string {
if (/^https?:\/\//i.test(url)) {
return url;
}
return `https://${url}`;
}
/**
* Render provider icon using favicon or fallback
*/
function renderProviderIcon(provider: DeployProvider, size = 14) {
const url = getProviderUrl(provider);
function renderProviderIcon(provider: DeployProvider, preset: PresetDeployProvider | undefined, size = 14) {
// Use baseURL from configured provider, falling back to preset baseURL
const baseURL = ('baseURL' in provider && provider.baseURL) || preset?.baseURL;
// For Shakespeare, special handling for host field
const shakespeareUrl = provider.type === 'shakespeare' && 'host' in provider && provider.host
? normalizeUrl(provider.host)
: undefined;
const url = shakespeareUrl || baseURL;
if (url) {
return (
@@ -776,23 +748,26 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
<div className="space-y-2">
<Label>Select Provider</Label>
<div className="flex flex-wrap gap-2">
{settings.providers.map((provider) => (
<button
key={provider.id}
type="button"
onClick={() => setSelectedProviderId(provider.id)}
className={cn(
"inline-flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium transition-all",
"border-2 hover:scale-105 active:scale-95",
selectedProviderId === provider.id
? "bg-primary text-primary-foreground border-primary shadow-sm"
: "bg-background text-foreground border-border hover:border-primary/50"
)}
>
{renderProviderIcon(provider, 14)}
<span>{provider.name}</span>
</button>
))}
{settings.providers.map((provider) => {
const preset = PRESET_DEPLOY_PROVIDERS.find(p => p.type === provider.type);
return (
<button
key={provider.id}
type="button"
onClick={() => setSelectedProviderId(provider.id)}
className={cn(
"inline-flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium transition-all",
"border-2 hover:scale-105 active:scale-95",
selectedProviderId === provider.id
? "bg-primary text-primary-foreground border-primary shadow-sm"
: "bg-background text-foreground border-border hover:border-primary/50"
)}
>
{renderProviderIcon(provider, preset, 14)}
<span>{provider.name}</span>
</button>
);
})}
</div>
</div>
+17
View File
@@ -115,3 +115,20 @@ export interface APKBuilderDeployConfig {
logs?: string[];
}) => void;
}
export interface PresetDeployProvider {
id: string;
type: 'shakespeare' | 'netlify' | 'vercel' | 'nsite' | 'cloudflare' | 'deno' | 'apkbuilder';
name: string;
description: string;
baseURL?: string;
requiresNostr?: boolean;
apiKeyLabel?: string;
apiKeyURL?: string;
accountIdLabel?: string;
accountIdURL?: string;
organizationIdLabel?: string;
organizationIdURL?: string;
buildServerUrlLabel?: string;
proxy?: boolean;
}
+73
View File
@@ -0,0 +1,73 @@
import type { PresetDeployProvider } from './deploy/types';
export const PRESET_DEPLOY_PROVIDERS: PresetDeployProvider[] = [
{
id: 'shakespeare',
type: 'shakespeare',
name: 'Shakespeare Deploy',
description: 'Deploy to Shakespeare hosting with Nostr authentication',
baseURL: 'https://shakespeare.diy',
requiresNostr: true,
},
{
id: 'nsite',
type: 'nsite',
name: 'nsite',
description: 'Deploy to Nostr as a static website',
// No baseURL for nsite - uses Rocket icon fallback
},
{
id: 'netlify',
type: 'netlify',
name: 'Netlify',
description: 'Deploy to Netlify',
baseURL: 'https://api.netlify.com/api/v1',
apiKeyLabel: 'Personal Access Token',
apiKeyURL: 'https://app.netlify.com/user/applications#personal-access-tokens',
proxy: true,
},
{
id: 'vercel',
type: 'vercel',
name: 'Vercel',
description: 'Deploy to Vercel',
baseURL: 'https://api.vercel.com',
apiKeyLabel: 'Access Token',
apiKeyURL: 'https://vercel.com/account/tokens',
proxy: true,
},
{
id: 'cloudflare',
type: 'cloudflare',
name: 'Cloudflare',
description: 'Deploy to Cloudflare Workers',
baseURL: 'https://api.cloudflare.com/client/v4',
apiKeyLabel: 'API Token',
apiKeyURL: 'https://dash.cloudflare.com/profile/api-tokens',
accountIdLabel: 'Account ID',
accountIdURL: 'https://developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/',
proxy: true,
},
{
id: 'deno',
type: 'deno',
name: 'Deno Deploy',
description: 'Deploy to Deno Deploy',
baseURL: 'https://api.deno.com/v1',
apiKeyLabel: 'Access Token',
apiKeyURL: 'https://dash.deno.com/account#access-tokens',
organizationIdLabel: 'Organization ID',
organizationIdURL: 'https://dash.deno.com/orgs',
proxy: true,
},
{
id: 'apkbuilder',
type: 'apkbuilder',
name: 'APK Builder',
description: 'Build Android APKs from your web app',
baseURL: 'https://android.com',
buildServerUrlLabel: 'Build Server URL',
apiKeyLabel: 'API Key',
proxy: true,
},
];
+24 -177
View File
@@ -8,6 +8,8 @@ import { useNetlifyOAuth } from '@/hooks/useNetlifyOAuth';
import { useVercelOAuth } from '@/hooks/useVercelOAuth';
import { useCurrentUser } from '@/hooks/useCurrentUser';
import type { DeployProvider } from '@/contexts/DeploySettingsContext';
import type { PresetDeployProvider } from '@/lib/deploy/types';
import { PRESET_DEPLOY_PROVIDERS } from '@/lib/deployProviderPresets';
import { ExternalFavicon } from '@/components/ExternalFavicon';
import { ProviderConfigDialog } from '@/components/ProviderConfigDialog';
import { AddProviderDialog } from '@/components/AddProviderDialog';
@@ -30,31 +32,17 @@ import {
} from '@dnd-kit/sortable';
import { CSS } from '@dnd-kit/utilities';
interface PresetProvider {
id: string;
type: 'shakespeare' | 'netlify' | 'vercel' | 'nsite' | 'cloudflare' | 'deno' | 'apkbuilder';
name: string;
description: string;
requiresNostr?: boolean;
apiKeyLabel?: string;
apiKeyURL?: string;
accountIdLabel?: string;
accountIdURL?: string;
organizationIdLabel?: string;
organizationIdURL?: string;
buildServerUrlLabel?: string;
proxy?: boolean;
}
interface ProviderTileProps {
provider: DeployProvider;
preset?: PresetProvider;
preset?: PresetDeployProvider;
onClick: () => void;
id: string;
}
function ProviderTile({ provider, onClick, id }: ProviderTileProps) {
const url = getProviderUrl(provider);
function ProviderTile({ provider, preset, onClick, id }: ProviderTileProps) {
// Use baseURL from configured provider, falling back to preset baseURL
const baseURL = ('baseURL' in provider && provider.baseURL) || preset?.baseURL;
const {
attributes,
listeners,
@@ -76,15 +64,11 @@ function ProviderTile({ provider, onClick, id }: ProviderTileProps) {
onClick={onClick}
className="flex flex-col items-center justify-center gap-2 p-4 rounded-lg border bg-card hover:bg-muted transition-colors text-center h-[120px] w-full"
>
{url ? (
<ExternalFavicon
url={url}
size={32}
fallback={<Rocket size={32} />}
/>
) : (
<Rocket size={32} />
)}
<ExternalFavicon
url={baseURL}
size={32}
fallback={<Rocket size={32} />}
/>
<span className="text-sm font-medium line-clamp-2 overflow-hidden max-w-full text-ellipsis">
{provider.name}
</span>
@@ -120,27 +104,21 @@ function AddProviderTile({ onClick }: AddProviderTileProps) {
}
interface PresetProviderTileProps {
preset: PresetProvider;
preset: PresetDeployProvider;
onClick: () => void;
}
function PresetProviderTile({ preset, onClick }: PresetProviderTileProps) {
const url = getProviderUrl(preset);
return (
<button
onClick={onClick}
className="flex flex-col items-center justify-center gap-2 p-4 rounded-lg border bg-card hover:bg-muted transition-colors text-center min-h-[100px]"
>
{url ? (
<ExternalFavicon
url={url}
size={32}
fallback={<Rocket size={32} />}
/>
) : (
<Rocket size={32} />
)}
<ExternalFavicon
url={preset.baseURL}
size={32}
fallback={<Rocket size={32} />}
/>
<span className="text-sm font-medium line-clamp-2 overflow-hidden max-w-full text-ellipsis">
{preset.name}
</span>
@@ -148,71 +126,6 @@ function PresetProviderTile({ preset, onClick }: PresetProviderTileProps) {
);
}
const PRESET_PROVIDERS: PresetProvider[] = [
{
id: 'shakespeare',
type: 'shakespeare',
name: 'Shakespeare Deploy',
description: 'Deploy to Shakespeare hosting with Nostr authentication',
requiresNostr: true,
},
{
id: 'nsite',
type: 'nsite',
name: 'nsite',
description: 'Deploy to Nostr as a static website',
},
{
id: 'netlify',
type: 'netlify',
name: 'Netlify',
description: 'Deploy to Netlify',
apiKeyLabel: 'Personal Access Token',
apiKeyURL: 'https://app.netlify.com/user/applications#personal-access-tokens',
proxy: true,
},
{
id: 'vercel',
type: 'vercel',
name: 'Vercel',
description: 'Deploy to Vercel',
apiKeyLabel: 'Access Token',
apiKeyURL: 'https://vercel.com/account/tokens',
proxy: true,
},
{
id: 'cloudflare',
type: 'cloudflare',
name: 'Cloudflare',
description: 'Deploy to Cloudflare Workers',
apiKeyLabel: 'API Token',
apiKeyURL: 'https://dash.cloudflare.com/profile/api-tokens',
accountIdLabel: 'Account ID',
accountIdURL: 'https://developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/',
proxy: true,
},
{
id: 'deno',
type: 'deno',
name: 'Deno Deploy',
description: 'Deploy to Deno Deploy',
apiKeyLabel: 'Access Token',
apiKeyURL: 'https://dash.deno.com/account#access-tokens',
organizationIdLabel: 'Organization ID',
organizationIdURL: 'https://dash.deno.com/orgs',
proxy: true,
},
{
id: 'apkbuilder',
type: 'apkbuilder',
name: 'APK Builder',
description: 'Build Android APKs from your web app',
buildServerUrlLabel: 'Build Server URL',
apiKeyLabel: 'API Key',
proxy: true,
},
];
// Helper function to generate custom provider ID
function generateCustomProviderId(type: string): string {
const uuid = crypto.randomUUID();
@@ -220,72 +133,6 @@ function generateCustomProviderId(type: string): string {
return `${type}-${randomSegment}`;
}
/**
* Normalize a URL string to ensure it has a protocol
* @param url - The URL string to normalize
* @returns A fully-qualified URL string
*/
function normalizeUrl(url: string): string {
// If it already has a protocol, return as-is
if (/^https?:\/\//i.test(url)) {
return url;
}
// Add https:// prefix
return `https://${url}`;
}
function getProviderUrl(provider: DeployProvider | PresetProvider): string | null {
switch (provider.type) {
case 'shakespeare':
// For Shakespeare providers, check for custom host first, then use default
if ('host' in provider && provider.host) {
return normalizeUrl(provider.host);
}
return 'https://shakespeare.diy';
case 'netlify':
// For Netlify providers, check for custom baseURL first, then use default
if ('baseURL' in provider && provider.baseURL) {
return provider.baseURL;
}
return 'https://netlify.com';
case 'vercel':
// For Vercel providers, check for custom baseURL first, then use default
if ('baseURL' in provider && provider.baseURL) {
return provider.baseURL;
}
return 'https://vercel.com';
case 'cloudflare':
// For Cloudflare providers, check for custom baseURL first, then use default
if ('baseURL' in provider && provider.baseURL) {
return provider.baseURL;
}
return 'https://cloudflare.com';
case 'deno':
// For Deno Deploy providers, check for custom baseURL first, then use default
if ('baseURL' in provider && provider.baseURL) {
return provider.baseURL;
}
return 'https://deno.com';
case 'nsite':
// nsite uses Rocket icon fallback
return null;
case 'apkbuilder':
// Use Android's favicon
return 'https://android.com';
default:
return null;
}
}
export function DeploySettings() {
const { t } = useTranslation();
const { settings, removeProvider, setProviders, isInitialized } = useDeploySettings();
@@ -300,7 +147,7 @@ export function DeploySettings() {
// Dialog state
const [selectedProviderIndex, setSelectedProviderIndex] = useState<number | null>(null);
const [dialogOpen, setDialogOpen] = useState(false);
const [selectedPreset, setSelectedPreset] = useState<PresetProvider | null>(null);
const [selectedPreset, setSelectedPreset] = useState<PresetDeployProvider | null>(null);
const [addDialogOpen, setAddDialogOpen] = useState(false);
const [customProviderDialogOpen, setCustomProviderDialogOpen] = useState(false);
@@ -329,12 +176,12 @@ export function DeploySettings() {
setDialogOpen(true);
};
const handleOpenAddDialog = (preset: PresetProvider) => {
const handleOpenAddDialog = (preset: PresetDeployProvider) => {
setSelectedPreset(preset);
setAddDialogOpen(true);
};
const handleAddPresetProvider = (preset: PresetProvider, apiKey: string, accountId?: string, organizationId?: string, buildServerUrl?: string) => {
const handleAddPresetProvider = (preset: PresetDeployProvider, apiKey: string, accountId?: string, organizationId?: string, buildServerUrl?: string) => {
// For Shakespeare, just check if user is logged in
if (preset.requiresNostr && !user) {
return;
@@ -454,7 +301,7 @@ export function DeploySettings() {
};
const configuredProviderIds = settings.providers.map(p => p.id);
const availablePresets = PRESET_PROVIDERS.filter(preset => !configuredProviderIds.includes(preset.id));
const availablePresets = PRESET_DEPLOY_PROVIDERS.filter(preset => !configuredProviderIds.includes(preset.id));
return (
<SettingsPageLayout
@@ -503,7 +350,7 @@ export function DeploySettings() {
>
<div className="grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3">
{settings.providers.map((provider, index) => {
const preset = PRESET_PROVIDERS.find(p => p.type === provider.type);
const preset = PRESET_DEPLOY_PROVIDERS.find(p => p.type === provider.type);
return (
<ProviderTile
@@ -527,7 +374,7 @@ export function DeploySettings() {
open={dialogOpen}
onOpenChange={setDialogOpen}
provider={settings.providers[selectedProviderIndex]}
preset={PRESET_PROVIDERS.find(p => p.type === settings.providers[selectedProviderIndex].type)}
preset={PRESET_DEPLOY_PROVIDERS.find(p => p.type === settings.providers[selectedProviderIndex].type)}
onUpdate={(updatedProvider) => handleUpdateProvider(selectedProviderIndex, updatedProvider)}
onRemove={() => handleRemoveProvider(selectedProviderIndex)}
/>