test again

This commit is contained in:
Adam Matthiesen 2024-01-27 16:13:54 -08:00
parent ce3cf3b23e
commit d201bb6ed2
3 changed files with 20 additions and 20 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@matthiesenxyz/create-astro-ghostcms", "name": "@matthiesenxyz/create-astro-ghostcms",
"version": "0.0.1-dev07", "version": "0.0.1-dev08",
"description": "Utility to quickly get started with our Integration and astro", "description": "Utility to quickly get started with our Integration and astro",
"type": "module", "type": "module",
"main": "./create-astro-ghostcms.mjs", "main": "./create-astro-ghostcms.mjs",

View File

@ -48,16 +48,16 @@ export async function main() {
// 2. Get template to set up // 2. Get template to set up
let [template, ...args] = flags._; let [template, ...args] = flags._;
if (template && !isValidTemplate(template)) { if (template && !isValidTemplate(template)) {
prompts.log.warning(`"${template}" isn't a valid template`); prompts.log.warning(color.red(`"${template}" isn't a valid template`));
template = null; template = null;
} }
if (!template) { if (!template) {
const answer = await prompts.select({ const answer = await prompts.select({
message: "Which template would you like to use?", message: `${color.cyan('Which template would you like to use?')}`,
options: [ options: [
{ {
value: "basic", value: "basic",
label: "Basic - Integration w/ Default Theme" label: `${color.magenta('Basic')} - ${color.cyan(color.italic('Integration w/ Default Theme'))}`
}, },
], ],
initialValue: "basic", initialValue: "basic",
@ -82,7 +82,7 @@ export async function main() {
await createBasic(ctx).catch(console.error); await createBasic(ctx).catch(console.error);
break; break;
default: default:
throw new Error(`Unknown template: ${template}`); throw new Error(color.red(`Unknown template: ${template}`));
} }
// 4. Huzzah! // 4. Huzzah!
@ -90,7 +90,7 @@ export async function main() {
} }
function getHelp() { function getHelp() {
return `Need Help? Check the Docs! ${color.underline(color.cyan('https://astro-ghostcms.xyz/docs'))}`; return `${color.yellow('Need Help? Check the Docs!')} ${color.underline(color.cyan('https://astro-ghostcms.xyz/docs'))}`;
} }
/** /**

View File

@ -24,39 +24,39 @@ export async function createBasic(ctx) {
// 2. Create the damned thing // 2. Create the damned thing
cwd = project.pathname; cwd = project.pathname;
const relativePath = path.relative(process.cwd(), project.pathname); const relativePath = path.relative(process.cwd(), project.pathname);
spinner.start(`Creating a new Astro-GhostCMS project in ${relativePath}`); spinner.start(`${c.yellow(`Creating a new Astro-GhostCMS project in ${relativePath}`)}`);
if (dryRun) { if (dryRun) {
await wait(2000); await wait(2000);
} else { } else {
await createApp(project.name, project.pathname, { await createApp(project.name, project.pathname, {
onError(error) { onError(error) {
spinner.stop("Failed to create new project"); spinner.stop(`${c.red('Failed to create new project')}`);
prompts.cancel(); prompts.cancel();
console.error(error); console.error(error);
process.exit(1); process.exit(1);
}, },
}); });
} }
spinner.stop(`New Astro-GhostCMS project '${project.name}' created 🚀`); spinner.stop(`${c.green('New Astro-GhostCMS project')} '${project.name}' ${c.green('created')} 🚀`);
const fCheck = await prompts.group( const fCheck = await prompts.group(
{ installDeps: () => { installDeps: () =>
prompts.confirm({ prompts.confirm({
message: "Install dependencies? (Recommended)", message: `${c.green('Install dependencies? (Recommended)')}`,
initialValue: false, initialValue: false,
}), initGitRepo: () => }), initGitRepo: () =>
prompts.confirm({ prompts.confirm({
message: "Initialize a Git repository?", message: `${c.cyan('Initialize a Git repository?')} ${c.dim(`( Tip: If this option gets 'stuck' press the enter button a second time! )`)}`,
initialValue: false, initialValue: false,
}), }),
}, },
{ onCancel: () => { { onCancel: () => {
prompts.cancel(c.red('Operation Cancelled!')); prompts.cancel(`${c.red('Operation Cancelled!')}`);
process.exit(0); process.exit(0);
} }
} }
); );
initGitRepo = initGitRepo ?? fCheck.initGitRepo.valueOf(); initGitRepo = initGitRepo ?? fCheck.initGitRepo;
// 3. Initialize git repo // 3. Initialize git repo
if (initGitRepo) { if (initGitRepo) {
if (dryRun) { if (dryRun) {
@ -64,27 +64,27 @@ export async function createBasic(ctx) {
} else { } else {
await exec("git", ["init"], { cwd }); await exec("git", ["init"], { cwd });
} }
prompts.log.success("Initialized Git repository"); prompts.log.success(c.green("Initialized Git repository"));
} else { } else {
prompts.log.info("Skipped Git initialization"); prompts.log.info(`${c.gray("Skipped Git initialization")}`);
} }
const nextSteps = `If you didnt opt to install Dependencies dont forget to run: \n ${c.yellow('npm install')} / ${c.yellow('pnpm install')} / ${c.yellow('yarn install')} inside your project directory! \n \n ${c.bgYellow(c.black("Dont forget to modify your .env file for YOUR ghost install!"))} ` const nextSteps = `If you didnt opt to install Dependencies dont forget to run: \n ${c.yellow('npm install')} / ${c.yellow('pnpm install')} / ${c.yellow('yarn install')} inside your project directory! \n \n ${c.bgYellow(c.black("Dont forget to modify your .env file for YOUR ghost install!"))} `
// 4. Install dependencies // 4. Install dependencies
installDeps = installDeps ?? fCheck.installDeps.valueOf(); installDeps = installDeps ?? fCheck.installDeps;
const pm = ctx.pkgManager ?? "pnpm"; const pm = ctx.pkgManager ?? "pnpm";
if (installDeps) { if (installDeps) {
spinner.start(`Installing dependencies with ${pm}`); spinner.start(`${c.cyan(`Installing dependencies with ${pm}`)} `);
if (dryRun) { if (dryRun) {
await wait(1); await wait(1);
} else { } else {
await installDependencies(pm, { cwd }); await installDependencies(pm, { cwd });
} }
spinner.stop(`Dependencies installed with ${pm}`); spinner.stop(`${c.green(`Dependencies installed with ${pm}`)}`);
success() success()
} else { } else {
prompts.log.info("Skipped dependency installation"); prompts.log.info(`${c.gray('Skipped dependency installation')}`);
success() success()
} }
@ -153,7 +153,7 @@ async function getProjectDetails(projectNameInput, opts) {
if (!projectName) { if (!projectName) {
const defaultProjectName = "my-astro-ghost"; const defaultProjectName = "my-astro-ghost";
let answer = await prompts.text({ let answer = await prompts.text({
message: "Where would you like to create your project?", message: `${c.cyan("Where would you like to create your project?")}`,
placeholder: `.${path.sep}${defaultProjectName}`, placeholder: `.${path.sep}${defaultProjectName}`,
}); });
if (prompts.isCancel(answer)) exitPrompt(); if (prompts.isCancel(answer)) exitPrompt();