mysqlsyncr 1.0.62 → 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
@@ -5218,6 +5221,7 @@ var compare = /*#__PURE__*/function () {
5218
5221
  var isMain = function () {
5219
5222
  try {
5220
5223
  console.log('Checking if this is the main module');
5224
+ console.log(require.main === module);
5221
5225
  console.log(require.main);
5222
5226
  return require.main === module;
5223
5227
  } catch (e) {
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
@@ -5215,6 +5218,7 @@ var compare = /*#__PURE__*/function () {
5215
5218
  var isMain = function () {
5216
5219
  try {
5217
5220
  console.log('Checking if this is the main module');
5221
+ console.log(require.main === module);
5218
5222
  console.log(require.main);
5219
5223
  return require.main === module;
5220
5224
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mysqlsyncr",
3
- "version": "1.0.62",
3
+ "version": "1.0.64",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -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
@@ -65,6 +65,7 @@ export { DBStructureChecker, dumpAllDatabases, compare, startApiServer };
65
65
  const isMain = (() => {
66
66
  try {
67
67
  console.log('Checking if this is the main module');
68
+ console.log(require.main === module)
68
69
  console.log(require.main);
69
70
  return require.main === module;
70
71
  } catch (e) {
@@ -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