Skip to content

Commit e4d46c4

Browse files
committed
Apply prettier formatting
1 parent afbc2d5 commit e4d46c4

12 files changed

Lines changed: 118 additions & 105 deletions

File tree

.github/funding.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@
55

66
github: warengonzaga
77
buy_me_a_coffee: warengonzaga
8-
98
# Your support means a lot to me to continue the development of open source project like this.
10-
# Sponsoring this project means a lot to me. Your support helps me to continue building great open-source projects just like this.
9+
# Sponsoring this project means a lot to me. Your support helps me to continue building great open-source projects just like this.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ This project is inspired by the following projects:
6161
- [aicommits](https://github.com/Nutlope/aicommits) - A CLI that writes your git commit messages for you with AI.
6262
- [ai-commit](https://github.com/insulineru/ai-commit) - Make commits easier with ChatGPT, Gitmoji and Conventional Commits.
6363
- [opencommit](https://github.com/di-sukharev/opencommit) - About
64-
Auto-generate impressive commits with AI in 1 second.
64+
Auto-generate impressive commits with AI in 1 second.
6565
- [tgpt](https://github.com/aandrew-me/tgpt) - AI Chatbots in terminal without needing API keys.
6666
6767
## ⚙️ Project Activity
6868
69-
![activity](https://repobeats.axiom.co/api/embed/b89d4c52ac63656f8148143516edd0db0d85788d.svg "Repobeats analytics image")
69+
![activity](https://repobeats.axiom.co/api/embed/b89d4c52ac63656f8148143516edd0db0d85788d.svg 'Repobeats analytics image')
7070
7171
## 🎯 Contributing
7272

code_of_conduct.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
1717
Examples of behavior that contributes to a positive environment for our
1818
community include:
1919

20-
* Demonstrating empathy and kindness toward other people
21-
* Being respectful of differing opinions, viewpoints, and experiences
22-
* Giving and gracefully accepting constructive feedback
23-
* Accepting responsibility and apologizing to those affected by our mistakes,
20+
- Demonstrating empathy and kindness toward other people
21+
- Being respectful of differing opinions, viewpoints, and experiences
22+
- Giving and gracefully accepting constructive feedback
23+
- Accepting responsibility and apologizing to those affected by our mistakes,
2424
and learning from the experience
25-
* Focusing on what is best not just for us as individuals, but for the
25+
- Focusing on what is best not just for us as individuals, but for the
2626
overall community
2727

2828
Examples of unacceptable behavior include:
2929

30-
* The use of sexualized language or imagery, and sexual attention or
30+
- The use of sexualized language or imagery, and sexual attention or
3131
advances of any kind
32-
* Trolling, insulting or derogatory comments, and personal or political attacks
33-
* Public or private harassment
34-
* Publishing others' private information, such as a physical or email
32+
- Trolling, insulting or derogatory comments, and personal or political attacks
33+
- Public or private harassment
34+
- Publishing others' private information, such as a physical or email
3535
address, without their explicit permission
36-
* Other conduct which could reasonably be considered inappropriate in a
36+
- Other conduct which could reasonably be considered inappropriate in a
3737
professional setting
3838

3939
## Enforcement Responsibilities
@@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
106106
### 4. Permanent Ban
107107

108108
**Community Impact**: Demonstrating a pattern of violation of community
109-
standards, including sustained inappropriate behavior, harassment of an
109+
standards, including sustained inappropriate behavior, harassment of an
110110
individual, or aggression toward or disparagement of classes of individuals.
111111

112112
**Consequence**: A permanent ban from any sort of public interaction within

contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ There are many ways to contribute to this open source project. Any contributions
1212

1313
### 🧬 Development
1414

15-
If you can write a code then create a pull request to this repo and I will review your code. Please consider to submit your pull request to the ```dev``` branch. I will auto reject if you submit your pull request to the ```main``` branch.
15+
If you can write a code then create a pull request to this repo and I will review your code. Please consider to submit your pull request to the `dev` branch. I will auto reject if you submit your pull request to the `main` branch.
1616

1717
#### 🔧 Setup
1818

source/app.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,27 @@ import isGit from 'is-git-repository';
66
import isCommitterSet from './utils/errors.js';
77
import info from './utils/info.js';
88
import askForCommitMessage from './utils/commit.js';
9-
import { getOpenAIKey, setOpenAIKey, deleteOPenAIKey } from './utils/api.js';
9+
import {getOpenAIKey, setOpenAIKey, deleteOPenAIKey} from './utils/api.js';
1010

1111
export default function App({flags}) {
12-
if(flags.setopenai) {
12+
if (flags.setopenai) {
1313
setOpenAIKey(flags.setopenai);
1414
}
15-
if(flags.delopenai) {
15+
if (flags.delopenai) {
1616
deleteOPenAIKey();
1717
}
1818
if (!getOpenAIKey()) {
1919
console.log('Please provide an OpenAI API key.');
20-
console.log('You can get one from https://platform.openai.com/account/api-keys')
21-
console.log('Run `magicc --setopenai=<api-key>` to save your API key and try again.');
20+
console.log(
21+
'You can get one from https://platform.openai.com/account/api-keys',
22+
);
23+
console.log(
24+
'Run `magicc --setopenai=<api-key>` to save your API key and try again.',
25+
);
2226
} else {
23-
console.log('You have an OpenAI API key, you can now generate a commit message.');
27+
console.log(
28+
'You have an OpenAI API key, you can now generate a commit message.',
29+
);
2430
const gitCheck = isGit();
2531
const committerCheck = isCommitterSet();
2632
if (gitCheck && committerCheck) {
@@ -31,16 +37,20 @@ export default function App({flags}) {
3137
}
3238
return (
3339
<>
34-
<Gradient name='passion'>
35-
<BigText text='Magicc' />
36-
<Text>You can do `magicc`, you can build anything that you desire. 🪄</Text>
40+
<Gradient name="passion">
41+
<BigText text="Magicc" />
42+
<Text>
43+
You can do `magicc`, you can build anything that you desire. 🪄
44+
</Text>
3745
</Gradient>
3846
<Text>
39-
Version: <Text color='green'>{info('version')}</Text> |
40-
Author: <Text color='blue'>{info('author')}</Text><Newline/>
47+
Version: <Text color="green">{info('version')}</Text> | Author:{' '}
48+
<Text color="blue">{info('author')}</Text>
49+
<Newline />
4150
<Text>
4251
Need Help? <Text color="cyan">magicc --help</Text>
43-
</Text><Newline/>
52+
</Text>
53+
<Newline />
4454
==================================================
4555
</Text>
4656
</>

source/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ const cli = meow(
3333
},
3434
);
3535

36-
render(<App flags={cli.flags}/>);
36+
render(<App flags={cli.flags} />);

source/utils/api.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,46 @@ import Conf from 'conf';
33
const config = new Conf({projectName: 'magicc'});
44

55
async function isValidOpenAIKey(apiKey) {
6-
try {
7-
const response = await fetch('https://api.openai.com/v1/models', {
8-
headers: {
9-
'Authorization': `Bearer ${apiKey}`
10-
}
11-
});
6+
try {
7+
const response = await fetch('https://api.openai.com/v1/models', {
8+
headers: {
9+
Authorization: `Bearer ${apiKey}`,
10+
},
11+
});
1212

13-
if (response.status === 200) {
14-
return true;
15-
} else if (response.status === 401) {
16-
console.error('Invalid API key');
17-
return false;
18-
} else {
19-
console.error('Unexpected response status:', response.status);
20-
return false;
21-
}
22-
} catch (error) {
23-
console.error('Error while validating API key:', error);
24-
return false;
25-
}
13+
if (response.status === 200) {
14+
return true;
15+
} else if (response.status === 401) {
16+
console.error('Invalid API key');
17+
return false;
18+
} else {
19+
console.error('Unexpected response status:', response.status);
20+
return false;
21+
}
22+
} catch (error) {
23+
console.error('Error while validating API key:', error);
24+
return false;
25+
}
2626
}
2727

28-
const setOpenAIKey = (key) => {
29-
isValidOpenAIKey(key).then(isValid => {
30-
if (isValid) {
31-
console.log('API key is valid');
32-
config.set('openai', key);
33-
} else {
34-
console.log('API key is invalid');
35-
}
36-
});
28+
const setOpenAIKey = key => {
29+
isValidOpenAIKey(key).then(isValid => {
30+
if (isValid) {
31+
console.log('API key is valid');
32+
config.set('openai', key);
33+
} else {
34+
console.log('API key is invalid');
35+
}
36+
});
3737
};
3838

3939
const getOpenAIKey = () => {
40-
return config.get('openai');
41-
}
40+
return config.get('openai');
41+
};
4242

4343
const deleteOPenAIKey = () => {
44-
config.delete('openai');
45-
console.log('OpenAI API key deleted.');
46-
}
44+
config.delete('openai');
45+
console.log('OpenAI API key deleted.');
46+
};
4747

4848
export {setOpenAIKey, getOpenAIKey, deleteOPenAIKey};

source/utils/commit.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ async function askForCommitMessage() {
2424
.catch(error => {
2525
console.error('Failed to commit changes:', error);
2626
});
27-
}
28-
else {
27+
} else {
2928
console.log('Changes not committed.');
3029
}
3130
exit();
@@ -49,7 +48,7 @@ async function askForCommitMessage() {
4948
</Box>
5049
);
5150
};
52-
51+
5352
if (prompt) {
5453
render(<SelectSuggestedCommit />);
5554
} else {

source/utils/config.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"emoji": "YYou are the author of the commit message. Your task is to select the appropriate category for the git diff based on the changes. Use the following categories (emoji category name => usage): 📦 new => for new files or new features; ✨ tweak => for enhancements or updates to the codebase; ☕ chore => for updates or changes outside the project codebase, including README.md; 🐞 fix => for fixing code bugs and errors. Please reply with the category name only.",
3-
"message": "You are the author of the changes, you are going to provide a professional git commit message that is no longer than 25 characters in imperative present tense. Stricly no emojis are allowed and no conventional commit message as prefix is already provided. For example, instead of 'fix: fix a bug' make it 'fix a bug'. The message should be in lower case and no period at the end.",
4-
"default_model": "gpt-4o-mini",
5-
"maxDiffSize": 4000
2+
"emoji": "YYou are the author of the commit message. Your task is to select the appropriate category for the git diff based on the changes. Use the following categories (emoji category name => usage): 📦 new => for new files or new features; ✨ tweak => for enhancements or updates to the codebase; ☕ chore => for updates or changes outside the project codebase, including README.md; 🐞 fix => for fixing code bugs and errors. Please reply with the category name only.",
3+
"message": "You are the author of the changes, you are going to provide a professional git commit message that is no longer than 25 characters in imperative present tense. Stricly no emojis are allowed and no conventional commit message as prefix is already provided. For example, instead of 'fix: fix a bug' make it 'fix a bug'. The message should be in lower case and no period at the end.",
4+
"default_model": "gpt-4o-mini",
5+
"maxDiffSize": 4000
66
}

source/utils/errors.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
import { execa } from "execa"
1+
import {execa} from 'execa';
22

33
const isCommitterSet = async () => {
4-
try {
5-
const { stdout: name } = await execa("git", ["config", "--get", "user.name"]);
6-
const { stdout: email } = await execa("git", ["config", "--get", "user.email"]);
4+
try {
5+
const {stdout: name} = await execa('git', ['config', '--get', 'user.name']);
6+
const {stdout: email} = await execa('git', [
7+
'config',
8+
'--get',
9+
'user.email',
10+
]);
711

8-
if (name && email) {
9-
return true;
10-
}
11-
} catch (error) {
12-
console.error("Failed to check if committer is set:", error);
13-
return false;
14-
}
15-
}
12+
if (name && email) {
13+
return true;
14+
}
15+
} catch (error) {
16+
console.error('Failed to check if committer is set:', error);
17+
return false;
18+
}
19+
};
1620

17-
export default isCommitterSet;
21+
export default isCommitterSet;

0 commit comments

Comments
 (0)