aicommits 0.1.1 → 0.1.2

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.
package/README.md CHANGED
@@ -25,6 +25,7 @@ Now:
25
25
  - Rewrite this in node to publish as an npm package
26
26
  - Fix screenshot on npm
27
27
  - add an npm ignore and add demo to README as well
28
+ - make CLI looks nicer
28
29
 
29
30
  Future tasks:
30
31
 
package/aicommit.js CHANGED
@@ -3,8 +3,6 @@
3
3
  void (async function () {
4
4
  $.verbose = false;
5
5
 
6
- let conventionalCommit = false;
7
-
8
6
  console.log(chalk.white("▲ ") + chalk.green("Welcome to AICommit!"));
9
7
 
10
8
  let pwd = await $`cd ~ && pwd;`;
@@ -27,11 +25,7 @@ void (async function () {
27
25
  await $`exit 1`;
28
26
  }
29
27
 
30
- let prompt = `I want you to act like a git commit message writer. I will input a git diff and your job is to convert it into a useful commit message. ${
31
- conventionalCommit
32
- ? "Preface the commit with 'feat:' if it is a feature or 'fix:' if it is a bug."
33
- : "Do not preface the commit with anything."
34
- } Return a complete sentence and do not repeat yourself: ${diff}`;
28
+ let prompt = `I want you to act like a git commit message writer. I will input a git diff and your job is to convert it into a useful commit message. Do not preface the commit with anything, return a complete sentence, and do not repeat yourself: ${diff}`;
35
29
 
36
30
  const payload = {
37
31
  model: "text-davinci-003",
package/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import chalk from "chalk";
3
4
  import { execSync } from "child_process";
4
5
  import inquirer from "inquirer";
5
6
  import fetch from "node-fetch";
@@ -7,11 +8,12 @@ import fetch from "node-fetch";
7
8
  let OPENAI_API_KEY = process.env.OPENAI_API_KEY;
8
9
 
9
10
  async function main() {
10
- console.log("▲ Welcome to AICommit!");
11
+ console.log(chalk.white("▲ ") + chalk.green("Welcome to AICommit!"));
11
12
 
12
13
  if (!OPENAI_API_KEY) {
13
14
  console.error(
14
- "▲ Please specify an OpenAI key using export OPEN_AI_KEY='YOUR_API_KEY'"
15
+ chalk.white("▲ ") +
16
+ "Please specify an OpenAI key using export OPEN_AI_KEY='YOUR_API_KEY'"
15
17
  );
16
18
  process.exit(1);
17
19
  }
@@ -21,7 +23,7 @@ async function main() {
21
23
  stdio: "ignore",
22
24
  });
23
25
  } catch (e) {
24
- console.error("▲ This is not a git repository");
26
+ console.error(chalk.white("▲ ") + "This is not a git repository");
25
27
  process.exit(1);
26
28
  }
27
29
 
@@ -31,14 +33,17 @@ async function main() {
31
33
 
32
34
  if (!diff) {
33
35
  console.log(
34
- "▲ No staged changes found. Make sure there are changes and run `git add .`"
36
+ chalk.white("▲ ") +
37
+ "No staged changes found. Make sure there are changes and run `git add .`"
35
38
  );
36
39
  process.exit(1);
37
40
  }
38
41
 
39
42
  // Accounting for GPT-3's input req of 4k tokens (approx 8k chars)
40
43
  if (diff.length > 8000) {
41
- console.log("▲ The diff is too large to write a commit message.");
44
+ console.log(
45
+ chalk.white("▲ ") + "The diff is too large to write a commit message."
46
+ );
42
47
  process.exit(1);
43
48
  }
44
49
 
@@ -48,10 +53,15 @@ async function main() {
48
53
  : "Do not preface the commit with anything."
49
54
  } Return a complete sentence and do not repeat yourself: ${diff}`;
50
55
 
51
- console.log("▲ Generating your AI commit message...\n");
56
+ console.log(
57
+ chalk.white("▲ ") + chalk.gray("Generating your AI commit message...\n")
58
+ );
52
59
  const aiCommitMessage = await generateCommitMessage(prompt);
53
60
 
54
- console.log(aiCommitMessage);
61
+ console.log(
62
+ chalk.white("▲ ") + chalk.bold("Commit message: ") + aiCommitMessage
63
+ );
64
+ console.log("\n");
55
65
 
56
66
  const confirmationMessage = await inquirer.prompt([
57
67
  {
@@ -63,7 +73,7 @@ async function main() {
63
73
  ]);
64
74
 
65
75
  if (confirmationMessage.useCommitMessage === "n") {
66
- console.log("▲ Commit message has not been commited.`");
76
+ console.log(chalk.white("▲ ") + "Commit message has not been commited.");
67
77
  process.exit(1);
68
78
  }
69
79
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicommits",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Writes your git commit messages for you with AI",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -11,6 +11,7 @@
11
11
  "author": "Hassan El Mghari (@nutlope)",
12
12
  "license": "MIT",
13
13
  "dependencies": {
14
+ "chalk": "^5.2.0",
14
15
  "inquirer": "^9.1.4",
15
16
  "node-fetch": "^3.3.0"
16
17
  }