@snapcommit/cli 3.8.14 → 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.
- package/dist/commands/github-connect.js +18 -9
- package/dist/repl.js +20 -0
- package/package.json +1 -1
|
@@ -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);
|
package/dist/repl.js
CHANGED
|
@@ -259,11 +259,31 @@ async function startREPL() {
|
|
|
259
259
|
console.log(chalk_1.default.gray(' • ') + chalk_1.default.cyan('stats') + chalk_1.default.gray(' - Show commit stats (stats today/week/month/year)'));
|
|
260
260
|
console.log(chalk_1.default.gray(' • ') + chalk_1.default.cyan('cd <path>') + chalk_1.default.gray(' - Navigate to different repo'));
|
|
261
261
|
console.log(chalk_1.default.gray(' • ') + chalk_1.default.cyan('update') + chalk_1.default.gray(' - Update to latest version'));
|
|
262
|
+
console.log(chalk_1.default.gray(' • ') + chalk_1.default.cyan('github connect') + chalk_1.default.gray(' - Connect GitHub for PR/CI features'));
|
|
262
263
|
console.log(chalk_1.default.gray(' • ') + chalk_1.default.cyan('exit/quit') + chalk_1.default.gray(' - Exit SnapCommit\n'));
|
|
263
264
|
console.log(chalk_1.default.gray('💡 I\'ll show you what I\'ll do before executing anything!\n'));
|
|
264
265
|
rl.prompt();
|
|
265
266
|
return;
|
|
266
267
|
}
|
|
268
|
+
// GitHub commands - handle these BEFORE natural language processing!
|
|
269
|
+
if (line === 'github connect' || line === 'connect github') {
|
|
270
|
+
const { githubConnectCommand } = await Promise.resolve().then(() => __importStar(require('./commands/github-connect')));
|
|
271
|
+
await githubConnectCommand();
|
|
272
|
+
rl.prompt();
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (line === 'github status' || line === 'github info') {
|
|
276
|
+
const { githubStatusCommand } = await Promise.resolve().then(() => __importStar(require('./commands/github-connect')));
|
|
277
|
+
await githubStatusCommand();
|
|
278
|
+
rl.prompt();
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
if (line === 'github disconnect') {
|
|
282
|
+
const { githubDisconnectCommand } = await Promise.resolve().then(() => __importStar(require('./commands/github-connect')));
|
|
283
|
+
await githubDisconnectCommand();
|
|
284
|
+
rl.prompt();
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
267
287
|
// Everything else is natural language
|
|
268
288
|
try {
|
|
269
289
|
rl.pause(); // Pause REPL readline to avoid conflicts
|