create-fs-app 1.1.6 → 1.1.8
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/README.md +8 -8
- package/create-fs-app.js +138 -139
- package/package.json +33 -33
- package/package-lock.json +0 -1592
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Create fs App
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
```sh
|
|
5
|
-
npx create-fs-app my-app
|
|
6
|
-
```
|
|
7
|
-
|
|
8
|
-
_([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) is a package runner tool that comes with npm 5.2+ and higher, see [instructions for older npm versions](https://gist.github.com/gaearon/4064d3c23a77c74a3614c498a8bb1c5f))_
|
|
1
|
+
# Create fs App
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
```sh
|
|
5
|
+
npx create-fs-app my-app
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
_([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) is a package runner tool that comes with npm 5.2+ and higher, see [instructions for older npm versions](https://gist.github.com/gaearon/4064d3c23a77c74a3614c498a8bb1c5f))_
|
package/create-fs-app.js
CHANGED
|
@@ -1,140 +1,139 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import child_process from "child_process";
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
6
|
-
import chalk from 'chalk';
|
|
7
|
-
import chalkAnimation from 'chalk-animation';
|
|
8
|
-
import inquirer from 'inquirer';
|
|
9
|
-
import { createSpinner } from 'nanospinner';
|
|
10
|
-
import figlet from 'figlet';
|
|
11
|
-
import gradient from 'gradient-string';
|
|
12
|
-
|
|
13
|
-
let appName = process.argv[2];
|
|
14
|
-
const currentDirectory = process.cwd();
|
|
15
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
-
// git repository
|
|
17
|
-
const mernGitRepo = "https://github.com/Om-jannu/mern-template.git";
|
|
18
|
-
|
|
19
|
-
//sleep function
|
|
20
|
-
const sleep = (ms = 1000) => new Promise((r) => setTimeout(r, ms));
|
|
21
|
-
const installMyPackage = async() =>{
|
|
22
|
-
child_process.execSync('npm i create-fs-app -g');
|
|
23
|
-
}
|
|
24
|
-
// welcome function
|
|
25
|
-
const welcome = async () => {
|
|
26
|
-
const msg = "create-fs-app";
|
|
27
|
-
const welcomeMsg = figlet(msg, (err, data) => {
|
|
28
|
-
console.log(gradient.pastel.multiline(data));
|
|
29
|
-
})
|
|
30
|
-
welcomeMsg;
|
|
31
|
-
await sleep();
|
|
32
|
-
console.log(`
|
|
33
|
-
I am your personal FullStack template generator
|
|
34
|
-
I can create Full Stack Templates for you ${chalk.green('in seconds')}😉
|
|
35
|
-
Let's get started...
|
|
36
|
-
`);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// qns function
|
|
40
|
-
const askFsName = async () => {
|
|
41
|
-
const answers = await inquirer.prompt({
|
|
42
|
-
name: "fs_app",
|
|
43
|
-
type: 'list',
|
|
44
|
-
message: 'Which FullStack App do you want to build?',
|
|
45
|
-
choices: [
|
|
46
|
-
'MERN app',
|
|
47
|
-
'MEAN app',
|
|
48
|
-
'MEVN app',
|
|
49
|
-
],
|
|
50
|
-
});
|
|
51
|
-
return handleAnswer(answers.fs_app);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
//completion screen
|
|
55
|
-
const completion = async () => {
|
|
56
|
-
const completion_msg = chalkAnimation.rainbow(
|
|
57
|
-
'\nSuccesfully created your Full Stack Template'
|
|
58
|
-
);
|
|
59
|
-
await sleep();
|
|
60
|
-
completion_msg.stop();
|
|
61
|
-
console.log(chalk.bold.yellow('To access your folder :'));
|
|
62
|
-
console.log(chalk.bold.blue(`cd ${(appName=='.')?currentDirectory:appName}`));
|
|
63
|
-
console.log(chalk.bold.blue('code .'));
|
|
64
|
-
console.log(chalk.bold.yellow(`\nNOTE : ${chalk.bold.blue('code .')} is for opening folder in ${chalk.bold.blue('vs-code')} for different IDE use different Keyword`));
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// answer handler
|
|
68
|
-
const handleAnswer = async (fs_app) => {
|
|
69
|
-
const spinner = createSpinner(chalk.bold.green('Creating your Project Structure...')).start();
|
|
70
|
-
await sleep();
|
|
71
|
-
spinner.stop();
|
|
72
|
-
if (fs_app == 'MERN app') {
|
|
73
|
-
console.log(chalk.bold.bgGreen("\nBuilding MERN structure"));
|
|
74
|
-
BuildStructure(fs_app,mernGitRepo);
|
|
75
|
-
await sleep();
|
|
76
|
-
completion();
|
|
77
|
-
}
|
|
78
|
-
if (fs_app == 'MEAN app') {
|
|
79
|
-
console.log("\nNot yet started");
|
|
80
|
-
// completion();
|
|
81
|
-
}
|
|
82
|
-
if (fs_app == 'MEVN app') {
|
|
83
|
-
console.log("\nNot yet started");
|
|
84
|
-
// completion();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// function to clone mern repository
|
|
89
|
-
const BuildStructure = async(selected_app,repoUrl) => {
|
|
90
|
-
|
|
91
|
-
// function to create a folder
|
|
92
|
-
async function createFolder(folderName,selected_app) {
|
|
93
|
-
try {
|
|
94
|
-
if (!fs.existsSync(folderName)) {
|
|
95
|
-
fs.mkdirSync(folderName);
|
|
96
|
-
console.log(chalk.bold.green(`Creating a ${selected_app} in ~/${folderName}`));
|
|
97
|
-
} else {
|
|
98
|
-
console.log(chalk.italic.red(`Folder ${folderName} already exists.`));
|
|
99
|
-
console.log(chalk.bold.yellow(`Try : cd ${folderName} && npx create-fs-app .`));
|
|
100
|
-
process.exit(1);
|
|
101
|
-
}
|
|
102
|
-
} catch (err) {
|
|
103
|
-
console.error(chalk.italic.red(`error creting folder ${err}`));
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// function to clone a repositoy
|
|
108
|
-
const cloneRepository = async(dirName, custdir, repo) => {
|
|
109
|
-
try {
|
|
110
|
-
child_process.execSync(`git clone ${repo} ${dirName}`, { stdio: 'inherit' });
|
|
111
|
-
console.log(chalk.bold.green('\nRepository cloned successfully to ' + custdir));
|
|
112
|
-
} catch (err) {
|
|
113
|
-
console.error(chalk.italic.red('Error cloning repository:', err));
|
|
114
|
-
process.exit(1);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (!appName) {
|
|
119
|
-
console.error(chalk.italic.red('Error: Please provide a directory name'));
|
|
120
|
-
process.exit(1);
|
|
121
|
-
}
|
|
122
|
-
else if (appName == ".") {
|
|
123
|
-
cloneRepository('.', currentDirectory, repoUrl);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
|
|
127
|
-
await
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
console.log(chalk.italic.red("
|
|
134
|
-
console.log(chalk.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
await
|
|
139
|
-
await welcome();
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import child_process from "child_process";
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import chalkAnimation from 'chalk-animation';
|
|
8
|
+
import inquirer from 'inquirer';
|
|
9
|
+
import { createSpinner } from 'nanospinner';
|
|
10
|
+
import figlet from 'figlet';
|
|
11
|
+
import gradient from 'gradient-string';
|
|
12
|
+
|
|
13
|
+
let appName = process.argv[2];
|
|
14
|
+
const currentDirectory = process.cwd();
|
|
15
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
+
// git repository
|
|
17
|
+
const mernGitRepo = "https://github.com/Om-jannu/mern-template.git";
|
|
18
|
+
|
|
19
|
+
//sleep function
|
|
20
|
+
const sleep = (ms = 1000) => new Promise((r) => setTimeout(r, ms));
|
|
21
|
+
const installMyPackage = async() =>{
|
|
22
|
+
child_process.execSync('npm i create-fs-app -g');
|
|
23
|
+
}
|
|
24
|
+
// welcome function
|
|
25
|
+
const welcome = async () => {
|
|
26
|
+
const msg = "create-fs-app";
|
|
27
|
+
const welcomeMsg = figlet(msg, (err, data) => {
|
|
28
|
+
console.log(gradient.pastel.multiline(data));
|
|
29
|
+
})
|
|
30
|
+
welcomeMsg;
|
|
31
|
+
await sleep();
|
|
32
|
+
console.log(`
|
|
33
|
+
I am your personal FullStack template generator
|
|
34
|
+
I can create Full Stack Templates for you ${chalk.green('in seconds')}😉
|
|
35
|
+
Let's get started...
|
|
36
|
+
`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// qns function
|
|
40
|
+
const askFsName = async () => {
|
|
41
|
+
const answers = await inquirer.prompt({
|
|
42
|
+
name: "fs_app",
|
|
43
|
+
type: 'list',
|
|
44
|
+
message: 'Which FullStack App do you want to build?',
|
|
45
|
+
choices: [
|
|
46
|
+
'MERN app',
|
|
47
|
+
'MEAN app',
|
|
48
|
+
'MEVN app',
|
|
49
|
+
],
|
|
50
|
+
});
|
|
51
|
+
return handleAnswer(answers.fs_app);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//completion screen
|
|
55
|
+
const completion = async () => {
|
|
56
|
+
const completion_msg = chalkAnimation.rainbow(
|
|
57
|
+
'\nSuccesfully created your Full Stack Template'
|
|
58
|
+
);
|
|
59
|
+
await sleep();
|
|
60
|
+
completion_msg.stop();
|
|
61
|
+
console.log(chalk.bold.yellow('To access your folder :'));
|
|
62
|
+
console.log(chalk.bold.blue(`cd ${(appName=='.')?currentDirectory:appName}`));
|
|
63
|
+
console.log(chalk.bold.blue('code .'));
|
|
64
|
+
console.log(chalk.bold.yellow(`\nNOTE : ${chalk.bold.blue('code .')} is for opening folder in ${chalk.bold.blue('vs-code')} for different IDE use different Keyword`));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// answer handler
|
|
68
|
+
const handleAnswer = async (fs_app) => {
|
|
69
|
+
const spinner = createSpinner(chalk.bold.green('Creating your Project Structure...')).start();
|
|
70
|
+
await sleep();
|
|
71
|
+
spinner.stop();
|
|
72
|
+
if (fs_app == 'MERN app') {
|
|
73
|
+
console.log(chalk.bold.bgGreen("\nBuilding MERN structure"));
|
|
74
|
+
BuildStructure(fs_app,mernGitRepo);
|
|
75
|
+
await sleep();
|
|
76
|
+
completion();
|
|
77
|
+
}
|
|
78
|
+
if (fs_app == 'MEAN app') {
|
|
79
|
+
console.log("\nNot yet started");
|
|
80
|
+
// completion();
|
|
81
|
+
}
|
|
82
|
+
if (fs_app == 'MEVN app') {
|
|
83
|
+
console.log("\nNot yet started");
|
|
84
|
+
// completion();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// function to clone mern repository
|
|
89
|
+
const BuildStructure = async(selected_app,repoUrl) => {
|
|
90
|
+
|
|
91
|
+
// function to create a folder
|
|
92
|
+
async function createFolder(folderName,selected_app) {
|
|
93
|
+
try {
|
|
94
|
+
if (!fs.existsSync(folderName)) {
|
|
95
|
+
fs.mkdirSync(folderName);
|
|
96
|
+
console.log(chalk.bold.green(`Creating a ${selected_app} in ~/${folderName}`));
|
|
97
|
+
} else {
|
|
98
|
+
console.log(chalk.italic.red(`Folder ${folderName} already exists.`));
|
|
99
|
+
console.log(chalk.bold.yellow(`Try : cd ${folderName} && npx create-fs-app .`));
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
} catch (err) {
|
|
103
|
+
console.error(chalk.italic.red(`error creting folder ${err}`));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// function to clone a repositoy
|
|
108
|
+
const cloneRepository = async(dirName, custdir, repo) => {
|
|
109
|
+
try {
|
|
110
|
+
child_process.execSync(`git clone ${repo} ${dirName}`, { stdio: 'inherit' });
|
|
111
|
+
console.log(chalk.bold.green('\nRepository cloned successfully to ' + custdir));
|
|
112
|
+
} catch (err) {
|
|
113
|
+
console.error(chalk.italic.red('Error cloning repository:', err));
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (!appName) {
|
|
119
|
+
console.error(chalk.italic.red('Error: Please provide a directory name'));
|
|
120
|
+
process.exit(1);
|
|
121
|
+
}
|
|
122
|
+
else if (appName == ".") {
|
|
123
|
+
cloneRepository('.', currentDirectory, repoUrl);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
await createFolder(appName,selected_app);
|
|
127
|
+
await cloneRepository(appName,currentDirectory,repoUrl);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (process.argv.length > 3) {
|
|
132
|
+
console.log(chalk.italic.red("Error: Please provide a valid directory name"));
|
|
133
|
+
console.log(chalk.italic.red("Note: directory name should not contain spaces"));
|
|
134
|
+
console.log(chalk.bold.yellow("Try : npx build-mern-app app_name"));
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
137
|
+
await installMyPackage();
|
|
138
|
+
await welcome();
|
|
140
139
|
await askFsName();
|
package/package.json
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "create-fs-app",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "A command line tool to create Full Stack templates",
|
|
5
|
-
"main": "./create-fs-app",
|
|
6
|
-
"bin": "./create-fs-app.js",
|
|
7
|
-
"keywords": [
|
|
8
|
-
"full Stack",
|
|
9
|
-
"full",
|
|
10
|
-
"Stack",
|
|
11
|
-
"mern",
|
|
12
|
-
"mean",
|
|
13
|
-
"react",
|
|
14
|
-
"express",
|
|
15
|
-
"mongodb",
|
|
16
|
-
"mongo"
|
|
17
|
-
],
|
|
18
|
-
"repository": {
|
|
19
|
-
"type": "git",
|
|
20
|
-
"url": "https://github.com/Om-jannu/create-fs-app.git"
|
|
21
|
-
},
|
|
22
|
-
"type": "module",
|
|
23
|
-
"author": "Om Jannu",
|
|
24
|
-
"license": "ISC",
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"chalk": "^5.2.0",
|
|
27
|
-
"chalk-animation": "^2.0.3",
|
|
28
|
-
"figlet": "^1.5.2",
|
|
29
|
-
"gradient-string": "^2.0.2",
|
|
30
|
-
"inquirer": "^9.1.4",
|
|
31
|
-
"nanospinner": "^1.1.0"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "create-fs-app",
|
|
3
|
+
"version": "1.1.8",
|
|
4
|
+
"description": "A command line tool to create Full Stack templates",
|
|
5
|
+
"main": "./create-fs-app",
|
|
6
|
+
"bin": "./create-fs-app.js",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"full Stack",
|
|
9
|
+
"full",
|
|
10
|
+
"Stack",
|
|
11
|
+
"mern",
|
|
12
|
+
"mean",
|
|
13
|
+
"react",
|
|
14
|
+
"express",
|
|
15
|
+
"mongodb",
|
|
16
|
+
"mongo"
|
|
17
|
+
],
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/Om-jannu/create-fs-app.git"
|
|
21
|
+
},
|
|
22
|
+
"type": "module",
|
|
23
|
+
"author": "Om Jannu",
|
|
24
|
+
"license": "ISC",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"chalk": "^5.2.0",
|
|
27
|
+
"chalk-animation": "^2.0.3",
|
|
28
|
+
"figlet": "^1.5.2",
|
|
29
|
+
"gradient-string": "^2.0.2",
|
|
30
|
+
"inquirer": "^9.1.4",
|
|
31
|
+
"nanospinner": "^1.1.0"
|
|
32
|
+
}
|
|
33
|
+
}
|