create-fs-app 1.1.9 → 1.1.10
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/.github/workflows/npm-publish-github-packages.yml +36 -0
- package/README.md +39 -5
- package/SECURITY.md +21 -0
- package/assets/logo.png +0 -0
- package/assets/s1.png +0 -0
- package/create-fs-app.js +129 -87
- package/package.json +4 -2
- package/assets/s2.png +0 -0
- package/package-lock.json +0 -1408
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
|
3
|
+
|
|
4
|
+
name: Node.js Package
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
release:
|
|
8
|
+
types: [created]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v3
|
|
15
|
+
- uses: actions/setup-node@v3
|
|
16
|
+
with:
|
|
17
|
+
node-version: 16
|
|
18
|
+
- run: npm ci
|
|
19
|
+
- run: npm test
|
|
20
|
+
|
|
21
|
+
publish-gpr:
|
|
22
|
+
needs: build
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
permissions:
|
|
25
|
+
contents: read
|
|
26
|
+
packages: write
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v3
|
|
29
|
+
- uses: actions/setup-node@v3
|
|
30
|
+
with:
|
|
31
|
+
node-version: 16
|
|
32
|
+
registry-url: https://npm.pkg.github.com/
|
|
33
|
+
- run: npm ci
|
|
34
|
+
- run: npm publish
|
|
35
|
+
env:
|
|
36
|
+
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
package/README.md
CHANGED
|
@@ -13,11 +13,45 @@ cd my-app
|
|
|
13
13
|
```
|
|
14
14
|
If you've previously installed `create-fs-app` globally via `npm install -g create-fs-app`, we recommend you uninstall the package using `npm uninstall -g create-fs-app` or `yarn global remove create-fs-app` to ensure that npx always uses the latest version.
|
|
15
15
|
|
|
16
|
-
_([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))_
|
|
17
|
-
|
|
18
16
|
<p align="center">
|
|
19
17
|
<img src="./assets/s1.png">
|
|
20
18
|
</p>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
|
|
20
|
+
### Get Started Immediately
|
|
21
|
+
|
|
22
|
+
You **don’t** need to install or configure tools like webpack or Babel.<br>
|
|
23
|
+
They are preconfigured and hidden so that you can focus on the code.
|
|
24
|
+
|
|
25
|
+
Create a project, and you’re good to go.
|
|
26
|
+
|
|
27
|
+
# Creating an App
|
|
28
|
+
|
|
29
|
+
**You’ll need to have Node 14.0.0 or later version on your local development machine** (but it’s not required on the server). We recommend using the latest LTS version. You can use [nvm](https://github.com/creationix/nvm#installation) (macOS/Linux) or [nvm-windows](https://github.com/coreybutler/nvm-windows#node-version-manager-nvm-for-windows) to switch Node versions between different projects.
|
|
30
|
+
|
|
31
|
+
To create a new app, you may choose one of the following methods:
|
|
32
|
+
|
|
33
|
+
### npx
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
npx create-fs-app my-app
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
_([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))_
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Yarn
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
yarn create-fs-app my-app
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
_[`yarn create <starter-kit-package>`](https://yarnpkg.com/lang/en/docs/cli/create/) is available in Yarn 0.25+_
|
|
49
|
+
|
|
50
|
+
It will create a directory called `my-app` inside the current folder.<br>
|
|
51
|
+
|
|
52
|
+
No configuration or complicated folder structures, only the files you need to build your app.<br>
|
|
53
|
+
Once the installation is done, you can open your project folder:
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
cd my-app
|
|
57
|
+
```
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
Use this section to tell people about which versions of your project are
|
|
6
|
+
currently being supported with security updates.
|
|
7
|
+
|
|
8
|
+
| Version | Supported |
|
|
9
|
+
| ------- | ------------------ |
|
|
10
|
+
| 5.1.x | :white_check_mark: |
|
|
11
|
+
| 5.0.x | :x: |
|
|
12
|
+
| 4.0.x | :white_check_mark: |
|
|
13
|
+
| < 4.0 | :x: |
|
|
14
|
+
|
|
15
|
+
## Reporting a Vulnerability
|
|
16
|
+
|
|
17
|
+
Use this section to tell people how to report a vulnerability.
|
|
18
|
+
|
|
19
|
+
Tell them where to go, how often they can expect to get an update on a
|
|
20
|
+
reported vulnerability, what to expect if the vulnerability is accepted or
|
|
21
|
+
declined, etc.
|
package/assets/logo.png
CHANGED
|
Binary file
|
package/assets/s1.png
CHANGED
|
Binary file
|
package/create-fs-app.js
CHANGED
|
@@ -1,32 +1,56 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
import fs from 'fs';
|
|
3
|
-
import child_process from
|
|
2
|
+
import child_process from 'child_process';
|
|
4
3
|
import path from 'path';
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
6
4
|
import chalk from 'chalk';
|
|
7
5
|
import chalkAnimation from 'chalk-animation';
|
|
8
6
|
import inquirer from 'inquirer';
|
|
9
7
|
import { createSpinner } from 'nanospinner';
|
|
10
8
|
import figlet from 'figlet';
|
|
11
9
|
import gradient from 'gradient-string';
|
|
10
|
+
import ora from 'ora';
|
|
11
|
+
import prompts from 'prompts';
|
|
12
12
|
|
|
13
|
-
let appName = process.argv[2];
|
|
14
13
|
const currentDirectory = process.cwd();
|
|
15
|
-
|
|
16
|
-
//
|
|
17
|
-
const mernGitRepo =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
|
|
15
|
+
// Git repositories
|
|
16
|
+
const mernGitRepo = 'https://github.com/Om-jannu/mern-template.git';
|
|
17
|
+
const meanGitRepo = 'https://github.com/your-username/mean-template.git';
|
|
18
|
+
const mevnGitRepo = 'https://github.com/your-username/mevn-template.git';
|
|
19
|
+
|
|
20
|
+
// Sleep function
|
|
21
|
+
const sleep = (ms = 1000) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const installMyPackage = async () => {
|
|
25
|
+
const response = await prompts({
|
|
26
|
+
type: 'confirm',
|
|
27
|
+
name: 'confirm',
|
|
28
|
+
message: 'This script needs to install the create-fs-app package globally. Do you want to proceed?',
|
|
29
|
+
initial: false,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (response.confirm) {
|
|
33
|
+
const spinner = ora('Installing create-fs-app package...').start();
|
|
34
|
+
try {
|
|
35
|
+
child_process.execSync('npm i create-fs-app -g');
|
|
36
|
+
spinner.succeed('create-fs-app package installed successfully');
|
|
37
|
+
} catch (error) {
|
|
38
|
+
spinner.fail('Error installing create-fs-app package');
|
|
39
|
+
console.error(chalk.red('Error installing create-fs-app package:', error.message));
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
console.log(chalk.yellow('Package installation canceled. Exiting...'));
|
|
44
|
+
process.exit(0);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// Welcome function
|
|
25
49
|
const welcome = async () => {
|
|
26
|
-
const msg =
|
|
50
|
+
const msg = 'create-fs-app';
|
|
27
51
|
const welcomeMsg = figlet(msg, (err, data) => {
|
|
28
52
|
console.log(gradient.pastel.multiline(data));
|
|
29
|
-
})
|
|
53
|
+
});
|
|
30
54
|
welcomeMsg;
|
|
31
55
|
await sleep();
|
|
32
56
|
console.log(`
|
|
@@ -34,106 +58,124 @@ const welcome = async () => {
|
|
|
34
58
|
I can create Full Stack Templates for you ${chalk.green('in seconds')}😉
|
|
35
59
|
Let's get started...
|
|
36
60
|
`);
|
|
37
|
-
}
|
|
61
|
+
};
|
|
38
62
|
|
|
39
|
-
//
|
|
63
|
+
// Question function
|
|
40
64
|
const askFsName = async () => {
|
|
41
65
|
const answers = await inquirer.prompt({
|
|
42
|
-
name:
|
|
66
|
+
name: 'fs_app',
|
|
43
67
|
type: 'list',
|
|
44
68
|
message: 'Which FullStack App do you want to build?',
|
|
45
|
-
choices: [
|
|
46
|
-
'MERN app',
|
|
47
|
-
'MEAN app',
|
|
48
|
-
'MEVN app',
|
|
49
|
-
],
|
|
69
|
+
choices: ['MERN app', 'MEAN app', 'MEVN app'],
|
|
50
70
|
});
|
|
51
71
|
return handleAnswer(answers.fs_app);
|
|
52
|
-
}
|
|
72
|
+
};
|
|
53
73
|
|
|
54
|
-
//
|
|
55
|
-
const completion = async () => {
|
|
74
|
+
// Completion screen
|
|
75
|
+
const completion = async (appName) => {
|
|
56
76
|
const completion_msg = chalkAnimation.rainbow(
|
|
57
|
-
'\
|
|
77
|
+
'\nSuccessfully created your Full Stack Template'
|
|
58
78
|
);
|
|
59
79
|
await sleep();
|
|
60
80
|
completion_msg.stop();
|
|
61
81
|
console.log(chalk.bold.yellow('To access your folder :'));
|
|
62
|
-
console.log(chalk.bold.blue(`cd ${
|
|
82
|
+
console.log(chalk.bold.blue(`cd ${appName === '.' ? currentDirectory : appName}`));
|
|
63
83
|
console.log(chalk.bold.blue('code .'));
|
|
64
84
|
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
|
-
}
|
|
85
|
+
};
|
|
66
86
|
|
|
67
|
-
//
|
|
87
|
+
// Answer handler
|
|
68
88
|
const handleAnswer = async (fs_app) => {
|
|
69
89
|
const spinner = createSpinner(chalk.bold.green('Creating your Project Structure...')).start();
|
|
70
90
|
await sleep();
|
|
71
91
|
spinner.stop();
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
let repoUrl;
|
|
95
|
+
switch (fs_app) {
|
|
96
|
+
case 'MERN app':
|
|
97
|
+
console.log(chalk.bold.bgGreen('\nBuilding MERN structure'));
|
|
98
|
+
repoUrl = mernGitRepo;
|
|
99
|
+
break;
|
|
100
|
+
case 'MEAN app':
|
|
101
|
+
console.log(chalk.bold.bgBlue('\nBuilding MEAN structure'));
|
|
102
|
+
repoUrl = meanGitRepo;
|
|
103
|
+
break;
|
|
104
|
+
case 'MEVN app':
|
|
105
|
+
console.log(chalk.bold.bgMagenta('\nBuilding MEVN structure'));
|
|
106
|
+
repoUrl = mevnGitRepo;
|
|
107
|
+
break;
|
|
108
|
+
default:
|
|
109
|
+
console.error(chalk.red('Invalid choice. Please try again.'));
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const appName = process.argv[2] || '.';
|
|
114
|
+
await buildStructure(fs_app, repoUrl, appName);
|
|
115
|
+
await completion(appName);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
console.error(chalk.red('Error creating project structure:', error.message));
|
|
118
|
+
process.exit(1);
|
|
85
119
|
}
|
|
86
|
-
}
|
|
120
|
+
};
|
|
87
121
|
|
|
88
|
-
//
|
|
89
|
-
const
|
|
122
|
+
// Function to build the project structure
|
|
123
|
+
const buildStructure = async (selectedApp, repoUrl, appName) => {
|
|
124
|
+
try {
|
|
125
|
+
// Function to create a folder
|
|
126
|
+
const createFolder = async (folderName) => {
|
|
127
|
+
try {
|
|
128
|
+
if (!fs.existsSync(folderName)) {
|
|
129
|
+
fs.mkdirSync(folderName);
|
|
130
|
+
console.log(chalk.bold.green(`Creating a ${selectedApp} in ~/${folderName}`));
|
|
131
|
+
} else {
|
|
132
|
+
console.log(chalk.italic.red(`Folder ${folderName} already exists.`));
|
|
133
|
+
console.log(chalk.bold.yellow(`Try : cd ${folderName} && npx create-fs-app .`));
|
|
134
|
+
}
|
|
135
|
+
} catch (err) {
|
|
136
|
+
throw new Error(`Error creating folder ${err}`);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
90
139
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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);
|
|
140
|
+
// Function to clone a repository
|
|
141
|
+
const cloneRepository = async (dirName, custdir, repo) => {
|
|
142
|
+
try {
|
|
143
|
+
child_process.execSync(`git clone ${repo} ${dirName}`, { stdio: 'inherit' });
|
|
144
|
+
console.log(chalk.bold.green('\nRepository cloned successfully to ' + custdir));
|
|
145
|
+
} catch (err) {
|
|
146
|
+
throw new Error('Error cloning repository:', err);
|
|
101
147
|
}
|
|
102
|
-
}
|
|
103
|
-
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
if (!appName) {
|
|
151
|
+
throw new Error('Error: Please provide a directory name');
|
|
152
|
+
} else if (appName === '.') {
|
|
153
|
+
cloneRepository('.', currentDirectory, repoUrl);
|
|
154
|
+
} else {
|
|
155
|
+
await createFolder(appName);
|
|
156
|
+
await cloneRepository(appName, path.join(currentDirectory, appName), repoUrl);
|
|
104
157
|
}
|
|
158
|
+
} catch (error) {
|
|
159
|
+
throw error;
|
|
105
160
|
}
|
|
161
|
+
};
|
|
106
162
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
console.log(chalk.
|
|
112
|
-
|
|
113
|
-
console.error(chalk.italic.red('Error cloning repository:', err));
|
|
163
|
+
const run = async () => {
|
|
164
|
+
try {
|
|
165
|
+
if (process.argv.length > 3) {
|
|
166
|
+
console.log(chalk.italic.red('Error: Please provide a valid directory name'));
|
|
167
|
+
console.log(chalk.italic.red('Note: directory name should not contain spaces'));
|
|
168
|
+
console.log(chalk.bold.yellow('Try : npx create-fs-app app_name'));
|
|
114
169
|
process.exit(1);
|
|
115
170
|
}
|
|
116
|
-
}
|
|
117
171
|
|
|
118
|
-
|
|
119
|
-
|
|
172
|
+
// await installMyPackage();
|
|
173
|
+
await welcome();
|
|
174
|
+
await askFsName();
|
|
175
|
+
} catch (error) {
|
|
176
|
+
console.error(chalk.red('An error occurred:', error.message));
|
|
120
177
|
process.exit(1);
|
|
121
178
|
}
|
|
122
|
-
|
|
123
|
-
|
|
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();
|
|
139
|
-
await askFsName();
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
run();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-fs-app",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"description": "A command line tool to create Full Stack templates",
|
|
5
5
|
"main": "./create-fs-app",
|
|
6
6
|
"bin": "./create-fs-app.js",
|
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
"figlet": "^1.5.2",
|
|
29
29
|
"gradient-string": "^2.0.2",
|
|
30
30
|
"inquirer": "^9.1.4",
|
|
31
|
-
"nanospinner": "^1.1.0"
|
|
31
|
+
"nanospinner": "^1.1.0",
|
|
32
|
+
"ora": "^8.0.1",
|
|
33
|
+
"prompts": "^2.4.2"
|
|
32
34
|
}
|
|
33
35
|
}
|
package/assets/s2.png
DELETED
|
Binary file
|