Skip to content

Commit 9007411

Browse files
committed
chore: merge main into release for new releases
2 parents f3faf3b + 0d34e8b commit 9007411

File tree

13 files changed

+596
-278
lines changed

13 files changed

+596
-278
lines changed

.cursor/mcp.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"mcpServers": {
3+
"trigger": {
4+
"command": "npx",
5+
"args": [
6+
"trigger.dev@latest",
7+
"mcp",
8+
"--dev-only"
9+
]
10+
}
11+
}
12+
}

apps/app/src/app/(app)/[orgId]/cloud-tests/actions/connect-cloud.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { encrypt } from '@/lib/encryption';
44
import { getIntegrationHandler } from '@comp/integrations';
55
import { db } from '@db';
66
import { revalidatePath } from 'next/cache';
7-
import { headers } from 'next/headers';
7+
import { cookies, headers } from 'next/headers';
88
import { z } from 'zod';
99
import { authActionClient } from '../../../../../actions/safe-action';
1010
import { runTests } from './run-tests';
@@ -100,7 +100,11 @@ export const connectCloudAction = authActionClient
100100
}
101101

102102
// Trigger immediate scan
103-
await runTests();
103+
const runResult = await runTests();
104+
105+
if (runResult.success && runResult.publicAccessToken) {
106+
(await cookies()).set('publicAccessToken', runResult.publicAccessToken);
107+
}
104108

105109
// Revalidate the path
106110
const headersList = await headers();
@@ -110,6 +114,13 @@ export const connectCloudAction = authActionClient
110114

111115
return {
112116
success: true,
117+
trigger: runResult.success
118+
? {
119+
taskId: runResult.taskId ?? undefined,
120+
publicAccessToken: runResult.publicAccessToken ?? undefined,
121+
}
122+
: undefined,
123+
runErrors: runResult.success ? undefined : (runResult.errors ?? undefined),
113124
};
114125
} catch (error) {
115126
console.error('Failed to connect cloud provider:', error);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
'use server';
2+
3+
import { auth as betterAuth } from '@/utils/auth';
4+
import { auth } from '@trigger.dev/sdk';
5+
import { headers } from 'next/headers';
6+
7+
export const createTriggerToken = async () => {
8+
const session = await betterAuth.api.getSession({
9+
headers: await headers(),
10+
});
11+
12+
if (!session) {
13+
return {
14+
success: false,
15+
error: 'Unauthorized',
16+
};
17+
}
18+
19+
const orgId = session.session?.activeOrganizationId;
20+
if (!orgId) {
21+
return {
22+
success: false,
23+
error: 'No active organization',
24+
};
25+
}
26+
27+
try {
28+
const token = await auth.createTriggerPublicToken('run-integration-tests', {
29+
multipleUse: true,
30+
expirationTime: '1hr',
31+
});
32+
33+
return {
34+
success: true,
35+
token,
36+
};
37+
} catch (error) {
38+
console.error('Error creating trigger token:', error);
39+
return {
40+
success: false,
41+
error: error instanceof Error ? error.message : 'Failed to create trigger token',
42+
};
43+
}
44+
};

apps/app/src/app/(app)/[orgId]/cloud-tests/components/CloudConnectionCard.tsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ interface CloudField {
1818
type?: string;
1919
}
2020

21+
type TriggerInfo = {
22+
taskId?: string;
23+
publicAccessToken?: string;
24+
};
25+
2126
interface CloudConnectionCardProps {
2227
cloudProvider: 'aws' | 'gcp' | 'azure';
2328
name: string;
@@ -27,7 +32,7 @@ interface CloudConnectionCardProps {
2732
guideUrl?: string;
2833
color?: string;
2934
logoUrl?: string;
30-
onSuccess?: () => void;
35+
onSuccess?: (trigger?: TriggerInfo) => void;
3136
}
3237

3338
export function CloudConnectionCard({
@@ -83,7 +88,11 @@ export function CloudConnectionCard({
8388
if (result?.data?.success) {
8489
toast.success(`${name} connected! Running initial scan...`);
8590
setCredentials({});
86-
onSuccess?.();
91+
onSuccess?.(result.data?.trigger);
92+
93+
if (result.data?.runErrors && result.data.runErrors.length > 0) {
94+
toast.error(result.data.runErrors[0] || 'Initial scan reported an issue');
95+
}
8796
} else {
8897
toast.error(result?.data?.error || 'Failed to connect');
8998
}
@@ -99,13 +108,11 @@ export function CloudConnectionCard({
99108
<Card className="rounded-xs">
100109
<CardHeader className="space-y-4">
101110
<div className="flex items-center gap-3">
102-
<div className={`bg-gradient-to-br ${color} flex items-center justify-center rounded-lg p-2`}>
111+
<div
112+
className={`bg-gradient-to-br ${color} flex items-center justify-center rounded-lg p-2`}
113+
>
103114
{logoUrl && (
104-
<img
105-
src={logoUrl}
106-
alt={`${shortName} logo`}
107-
className="h-8 w-8 object-contain"
108-
/>
115+
<img src={logoUrl} alt={`${shortName} logo`} className="h-8 w-8 object-contain" />
109116
)}
110117
</div>
111118
<div>

apps/app/src/app/(app)/[orgId]/cloud-tests/components/EmptyState.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,18 @@ const PROVIDER_FIELDS: Record<'aws' | 'gcp' | 'azure', ProviderFieldWithOptions[
117117
],
118118
};
119119

120+
type TriggerInfo = {
121+
taskId?: string;
122+
publicAccessToken?: string;
123+
};
124+
120125
interface EmptyStateProps {
121126
onBack?: () => void;
122127
connectedProviders?: string[];
128+
onConnected?: (trigger?: TriggerInfo) => void;
123129
}
124130

125-
export function EmptyState({ onBack, connectedProviders = [] }: EmptyStateProps = {}) {
131+
export function EmptyState({ onBack, connectedProviders = [], onConnected }: EmptyStateProps = {}) {
126132
const [step, setStep] = useState<Step>('choose');
127133
const [selectedProvider, setSelectedProvider] = useState<CloudProvider>(null);
128134
const [credentials, setCredentials] = useState<Record<string, string>>({});
@@ -224,6 +230,12 @@ export function EmptyState({ onBack, connectedProviders = [] }: EmptyStateProps
224230

225231
if (result?.data?.success) {
226232
setStep('success');
233+
if (result.data?.trigger) {
234+
onConnected?.(result.data.trigger);
235+
}
236+
if (result.data?.runErrors && result.data.runErrors.length > 0) {
237+
toast.error(result.data.runErrors[0] || 'Initial scan reported an issue');
238+
}
227239
// If user already has clouds, automatically return to results after 2 seconds
228240
if (onBack) {
229241
setTimeout(() => {

0 commit comments

Comments
 (0)