-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-github-access.ts
More file actions
78 lines (66 loc) · 3 KB
/
setup-github-access.ts
File metadata and controls
78 lines (66 loc) · 3 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
68
69
70
71
72
73
74
75
76
77
78
/**
* GitHub Access Setup Script for SmartMouse
* This script guides the user through setting up GitHub access
*/
import { execSync } from 'child_process';
import { createGitHubConfig } from './github-integration.js';
function openUrl(url: string) {
// Cross-platform way to open URLs
const platform = process.platform;
let command;
switch (platform) {
case 'win32':
command = `start ${url}`;
break;
case 'darwin': // macOS
command = `open ${url}`;
break;
case 'linux':
command = `xdg-open ${url}`;
break;
default:
console.log(`Please open this URL in your browser: ${url}`);
return;
}
try {
execSync(command, { stdio: 'inherit' });
console.log(`Opening ${url} in your default browser...`);
} catch (error) {
console.log(`Failed to open browser automatically. Please open this URL manually: ${url}`);
}
}
async function setupGitHubAccess() {
console.log('🔐 Setting up GitHub Access for SmartMouse...\n');
console.log('Step 1: We need to create a GitHub Personal Access Token');
console.log(' This will allow SmartMouse to interact with GitHub on your behalf\n');
console.log('Step 2: Opening GitHub Personal Access Token creation page...');
console.log(' Please follow these steps after the page opens:\n');
console.log(' 1. Click "Generate new token" -> "Generate new token (classic)"');
console.log(' 2. Give your token a descriptive name (e.g., "SmartMouse Token")');
console.log(' 3. Set expiration to "No expiration" or your preferred duration');
console.log(' 4. Under "Select scopes", check the following:');
console.log(' - [x] repo (Full control of private repositories)');
console.log(' - [x] read:org (Read org membership and teams)');
console.log(' - [x] gist (Create and edit gists)');
console.log(' - [x] user (Update user profile)');
console.log(' 5. Click "Generate token"');
console.log(' 6. Copy the generated token (IMPORTANT: You won\'t see it again!)');
console.log(' 7. Save the token to a file named github-config.json in this directory\n');
console.log('📋 To complete the setup:');
console.log(' 1. Press any key to open the GitHub token creation page in your browser');
console.log(' 2. Follow the steps above to create your token');
console.log(' 3. Create a file named github-config.json with this format:');
console.log(' {');
console.log(' "token": "your_copied_token_here",');
console.log(' "baseUrl": "https://api.github.com"');
console.log(' }');
console.log('');
console.log(' 4. After creating the file, test the connection with:');
console.log(' npx tsx test-github.ts\n');
// Open the GitHub token creation page
console.log('Opening GitHub token creation page...');
openUrl('https://github.com/settings/tokens');
console.log('\n🎉 Instructions displayed above. Please follow them to complete the setup!');
}
// Run the setup
setupGitHubAccess();