mongor-cli 1.0.1 → 1.0.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 +1 -78
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -1,78 +1 @@
1
- #!/usr/bin/env node
2
-
3
- const fs = require('fs');
4
- const yargs = require('yargs/yargs');
5
- const { hideBin } = require('yargs/helpers');
6
-
7
- // ⚠️ Paste your official Google Gemini API key here.
8
- const API_KEY = "AIzaSyAQ_F2ZOMKMMaDMVy2Jmt2KtIdlSnu1t5M";
9
-
10
- async function generateCode(prompt, outputFile) {
11
- // --- THIS IS THE FINAL, CORRECTED URL ---
12
- const url = `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=${API_KEY}`;
13
-
14
- const body = {
15
- contents: [{
16
- parts: [{
17
- text: `You are an expert code generation assistant. Provide only the code for the following prompt, without any extra explanation or markdown fences. Prompt: "${prompt}"`
18
- }]
19
- }]
20
- };
21
-
22
- try {
23
- console.log("WAIT Server started on port 3000....");
24
-
25
- const response = await fetch(url, {
26
- method: 'POST',
27
- headers: { 'Content-Type': 'application/json' },
28
- body: JSON.stringify(body),
29
- });
30
-
31
- if (!response.ok) {
32
- const errorData = await response.json();
33
- console.error('❌ API Error Details:', JSON.stringify(errorData.error, null, 2));
34
- throw new Error(`API request failed with status ${response.status}`);
35
- }
36
-
37
- const data = await response.json();
38
- const code = data.candidates[0].content.parts[0].text;
39
-
40
- if (outputFile) {
41
- fs.writeFileSync(outputFile, code);
42
- console.log(`✅ Code successfully saved to ${outputFile}`);
43
- } else {
44
- console.log(code);
45
- }
46
-
47
- } catch (error) {
48
- console.error('❌ An error occurred:', error.message);
49
- }
50
- }
51
-
52
- // Yargs setup (no changes needed here)
53
- yargs(hideBin(process.argv))
54
- .command(
55
- '$0 <prompt>',
56
- 'Generates code based on a text prompt using Google Gemini.',
57
- (yargs) => {
58
- return yargs
59
- .positional('prompt', {
60
- describe: 'The code you want to generate',
61
- type: 'string',
62
- })
63
- .option('output', {
64
- alias: 'o',
65
- describe: 'File to save the generated code',
66
- type: 'string',
67
- });
68
- },
69
- (argv) => {
70
- if (!API_KEY || API_KEY === "YOUR_GEMINI_API_KEY_HERE") {
71
- console.error('❌ ERROR: Please replace "YOUR_GEMINI_API_KEY_HERE" with your actual key in the index.js file.');
72
- return;
73
- }
74
- generateCode(argv.prompt, argv.output);
75
- }
76
- )
77
- .demandCommand(1, 'You must provide a prompt to generate code.')
78
- .parse();
1
+ //nO longer available
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mongor-cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "main": "index.js",
5
5
  "bin": {
6
6
  "mongor-cli": "./index.js"
@@ -14,6 +14,6 @@
14
14
  "type": "commonjs",
15
15
  "description": "A cli for vs code ",
16
16
  "dependencies": {
17
- "yargs": "^18.0.0"
17
+ "yargs": "^17.7.2"
18
18
  }
19
19
  }