@jjdenhertog/ai-driven-development
Version:
AI-driven development workflow with learning capabilities for Claude
45 lines • 2.46 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createTaskPR = createTaskPR;
/* eslint-disable @typescript-eslint/prefer-regexp-exec */
const node_child_process_1 = require("node:child_process");
const logger_1 = require("../logger");
const getPRContent_1 = require("./getPRContent");
const updateTaskFile_1 = require("./updateTaskFile");
function createTaskPR(task, branchName, worktreePath) {
return __awaiter(this, void 0, void 0, function* () {
(0, logger_1.log)('Preparing to create pull request...', 'info');
try {
// Get PR content
const prContent = (0, getPRContent_1.getPRContent)(task);
const title = `${task.id}: ${task.name}`;
// Create PR
(0, logger_1.log)('Creating pull request...', 'info');
const prOutput = (0, node_child_process_1.execSync)(`gh pr create --title "${title}" --body "${prContent}" --base main --head ${branchName}`, { encoding: 'utf8', cwd: worktreePath });
// Extract PR URL from output
const prUrlMatch = prOutput.match(/https:\/\/github\.com\/[\w-]+\/[\w-]+\/pull\/\d+/);
if (prUrlMatch) {
const [prUrl] = prUrlMatch;
(0, logger_1.log)(`Pull request created: ${prUrl}`, 'success');
// Update task file with PR URL
(0, updateTaskFile_1.updateTaskFile)(task.path, {
pr_url: prUrl,
pr_created_at: new Date().toISOString()
});
}
}
catch (error) {
(0, logger_1.log)(`Failed to create PR: ${error instanceof Error ? error.message : String(error)}`, 'error');
}
});
}
//# sourceMappingURL=createTaskPR.js.map