diff --git a/dist/index.js b/dist/index.js index 37c63fd..de93512 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,5 +1,38 @@ #!/usr/bin/env node "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; @@ -79,34 +112,6 @@ program console.log(`\nOpen issues in ${options.repo}:\n`); issues.forEach((issue) => console.log(` #${issue.number} — ${issue.title}`)); }); -program - .command('bounty') - .description('Attach a Stellar USDC bounty request to a GitHub issue') - .requiredOption('-r, --repo ', 'target repository (org/repo)') - .requiredOption('-i, --issue ', 'target issue number') - .requiredOption('-a, --amount ', 'bounty amount in USDC') - .option('-t, --token ', 'bounty token', 'USDC') - .option('-n, --network ', 'Stellar network: testnet or mainnet', 'testnet') - .option('--dry-run', 'validate and print the request without submitting') - .action(async (options) => { - const repoInput = options.repo || config.defaultRepo; - if (!repoInput) - throw new Error('Repository is required. Use --repo owner/repo or set defaultRepo in .issueflow.'); - const { owner, repo } = parseRepo(repoInput); - const issueNumber = parseIssueNumber(options.issue); - const amount = parseAmount(options.amount); - const token = parseToken(options.token); - const network = parseNetwork(options.network); - const octokit = createOctokit(); - const { data: issue } = await octokit.issues.get({ owner, repo, issue_number: issueNumber }); - const request = createBountyRequest({ repository: repoInput, issueNumber, issueTitle: issue.title, amount, token, network, dryRun: Boolean(options.dryRun) }); - printSummary(request); - if (options.dryRun) - return; - const result = await submitBountyRequest(request); - console.log(chalk_1.default.yellow(`\n${result.message}`)); - console.log(chalk_1.default.green('Bounty request prepared successfully.')); -}); program .command('label') .description('Assign a label to multiple GitHub issues at once') @@ -127,4 +132,35 @@ program console.log(`✓ Label "${options.label}" added to #${issueNumber}`); } }); +program + .command('create') + .description('Create GitHub issues in bulk from a markdown file') + .option('-r, --repo ', 'target repository (org/repo)') + .option('-f, --file ', 'markdown file with issues') + .action(async (options) => { + const { owner, repo } = parseRepo(options.repo); + const octokit = createOctokit(); + const fs = await Promise.resolve().then(() => __importStar(require('fs'))); + const content = fs.readFileSync(options.file, 'utf-8'); + const lines = content.split('\n'); + let title = ''; + let bodyLines = []; + for (const line of lines) { + if (line.startsWith('#')) { + if (title) { + await octokit.issues.create({ owner, repo, title, body: bodyLines.join('\n').trim() }); + console.log(`✓ Created issue: ${title}`); + bodyLines = []; + } + title = line.replace(/^#+\s*/, '').trim(); + } + else { + bodyLines.push(line); + } + } + if (title) { + await octokit.issues.create({ owner, repo, title, body: bodyLines.join('\n').trim() }); + console.log(`✓ Created issue: ${title}`); + } +}); program.parse(); diff --git a/src/index.ts b/src/index.ts index 823e813..56e1f4a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -117,5 +117,35 @@ program } }); +program + .command('create') + .description('Create GitHub issues in bulk from a markdown file') + .option('-r, --repo ', 'target repository (org/repo)') + .option('-f, --file ', 'markdown file with issues') + .action(async (options) => { + const { owner, repo } = parseRepo(options.repo); + const octokit = createOctokit(); + const fs = await import('fs'); + const content = fs.readFileSync(options.file, 'utf-8'); + const lines = content.split('\n'); + let title = ''; + let bodyLines: string[] = []; + for (const line of lines) { + if (line.startsWith('#')) { + if (title) { + await octokit.issues.create({ owner, repo, title, body: bodyLines.join('\n').trim() }); + console.log(`✓ Created issue: ${title}`); + bodyLines = []; + } + title = line.replace(/^#+\s*/, '').trim(); + } else { + bodyLines.push(line); + } + } + if (title) { + await octokit.issues.create({ owner, repo, title, body: bodyLines.join('\n').trim() }); + console.log(`✓ Created issue: ${title}`); + } + }); program.parse(); diff --git a/test-issues.md b/test-issues.md new file mode 100644 index 0000000..6c2c353 --- /dev/null +++ b/test-issues.md @@ -0,0 +1,5 @@ +# Test Issue 1 +This is a test issue created by the IssueFlow CLI. + +# Test Issue 2 +This verifies bulk creation works correctly.