@joynt/foundry 0.0.0-stage → 0.1.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backends/command.d.ts +37 -0
- package/dist/backends/command.d.ts.map +1 -0
- package/dist/backends/command.js +79 -0
- package/dist/backends/command.js.map +1 -0
- package/dist/backends/index.d.ts +9 -0
- package/dist/backends/index.d.ts.map +1 -0
- package/dist/backends/index.js +37 -0
- package/dist/backends/index.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +191 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/action.d.ts +6 -0
- package/dist/commands/action.d.ts.map +1 -0
- package/dist/commands/action.js +171 -0
- package/dist/commands/action.js.map +1 -0
- package/dist/commands/cancelled.d.ts +5 -0
- package/dist/commands/cancelled.d.ts.map +1 -0
- package/dist/commands/cancelled.js +107 -0
- package/dist/commands/cancelled.js.map +1 -0
- package/dist/commands/init.d.ts +5 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +323 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/preview.d.ts +4 -0
- package/dist/commands/preview.d.ts.map +1 -0
- package/dist/commands/preview.js +108 -0
- package/dist/commands/preview.js.map +1 -0
- package/dist/commands/release.d.ts +2 -0
- package/dist/commands/release.d.ts.map +1 -0
- package/dist/commands/release.js +89 -0
- package/dist/commands/release.js.map +1 -0
- package/dist/commands/report.d.ts +14 -0
- package/dist/commands/report.d.ts.map +1 -0
- package/dist/commands/report.js +91 -0
- package/dist/commands/report.js.map +1 -0
- package/dist/commands/reset.d.ts +4 -0
- package/dist/commands/reset.d.ts.map +1 -0
- package/dist/commands/reset.js +155 -0
- package/dist/commands/reset.js.map +1 -0
- package/dist/commands/review.d.ts +2 -0
- package/dist/commands/review.d.ts.map +1 -0
- package/dist/commands/review.js +73 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/setup-bot.d.ts +31 -0
- package/dist/commands/setup-bot.d.ts.map +1 -0
- package/dist/commands/setup-bot.js +429 -0
- package/dist/commands/setup-bot.js.map +1 -0
- package/dist/commands/sync.d.ts +2 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +77 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +147 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/agent-output.d.ts +49 -0
- package/dist/lib/agent-output.d.ts.map +1 -0
- package/dist/lib/agent-output.js +256 -0
- package/dist/lib/agent-output.js.map +1 -0
- package/dist/lib/agent-report.d.ts +107 -0
- package/dist/lib/agent-report.d.ts.map +1 -0
- package/dist/lib/agent-report.js +233 -0
- package/dist/lib/agent-report.js.map +1 -0
- package/dist/lib/authorize.d.ts +3 -0
- package/dist/lib/authorize.d.ts.map +1 -0
- package/dist/lib/authorize.js +67 -0
- package/dist/lib/authorize.js.map +1 -0
- package/dist/lib/branches.d.ts +22 -0
- package/dist/lib/branches.d.ts.map +1 -0
- package/dist/lib/branches.js +82 -0
- package/dist/lib/branches.js.map +1 -0
- package/dist/lib/claim.d.ts +22 -0
- package/dist/lib/claim.d.ts.map +1 -0
- package/dist/lib/claim.js +129 -0
- package/dist/lib/claim.js.map +1 -0
- package/dist/lib/completion.d.ts +5 -0
- package/dist/lib/completion.d.ts.map +1 -0
- package/dist/lib/completion.js +63 -0
- package/dist/lib/completion.js.map +1 -0
- package/dist/lib/deployments.d.ts +21 -0
- package/dist/lib/deployments.d.ts.map +1 -0
- package/dist/lib/deployments.js +104 -0
- package/dist/lib/deployments.js.map +1 -0
- package/dist/lib/event-handler.d.ts +74 -0
- package/dist/lib/event-handler.d.ts.map +1 -0
- package/dist/lib/event-handler.js +1002 -0
- package/dist/lib/event-handler.js.map +1 -0
- package/dist/lib/events.d.ts +72 -0
- package/dist/lib/events.d.ts.map +1 -0
- package/dist/lib/events.js +3 -0
- package/dist/lib/events.js.map +1 -0
- package/dist/lib/gh-cli-client.d.ts +46 -0
- package/dist/lib/gh-cli-client.d.ts.map +1 -0
- package/dist/lib/gh-cli-client.js +260 -0
- package/dist/lib/gh-cli-client.js.map +1 -0
- package/dist/lib/git.d.ts +42 -0
- package/dist/lib/git.d.ts.map +1 -0
- package/dist/lib/git.js +247 -0
- package/dist/lib/git.js.map +1 -0
- package/dist/lib/github-client.d.ts +98 -0
- package/dist/lib/github-client.d.ts.map +1 -0
- package/dist/lib/github-client.js +3 -0
- package/dist/lib/github-client.js.map +1 -0
- package/dist/lib/github.d.ts +82 -0
- package/dist/lib/github.d.ts.map +1 -0
- package/dist/lib/github.js +202 -0
- package/dist/lib/github.js.map +1 -0
- package/dist/lib/issue-file.d.ts +15 -0
- package/dist/lib/issue-file.d.ts.map +1 -0
- package/dist/lib/issue-file.js +84 -0
- package/dist/lib/issue-file.js.map +1 -0
- package/dist/lib/labels.d.ts +14 -0
- package/dist/lib/labels.d.ts.map +1 -0
- package/dist/lib/labels.js +70 -0
- package/dist/lib/labels.js.map +1 -0
- package/dist/lib/log.d.ts +11 -0
- package/dist/lib/log.d.ts.map +1 -0
- package/dist/lib/log.js +53 -0
- package/dist/lib/log.js.map +1 -0
- package/dist/lib/octokit-client.d.ts +112 -0
- package/dist/lib/octokit-client.d.ts.map +1 -0
- package/dist/lib/octokit-client.js +507 -0
- package/dist/lib/octokit-client.js.map +1 -0
- package/dist/lib/preview-verify.d.ts +48 -0
- package/dist/lib/preview-verify.d.ts.map +1 -0
- package/dist/lib/preview-verify.js +148 -0
- package/dist/lib/preview-verify.js.map +1 -0
- package/dist/lib/preview.d.ts +33 -0
- package/dist/lib/preview.d.ts.map +1 -0
- package/dist/lib/preview.js +308 -0
- package/dist/lib/preview.js.map +1 -0
- package/dist/lib/reconcile.d.ts +14 -0
- package/dist/lib/reconcile.d.ts.map +1 -0
- package/dist/lib/reconcile.js +114 -0
- package/dist/lib/reconcile.js.map +1 -0
- package/dist/lib/review.d.ts +38 -0
- package/dist/lib/review.d.ts.map +1 -0
- package/dist/lib/review.js +284 -0
- package/dist/lib/review.js.map +1 -0
- package/dist/lib/stale-prs.d.ts +31 -0
- package/dist/lib/stale-prs.d.ts.map +1 -0
- package/dist/lib/stale-prs.js +161 -0
- package/dist/lib/stale-prs.js.map +1 -0
- package/dist/lib/state-store.d.ts +23 -0
- package/dist/lib/state-store.d.ts.map +1 -0
- package/dist/lib/state-store.js +3 -0
- package/dist/lib/state-store.js.map +1 -0
- package/dist/lib/state.d.ts +23 -0
- package/dist/lib/state.d.ts.map +1 -0
- package/dist/lib/state.js +57 -0
- package/dist/lib/state.js.map +1 -0
- package/dist/lib/status-comment.d.ts +14 -0
- package/dist/lib/status-comment.d.ts.map +1 -0
- package/dist/lib/status-comment.js +195 -0
- package/dist/lib/status-comment.js.map +1 -0
- package/dist/lib/stores/file-store.d.ts +22 -0
- package/dist/lib/stores/file-store.d.ts.map +1 -0
- package/dist/lib/stores/file-store.js +172 -0
- package/dist/lib/stores/file-store.js.map +1 -0
- package/dist/lib/stores/index.d.ts +13 -0
- package/dist/lib/stores/index.d.ts.map +1 -0
- package/dist/lib/stores/index.js +20 -0
- package/dist/lib/stores/index.js.map +1 -0
- package/dist/lib/task-recovery.d.ts +22 -0
- package/dist/lib/task-recovery.d.ts.map +1 -0
- package/dist/lib/task-recovery.js +172 -0
- package/dist/lib/task-recovery.js.map +1 -0
- package/dist/lib/templates.d.ts +8 -0
- package/dist/lib/templates.d.ts.map +1 -0
- package/dist/lib/templates.js +58 -0
- package/dist/lib/templates.js.map +1 -0
- package/dist/lib/thread.d.ts +13 -0
- package/dist/lib/thread.d.ts.map +1 -0
- package/dist/lib/thread.js +75 -0
- package/dist/lib/thread.js.map +1 -0
- package/dist/lib/verify.d.ts +31 -0
- package/dist/lib/verify.d.ts.map +1 -0
- package/dist/lib/verify.js +90 -0
- package/dist/lib/verify.js.map +1 -0
- package/dist/lib/version.d.ts +9 -0
- package/dist/lib/version.d.ts.map +1 -0
- package/dist/lib/version.js +134 -0
- package/dist/lib/version.js.map +1 -0
- package/dist/lib/webhook.d.ts +39 -0
- package/dist/lib/webhook.d.ts.map +1 -0
- package/dist/lib/webhook.js +248 -0
- package/dist/lib/webhook.js.map +1 -0
- package/dist/lib/worker.d.ts +42 -0
- package/dist/lib/worker.d.ts.map +1 -0
- package/dist/lib/worker.js +9 -0
- package/dist/lib/worker.js.map +1 -0
- package/dist/lib/workers/index.d.ts +11 -0
- package/dist/lib/workers/index.d.ts.map +1 -0
- package/dist/lib/workers/index.js +18 -0
- package/dist/lib/workers/index.js.map +1 -0
- package/dist/lib/workers/subprocess.d.ts +8 -0
- package/dist/lib/workers/subprocess.d.ts.map +1 -0
- package/dist/lib/workers/subprocess.js +105 -0
- package/dist/lib/workers/subprocess.js.map +1 -0
- package/dist/lib/worktree.d.ts +21 -0
- package/dist/lib/worktree.d.ts.map +1 -0
- package/dist/lib/worktree.js +113 -0
- package/dist/lib/worktree.js.map +1 -0
- package/dist/types.d.ts +201 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +44 -4
- package/templates/foundry.yml +121 -0
- package/templates/vercel-preview-url.sh +61 -0
- package/README.md +0 -3
package/dist/lib/git.js
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
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
|
+
exports.hasCommits = hasCommits;
|
|
37
|
+
exports.currentBranch = currentBranch;
|
|
38
|
+
exports.branchExists = branchExists;
|
|
39
|
+
exports.remoteBranchExists = remoteBranchExists;
|
|
40
|
+
exports.fetchAll = fetchAll;
|
|
41
|
+
exports.checkout = checkout;
|
|
42
|
+
exports.createBranch = createBranch;
|
|
43
|
+
exports.push = push;
|
|
44
|
+
exports.countCommits = countCommits;
|
|
45
|
+
exports.isDirty = isDirty;
|
|
46
|
+
exports.deleteBranch = deleteBranch;
|
|
47
|
+
exports.deleteRemoteBranch = deleteRemoteBranch;
|
|
48
|
+
exports.rebase = rebase;
|
|
49
|
+
exports.merge = merge;
|
|
50
|
+
exports.tag = tag;
|
|
51
|
+
exports.pushTag = pushTag;
|
|
52
|
+
exports.addWorktree = addWorktree;
|
|
53
|
+
exports.addWorktreeTracking = addWorktreeTracking;
|
|
54
|
+
exports.pruneWorktrees = pruneWorktrees;
|
|
55
|
+
exports.removeWorktree = removeWorktree;
|
|
56
|
+
exports.listWorktrees = listWorktrees;
|
|
57
|
+
exports.worktreeExists = worktreeExists;
|
|
58
|
+
exports.repoRoot = repoRoot;
|
|
59
|
+
exports.headSha = headSha;
|
|
60
|
+
exports.slugify = slugify;
|
|
61
|
+
exports.resolveBranchName = resolveBranchName;
|
|
62
|
+
exports.resolveWorktreePath = resolveWorktreePath;
|
|
63
|
+
exports.workerId = workerId;
|
|
64
|
+
exports.getLatestTag = getLatestTag;
|
|
65
|
+
exports.commitAll = commitAll;
|
|
66
|
+
/**
|
|
67
|
+
* Git & worktree operations
|
|
68
|
+
*/
|
|
69
|
+
const node_child_process_1 = require("node:child_process");
|
|
70
|
+
const path = __importStar(require("node:path"));
|
|
71
|
+
const fs = __importStar(require("node:fs"));
|
|
72
|
+
function git(args, cwd) {
|
|
73
|
+
return (0, node_child_process_1.execFileSync)('git', args, {
|
|
74
|
+
cwd: cwd ?? process.cwd(),
|
|
75
|
+
encoding: 'utf-8',
|
|
76
|
+
timeout: 60_000,
|
|
77
|
+
env: { ...process.env },
|
|
78
|
+
}).trim();
|
|
79
|
+
}
|
|
80
|
+
function gitSafe(args, cwd) {
|
|
81
|
+
try {
|
|
82
|
+
return (0, node_child_process_1.execFileSync)('git', args, {
|
|
83
|
+
cwd: cwd ?? process.cwd(),
|
|
84
|
+
encoding: 'utf-8',
|
|
85
|
+
timeout: 60_000,
|
|
86
|
+
env: { ...process.env },
|
|
87
|
+
stdio: ['pipe', 'pipe', 'pipe'], // suppress stderr
|
|
88
|
+
}).trim();
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function hasCommits(cwd) {
|
|
95
|
+
return gitSafe(['rev-list', '--count', 'HEAD'], cwd) !== null;
|
|
96
|
+
}
|
|
97
|
+
// ── Branch operations ───────────────────────────────────────────────────
|
|
98
|
+
function currentBranch(cwd) {
|
|
99
|
+
return git(['rev-parse', '--abbrev-ref', 'HEAD'], cwd);
|
|
100
|
+
}
|
|
101
|
+
function branchExists(branch, cwd) {
|
|
102
|
+
return gitSafe(['rev-parse', '--verify', branch], cwd) !== null;
|
|
103
|
+
}
|
|
104
|
+
function remoteBranchExists(branch, cwd) {
|
|
105
|
+
return gitSafe(['rev-parse', '--verify', `origin/${branch}`], cwd) !== null;
|
|
106
|
+
}
|
|
107
|
+
function fetchAll(cwd) {
|
|
108
|
+
git(['fetch', '--all', '--prune'], cwd);
|
|
109
|
+
}
|
|
110
|
+
function checkout(branch, cwd) {
|
|
111
|
+
git(['checkout', branch], cwd);
|
|
112
|
+
}
|
|
113
|
+
function createBranch(branch, base, cwd) {
|
|
114
|
+
git(['checkout', '-b', branch, base], cwd);
|
|
115
|
+
}
|
|
116
|
+
function push(branch, cwd, force = false) {
|
|
117
|
+
const args = ['push', '-u', 'origin', branch];
|
|
118
|
+
if (force)
|
|
119
|
+
args.splice(1, 0, '--force-with-lease');
|
|
120
|
+
git(args, cwd);
|
|
121
|
+
}
|
|
122
|
+
/** Number of commits in a revision range, e.g. `origin/<integration>..HEAD`. 0 on any error. */
|
|
123
|
+
function countCommits(range, cwd) {
|
|
124
|
+
const out = gitSafe(['rev-list', '--count', range], cwd);
|
|
125
|
+
return out === null ? 0 : Number(out) || 0;
|
|
126
|
+
}
|
|
127
|
+
/** True when the working tree has uncommitted or untracked changes. */
|
|
128
|
+
function isDirty(cwd) {
|
|
129
|
+
const out = gitSafe(['status', '--porcelain'], cwd);
|
|
130
|
+
return out !== null && out.length > 0;
|
|
131
|
+
}
|
|
132
|
+
function deleteBranch(branch, cwd) {
|
|
133
|
+
gitSafe(['branch', '-D', branch], cwd);
|
|
134
|
+
}
|
|
135
|
+
function deleteRemoteBranch(branch, cwd) {
|
|
136
|
+
gitSafe(['push', 'origin', '--delete', branch], cwd);
|
|
137
|
+
}
|
|
138
|
+
function rebase(onto, cwd) {
|
|
139
|
+
git(['rebase', onto], cwd);
|
|
140
|
+
}
|
|
141
|
+
function merge(branch, cwd, noFf = false) {
|
|
142
|
+
const args = ['merge', branch];
|
|
143
|
+
if (noFf)
|
|
144
|
+
args.push('--no-ff');
|
|
145
|
+
git(args, cwd);
|
|
146
|
+
}
|
|
147
|
+
function tag(name, message, cwd) {
|
|
148
|
+
git(['tag', '-a', name, '-m', message], cwd);
|
|
149
|
+
}
|
|
150
|
+
function pushTag(name, cwd) {
|
|
151
|
+
git(['push', 'origin', name], cwd);
|
|
152
|
+
}
|
|
153
|
+
// ── Worktree operations ─────────────────────────────────────────────────
|
|
154
|
+
function addWorktree(worktreePath, branch, base, cwd) {
|
|
155
|
+
fs.mkdirSync(path.dirname(worktreePath), { recursive: true });
|
|
156
|
+
git(['worktree', 'add', '-b', branch, worktreePath, base], cwd);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Add a worktree for a branch that already exists on the remote. The local
|
|
160
|
+
* branch is created or reset to origin/<branch> and set to track it.
|
|
161
|
+
*/
|
|
162
|
+
function addWorktreeTracking(worktreePath, branch, cwd) {
|
|
163
|
+
fs.mkdirSync(path.dirname(worktreePath), { recursive: true });
|
|
164
|
+
git(['worktree', 'add', '-B', branch, '--track', worktreePath, `origin/${branch}`], cwd);
|
|
165
|
+
}
|
|
166
|
+
/** Drop worktree registrations whose directories no longer exist. */
|
|
167
|
+
function pruneWorktrees(cwd) {
|
|
168
|
+
gitSafe(['worktree', 'prune'], cwd);
|
|
169
|
+
}
|
|
170
|
+
function removeWorktree(worktreePath, cwd) {
|
|
171
|
+
gitSafe(['worktree', 'remove', worktreePath, '--force'], cwd);
|
|
172
|
+
}
|
|
173
|
+
function listWorktrees(cwd) {
|
|
174
|
+
const raw = git(['worktree', 'list', '--porcelain'], cwd);
|
|
175
|
+
const entries = [];
|
|
176
|
+
let current = {};
|
|
177
|
+
for (const line of raw.split('\n')) {
|
|
178
|
+
if (line.startsWith('worktree ')) {
|
|
179
|
+
current.path = line.slice('worktree '.length);
|
|
180
|
+
}
|
|
181
|
+
else if (line.startsWith('branch ')) {
|
|
182
|
+
current.branch = line.slice('branch refs/heads/'.length);
|
|
183
|
+
}
|
|
184
|
+
else if (line === '') {
|
|
185
|
+
if (current.path && current.branch) {
|
|
186
|
+
entries.push({ path: current.path, branch: current.branch });
|
|
187
|
+
}
|
|
188
|
+
current = {};
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (current.path && current.branch) {
|
|
192
|
+
entries.push({ path: current.path, branch: current.branch });
|
|
193
|
+
}
|
|
194
|
+
return entries;
|
|
195
|
+
}
|
|
196
|
+
/** Resolve symlinks so paths compare equal to what git reports (macOS: /var → /private/var). */
|
|
197
|
+
function canonical(p) {
|
|
198
|
+
try {
|
|
199
|
+
return fs.realpathSync.native(p);
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
return path.resolve(p);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function worktreeExists(worktreePath, cwd) {
|
|
206
|
+
const target = canonical(worktreePath);
|
|
207
|
+
return listWorktrees(cwd).some(w => canonical(w.path) === target);
|
|
208
|
+
}
|
|
209
|
+
// ── Utility ─────────────────────────────────────────────────────────────
|
|
210
|
+
function repoRoot(cwd) {
|
|
211
|
+
return git(['rev-parse', '--show-toplevel'], cwd);
|
|
212
|
+
}
|
|
213
|
+
function headSha(cwd) {
|
|
214
|
+
return git(['rev-parse', 'HEAD'], cwd);
|
|
215
|
+
}
|
|
216
|
+
function slugify(text) {
|
|
217
|
+
return text
|
|
218
|
+
.toLowerCase()
|
|
219
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
220
|
+
.replace(/^-+|-+$/g, '')
|
|
221
|
+
.slice(0, 40);
|
|
222
|
+
}
|
|
223
|
+
function resolveBranchName(template, issue, title) {
|
|
224
|
+
return template
|
|
225
|
+
.replace('{issue}', String(issue))
|
|
226
|
+
.replace('{slug}', slugify(title));
|
|
227
|
+
}
|
|
228
|
+
function resolveWorktreePath(base, issue, title, repoDir) {
|
|
229
|
+
const name = `${issue}-${slugify(title)}`;
|
|
230
|
+
return path.resolve(repoDir, base, name);
|
|
231
|
+
}
|
|
232
|
+
/** Stable id for a task's worker process. Stored as `tmux_session` on the task for historical reasons. */
|
|
233
|
+
function workerId(issue) {
|
|
234
|
+
return `foundry-${issue}`;
|
|
235
|
+
}
|
|
236
|
+
function getLatestTag(prefix, cwd) {
|
|
237
|
+
const raw = gitSafe(['tag', '--list', `${prefix}*`, '--sort=-v:refname'], cwd);
|
|
238
|
+
if (!raw)
|
|
239
|
+
return null;
|
|
240
|
+
const tags = raw.split('\n').filter(Boolean);
|
|
241
|
+
return tags[0] ?? null;
|
|
242
|
+
}
|
|
243
|
+
function commitAll(message, cwd) {
|
|
244
|
+
git(['add', '-A'], cwd);
|
|
245
|
+
git(['commit', '-m', message], cwd);
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/lib/git.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,gCAEC;AAID,sCAEC;AAED,oCAEC;AAED,gDAEC;AAED,4BAEC;AAED,4BAEC;AAED,oCAEC;AAED,oBAIC;AAGD,oCAGC;AAGD,0BAGC;AAED,oCAEC;AAED,gDAEC;AAED,wBAEC;AAED,sBAIC;AAED,kBAEC;AAED,0BAEC;AAID,kCAGC;AAMD,kDAGC;AAGD,wCAEC;AAED,wCAEC;AAED,sCAqBC;AAOD,wCAGC;AAID,4BAEC;AAED,0BAEC;AAED,0BAMC;AAED,8CAIC;AAED,kDAGC;AAGD,4BAEC;AAED,oCAKC;AAED,8BAGC;AA9MD;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,EAAE,mBAAmB,CAAC,EAAE,GAAG,CAAC,CAAC;IAC/E,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtB,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC7C,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AACzB,CAAC;AAED,SAAgB,SAAS,CAAC,OAAe,EAAE,GAAY;IACrD,GAAG,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;IACxB,GAAG,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHubClient interface — all GitHub operations go through this contract.
|
|
3
|
+
*/
|
|
4
|
+
import type { GitHubIssue, GitHubComment } from '../types.js';
|
|
5
|
+
export interface PRReview {
|
|
6
|
+
author: {
|
|
7
|
+
login: string;
|
|
8
|
+
};
|
|
9
|
+
state: string;
|
|
10
|
+
body: string;
|
|
11
|
+
submittedAt: string;
|
|
12
|
+
}
|
|
13
|
+
export interface PRReviewComment {
|
|
14
|
+
author: {
|
|
15
|
+
login: string;
|
|
16
|
+
};
|
|
17
|
+
body: string;
|
|
18
|
+
createdAt: string;
|
|
19
|
+
path: string;
|
|
20
|
+
line: number | null;
|
|
21
|
+
}
|
|
22
|
+
export interface CreatePROpts {
|
|
23
|
+
title: string;
|
|
24
|
+
body: string;
|
|
25
|
+
head: string;
|
|
26
|
+
base: string;
|
|
27
|
+
}
|
|
28
|
+
export interface CheckRunAnnotation {
|
|
29
|
+
path: string;
|
|
30
|
+
start_line: number;
|
|
31
|
+
end_line: number;
|
|
32
|
+
annotation_level: 'notice' | 'warning' | 'failure';
|
|
33
|
+
message: string;
|
|
34
|
+
}
|
|
35
|
+
export interface CheckRunOutput {
|
|
36
|
+
title: string;
|
|
37
|
+
summary: string;
|
|
38
|
+
annotations?: CheckRunAnnotation[];
|
|
39
|
+
}
|
|
40
|
+
export interface CreateCheckRunOpts {
|
|
41
|
+
name: string;
|
|
42
|
+
head_sha: string;
|
|
43
|
+
status?: 'queued' | 'in_progress' | 'completed';
|
|
44
|
+
conclusion?: 'success' | 'failure' | 'neutral' | 'cancelled' | 'timed_out' | 'action_required';
|
|
45
|
+
output?: CheckRunOutput;
|
|
46
|
+
}
|
|
47
|
+
export interface UpdateCheckRunOpts {
|
|
48
|
+
status?: 'queued' | 'in_progress' | 'completed';
|
|
49
|
+
conclusion?: 'success' | 'failure' | 'neutral' | 'cancelled' | 'timed_out' | 'action_required';
|
|
50
|
+
output?: CheckRunOutput;
|
|
51
|
+
}
|
|
52
|
+
export interface GitHubClient {
|
|
53
|
+
listIssuesByLabel(repo: string, label: string): Promise<GitHubIssue[]>;
|
|
54
|
+
getIssue(repo: string, issue: number): Promise<GitHubIssue>;
|
|
55
|
+
addLabel(repo: string, issue: number, label: string): Promise<void>;
|
|
56
|
+
removeLabel(repo: string, issue: number, label: string): Promise<void>;
|
|
57
|
+
addComment(repo: string, issue: number, body: string): Promise<void>;
|
|
58
|
+
getComments(repo: string, issue: number): Promise<GitHubComment[]>;
|
|
59
|
+
listLabels(repo: string): Promise<string[]>;
|
|
60
|
+
deleteLabel(repo: string, name: string): Promise<void>;
|
|
61
|
+
ensureLabel(repo: string, name: string, color: string, description: string): Promise<void>;
|
|
62
|
+
closeIssue(repo: string, issue: number): Promise<void>;
|
|
63
|
+
createPR(repo: string, opts: CreatePROpts): Promise<string>;
|
|
64
|
+
closePR(repo: string, pr: string | number): Promise<void>;
|
|
65
|
+
/** Replace a pull request's description. */
|
|
66
|
+
updatePRBody(repo: string, pr: string | number, body: string): Promise<void>;
|
|
67
|
+
getPRStatus(repo: string, branch: string): Promise<{
|
|
68
|
+
state: string;
|
|
69
|
+
url: string;
|
|
70
|
+
} | null>;
|
|
71
|
+
getPRBranch(repo: string, pr: string | number): Promise<string>;
|
|
72
|
+
mergePR(repo: string, pr: string | number, method?: 'merge' | 'rebase' | 'squash'): Promise<void>;
|
|
73
|
+
isPRMergeable(repo: string, pr: string | number): Promise<boolean>;
|
|
74
|
+
/** Tri-state: GitHub computes mergeability lazily after the base changes. */
|
|
75
|
+
getPRMergeability(repo: string, pr: number): Promise<'mergeable' | 'conflicting' | 'unknown'>;
|
|
76
|
+
listOpenPRs(repo: string, base: string): Promise<Array<{
|
|
77
|
+
number: number;
|
|
78
|
+
head: string;
|
|
79
|
+
}>>;
|
|
80
|
+
getPRReviews(repo: string, prNumber: number): Promise<{
|
|
81
|
+
reviews: PRReview[];
|
|
82
|
+
comments: PRReviewComment[];
|
|
83
|
+
}>;
|
|
84
|
+
commentOnPR(repo: string, prNumber: number, body: string): Promise<void>;
|
|
85
|
+
updateComment(repo: string, commentId: number, body: string): Promise<void>;
|
|
86
|
+
createReactionForIssueComment(repo: string, commentId: number, reaction: string): Promise<void>;
|
|
87
|
+
createCheckRun(repo: string, opts: CreateCheckRunOpts): Promise<number>;
|
|
88
|
+
updateCheckRun(repo: string, checkRunId: number, opts: UpdateCheckRunOpts): Promise<void>;
|
|
89
|
+
listCheckRuns(repo: string, sha: string): Promise<Array<{
|
|
90
|
+
name: string;
|
|
91
|
+
status: string;
|
|
92
|
+
conclusion: string | null;
|
|
93
|
+
}>>;
|
|
94
|
+
getRepoSlug(): Promise<string>;
|
|
95
|
+
/** The user's permission on the repo: admin, write, read, or none (maintain/triage collapse to write/read). */
|
|
96
|
+
getCollaboratorPermission(repo: string, username: string): Promise<string>;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=github-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-client.d.ts","sourceRoot":"","sources":["../../src/lib/github-client.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,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+1 @@
|
|
|
1
|
+
{"version":3,"file":"github-client.js","sourceRoot":"","sources":["../../src/lib/github-client.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub module — thin facade over GitHubClient.
|
|
3
|
+
*
|
|
4
|
+
* Provides a module-level singleton and delegating functions so existing
|
|
5
|
+
* call-sites (`github.addLabel(...)`) keep working. Tests inject a mock
|
|
6
|
+
* via `setClient()`.
|
|
7
|
+
*/
|
|
8
|
+
import type { GitHubClient, CreatePROpts, PRReview, PRReviewComment, CreateCheckRunOpts, UpdateCheckRunOpts } from './github-client.js';
|
|
9
|
+
import type { GitHubIssue, GitHubComment } from '../types.js';
|
|
10
|
+
import type { FoundryConfig } from '../types.js';
|
|
11
|
+
export type { PRReview, PRReviewComment, CreatePROpts, CreateCheckRunOpts, UpdateCheckRunOpts, CheckRunAnnotation, CheckRunOutput } from './github-client.js';
|
|
12
|
+
export type { GitHubClient } from './github-client.js';
|
|
13
|
+
export declare function setClient(client: GitHubClient): void;
|
|
14
|
+
export declare function getClient(): GitHubClient;
|
|
15
|
+
/**
|
|
16
|
+
* Initialize the GitHub client based on config and/or environment.
|
|
17
|
+
*
|
|
18
|
+
* Priority:
|
|
19
|
+
* 1. FOUNDRY_GITHUB_BACKEND env var
|
|
20
|
+
* 2. config.github_backend
|
|
21
|
+
* 3. Auto-detect: if GitHub App credentials exist for the current org → octokit
|
|
22
|
+
* 4. Default: gh-cli
|
|
23
|
+
*
|
|
24
|
+
* For the 'octokit' backend, auth is resolved from:
|
|
25
|
+
* 1. GitHub App credentials (env vars or ~/.joynt-foundry/github-app-{org}.*)
|
|
26
|
+
* 2. GITHUB_TOKEN env var
|
|
27
|
+
* 3. `gh auth token` (falls back to gh CLI for token)
|
|
28
|
+
*/
|
|
29
|
+
export declare function initClient(config?: FoundryConfig): Promise<void>;
|
|
30
|
+
export declare function listIssuesByLabel(repo: string, label: string): Promise<GitHubIssue[]>;
|
|
31
|
+
export declare function getIssue(repo: string, issue: number): Promise<GitHubIssue>;
|
|
32
|
+
export declare function addLabel(repo: string, issue: number, label: string): Promise<void>;
|
|
33
|
+
export declare function removeLabel(repo: string, issue: number, label: string): Promise<void>;
|
|
34
|
+
export declare function addComment(repo: string, issue: number, body: string): Promise<void>;
|
|
35
|
+
export declare function getComments(repo: string, issue: number): Promise<GitHubComment[]>;
|
|
36
|
+
export declare function listLabels(repo: string): Promise<string[]>;
|
|
37
|
+
export declare function deleteLabel(repo: string, name: string): Promise<void>;
|
|
38
|
+
export declare function ensureLabel(repo: string, name: string, color: string, description: string): Promise<void>;
|
|
39
|
+
export declare function closeIssue(repo: string, issue: number): Promise<void>;
|
|
40
|
+
export declare function closePR(repo: string, pr: string | number): Promise<void>;
|
|
41
|
+
export declare function updatePRBody(repo: string, pr: string | number, body: string): Promise<void>;
|
|
42
|
+
export declare function createPR(repo: string, opts: CreatePROpts): Promise<string>;
|
|
43
|
+
export declare function getPRStatus(repo: string, branch: string): Promise<{
|
|
44
|
+
state: string;
|
|
45
|
+
url: string;
|
|
46
|
+
} | null>;
|
|
47
|
+
export declare function getPRBranch(repo: string, pr: string | number): Promise<string>;
|
|
48
|
+
export declare function mergePR(repo: string, pr: string | number, method?: 'merge' | 'rebase' | 'squash'): Promise<void>;
|
|
49
|
+
export declare function getPRMergeability(repo: string, pr: number): Promise<'mergeable' | 'conflicting' | 'unknown'>;
|
|
50
|
+
export declare function listOpenPRs(repo: string, base: string): Promise<Array<{
|
|
51
|
+
number: number;
|
|
52
|
+
head: string;
|
|
53
|
+
}>>;
|
|
54
|
+
export declare function isPRMergeable(repo: string, pr: string | number): Promise<boolean>;
|
|
55
|
+
export declare function getPRReviews(repo: string, prNumber: number): Promise<{
|
|
56
|
+
reviews: PRReview[];
|
|
57
|
+
comments: PRReviewComment[];
|
|
58
|
+
}>;
|
|
59
|
+
export declare function commentOnPR(repo: string, prNumber: number, body: string): Promise<void>;
|
|
60
|
+
export declare function updateComment(repo: string, commentId: number, body: string): Promise<void>;
|
|
61
|
+
export declare function createReactionForIssueComment(repo: string, commentId: number, reaction: string): Promise<void>;
|
|
62
|
+
export declare function listCheckRuns(repo: string, sha: string): Promise<Array<{
|
|
63
|
+
name: string;
|
|
64
|
+
status: string;
|
|
65
|
+
conclusion: string | null;
|
|
66
|
+
}>>;
|
|
67
|
+
export declare function createCheckRun(repo: string, opts: CreateCheckRunOpts): Promise<number>;
|
|
68
|
+
export declare function updateCheckRun(repo: string, checkRunId: number, opts: UpdateCheckRunOpts): Promise<void>;
|
|
69
|
+
export declare function getCollaboratorPermission(repo: string, username: string): Promise<string>;
|
|
70
|
+
export declare function getRepoSlug(): Promise<string>;
|
|
71
|
+
/**
|
|
72
|
+
* Transition labels on an issue: fetch current labels, remove only those
|
|
73
|
+
* present, add only those missing. One `getIssue` call replaces N blind
|
|
74
|
+
* DELETE requests that would 404 when a label isn't present.
|
|
75
|
+
*
|
|
76
|
+
* @param currentLabels - If the caller already has the label set (e.g. from
|
|
77
|
+
* a recently-fetched GitHubIssue), pass it to skip the extra API call.
|
|
78
|
+
*/
|
|
79
|
+
export declare function transitionLabels(repo: string, issue: number, remove: string[], add: string[], currentLabels?: string[]): Promise<void>;
|
|
80
|
+
export declare function hasLabel(issue: GitHubIssue, label: string): boolean;
|
|
81
|
+
export declare function extractPRNumber(prUrl: string): number | null;
|
|
82
|
+
//# sourceMappingURL=github.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../src/lib/github.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxI,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aA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G,OAAO,CAAC,MAAM,CAAC,CAEtF;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAExG;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEzF;AAED,wBAAgB,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,CAE7C;AAID;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EAAE,EAChB,GAAG,EAAE,MAAM,EAAE,EACb,aAAa,CAAC,EAAE,MAAM,EAAE,GACvB,OAAO,CAAC,IAAI,CAAC,CAoBf;AAID,wBAAgB,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAEnE;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG5D"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setClient = setClient;
|
|
4
|
+
exports.getClient = getClient;
|
|
5
|
+
exports.initClient = initClient;
|
|
6
|
+
exports.listIssuesByLabel = listIssuesByLabel;
|
|
7
|
+
exports.getIssue = getIssue;
|
|
8
|
+
exports.addLabel = addLabel;
|
|
9
|
+
exports.removeLabel = removeLabel;
|
|
10
|
+
exports.addComment = addComment;
|
|
11
|
+
exports.getComments = getComments;
|
|
12
|
+
exports.listLabels = listLabels;
|
|
13
|
+
exports.deleteLabel = deleteLabel;
|
|
14
|
+
exports.ensureLabel = ensureLabel;
|
|
15
|
+
exports.closeIssue = closeIssue;
|
|
16
|
+
exports.closePR = closePR;
|
|
17
|
+
exports.updatePRBody = updatePRBody;
|
|
18
|
+
exports.createPR = createPR;
|
|
19
|
+
exports.getPRStatus = getPRStatus;
|
|
20
|
+
exports.getPRBranch = getPRBranch;
|
|
21
|
+
exports.mergePR = mergePR;
|
|
22
|
+
exports.getPRMergeability = getPRMergeability;
|
|
23
|
+
exports.listOpenPRs = listOpenPRs;
|
|
24
|
+
exports.isPRMergeable = isPRMergeable;
|
|
25
|
+
exports.getPRReviews = getPRReviews;
|
|
26
|
+
exports.commentOnPR = commentOnPR;
|
|
27
|
+
exports.updateComment = updateComment;
|
|
28
|
+
exports.createReactionForIssueComment = createReactionForIssueComment;
|
|
29
|
+
exports.listCheckRuns = listCheckRuns;
|
|
30
|
+
exports.createCheckRun = createCheckRun;
|
|
31
|
+
exports.updateCheckRun = updateCheckRun;
|
|
32
|
+
exports.getCollaboratorPermission = getCollaboratorPermission;
|
|
33
|
+
exports.getRepoSlug = getRepoSlug;
|
|
34
|
+
exports.transitionLabels = transitionLabels;
|
|
35
|
+
exports.hasLabel = hasLabel;
|
|
36
|
+
exports.extractPRNumber = extractPRNumber;
|
|
37
|
+
const gh_cli_client_js_1 = require("./gh-cli-client.js");
|
|
38
|
+
// ── Singleton ────────────────────────────────────────────────────────────
|
|
39
|
+
let _client = new gh_cli_client_js_1.GhCliClient();
|
|
40
|
+
function setClient(client) {
|
|
41
|
+
_client = client;
|
|
42
|
+
}
|
|
43
|
+
function getClient() {
|
|
44
|
+
return _client;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Initialize the GitHub client based on config and/or environment.
|
|
48
|
+
*
|
|
49
|
+
* Priority:
|
|
50
|
+
* 1. FOUNDRY_GITHUB_BACKEND env var
|
|
51
|
+
* 2. config.github_backend
|
|
52
|
+
* 3. Auto-detect: if GitHub App credentials exist for the current org → octokit
|
|
53
|
+
* 4. Default: gh-cli
|
|
54
|
+
*
|
|
55
|
+
* For the 'octokit' backend, auth is resolved from:
|
|
56
|
+
* 1. GitHub App credentials (env vars or ~/.joynt-foundry/github-app-{org}.*)
|
|
57
|
+
* 2. GITHUB_TOKEN env var
|
|
58
|
+
* 3. `gh auth token` (falls back to gh CLI for token)
|
|
59
|
+
*/
|
|
60
|
+
async function initClient(config) {
|
|
61
|
+
const envBackend = process.env.FOUNDRY_GITHUB_BACKEND;
|
|
62
|
+
const org = config?.repo?.split('/')[0];
|
|
63
|
+
let hasAppCreds = false;
|
|
64
|
+
if (org) {
|
|
65
|
+
const { appCredsExist } = await import('./octokit-client.js');
|
|
66
|
+
hasAppCreds = appCredsExist(org);
|
|
67
|
+
}
|
|
68
|
+
const backend = envBackend ?? config?.github_backend ?? (hasAppCreds ? 'octokit' : 'gh-cli');
|
|
69
|
+
if (backend === 'octokit' || hasAppCreds) {
|
|
70
|
+
const { OctokitClient } = await import('./octokit-client.js');
|
|
71
|
+
_client = new OctokitClient(undefined, org);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
_client = new gh_cli_client_js_1.GhCliClient();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// ── Delegate functions ───────────────────────────────────────────────────
|
|
78
|
+
function listIssuesByLabel(repo, label) {
|
|
79
|
+
return _client.listIssuesByLabel(repo, label);
|
|
80
|
+
}
|
|
81
|
+
function getIssue(repo, issue) {
|
|
82
|
+
return _client.getIssue(repo, issue);
|
|
83
|
+
}
|
|
84
|
+
function addLabel(repo, issue, label) {
|
|
85
|
+
return _client.addLabel(repo, issue, label);
|
|
86
|
+
}
|
|
87
|
+
function removeLabel(repo, issue, label) {
|
|
88
|
+
return _client.removeLabel(repo, issue, label);
|
|
89
|
+
}
|
|
90
|
+
function addComment(repo, issue, body) {
|
|
91
|
+
return _client.addComment(repo, issue, body);
|
|
92
|
+
}
|
|
93
|
+
function getComments(repo, issue) {
|
|
94
|
+
return _client.getComments(repo, issue);
|
|
95
|
+
}
|
|
96
|
+
function listLabels(repo) {
|
|
97
|
+
return _client.listLabels(repo);
|
|
98
|
+
}
|
|
99
|
+
function deleteLabel(repo, name) {
|
|
100
|
+
return _client.deleteLabel(repo, name);
|
|
101
|
+
}
|
|
102
|
+
function ensureLabel(repo, name, color, description) {
|
|
103
|
+
return _client.ensureLabel(repo, name, color, description);
|
|
104
|
+
}
|
|
105
|
+
function closeIssue(repo, issue) {
|
|
106
|
+
return _client.closeIssue(repo, issue);
|
|
107
|
+
}
|
|
108
|
+
function closePR(repo, pr) {
|
|
109
|
+
return _client.closePR(repo, pr);
|
|
110
|
+
}
|
|
111
|
+
function updatePRBody(repo, pr, body) {
|
|
112
|
+
return _client.updatePRBody(repo, pr, body);
|
|
113
|
+
}
|
|
114
|
+
function createPR(repo, opts) {
|
|
115
|
+
return _client.createPR(repo, opts);
|
|
116
|
+
}
|
|
117
|
+
function getPRStatus(repo, branch) {
|
|
118
|
+
return _client.getPRStatus(repo, branch);
|
|
119
|
+
}
|
|
120
|
+
function getPRBranch(repo, pr) {
|
|
121
|
+
return _client.getPRBranch(repo, pr);
|
|
122
|
+
}
|
|
123
|
+
function mergePR(repo, pr, method) {
|
|
124
|
+
return _client.mergePR(repo, pr, method);
|
|
125
|
+
}
|
|
126
|
+
function getPRMergeability(repo, pr) {
|
|
127
|
+
return _client.getPRMergeability(repo, pr);
|
|
128
|
+
}
|
|
129
|
+
function listOpenPRs(repo, base) {
|
|
130
|
+
return _client.listOpenPRs(repo, base);
|
|
131
|
+
}
|
|
132
|
+
function isPRMergeable(repo, pr) {
|
|
133
|
+
return _client.isPRMergeable(repo, pr);
|
|
134
|
+
}
|
|
135
|
+
function getPRReviews(repo, prNumber) {
|
|
136
|
+
return _client.getPRReviews(repo, prNumber);
|
|
137
|
+
}
|
|
138
|
+
function commentOnPR(repo, prNumber, body) {
|
|
139
|
+
return _client.commentOnPR(repo, prNumber, body);
|
|
140
|
+
}
|
|
141
|
+
function updateComment(repo, commentId, body) {
|
|
142
|
+
return _client.updateComment(repo, commentId, body);
|
|
143
|
+
}
|
|
144
|
+
function createReactionForIssueComment(repo, commentId, reaction) {
|
|
145
|
+
return _client.createReactionForIssueComment(repo, commentId, reaction);
|
|
146
|
+
}
|
|
147
|
+
function listCheckRuns(repo, sha) {
|
|
148
|
+
return _client.listCheckRuns(repo, sha);
|
|
149
|
+
}
|
|
150
|
+
function createCheckRun(repo, opts) {
|
|
151
|
+
return _client.createCheckRun(repo, opts);
|
|
152
|
+
}
|
|
153
|
+
function updateCheckRun(repo, checkRunId, opts) {
|
|
154
|
+
return _client.updateCheckRun(repo, checkRunId, opts);
|
|
155
|
+
}
|
|
156
|
+
function getCollaboratorPermission(repo, username) {
|
|
157
|
+
return _client.getCollaboratorPermission(repo, username);
|
|
158
|
+
}
|
|
159
|
+
function getRepoSlug() {
|
|
160
|
+
return _client.getRepoSlug();
|
|
161
|
+
}
|
|
162
|
+
// ── Label transitions ────────────────────────────────────────────────────
|
|
163
|
+
/**
|
|
164
|
+
* Transition labels on an issue: fetch current labels, remove only those
|
|
165
|
+
* present, add only those missing. One `getIssue` call replaces N blind
|
|
166
|
+
* DELETE requests that would 404 when a label isn't present.
|
|
167
|
+
*
|
|
168
|
+
* @param currentLabels - If the caller already has the label set (e.g. from
|
|
169
|
+
* a recently-fetched GitHubIssue), pass it to skip the extra API call.
|
|
170
|
+
*/
|
|
171
|
+
async function transitionLabels(repo, issue, remove, add, currentLabels) {
|
|
172
|
+
if (remove.length === 0 && add.length === 0)
|
|
173
|
+
return;
|
|
174
|
+
let labels = currentLabels;
|
|
175
|
+
if (!labels) {
|
|
176
|
+
const iss = await _client.getIssue(repo, issue);
|
|
177
|
+
labels = iss.labels.map(l => l.name);
|
|
178
|
+
}
|
|
179
|
+
const present = new Set(labels);
|
|
180
|
+
for (const label of remove) {
|
|
181
|
+
if (present.has(label)) {
|
|
182
|
+
try {
|
|
183
|
+
await _client.removeLabel(repo, issue, label);
|
|
184
|
+
}
|
|
185
|
+
catch { }
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
for (const label of add) {
|
|
189
|
+
if (!present.has(label)) {
|
|
190
|
+
await _client.addLabel(repo, issue, label);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
// ── Pure logic (no interface needed) ─────────────────────────────────────
|
|
195
|
+
function hasLabel(issue, label) {
|
|
196
|
+
return issue.labels.some(l => l.name === label);
|
|
197
|
+
}
|
|
198
|
+
function extractPRNumber(prUrl) {
|
|
199
|
+
const match = prUrl.match(/\/pull\/(\d+)/);
|
|
200
|
+
return match ? Number(match[1]) : null;
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=github.js.map
|