dbnexus 0.1.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/LICENSE +1 -0
- package/README.md +166 -0
- package/dist/api.js +86067 -0
- package/dist/cli.js +31634 -0
- package/dist/index.js +114 -0
- package/dist/web/assets/index-2M0S9O7L.js +379 -0
- package/dist/web/assets/index-irX5x4FY.css +1 -0
- package/dist/web/favicon.svg +18 -0
- package/dist/web/index.html +20 -0
- package/dist/web/logo-dark.svg +26 -0
- package/dist/web/logo-light.svg +26 -0
- package/dist/web/logo-option1.svg +24 -0
- package/dist/web/logo-option2.svg +32 -0
- package/dist/web/logo-option3.svg +29 -0
- package/dist/web/logo-option4.svg +26 -0
- package/dist/web/logo-option5.svg +30 -0
- package/dist/web/logo-option6.svg +30 -0
- package/package.json +43 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import * as fs from 'node:fs';
|
|
5
|
+
import { spawn } from 'node:child_process';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
|
|
11
|
+
// Parse arguments
|
|
12
|
+
const args = process.argv.slice(2);
|
|
13
|
+
let port = '3001';
|
|
14
|
+
let dataDir = null;
|
|
15
|
+
let noOpen = false;
|
|
16
|
+
let showHelp = false;
|
|
17
|
+
let showVersion = false;
|
|
18
|
+
|
|
19
|
+
for (let i = 0; i < args.length; i++) {
|
|
20
|
+
const arg = args[i];
|
|
21
|
+
if (arg === '--port' || arg === '-p') {
|
|
22
|
+
port = args[++i] || '3001';
|
|
23
|
+
} else if (arg === '--data-dir') {
|
|
24
|
+
dataDir = args[++i];
|
|
25
|
+
} else if (arg === '--no-open') {
|
|
26
|
+
noOpen = true;
|
|
27
|
+
} else if (arg === '--help' || arg === '-h') {
|
|
28
|
+
showHelp = true;
|
|
29
|
+
} else if (arg === '--version' || arg === '-v') {
|
|
30
|
+
showVersion = true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (showVersion) {
|
|
35
|
+
console.log('0.1.0');
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (showHelp) {
|
|
40
|
+
console.log(`
|
|
41
|
+
DB Nexus - Database Management Tool
|
|
42
|
+
|
|
43
|
+
Usage: dbnexus [options]
|
|
44
|
+
|
|
45
|
+
Options:
|
|
46
|
+
-p, --port <port> Port to run on (default: 3001)
|
|
47
|
+
--data-dir <path> Custom data directory
|
|
48
|
+
--no-open Don't open browser automatically
|
|
49
|
+
-v, --version Show version
|
|
50
|
+
-h, --help Show help
|
|
51
|
+
|
|
52
|
+
Examples:
|
|
53
|
+
dbnexus Start on default port
|
|
54
|
+
dbnexus --port 8080 Start on custom port
|
|
55
|
+
dbnexus --data-dir ~/data Use custom data directory
|
|
56
|
+
`);
|
|
57
|
+
process.exit(0);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
console.log('\n 🚀 DB Nexus\n');
|
|
61
|
+
|
|
62
|
+
// Set data directory
|
|
63
|
+
if (dataDir) {
|
|
64
|
+
process.env.DBNEXUS_DATA_DIR = path.resolve(dataDir);
|
|
65
|
+
console.log(' Data Directory: ' + process.env.DBNEXUS_DATA_DIR);
|
|
66
|
+
} else {
|
|
67
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || process.cwd();
|
|
68
|
+
const defaultDataDir = path.join(homeDir, '.dbnexus');
|
|
69
|
+
console.log(' Data Directory: ' + defaultDataDir);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
console.log(' Port: ' + port);
|
|
73
|
+
console.log('');
|
|
74
|
+
|
|
75
|
+
// Set environment
|
|
76
|
+
process.env.PORT = port;
|
|
77
|
+
process.env.NODE_ENV = 'production';
|
|
78
|
+
|
|
79
|
+
// Find and run the API
|
|
80
|
+
const apiPath = path.join(__dirname, 'api.js');
|
|
81
|
+
|
|
82
|
+
if (!fs.existsSync(apiPath)) {
|
|
83
|
+
console.error('Error: API bundle not found at ' + apiPath);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
console.log(' Starting server...');
|
|
88
|
+
|
|
89
|
+
// Import and run the API directly
|
|
90
|
+
import(apiPath).then(async () => {
|
|
91
|
+
console.log(' ✓ Server running at http://localhost:' + port);
|
|
92
|
+
console.log('');
|
|
93
|
+
|
|
94
|
+
if (!noOpen) {
|
|
95
|
+
// Open browser
|
|
96
|
+
const open = await import('open');
|
|
97
|
+
await open.default('http://localhost:' + port);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
console.log(' Press Ctrl+C to stop\n');
|
|
101
|
+
}).catch(err => {
|
|
102
|
+
console.error('Failed to start server:', err);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Handle shutdown
|
|
107
|
+
process.on('SIGINT', () => {
|
|
108
|
+
console.log('\n Shutting down...');
|
|
109
|
+
process.exit(0);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
process.on('SIGTERM', () => {
|
|
113
|
+
process.exit(0);
|
|
114
|
+
});
|