@manojkmfsi/monodog 1.0.20 → 1.0.21
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 +6 -0
- package/dist/config-loader.js +5 -6
- package/dist/get-db-url.js +0 -1
- package/dist/index.js +219 -80
- package/dist/serve.js +7 -91
- package/dist/services/commitService.js +1 -1
- package/dist/{gitService.js → services/gitService.js} +0 -101
- package/dist/utils/utilities.js +92 -14
- package/{monodog-conf.json → monodog-config.json} +2 -4
- package/monodog-dashboard/dist/assets/{index-dadb5f0d.js → index-1a6836e4.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/get-db-url.ts +0 -2
- package/src/index.ts +227 -72
- package/src/serve.ts +6 -68
- package/src/services/commitService.ts +1 -1
- package/src/services/gitService.ts +165 -0
- package/src/utils/utilities.ts +105 -14
- package/src/gitService.ts +0 -276
- /package/{monodog-conf.example.json → monodog-config.example.json} +0 -0
package/dist/utils/utilities.js
CHANGED
|
@@ -46,12 +46,14 @@ exports.findCircularDependencies = findCircularDependencies;
|
|
|
46
46
|
exports.generateDependencyGraph = generateDependencyGraph;
|
|
47
47
|
exports.checkOutdatedDependencies = checkOutdatedDependencies;
|
|
48
48
|
exports.getPackageSize = getPackageSize;
|
|
49
|
+
exports.findMonorepoRoot = findMonorepoRoot;
|
|
49
50
|
// import { Package } from '@prisma/client';
|
|
50
51
|
const fs = __importStar(require("fs"));
|
|
51
52
|
const path_1 = __importDefault(require("path"));
|
|
52
53
|
const config_loader_1 = require("../config-loader");
|
|
53
54
|
const health_utils_1 = require("./health-utils");
|
|
54
55
|
Object.defineProperty(exports, "calculatePackageHealth", { enumerable: true, get: function () { return health_utils_1.calculatePackageHealth; } });
|
|
56
|
+
const yaml = __importStar(require("js-yaml"));
|
|
55
57
|
/**
|
|
56
58
|
* Resolves simple workspace globs (like 'packages/*', 'apps/*') into actual package directory paths.
|
|
57
59
|
* Note: This implementation only handles the 'folder/*' pattern and is not a full glob resolver.
|
|
@@ -80,27 +82,65 @@ function resolveWorkspaceGlobs(rootDir, globs) {
|
|
|
80
82
|
return resolvedPaths;
|
|
81
83
|
}
|
|
82
84
|
/**
|
|
83
|
-
*
|
|
85
|
+
* Parses pnpm-workspace.yaml and extracts workspace globs
|
|
84
86
|
*/
|
|
85
|
-
function
|
|
86
|
-
const
|
|
87
|
-
if (!fs.existsSync(
|
|
88
|
-
console.warn(`\n⚠️ Warning: No package.json found at root directory: ${rootDir}`);
|
|
87
|
+
function getWorkspacesFromPnpmYaml(rootDir) {
|
|
88
|
+
const workspaceYamlPath = path_1.default.join(rootDir, 'pnpm-workspace.yaml');
|
|
89
|
+
if (!fs.existsSync(workspaceYamlPath)) {
|
|
89
90
|
return undefined;
|
|
90
91
|
}
|
|
91
92
|
try {
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
const yamlContent = fs.readFileSync(workspaceYamlPath, 'utf-8');
|
|
94
|
+
const yamlData = yaml.load(yamlContent);
|
|
95
|
+
if (yamlData && yamlData.packages) {
|
|
96
|
+
// Filter out exclusion patterns (lines starting with '!')
|
|
97
|
+
const packages = Array.isArray(yamlData.packages)
|
|
98
|
+
? yamlData.packages.filter((pkg) => typeof pkg === 'string' && !pkg.startsWith('!'))
|
|
99
|
+
: [];
|
|
100
|
+
if (packages.length > 0) {
|
|
101
|
+
return packages;
|
|
102
|
+
}
|
|
99
103
|
}
|
|
100
104
|
}
|
|
101
105
|
catch (e) {
|
|
102
|
-
console.error(`\n❌ Error parsing
|
|
106
|
+
console.error(`\n❌ Error parsing pnpm-workspace.yaml at ${workspaceYamlPath}:`, e);
|
|
107
|
+
}
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Reads workspace configuration from package.json or pnpm-workspace.yaml
|
|
112
|
+
* Priority: package.json (if exists) -> pnpm-workspace.yaml
|
|
113
|
+
*/
|
|
114
|
+
function getWorkspacesFromRoot(rootDir) {
|
|
115
|
+
const packageJsonPath = path_1.default.join(rootDir, 'package.json');
|
|
116
|
+
// Try package.json first
|
|
117
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
118
|
+
try {
|
|
119
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
120
|
+
// Handle both standard array and object format (used by yarn/pnpm)
|
|
121
|
+
if (Array.isArray(packageJson.workspaces)) {
|
|
122
|
+
console.log('✅ Workspace configuration found in package.json');
|
|
123
|
+
return packageJson.workspaces;
|
|
124
|
+
}
|
|
125
|
+
else if (packageJson.workspaces && Array.isArray(packageJson.workspaces.packages)) {
|
|
126
|
+
console.log('✅ Workspace configuration found in package.json');
|
|
127
|
+
return packageJson.workspaces.packages;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
console.error(`\n❌ Error parsing package.json at ${packageJsonPath}. Attempting to read pnpm-workspace.yaml...`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
console.warn(`\n⚠️ Warning: No package.json found at root directory: ${rootDir}`);
|
|
136
|
+
}
|
|
137
|
+
// Fallback to pnpm-workspace.yaml
|
|
138
|
+
const pnpmWorkspaces = getWorkspacesFromPnpmYaml(rootDir);
|
|
139
|
+
if (pnpmWorkspaces && pnpmWorkspaces.length > 0) {
|
|
140
|
+
console.log('✅ Workspace configuration found in pnpm-workspace.yaml');
|
|
141
|
+
return pnpmWorkspaces;
|
|
103
142
|
}
|
|
143
|
+
console.warn('\n⚠️ No workspace configuration found in package.json or pnpm-workspace.yaml');
|
|
104
144
|
return undefined;
|
|
105
145
|
}
|
|
106
146
|
/**
|
|
@@ -110,7 +150,7 @@ function scanMonorepo(rootDir) {
|
|
|
110
150
|
const packages = [];
|
|
111
151
|
console.log('rootDir:', rootDir);
|
|
112
152
|
const workspacesGlobs = config_loader_1.appConfig.workspaces;
|
|
113
|
-
// Use provided workspaces globs if given, otherwise attempt to detect from root package.json
|
|
153
|
+
// Use provided workspaces globs if given, otherwise attempt to detect from root package.json or pnpm-workspace.yaml
|
|
114
154
|
const detectedWorkspacesGlobs = workspacesGlobs.length > 0 ? workspacesGlobs : getWorkspacesFromRoot(rootDir);
|
|
115
155
|
if (detectedWorkspacesGlobs && detectedWorkspacesGlobs.length > 0) {
|
|
116
156
|
if (workspacesGlobs.length) {
|
|
@@ -326,3 +366,41 @@ function getPackageSize(packagePath) {
|
|
|
326
366
|
return { size: 0, files: 0 };
|
|
327
367
|
}
|
|
328
368
|
}
|
|
369
|
+
/**
|
|
370
|
+
* Find the monorepo root by looking for package.json with workspaces or pnpm-workspace.yaml
|
|
371
|
+
*/
|
|
372
|
+
function findMonorepoRoot() {
|
|
373
|
+
let currentDir = __dirname;
|
|
374
|
+
while (currentDir !== path_1.default.parse(currentDir).root) {
|
|
375
|
+
const packageJsonPath = path_1.default.join(currentDir, 'package.json');
|
|
376
|
+
const pnpmWorkspacePath = path_1.default.join(currentDir, 'pnpm-workspace.yaml');
|
|
377
|
+
// Check if this directory has package.json with workspaces or pnpm-workspace.yaml
|
|
378
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
379
|
+
try {
|
|
380
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
381
|
+
// If it has workspaces or is the root monorepo package
|
|
382
|
+
if (packageJson.workspaces || fs.existsSync(pnpmWorkspacePath)) {
|
|
383
|
+
console.log('✅ Found monorepo root:', currentDir);
|
|
384
|
+
return currentDir;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
catch (error) {
|
|
388
|
+
// Continue searching if package.json is invalid
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
// Check if we're at the git root
|
|
392
|
+
const gitPath = path_1.default.join(currentDir, '.git');
|
|
393
|
+
if (fs.existsSync(gitPath)) {
|
|
394
|
+
console.log('✅ Found git root (likely monorepo root):', currentDir);
|
|
395
|
+
return currentDir;
|
|
396
|
+
}
|
|
397
|
+
// Go up one directory
|
|
398
|
+
const parentDir = path_1.default.dirname(currentDir);
|
|
399
|
+
if (parentDir === currentDir)
|
|
400
|
+
break; // Prevent infinite loop
|
|
401
|
+
currentDir = parentDir;
|
|
402
|
+
}
|
|
403
|
+
// Fallback to process.cwd() if we can't find the root
|
|
404
|
+
console.log('⚠️ Could not find monorepo root, using process.cwd():', process.cwd());
|
|
405
|
+
return process.cwd();
|
|
406
|
+
}
|