forked from StellarDevHub/soroban-playground
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_issues.js
More file actions
38 lines (30 loc) · 1.33 KB
/
Copy pathcreate_issues.js
File metadata and controls
38 lines (30 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const fs = require('fs');
const { execSync } = require('child_process');
const path = require('path');
const files = fs.readdirSync(__dirname).filter(f => f.startsWith('ISSUE_') && f.endsWith('.md'));
console.log(`Found ${files.length} issue files.`);
for (const file of files) {
const content = fs.readFileSync(path.join(__dirname, file), 'utf-8');
// Extract title using regex
const titleMatch = content.match(/title:\s*"?(.*?)"?\s*\n/);
const title = titleMatch ? titleMatch[1] : `Issue from ${file}`;
// Extract labels using regex
const labelsMatch = content.match(/labels:\s*(.*?)\s*\n/);
const labelsStr = labelsMatch ? labelsMatch[1].replace(/['"]/g, '') : '';
const labelsArg = labelsStr ? `--label "${labelsStr}"` : '';
// Remove frontmatter
const body = content.replace(/^---[\s\S]*?---\n*/, '');
// Save body to a temp file
const tempFile = path.join(__dirname, `temp_body_${file}`);
fs.writeFileSync(tempFile, body);
try {
console.log(`Creating issue: ${title}`);
const cmd = `gh issue create --title "${title}" --body-file "${tempFile}" ${labelsArg}`;
const output = execSync(cmd, { encoding: 'utf-8' });
console.log(`Success: ${output.trim()}`);
} catch (error) {
console.error(`Failed to create issue for ${file}:`, error.message);
} finally {
fs.unlinkSync(tempFile);
}
}