create-rappmicco-app 1.0.0

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.
Files changed (2) hide show
  1. package/index.js +83 -0
  2. package/package.json +22 -0
package/index.js ADDED
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execSync } from "node:child_process";
4
+ import fs from "node:fs";
5
+ import path from "node:path";
6
+ import inquirer from "inquirer";
7
+
8
+ //repository Object
9
+ const REPO_URL = {
10
+ Frontend: "https://github.com/RappMicco/backend-boilerplate.git",
11
+ Backend: "https://github.com/RappMicco/backend-boilerplate.git",
12
+ };
13
+
14
+ //asking question process
15
+ /*
16
+
17
+ 1. What is you project name/ folder name?
18
+ 2. Select type: [Frontend, Backend]
19
+
20
+ */
21
+ const getProjectDetails = async () => {
22
+ const answer = await inquirer.prompt([
23
+ {
24
+ type: "input",
25
+ name: "projectName",
26
+ message: "Enter your project / folder name:",
27
+ validate: (input) => {
28
+ if(!input) return "Project namr cannot be empty!";
29
+ return true;
30
+ },
31
+ },
32
+ {
33
+
34
+ type: "list",
35
+ name: "projectType",
36
+ message: "Select type:",
37
+ choices: ["Frontend", "Backend"],
38
+ },
39
+ ]);
40
+
41
+ return answer;
42
+ };
43
+
44
+
45
+ const startProcessing = async () => {
46
+ try {
47
+ const { projectName, projectType } = await getProjectDetails();
48
+
49
+ const targetPath = path.join(process.cwd(). projectName);
50
+
51
+ //check if targetPAth exist
52
+ if (fs.existsSync(targetPath)) {
53
+ console.error(`Directory "${projectName}" already exist!`);
54
+ process.exit(1);
55
+ }
56
+
57
+ //get correct repo
58
+ const repoUrl = REPO_URL[projectType];
59
+
60
+ //print on the terminal
61
+ console.log(`Cloning the ${projectType} boilerplate repository...`);
62
+ execSync(`git clone ${repoUrl} "${targetPath}"`, {stdio: "inherit"});
63
+
64
+ //remove .git folder
65
+ console.log(`Removing .git folder from the cloned repository...`);
66
+ fs.rmSync(path.join(targetPath, ".git"), { recursive: true, force: true });
67
+
68
+ //installing dependencies
69
+ console.log("Installing dependencies...");
70
+ execSync("npm install", { cd: targetPath, stdio: "inherit"});
71
+
72
+ //freebies messages
73
+ console.log("Setup Complete, Good Job Rapp!");
74
+ console.log("Run the following commands to start you App");
75
+ console.log(` cd ${projectName}`);
76
+ console.log(` npm run dev`);
77
+ } catch (error) {
78
+ console.error("Failed to setup the project: ", error);
79
+ process.exit(1);
80
+ }
81
+ };
82
+
83
+ startProcessing();
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "create-rappmicco-app",
3
+ "version": "1.0.0",
4
+ "description": "Create Boiler Apps",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1"
9
+ },
10
+ "keywords": [
11
+ "boilerplate"
12
+ ],
13
+ "author": "Rapp Micco Rizo",
14
+ "license": "ISC",
15
+ "dependencies": {
16
+ "inquirer": "^13.2.2"
17
+ },
18
+ "bin": "./index.js",
19
+ "publishConfig": {
20
+ "access": "public"
21
+ }
22
+ }