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