create-jinmankn-app 1.0.3 → 1.0.5

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/bin/index.js +79 -19
  2. package/package.json +1 -1
package/bin/index.js CHANGED
@@ -15,20 +15,42 @@ if (!fs.existsSync(templatesDir)) {
15
15
  process.exit(1);
16
16
  }
17
17
 
18
- // Get templates automatically
18
+ // Template metadata
19
+ const templateChoices = [
20
+ {
21
+ name: "🏥 Hospital Management System",
22
+ value: "hospital-faisal"
23
+ },
24
+ {
25
+ name: "🗳️ BLUEPRINT",
26
+ value: "blueprint"
27
+ },
28
+ {
29
+ name: "📦 Student Fee Management System",
30
+ value: "chom"
31
+ }
32
+ ];
33
+
34
+ // Get actual template folders
19
35
  const templates = fs
20
36
  .readdirSync(templatesDir)
21
37
  .filter((dir) =>
22
38
  fs.lstatSync(path.join(templatesDir, dir)).isDirectory()
23
39
  );
24
40
 
41
+ // Filter only existing templates
42
+ const availableTemplates = templateChoices.filter((template) =>
43
+ templates.includes(template.value)
44
+ );
45
+
25
46
  // No templates check
26
- if (templates.length === 0) {
47
+ if (availableTemplates.length === 0) {
27
48
  console.log(chalk.red("No templates found!"));
28
49
  process.exit(1);
29
50
  }
30
51
 
31
52
  async function createProject() {
53
+
32
54
  // Prompt user
33
55
  const answers = await inquirer.prompt([
34
56
  {
@@ -38,12 +60,9 @@ async function createProject() {
38
60
  },
39
61
  {
40
62
  type: "list",
41
- name: "template",
63
+ name: "templates",
42
64
  message: "Choose a template:",
43
- choices: templates.map((t) => ({
44
- name: t,
45
- value: t
46
- }))
65
+ choices: availableTemplates
47
66
  }
48
67
  ]);
49
68
 
@@ -59,22 +78,33 @@ async function createProject() {
59
78
 
60
79
  // Prevent overwrite
61
80
  if (fs.existsSync(projectPath)) {
62
- console.log(chalk.red("Folder already exists!"));
81
+ console.log(
82
+ chalk.red("Folder already exists!")
83
+ );
84
+
63
85
  process.exit(1);
64
86
  }
65
87
 
66
88
  // Spinner
67
- const spinner = ora("Creating project...").start();
89
+ const spinner = ora(
90
+ "Creating project..."
91
+ ).start();
68
92
 
69
93
  try {
94
+
70
95
  // Copy template
71
96
  await fs.copy(templatePath, projectPath);
72
97
 
73
98
  // Install frontend dependencies
74
- const frontendPath = path.join(projectPath, "frontend");
99
+ const frontendPath = path.join(
100
+ projectPath,
101
+ "frontend"
102
+ );
75
103
 
76
104
  if (fs.existsSync(frontendPath)) {
77
- spinner.text = "Installing frontend dependencies...";
105
+
106
+ spinner.text =
107
+ "Installing frontend dependencies...";
78
108
 
79
109
  execSync("npm install", {
80
110
  cwd: frontendPath,
@@ -83,10 +113,15 @@ async function createProject() {
83
113
  }
84
114
 
85
115
  // Install backend dependencies
86
- const backendPath = path.join(projectPath, "backend");
116
+ const backendPath = path.join(
117
+ projectPath,
118
+ "backend"
119
+ );
87
120
 
88
121
  if (fs.existsSync(backendPath)) {
89
- spinner.text = "Installing backend dependencies...";
122
+
123
+ spinner.text =
124
+ "Installing backend dependencies...";
90
125
 
91
126
  execSync("npm install", {
92
127
  cwd: backendPath,
@@ -95,28 +130,53 @@ async function createProject() {
95
130
  }
96
131
 
97
132
  spinner.succeed(
98
- chalk.green("Project created successfully!")
133
+ chalk.green(
134
+ "Project created successfully!"
135
+ )
99
136
  );
100
137
 
101
138
  console.log("\n");
102
139
 
103
- console.log(chalk.cyan("Next steps:"));
140
+ console.log(
141
+ chalk.cyan("Next steps:")
142
+ );
104
143
 
105
144
  console.log(
106
- chalk.white(`cd ${answers.projectName}`)
145
+ chalk.white(
146
+ `cd ${answers.projectName}`
147
+ )
107
148
  );
108
149
 
150
+ console.log("");
151
+
109
152
  console.log(
110
- chalk.white("cd frontend && npm run dev")
153
+ chalk.yellow("Frontend:")
111
154
  );
112
155
 
113
156
  console.log(
114
- chalk.white("cd backend && npm run dev")
157
+ chalk.white(
158
+ "cd frontend && npm run dev"
159
+ )
160
+ );
161
+
162
+ console.log("");
163
+
164
+ console.log(
165
+ chalk.yellow("Backend:")
166
+ );
167
+
168
+ console.log(
169
+ chalk.white(
170
+ "cd backend && npm run dev"
171
+ )
115
172
  );
116
173
 
117
174
  } catch (err) {
175
+
118
176
  spinner.fail(
119
- chalk.red("Failed to create project")
177
+ chalk.red(
178
+ "Failed to create project"
179
+ )
120
180
  );
121
181
 
122
182
  console.log(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-jinmankn-app",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "bin": {
6
6
  "create-jinmankn-app": "./bin/index.js"