Skip to content

Commit

Permalink
Merge pull request #66 from JC-Coder/fix/emm00-spinner-patch
Browse files Browse the repository at this point in the history
Fix/emm00 spinner patch
  • Loading branch information
JC-Coder authored May 14, 2024
2 parents 3bb278f + 75335dd commit 6600788
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 33 deletions.
3 changes: 2 additions & 1 deletion src/utils/create-backend-project.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ export async function createBackendProject(
orm,
installDependencies,
) {
const spinner = ora("Creating Project ...").start();
try {
const spinner = ora("Creating Project ...").start();

const destinationPath = path.join(
process.cwd(),
projectName ?? `project-starter-${framework}-template`,
Expand Down
49 changes: 17 additions & 32 deletions src/utils/create-frontend-project.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,6 @@ import path from "path";
import ora from "ora";
import { sendStat } from "./stat.js";

/**
* loader
*/
let stages = [{ message: "Creating Project ...", duration: 2000 }];

async function startSpinner() {
for (const stage of stages) {
const spinner = ora(stage.message).start();
await new Promise((resolve) => setTimeout(resolve, stage.duration));
spinner.succeed(stage.message.replace("...", " completed."));
}

stages = [{ message: "Creating Project ...", duration: 2000 }];
}

/**
* function to create frontend projects
* @param {string} framework - {reactjs, vuejs}
Expand All @@ -27,12 +12,15 @@ async function startSpinner() {

export async function createFrontendProject(projectName, framework, language) {
try {
const spinner = ora("Creating Project ...").start();

const destinationPath = path.join(
process.cwd(),
projectName ?? `project-starter-${framework}-template`,
);

if (framework === "reactjs") {
spinner.start('Creating ReactJS project ...')
// copy files based on the language chosen
switch (language) {
case "javascript":
Expand All @@ -46,22 +34,20 @@ export async function createFrontendProject(projectName, framework, language) {
getTemplateDir(`frontend/reactjs/react-typescript-temp`),
destinationPath,
);

break;
default:
break;
}
addGitignore(framework, destinationPath);

// success message
stages.push({
message: `Frontend - ReactJS project with ${
spinner.succeed(
`Frontend - ReactJS project with ${
language.charAt(0).toUpperCase() + language.slice(1)
} created successfully! : ${destinationPath}`,
duration: 1000,
});

await startSpinner();
);
} else if (framework === "vuejs") {
spinner.start('Creating VueJS project ...')
switch (language) {
case "javascript":
copyFile(
Expand All @@ -74,28 +60,27 @@ export async function createFrontendProject(projectName, framework, language) {
getTemplateDir(`frontend/vuejs/vuejs-typescript-temp`),
destinationPath,
);

break;
default:
break;
}
addGitignore(framework, destinationPath);

// success message
stages.push({
message: `Frontend - VueJs project with ${
spinner.succeed(
`Frontend - VueJs project with ${
language.charAt(0).toUpperCase() + language.slice(1)
} created successfully! : ${destinationPath}`,
});
);
} else if (framework === "html-x-css-x-javascript") {
spinner.start('Creating HTML, CSS, and JavaScript project ...')

copyFile(getTemplateDir(`frontend/html-css-javascript`), destinationPath);

// success message
stages.push({
message: `Frontend - plain html with css and javascript created successfully! : ${destinationPath}`,
duration: 1000,
});

await startSpinner();
spinner.succeed(
`Frontend - HTML, CSS, and JavaScript project created! : ${destinationPath}`,
);
}

// update stat
Expand Down

0 comments on commit 6600788

Please sign in to comment.