-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathcreate-app-project.js
More file actions
66 lines (53 loc) · 1.82 KB
/
Copy pathcreate-app-project.js
File metadata and controls
66 lines (53 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { copyFile, getTemplateDir, handleAppConfigs } from "./file-manager.js";
import path from "path";
import ora from "ora";
import { isConnectedToInternet } from "./helper.js";
import { axiosInstance } from "./axios.js";
import { CLI_CONSTANTS } from "./constant.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 App Project ...", duration: 2000 }];
}
/**
* function to create frontend projects
* @param {string} framework
* @param {string} projectName
*/
export async function createAppProject(projectName, framework) {
try {
const destinationPath = path.join(
process.cwd(),
projectName ?? `project-starter-${framework}-template`,
);
if (framework === "react-native") {
copyFile(
getTemplateDir(`app/react-native`),
destinationPath,
);
// success message
stages.push({
message: `App - React-Native project created successfully! : ${destinationPath}`,
duration: 1000,
});
await startSpinner();
}
await handleAppConfigs(destinationPath, projectName);
// update stat
// if (await isConnectedToInternet()) {
// await axiosInstance(CLI_CONSTANTS.statBaseUrl).post("/stat", {
// app: "startease",
// framework,
// });
// }
} catch (e) {
console.log(`Error Creating Frontend Project: ${e}`);
}
}