Skip to content

Commit

Permalink
Merge pull request #88 from seamapi/add_fakeseamconnect_to_server_sel…
Browse files Browse the repository at this point in the history
…ection

Add fakeseamconnect to server selection
  • Loading branch information
kainpets authored Feb 12, 2024
2 parents 83bbe3c + f4f0b18 commit bcbbbdf
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions lib/interact-for-server-selection.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import prompts from "prompts"
import { getConfigStore } from "./get-config-store"
import { randomBytes } from "node:crypto"
import { getServer } from "./get-server"

export async function interactForServerSelection() {
const servers = ["http://localhost:3020", "https://connect.getseam.com"]
const servers = [
"http://localhost:3020",
"https://connect.getseam.com",
"https://fakeseamconnect.seam.vc",
]

const { server } = await prompts([
{
Expand All @@ -14,7 +20,25 @@ export async function interactForServerSelection() {
])

const config = getConfigStore()
config.set("server", server)
if (server === servers[2]) {
let { userUrlSeed } = await prompts([
{
type: "text",
name: "userUrlSeed",
message:
"You can input a custom server URL or leave this field empty to use a new fakeserver.",
},
])

if (userUrlSeed.trim().length === 0) {
userUrlSeed = randomBytes(5).toString("hex")
}
config.set("server", `https://${userUrlSeed}.fakeseamconnect.seam.vc`)
config.set(`${getServer()}.pat`, `seam_apikey1_token`)
console.log(`PAT set to use fakeseamconnect with "seam_apikey1_token"`)
} else {
config.set("server", server)
}
config.delete("current_workspace_id")
console.log(`Server set to ${server}`)
}

0 comments on commit bcbbbdf

Please sign in to comment.