feat(create-mcfly): default directory; some styles
This commit is contained in:
parent
1881bcdcf5
commit
d04a7ebdcd
1 changed files with 11 additions and 7 deletions
|
@ -3,15 +3,17 @@
|
||||||
const { downloadTemplate } = require("giget");
|
const { downloadTemplate } = require("giget");
|
||||||
const { consola } = require("consola");
|
const { consola } = require("consola");
|
||||||
const { execSync: exec } = require("node:child_process");
|
const { execSync: exec } = require("node:child_process");
|
||||||
|
const { colorize } = require("consola/utils");
|
||||||
create();
|
create();
|
||||||
async function create() {
|
async function create() {
|
||||||
console.clear();
|
console.clear();
|
||||||
let hasErrors = false;
|
let hasErrors = false;
|
||||||
consola.box("👋 Hello! Welcome to McFly.");
|
const defaultDirectory = "./mcfly-app";
|
||||||
|
consola.box(`👋 Hello! Welcome to ${colorize("bold", "McFly")}!`);
|
||||||
const directory =
|
const directory =
|
||||||
(await consola.prompt("Give your new project a name:", {
|
(await consola.prompt("Give your new project a name:", {
|
||||||
placeholder: "./mcfly-app",
|
placeholder: defaultDirectory,
|
||||||
})) ?? "mcfly-app";
|
})) ?? defaultDirectory;
|
||||||
try {
|
try {
|
||||||
consola.start(`Copying template to ${directory}...`);
|
consola.start(`Copying template to ${directory}...`);
|
||||||
await downloadTemplate("github:ayoayco/mcfly/templates/basic", {
|
await downloadTemplate("github:ayoayco/mcfly/templates/basic", {
|
||||||
|
@ -56,23 +58,25 @@ async function create() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let nextActions = [`Go to your project by running 'cd ./${directory}'`];
|
let nextActions = [`Go to your project by running: 'cd ${directory}'`];
|
||||||
|
|
||||||
if (!installDeps) {
|
if (!installDeps) {
|
||||||
nextActions.push("Install the dependencies with: 'npm install'");
|
nextActions.push("Install the dependencies with: 'npm install'");
|
||||||
}
|
}
|
||||||
|
|
||||||
nextActions = nextActions.concat([
|
nextActions = nextActions.concat([
|
||||||
"Run 'npm start' to start the dev server",
|
"To start the dev server, run: 'npm start'",
|
||||||
"Join us at https://ayco.io/gh/McFly",
|
"Join us at https://ayco.io/gh/McFly",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const result = `🎉 Your new McFly app is now ready: ./${directory}\n\nNext actions: ${nextActions
|
const result = `🎉 Your new ${colorize(
|
||||||
|
"bold",
|
||||||
|
"McFly"
|
||||||
|
)} app is now ready: ${directory}\n\nNext actions: ${nextActions
|
||||||
.map((action, index) => `\n${++index}. ${action}`)
|
.map((action, index) => `\n${++index}. ${action}`)
|
||||||
.join("")}`;
|
.join("")}`;
|
||||||
|
|
||||||
consola.box(result);
|
consola.box(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue