()
| 724 | } |
| 725 | |
| 726 | async fetchAllIssues() { |
| 727 | console.log('🚀 Starting to fetch iCSS repository issues...'); |
| 728 | |
| 729 | let page = 1; |
| 730 | let allIssues = []; |
| 731 | const perPage = 100; // GitHub API maximum |
| 732 | |
| 733 | try { |
| 734 | while (true) { |
| 735 | console.log(`📄 Fetching page ${page}...`); |
| 736 | |
| 737 | const response = await axios.get(this.baseURL, { |
| 738 | params: { |
| 739 | state: 'all', // 获取所有状态的issues |
| 740 | per_page: perPage, |
| 741 | page: page, |
| 742 | sort: 'updated', |
| 743 | direction: 'desc' |
| 744 | }, |
| 745 | headers: { |
| 746 | 'Accept': 'application/vnd.github.v3+json', |
| 747 | 'User-Agent': 'iCSS-MCP-Server', |
| 748 | ...(this.githubToken && { 'Authorization': `token ${this.githubToken}` }) |
| 749 | } |
| 750 | }); |
| 751 | |
| 752 | const issues = response.data; |
| 753 | |
| 754 | if (issues.length === 0) { |
| 755 | console.log('✅ No more issues found'); |
| 756 | break; |
| 757 | } |
| 758 | |
| 759 | console.log(` 📝 Found ${issues.length} issues on page ${page}`); |
| 760 | allIssues = allIssues.concat(issues); |
| 761 | |
| 762 | // GitHub API rate limiting |
| 763 | if (issues.length < perPage) { |
| 764 | break; |
| 765 | } |
| 766 | |
| 767 | page++; |
| 768 | |
| 769 | // 添加延迟以避免速率限制 |
| 770 | await new Promise(resolve => setTimeout(resolve, 1000)); |
| 771 | } |
| 772 | |
| 773 | console.log(`🎉 Total issues fetched: ${allIssues.length}`); |
| 774 | await this.saveIssuesToDatabase(allIssues); |
| 775 | |
| 776 | } catch (error) { |
| 777 | if (error.response?.status === 403) { |
| 778 | console.error('❌ GitHub API rate limit exceeded. Please set GITHUB_TOKEN environment variable.'); |
| 779 | console.error('Visit https://github.com/settings/tokens to generate a token.'); |
| 780 | process.exit(1); |
| 781 | } |
| 782 | console.error('❌ Error fetching issues:', error.message); |
| 783 | if (error.response) { |
no test coverage detected