Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4
feat: auto-claim keyless applications on login#157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
901e63fad9402a289d402dcd38262e41d172c8ea109694f026e495e6b254b15bf66e60d90fd0aFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "clerk": minor | ||
| --- | ||
| Automatically claim and link keyless applications on `clerk auth login`, and write temporary dev keys during `clerk init` when skipping authentication. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -3,10 +3,16 @@ import { link } from "../link/index.js"; | ||
| import { pull } from "../env/pull.js"; | ||
| import { isAgent } from "../../mode.js"; | ||
| import { dim, bold } from "../../lib/color.js"; | ||
| import { throwUserAbort, CliError } from "../../lib/errors.js"; | ||
| import { throwUserAbort, CliError, errorMessage } from "../../lib/errors.js"; | ||
| import { lookupFramework, type FrameworkInfo } from "../../lib/framework.js"; | ||
| import { resolveProfile } from "../../lib/config.js"; | ||
| import { log } from "../../lib/log.js"; | ||
| import { | ||
| createAccountlessApp, | ||
| writeKeysToEnvFile, | ||
| parseClaimToken, | ||
| writeKeylessBreadcrumb, | ||
| } from "../../lib/keyless.js"; | ||
| import { printNextSteps } from "../../lib/next-steps.js"; | ||
| import { gatherContext, hasPackageJson } from "./context.js"; | ||
| import { scaffold, enrichProjectContext } from "./scaffold.js"; | ||
| @@ -117,7 +123,7 @@ export async function init(options: InitOptions = {}) { | ||
| } else if (!keyless) { | ||
| await pull({ file: ctx.envFile }); | ||
| } else { | ||
| printKeylessInfo(); | ||
| await setupKeylessApp(ctx.cwd, ctx.framework.dep, ctx.envFile); | ||
| } | ||
| if (options.skills !== false) { | ||
| @@ -276,6 +282,33 @@ async function authenticateAndLink(cwd: string, app: string | undefined): Promis | ||
| await link({ skipIfLinked: true, app, cwd }); | ||
| } | ||
| // --- Keyless app setup --- | ||
| async function setupKeylessApp(cwd: string, frameworkDep: string, envFile: string): Promise<void> { | ||
| try { | ||
| const app = await withSpinner("Creating development application...", () => | ||
| createAccountlessApp(frameworkDep), | ||
rafa-thayto marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ); | ||
| await writeKeysToEnvFile(cwd, { | ||
| publishableKey: app.publishable_key, | ||
| secretKey: app.secret_key, | ||
| }); | ||
| await writeKeylessBreadcrumb(cwd, parseClaimToken(app.claim_url)); | ||
| printKeylessInfo(envFile); | ||
| } catch (error) { | ||
| log.debug(`Could not create accountless app: ${errorMessage(error)}`); | ||
| const isTimeout = error instanceof Error && error.name === "AbortError"; | ||
| const prefix = isTimeout | ||
| ? "Could not reach api.clerk.com within 15s." | ||
| : "Could not set up development keys."; | ||
| log.warn( | ||
| `${prefix} Run \`clerk auth login\` then \`clerk link\` to connect your app manually.`, | ||
| ); | ||
| } | ||
| } | ||
rafa-thayto marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| // --- Detect & install --- | ||
| async function detectAndInstall( | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.