mysqlsyncr 1.0.3 → 1.0.4

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.3",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/compare.js CHANGED
@@ -10,7 +10,9 @@ export const compareAllDatabases = async (connection, inputDir, update = false,
10
10
  await connection.reconnect(); // Ensure the connection is open
11
11
  }
12
12
  // Read the expected databases from the input directory
13
- const expectedDatabases = await fs.readdir(inputDir);
13
+ let expectedDatabases = await fs.readdir(inputDir);
14
+ //filter out diffs.json
15
+ expectedDatabases = expectedDatabases.filter(file => file !== 'diffs.json');
14
16
  // console.log('Expected databases from input directory:', expectedDatabases);
15
17
 
16
18
  // Check existing databases
@@ -57,7 +59,12 @@ export const compareAllDatabases = async (connection, inputDir, update = false,
57
59
  if(options.database && options.database !== database){
58
60
  continue;
59
61
  }
62
+ if(missingDatabases.includes(database)){
63
+ console.log('Skipping database', database, 'because it is missing');
64
+ continue;
65
+ }
60
66
  const filePath = path.join(inputDir, database, `${database}.json`);
67
+
61
68
  try {
62
69
  const fileContent = await fs.readFile(filePath, 'utf-8');
63
70
  const expectedStructure = JSON.parse(fileContent);
package/src/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  import mysql from 'mysql2';
4
4
  import util from 'util';
5
5
  import fs from 'fs';
6
-
6
+ import path from 'path';
7
7
  import { cli } from './cli.js';
8
8
  import { dumpAllDatabases } from './dump.js';
9
9
  import { compareAllDatabases } from './compare.js';
@@ -54,7 +54,7 @@ class DBStructureChecker {
54
54
  let diffs = await compareAllDatabases(checker.connection, argv.output, false, command, argv); // Dry run
55
55
  let totalDiffs = Object.values(diffs).reduce((acc, arr) => acc + arr.length, 0);
56
56
  console.log('Total differences count:', totalDiffs);
57
- fs.writeFileSync(argv.output + '/diffs.json', JSON.stringify(diffs, null, 4));
57
+ fs.writeFileSync(path.join(argv.output, 'diffs.json'), JSON.stringify(diffs, null, 4));
58
58
  } else if (command === 'update') {
59
59
  console.log('Updating the database structure based on JSON dumps');
60
60
  let totalDiffs = Infinity; // Initialize with a large number