()
| 268 | } |
| 269 | } |
| 270 | const handleSubmit = async () => { |
| 271 | if (state.step === 'warnings') { |
| 272 | logEvent('ncode_install_github_app_step_completed', { |
| 273 | step: 'warnings' as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS |
| 274 | }); |
| 275 | setState(prev_11 => ({ |
| 276 | ...prev_11, |
| 277 | step: 'install-app' |
| 278 | })); |
| 279 | setTimeout(openGitHubAppInstallation, 0); |
| 280 | } else if (state.step === 'choose-repo') { |
| 281 | let repoName_1 = state.useCurrentRepo ? state.currentRepo : state.selectedRepoName; |
| 282 | if (!repoName_1.trim()) { |
| 283 | return; |
| 284 | } |
| 285 | const repoWarnings: Warning[] = []; |
| 286 | if (repoName_1.includes('github.com')) { |
| 287 | const match = repoName_1.match(/github\.com[:/]([^/]+\/[^/]+)(\.git)?$/); |
| 288 | if (!match) { |
| 289 | repoWarnings.push({ |
| 290 | title: 'Invalid GitHub URL format', |
| 291 | message: 'The repository URL format appears to be invalid.', |
| 292 | instructions: ['Use format: owner/repo or https://github.com/owner/repo', 'Example: anthropics/claude-cli'] |
| 293 | }); |
| 294 | } else { |
| 295 | repoName_1 = match[1]?.replace(/\.git$/, '') || ''; |
| 296 | } |
| 297 | } |
| 298 | if (!repoName_1.includes('/')) { |
| 299 | repoWarnings.push({ |
| 300 | title: 'Repository format warning', |
| 301 | message: 'Repository should be in format "owner/repo"', |
| 302 | instructions: ['Use format: owner/repo', 'Example: anthropics/claude-cli'] |
| 303 | }); |
| 304 | } |
| 305 | const permissionCheck = await checkRepositoryPermissions(repoName_1); |
| 306 | if (permissionCheck.error === 'repository_not_found') { |
| 307 | repoWarnings.push({ |
| 308 | title: 'Repository not found', |
| 309 | message: `Repository ${repoName_1} was not found or you don't have access.`, |
| 310 | instructions: [`Check that the repository name is correct: ${repoName_1}`, 'Ensure you have access to this repository', 'For private repositories, make sure your GitHub token has the "repo" scope', 'You can add the repo scope with: gh auth refresh -h github.com -s repo,workflow'] |
| 311 | }); |
| 312 | } else if (!permissionCheck.hasAccess) { |
| 313 | repoWarnings.push({ |
| 314 | title: 'Admin permissions required', |
| 315 | message: `You might need admin permissions on ${repoName_1} to set up GitHub Actions.`, |
| 316 | instructions: ['Repository admins can install GitHub Apps and set secrets', 'Ask a repository admin to run this command if setup fails', 'Alternatively, you can use the manual setup instructions'] |
| 317 | }); |
| 318 | } |
| 319 | const workflowExists = await checkExistingWorkflowFile(repoName_1); |
| 320 | if (repoWarnings.length > 0) { |
| 321 | const allWarnings = [...state.warnings, ...repoWarnings]; |
| 322 | setState(prev_12 => ({ |
| 323 | ...prev_12, |
| 324 | selectedRepoName: repoName_1, |
| 325 | workflowExists, |
| 326 | warnings: allWarnings, |
| 327 | step: 'warnings' |
no test coverage detected