@manojkmfsi/monodog 1.0.1

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.
Files changed (61) hide show
  1. package/.eslintrc.cjs +15 -0
  2. package/.turbo/turbo-build.log +4 -0
  3. package/CHANGELOG.md +79 -0
  4. package/LICENCE +21 -0
  5. package/README.md +55 -0
  6. package/dist/config-loader.js +116 -0
  7. package/dist/get-db-url.js +10 -0
  8. package/dist/gitService.js +242 -0
  9. package/dist/index.js +1370 -0
  10. package/dist/serve.js +103 -0
  11. package/dist/setup.js +155 -0
  12. package/dist/utils/ci-status.js +446 -0
  13. package/dist/utils/helpers.js +237 -0
  14. package/dist/utils/monorepo-scanner.js +486 -0
  15. package/dist/utils/utilities.js +414 -0
  16. package/monodog-conf.example.json +16 -0
  17. package/monodog-conf.json +16 -0
  18. package/monodog-dashboard/README.md +58 -0
  19. package/monodog-dashboard/dist/assets/index-2d967652.js +71 -0
  20. package/monodog-dashboard/dist/assets/index-504dc418.css +1 -0
  21. package/monodog-dashboard/dist/index.html +15 -0
  22. package/package.json +50 -0
  23. package/prisma/migrations/20251017041048_init/migration.sql +19 -0
  24. package/prisma/migrations/20251017083007_add_package/migration.sql +21 -0
  25. package/prisma/migrations/20251021083705_alter_package/migration.sql +37 -0
  26. package/prisma/migrations/20251022085155_test/migration.sql +2 -0
  27. package/prisma/migrations/20251022160841_/migration.sql +35 -0
  28. package/prisma/migrations/20251023130158_rename_column_name/migration.sql +34 -0
  29. package/prisma/migrations/20251023174837_/migration.sql +34 -0
  30. package/prisma/migrations/20251023175830_uodate_schema/migration.sql +32 -0
  31. package/prisma/migrations/20251024103700_add_dependency_info/migration.sql +13 -0
  32. package/prisma/migrations/20251025192150_add_dependency_info/migration.sql +19 -0
  33. package/prisma/migrations/20251025192342_add_dependency_info/migration.sql +40 -0
  34. package/prisma/migrations/20251025204613_add_dependency_info/migration.sql +8 -0
  35. package/prisma/migrations/20251026071336_add_dependency_info/migration.sql +25 -0
  36. package/prisma/migrations/20251027062626_add_commit/migration.sql +10 -0
  37. package/prisma/migrations/20251027062748_add_commit/migration.sql +23 -0
  38. package/prisma/migrations/20251027092741_add_commit/migration.sql +17 -0
  39. package/prisma/migrations/20251027112736_add_health_status/migration.sql +16 -0
  40. package/prisma/migrations/20251027140546_init_packages/migration.sql +16 -0
  41. package/prisma/migrations/20251029073436_added_package_heath_key/migration.sql +34 -0
  42. package/prisma/migrations/20251029073830_added_package_health_key/migration.sql +49 -0
  43. package/prisma/migrations/20251111091920_/migration.sql +16 -0
  44. package/prisma/migrations/20251211155036_cascade_on_auto_delete/migration.sql +48 -0
  45. package/prisma/migrations/migration_lock.toml +3 -0
  46. package/prisma/schema.prisma +114 -0
  47. package/release.config.js +41 -0
  48. package/src/config-loader.ts +119 -0
  49. package/src/get-db-url.ts +11 -0
  50. package/src/gitService.ts +277 -0
  51. package/src/index.ts +1554 -0
  52. package/src/serve.ts +87 -0
  53. package/src/setup.ts +164 -0
  54. package/src/types/monorepo-scanner.d.ts +32 -0
  55. package/src/utils/ci-status.ts +639 -0
  56. package/src/utils/helpers.js +203 -0
  57. package/src/utils/helpers.js.map +1 -0
  58. package/src/utils/helpers.ts +238 -0
  59. package/src/utils/monorepo-scanner.ts +599 -0
  60. package/src/utils/utilities.ts +483 -0
  61. package/tsconfig.json +16 -0
package/dist/serve.js ADDED
@@ -0,0 +1,103 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
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
+ 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
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ const path = __importStar(require("path"));
49
+ const index_1 = require("./index"); // Assume index.ts exports this function
50
+ const config_loader_1 = require("./config-loader");
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 ---
61
+ console.log(`Starting Monodog API server...`);
62
+ console.log(`Analyzing monorepo at root: ${rootPath}`);
63
+ // Start the Express server and begin analysis
64
+ (0, index_1.startServer)(rootPath, port, host);
65
+ (0, index_1.serveDashboard)(path.join(rootPath), config_loader_1.appConfig.dashboard.port, config_loader_1.appConfig.dashboard.host);
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
+ }
package/dist/setup.js ADDED
@@ -0,0 +1,155 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ /**
38
+ * CLI Entry Point for the Setting up workspace.
39
+ * * This script is executed when a user runs the setup command
40
+ * in their project. It handles command-line arguments to determine
41
+ * whether to:
42
+ * 1. Copy monodog to workspace.
43
+ */
44
+ const fs = __importStar(require("fs"));
45
+ const path = __importStar(require("path"));
46
+ const config_loader_1 = require("./config-loader");
47
+ // --- Argument Parsing ---
48
+ // 1. Get arguments excluding the node executable and script name
49
+ const args = process.argv.slice(2);
50
+ // Default settings
51
+ let rootPath = path.resolve(process.cwd()); // Default to the current working directory ?(inside node modules)
52
+ const host = config_loader_1.appConfig.server.host ?? 'localhost'; //Default host
53
+ console.log('rp1', rootPath);
54
+ // Simple argument parsing loop
55
+ for (let i = 0; i < args.length; i++) {
56
+ const arg = args[i];
57
+ if (arg === '--root') {
58
+ // Look at the next argument for the path
59
+ if (i + 1 < args.length) {
60
+ rootPath = path.resolve(args[i + 1]);
61
+ i++; // Skip the next argument since we've consumed it
62
+ }
63
+ else {
64
+ console.error('Error: --root requires a path argument.');
65
+ process.exit(1);
66
+ }
67
+ }
68
+ }
69
+ console.log('rp2', rootPath);
70
+ // --- Execution Logic ---
71
+ console.log(`\nInitializing Setup...`);
72
+ copyPackageToWorkspace(rootPath);
73
+ console.log('\n*** Run the server ***');
74
+ console.log('npm --workspace @manojkmfsi/monoapp run serve');
75
+ process.exit(0);
76
+ /**
77
+ * Copies an installed NPM package from node_modules into the local install_path directory.
78
+ */
79
+ function copyPackageToWorkspace(rootDir) {
80
+ // 1. Get package name from arguments
81
+ // The package name is expected as the first command-line argument (process.argv[2])
82
+ const packageName = process.argv[2];
83
+ if (!packageName || packageName.startsWith('--')) {
84
+ console.error('Error: Please provide the package name as an argument if you want to setup dashboard.');
85
+ console.log('Usage: pnpm monodog-cli @monodog/dashboard --serve --root .');
86
+ }
87
+ const sourcePath = path.join(rootDir, 'node_modules', packageName);
88
+ // Convert package name to a valid folder name (e.g., @scope/name -> scope-name)
89
+ // This is optional but makes file paths cleaner.
90
+ const folderName = packageName.replace('@', '').replace('/', '-');
91
+ const destinationPath = path.join(rootDir, folderName);
92
+ console.log(`\n--- Monorepo Workspace Conversion ---`);
93
+ console.log(`Target Package: ${packageName}`);
94
+ console.log(`Target folder: ${folderName}`);
95
+ console.log(`-----------------------------------`);
96
+ // 2. Validate Source existence
97
+ if (!fs.existsSync(sourcePath)) {
98
+ console.error(`\n❌ Error: Source package not found at ${sourcePath}.`);
99
+ console.error("Please ensure the package is installed via 'pnpm install <package-name>' first.");
100
+ process.exit(1);
101
+ }
102
+ // Check if source path exists and is a directory before copying
103
+ if (!fs.existsSync(sourcePath) || !fs.statSync(sourcePath).isDirectory()) {
104
+ console.error(`\n❌ Fatal Error: Source package directory not found or is not a directory.`);
105
+ console.error(`Attempted source path: ${sourcePath}`);
106
+ console.error(`This likely means the package '${packageName}' was not fully installed or is improperly linked by the package manager.`);
107
+ process.exit(1);
108
+ }
109
+ // 3. Handle Destination existence: Skip if found to acontinue setup
110
+ if (fs.existsSync(destinationPath)) {
111
+ console.log(`\n⚠️ Warning: Destination directory already exists at ${destinationPath}.`);
112
+ console.log(`\nSkipping Setup.`);
113
+ process.exit(0);
114
+ }
115
+ // 4. Perform the copy operation
116
+ try {
117
+ console.log(`\nCopying files from ${sourcePath} to ${destinationPath}...`);
118
+ // fs.cpSync provides cross-platform recursive copying (Node 16.7+)
119
+ // Added filter to exclude node_modules, dist, and cache folders from the copy,
120
+ // which prevents recursive errors and corrupted copies.
121
+ // const INCLUDED_ROOT_ITEMS = ['package.json', 'README.md', 'dist', 'monodog-conf.json', 'monodog-dashboard'];
122
+ fs.cpSync(sourcePath, destinationPath, {
123
+ recursive: true,
124
+ dereference: true,
125
+ // filter: (src: string): boolean => {
126
+ // const relative = path.relative(sourcePath, src);
127
+ // // 1. Always include the source root itself to initiate the copy
128
+ // if (relative === '') {
129
+ // return true;
130
+ // }
131
+ // // 2. Get the top-level path segment (e.g., 'dist', 'prisma', 'package.json')
132
+ // // This is the file/directory name immediately under the source path.
133
+ // const topLevelItem = relative.split(path.sep)[0];
134
+ // // 3. Include if the top-level item is one of the desired items.
135
+ // if (INCLUDED_ROOT_ITEMS.includes(topLevelItem)) {
136
+ // return true;
137
+ // }
138
+ // // 4. Exclude everything else (like /src, /test, /node_modules, etc.)
139
+ // return false;
140
+ // }
141
+ // filter: (src: string): boolean => {
142
+ // const basename = path.basename(src);
143
+ // return !(['node_modules', '.turbo'].includes(basename));
144
+ // }
145
+ // Filter out node_modules inside the package itself to avoid deep recursion
146
+ // filter: (src: string): boolean => !src.includes('node_modules'),
147
+ });
148
+ console.log(`\n✅ Success! Contents of '${packageName}' copied to '${destinationPath}'`);
149
+ }
150
+ catch (err) {
151
+ const message = err instanceof Error ? err.message : String(err);
152
+ console.error(`\n❌ Failed to copy files: ${message}`);
153
+ process.exit(1);
154
+ }
155
+ }