create-fs-app 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/create-fs-app.js +7 -20
- package/package.json +1 -1
package/create-fs-app.js
CHANGED
|
@@ -12,13 +12,16 @@ import gradient from 'gradient-string';
|
|
|
12
12
|
|
|
13
13
|
let appName = process.argv[2];
|
|
14
14
|
const currentDirectory = process.cwd();
|
|
15
|
-
let custAppName = (appName=='.')?currentDirectory:appName;
|
|
16
15
|
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
+
|
|
17
|
+
// git repository
|
|
17
18
|
const mernGitRepo = "https://github.com/Om-jannu/mern-template.git";
|
|
18
19
|
|
|
19
20
|
//sleep function
|
|
20
21
|
const sleep = (ms = 1000) => new Promise((r) => setTimeout(r, ms));
|
|
21
|
-
|
|
22
|
+
const installMyPackage = async() =>{
|
|
23
|
+
child_process.execSync('npm i create-fs-app -g');
|
|
24
|
+
}
|
|
22
25
|
// welcome function
|
|
23
26
|
const welcome = async () => {
|
|
24
27
|
const msg = "create-fs-app";
|
|
@@ -94,6 +97,7 @@ const buildStructure = async(dirName, dir, repo) => {
|
|
|
94
97
|
}
|
|
95
98
|
}
|
|
96
99
|
|
|
100
|
+
// function to create a folder
|
|
97
101
|
async function createFolder(folderName) {
|
|
98
102
|
try {
|
|
99
103
|
if (!fs.existsSync(folderName)) {
|
|
@@ -118,24 +122,7 @@ const BuildMernStructure = async() => {
|
|
|
118
122
|
buildStructure('.', currentDirectory, mernGitRepo);
|
|
119
123
|
}
|
|
120
124
|
else {
|
|
121
|
-
// fs.access(currentDirectory, fs.constants.F_OK, (error) => {
|
|
122
|
-
// if (error) {
|
|
123
|
-
// console.error(chalk.bold.red(`Error: Directory "${currentDirectory}" does not exist`));
|
|
124
|
-
// process.exit(1);
|
|
125
|
-
// }
|
|
126
|
-
// process.chdir(currentDirectory);
|
|
127
|
-
// console.log(chalk.bold.yellow(`Current directory : ${process.cwd()}`));
|
|
128
|
-
// if (fs.existsSync(path.join(parentDir, appName))) {
|
|
129
|
-
// console.log(chalk.bold.red("Folder already exists"));
|
|
130
|
-
// process.exit(0);
|
|
131
|
-
// }
|
|
132
|
-
// fs.mkdirSync(appName);
|
|
133
|
-
// const projectdirname = parentDir+'\\'+appName;
|
|
134
|
-
// buildStructure(appName,projectdirname,mernGitRepo);
|
|
135
|
-
// console.log(chalk.bold.green(`Project "${appName}" has been created`));
|
|
136
|
-
// });
|
|
137
125
|
const projDir = path.resolve(path.dirname(__filename),appName);
|
|
138
|
-
// console.log(projDir);
|
|
139
126
|
await createFolder(appName);
|
|
140
127
|
await buildStructure(appName,projDir,mernGitRepo);
|
|
141
128
|
}
|
|
@@ -147,7 +134,7 @@ if (process.argv.length > 3) {
|
|
|
147
134
|
console.log(chalk.bold.yellow("Try : npx build-mern-app app_name"));
|
|
148
135
|
process.exit(1);
|
|
149
136
|
}
|
|
150
|
-
|
|
137
|
+
await installMyPackage();
|
|
151
138
|
await welcome();
|
|
152
139
|
await askFsName();
|
|
153
140
|
|