mysqlsyncr 1.0.38 → 1.0.40

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mysqlsyncr",
3
- "version": "1.0.38",
3
+ "version": "1.0.40",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -45,18 +45,18 @@ class DBStructureChecker {
45
45
  }
46
46
 
47
47
  // Export the DBStructureChecker class
48
- export { DBStructureChecker };
48
+ export { DBStructureChecker, dumpAllDatabases, compareAllDatabases, startApiServer };
49
49
 
50
50
  // Start the server only if the 'ui' command is used
51
51
  (async () => {
52
52
  const { command, config, argv } = cli();
53
-
53
+ console.log("MySQLsyncr started via command line")
54
54
  if (command === 'ui') {
55
55
  const PORT = argv.uiPort
56
- startApiServer(PORT); // Start the Socket.IO server
56
+ startApiServer(PORT, argv); // Start the Socket.IO server
57
57
  console.log('Server started on port', PORT);
58
58
  console.log('Open http://localhost:' + PORT + ' in your browser to use the UI');
59
- if(argv.openUI){
59
+ if(argv.openUI && argv.openUI === true || argv.openUI === 'true'){
60
60
  await open(`http://localhost:${PORT}`);
61
61
  }
62
62
  } else {
@@ -10,26 +10,47 @@ import { dirname, join } from 'path';
10
10
  import { readdir, mkdir } from 'fs/promises';
11
11
  import { resolve } from 'path';
12
12
 
13
- export const startApiServer = (port) => {
13
+ const setConfig = (config, argv) => {
14
+ if(!config.host && argv.host){
15
+ config.host = argv.host;
16
+ }
17
+ if(!config.port && argv.port){
18
+ config.port = argv.port;
19
+ }
20
+ if(!config.user && argv.user){
21
+ config.user = argv.user;
22
+ }
23
+ if(!config.password && argv.password){
24
+ config.password = argv.password;
25
+ }
26
+ if(!config.output && argv.output !=='../db-dump'){
27
+ config.output = argv.output;
28
+ }
29
+ return config;
30
+ }
31
+
32
+ export const startApiServer = (port, argv) => {
14
33
  const app = express();
15
34
  app.use(cors({ origin: '*' }));
16
35
  const server = http.createServer(app);
17
- app.use(express.json({ limit: '50mb' })); // Increased payload limit
18
- app.use(express.urlencoded({ limit: '50mb', extended: true })); // Also handle URL-encoded data
36
+ app.use(express.json({ limit: '50mb' }));
37
+ app.use(express.urlencoded({ limit: '50mb', extended: true }));
19
38
 
20
39
  const __filename = fileURLToPath(import.meta.url);
21
40
  const __dirname = dirname(__filename);
22
41
  app.use(express.static(join(__dirname, '../ui/dist/spa')));
23
42
 
24
43
  app.post('/api/getDatabasesFromExistingDumps', async (req, res) => {
25
- const { config } = req.body;
44
+ let { config } = req.body;
45
+ config = setConfig(config, argv);
26
46
  const databases = await getDatabasesFromExistingDumps(config);
27
47
  res.json(databases);
28
48
  });
29
49
 
30
50
  // API endpoint to dump the database
31
51
  app.post('/api/dump', async (req, res) => {
32
- const { config, database } = req.body;
52
+ let { config, database } = req.body;
53
+ config = setConfig(config, argv);
33
54
  const checker = new DBStructureChecker(config, database);
34
55
 
35
56
  checker.connection.on('error', (err) => {
@@ -56,8 +77,9 @@ export const startApiServer = (port) => {
56
77
 
57
78
  // API endpoint to compare the database
58
79
  app.post('/api/compare', async (req, res) => {
59
- const { config } = req.body;
60
- const checker = new DBStructureChecker(config, config.database);
80
+ let { config, database } = req.body;
81
+ config = setConfig(config, argv);
82
+ const checker = new DBStructureChecker(config, database);
61
83
 
62
84
  checker.connection.on('error', (err) => {
63
85
  console.error('Database connection error in route compare:', err);
@@ -87,7 +109,8 @@ export const startApiServer = (port) => {
87
109
 
88
110
  // API endpoint to apply differences
89
111
  app.post('/api/apply', async (req, res) => {
90
- const { config, database, diffs } = req.body;
112
+ let { config, database, diffs } = req.body;
113
+ config = setConfig(config, argv);
91
114
  console.log('Applying differences:', diffs);
92
115
  const checker = new DBStructureChecker(config, database);
93
116
 
package/view.png CHANGED
Binary file