zobro-cli 1.1.1 → 1.1.3

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 +35 -26
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -2,14 +2,16 @@
2
2
 
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
- const yargs = require('yargs/yargs');
6
- const { hideBin } = require('yargs/helpers');
7
5
 
8
- // šŸ›”ļø SECURE: No hardcoded key. It pulls from your computer's system settings.
9
- const API_KEY = process.env.GEMINI_API_KEY;
6
+ // šŸ›”ļø SECURE: This pulls the key from your computer's hidden settings
10
7
 
8
+ const API_KEY = process.env.GEMINI_API_KEY;
9
+
10
+ if (!API_KEY) {
11
+ console.error('āŒ ERROR: API Key not found on this system.');
12
+ // ... rest of your error message
13
+ }
11
14
  async function generateProject(prompt, directoryName) {
12
- // Check if the key exists before running
13
15
  if (!API_KEY) {
14
16
  console.error('āŒ ERROR: API Key not found on this system.');
15
17
  console.log('šŸ‘‰ To fix this, run: setx GEMINI_API_KEY "your_real_key_here"');
@@ -17,7 +19,7 @@ async function generateProject(prompt, directoryName) {
17
19
  return;
18
20
  }
19
21
 
20
- const url = `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=${API_KEY}`;
22
+ const url = `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=${API_KEY}`;
21
23
 
22
24
  const newPrompt = `
23
25
  You are an expert software developer and project scaffolder.
@@ -26,7 +28,7 @@ Each object in the array must have two keys:
26
28
  1. "filename": (string) The full relative path for the file.
27
29
  2. "code": (string) The complete code for that file.
28
30
 
29
- Only return the raw JSON array, with no other text or markdown fences.
31
+ Only return the raw JSON array, with no other text, explanations, or markdown fences.
30
32
  User Prompt: "${prompt}"`;
31
33
 
32
34
  const body = { contents: [{ parts: [{ text: newPrompt }] }] };
@@ -43,15 +45,14 @@ User Prompt: "${prompt}"`;
43
45
  if (!response.ok) {
44
46
  const errorData = await response.json();
45
47
  console.error('āŒ API Error Details:', JSON.stringify(errorData.error, null, 2));
46
- throw new Error(`API request failed with status ${response.status}`);
48
+ return;
47
49
  }
48
50
 
49
51
  const data = await response.json();
50
52
  let responseText = data.candidates[0].content.parts[0].text;
51
53
 
52
- if (responseText.startsWith("```json")) {
53
- responseText = responseText.substring(7, responseText.length - 3).trim();
54
- }
54
+ // Clean up markdown if AI adds it
55
+ responseText = responseText.replace(/```json|```/g, "").trim();
55
56
 
56
57
  const files = JSON.parse(responseText);
57
58
  fs.mkdirSync(directoryName, { recursive: true });
@@ -64,24 +65,32 @@ User Prompt: "${prompt}"`;
64
65
  console.log(`āœ… Created: ${file.filename}`);
65
66
  }
66
67
 
67
- console.log(`\nšŸŽ‰ Done! Project is ready.`);
68
+ console.log(`\nšŸŽ‰ Done! Your project is ready in the folder: ${directoryName}`);
68
69
 
69
70
  } catch (error) {
70
71
  console.error('āŒ An error occurred:', error.message);
71
72
  }
72
73
  }
73
74
 
74
- yargs(hideBin(process.argv))
75
- .command(
76
- '$0 <prompt>',
77
- 'Generates a full project structure.',
78
- (yargs) => {
79
- return yargs
80
- .positional('prompt', { type: 'string' })
81
- .option('directory', { alias: 'd', type: 'string', demandOption: true });
82
- },
83
- (argv) => {
84
- generateProject(argv.prompt, argv.directory);
85
- }
86
- )
87
- .parse();
75
+ // Fixed Yargs setup to prevent ESM errors
76
+ async function startCLI() {
77
+ const yargs = (await import('yargs/yargs')).default;
78
+ const { hideBin } = await import('yargs/helpers');
79
+
80
+ yargs(hideBin(process.argv))
81
+ .command(
82
+ '$0 <prompt>',
83
+ 'Generates a full project structure.',
84
+ (yargs) => {
85
+ return yargs
86
+ .positional('prompt', { type: 'string' })
87
+ .option('directory', { alias: 'd', type: 'string', demandOption: true });
88
+ },
89
+ (argv) => {
90
+ generateProject(argv.prompt, argv.directory);
91
+ }
92
+ )
93
+ .parse();
94
+ }
95
+
96
+ startCLI();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zobro-cli",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "main": "index.js",
5
5
  "bin": {
6
6
  "zobro-cli": "./index.js"