-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathapp.js
More file actions
58 lines (57 loc) · 1.57 KB
/
app.js
File metadata and controls
58 lines (57 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import React from 'react';
import {Text, Newline} from 'ink';
import BigText from 'ink-big-text';
import Gradient from 'ink-gradient';
import isGit from 'is-git-repository';
import isCommitterSet from './utils/errors.js';
import info from './utils/info.js';
import askForCommitMessage from './utils/commit.js';
import {getOpenAIKey, setOpenAIKey, deleteOPenAIKey} from './utils/api.js';
export default function App({flags}) {
if (flags.setopenai) {
setOpenAIKey(flags.setopenai);
}
if (flags.delopenai) {
deleteOPenAIKey();
}
if (!getOpenAIKey()) {
console.log('Please provide an OpenAI API key.');
console.log(
'You can get one from https://platform.openai.com/account/api-keys',
);
console.log(
'Run `magicc --setopenai=<api-key>` to save your API key and try again.',
);
} else {
console.log(
'You have an OpenAI API key, you can now generate a commit message.',
);
const gitCheck = isGit();
const committerCheck = isCommitterSet();
if (gitCheck && committerCheck) {
askForCommitMessage();
} else {
console.log('This is not a git repository.');
}
}
return (
<>
<Gradient name="passion">
<BigText text="Magicc" />
<Text>
You can do `magicc`, you can build anything that you desire. 🪄
</Text>
</Gradient>
<Text>
Version: <Text color="green">{info('version')}</Text> | Author:{' '}
<Text color="blue">{info('author')}</Text>
<Newline />
<Text>
Need Help? <Text color="cyan">magicc --help</Text>
</Text>
<Newline />
==================================================
</Text>
</>
);
}