-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathextension.ts
More file actions
56 lines (48 loc) · 1.5 KB
/
extension.ts
File metadata and controls
56 lines (48 loc) · 1.5 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
import * as vscode from 'vscode';
import { CommandManager } from './commands';
import { ConfigurationManager } from './config';
import { Logger } from './logger';
/**
* Activates the extension and registers commands.
*
* @param {vscode.ExtensionContext} context - The context for the extension.
*/
export async function activate(context: vscode.ExtensionContext) {
try {
Logger.initialize();
Logger.info('Activating AI Commit extension...');
const configManager = ConfigurationManager.getInstance(context);
const commandManager = new CommandManager(context);
commandManager.registerCommands();
context.subscriptions.push({
dispose: () => {
configManager.dispose();
commandManager.dispose();
Logger.dispose();
}
});
Logger.info('AI Commit extension activated successfully');
const apiKey = configManager.getConfig<string>('OPENAI_API_KEY');
if (!apiKey) {
const result = await vscode.window.showWarningMessage(
'OpenAI API Key not configured. Would you like to configure it now?',
'Yes',
'No'
);
if (result === 'Yes') {
await vscode.commands.executeCommand(
'workbench.action.openSettings',
'ai-commit.OPENAI_API_KEY'
);
}
}
} catch (error) {
Logger.error('Failed to activate extension:', error);
throw error;
}
}
/**
* Deactivates the extension.
* This function is called when the extension is deactivated.
*/
export function deactivate() {}