@reliverse/rse
Version:
@reliverse/rse is your all-in-one companion for bootstrapping and improving any kind of projects (especially web apps built with frameworks like Next.js) — whether you're kicking off something new or upgrading an existing app. It is also a little AI-power
30 lines (29 loc) • 1.35 kB
JavaScript
import { relinka } from "@reliverse/relinka";
import { inputPrompt } from "@reliverse/rempts";
import { updateReliverseMemory } from "../reliverseMemory.js";
export async function askUsernameGithub(memory, frontendUsername) {
if (memory.githubUsername?.trim()) {
return memory.githubUsername;
}
const githubUsername = await inputPrompt({
title: `What's your GitHub username?`,
content: "If you don't have a GitHub account, you can create one for free at https://github.com/signup",
hint: `Leave empty if your GitHub username matches your frontend username and you want to use it: ${frontendUsername}`,
defaultValue: frontendUsername ?? "",
validate: (value) => {
const trimmed = value?.trim();
if (!trimmed) return "A GitHub username is required for the next steps.";
if (!/^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}$/i.test(trimmed)) {
return "Invalid GitHub username format. It must be 1-39 characters long, contain only letters, numbers, or dashes, and cannot start or end with a dash.";
}
return true;
}
});
if (!githubUsername.trim()) {
relinka("error", "Invalid GitHub username provided.");
throw new Error("GitHub username input is invalid.");
}
await updateReliverseMemory({ githubUsername });
memory.githubUsername = githubUsername;
return githubUsername;
}