mysqlsyncr 1.0.60 → 1.0.64

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.
@@ -1,4 +1,4 @@
1
- const mysqlSyncr = require('../dist/index.cjs.cjs');
1
+ const mysqlSyncr = require('../dist/index.cjs');
2
2
  const path = require('path');
3
3
 
4
4
  const dotenv = require('dotenv');
package/dist/index.cjs CHANGED
@@ -3456,36 +3456,39 @@ var findDifferences = function findDifferences(expected, current) {
3456
3456
  }
3457
3457
 
3458
3458
  // Compare stored procedures
3459
- if (!expected.procedures) throw new Error('No procedures found in expected');
3460
- var _loop6 = function _loop6() {
3461
- var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i3], 2);
3462
- _Object$entries2$_i[0];
3463
- var contents = _Object$entries2$_i[1];
3464
- var procName = contents.Name;
3465
- var currentProc = current.procedures.find(function (p) {
3466
- return p.Name === procName;
3467
- });
3468
- if (!currentProc) {
3469
- console.log('missing_procedure', contents);
3470
- differences.push(_objectSpread2({
3471
- type: 'missing_procedure'
3472
- }, contents));
3473
- return 1; // continue
3474
- }
3475
-
3476
- // Check if the procedure definition matches
3477
- if (currentProc.Definition !== contents.Definition) {
3478
- var normalizedCurrentDef = normalizeSQLDefinition(currentProc.Definition);
3479
- var normalizedNewDef = normalizeSQLDefinition(contents.Definition);
3480
- if (normalizedCurrentDef !== normalizedNewDef) {
3459
+ if (!expected.procedures) {
3460
+ console.log('No procedures found in expected for database', current.database);
3461
+ } else {
3462
+ var _loop6 = function _loop6() {
3463
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i3], 2);
3464
+ _Object$entries2$_i[0];
3465
+ var contents = _Object$entries2$_i[1];
3466
+ var procName = contents.Name;
3467
+ var currentProc = current.procedures.find(function (p) {
3468
+ return p.Name === procName;
3469
+ });
3470
+ if (!currentProc) {
3471
+ console.log('missing_procedure', contents);
3481
3472
  differences.push(_objectSpread2({
3482
- type: 'mismatched_procedure'
3473
+ type: 'missing_procedure'
3483
3474
  }, contents));
3475
+ return 1; // continue
3484
3476
  }
3477
+
3478
+ // Check if the procedure definition matches
3479
+ if (currentProc.Definition !== contents.Definition) {
3480
+ var normalizedCurrentDef = normalizeSQLDefinition(currentProc.Definition);
3481
+ var normalizedNewDef = normalizeSQLDefinition(contents.Definition);
3482
+ if (normalizedCurrentDef !== normalizedNewDef) {
3483
+ differences.push(_objectSpread2({
3484
+ type: 'mismatched_procedure'
3485
+ }, contents));
3486
+ }
3487
+ }
3488
+ };
3489
+ for (var _i3 = 0, _Object$entries2 = Object.entries(expected.procedures); _i3 < _Object$entries2.length; _i3++) {
3490
+ if (_loop6()) continue;
3485
3491
  }
3486
- };
3487
- for (var _i3 = 0, _Object$entries2 = Object.entries(expected.procedures); _i3 < _Object$entries2.length; _i3++) {
3488
- if (_loop6()) continue;
3489
3492
  }
3490
3493
 
3491
3494
  // Compare views
@@ -4261,7 +4264,7 @@ var startApiServer = function startApiServer(port, argv) {
4261
4264
  extended: true
4262
4265
  }));
4263
4266
  var __dirname = process.platform === "win32" ? process.cwd().replace(/\\/g, '/') : process.cwd();
4264
- app.use(express["static"](path.join(__dirname, '../ui/dist/spa')));
4267
+ app.use(express["static"](path.join(__dirname, './ui/dist/spa')));
4265
4268
  app.post('/api/getDatabasesFromExistingDumps', /*#__PURE__*/function () {
4266
4269
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(req, res) {
4267
4270
  var config, databases;
@@ -5217,6 +5220,9 @@ var compare = /*#__PURE__*/function () {
5217
5220
  // Only run this if this is the main module
5218
5221
  var isMain = function () {
5219
5222
  try {
5223
+ console.log('Checking if this is the main module');
5224
+ console.log(require.main === module);
5225
+ console.log(require.main);
5220
5226
  return require.main === module;
5221
5227
  } catch (e) {
5222
5228
  return false;
package/dist/index.js CHANGED
@@ -3453,36 +3453,39 @@ var findDifferences = function findDifferences(expected, current) {
3453
3453
  }
3454
3454
 
3455
3455
  // Compare stored procedures
3456
- if (!expected.procedures) throw new Error('No procedures found in expected');
3457
- var _loop6 = function _loop6() {
3458
- var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i3], 2);
3459
- _Object$entries2$_i[0];
3460
- var contents = _Object$entries2$_i[1];
3461
- var procName = contents.Name;
3462
- var currentProc = current.procedures.find(function (p) {
3463
- return p.Name === procName;
3464
- });
3465
- if (!currentProc) {
3466
- console.log('missing_procedure', contents);
3467
- differences.push(_objectSpread2({
3468
- type: 'missing_procedure'
3469
- }, contents));
3470
- return 1; // continue
3471
- }
3472
-
3473
- // Check if the procedure definition matches
3474
- if (currentProc.Definition !== contents.Definition) {
3475
- var normalizedCurrentDef = normalizeSQLDefinition(currentProc.Definition);
3476
- var normalizedNewDef = normalizeSQLDefinition(contents.Definition);
3477
- if (normalizedCurrentDef !== normalizedNewDef) {
3456
+ if (!expected.procedures) {
3457
+ console.log('No procedures found in expected for database', current.database);
3458
+ } else {
3459
+ var _loop6 = function _loop6() {
3460
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i3], 2);
3461
+ _Object$entries2$_i[0];
3462
+ var contents = _Object$entries2$_i[1];
3463
+ var procName = contents.Name;
3464
+ var currentProc = current.procedures.find(function (p) {
3465
+ return p.Name === procName;
3466
+ });
3467
+ if (!currentProc) {
3468
+ console.log('missing_procedure', contents);
3478
3469
  differences.push(_objectSpread2({
3479
- type: 'mismatched_procedure'
3470
+ type: 'missing_procedure'
3480
3471
  }, contents));
3472
+ return 1; // continue
3481
3473
  }
3474
+
3475
+ // Check if the procedure definition matches
3476
+ if (currentProc.Definition !== contents.Definition) {
3477
+ var normalizedCurrentDef = normalizeSQLDefinition(currentProc.Definition);
3478
+ var normalizedNewDef = normalizeSQLDefinition(contents.Definition);
3479
+ if (normalizedCurrentDef !== normalizedNewDef) {
3480
+ differences.push(_objectSpread2({
3481
+ type: 'mismatched_procedure'
3482
+ }, contents));
3483
+ }
3484
+ }
3485
+ };
3486
+ for (var _i3 = 0, _Object$entries2 = Object.entries(expected.procedures); _i3 < _Object$entries2.length; _i3++) {
3487
+ if (_loop6()) continue;
3482
3488
  }
3483
- };
3484
- for (var _i3 = 0, _Object$entries2 = Object.entries(expected.procedures); _i3 < _Object$entries2.length; _i3++) {
3485
- if (_loop6()) continue;
3486
3489
  }
3487
3490
 
3488
3491
  // Compare views
@@ -4258,7 +4261,7 @@ var startApiServer = function startApiServer(port, argv) {
4258
4261
  extended: true
4259
4262
  }));
4260
4263
  var __dirname = process.platform === "win32" ? process.cwd().replace(/\\/g, '/') : process.cwd();
4261
- app.use(express["static"](join(__dirname, '../ui/dist/spa')));
4264
+ app.use(express["static"](join(__dirname, './ui/dist/spa')));
4262
4265
  app.post('/api/getDatabasesFromExistingDumps', /*#__PURE__*/function () {
4263
4266
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(req, res) {
4264
4267
  var config, databases;
@@ -5214,6 +5217,9 @@ var compare = /*#__PURE__*/function () {
5214
5217
  // Only run this if this is the main module
5215
5218
  var isMain = function () {
5216
5219
  try {
5220
+ console.log('Checking if this is the main module');
5221
+ console.log(require.main === module);
5222
+ console.log(require.main);
5217
5223
  return require.main === module;
5218
5224
  } catch (e) {
5219
5225
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mysqlsyncr",
3
- "version": "1.0.60",
3
+ "version": "1.0.64",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -18,7 +18,7 @@
18
18
  "build": "rollup -c"
19
19
  },
20
20
  "bin": {
21
- "mysqlsyncr": "src/index.js"
21
+ "mysqlsyncr": "dist/index.cjs"
22
22
  },
23
23
  "author": "",
24
24
  "license": "ISC",
@@ -15,7 +15,7 @@ export const findDifferences = (expected, current) => {
15
15
  if (!expected.tables) throw new Error('No tables found in expected');
16
16
  for (const [tableName, contents] of Object.entries(expected.tables)) {
17
17
  //check if craete table matches from json, if so, we dont need to compare indexes, triggers, or fields
18
-
18
+
19
19
  if (!current.tables[tableName]) {
20
20
  console.log('missing_table', contents);
21
21
  differences.push({ type: 'missing_table', tableName, createSQL: contents.createSQL });
@@ -134,28 +134,29 @@ export const findDifferences = (expected, current) => {
134
134
 
135
135
 
136
136
  // Compare stored procedures
137
- if (!expected.procedures) throw new Error('No procedures found in expected');
138
- for (const [position, contents] of Object.entries(expected.procedures)) {
139
- let procName = contents.Name;
140
- let currentProc = current.procedures.find(p => p.Name === procName);
141
- if (!currentProc) {
142
- console.log('missing_procedure', contents);
143
- differences.push({ type: 'missing_procedure', ...contents });
144
- continue;
145
- }
137
+ if (!expected.procedures) {
138
+ console.log('No procedures found in expected for database', current.database);
139
+ } else {
140
+ for (const [position, contents] of Object.entries(expected.procedures)) {
141
+ let procName = contents.Name;
142
+ let currentProc = current.procedures.find(p => p.Name === procName);
143
+ if (!currentProc) {
144
+ console.log('missing_procedure', contents);
145
+ differences.push({ type: 'missing_procedure', ...contents });
146
+ continue;
147
+ }
146
148
 
147
149
 
148
- // Check if the procedure definition matches
149
- if (currentProc.Definition !== contents.Definition) {
150
- const normalizedCurrentDef = normalizeSQLDefinition(currentProc.Definition);
151
- const normalizedNewDef = normalizeSQLDefinition(contents.Definition);
150
+ // Check if the procedure definition matches
151
+ if (currentProc.Definition !== contents.Definition) {
152
+ const normalizedCurrentDef = normalizeSQLDefinition(currentProc.Definition);
153
+ const normalizedNewDef = normalizeSQLDefinition(contents.Definition);
152
154
 
153
- if (normalizedCurrentDef !== normalizedNewDef) {
154
- differences.push({ type: 'mismatched_procedure', ...contents });
155
+ if (normalizedCurrentDef !== normalizedNewDef) {
156
+ differences.push({ type: 'mismatched_procedure', ...contents });
157
+ }
155
158
  }
156
159
  }
157
-
158
-
159
160
  }
160
161
 
161
162
  // Compare views
@@ -179,15 +180,15 @@ export const findDifferences = (expected, current) => {
179
180
  if (!current.views[viewName]) {
180
181
  differences.push({ type: 'missing_view', viewName, definition: expectedDefinition });
181
182
  } else if (current.views[viewName] !== expectedDefinition) {
182
- differences.push({
183
- type: 'mismatched_view',
184
- viewName,
185
- definition: expectedDefinition,
186
- current: current.views[viewName]
183
+ differences.push({
184
+ type: 'mismatched_view',
185
+ viewName,
186
+ definition: expectedDefinition,
187
+ current: current.views[viewName]
187
188
  });
188
189
  }
189
190
  }
190
-
191
+
191
192
  // Check for extra views
192
193
  for (const viewName of Object.keys(current.views)) {
193
194
  if (!expected.views[viewName]) {
package/src/index.js CHANGED
@@ -64,6 +64,9 @@ export { DBStructureChecker, dumpAllDatabases, compare, startApiServer };
64
64
  // Only run this if this is the main module
65
65
  const isMain = (() => {
66
66
  try {
67
+ console.log('Checking if this is the main module');
68
+ console.log(require.main === module)
69
+ console.log(require.main);
67
70
  return require.main === module;
68
71
  } catch (e) {
69
72
  return false;
@@ -5,8 +5,7 @@ import { compareAllDatabases } from './compare.js';
5
5
  import { DBStructureChecker } from './index.js'; // Import your DBStructureChecker class
6
6
  import { applyDifferences } from './apply.js';
7
7
  import cors from 'cors';
8
- import { fileURLToPath } from 'url';
9
- import { dirname, join } from 'path';
8
+ import { join } from 'path';
10
9
  import { readdir, mkdir } from 'fs/promises';
11
10
  import { resolve } from 'path';
12
11
 
@@ -40,7 +39,7 @@ export const startApiServer = (port, argv) => {
40
39
  ? process.cwd().replace(/\\/g, '/')
41
40
  : process.cwd();
42
41
 
43
- app.use(express.static(join(__dirname, '../ui/dist/spa')));
42
+ app.use(express.static(join(__dirname, './ui/dist/spa')));
44
43
 
45
44
  app.post('/api/getDatabasesFromExistingDumps', async (req, res) => {
46
45
  let { config } = req.body;