gitship-core 0.0.2 → 0.0.3
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/db.d.ts +31 -0
- package/dist/db.js +325 -0
- package/dist/db.js.map +1 -0
- package/dist/engine.d.ts +2 -0
- package/dist/engine.js +373 -0
- package/dist/engine.js.map +1 -0
- package/dist/github.d.ts +25 -0
- package/dist/github.js +98 -0
- package/dist/github.js.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/paths.d.ts +13 -0
- package/dist/paths.js +33 -0
- package/dist/paths.js.map +1 -0
- package/dist/queue.d.ts +10 -0
- package/dist/queue.js +102 -0
- package/dist/queue.js.map +1 -0
- package/package.json +4 -1
- package/src/db.ts +0 -425
- package/src/engine.ts +0 -477
- package/src/github.ts +0 -124
- package/src/paths.ts +0 -35
- package/src/queue.ts +0 -130
- package/tsconfig.json +0 -8
- /package/{src/index.ts → dist/index.d.ts} +0 -0
package/dist/engine.js
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { execa } from "execa";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { nanoid } from "nanoid";
|
|
5
|
+
import { updateDeploymentStatus, createDeploymentStep, updateDeploymentStep, appendDeploymentLog, getDeployment, } from "./db.js";
|
|
6
|
+
import { BUILDS_DIR, readAuthConfig } from "./paths.js";
|
|
7
|
+
import { activeProcesses } from "./queue.js";
|
|
8
|
+
export async function runDeploymentPipeline(project, deployment) {
|
|
9
|
+
const auth = readAuthConfig();
|
|
10
|
+
const token = auth.github_token;
|
|
11
|
+
if (!token) {
|
|
12
|
+
const errorMsg = "Error: GitHub authentication token is missing. Please run 'deploykit auth github'.\n";
|
|
13
|
+
appendDeploymentLog(deployment.id, errorMsg);
|
|
14
|
+
updateDeploymentStatus(deployment.id, "FAILED", {
|
|
15
|
+
finished_at: Date.now(),
|
|
16
|
+
total_duration_ms: 0,
|
|
17
|
+
});
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
// Prevent shell command injection via branch or commit SHA inputs
|
|
21
|
+
const safeBranchRegex = /^[a-zA-Z0-9/_.-]+$/;
|
|
22
|
+
if (!safeBranchRegex.test(deployment.branch)) {
|
|
23
|
+
const errorMsg = `Error: Unsafe branch name format: "${deployment.branch}". Deployment aborted.\n`;
|
|
24
|
+
appendDeploymentLog(deployment.id, errorMsg);
|
|
25
|
+
updateDeploymentStatus(deployment.id, "FAILED", {
|
|
26
|
+
finished_at: Date.now(),
|
|
27
|
+
total_duration_ms: 0,
|
|
28
|
+
});
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (deployment.commit_sha && !/^[a-zA-Z0-9]+$/.test(deployment.commit_sha)) {
|
|
32
|
+
const errorMsg = `Error: Unsafe commit SHA format: "${deployment.commit_sha}". Deployment aborted.\n`;
|
|
33
|
+
appendDeploymentLog(deployment.id, errorMsg);
|
|
34
|
+
updateDeploymentStatus(deployment.id, "FAILED", {
|
|
35
|
+
finished_at: Date.now(),
|
|
36
|
+
total_duration_ms: 0,
|
|
37
|
+
});
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const startTime = Date.now();
|
|
41
|
+
updateDeploymentStatus(deployment.id, "RUNNING", { started_at: startTime });
|
|
42
|
+
appendDeploymentLog(deployment.id, `=== Starting deployment ${deployment.id} for project "${project.name}" ===\n` +
|
|
43
|
+
`Branch: ${deployment.branch}\n` +
|
|
44
|
+
`Commit: ${deployment.commit_sha || "latest"}\n` +
|
|
45
|
+
`Author: ${deployment.author || "system"}\n` +
|
|
46
|
+
`Target: ${project.target_type} (${project.target_type === "ssh"
|
|
47
|
+
? `${project.target_host}:${project.target_path}`
|
|
48
|
+
: project.target_path})\n\n`);
|
|
49
|
+
let status = "SUCCESS";
|
|
50
|
+
try {
|
|
51
|
+
// Step 1: Clone or Pull
|
|
52
|
+
const cloneSuccess = await runStep(deployment.id, "clone", async (log) => {
|
|
53
|
+
// Double check cancellation
|
|
54
|
+
checkCancelled(deployment.id);
|
|
55
|
+
const repoUrl = `https://${token}@github.com/${project.owner}/${project.repo}.git`;
|
|
56
|
+
if (project.target_type === "local") {
|
|
57
|
+
const projectPath = path.join(BUILDS_DIR, project.name);
|
|
58
|
+
if (!fs.existsSync(projectPath)) {
|
|
59
|
+
log(`Cloning repository into local path ${projectPath}...\n`);
|
|
60
|
+
await execLocal(deployment.id, "git", ["clone", "--branch", deployment.branch, repoUrl, "."], BUILDS_DIR, project.name, // create dir
|
|
61
|
+
log);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
log(`Repository directory exists. Fetching latest changes...\n`);
|
|
65
|
+
await execLocal(deployment.id, "git", ["fetch", "origin"], projectPath, undefined, log);
|
|
66
|
+
const checkoutTarget = deployment.commit_sha || `origin/${deployment.branch}`;
|
|
67
|
+
log(`Checking out target: ${checkoutTarget}...\n`);
|
|
68
|
+
await execLocal(deployment.id, "git", ["checkout", "-B", deployment.branch], projectPath, undefined, log);
|
|
69
|
+
await execLocal(deployment.id, "git", ["reset", "--hard", checkoutTarget], projectPath, undefined, log);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
// SSH Target
|
|
74
|
+
const port = project.target_host?.split(":")[1] || "22";
|
|
75
|
+
const host = project.target_host?.split(":")[0] || "";
|
|
76
|
+
log(`Ensuring target path ${project.target_path} exists on remote server...\n`);
|
|
77
|
+
await execSSH(deployment.id, host, port, `mkdir -p ${project.target_path}`, log);
|
|
78
|
+
// Check if git repository exists on the remote target path
|
|
79
|
+
log(`Checking if repository is already initialized on remote...\n`);
|
|
80
|
+
let isInitialized = false;
|
|
81
|
+
try {
|
|
82
|
+
await execSSH(deployment.id, host, port, `cd ${project.target_path} && git rev-parse --is-inside-work-tree`, () => { });
|
|
83
|
+
isInitialized = true;
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
isInitialized = false;
|
|
87
|
+
}
|
|
88
|
+
checkCancelled(deployment.id);
|
|
89
|
+
if (!isInitialized) {
|
|
90
|
+
log(`Cloning repository on remote server into ${project.target_path}...\n`);
|
|
91
|
+
await execSSH(deployment.id, host, port, `git clone --branch ${deployment.branch} ${repoUrl} ${project.target_path}`, log);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
log(`Fetching updates on remote server...\n`);
|
|
95
|
+
await execSSH(deployment.id, host, port, `cd ${project.target_path} && git fetch origin`, log);
|
|
96
|
+
const checkoutTarget = deployment.commit_sha || `origin/${deployment.branch}`;
|
|
97
|
+
log(`Checking out target on remote server: ${checkoutTarget}...\n`);
|
|
98
|
+
await execSSH(deployment.id, host, port, `cd ${project.target_path} && git checkout -B ${deployment.branch} && git reset --hard ${checkoutTarget}`, log);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
if (!cloneSuccess)
|
|
103
|
+
throw new Error("Step 'clone' failed.");
|
|
104
|
+
// Step 2: Install dependencies
|
|
105
|
+
if (project.install_cmd) {
|
|
106
|
+
const installSuccess = await runStep(deployment.id, "install", async (log) => {
|
|
107
|
+
checkCancelled(deployment.id);
|
|
108
|
+
log(`Running install command: ${project.install_cmd}\n`);
|
|
109
|
+
if (project.target_type === "local") {
|
|
110
|
+
const projectPath = path.join(BUILDS_DIR, project.name);
|
|
111
|
+
await execShell(deployment.id, project.install_cmd, projectPath, log);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
const port = project.target_host?.split(":")[1] || "22";
|
|
115
|
+
const host = project.target_host?.split(":")[0] || "";
|
|
116
|
+
await execSSH(deployment.id, host, port, `cd ${project.target_path} && ${project.install_cmd}`, log);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
if (!installSuccess)
|
|
120
|
+
throw new Error("Step 'install' failed.");
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
skipStep(deployment.id, "install");
|
|
124
|
+
}
|
|
125
|
+
// Step 3: Build project
|
|
126
|
+
if (project.build_cmd) {
|
|
127
|
+
const buildSuccess = await runStep(deployment.id, "build", async (log) => {
|
|
128
|
+
checkCancelled(deployment.id);
|
|
129
|
+
log(`Running build command: ${project.build_cmd}\n`);
|
|
130
|
+
if (project.target_type === "local") {
|
|
131
|
+
const projectPath = path.join(BUILDS_DIR, project.name);
|
|
132
|
+
await execShell(deployment.id, project.build_cmd, projectPath, log);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
const port = project.target_host?.split(":")[1] || "22";
|
|
136
|
+
const host = project.target_host?.split(":")[0] || "";
|
|
137
|
+
await execSSH(deployment.id, host, port, `cd ${project.target_path} && ${project.build_cmd}`, log);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
if (!buildSuccess)
|
|
141
|
+
throw new Error("Step 'build' failed.");
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
skipStep(deployment.id, "build");
|
|
145
|
+
}
|
|
146
|
+
// Step 4: Restart application
|
|
147
|
+
if (project.restart_cmd) {
|
|
148
|
+
const restartSuccess = await runStep(deployment.id, "restart", async (log) => {
|
|
149
|
+
checkCancelled(deployment.id);
|
|
150
|
+
log(`Running restart command: ${project.restart_cmd}\n`);
|
|
151
|
+
if (project.target_type === "local") {
|
|
152
|
+
const projectPath = path.join(BUILDS_DIR, project.name);
|
|
153
|
+
await execShell(deployment.id, project.restart_cmd, projectPath, log);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
const port = project.target_host?.split(":")[1] || "22";
|
|
157
|
+
const host = project.target_host?.split(":")[0] || "";
|
|
158
|
+
await execSSH(deployment.id, host, port, `cd ${project.target_path} && ${project.restart_cmd}`, log);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
if (!restartSuccess)
|
|
162
|
+
throw new Error("Step 'restart' failed.");
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
skipStep(deployment.id, "restart");
|
|
166
|
+
}
|
|
167
|
+
// Step 5: Health Check
|
|
168
|
+
if (project.healthcheck_path) {
|
|
169
|
+
const healthSuccess = await runStep(deployment.id, "healthcheck", async (log) => {
|
|
170
|
+
checkCancelled(deployment.id);
|
|
171
|
+
const pathStr = project.healthcheck_path || "/";
|
|
172
|
+
const portNum = project.healthcheck_port;
|
|
173
|
+
const retries = project.healthcheck_retries || 5;
|
|
174
|
+
const interval = project.healthcheck_interval_ms || 1000;
|
|
175
|
+
const timeout = project.healthcheck_timeout_ms || 2000;
|
|
176
|
+
const url = portNum ? `http://localhost:${portNum}${pathStr}` : `http://localhost${pathStr}`;
|
|
177
|
+
log(`Performing health check on: ${url} (Retries: ${retries}, Interval: ${interval}ms)\n`);
|
|
178
|
+
let lastError = null;
|
|
179
|
+
for (let i = 1; i <= retries; i++) {
|
|
180
|
+
checkCancelled(deployment.id);
|
|
181
|
+
log(`Attempt ${i} of ${retries}... `);
|
|
182
|
+
try {
|
|
183
|
+
if (project.target_type === "local") {
|
|
184
|
+
const controller = new AbortController();
|
|
185
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
186
|
+
const res = await fetch(url, { signal: controller.signal });
|
|
187
|
+
clearTimeout(timeoutId);
|
|
188
|
+
if (res.ok) {
|
|
189
|
+
log(`OK (${res.status})\n`);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
throw new Error(`HTTP status ${res.status}`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
// SSH Target
|
|
198
|
+
const sshPort = project.target_host?.split(":")[1] || "22";
|
|
199
|
+
const host = project.target_host?.split(":")[0] || "";
|
|
200
|
+
const maxTimeSecs = Math.max(1, Math.round(timeout / 1000));
|
|
201
|
+
await execSSH(deployment.id, host, sshPort, `curl -s -f --max-time ${maxTimeSecs} ${url}`, () => { });
|
|
202
|
+
log(`OK (exit code 0)\n`);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
catch (err) {
|
|
207
|
+
lastError = err;
|
|
208
|
+
log(`FAILED: ${err.message || err}\n`);
|
|
209
|
+
if (i < retries) {
|
|
210
|
+
await new Promise((r) => setTimeout(r, interval));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
throw new Error(`Health check failed after ${retries} retries. Last error: ${lastError?.message || lastError}`);
|
|
215
|
+
});
|
|
216
|
+
if (!healthSuccess)
|
|
217
|
+
throw new Error("Step 'healthcheck' failed.");
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
skipStep(deployment.id, "healthcheck");
|
|
221
|
+
}
|
|
222
|
+
// Check if cancelled at the very end
|
|
223
|
+
const currentDep = getDeployment(deployment.id);
|
|
224
|
+
if (currentDep?.status === "CANCELLED") {
|
|
225
|
+
status = "CANCELLED";
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
appendDeploymentLog(deployment.id, `\n=== Deployment SUCCESS ===\n`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
catch (err) {
|
|
232
|
+
const currentDep = getDeployment(deployment.id);
|
|
233
|
+
if (currentDep?.status === "CANCELLED") {
|
|
234
|
+
status = "CANCELLED";
|
|
235
|
+
appendDeploymentLog(deployment.id, `\n=== Deployment CANCELLED ===\n`);
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
status = "FAILED";
|
|
239
|
+
appendDeploymentLog(deployment.id, `\n=== Deployment FAILED ===\nReason: ${err.message || err}\n`);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
const endTime = Date.now();
|
|
244
|
+
const duration = endTime - startTime;
|
|
245
|
+
updateDeploymentStatus(deployment.id, status, {
|
|
246
|
+
finished_at: endTime,
|
|
247
|
+
total_duration_ms: duration,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function checkCancelled(deploymentId) {
|
|
252
|
+
const currentDep = getDeployment(deploymentId);
|
|
253
|
+
if (currentDep?.status === "CANCELLED") {
|
|
254
|
+
throw new Error("Deployment cancelled by user.");
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
// Execa locally helper
|
|
258
|
+
async function execLocal(deploymentId, cmd, args, cwd, createDir, log) {
|
|
259
|
+
const finalCwd = createDir ? cwd : cwd;
|
|
260
|
+
if (createDir) {
|
|
261
|
+
fs.mkdirSync(path.join(cwd, createDir), { recursive: true });
|
|
262
|
+
}
|
|
263
|
+
const proc = execa(cmd, args, {
|
|
264
|
+
cwd: createDir ? path.join(cwd, createDir) : finalCwd,
|
|
265
|
+
all: true,
|
|
266
|
+
});
|
|
267
|
+
activeProcesses.set(deploymentId, proc);
|
|
268
|
+
if (log && proc.all) {
|
|
269
|
+
proc.all.on("data", (chunk) => {
|
|
270
|
+
log(chunk.toString());
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
try {
|
|
274
|
+
await proc;
|
|
275
|
+
}
|
|
276
|
+
finally {
|
|
277
|
+
activeProcesses.delete(deploymentId);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
// Execa locally with shell helper
|
|
281
|
+
async function execShell(deploymentId, cmd, cwd, log) {
|
|
282
|
+
const proc = execa({ shell: true, cwd, all: true }) `${cmd}`;
|
|
283
|
+
activeProcesses.set(deploymentId, proc);
|
|
284
|
+
if (proc.all) {
|
|
285
|
+
proc.all.on("data", (chunk) => {
|
|
286
|
+
log(chunk.toString());
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
try {
|
|
290
|
+
await proc;
|
|
291
|
+
}
|
|
292
|
+
finally {
|
|
293
|
+
activeProcesses.delete(deploymentId);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
// Execa SSH command helper
|
|
297
|
+
async function execSSH(deploymentId, host, port, cmd, log) {
|
|
298
|
+
// Execute via SSH CLI
|
|
299
|
+
const proc = execa("ssh", ["-o", "StrictHostKeyChecking=no", "-p", port, host, cmd], {
|
|
300
|
+
all: true,
|
|
301
|
+
});
|
|
302
|
+
activeProcesses.set(deploymentId, proc);
|
|
303
|
+
if (proc.all) {
|
|
304
|
+
proc.all.on("data", (chunk) => {
|
|
305
|
+
log(chunk.toString());
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
try {
|
|
309
|
+
await proc;
|
|
310
|
+
}
|
|
311
|
+
finally {
|
|
312
|
+
activeProcesses.delete(deploymentId);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
async function runStep(deploymentId, name, fn) {
|
|
316
|
+
const stepId = nanoid();
|
|
317
|
+
const startTime = Date.now();
|
|
318
|
+
const step = {
|
|
319
|
+
id: stepId,
|
|
320
|
+
deployment_id: deploymentId,
|
|
321
|
+
step_name: name,
|
|
322
|
+
status: "RUNNING",
|
|
323
|
+
started_at: startTime,
|
|
324
|
+
finished_at: null,
|
|
325
|
+
duration_ms: null,
|
|
326
|
+
};
|
|
327
|
+
createDeploymentStep(step);
|
|
328
|
+
appendDeploymentLog(deploymentId, `[Step: ${name}] Started...\n`);
|
|
329
|
+
try {
|
|
330
|
+
await fn((text) => {
|
|
331
|
+
appendDeploymentLog(deploymentId, text);
|
|
332
|
+
});
|
|
333
|
+
// Check cancellation again
|
|
334
|
+
checkCancelled(deploymentId);
|
|
335
|
+
const endTime = Date.now();
|
|
336
|
+
const duration = endTime - startTime;
|
|
337
|
+
updateDeploymentStep(stepId, {
|
|
338
|
+
status: "SUCCESS",
|
|
339
|
+
finished_at: endTime,
|
|
340
|
+
duration_ms: duration,
|
|
341
|
+
});
|
|
342
|
+
appendDeploymentLog(deploymentId, `[Step: ${name}] Completed successfully (${Math.round(duration / 1000)}s).\n\n`);
|
|
343
|
+
return true;
|
|
344
|
+
}
|
|
345
|
+
catch (err) {
|
|
346
|
+
const endTime = Date.now();
|
|
347
|
+
const duration = endTime - startTime;
|
|
348
|
+
const currentDep = getDeployment(deploymentId);
|
|
349
|
+
const isCancelled = currentDep?.status === "CANCELLED";
|
|
350
|
+
updateDeploymentStep(stepId, {
|
|
351
|
+
status: isCancelled ? "FAILED" : "FAILED", // or can mark as cancelled if step structure supported it, but FAILED is robust
|
|
352
|
+
finished_at: endTime,
|
|
353
|
+
duration_ms: duration,
|
|
354
|
+
});
|
|
355
|
+
appendDeploymentLog(deploymentId, `[Step: ${name}] ${isCancelled ? 'Cancelled' : 'Failed'} (${Math.round(duration / 1000)}s).\nError detail: ${err.message || err}\n\n`);
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
function skipStep(deploymentId, name) {
|
|
360
|
+
const stepId = nanoid();
|
|
361
|
+
const step = {
|
|
362
|
+
id: stepId,
|
|
363
|
+
deployment_id: deploymentId,
|
|
364
|
+
step_name: name,
|
|
365
|
+
status: "SUCCESS",
|
|
366
|
+
started_at: Date.now(),
|
|
367
|
+
finished_at: Date.now(),
|
|
368
|
+
duration_ms: 0,
|
|
369
|
+
};
|
|
370
|
+
createDeploymentStep(step);
|
|
371
|
+
appendDeploymentLog(deploymentId, `[Step: ${name}] Skipped (not configured).\n\n`);
|
|
372
|
+
}
|
|
373
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAQhC,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAO7C,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,OAAgB,EAChB,UAAsB;IAEt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AAG,UAAU,EAAE,MAAM,KAAK,WAAW,CAAC;QAEvD,oBAAoB,CAAC,MAAM,EAAE;YAC3B,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,gFAAgF;YAC3H,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,QAAQ;SACtB,CAAC,CAAC;QAEH,mBAAmB,CAAC,YAAY,EAAE,UAAU,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,sBAAsB,GAAG,CAAC,OAAO,IAAI,GAAG,MAAM,CAAC,CAAC;QACzK,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CACf,YAAoB,EACpB,IAA+D;IAE/D,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,MAAM,IAAI,GAAmB;QAC3B,EAAE,EAAE,MAAM;QACV,aAAa,EAAE,YAAY;QAC3B,SAAS,EAAE,IAAI;QACf,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;QACtB,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE;QACvB,WAAW,EAAE,CAAC;KACf,CAAC;IACF,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAC3B,mBAAmB,CAAC,YAAY,EAAE,UAAU,IAAI,iCAAiC,CAAC,CAAC;AACrF,CAAC"}
|
package/dist/github.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Octokit } from "octokit";
|
|
2
|
+
export declare function getOctokit(token: string): Octokit;
|
|
3
|
+
export declare function validateToken(token: string): Promise<{
|
|
4
|
+
username: string;
|
|
5
|
+
name: string | null;
|
|
6
|
+
}>;
|
|
7
|
+
export interface GitRepo {
|
|
8
|
+
owner: string;
|
|
9
|
+
name: string;
|
|
10
|
+
fullName: string;
|
|
11
|
+
url: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function listRepositories(token: string): Promise<GitRepo[]>;
|
|
14
|
+
export declare function listBranches(token: string, owner: string, repo: string): Promise<string[]>;
|
|
15
|
+
export interface WebhookConfig {
|
|
16
|
+
owner: string;
|
|
17
|
+
repo: string;
|
|
18
|
+
webhookUrl: string;
|
|
19
|
+
secret: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function setupWebhook(token: string, config: WebhookConfig): Promise<{
|
|
22
|
+
id: number;
|
|
23
|
+
url: string;
|
|
24
|
+
}>;
|
|
25
|
+
export declare function openBrowser(url: string): Promise<void>;
|
package/dist/github.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Octokit } from "octokit";
|
|
2
|
+
export function getOctokit(token) {
|
|
3
|
+
return new Octokit({ auth: token });
|
|
4
|
+
}
|
|
5
|
+
export async function validateToken(token) {
|
|
6
|
+
const octokit = getOctokit(token);
|
|
7
|
+
const { data } = await octokit.rest.users.getAuthenticated();
|
|
8
|
+
return {
|
|
9
|
+
username: data.login,
|
|
10
|
+
name: data.name || null,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export async function listRepositories(token) {
|
|
14
|
+
const octokit = getOctokit(token);
|
|
15
|
+
const repos = [];
|
|
16
|
+
// Fetch up to 100 repositories. In a real-world scenario we could paginate further,
|
|
17
|
+
// but for an MVP 100 is typically enough or we can list top repos.
|
|
18
|
+
const response = await octokit.rest.repos.listForAuthenticatedUser({
|
|
19
|
+
per_page: 100,
|
|
20
|
+
sort: "updated",
|
|
21
|
+
});
|
|
22
|
+
for (const repo of response.data) {
|
|
23
|
+
repos.push({
|
|
24
|
+
owner: repo.owner.login,
|
|
25
|
+
name: repo.name,
|
|
26
|
+
fullName: repo.full_name,
|
|
27
|
+
url: repo.clone_url,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return repos;
|
|
31
|
+
}
|
|
32
|
+
export async function listBranches(token, owner, repo) {
|
|
33
|
+
const octokit = getOctokit(token);
|
|
34
|
+
const response = await octokit.rest.repos.listBranches({
|
|
35
|
+
owner,
|
|
36
|
+
repo,
|
|
37
|
+
per_page: 100,
|
|
38
|
+
});
|
|
39
|
+
return response.data.map(b => b.name);
|
|
40
|
+
}
|
|
41
|
+
export async function setupWebhook(token, config) {
|
|
42
|
+
const octokit = getOctokit(config.webhookUrl ? token : token); // ensure unused warning bypass
|
|
43
|
+
// 1. List existing webhooks to find a duplicate
|
|
44
|
+
const webhooks = await octokit.rest.repos.listWebhooks({
|
|
45
|
+
owner: config.owner,
|
|
46
|
+
repo: config.repo,
|
|
47
|
+
per_page: 100,
|
|
48
|
+
});
|
|
49
|
+
const existing = webhooks.data.find(h => h.config.url === config.webhookUrl);
|
|
50
|
+
if (existing) {
|
|
51
|
+
// 2. Update webhook
|
|
52
|
+
await octokit.rest.repos.updateWebhook({
|
|
53
|
+
owner: config.owner,
|
|
54
|
+
repo: config.repo,
|
|
55
|
+
hook_id: existing.id,
|
|
56
|
+
config: {
|
|
57
|
+
url: config.webhookUrl,
|
|
58
|
+
content_type: "json",
|
|
59
|
+
secret: config.secret,
|
|
60
|
+
insecure_ssl: "1",
|
|
61
|
+
},
|
|
62
|
+
events: ["push"],
|
|
63
|
+
active: true,
|
|
64
|
+
});
|
|
65
|
+
return { id: existing.id, url: config.webhookUrl };
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
// 3. Create webhook
|
|
69
|
+
const response = await octokit.rest.repos.createWebhook({
|
|
70
|
+
owner: config.owner,
|
|
71
|
+
repo: config.repo,
|
|
72
|
+
name: "web",
|
|
73
|
+
active: true,
|
|
74
|
+
events: ["push"],
|
|
75
|
+
config: {
|
|
76
|
+
url: config.webhookUrl,
|
|
77
|
+
content_type: "json",
|
|
78
|
+
secret: config.secret,
|
|
79
|
+
insecure_ssl: "1",
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
return { id: response.data.id, url: config.webhookUrl };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
import { execa } from "execa";
|
|
86
|
+
export async function openBrowser(url) {
|
|
87
|
+
const platform = process.platform;
|
|
88
|
+
if (platform === "darwin") {
|
|
89
|
+
await execa("open", [url]);
|
|
90
|
+
}
|
|
91
|
+
else if (platform === "win32") {
|
|
92
|
+
await execa("cmd", ["/c", "start", url]);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
await execa("xdg-open", [url]);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=github.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.js","sourceRoot":"","sources":["../src/github.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,IAAI,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,KAAa;IAC/C,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC;IAC7D,OAAO;QACL,QAAQ,EAAE,IAAI,CAAC,KAAK;QACpB,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI;KACxB,CAAC;AACJ,CAAC;AASD,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,KAAa;IAClD,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,KAAK,GAAc,EAAE,CAAC;IAE5B,oFAAoF;IACpF,mEAAmE;IACnE,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC;QACjE,QAAQ,EAAE,GAAG;QACb,IAAI,EAAE,SAAS;KAChB,CAAC,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QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAClC,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1B,MAAM,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,CAAC;SAAM,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QAChC,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IAC3C,CAAC;SAAM,CAAC;QACN,MAAM,KAAK,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACjC,CAAC;AACH,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/dist/paths.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const DEPLOYKIT_DIR: string;
|
|
2
|
+
export declare const CONFIG_PATH: string;
|
|
3
|
+
export declare const DB_PATH: string;
|
|
4
|
+
export declare const BUILDS_DIR: string;
|
|
5
|
+
export declare function ensureDirsExist(): void;
|
|
6
|
+
export declare function readAuthConfig(): {
|
|
7
|
+
github_token?: string;
|
|
8
|
+
github_username?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function writeAuthConfig(config: {
|
|
11
|
+
github_token: string;
|
|
12
|
+
github_username?: string;
|
|
13
|
+
}): void;
|
package/dist/paths.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import os from "os";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
export const DEPLOYKIT_DIR = process.env.DEPLOYKIT_DIR || path.join(os.homedir(), ".deploykit");
|
|
5
|
+
export const CONFIG_PATH = path.join(DEPLOYKIT_DIR, "config.json");
|
|
6
|
+
export const DB_PATH = path.join(DEPLOYKIT_DIR, "deploykit.db");
|
|
7
|
+
export const BUILDS_DIR = path.join(DEPLOYKIT_DIR, "builds");
|
|
8
|
+
export function ensureDirsExist() {
|
|
9
|
+
if (!fs.existsSync(DEPLOYKIT_DIR)) {
|
|
10
|
+
fs.mkdirSync(DEPLOYKIT_DIR, { recursive: true });
|
|
11
|
+
}
|
|
12
|
+
if (!fs.existsSync(BUILDS_DIR)) {
|
|
13
|
+
fs.mkdirSync(BUILDS_DIR, { recursive: true });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function readAuthConfig() {
|
|
17
|
+
ensureDirsExist();
|
|
18
|
+
if (!fs.existsSync(CONFIG_PATH)) {
|
|
19
|
+
return {};
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const raw = fs.readFileSync(CONFIG_PATH, "utf-8");
|
|
23
|
+
return JSON.parse(raw);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function writeAuthConfig(config) {
|
|
30
|
+
ensureDirsExist();
|
|
31
|
+
fs.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2), "utf-8");
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAC;AAChG,MAAM,CAAC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,10 @@
|
|
|
1
|
+
import { Deployment } from "gitship-shared";
|
|
2
|
+
export declare const activeProcesses: Map<string, {
|
|
3
|
+
kill: () => void;
|
|
4
|
+
}>;
|
|
5
|
+
export declare function enqueueDeployment(projectId: string, branch: string, commitSha: string | null, commitMessage: string | null, author: string | null, rollbackOfId?: string | null): Promise<Deployment>;
|
|
6
|
+
export declare function processQueue(projectId: string): Promise<void>;
|
|
7
|
+
export declare function cancelDeployment(id: string): {
|
|
8
|
+
success: boolean;
|
|
9
|
+
message: string;
|
|
10
|
+
};
|