generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bbad960
commit 8bf712a
Showing
5 changed files
with
310 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { NextResponse } from "next/server"; | ||
import { db, vercelTokens } from "@/drizzle/schema"; | ||
import { Vercel } from "@vercel/sdk"; | ||
import { auth } from "@clerk/nextjs/server"; | ||
import { eq } from "drizzle-orm"; | ||
|
||
export async function POST() { | ||
try { | ||
const { userId } = auth(); | ||
if (!userId) { | ||
return new NextResponse("Unauthorized", { status: 401 }); | ||
} | ||
|
||
const tokenRecord = await db | ||
.select() | ||
.from(vercelTokens) | ||
.where(eq(vercelTokens.userId, userId)) | ||
.limit(1); | ||
|
||
if (!tokenRecord[0] || !tokenRecord[0].projectId) { | ||
return new NextResponse("No deployment found", { status: 404 }); | ||
} | ||
|
||
const vercel = new Vercel({ | ||
bearerToken: tokenRecord[0].token, | ||
}); | ||
const repo = "file-organizer-2000"; | ||
const org = "different-ai"; | ||
const ref = "master"; | ||
|
||
const deployment = await vercel.deployments.createDeployment({ | ||
requestBody: { | ||
name: `file-organizer-redeploy-${Date.now()}`, | ||
target: "production", | ||
project: tokenRecord[0].projectId, | ||
gitSource: { | ||
type: "github", | ||
repo: repo, | ||
ref: ref, | ||
org: org, | ||
}, | ||
projectSettings: { | ||
framework: "nextjs", | ||
buildCommand: "pnpm build:self-host", | ||
installCommand: "pnpm install", | ||
outputDirectory: ".next", | ||
rootDirectory: "web", | ||
}, | ||
}, | ||
}); | ||
|
||
return NextResponse.json({ | ||
success: true, | ||
deploymentUrl: deployment.url, | ||
}); | ||
} catch (error) { | ||
console.error("Error in redeploy:", error); | ||
return NextResponse.json( | ||
{ error: "Failed to redeploy" }, | ||
{ status: 500 } | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
export function PluginSetup({ projectUrl }) { | ||
return ( | ||
<Card className="rounded-md p-4"> | ||
<CardHeader className="p-4"> | ||
<CardTitle>Plugin Setup</CardTitle> | ||
</CardHeader> | ||
<CardContent className="p-4"> | ||
<div className="space-y-4"> | ||
<p className="text-sm text-muted-foreground"> | ||
Make sure your Obsidian plugin is configured with these settings: | ||
</p> | ||
<div className="space-y-2"> | ||
<div className="flex items-center justify-between"> | ||
<span className="text-sm font-medium">Self-Hosting URL</span> | ||
<code className="px-2 py-1 bg-muted rounded text-xs"> | ||
{projectUrl} | ||
</code> | ||
</div> | ||
</div> | ||
<Button | ||
variant="outline" | ||
size="sm" | ||
asChild | ||
className="w-full" | ||
> | ||
<a href="obsidian://show-plugin?id=fileorganizer2000"> | ||
Open Plugin Settings | ||
</a> | ||
</Button> | ||
</div> | ||
</CardContent> | ||
</Card> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.