@aikotools/repo-maintenance 1.1.1 → 1.2.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/dist/server/server/index.js +22 -2
- package/package.json +4 -1
|
@@ -94,7 +94,7 @@ app.all('/trpc/*', async (c) => {
|
|
|
94
94
|
// Serve static files from dist/client in production
|
|
95
95
|
const clientDir = path.join(packageRoot, 'dist/client');
|
|
96
96
|
if (existsSync(clientDir)) {
|
|
97
|
-
app.use('/*', serveStatic({ root:
|
|
97
|
+
app.use('/*', serveStatic({ root: clientDir }));
|
|
98
98
|
// SPA fallback: serve index.html for non-API routes
|
|
99
99
|
app.get('*', async (c) => {
|
|
100
100
|
const indexPath = path.join(clientDir, 'index.html');
|
|
@@ -110,9 +110,29 @@ app.onError((err, c) => {
|
|
|
110
110
|
console.error('[RepoHub] Error:', err.message);
|
|
111
111
|
return c.json({ error: err.message }, 500);
|
|
112
112
|
});
|
|
113
|
-
const
|
|
113
|
+
const preferredPort = Number(process.env.PORT) || 3100;
|
|
114
|
+
async function findAvailablePort(start) {
|
|
115
|
+
const { createServer } = await import('net');
|
|
116
|
+
let port = start;
|
|
117
|
+
while (port < start + 20) {
|
|
118
|
+
const available = await new Promise((resolve) => {
|
|
119
|
+
const server = createServer();
|
|
120
|
+
server.once('error', () => resolve(false));
|
|
121
|
+
server.once('listening', () => server.close(() => resolve(true)));
|
|
122
|
+
server.listen(port);
|
|
123
|
+
});
|
|
124
|
+
if (available)
|
|
125
|
+
return port;
|
|
126
|
+
port++;
|
|
127
|
+
}
|
|
128
|
+
throw new Error(`No available port found between ${start} and ${port}`);
|
|
129
|
+
}
|
|
130
|
+
const port = await findAvailablePort(preferredPort);
|
|
114
131
|
serve({
|
|
115
132
|
fetch: app.fetch,
|
|
116
133
|
port,
|
|
117
134
|
});
|
|
135
|
+
if (port !== preferredPort) {
|
|
136
|
+
console.log(`[RepoHub] Port ${preferredPort} in use, using ${port} instead`);
|
|
137
|
+
}
|
|
118
138
|
console.log(`[RepoHub] Server running on http://localhost:${port}`);
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aikotools/repo-maintenance",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=20"
|
|
11
|
+
},
|
|
9
12
|
"bin": {
|
|
10
13
|
"repohub": "./bin/repohub.js"
|
|
11
14
|
},
|