@snapcommit/cli 3.8.15 → 3.8.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -224,23 +224,32 @@ async function githubConnectCommand(tokenArg) {
|
|
|
224
224
|
console.log(chalk_1.default.white(' - Create pull requests with natural language'));
|
|
225
225
|
console.log(chalk_1.default.white(' - Check CI/workflow status'));
|
|
226
226
|
console.log(chalk_1.default.white(' - Manage issues and PRs\n'));
|
|
227
|
-
// Get auth config to get
|
|
227
|
+
// Get auth config to get CLI token
|
|
228
228
|
const authConfig = (0, auth_1.getAuthConfig)();
|
|
229
229
|
if (!authConfig || !authConfig.token) {
|
|
230
230
|
console.log(chalk_1.default.red('\n❌ You must be logged in first!'));
|
|
231
231
|
console.log(chalk_1.default.gray(' Run: ') + chalk_1.default.cyan('snap login\n'));
|
|
232
232
|
return;
|
|
233
233
|
}
|
|
234
|
-
// Generate state parameter for OAuth security
|
|
235
|
-
const state = Buffer.from(JSON.stringify({
|
|
236
|
-
userId: authConfig.userId,
|
|
237
|
-
timestamp: Date.now()
|
|
238
|
-
})).toString('base64');
|
|
239
|
-
// Generate OAuth URL
|
|
240
|
-
const oauthUrl = `https://snapcommit.dev/api/github/connect?state=${encodeURIComponent(state)}`;
|
|
241
234
|
console.log(chalk_1.default.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
|
|
242
|
-
console.log(chalk_1.default.cyan('
|
|
235
|
+
console.log(chalk_1.default.cyan('🔄 Getting GitHub OAuth URL...\n'));
|
|
243
236
|
try {
|
|
237
|
+
// Call API to get OAuth URL
|
|
238
|
+
const response = await fetch('https://snapcommit.dev/api/github/connect', {
|
|
239
|
+
method: 'POST',
|
|
240
|
+
headers: {
|
|
241
|
+
'Content-Type': 'application/json',
|
|
242
|
+
},
|
|
243
|
+
body: JSON.stringify({ token: authConfig.token }),
|
|
244
|
+
});
|
|
245
|
+
if (!response.ok) {
|
|
246
|
+
const error = await response.json();
|
|
247
|
+
console.log(chalk_1.default.red(`\n❌ Failed to get OAuth URL: ${error.error}\n`));
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const data = await response.json();
|
|
251
|
+
const oauthUrl = data.oauthUrl;
|
|
252
|
+
console.log(chalk_1.default.cyan('Opening browser for GitHub authorization...\n'));
|
|
244
253
|
// Open browser
|
|
245
254
|
const open = (await Promise.resolve().then(() => __importStar(require('open')))).default;
|
|
246
255
|
await open(oauthUrl);
|