|
| 1 | +"use strict"; |
| 2 | +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { |
| 3 | + if (k2 === undefined) k2 = k; |
| 4 | + var desc = Object.getOwnPropertyDescriptor(m, k); |
| 5 | + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { |
| 6 | + desc = { enumerable: true, get: function() { return m[k]; } }; |
| 7 | + } |
| 8 | + Object.defineProperty(o, k2, desc); |
| 9 | +}) : (function(o, m, k, k2) { |
| 10 | + if (k2 === undefined) k2 = k; |
| 11 | + o[k2] = m[k]; |
| 12 | +})); |
| 13 | +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { |
| 14 | + Object.defineProperty(o, "default", { enumerable: true, value: v }); |
| 15 | +}) : function(o, v) { |
| 16 | + o["default"] = v; |
| 17 | +}); |
| 18 | +var __importStar = (this && this.__importStar) || (function () { |
| 19 | + var ownKeys = function(o) { |
| 20 | + ownKeys = Object.getOwnPropertyNames || function (o) { |
| 21 | + var ar = []; |
| 22 | + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; |
| 23 | + return ar; |
| 24 | + }; |
| 25 | + return ownKeys(o); |
| 26 | + }; |
| 27 | + return function (mod) { |
| 28 | + if (mod && mod.__esModule) return mod; |
| 29 | + var result = {}; |
| 30 | + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); |
| 31 | + __setModuleDefault(result, mod); |
| 32 | + return result; |
| 33 | + }; |
| 34 | +})(); |
| 35 | +Object.defineProperty(exports, "__esModule", { value: true }); |
| 36 | +const core = __importStar(require("@actions/core")); |
| 37 | +const github = __importStar(require("@actions/github")); |
| 38 | +const extractTodosFromDir_1 = require("./parser/extractTodosFromDir"); |
| 39 | +const issueManager_1 = require("./core/issueManager"); |
| 40 | +const report_1 = require("./core/report"); |
| 41 | +const todoUtils_1 = require("./core/todoUtils"); |
| 42 | +async function run() { |
| 43 | + try { |
| 44 | + const token = core.getInput('repo-token', { required: true }); |
| 45 | + const generateReport = core.getInput('report') === 'true'; |
| 46 | + const titleTemplatePath = core.getInput('issue-title-template'); |
| 47 | + const bodyTemplatePath = core.getInput('issue-body-template'); |
| 48 | + const workspace = process.env.GITHUB_WORKSPACE || '.'; |
| 49 | + const todos = (0, extractTodosFromDir_1.extractTodosFromDir)(workspace); |
| 50 | + const octokit = github.getOctokit(token); |
| 51 | + const { owner, repo } = github.context.repo; |
| 52 | + core.info(`🔍 Found ${todos.length} TODOs`); |
| 53 | + const existingTitles = await (0, issueManager_1.getExistingIssueTitles)(octokit, owner, repo); |
| 54 | + const seenKeys = new Set(); |
| 55 | + const uniqueTodos = todos.filter(todo => { |
| 56 | + const key = (0, todoUtils_1.todoKey)(todo); |
| 57 | + if (seenKeys.has(key)) |
| 58 | + return false; |
| 59 | + seenKeys.add(key); |
| 60 | + return true; |
| 61 | + }); |
| 62 | + const todosToCreate = (0, todoUtils_1.limitTodos)(uniqueTodos, 5); |
| 63 | + for (const todo of todosToCreate) { |
| 64 | + await (0, issueManager_1.createIssueIfNeeded)(octokit, owner, repo, todo, existingTitles, titleTemplatePath, bodyTemplatePath); |
| 65 | + } |
| 66 | + if (generateReport) { |
| 67 | + (0, report_1.generateMarkdownReport)(todos); |
| 68 | + core.info('📝 Generated TODO_REPORT.md'); |
| 69 | + } |
| 70 | + } |
| 71 | + catch (error) { |
| 72 | + core.setFailed(`Action failed: ${error.message}`); |
| 73 | + } |
| 74 | +} |
| 75 | +run(); |
0 commit comments