@manojkmfsi/monodog 1.0.20 → 1.0.22
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/dist/config-loader.js +5 -6
- package/dist/controllers/commitController.js +4 -4
- package/dist/controllers/packageController.js +2 -2
- package/dist/get-db-url.js +0 -1
- package/dist/index.js +216 -80
- package/dist/serve.js +7 -91
- package/dist/services/commitService.js +7 -7
- package/dist/services/configService.js +5 -5
- package/dist/services/gitService.js +141 -0
- package/dist/setup.js +5 -5
- package/dist/utils/db-utils.js +3 -3
- package/dist/utils/monorepo-scanner.js +3 -3
- package/dist/utils/utilities.js +95 -17
- package/{monodog-conf.json → monodog-config.json} +2 -4
- package/monodog-dashboard/README.md +2 -2
- package/monodog-dashboard/dist/assets/{index-dadb5f0d.js → index-746f6c13.js} +2 -2
- package/monodog-dashboard/dist/index.html +1 -1
- package/package.json +4 -3
- package/src/config-loader.ts +5 -7
- package/src/controllers/commitController.ts +4 -4
- package/src/controllers/packageController.ts +2 -2
- package/src/get-db-url.ts +0 -2
- package/src/index.ts +225 -73
- package/src/serve.ts +6 -68
- package/src/services/commitService.ts +7 -7
- package/src/services/configService.ts +5 -5
- package/src/services/gitService.ts +165 -0
- package/src/setup.ts +5 -5
- package/src/utils/db-utils.ts +3 -3
- package/src/utils/monorepo-scanner.ts +3 -3
- package/src/utils/utilities.ts +108 -17
- package/dist/gitService.js +0 -242
- package/release.config.js +0 -41
- package/src/gitService.ts +0 -276
- /package/{monodog-conf.example.json → monodog-config.example.json} +0 -0
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
package/dist/config-loader.js
CHANGED
|
@@ -39,7 +39,7 @@ const path = __importStar(require("path"));
|
|
|
39
39
|
// Global variable to hold the loaded config
|
|
40
40
|
let config = null;
|
|
41
41
|
/**
|
|
42
|
-
* Loads the monodog-
|
|
42
|
+
* Loads the monodog-config.json file from the monorepo root.
|
|
43
43
|
* This should be called only once during application startup.
|
|
44
44
|
* @returns The application configuration object.
|
|
45
45
|
*/
|
|
@@ -50,8 +50,8 @@ function loadConfig() {
|
|
|
50
50
|
// 1. Determine the path to the config file
|
|
51
51
|
// We assume the backend package is running from the monorepo root (cwd is root)
|
|
52
52
|
// or that we can navigate up to the root from the current file's location.
|
|
53
|
-
const rootPath = path.resolve(process.cwd());
|
|
54
|
-
const configPath = path.resolve(rootPath, 'monodog-
|
|
53
|
+
const rootPath = path.resolve(process.cwd());
|
|
54
|
+
const configPath = path.resolve(rootPath, 'monodog-config.json');
|
|
55
55
|
createConfigFileIfMissing(rootPath);
|
|
56
56
|
if (!fs.existsSync(configPath)) {
|
|
57
57
|
console.error(`ERROR1: Configuration file not found at ${configPath}`);
|
|
@@ -61,21 +61,20 @@ function loadConfig() {
|
|
|
61
61
|
// 2. Read and parse the JSON file
|
|
62
62
|
const fileContent = fs.readFileSync(configPath, 'utf-8');
|
|
63
63
|
const parsedConfig = JSON.parse(fileContent);
|
|
64
|
-
// 3. Optional: Add validation logic here (e.g., check if ports are numbers)
|
|
65
64
|
// Cache and return
|
|
66
65
|
config = parsedConfig;
|
|
67
66
|
process.stderr.write('[Config] Loaded configuration from: ...\n');
|
|
68
67
|
return config;
|
|
69
68
|
}
|
|
70
69
|
catch (error) {
|
|
71
|
-
console.error('ERROR: Failed to read or parse monodog-
|
|
70
|
+
console.error('ERROR: Failed to read or parse monodog-config.json.');
|
|
72
71
|
console.error(error);
|
|
73
72
|
process.exit(1);
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
75
|
function createConfigFileIfMissing(rootPath) {
|
|
77
76
|
// --- CONFIGURATION ---
|
|
78
|
-
const configFileName = 'monodog-
|
|
77
|
+
const configFileName = 'monodog-config.json';
|
|
79
78
|
const configFilePath = path.resolve(rootPath, configFileName);
|
|
80
79
|
// The default content for the configuration file
|
|
81
80
|
const defaultContent = {
|
|
@@ -6,14 +6,14 @@ const getCommitsByPath = async (_req, res) => {
|
|
|
6
6
|
try {
|
|
7
7
|
const { packagePath } = _req.params;
|
|
8
8
|
const decodedPath = decodeURIComponent(packagePath);
|
|
9
|
-
console.log('
|
|
10
|
-
console.log('
|
|
9
|
+
console.log('Fetching commits for path:', decodedPath);
|
|
10
|
+
console.log('Current working directory:', process.cwd());
|
|
11
11
|
const commits = await (0, commitService_1.getCommitsByPathService)(decodedPath);
|
|
12
|
-
console.log(
|
|
12
|
+
console.log(`Successfully fetched ${commits.length} commits for ${decodedPath}`);
|
|
13
13
|
res.json(commits);
|
|
14
14
|
}
|
|
15
15
|
catch (error) {
|
|
16
|
-
console.error('
|
|
16
|
+
console.error('Error fetching commit details:', error);
|
|
17
17
|
res.status(500).json({
|
|
18
18
|
error: 'Failed to fetch commit details',
|
|
19
19
|
message: error.message,
|
|
@@ -44,8 +44,8 @@ const updatePackageConfig = async (req, res) => {
|
|
|
44
44
|
error: 'Package name, configuration, and package path are required',
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
console.log('
|
|
48
|
-
console.log('
|
|
47
|
+
console.log('Updating package configuration for:', packageName);
|
|
48
|
+
console.log('Package path:', packagePath);
|
|
49
49
|
const updatedPackage = await (0, configService_1.updatePackageConfigurationService)(packagePath, packageName, config);
|
|
50
50
|
return res.json({
|
|
51
51
|
success: true,
|
package/dist/get-db-url.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const config_loader_1 = require("./config-loader");
|
|
4
4
|
function generateUrl() {
|
|
5
|
-
// const appConfig = loadConfig();
|
|
6
5
|
const DATABASE_URL = `${config_loader_1.appConfig.database.path}`;
|
|
7
6
|
process.env.DATABASE_URL = DATABASE_URL;
|
|
8
7
|
process.stdout.write(DATABASE_URL);
|
package/dist/index.js
CHANGED
|
@@ -9,94 +9,230 @@ const express_1 = __importDefault(require("express"));
|
|
|
9
9
|
const cors_1 = __importDefault(require("cors"));
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
11
|
const body_parser_1 = require("body-parser");
|
|
12
|
+
const helmet_1 = __importDefault(require("helmet"));
|
|
12
13
|
const config_loader_1 = require("./config-loader");
|
|
13
14
|
const packageRoutes_1 = __importDefault(require("./routes/packageRoutes"));
|
|
14
15
|
const commitRoutes_1 = __importDefault(require("./routes/commitRoutes"));
|
|
15
16
|
const healthRoutes_1 = __importDefault(require("./routes/healthRoutes"));
|
|
16
17
|
const configRoutes_1 = __importDefault(require("./routes/configRoutes"));
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
app.use('/api/config/', configRoutes_1.default);
|
|
37
|
-
// 404 handler
|
|
38
|
-
app.use('*', (_, res) => {
|
|
39
|
-
res.status(404).json({
|
|
40
|
-
error: 'Endpoint not found',
|
|
41
|
-
timestamp: Date.now(),
|
|
42
|
-
});
|
|
18
|
+
// Security constants
|
|
19
|
+
const PORT_MIN = 1024;
|
|
20
|
+
const PORT_MAX = 65535;
|
|
21
|
+
// Validate port number
|
|
22
|
+
function validatePort(port) {
|
|
23
|
+
const portNum = typeof port === 'string' ? parseInt(port, 10) : port;
|
|
24
|
+
if (isNaN(portNum) || portNum < PORT_MIN || portNum > PORT_MAX) {
|
|
25
|
+
throw new Error(`Port must be between ${PORT_MIN} and ${PORT_MAX}`);
|
|
26
|
+
}
|
|
27
|
+
return portNum;
|
|
28
|
+
}
|
|
29
|
+
// Global error handler
|
|
30
|
+
const errorHandler = (err, req, res, _next) => {
|
|
31
|
+
const status = err.status || err.statusCode || 500;
|
|
32
|
+
console.error('[ERROR]', {
|
|
33
|
+
status,
|
|
34
|
+
method: req.method,
|
|
35
|
+
path: req.path,
|
|
36
|
+
message: err.message,
|
|
43
37
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
.listen(PORT, host, async () => {
|
|
47
|
-
console.log(`🚀 Backend server running on http://${host}:${PORT}`);
|
|
48
|
-
console.log(`📊 API endpoints available:`);
|
|
49
|
-
console.log(` - GET /api/health`);
|
|
50
|
-
console.log(` - GET /api/packages/refresh`);
|
|
51
|
-
console.log(` - GET /api/packages`);
|
|
52
|
-
console.log(` - GET /api/packages/:name`);
|
|
53
|
-
console.log(` - PUT /api/packages/update-config`);
|
|
54
|
-
console.log(` - GET /api/commits/:packagePath`);
|
|
55
|
-
console.log(` - GET /api/health/packages`);
|
|
56
|
-
console.log(` - PUT /api/config/files/:id`);
|
|
57
|
-
console.log(` - GET /api/config/files`);
|
|
58
|
-
})
|
|
59
|
-
.on('error', err => {
|
|
60
|
-
// Handle common errors like EADDRINUSE (port already in use)
|
|
61
|
-
if (err.message.includes('EADDRINUSE')) {
|
|
62
|
-
console.error(`Error: Port ${port} is already in use. Please specify a different port via configuration file.`);
|
|
63
|
-
process.exit(1);
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
console.error('Server failed to start:', err);
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
38
|
+
res.status(status).json({
|
|
39
|
+
error: 'Internal server error'
|
|
69
40
|
});
|
|
41
|
+
};
|
|
42
|
+
// The main function exported and called by the CLI
|
|
43
|
+
function startServer(rootPath) {
|
|
44
|
+
try {
|
|
45
|
+
const port = config_loader_1.appConfig.server.port;
|
|
46
|
+
const host = config_loader_1.appConfig.server.host;
|
|
47
|
+
const validatedPort = validatePort(port);
|
|
48
|
+
const app = (0, express_1.default)();
|
|
49
|
+
// Set request timeout (30 seconds)
|
|
50
|
+
app.use((req, res, next) => {
|
|
51
|
+
req.setTimeout(30000);
|
|
52
|
+
res.setTimeout(30000);
|
|
53
|
+
next();
|
|
54
|
+
});
|
|
55
|
+
app.locals.rootPath = rootPath;
|
|
56
|
+
// Security middleware with CSP allowing API calls
|
|
57
|
+
const apiHost = host === '0.0.0.0' ? 'localhost' : host;
|
|
58
|
+
const apiUrl = process.env.API_URL || `http://${apiHost}:${validatedPort}`;
|
|
59
|
+
const dashboardHost = config_loader_1.appConfig.dashboard.host === '0.0.0.0' ? 'localhost' : config_loader_1.appConfig.dashboard.host;
|
|
60
|
+
const dashboardUrl = `http://${dashboardHost}:${config_loader_1.appConfig.dashboard.port}`;
|
|
61
|
+
app.use((0, helmet_1.default)({
|
|
62
|
+
contentSecurityPolicy: {
|
|
63
|
+
directives: {
|
|
64
|
+
defaultSrc: ["'self'"],
|
|
65
|
+
connectSrc: ["'self'", apiUrl, 'http://localhost:*', 'http://127.0.0.1:*'],
|
|
66
|
+
scriptSrc: ["'self'"],
|
|
67
|
+
imgSrc: ["'self'", 'data:', 'https:'],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
}));
|
|
71
|
+
app.use((0, cors_1.default)({
|
|
72
|
+
origin: process.env.CORS_ORIGIN || dashboardUrl,
|
|
73
|
+
credentials: true,
|
|
74
|
+
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
|
|
75
|
+
allowedHeaders: ['Content-Type', 'Authorization'],
|
|
76
|
+
}));
|
|
77
|
+
app.use((0, body_parser_1.json)({ limit: '1mb' }));
|
|
78
|
+
// Request logging middleware (safe version)
|
|
79
|
+
app.use((_req, _res, next) => {
|
|
80
|
+
console.log(`[${new Date().toISOString()}] ${_req.method} ${_req.path}`);
|
|
81
|
+
next();
|
|
82
|
+
});
|
|
83
|
+
app.use('/api/packages', packageRoutes_1.default);
|
|
84
|
+
// Get commit details
|
|
85
|
+
app.use('/api/commits/', commitRoutes_1.default);
|
|
86
|
+
// Health check endpoint
|
|
87
|
+
app.use('/api/health/', healthRoutes_1.default);
|
|
88
|
+
// Configuration endpoint
|
|
89
|
+
app.use('/api/config/', configRoutes_1.default);
|
|
90
|
+
// 404 handler
|
|
91
|
+
app.use('*', (_, res) => {
|
|
92
|
+
res.status(404).json({
|
|
93
|
+
error: 'Endpoint not found',
|
|
94
|
+
timestamp: Date.now(),
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
// Global error handler (must be last)
|
|
98
|
+
app.use(errorHandler);
|
|
99
|
+
const server = app.listen(validatedPort, host, () => {
|
|
100
|
+
console.log(`Backend server running on http://${host}:${validatedPort}`);
|
|
101
|
+
console.log(`API endpoints available:`);
|
|
102
|
+
console.log(` - GET /api/health`);
|
|
103
|
+
console.log(` - GET /api/packages/refresh`);
|
|
104
|
+
console.log(` - GET /api/packages`);
|
|
105
|
+
console.log(` - GET /api/packages/:name`);
|
|
106
|
+
console.log(` - PUT /api/packages/update-config`);
|
|
107
|
+
console.log(` - GET /api/commits/:packagePath`);
|
|
108
|
+
console.log(` - GET /api/health/packages`);
|
|
109
|
+
console.log(` - PUT /api/config/files/:id`);
|
|
110
|
+
console.log(` - GET /api/config/files`);
|
|
111
|
+
});
|
|
112
|
+
server.on('error', (err) => {
|
|
113
|
+
// Handle common errors like EADDRINUSE (port already in use)
|
|
114
|
+
if (err.code === 'EADDRINUSE') {
|
|
115
|
+
console.error(`Error: Port ${validatedPort} is already in use. Please specify a different port.`);
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
else if (err.code === 'EACCES') {
|
|
119
|
+
console.error(`Error: Permission denied to listen on port ${validatedPort}. Use a port above 1024.`);
|
|
120
|
+
process.exit(1);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
console.error('Server failed to start:', err.message);
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
// Graceful shutdown
|
|
128
|
+
process.on('SIGTERM', () => {
|
|
129
|
+
console.log('SIGTERM signal received: closing HTTP server');
|
|
130
|
+
server.close(() => {
|
|
131
|
+
console.log('HTTP server closed');
|
|
132
|
+
process.exit(0);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
console.error('Failed to start server:', error.message);
|
|
138
|
+
process.exit(1);
|
|
139
|
+
}
|
|
70
140
|
}
|
|
71
|
-
function serveDashboard(rootPath
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
141
|
+
function serveDashboard(rootPath) {
|
|
142
|
+
try {
|
|
143
|
+
const port = config_loader_1.appConfig.dashboard.port;
|
|
144
|
+
const host = config_loader_1.appConfig.dashboard.host;
|
|
145
|
+
const validatedPort = validatePort(port);
|
|
146
|
+
const app = (0, express_1.default)();
|
|
147
|
+
// Security middleware
|
|
148
|
+
const serverHost = config_loader_1.appConfig.server.host === '0.0.0.0' ? 'localhost' : config_loader_1.appConfig.server.host;
|
|
149
|
+
const apiUrl = process.env.API_URL || `http://${serverHost}:${config_loader_1.appConfig.server.port}`;
|
|
150
|
+
app.use((0, helmet_1.default)({
|
|
151
|
+
contentSecurityPolicy: {
|
|
152
|
+
directives: {
|
|
153
|
+
defaultSrc: ["'self'"],
|
|
154
|
+
connectSrc: ["'self'", apiUrl, 'http://localhost:*', 'http://127.0.0.1:*'],
|
|
155
|
+
scriptSrc: ["'self'"],
|
|
156
|
+
imgSrc: ["'self'", 'data:', 'https:'],
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
}));
|
|
160
|
+
// Strict CORS for dashboard
|
|
161
|
+
app.use((0, cors_1.default)({
|
|
162
|
+
origin: false, // Don't allow any origin for static assets
|
|
163
|
+
}));
|
|
164
|
+
// Set request timeout
|
|
165
|
+
app.use((req, res, next) => {
|
|
166
|
+
req.setTimeout(30000);
|
|
167
|
+
res.setTimeout(30000);
|
|
82
168
|
next();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
res.
|
|
86
|
-
res.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
169
|
+
});
|
|
170
|
+
app.get('/env-config.js', (req, res) => {
|
|
171
|
+
res.setHeader('Content-Type', 'application/javascript');
|
|
172
|
+
res.setHeader('Cache-Control', 'private, no-cache, no-store, must-revalidate');
|
|
173
|
+
const serverHost = config_loader_1.appConfig.server.host === '0.0.0.0' ? 'localhost' : config_loader_1.appConfig.server.host;
|
|
174
|
+
const apiUrl = process.env.API_URL || `http://${serverHost}:${config_loader_1.appConfig.server.port}`;
|
|
175
|
+
res.send(`window.ENV = { API_URL: "${apiUrl}" };`);
|
|
176
|
+
});
|
|
177
|
+
// This code makes sure that any request that does not matches a static file
|
|
178
|
+
// in the build folder, will just serve index.html. Client side routing is
|
|
179
|
+
// going to make sure that the correct content will be loaded.
|
|
180
|
+
app.use((req, res, next) => {
|
|
181
|
+
if (/(.ico|.js|.css|.jpg|.png|.map|.woff|.woff2|.ttf)$/i.test(req.path)) {
|
|
182
|
+
next();
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
res.header('Cache-Control', 'private, no-cache, no-store, must-revalidate');
|
|
186
|
+
res.header('Expires', '-1');
|
|
187
|
+
res.header('Pragma', 'no-cache');
|
|
188
|
+
res.sendFile('index.html', {
|
|
189
|
+
root: path_1.default.resolve(__dirname, '..', 'monodog-dashboard', 'dist'),
|
|
190
|
+
}, (err) => {
|
|
191
|
+
if (err) {
|
|
192
|
+
console.error('Error serving index.html:', err.message);
|
|
193
|
+
res.status(500).json({ error: 'Internal server error' });
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
const staticPath = path_1.default.join(__dirname, '..', 'monodog-dashboard', 'dist');
|
|
199
|
+
console.log('Serving static files from:', staticPath);
|
|
200
|
+
app.use(express_1.default.static(staticPath, {
|
|
201
|
+
maxAge: '1d',
|
|
202
|
+
etag: false,
|
|
203
|
+
dotfiles: 'deny', // Don't serve dot files
|
|
204
|
+
}));
|
|
205
|
+
// Global error handler
|
|
206
|
+
app.use(errorHandler);
|
|
207
|
+
const server = app.listen(validatedPort, host, () => {
|
|
208
|
+
console.log(`Dashboard listening on http://${host}:${validatedPort}`);
|
|
209
|
+
console.log('Press Ctrl+C to quit.');
|
|
210
|
+
});
|
|
211
|
+
server.on('error', (err) => {
|
|
212
|
+
if (err.code === 'EADDRINUSE') {
|
|
213
|
+
console.error(`Error: Port ${validatedPort} is already in use.`);
|
|
214
|
+
process.exit(1);
|
|
215
|
+
}
|
|
216
|
+
else if (err.code === 'EACCES') {
|
|
217
|
+
console.error(`Error: Permission denied to listen on port ${validatedPort}.`);
|
|
218
|
+
process.exit(1);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
console.error('Server failed to start:', err.message);
|
|
222
|
+
process.exit(1);
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
// Graceful shutdown
|
|
226
|
+
process.on('SIGTERM', () => {
|
|
227
|
+
console.log('SIGTERM signal received: closing dashboard server');
|
|
228
|
+
server.close(() => {
|
|
229
|
+
console.log('Dashboard server closed');
|
|
230
|
+
process.exit(0);
|
|
90
231
|
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const PORT = parseInt(port ? port.toString() : '8999');
|
|
98
|
-
app.listen(PORT, host, () => {
|
|
99
|
-
console.log(`App listening on ${host}:${port}`);
|
|
100
|
-
console.log('Press Ctrl+C to quit.');
|
|
101
|
-
});
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
console.error('Failed to start dashboard:', error.message);
|
|
236
|
+
process.exit(1);
|
|
237
|
+
}
|
|
102
238
|
}
|
package/dist/serve.js
CHANGED
|
@@ -2,102 +2,18 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
/**
|
|
4
4
|
* CLI Entry Point for serving Monodog.
|
|
5
|
-
*
|
|
5
|
+
* This script is executed when a user runs the serve command
|
|
6
6
|
* in their project. It handles command-line arguments to determine
|
|
7
7
|
* whether to:
|
|
8
8
|
* 1. Start the API server for the dashboard.
|
|
9
9
|
* 2. Start serving the dashboard frontend.
|
|
10
10
|
*/
|
|
11
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
-
if (k2 === undefined) k2 = k;
|
|
13
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
-
}
|
|
17
|
-
Object.defineProperty(o, k2, desc);
|
|
18
|
-
}) : (function(o, m, k, k2) {
|
|
19
|
-
if (k2 === undefined) k2 = k;
|
|
20
|
-
o[k2] = m[k];
|
|
21
|
-
}));
|
|
22
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
23
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24
|
-
}) : function(o, v) {
|
|
25
|
-
o["default"] = v;
|
|
26
|
-
});
|
|
27
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
28
|
-
var ownKeys = function(o) {
|
|
29
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
30
|
-
var ar = [];
|
|
31
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
32
|
-
return ar;
|
|
33
|
-
};
|
|
34
|
-
return ownKeys(o);
|
|
35
|
-
};
|
|
36
|
-
return function (mod) {
|
|
37
|
-
if (mod && mod.__esModule) return mod;
|
|
38
|
-
var result = {};
|
|
39
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
40
|
-
__setModuleDefault(result, mod);
|
|
41
|
-
return result;
|
|
42
|
-
};
|
|
43
|
-
})();
|
|
44
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
-
};
|
|
47
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const fs_1 = __importDefault(require("fs"));
|
|
52
|
-
// --- Argument Parsing ---
|
|
53
|
-
// 1. Get arguments excluding the node executable and script name
|
|
54
|
-
const args = process.argv.slice(2);
|
|
55
|
-
// Default settings
|
|
56
|
-
const DEFAULT_PORT = 8999;
|
|
57
|
-
const rootPath = findMonorepoRoot();
|
|
58
|
-
const port = config_loader_1.appConfig.server.port ?? DEFAULT_PORT; //Default port
|
|
59
|
-
const host = config_loader_1.appConfig.server.host ?? 'localhost'; //Default host
|
|
60
|
-
// --- Execution Logic ---
|
|
12
|
+
const index_1 = require("./index");
|
|
13
|
+
const utilities_1 = require("./utils/utilities");
|
|
14
|
+
const rootPath = (0, utilities_1.findMonorepoRoot)();
|
|
61
15
|
console.log(`Starting Monodog API server...`);
|
|
62
16
|
console.log(`Analyzing monorepo at root: ${rootPath}`);
|
|
63
|
-
// Start the Express server and
|
|
64
|
-
(0, index_1.startServer)(rootPath
|
|
65
|
-
(0, index_1.serveDashboard)(
|
|
66
|
-
/**
|
|
67
|
-
* Find the monorepo root by looking for package.json with workspaces or pnpm-workspace.yaml
|
|
68
|
-
*/
|
|
69
|
-
function findMonorepoRoot() {
|
|
70
|
-
let currentDir = __dirname;
|
|
71
|
-
while (currentDir !== path.parse(currentDir).root) {
|
|
72
|
-
const packageJsonPath = path.join(currentDir, 'package.json');
|
|
73
|
-
const pnpmWorkspacePath = path.join(currentDir, 'pnpm-workspace.yaml');
|
|
74
|
-
// Check if this directory has package.json with workspaces or pnpm-workspace.yaml
|
|
75
|
-
if (fs_1.default.existsSync(packageJsonPath)) {
|
|
76
|
-
try {
|
|
77
|
-
const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf8'));
|
|
78
|
-
// If it has workspaces or is the root monorepo package
|
|
79
|
-
if (packageJson.workspaces || fs_1.default.existsSync(pnpmWorkspacePath)) {
|
|
80
|
-
console.log('✅ Found monorepo root:', currentDir);
|
|
81
|
-
return currentDir;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
// Continue searching if package.json is invalid
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
// Check if we're at the git root
|
|
89
|
-
const gitPath = path.join(currentDir, '.git');
|
|
90
|
-
if (fs_1.default.existsSync(gitPath)) {
|
|
91
|
-
console.log('✅ Found git root (likely monorepo root):', currentDir);
|
|
92
|
-
return currentDir;
|
|
93
|
-
}
|
|
94
|
-
// Go up one directory
|
|
95
|
-
const parentDir = path.dirname(currentDir);
|
|
96
|
-
if (parentDir === currentDir)
|
|
97
|
-
break; // Prevent infinite loop
|
|
98
|
-
currentDir = parentDir;
|
|
99
|
-
}
|
|
100
|
-
// Fallback to process.cwd() if we can't find the root
|
|
101
|
-
console.log('⚠️ Could not find monorepo root, using process.cwd():', process.cwd());
|
|
102
|
-
return process.cwd();
|
|
103
|
-
}
|
|
17
|
+
// Start the Express server and dashboard
|
|
18
|
+
(0, index_1.startServer)(rootPath);
|
|
19
|
+
(0, index_1.serveDashboard)(rootPath);
|
|
@@ -4,14 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getCommitsByPathService = void 0;
|
|
7
|
-
const gitService_1 = require("
|
|
7
|
+
const gitService_1 = require("./gitService");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const getCommitsByPathService = async (packagePath) => {
|
|
11
11
|
// Decode the package path
|
|
12
12
|
const decodedPath = decodeURIComponent(packagePath);
|
|
13
|
-
console.log('
|
|
14
|
-
console.log('
|
|
13
|
+
console.log('Fetching commits for path:', decodedPath);
|
|
14
|
+
console.log('Current working directory:', process.cwd());
|
|
15
15
|
const gitService = new gitService_1.GitService();
|
|
16
16
|
// Check if this is an absolute path and convert to relative if needed
|
|
17
17
|
let relativePath = decodedPath;
|
|
@@ -19,19 +19,19 @@ const getCommitsByPathService = async (packagePath) => {
|
|
|
19
19
|
// If it's an absolute path, make it relative to project root
|
|
20
20
|
if (path_1.default.isAbsolute(decodedPath)) {
|
|
21
21
|
relativePath = path_1.default.relative(projectRoot, decodedPath);
|
|
22
|
-
console.log('
|
|
22
|
+
console.log('Converted absolute path to relative:', relativePath);
|
|
23
23
|
}
|
|
24
24
|
// Check if the path exists
|
|
25
25
|
try {
|
|
26
26
|
await fs_1.default.promises.access(relativePath);
|
|
27
|
-
console.log('
|
|
27
|
+
console.log('Path exists:', relativePath);
|
|
28
28
|
}
|
|
29
29
|
catch (fsError) {
|
|
30
|
-
console.log('
|
|
30
|
+
console.log('Path does not exist:', relativePath);
|
|
31
31
|
// Try the original path as well
|
|
32
32
|
try {
|
|
33
33
|
await fs_1.default.promises.access(decodedPath);
|
|
34
|
-
console.log('
|
|
34
|
+
console.log('Original path exists:', decodedPath);
|
|
35
35
|
relativePath = decodedPath; // Use original path if it exists
|
|
36
36
|
}
|
|
37
37
|
catch (secondError) {
|
|
@@ -150,12 +150,12 @@ async function scanConfigFiles(rootDir) {
|
|
|
150
150
|
return filename.toLowerCase() === pattern.toLowerCase();
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
|
-
console.log(
|
|
153
|
+
console.log(`Scanning for config files in: ${rootDir}`);
|
|
154
154
|
// Start scanning from root
|
|
155
155
|
scanDirectory(rootDir);
|
|
156
156
|
// Sort files by path for consistent ordering
|
|
157
157
|
configFiles.sort((a, b) => a.path.localeCompare(b.path));
|
|
158
|
-
console.log(
|
|
158
|
+
console.log(`Found ${configFiles.length} configuration files`);
|
|
159
159
|
// Log some sample files for debugging
|
|
160
160
|
if (configFiles.length > 0) {
|
|
161
161
|
console.log('Sample config files found:');
|
|
@@ -238,8 +238,8 @@ const getConfigurationFilesService = async (rootDir) => {
|
|
|
238
238
|
exports.getConfigurationFilesService = getConfigurationFilesService;
|
|
239
239
|
const updateConfigFileService = async (id, rootDir, content) => {
|
|
240
240
|
const filePath = path_1.default.join(rootDir, id.startsWith('/') ? id.slice(1) : id);
|
|
241
|
-
console.log('
|
|
242
|
-
console.log('
|
|
241
|
+
console.log('Saving file:', filePath);
|
|
242
|
+
console.log('Root directory:', rootDir);
|
|
243
243
|
// Security check: ensure the file is within the project directory
|
|
244
244
|
if (!filePath.startsWith(rootDir)) {
|
|
245
245
|
throw new Error('Invalid file path');
|
|
@@ -342,7 +342,7 @@ const updatePackageConfigurationService = async (packagePath, packageName, confi
|
|
|
342
342
|
updateData.devDependencies = JSON.stringify(newConfig.devDependencies);
|
|
343
343
|
if (newConfig.peerDependencies)
|
|
344
344
|
updateData.peerDependencies = JSON.stringify(newConfig.peerDependencies);
|
|
345
|
-
console.log('
|
|
345
|
+
console.log('Updating database with:', updateData);
|
|
346
346
|
const updatedPackage = await prisma.package.update({
|
|
347
347
|
where: { name: packageName },
|
|
348
348
|
data: updateData,
|