@snapcommit/cli 3.8.15 → 3.8.17
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 +13 -94
- package/package.json +1 -1
|
@@ -3,39 +3,6 @@
|
|
|
3
3
|
* GitHub authentication - Auto-fetches OAuth token from SnapCommit account
|
|
4
4
|
* Falls back to manual PAT if OAuth token not available
|
|
5
5
|
*/
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
-
var ownKeys = function(o) {
|
|
24
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
-
var ar = [];
|
|
26
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
-
return ar;
|
|
28
|
-
};
|
|
29
|
-
return ownKeys(o);
|
|
30
|
-
};
|
|
31
|
-
return function (mod) {
|
|
32
|
-
if (mod && mod.__esModule) return mod;
|
|
33
|
-
var result = {};
|
|
34
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
-
__setModuleDefault(result, mod);
|
|
36
|
-
return result;
|
|
37
|
-
};
|
|
38
|
-
})();
|
|
39
6
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
8
|
};
|
|
@@ -213,68 +180,20 @@ async function githubConnectCommand(tokenArg) {
|
|
|
213
180
|
console.log(chalk_1.default.cyan(' • "list my open PRs"\n'));
|
|
214
181
|
return;
|
|
215
182
|
}
|
|
216
|
-
//
|
|
217
|
-
console.log(chalk_1.default.yellow('\n⚠️ GitHub
|
|
218
|
-
console.log(chalk_1.default.white(
|
|
219
|
-
console.log(chalk_1.default.bold.cyan('Quick Setup
|
|
220
|
-
console.log(chalk_1.default.gray(' 1.
|
|
221
|
-
console.log(chalk_1.default.gray(' 2.
|
|
222
|
-
console.log(chalk_1.default.gray(
|
|
223
|
-
console.log(chalk_1.default.gray('
|
|
224
|
-
console.log(chalk_1.default.white(' - Create pull requests with natural language'));
|
|
225
|
-
console.log(chalk_1.default.white(' - Check CI/workflow status'));
|
|
226
|
-
console.log(chalk_1.default.white(' - Manage issues and PRs\n'));
|
|
227
|
-
// Get auth config to get user ID
|
|
228
|
-
const authConfig = (0, auth_1.getAuthConfig)();
|
|
229
|
-
if (!authConfig || !authConfig.token) {
|
|
230
|
-
console.log(chalk_1.default.red('\n❌ You must be logged in first!'));
|
|
231
|
-
console.log(chalk_1.default.gray(' Run: ') + chalk_1.default.cyan('snap login\n'));
|
|
232
|
-
return;
|
|
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)}`;
|
|
183
|
+
// Token not found - user needs to sign up with GitHub on the website
|
|
184
|
+
console.log(chalk_1.default.yellow('\n⚠️ GitHub not connected yet!\n'));
|
|
185
|
+
console.log(chalk_1.default.white('To use GitHub features, you need to sign up with GitHub on our website.\n'));
|
|
186
|
+
console.log(chalk_1.default.bold.cyan('📝 Quick Setup:\n'));
|
|
187
|
+
console.log(chalk_1.default.gray(' 1. Visit: ') + chalk_1.default.cyan.underline('https://snapcommit.dev'));
|
|
188
|
+
console.log(chalk_1.default.gray(' 2. Click "Get Started"'));
|
|
189
|
+
console.log(chalk_1.default.gray(' 3. Sign up with GitHub'));
|
|
190
|
+
console.log(chalk_1.default.gray(' 4. Come back here and run ') + chalk_1.default.cyan('github connect') + chalk_1.default.gray(' again\n'));
|
|
241
191
|
console.log(chalk_1.default.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
|
|
242
|
-
console.log(chalk_1.default.
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
console.log(chalk_1.default.green('✅ Browser opened!\n'));
|
|
248
|
-
console.log(chalk_1.default.gray('Waiting for you to authorize...\n'));
|
|
249
|
-
console.log(chalk_1.default.yellow('After authorization, come back here and press ENTER'));
|
|
250
|
-
// Wait for user confirmation
|
|
251
|
-
await askQuestion(chalk_1.default.cyan('\nPress ENTER after authorizing in browser: '));
|
|
252
|
-
// Try to fetch the token again
|
|
253
|
-
const autoConfig2 = await autoFetchGitHubToken();
|
|
254
|
-
if (autoConfig2) {
|
|
255
|
-
saveGitHubToken(autoConfig2);
|
|
256
|
-
console.log(chalk_1.default.green.bold('\n✅ GITHUB CONNECTED! 🎉\n'));
|
|
257
|
-
console.log(chalk_1.default.white(` Connected as: ${chalk_1.default.bold('@' + autoConfig2.username)}\n`));
|
|
258
|
-
console.log(chalk_1.default.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
|
|
259
|
-
console.log(chalk_1.default.bold('🚀 You can now use GitHub features!\n'));
|
|
260
|
-
console.log(chalk_1.default.gray(' Try these commands in snap REPL:\n'));
|
|
261
|
-
console.log(chalk_1.default.cyan(' • "create a pull request"'));
|
|
262
|
-
console.log(chalk_1.default.cyan(' • "check CI status"'));
|
|
263
|
-
console.log(chalk_1.default.cyan(' • "list my open PRs"\n'));
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
console.log(chalk_1.default.red('\n❌ Connection failed\n'));
|
|
267
|
-
console.log(chalk_1.default.yellow('Possible reasons:'));
|
|
268
|
-
console.log(chalk_1.default.gray(' • Authorization was cancelled'));
|
|
269
|
-
console.log(chalk_1.default.gray(' • GitHub authorization not completed'));
|
|
270
|
-
console.log(chalk_1.default.gray(' • Network error\n'));
|
|
271
|
-
console.log(chalk_1.default.gray('Try running ') + chalk_1.default.cyan('github connect') + chalk_1.default.gray(' again\n'));
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
catch (error) {
|
|
275
|
-
console.log(chalk_1.default.red(`\n❌ ${error.message}\n`));
|
|
276
|
-
console.log(chalk_1.default.gray('Try running ') + chalk_1.default.cyan('github connect') + chalk_1.default.gray(' again\n'));
|
|
277
|
-
}
|
|
192
|
+
console.log(chalk_1.default.bold('💡 Why sign up on the website?\n'));
|
|
193
|
+
console.log(chalk_1.default.gray(' • Your GitHub account is automatically connected'));
|
|
194
|
+
console.log(chalk_1.default.gray(' • Secure OAuth flow through Supabase'));
|
|
195
|
+
console.log(chalk_1.default.gray(' • Works seamlessly with the CLI\n'));
|
|
196
|
+
console.log(chalk_1.default.gray('After signing up, run: ') + chalk_1.default.cyan('github connect\n'));
|
|
278
197
|
}
|
|
279
198
|
/**
|
|
280
199
|
* GitHub status command
|