@thebros/create-benjamin 1.0.9 → 1.0.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.
Files changed (3) hide show
  1. package/.env +1 -1
  2. package/bin/index.js +27 -29
  3. package/package.json +5 -5
package/.env CHANGED
@@ -1 +1 @@
1
- OPENAI_API_KEY=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
1
+ OPENAI_API_KEY=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
package/bin/index.js CHANGED
@@ -8,27 +8,32 @@ import inquirer from "inquirer";
8
8
  import ora from "ora";
9
9
  import OpenAI from "openai";
10
10
 
11
- let apiKey = process.env.OPENAI_API_KEY;
12
-
13
- if (!apiKey) {
14
- const answer = await inquirer.prompt([
15
- {
16
- type: "password",
17
- name: "key",
18
- message: "Enter OpenAI API Key (or press enter to skip):",
19
- },
20
- ]);
11
+ async function main() {
12
+ console.log(chalk.cyan("\nšŸ¤– Create Benjamin AI Generator\n"));
21
13
 
22
- apiKey = answer.key;
14
+ // ===== GET API KEY =====
15
+ let apiKey = process.env.OPENAI_API_KEY;
23
16
 
24
17
  if (!apiKey) {
25
- console.log("āš ļø Running in template mode (no AI)");
26
- process.exit(0);
18
+ const answer = await inquirer.prompt([
19
+ {
20
+ type: "password",
21
+ name: "key",
22
+ message: "Enter OpenAI API Key:",
23
+ },
24
+ ]);
25
+
26
+ apiKey = answer.key;
27
+
28
+ if (!apiKey) {
29
+ console.log("āŒ No API key provided");
30
+ process.exit(1);
31
+ }
27
32
  }
28
- }
29
- async function main() {
30
- console.log(chalk.cyan("\nšŸ¤– Create Benjamin AI Project Generator\n"));
31
33
 
34
+ const openai = new OpenAI({ apiKey });
35
+
36
+ // ===== USER INPUT =====
32
37
  const answers = await inquirer.prompt([
33
38
  {
34
39
  type: "input",
@@ -39,7 +44,7 @@ async function main() {
39
44
  {
40
45
  type: "input",
41
46
  name: "description",
42
- message: "Describe your project (be detailed):",
47
+ message: "Describe your project:",
43
48
  },
44
49
  ]);
45
50
 
@@ -55,22 +60,15 @@ async function main() {
55
60
 
56
61
  const spinner = ora("Generating project with AI...").start();
57
62
 
58
- // ===== AI PROMPT =====
63
+ // ===== PROMPT =====
59
64
  const prompt = `
60
65
  You are a senior full-stack developer.
61
66
 
62
- Generate a complete project structure and code for this app:
67
+ Generate a full project for:
63
68
 
64
- Project: ${answers.description}
69
+ ${answers.description}
65
70
 
66
- Rules:
67
- - Must be Node.js backend + React frontend if needed
68
- - Use Express for backend
69
- - Use React + Vite for frontend
70
- - Use MySQL if database needed
71
- - Include folder structure
72
- - Include working code files
73
- - Return ONLY JSON in this format:
71
+ Return ONLY valid JSON:
74
72
 
75
73
  {
76
74
  "files": {
@@ -79,6 +77,7 @@ Rules:
79
77
  }
80
78
  `;
81
79
 
80
+ // ===== AI CALL =====
82
81
  const response = await openai.chat.completions.create({
83
82
  model: "gpt-4o-mini",
84
83
  messages: [{ role: "user", content: prompt }],
@@ -87,7 +86,6 @@ Rules:
87
86
 
88
87
  let text = response.choices[0].message.content;
89
88
 
90
- // Clean AI response
91
89
  text = text.replace(/```json/g, "").replace(/```/g, "");
92
90
 
93
91
  let project;
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@thebros/create-benjamin",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "create-benjamin": "./bin/index.js"
7
7
  },
8
8
  "dependencies": {
9
- "chalk": "^5.3.0",
9
+ "chalk": "^5.6.2",
10
10
  "dotenv": "^17.4.2",
11
11
  "execa": "^8.0.1",
12
12
  "figlet": "^1.7.0",
13
- "fs-extra": "^11.2.0",
14
- "inquirer": "^9.2.15",
13
+ "fs-extra": "^11.3.5",
14
+ "inquirer": "^9.3.8",
15
15
  "openai": "^6.39.0",
16
- "ora": "^8.0.1"
16
+ "ora": "^8.2.0"
17
17
  },
18
18
  "publishConfig": {
19
19
  "access": "public"