create-jaypeehindang-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.
- package/index.js +79 -0
- package/package.json +22 -0
package/index.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
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/jp26198926/backend-boilerplate.git",
|
|
11
|
+
Backend: "https://github.com/jp26198926/backend-boilerplate.git",
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//asking question process
|
|
15
|
+
/*
|
|
16
|
+
1. Enter you project / folder name.
|
|
17
|
+
2. select type: [Frontend, Backend].
|
|
18
|
+
*/
|
|
19
|
+
const getProjectDetails = async () => {
|
|
20
|
+
const answer = await inquirer.prompt([
|
|
21
|
+
{
|
|
22
|
+
type: "input",
|
|
23
|
+
name: "projectName",
|
|
24
|
+
message: "Enter your project / folder name:",
|
|
25
|
+
validate: (input) => {
|
|
26
|
+
if (!input) return "Project name cannot be empty!";
|
|
27
|
+
return true;
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: "list",
|
|
32
|
+
name: "projectType",
|
|
33
|
+
message: "Select type:",
|
|
34
|
+
choices: ["Frontend", "Backend"],
|
|
35
|
+
},
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
return answer;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const startProcessing = async () => {
|
|
42
|
+
try {
|
|
43
|
+
const { projectName, projectType } = await getProjectDetails();
|
|
44
|
+
|
|
45
|
+
const targetPath = path.join(process.cwd(), projectName);
|
|
46
|
+
|
|
47
|
+
//check if targetPath exist
|
|
48
|
+
if (fs.existsSync(targetPath)) {
|
|
49
|
+
console.error(`Directory "${projectName}" already exist!`);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
//get the correct repo
|
|
54
|
+
const reporUrl = REPO_URL[projectType];
|
|
55
|
+
|
|
56
|
+
//print on the terminal
|
|
57
|
+
console.log(`Cloning the ${projectType} boilerplate repostiory...`);
|
|
58
|
+
execSync(`git clone ${reporUrl} "${targetPath}"`, { stdio: "inherit" });
|
|
59
|
+
|
|
60
|
+
//remove .git folder
|
|
61
|
+
console.log(`Removing .git folder from the cloned repository...`);
|
|
62
|
+
fs.rmSync(path.join(targetPath, ".git"), { recursive: true, force: true });
|
|
63
|
+
|
|
64
|
+
//installing dependency
|
|
65
|
+
console.log("Installing dependencies...");
|
|
66
|
+
execSync("npm install", { cwd: targetPath, stdio: "inherit" });
|
|
67
|
+
|
|
68
|
+
//freebies messages
|
|
69
|
+
console.log("Setup Complete, Happy Hacking!");
|
|
70
|
+
console.log("Run the following commands to start your App.");
|
|
71
|
+
console.log(` cd ${projectName}`);
|
|
72
|
+
console.log(` npm run dev`);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error("Failed to setup the project: ", error);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
startProcessing();
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-jaypeehindang-app",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Create Boilerplate 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": "Jaypee Hindang",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"inquirer": "^13.2.2"
|
|
17
|
+
},
|
|
18
|
+
"bin": "./index.js",
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
}
|
|
22
|
+
}
|