Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import figlet from "figlet";
import { program } from "commander";
import chalk from "chalk";
import shell from "shelljs";
import path from "path";
import useGradient from "./src/utils/useGradient.js";
import { createBackendProject } from "./src/utils/create-backend-project.js";
import {
Expand All @@ -14,11 +16,13 @@ import {
promptOrm,
promptProjectName,
promptProjectStack,
promptDependenciesInstall
promptDependenciesInstall,
promptInitializeGit
} from "./src/utils/prompts.js";
import { createFrontendProject } from "./src/utils/create-frontend-project.js";
import { validateProjectName } from "./src/utils/helper.js";
import { sendQueuedStats } from "./src/utils/stat.js";
import ora from "ora";

const toolName = "StartEase";
const jsBackendStacks = ["expressjs", "nestjs"];
Expand All @@ -42,6 +46,7 @@ async function startProject() {
let orm;
let language;
let installDependencies;
let initializeGit;

const initialMsg = `Simplify Project Setup with the. ${chalk.green(
toolName,
Expand All @@ -65,12 +70,13 @@ async function startProject() {
if (projectStack === "frontend") {
language = await promptFrontendLanguage();
framework = await promptFrontendFramework();
initializeGit = await promptInitializeGit();

if (framework === "html-x-css-x-javascript") {
return await createFrontendProject(projectName, framework, "javascript");
}

return await createFrontendProject(projectName, framework, language);
await createFrontendProject(projectName, framework, language);
} else if (projectStack === "backend") {
framework = await promptBackendFramework();

Expand All @@ -83,11 +89,31 @@ async function startProject() {
orm = await promptOrm(database);
}
}

installDependencies = await promptDependenciesInstall();

initializeGit = await promptInitializeGit();

await createBackendProject(projectName, framework, database, orm, installDependencies);
}
if (initializeGit) {
if (shell.which("git")) {
const destinationPath = path.join(
process.cwd(),
projectName ?? `project-starter-${framework}-template`,
);
// initialize git for the final source
const spinner = ora();
spinner.succeed();
spinner.start("Initializing git ...");

shell.cd(`${destinationPath}`);
shell.exec(`git init`, { silent: true });
shell.exec(`git add .`, { silent: true });
shell.exec(`git commit -m "Initial commit"`, { silent: true });
shell.cd("-");
spinner.succeed("Project ready!🚀");
}
}
}

/**
Expand Down
13 changes: 0 additions & 13 deletions src/utils/create-backend-project.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,19 +322,6 @@ export async function createBackendProject(
projectName,
},
);

if (shell.which("git")) {
// initialize git for the final source

spinner.succeed();
spinner.start("Initializing git ...");

shell.cd(`${destinationPath}`);
shell.exec(`git init`);
shell.exec(`git add .`);
shell.exec(`git commit -m "Initial commit"`);
shell.cd("-");
}
}

// process dependencies install
Expand Down
12 changes: 12 additions & 0 deletions src/utils/prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,15 @@ export async function promptDependenciesInstall() {

return result.installDependencies;
}

export async function promptInitializeGit() {
const result = await inquirer.prompt([
{
type: "confirm",
name: "initializeGit",
message: "Initialize Git?",
default: true,
},
]);
return result.initializeGit;
}