| 1 | import { sql } from "drizzle-orm"; |
| 2 | |
| 3 | import type { Database |
| 4 | import { oauthClient } |
| 5 | |
| 6 | /** gh's OAuth app: the same client id on every GitHub host, so Ghost registers it under that id. No owner, so nobody can edit or delete it; no secret, as gh uses the device flow. */ |
| 7 | export const GITHUB_CLI_CLIENT_ID = |
| 8 | |
| 9 | /** Rows every instance needs and no migration should carry. Safe to rerun: an existing row keeps its fields, and only gains the verified mark. */ |
| 10 | export async function seedBuiltInRows |
| 11 | await db |
| 12 | .insert(oauthClient) |
| 13 | .values({ |
| 14 | id: "github-cli", |
| 15 | clientId: GITHUB_CLI_CLIENT_ID, |
| 16 | name: "GitHub CLI", |
| 17 | uri: "https://cli.github.com", |
| 18 | redirectUris: [], |
| 19 | tokenEndpointAuthMethod: "none", |
| 20 | skipConsent: false, |
| 21 | metadata: { deviceFlow: true |
| 22 | createdAt: new Date |
| 23 | updatedAt: new Date |
| 24 | }) |
| 25 | .onConflictDoUpdate({ |
| 26 | target: oauthClient.clientId |
| 27 | set: { |
| 28 | metadata: sql`coalesce(${ |
| 29 | }, |
| 30 | }); |
| 31 | } |