-
Notifications
You must be signed in to change notification settings - Fork 328
Expand file tree
/
Copy pathbasic-react-app.command.js
More file actions
63 lines (52 loc) · 1.69 KB
/
basic-react-app.command.js
File metadata and controls
63 lines (52 loc) · 1.69 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
const shell = require("shelljs");
const path = require("path");
const fs = require("fs");
const wrapTagAround = require("configure-react/utils/wrapTagAround");
const importAtTop = require("configure-react/utils/importAtTop");
const settingReactRouter = () => {
// Create Routes
shell.exec("npx configure-react create-routes");
};
const settingRedux = () => {
// Create Redux
shell.exec("npx configure-react create-redux");
};
const settingFormik = () => {
// Create Formik
};
const settingAxios = () => {
// Create Axios
};
const startCreateReactApp = () => {
shell.exec(
"npm i react-router-dom react-router redux react-redux redux-thunk formik yup axios react-toastify react-icons "
);
settingReactRouter();
settingRedux();
settingFormik();
settingYup();
settingAxios();
settingReactToastify();
settingReactIcons();
};
const basicReactApp = (projectName) => {
if (projectName[0] !== ".")
return console.log(
"Please go to the project directory root where package.json and react install and run the command"
);
const currentPath = process.cwd();
const packageJsonPath = path.join(currentPath, "./package.json");
const packageJsonData = fs.readFileSync(packageJsonPath, "utf8");
const packageJsonDataObject = JSON.parse(packageJsonData);
const packageJsonDataObjectScripts = packageJsonDataObject.scripts;
if (
packageJsonDataObjectScripts["start"] !== "react-scripts start" ||
packageJsonData.dependencies.react === undefined
) {
return console.log(
"Please install react and run the command from the project directory root where package.json and react install"
);
}
startCreateReactApp();
};
module.exports = basicReactApp;