@sensio-erp/commit-ai 1.0.2 → 1.0.4

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/commit-ai.js +14 -13
  2. package/package.json +4 -4
package/bin/commit-ai.js CHANGED
@@ -4,16 +4,17 @@ require("dotenv").config();
4
4
  const { execSync } = require("child_process");
5
5
  const fs = require("fs");
6
6
  const path = require("path");
7
- const inquirer = require("inquirer");
8
- const chalk = require("chalk");
9
7
  const { generateCommit } = require("../src/openai");
10
8
 
11
9
  if (!process.env.OPENAI_API_KEY) {
12
- console.error("❌ OPENAI_API_KEY não definida");
13
- process.exit(1);
10
+ console.error("❌ OPENAI_API_KEY não definida");
11
+ process.exit(1);
14
12
  }
15
13
 
16
14
  async function run() {
15
+ const chalk = (await import("chalk")).default;
16
+ const inquirer = (await import("inquirer")).default;
17
+
17
18
  try {
18
19
  console.log(chalk.cyan("\n🔍 Lendo alterações staged...\n"));
19
20
 
@@ -86,7 +87,7 @@ ${diff}
86
87
  process.exit(0);
87
88
  }
88
89
 
89
- commitWithMessage(finalMessage);
90
+ commitWithMessage(finalMessage);
90
91
 
91
92
  console.log(chalk.green("\n✅ Commit realizado com sucesso!\n"));
92
93
  } catch (err) {
@@ -110,18 +111,18 @@ function escapeCommit(message) {
110
111
  }
111
112
 
112
113
  function commitWithMessage(message) {
113
- const lines = message.split("\n").filter(Boolean);
114
+ const lines = message.split("\n").filter(Boolean);
114
115
 
115
- const title = lines[0];
116
- const body = lines.slice(1);
116
+ const title = lines[0];
117
+ const body = lines.slice(1);
117
118
 
118
- let command = `git commit -m "${escapeCommit(title)}"`;
119
+ let command = `git commit -m "${escapeCommit(title)}"`;
119
120
 
120
- body.forEach(line => {
121
- command += ` -m "${escapeCommit(line)}"`;
122
- });
121
+ body.forEach(line => {
122
+ command += ` -m "${escapeCommit(line)}"`;
123
+ });
123
124
 
124
- execSync(command, { stdio: "inherit" });
125
+ execSync(command, { stdio: "inherit" });
125
126
  }
126
127
 
127
128
  run();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sensio-erp/commit-ai",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "AI-powered CLI to generate smart git commit messages based on staged changes",
5
5
  "keywords": [
6
6
  "cli",
@@ -33,9 +33,9 @@
33
33
  "release": "npm version patch && npm publish --access public"
34
34
  },
35
35
  "dependencies": {
36
- "openai": "^4.0.0",
37
- "inquirer": "^9.0.0",
38
36
  "chalk": "^5.0.0",
39
- "dotenv": "^16.0.0"
37
+ "dotenv": "^16.6.1",
38
+ "inquirer": "^9.0.0",
39
+ "openai": "^4.0.0"
40
40
  }
41
41
  }