opencode auth login: validation on provider id and better error messages
This commit is contained in:
parent
19e259d90d
commit
fcaf0e6dbf
1 changed files with 7 additions and 2 deletions
|
|
@ -78,11 +78,16 @@ export const AuthLoginCommand = cmd({
|
||||||
|
|
||||||
if (provider === "other") {
|
if (provider === "other") {
|
||||||
provider = await prompts.text({
|
provider = await prompts.text({
|
||||||
message:
|
message: "Enter provider id",
|
||||||
"Enter provider - must be package name from https://ai-sdk.dev/providers",
|
validate: (x) =>
|
||||||
|
x.match(/^[a-z-]+$/) ? undefined : "a-z and hyphens only",
|
||||||
})
|
})
|
||||||
|
if (prompts.isCancel(provider)) throw new UI.CancelledError()
|
||||||
provider = provider.replace(/^@ai-sdk\//, "")
|
provider = provider.replace(/^@ai-sdk\//, "")
|
||||||
if (prompts.isCancel(provider)) throw new UI.CancelledError()
|
if (prompts.isCancel(provider)) throw new UI.CancelledError()
|
||||||
|
prompts.log.warn(
|
||||||
|
`This only stores a credential for ${provider} - you will need configure it in opencode.json, check the docs for examples.`,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (provider === "amazon-bedrock") {
|
if (provider === "amazon-bedrock") {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue