@wtdlee/repomap 0.2.0 → 0.3.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/doc-server.js +13 -0
- package/dist/utils/port.d.ts +15 -0
- package/dist/utils/port.js +41 -0
- package/package.json +2 -2
|
@@ -9,6 +9,7 @@ import { PageMapGenerator } from '../generators/page-map-generator.js';
|
|
|
9
9
|
import { RailsMapGenerator } from '../generators/rails-map-generator.js';
|
|
10
10
|
import { detectEnvironments } from '../utils/env-detector.js';
|
|
11
11
|
import { analyzeRailsApp } from '../analyzers/rails/index.js';
|
|
12
|
+
import { findAvailablePort } from '../utils/port.js';
|
|
12
13
|
/**
|
|
13
14
|
* Documentation server with live reload
|
|
14
15
|
* ライブリロード機能付きドキュメントサーバー
|
|
@@ -1167,6 +1168,18 @@ export class DocServer {
|
|
|
1167
1168
|
console.error(` ⚠️ Rails analysis failed:`, error.message);
|
|
1168
1169
|
}
|
|
1169
1170
|
}
|
|
1171
|
+
// Find available port (auto-detect if requested port is in use)
|
|
1172
|
+
try {
|
|
1173
|
+
const availablePort = await findAvailablePort(this.port);
|
|
1174
|
+
if (availablePort !== this.port) {
|
|
1175
|
+
console.log(`\n⚠️ Port ${this.port} is in use, using port ${availablePort} instead`);
|
|
1176
|
+
}
|
|
1177
|
+
this.port = availablePort;
|
|
1178
|
+
}
|
|
1179
|
+
catch (error) {
|
|
1180
|
+
console.error(`\n❌ Failed to find available port: ${error.message}`);
|
|
1181
|
+
process.exit(1);
|
|
1182
|
+
}
|
|
1170
1183
|
// Start server
|
|
1171
1184
|
this.server.listen(this.port, () => {
|
|
1172
1185
|
console.log(`\n🌐 Documentation server running at http://localhost:${this.port}`);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if a port is available
|
|
3
|
+
* ポートが使用可能かどうかを確認
|
|
4
|
+
*/
|
|
5
|
+
export declare function isPortAvailable(port: number): Promise<boolean>;
|
|
6
|
+
/**
|
|
7
|
+
* Find an available port starting from the given port
|
|
8
|
+
* 指定されたポートから利用可能なポートを探す
|
|
9
|
+
*
|
|
10
|
+
* @param startPort - Port to start searching from
|
|
11
|
+
* @param maxAttempts - Maximum number of ports to try (default: 10)
|
|
12
|
+
* @returns Available port number
|
|
13
|
+
* @throws Error if no available port found within maxAttempts
|
|
14
|
+
*/
|
|
15
|
+
export declare function findAvailablePort(startPort: number, maxAttempts?: number): Promise<number>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as net from 'net';
|
|
2
|
+
/**
|
|
3
|
+
* Check if a port is available
|
|
4
|
+
* ポートが使用可能かどうかを確認
|
|
5
|
+
*/
|
|
6
|
+
export function isPortAvailable(port) {
|
|
7
|
+
return new Promise((resolve) => {
|
|
8
|
+
const server = net.createServer();
|
|
9
|
+
server.once('error', (err) => {
|
|
10
|
+
if (err.code === 'EADDRINUSE') {
|
|
11
|
+
resolve(false);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
resolve(false);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
server.once('listening', () => {
|
|
18
|
+
server.close();
|
|
19
|
+
resolve(true);
|
|
20
|
+
});
|
|
21
|
+
server.listen(port);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Find an available port starting from the given port
|
|
26
|
+
* 指定されたポートから利用可能なポートを探す
|
|
27
|
+
*
|
|
28
|
+
* @param startPort - Port to start searching from
|
|
29
|
+
* @param maxAttempts - Maximum number of ports to try (default: 10)
|
|
30
|
+
* @returns Available port number
|
|
31
|
+
* @throws Error if no available port found within maxAttempts
|
|
32
|
+
*/
|
|
33
|
+
export async function findAvailablePort(startPort, maxAttempts = 10) {
|
|
34
|
+
for (let i = 0; i < maxAttempts; i++) {
|
|
35
|
+
const port = startPort + i;
|
|
36
|
+
if (await isPortAvailable(port)) {
|
|
37
|
+
return port;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
throw new Error(`No available port found between ${startPort} and ${startPort + maxAttempts - 1}`);
|
|
41
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wtdlee/repomap",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Interactive documentation generator for code repositories - visualize pages, components, GraphQL operations, and data flows",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"@babel/traverse": "^7.23.0",
|
|
80
80
|
"chalk": "^5.3.0",
|
|
81
81
|
"commander": "^14.0.2",
|
|
82
|
+
"express": "^5.2.1",
|
|
82
83
|
"fast-glob": "^3.3.2",
|
|
83
84
|
"glob": "^13.0.0",
|
|
84
85
|
"graphql": "^16.8.1",
|
|
@@ -100,7 +101,6 @@
|
|
|
100
101
|
"eslint": "^9.39.1",
|
|
101
102
|
"eslint-config-prettier": "^10.1.8",
|
|
102
103
|
"eslint-plugin-prettier": "^5.5.4",
|
|
103
|
-
"express": "^5.2.1",
|
|
104
104
|
"globals": "^16.5.0",
|
|
105
105
|
"husky": "^9.1.7",
|
|
106
106
|
"lint-staged": "^16.2.7",
|