Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const CredentialsSchema = z.looseObject({
type Credentials = z.infer<typeof CredentialsSchema>;

export async function getToken(): Promise<string | undefined> {
if (env.PRISMIC_TOKEN) return env.PRISMIC_TOKEN;
Comment thread
cursor[bot] marked this conversation as resolved.
const credentials = await readCredentials();
return credentials?.token;
}
Expand All @@ -34,6 +35,7 @@ export async function getHost(): Promise<string> {
}

export async function refreshToken(): Promise<string | undefined> {
if (env.PRISMIC_TOKEN) return;
const token = await getToken();
if (!token) return;
const host = await getHost();
Expand Down
1 change: 1 addition & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const Env = z.object({
PRISMIC_SENTRY_ENVIRONMENT: z.optional(z.string()),
PRISMIC_SENTRY_ENABLED: z.optional(z.stringbool()),
PRISMIC_HOST: z.optional(z.string()),
PRISMIC_TOKEN: z.optional(z.string()),
PRISMIC_DOCS_HOST: z.optional(z.string()),
PRISMIC_CONFIG_DIR: z.optional(z.string()),
PRISMIC_TYPE_BUILDER_ENABLED: z.optional(z.stringbool()),
Expand Down
Loading