git-tm 0.2.0 → 0.4.0
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/LICENSE +21 -21
- package/README.md +85 -80
- package/package.json +45 -46
- package/src/cli.js +235 -234
- package/src/git.js +212 -212
- package/src/public/app.js +960 -960
- package/src/public/images/logo.svg +8 -8
- package/src/public/index.html +88 -88
- package/src/public/styles.css +1259 -1259
- package/src/server.js +102 -102
package/src/server.js
CHANGED
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
import express from 'express';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
|
-
import { dirname } from 'path';
|
|
5
|
-
import {
|
|
6
|
-
getRepoData,
|
|
7
|
-
compareCommits,
|
|
8
|
-
checkoutRemoteBranch,
|
|
9
|
-
getBranchCommits,
|
|
10
|
-
} from './git.js';
|
|
11
|
-
|
|
12
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
-
const __dirname = dirname(__filename);
|
|
14
|
-
|
|
15
|
-
const app = express();
|
|
16
|
-
|
|
17
|
-
app.use(express.static(path.join(__dirname, "public")));
|
|
18
|
-
|
|
19
|
-
app.get("/api/repo-data", async (req, res) => {
|
|
20
|
-
try {
|
|
21
|
-
const data = await getRepoData();
|
|
22
|
-
res.json(data);
|
|
23
|
-
} catch (error) {
|
|
24
|
-
res.status(500).json({ error: error.message });
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
app.get("/api/compare", async (req, res) => {
|
|
29
|
-
try {
|
|
30
|
-
const { from, to } = req.query;
|
|
31
|
-
if (!from || !to) {
|
|
32
|
-
return res.status(400).json({ error: "Missing commit hashes" });
|
|
33
|
-
}
|
|
34
|
-
const diff = await compareCommits(from, to);
|
|
35
|
-
res.send(diff);
|
|
36
|
-
} catch (error) {
|
|
37
|
-
res.status(500).json({ error: error.message });
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
app.post("/api/checkout-remote", async (req, res) => {
|
|
42
|
-
try {
|
|
43
|
-
const { branchName } = req.query;
|
|
44
|
-
if (!branchName) {
|
|
45
|
-
return res.status(400).json({ Rerror: "Missing branch name" });
|
|
46
|
-
}
|
|
47
|
-
const success = await checkoutRemoteBranch(branchName);
|
|
48
|
-
if (success) {
|
|
49
|
-
const data = await getRepoData();
|
|
50
|
-
res.json(data);
|
|
51
|
-
} else {
|
|
52
|
-
res.status(500).json({ error: "Failed to checkout branch" });
|
|
53
|
-
}
|
|
54
|
-
} catch (error) {
|
|
55
|
-
res.status(500).json({ error: error.message });
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
app.get("/api/branch-commits", async (req, res) => {
|
|
60
|
-
try {
|
|
61
|
-
const { branch } = req.query;
|
|
62
|
-
if (!branch) {
|
|
63
|
-
return res.status(400).json({ error: "Missing branch name" });
|
|
64
|
-
}
|
|
65
|
-
const commits = await getBranchCommits(branch);
|
|
66
|
-
res.json(commits);
|
|
67
|
-
} catch (error) {
|
|
68
|
-
console.error("Failed to get branch commits:", error);
|
|
69
|
-
res.status(500).json({
|
|
70
|
-
error: "Failed to get branch commits",
|
|
71
|
-
details: error.message,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
function startServer(port) {
|
|
77
|
-
return new Promise((resolve, reject) => {
|
|
78
|
-
const server = app.listen(port, async () => {
|
|
79
|
-
try {
|
|
80
|
-
const { default: open } = await import('open');
|
|
81
|
-
await open(`http://localhost:${port}`);
|
|
82
|
-
resolve(port);
|
|
83
|
-
} catch (error) {
|
|
84
|
-
console.warn("Failed to open browser automatically.");
|
|
85
|
-
console.log("Please open your browser and visit:");
|
|
86
|
-
resolve(port);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
server.on("error", (error) => {
|
|
91
|
-
if (error.code === "EADDRINUSE") {
|
|
92
|
-
const nextPort = parseInt(port) + 1;
|
|
93
|
-
console.log(`\n⚠️ Port ${port} is in use.`);
|
|
94
|
-
console.log(`↪️ Trying port ${nextPort}...\n`);
|
|
95
|
-
startServer(nextPort).then(resolve).catch(reject);
|
|
96
|
-
} else {
|
|
97
|
-
reject(error);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { dirname } from 'path';
|
|
5
|
+
import {
|
|
6
|
+
getRepoData,
|
|
7
|
+
compareCommits,
|
|
8
|
+
checkoutRemoteBranch,
|
|
9
|
+
getBranchCommits,
|
|
10
|
+
} from './git.js';
|
|
11
|
+
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = dirname(__filename);
|
|
14
|
+
|
|
15
|
+
const app = express();
|
|
16
|
+
|
|
17
|
+
app.use(express.static(path.join(__dirname, "public")));
|
|
18
|
+
|
|
19
|
+
app.get("/api/repo-data", async (req, res) => {
|
|
20
|
+
try {
|
|
21
|
+
const data = await getRepoData();
|
|
22
|
+
res.json(data);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
res.status(500).json({ error: error.message });
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
app.get("/api/compare", async (req, res) => {
|
|
29
|
+
try {
|
|
30
|
+
const { from, to } = req.query;
|
|
31
|
+
if (!from || !to) {
|
|
32
|
+
return res.status(400).json({ error: "Missing commit hashes" });
|
|
33
|
+
}
|
|
34
|
+
const diff = await compareCommits(from, to);
|
|
35
|
+
res.send(diff);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
res.status(500).json({ error: error.message });
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
app.post("/api/checkout-remote", async (req, res) => {
|
|
42
|
+
try {
|
|
43
|
+
const { branchName } = req.query;
|
|
44
|
+
if (!branchName) {
|
|
45
|
+
return res.status(400).json({ Rerror: "Missing branch name" });
|
|
46
|
+
}
|
|
47
|
+
const success = await checkoutRemoteBranch(branchName);
|
|
48
|
+
if (success) {
|
|
49
|
+
const data = await getRepoData();
|
|
50
|
+
res.json(data);
|
|
51
|
+
} else {
|
|
52
|
+
res.status(500).json({ error: "Failed to checkout branch" });
|
|
53
|
+
}
|
|
54
|
+
} catch (error) {
|
|
55
|
+
res.status(500).json({ error: error.message });
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
app.get("/api/branch-commits", async (req, res) => {
|
|
60
|
+
try {
|
|
61
|
+
const { branch } = req.query;
|
|
62
|
+
if (!branch) {
|
|
63
|
+
return res.status(400).json({ error: "Missing branch name" });
|
|
64
|
+
}
|
|
65
|
+
const commits = await getBranchCommits(branch);
|
|
66
|
+
res.json(commits);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.error("Failed to get branch commits:", error);
|
|
69
|
+
res.status(500).json({
|
|
70
|
+
error: "Failed to get branch commits",
|
|
71
|
+
details: error.message,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
function startServer(port) {
|
|
77
|
+
return new Promise((resolve, reject) => {
|
|
78
|
+
const server = app.listen(port, async () => {
|
|
79
|
+
try {
|
|
80
|
+
const { default: open } = await import('open');
|
|
81
|
+
await open(`http://localhost:${port}`);
|
|
82
|
+
resolve(port);
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.warn("Failed to open browser automatically.");
|
|
85
|
+
console.log("Please open your browser and visit:");
|
|
86
|
+
resolve(port);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
server.on("error", (error) => {
|
|
91
|
+
if (error.code === "EADDRINUSE") {
|
|
92
|
+
const nextPort = parseInt(port) + 1;
|
|
93
|
+
console.log(`\n⚠️ Port ${port} is in use.`);
|
|
94
|
+
console.log(`↪️ Trying port ${nextPort}...\n`);
|
|
95
|
+
startServer(nextPort).then(resolve).catch(reject);
|
|
96
|
+
} else {
|
|
97
|
+
reject(error);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
103
|
export { startServer };
|