-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-github.ts
More file actions
67 lines (55 loc) · 2.48 KB
/
test-github.ts
File metadata and controls
67 lines (55 loc) · 2.48 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
59
60
61
62
63
64
65
66
67
/**
* Test script for GitHub Integration
* This script tests the basic functionality of the GitHub integration module
*/
import { initGitHubIntegration, createGitHubConfig } from './github-integration.js';
async function testGitHubIntegration() {
console.log('🧪 Testing GitHub Integration...\n');
try {
// Try to initialize GitHub integration
// This will fail if github-config.json doesn't exist
console.log('🔐 Attempting to initialize GitHub integration...');
try {
const github = await initGitHubIntegration();
// Test getting user info
console.log('👤 Getting user information...');
const user = await github.getUser();
console.log(` ✓ Authenticated as: ${user.login}`);
// Test listing repositories
console.log('📚 Listing repositories...');
const repos = await github.listRepositories();
console.log(` ✓ Found ${repos.length} repositories`);
// Show first 3 repositories if any exist
if (repos.length > 0) {
console.log(' First 3 repositories:');
repos.slice(0, 3).forEach(repo => {
console.log(` - ${repo.full_name} (${repo.private ? 'private' : 'public'})`);
});
}
console.log('\n✅ GitHub Integration test passed!');
console.log('ℹ️ You are successfully authenticated with GitHub.');
console.log('ℹ️ You can now use the GitHub integration module for automation tasks.');
} catch (error) {
console.log(' ✗ Failed to authenticate with GitHub');
console.error(` Error: ${(error as Error).message}`);
console.log('\n📋 To set up GitHub authentication:');
console.log(' 1. Create a GitHub personal access token at:');
console.log(' https://github.com/settings/tokens');
console.log(' 2. Include these scopes: repo, read:org, gist, user');
console.log(' 3. Run this command with your token:');
console.log(' npx tsx test-github.ts <your-token-here>');
console.log('');
}
} catch (error) {
console.error('❌ Test failed with error:', (error as Error).message);
}
}
// If a command line argument is provided, treat it as a token and create config
if (process.argv[2]) {
const token = process.argv[2];
console.log(`🔑 Setting up GitHub config with provided token...`);
createGitHubConfig(token);
console.log('✅ GitHub config created. Running test...\n');
}
// Run the test
testGitHubIntegration();