@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
24 lines (23 loc) • 1.01 kB
JavaScript
import { inputPrompt, isValidName } from "@reliverse/rempts";
import { generate } from "random-words";
export async function askProjectName({
repoName = ""
}) {
let defaultValue;
if (repoName) {
defaultValue = repoName.split("/").pop() ?? "";
} else {
defaultValue = generate({ exactly: 2, join: "-" });
}
const title = repoName ? "How should I name proceeding project?" : "How should I name your brand new project?";
const content = repoName ? "This name will be used to create the project directory." : "This name may be used to create the project directory, throughout the project, etc.";
const placeholder = repoName ? `Press <Enter> to use the repository name: ${defaultValue}` : `I've just generated a random name for you (press <Enter> to use it): ${defaultValue}`;
const name = await inputPrompt({
title,
content,
placeholder,
defaultValue,
validate: (value) => isValidName(value).isValid || `Invalid project name: ${value}`
});
return name.toString();
}