@manojkmfsi/monodog 1.1.6 → 1.1.8
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/package.json +1 -1
- package/src/config/swagger-config.ts +0 -344
- package/src/config-loader.ts +0 -97
- package/src/constants/index.ts +0 -13
- package/src/constants/middleware.ts +0 -83
- package/src/constants/port.ts +0 -20
- package/src/constants/security.ts +0 -78
- package/src/controllers/commit-controller.ts +0 -31
- package/src/controllers/config-controller.ts +0 -42
- package/src/controllers/health-controller.ts +0 -24
- package/src/controllers/package-controller.ts +0 -67
- package/src/get-db-url.ts +0 -9
- package/src/index.ts +0 -9
- package/src/middleware/dashboard-startup.ts +0 -161
- package/src/middleware/error-handler.ts +0 -50
- package/src/middleware/index.ts +0 -20
- package/src/middleware/logger.ts +0 -65
- package/src/middleware/security.ts +0 -90
- package/src/middleware/server-startup.ts +0 -153
- package/src/middleware/swagger-middleware.ts +0 -58
- package/src/repositories/commit-repository.ts +0 -108
- package/src/repositories/dependency-repository.ts +0 -110
- package/src/repositories/index.ts +0 -10
- package/src/repositories/package-health-repository.ts +0 -75
- package/src/repositories/package-repository.ts +0 -142
- package/src/repositories/prisma-client.ts +0 -25
- package/src/routes/commit-routes.ts +0 -10
- package/src/routes/config-routes.ts +0 -14
- package/src/routes/health-routes.ts +0 -14
- package/src/routes/package-routes.ts +0 -22
- package/src/serve.ts +0 -41
- package/src/services/commit-service.ts +0 -44
- package/src/services/config-service.ts +0 -391
- package/src/services/git-service.ts +0 -140
- package/src/services/health-service.ts +0 -162
- package/src/services/package-service.ts +0 -228
- package/src/setup.ts +0 -78
- package/src/types/ci.ts +0 -122
- package/src/types/config.ts +0 -22
- package/src/types/database.ts +0 -67
- package/src/types/git.ts +0 -33
- package/src/types/health.ts +0 -11
- package/src/types/index.ts +0 -23
- package/src/types/package.ts +0 -39
- package/src/types/scanner.ts +0 -31
- package/src/types/swagger-jsdoc.d.ts +0 -15
- package/src/utils/ci-status.ts +0 -535
- package/src/utils/db-utils.ts +0 -92
- package/src/utils/health-utils.ts +0 -67
- package/src/utils/monorepo-scanner.ts +0 -576
- package/src/utils/utilities.ts +0 -427
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Swagger Documentation Middleware
|
|
3
|
-
* Sets up Swagger UI for API documentation
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import swaggerUi from 'swagger-ui-express';
|
|
7
|
-
import swaggerJsDoc from 'swagger-jsdoc';
|
|
8
|
-
import type { Express, Request, Response } from 'express';
|
|
9
|
-
import { AppLogger } from './logger';
|
|
10
|
-
import { swaggerOptions } from '../config/swagger-config';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Setup Swagger documentation endpoint
|
|
14
|
-
* @param app Express application instance
|
|
15
|
-
*/
|
|
16
|
-
export function setupSwaggerDocs(app: Express): void {
|
|
17
|
-
try {
|
|
18
|
-
const specs = swaggerJsDoc(swaggerOptions) as Record<string, unknown>;
|
|
19
|
-
|
|
20
|
-
// Serve raw Swagger JSON FIRST (before the middleware catches all /api-docs paths)
|
|
21
|
-
app.get('/api-docs/swagger.json', (_req: Request, res: Response) => {
|
|
22
|
-
res.setHeader('Content-Type', 'application/json');
|
|
23
|
-
res.send(specs);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
// Serve Swagger UI at /api-docs
|
|
27
|
-
app.use(
|
|
28
|
-
'/api-docs',
|
|
29
|
-
swaggerUi.serve,
|
|
30
|
-
swaggerUi.setup(specs, {
|
|
31
|
-
swaggerOptions: {
|
|
32
|
-
url: '/api-docs/swagger.json',
|
|
33
|
-
persistAuthorization: true,
|
|
34
|
-
displayOperationId: true,
|
|
35
|
-
filter: true,
|
|
36
|
-
showExtensions: true,
|
|
37
|
-
},
|
|
38
|
-
customCss: `
|
|
39
|
-
.swagger-ui .topbar {
|
|
40
|
-
background-color: #2c3e50;
|
|
41
|
-
}
|
|
42
|
-
.swagger-ui .info .title {
|
|
43
|
-
color: #2c3e50;
|
|
44
|
-
font-weight: bold;
|
|
45
|
-
}
|
|
46
|
-
.swagger-ui .btn-box .btn {
|
|
47
|
-
background-color: #2c3e50;
|
|
48
|
-
}
|
|
49
|
-
`,
|
|
50
|
-
customCssUrl: 'https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/4.15.5/swagger-ui.min.css',
|
|
51
|
-
})
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
AppLogger.info('Swagger documentation available at /api-docs');
|
|
55
|
-
} catch (error) {
|
|
56
|
-
AppLogger.error('Failed to setup Swagger documentation', error as Error);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { getPrismaClient, getPrismaErrors } from './prisma-client';
|
|
2
|
-
import { AppLogger } from '../middleware/logger';
|
|
3
|
-
import type { Commit } from '../types';
|
|
4
|
-
|
|
5
|
-
const prisma = getPrismaClient();
|
|
6
|
-
const Prisma = getPrismaErrors();
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Commit Repository - Handles all Commit-related database operations
|
|
10
|
-
*/
|
|
11
|
-
export class CommitRepository {
|
|
12
|
-
/**
|
|
13
|
-
* Find all commits for a package
|
|
14
|
-
*/
|
|
15
|
-
static async findByPackageName(packageName: string) {
|
|
16
|
-
return await prisma.commit.findMany({
|
|
17
|
-
where: { packageName },
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Find a specific commit
|
|
23
|
-
*/
|
|
24
|
-
static async findByHash(hash: string, packageName: string) {
|
|
25
|
-
return await prisma.commit.findUnique({
|
|
26
|
-
where: {
|
|
27
|
-
hash_packageName: {
|
|
28
|
-
hash,
|
|
29
|
-
packageName,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Create or update a commit
|
|
37
|
-
*/
|
|
38
|
-
static async upsert(data: {
|
|
39
|
-
hash: string;
|
|
40
|
-
message?: string;
|
|
41
|
-
author?: string;
|
|
42
|
-
date?: string | Date;
|
|
43
|
-
type?: string;
|
|
44
|
-
packageName: string;
|
|
45
|
-
}) {
|
|
46
|
-
try {
|
|
47
|
-
return await prisma.commit.upsert({
|
|
48
|
-
where: {
|
|
49
|
-
hash_packageName: {
|
|
50
|
-
hash: data.hash,
|
|
51
|
-
packageName: data.packageName,
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
update: {
|
|
55
|
-
message: data.message || '',
|
|
56
|
-
author: data.author || '',
|
|
57
|
-
date: data.date,
|
|
58
|
-
type: data.type || '',
|
|
59
|
-
},
|
|
60
|
-
create: {
|
|
61
|
-
hash: data.hash,
|
|
62
|
-
message: data.message || '',
|
|
63
|
-
author: data.author || '',
|
|
64
|
-
date: data.date,
|
|
65
|
-
type: data.type || '',
|
|
66
|
-
packageName: data.packageName,
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
} catch (e) {
|
|
70
|
-
const err = e as Error & { code?: string };
|
|
71
|
-
if (
|
|
72
|
-
err instanceof Prisma.PrismaClientKnownRequestError &&
|
|
73
|
-
err.code === 'P2002'
|
|
74
|
-
) {
|
|
75
|
-
AppLogger.warn(`Skipping commit: ${data.hash} (Commit already exists)`);
|
|
76
|
-
} else {
|
|
77
|
-
AppLogger.error(`Failed to store commit: ${data.hash}`, err);
|
|
78
|
-
throw err;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Store multiple commits
|
|
85
|
-
*/
|
|
86
|
-
static async storeMany(packageName: string, commits: Commit[]) {
|
|
87
|
-
AppLogger.debug('Storing commits for: ' + packageName);
|
|
88
|
-
for (const commit of commits) {
|
|
89
|
-
await this.upsert({
|
|
90
|
-
hash: commit.hash,
|
|
91
|
-
message: commit.message,
|
|
92
|
-
author: commit.author,
|
|
93
|
-
date: commit.date,
|
|
94
|
-
type: commit.type,
|
|
95
|
-
packageName,
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Delete all commits for a package
|
|
102
|
-
*/
|
|
103
|
-
static async deleteByPackageName(packageName: string) {
|
|
104
|
-
return await prisma.commit.deleteMany({
|
|
105
|
-
where: { packageName },
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { getPrismaClient, getPrismaErrors } from './prisma-client';
|
|
2
|
-
import { AppLogger } from '../middleware/logger';
|
|
3
|
-
import type { DependencyInfo } from '../types';
|
|
4
|
-
|
|
5
|
-
const prisma = getPrismaClient();
|
|
6
|
-
const Prisma = getPrismaErrors();
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Dependency Repository - Handles all DependencyInfo-related database operations
|
|
10
|
-
*/
|
|
11
|
-
export class DependencyRepository {
|
|
12
|
-
/**
|
|
13
|
-
* Find all dependencies for a package
|
|
14
|
-
*/
|
|
15
|
-
static async findByPackageName(packageName: string) {
|
|
16
|
-
return await prisma.dependencyInfo.findMany({
|
|
17
|
-
where: { packageName },
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Find a specific dependency
|
|
23
|
-
*/
|
|
24
|
-
static async findByNameAndPackage(name: string, packageName: string) {
|
|
25
|
-
return await prisma.dependencyInfo.findUnique({
|
|
26
|
-
where: {
|
|
27
|
-
name_packageName: {
|
|
28
|
-
name,
|
|
29
|
-
packageName,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Create or update a dependency
|
|
37
|
-
*/
|
|
38
|
-
static async upsert(data: {
|
|
39
|
-
name: string;
|
|
40
|
-
version: string;
|
|
41
|
-
type: string;
|
|
42
|
-
latest?: string;
|
|
43
|
-
outdated?: boolean;
|
|
44
|
-
packageName: string;
|
|
45
|
-
}) {
|
|
46
|
-
try {
|
|
47
|
-
return await prisma.dependencyInfo.upsert({
|
|
48
|
-
where: {
|
|
49
|
-
name_packageName: {
|
|
50
|
-
name: data.name,
|
|
51
|
-
packageName: data.packageName,
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
update: {
|
|
55
|
-
version: data.version,
|
|
56
|
-
type: data.type,
|
|
57
|
-
latest: data.latest || '',
|
|
58
|
-
outdated: data.outdated ?? false,
|
|
59
|
-
},
|
|
60
|
-
create: {
|
|
61
|
-
name: data.name,
|
|
62
|
-
version: data.version,
|
|
63
|
-
type: data.type,
|
|
64
|
-
latest: data.latest || '',
|
|
65
|
-
outdated: data.outdated ?? false,
|
|
66
|
-
packageName: data.packageName,
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
} catch (e) {
|
|
70
|
-
const err = e as Error & { code?: string };
|
|
71
|
-
if (
|
|
72
|
-
err instanceof Prisma.PrismaClientKnownRequestError &&
|
|
73
|
-
err.code === 'P2002'
|
|
74
|
-
) {
|
|
75
|
-
AppLogger.warn(
|
|
76
|
-
`Skipping dependency: ${data.name} (Dependency already exists)`
|
|
77
|
-
);
|
|
78
|
-
} else {
|
|
79
|
-
AppLogger.error(`Failed to store dependency: ${data.name}`, err);
|
|
80
|
-
throw err;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Store multiple dependencies
|
|
87
|
-
*/
|
|
88
|
-
static async storeMany(packageName: string, dependencies: DependencyInfo[]) {
|
|
89
|
-
AppLogger.debug('Storing Dependencies for: ' + packageName);
|
|
90
|
-
for (const dep of dependencies) {
|
|
91
|
-
await this.upsert({
|
|
92
|
-
name: dep.name,
|
|
93
|
-
version: dep.version,
|
|
94
|
-
type: dep.type,
|
|
95
|
-
latest: dep.latest,
|
|
96
|
-
outdated: dep.outdated,
|
|
97
|
-
packageName,
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Delete all dependencies for a package
|
|
104
|
-
*/
|
|
105
|
-
static async deleteByPackageName(packageName: string) {
|
|
106
|
-
return await prisma.dependencyInfo.deleteMany({
|
|
107
|
-
where: { packageName },
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Repository Pattern Index
|
|
3
|
-
* Exports all repositories for data access layer
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export { PackageRepository } from './package-repository';
|
|
7
|
-
export { PackageHealthRepository } from './package-health-repository';
|
|
8
|
-
export { CommitRepository } from './commit-repository';
|
|
9
|
-
export { DependencyRepository } from './dependency-repository';
|
|
10
|
-
export { getPrismaClient, getPrismaErrors } from './prisma-client';
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { getPrismaClient } from './prisma-client';
|
|
2
|
-
|
|
3
|
-
const prisma = getPrismaClient();
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Package Health Repository - Handles all PackageHealth-related database operations
|
|
7
|
-
*/
|
|
8
|
-
export class PackageHealthRepository {
|
|
9
|
-
/**
|
|
10
|
-
* Find all package health records
|
|
11
|
-
*/
|
|
12
|
-
static async findAll() {
|
|
13
|
-
return await prisma.packageHealth.findMany();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Find package health by package name
|
|
18
|
-
*/
|
|
19
|
-
static async findByPackageName(packageName: string) {
|
|
20
|
-
return await prisma.packageHealth.findUnique({
|
|
21
|
-
where: { packageName },
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Create or update package health record
|
|
27
|
-
*/
|
|
28
|
-
static async upsert(data: {
|
|
29
|
-
packageName: string;
|
|
30
|
-
packageOverallScore: number;
|
|
31
|
-
packageBuildStatus: string;
|
|
32
|
-
packageTestCoverage: number;
|
|
33
|
-
packageLintStatus: string;
|
|
34
|
-
packageSecurity: string;
|
|
35
|
-
packageDependencies?: string;
|
|
36
|
-
}) {
|
|
37
|
-
return await prisma.packageHealth.upsert({
|
|
38
|
-
where: { packageName: data.packageName },
|
|
39
|
-
update: {
|
|
40
|
-
packageOverallScore: data.packageOverallScore,
|
|
41
|
-
packageBuildStatus: data.packageBuildStatus,
|
|
42
|
-
packageTestCoverage: data.packageTestCoverage,
|
|
43
|
-
packageLintStatus: data.packageLintStatus,
|
|
44
|
-
packageSecurity: data.packageSecurity,
|
|
45
|
-
packageDependencies: data.packageDependencies || '',
|
|
46
|
-
updatedAt: new Date(),
|
|
47
|
-
},
|
|
48
|
-
create: {
|
|
49
|
-
packageName: data.packageName,
|
|
50
|
-
packageOverallScore: data.packageOverallScore,
|
|
51
|
-
packageBuildStatus: data.packageBuildStatus,
|
|
52
|
-
packageTestCoverage: data.packageTestCoverage,
|
|
53
|
-
packageLintStatus: data.packageLintStatus,
|
|
54
|
-
packageSecurity: data.packageSecurity,
|
|
55
|
-
packageDependencies: data.packageDependencies || '',
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Delete package health record
|
|
62
|
-
*/
|
|
63
|
-
static async deleteByPackageName(packageName: string) {
|
|
64
|
-
return await prisma.packageHealth.delete({
|
|
65
|
-
where: { packageName },
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Delete all package health records
|
|
71
|
-
*/
|
|
72
|
-
static async deleteAll() {
|
|
73
|
-
return await prisma.packageHealth.deleteMany();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { getPrismaClient } from './prisma-client';
|
|
2
|
-
import type { PackageInfo } from '../types';
|
|
3
|
-
|
|
4
|
-
const prisma = getPrismaClient();
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Package Repository - Handles all Package-related database operations
|
|
8
|
-
*/
|
|
9
|
-
export class PackageRepository {
|
|
10
|
-
/**
|
|
11
|
-
* Find all packages
|
|
12
|
-
*/
|
|
13
|
-
static async findAll() {
|
|
14
|
-
return await prisma.package.findMany();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Find a package by name
|
|
19
|
-
*/
|
|
20
|
-
static async findByName(name: string) {
|
|
21
|
-
return await prisma.package.findUnique({
|
|
22
|
-
where: { name },
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Find a package with related data
|
|
28
|
-
*/
|
|
29
|
-
static async findByNameWithRelations(name: string) {
|
|
30
|
-
return await prisma.package.findUnique({
|
|
31
|
-
where: { name },
|
|
32
|
-
include: {
|
|
33
|
-
dependenciesInfo: true,
|
|
34
|
-
commits: true,
|
|
35
|
-
packageHealth: true,
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Create or update a package
|
|
42
|
-
*/
|
|
43
|
-
static async upsert(data: {
|
|
44
|
-
name: string;
|
|
45
|
-
version?: string;
|
|
46
|
-
type?: string;
|
|
47
|
-
path?: string;
|
|
48
|
-
description?: string;
|
|
49
|
-
license?: string;
|
|
50
|
-
repository?: Record<string, unknown>;
|
|
51
|
-
scripts?: Record<string, unknown>;
|
|
52
|
-
dependencies?: Record<string, unknown>;
|
|
53
|
-
devDependencies?: Record<string, unknown>;
|
|
54
|
-
peerDependencies?: Record<string, unknown>;
|
|
55
|
-
maintainers?: string;
|
|
56
|
-
status?: string;
|
|
57
|
-
}) {
|
|
58
|
-
const createData = {
|
|
59
|
-
createdAt: new Date(),
|
|
60
|
-
lastUpdated: new Date(),
|
|
61
|
-
dependencies: JSON.stringify(data.dependencies || {}),
|
|
62
|
-
maintainers: typeof data.maintainers === 'string' ? data.maintainers : '',
|
|
63
|
-
scripts: JSON.stringify(data.scripts || {}),
|
|
64
|
-
devDependencies: JSON.stringify(data.devDependencies || {}),
|
|
65
|
-
peerDependencies: JSON.stringify(data.peerDependencies || {}),
|
|
66
|
-
name: data.name,
|
|
67
|
-
version: data.version || '',
|
|
68
|
-
type: data.type || '',
|
|
69
|
-
path: data.path || '',
|
|
70
|
-
description: data.description || '',
|
|
71
|
-
license: data.license || '',
|
|
72
|
-
repository: JSON.stringify(data.repository || {}),
|
|
73
|
-
status: data.status || '',
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const updateData = {
|
|
77
|
-
version: data.version,
|
|
78
|
-
type: data.type,
|
|
79
|
-
path: data.path,
|
|
80
|
-
description: data.description,
|
|
81
|
-
license: data.license,
|
|
82
|
-
repository: JSON.stringify(data.repository || {}),
|
|
83
|
-
scripts: JSON.stringify(data.scripts || {}),
|
|
84
|
-
lastUpdated: new Date(),
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
return await prisma.package.upsert({
|
|
88
|
-
where: { name: data.name },
|
|
89
|
-
create: createData,
|
|
90
|
-
update: updateData,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Update package status
|
|
96
|
-
*/
|
|
97
|
-
static async updateStatus(name: string, status: string) {
|
|
98
|
-
return await prisma.package.update({
|
|
99
|
-
where: { name },
|
|
100
|
-
data: { status },
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Update package configuration
|
|
106
|
-
*/
|
|
107
|
-
static async updateConfig(name: string, updateData: Record<string, unknown>) {
|
|
108
|
-
const data: Record<string, unknown> = {
|
|
109
|
-
lastUpdated: new Date(),
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
if (updateData.version) data.version = updateData.version;
|
|
113
|
-
if (updateData.description !== undefined) data.description = updateData.description || '';
|
|
114
|
-
if (updateData.license !== undefined) data.license = updateData.license || '';
|
|
115
|
-
if (updateData.scripts) data.scripts = JSON.stringify(updateData.scripts);
|
|
116
|
-
if (updateData.repository) data.repository = JSON.stringify(updateData.repository);
|
|
117
|
-
if (updateData.dependencies) data.dependencies = JSON.stringify(updateData.dependencies);
|
|
118
|
-
if (updateData.devDependencies) data.devDependencies = JSON.stringify(updateData.devDependencies);
|
|
119
|
-
if (updateData.peerDependencies) data.peerDependencies = JSON.stringify(updateData.peerDependencies);
|
|
120
|
-
|
|
121
|
-
return await prisma.package.update({
|
|
122
|
-
where: { name },
|
|
123
|
-
data,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Delete all packages
|
|
129
|
-
*/
|
|
130
|
-
static async deleteAll() {
|
|
131
|
-
return await prisma.package.deleteMany();
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Delete a package by name
|
|
136
|
-
*/
|
|
137
|
-
static async deleteByName(name: string) {
|
|
138
|
-
return await prisma.package.delete({
|
|
139
|
-
where: { name },
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as PrismaPkg from '@prisma/client';
|
|
2
|
-
|
|
3
|
-
const PrismaClient = (PrismaPkg as any).PrismaClient || (PrismaPkg as any).default || PrismaPkg;
|
|
4
|
-
const Prisma = (PrismaPkg as any).Prisma || (PrismaPkg as any).PrismaClient?.Prisma || (PrismaPkg as any).default?.Prisma || PrismaPkg;
|
|
5
|
-
|
|
6
|
-
let prismaInstance: ReturnType<typeof PrismaClient> | null = null;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Get singleton instance of Prisma Client
|
|
10
|
-
*/
|
|
11
|
-
export function getPrismaClient() {
|
|
12
|
-
if (!prismaInstance) {
|
|
13
|
-
prismaInstance = new PrismaClient();
|
|
14
|
-
}
|
|
15
|
-
return prismaInstance;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Get Prisma error classes for error handling
|
|
20
|
-
*/
|
|
21
|
-
export function getPrismaErrors() {
|
|
22
|
-
return Prisma;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default getPrismaClient;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import express from 'express';
|
|
2
|
-
import { getConfigurationFiles, updateConfigFile } from '../controllers/config-controller';
|
|
3
|
-
|
|
4
|
-
const configRouter = express.Router();
|
|
5
|
-
|
|
6
|
-
configRouter
|
|
7
|
-
.route('/files')
|
|
8
|
-
.get(getConfigurationFiles);
|
|
9
|
-
|
|
10
|
-
configRouter
|
|
11
|
-
.route('/files/:id')
|
|
12
|
-
.put(updateConfigFile);
|
|
13
|
-
|
|
14
|
-
export default configRouter;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import express from 'express';
|
|
2
|
-
import { getPackagesHealth, refreshHealth } from '../controllers/health-controller';
|
|
3
|
-
|
|
4
|
-
const healthRouter = express.Router();
|
|
5
|
-
|
|
6
|
-
healthRouter
|
|
7
|
-
.route('/refresh')
|
|
8
|
-
.post(refreshHealth);
|
|
9
|
-
|
|
10
|
-
healthRouter
|
|
11
|
-
.route('/packages')
|
|
12
|
-
.get(getPackagesHealth);
|
|
13
|
-
|
|
14
|
-
export default healthRouter;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import express from 'express';
|
|
2
|
-
import { getPackages, refreshPackages, getPackageDetail, updatePackageConfig } from '../controllers/package-controller';
|
|
3
|
-
|
|
4
|
-
const packageRouter = express.Router();
|
|
5
|
-
|
|
6
|
-
packageRouter
|
|
7
|
-
.route('/refresh')
|
|
8
|
-
.post(refreshPackages);
|
|
9
|
-
|
|
10
|
-
packageRouter
|
|
11
|
-
.route('/update-config')
|
|
12
|
-
.put(updatePackageConfig);
|
|
13
|
-
|
|
14
|
-
packageRouter
|
|
15
|
-
.route('/:name')
|
|
16
|
-
.get(getPackageDetail);
|
|
17
|
-
|
|
18
|
-
packageRouter
|
|
19
|
-
.route('/')
|
|
20
|
-
.get(getPackages);
|
|
21
|
-
|
|
22
|
-
export default packageRouter;
|
package/src/serve.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* CLI Entry Point for serving Monodog.
|
|
5
|
-
* This script is executed when a user runs the serve command
|
|
6
|
-
* in their project. It handles command-line arguments to determine
|
|
7
|
-
* whether to:
|
|
8
|
-
* 1. Start the API server for the dashboard.
|
|
9
|
-
* 2. Start serving the dashboard frontend.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { startServer, serveDashboard } from './index';
|
|
13
|
-
import { findMonorepoRoot } from './utils/utilities';
|
|
14
|
-
|
|
15
|
-
let logLevel = '';
|
|
16
|
-
let nodeEnv = 'production';
|
|
17
|
-
|
|
18
|
-
const args = process.argv;
|
|
19
|
-
|
|
20
|
-
if (args.includes('--dev')) {
|
|
21
|
-
nodeEnv = 'development';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Priority: Check for debug first, then fall back to info
|
|
25
|
-
if (args.includes('--debug')) {
|
|
26
|
-
logLevel = 'debug';
|
|
27
|
-
} else if (args.includes('--info')) {
|
|
28
|
-
logLevel = 'info';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
process.env.LOG_LEVEL = logLevel;
|
|
32
|
-
process.env.NODE_ENV = nodeEnv
|
|
33
|
-
|
|
34
|
-
const rootPath = findMonorepoRoot();
|
|
35
|
-
|
|
36
|
-
// Start the Express server and dashboard
|
|
37
|
-
|
|
38
|
-
startServer(rootPath);
|
|
39
|
-
|
|
40
|
-
serveDashboard(rootPath);
|
|
41
|
-
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { GitService } from './git-service';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import { AppLogger } from '../middleware/logger';
|
|
5
|
-
|
|
6
|
-
export const getCommitsByPathService = async (packagePath: string) => {
|
|
7
|
-
|
|
8
|
-
// Decode the package path
|
|
9
|
-
const decodedPath = decodeURIComponent(packagePath);
|
|
10
|
-
|
|
11
|
-
AppLogger.debug('Fetching commits for path: ' + decodedPath);
|
|
12
|
-
AppLogger.debug('Current working directory: ' + process.cwd());
|
|
13
|
-
|
|
14
|
-
const gitService = new GitService();
|
|
15
|
-
|
|
16
|
-
// Check if this is an absolute path and convert to relative if needed
|
|
17
|
-
let relativePath = decodedPath;
|
|
18
|
-
const projectRoot = process.cwd();
|
|
19
|
-
|
|
20
|
-
// If it's an absolute path, make it relative to project root
|
|
21
|
-
if (path.isAbsolute(decodedPath)) {
|
|
22
|
-
relativePath = path.relative(projectRoot, decodedPath);
|
|
23
|
-
AppLogger.debug('Converted absolute path to relative: ' + relativePath);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Check if the path exists
|
|
27
|
-
try {
|
|
28
|
-
await fs.promises.access(relativePath);
|
|
29
|
-
AppLogger.debug('Path exists: ' + relativePath);
|
|
30
|
-
} catch (fsError) {
|
|
31
|
-
// Try the original path as well
|
|
32
|
-
try {
|
|
33
|
-
await fs.promises.access(decodedPath);
|
|
34
|
-
AppLogger.debug('Original Commit path exists: ' + decodedPath);
|
|
35
|
-
relativePath = decodedPath; // Use original path if it exists
|
|
36
|
-
} catch (secondError) {
|
|
37
|
-
throw new Error(`Commit Path does not exist: ${decodedPath}`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const commits = await gitService.getAllCommits(relativePath);
|
|
42
|
-
|
|
43
|
-
return commits;
|
|
44
|
-
}
|