create-fs-app 1.1.8 → 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.
@@ -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
@@ -1,8 +1,57 @@
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
+ ![PRs Welcome](https://img.shields.io/badge/PRs-welcome-green.svg)
2
+ <img src="./assets/logo.png">
3
+ Create Full Stack apps with no build configuration.
4
+
5
+ - [Creating an App](#creating-an-app) – How to create a new app.
6
+ Create fs App works on macOS, Windows, and Linux.<br>
7
+ If something doesn’t work, please [file an issue](https://github.com/Om-jannu/create-fs-app/issues/new).<br>
8
+
9
+ ## Quick Overview
10
+ ```sh
11
+ npx create-fs-app my-app
12
+ cd my-app
13
+ ```
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
+
16
+ <p align="center">
17
+ <img src="./assets/s1.png">
18
+ </p>
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.
Binary file
package/assets/s1.png ADDED
Binary file
package/create-fs-app.js CHANGED
@@ -1,139 +1,181 @@
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();
139
- await askFsName();
1
+ import fs from 'fs';
2
+ import child_process from 'child_process';
3
+ import path from 'path';
4
+ import chalk from 'chalk';
5
+ import chalkAnimation from 'chalk-animation';
6
+ import inquirer from 'inquirer';
7
+ import { createSpinner } from 'nanospinner';
8
+ import figlet from 'figlet';
9
+ import gradient from 'gradient-string';
10
+ import ora from 'ora';
11
+ import prompts from 'prompts';
12
+
13
+ const currentDirectory = process.cwd();
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
49
+ const welcome = async () => {
50
+ const msg = 'create-fs-app';
51
+ const welcomeMsg = figlet(msg, (err, data) => {
52
+ console.log(gradient.pastel.multiline(data));
53
+ });
54
+ welcomeMsg;
55
+ await sleep();
56
+ console.log(`
57
+ I am your personal FullStack template generator
58
+ I can create Full Stack Templates for you ${chalk.green('in seconds')}😉
59
+ Let's get started...
60
+ `);
61
+ };
62
+
63
+ // Question function
64
+ const askFsName = async () => {
65
+ const answers = await inquirer.prompt({
66
+ name: 'fs_app',
67
+ type: 'list',
68
+ message: 'Which FullStack App do you want to build?',
69
+ choices: ['MERN app', 'MEAN app', 'MEVN app'],
70
+ });
71
+ return handleAnswer(answers.fs_app);
72
+ };
73
+
74
+ // Completion screen
75
+ const completion = async (appName) => {
76
+ const completion_msg = chalkAnimation.rainbow(
77
+ '\nSuccessfully created your Full Stack Template'
78
+ );
79
+ await sleep();
80
+ completion_msg.stop();
81
+ console.log(chalk.bold.yellow('To access your folder :'));
82
+ console.log(chalk.bold.blue(`cd ${appName === '.' ? currentDirectory : appName}`));
83
+ console.log(chalk.bold.blue('code .'));
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`));
85
+ };
86
+
87
+ // Answer handler
88
+ const handleAnswer = async (fs_app) => {
89
+ const spinner = createSpinner(chalk.bold.green('Creating your Project Structure...')).start();
90
+ await sleep();
91
+ spinner.stop();
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);
119
+ }
120
+ };
121
+
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
+ };
139
+
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);
147
+ }
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);
157
+ }
158
+ } catch (error) {
159
+ throw error;
160
+ }
161
+ };
162
+
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'));
169
+ process.exit(1);
170
+ }
171
+
172
+ // await installMyPackage();
173
+ await welcome();
174
+ await askFsName();
175
+ } catch (error) {
176
+ console.error(chalk.red('An error occurred:', error.message));
177
+ process.exit(1);
178
+ }
179
+ };
180
+
181
+ run();
package/package.json CHANGED
@@ -1,33 +1,35 @@
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
- }
1
+ {
2
+ "name": "create-fs-app",
3
+ "version": "1.1.10",
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
+ "ora": "^8.0.1",
33
+ "prompts": "^2.4.2"
34
+ }
35
+ }