mysqlsyncr 1.0.86 → 1.0.88

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/dist/index.cjs CHANGED
@@ -5214,19 +5214,19 @@ var compare = /*#__PURE__*/function () {
5214
5214
  case 0:
5215
5215
  return _context5.abrupt("return", new Promise(/*#__PURE__*/function () {
5216
5216
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(resolve, reject) {
5217
- var _checker;
5217
+ var checker;
5218
5218
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
5219
5219
  while (1) switch (_context4.prev = _context4.next) {
5220
5220
  case 0:
5221
5221
  _context4.prev = 0;
5222
- _checker = new DBStructureChecker(config);
5223
- _checker.connection.on('connect', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
5222
+ checker = new DBStructureChecker(config);
5223
+ checker.connection.on('connect', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
5224
5224
  var diffs;
5225
5225
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
5226
5226
  while (1) switch (_context3.prev = _context3.next) {
5227
5227
  case 0:
5228
5228
  _context3.next = 2;
5229
- return compareAllDatabases(_checker.connection, output, false, 'compare', {
5229
+ return compareAllDatabases(checker.connection, output, false, 'compare', {
5230
5230
  output: output
5231
5231
  });
5232
5232
  case 2:
@@ -5252,15 +5252,19 @@ var compare = /*#__PURE__*/function () {
5252
5252
  });
5253
5253
  case 8:
5254
5254
  _context4.prev = 8;
5255
- _context4.next = 11;
5255
+ if (!checker) {
5256
+ _context4.next = 12;
5257
+ break;
5258
+ }
5259
+ _context4.next = 12;
5256
5260
  return checker.closeConnection();
5257
- case 11:
5258
- return _context4.finish(8);
5259
5261
  case 12:
5262
+ return _context4.finish(8);
5263
+ case 13:
5260
5264
  case "end":
5261
5265
  return _context4.stop();
5262
5266
  }
5263
- }, _callee4, null, [[0, 5, 8, 12]]);
5267
+ }, _callee4, null, [[0, 5, 8, 13]]);
5264
5268
  }));
5265
5269
  return function (_x3, _x4) {
5266
5270
  return _ref2.apply(this, arguments);
@@ -5282,23 +5286,24 @@ var apply = /*#__PURE__*/function () {
5282
5286
  while (1) switch (_context7.prev = _context7.next) {
5283
5287
  case 0:
5284
5288
  return _context7.abrupt("return", new Promise(function (resolve, reject) {
5289
+ var checker;
5285
5290
  try {
5286
- var _checker2 = new DBStructureChecker(config, database);
5287
- _checker2.connection.on('error', function (err) {
5291
+ checker = new DBStructureChecker(config, database);
5292
+ checker.connection.on('error', function (err) {
5288
5293
  console.error('Database connection error in route apply:', err);
5289
5294
  reject({
5290
5295
  type: 'error',
5291
5296
  error: err.message
5292
5297
  });
5293
5298
  });
5294
- _checker2.connection.on('connect', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
5299
+ checker.connection.on('connect', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
5295
5300
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
5296
5301
  while (1) switch (_context6.prev = _context6.next) {
5297
5302
  case 0:
5298
5303
  console.log('Connected to the database');
5299
- _checker2.targetDatabase = database;
5300
- _checker2.command = 'apply';
5301
- _checker2.options = {
5304
+ checker.targetDatabase = database;
5305
+ checker.command = 'apply';
5306
+ checker.options = {
5302
5307
  config: config,
5303
5308
  database: database,
5304
5309
  diffs: diffs
@@ -5306,7 +5311,7 @@ var apply = /*#__PURE__*/function () {
5306
5311
  _context6.prev = 4;
5307
5312
  console.log('Applying the database structure based on JSON dumps');
5308
5313
  _context6.next = 8;
5309
- return applyDifferences(_checker2.connection, database, diffs);
5314
+ return applyDifferences(checker.connection, database, diffs);
5310
5315
  case 8:
5311
5316
  resolve({
5312
5317
  type: 'success',
@@ -5323,15 +5328,19 @@ var apply = /*#__PURE__*/function () {
5323
5328
  });
5324
5329
  case 14:
5325
5330
  _context6.prev = 14;
5326
- _context6.next = 17;
5327
- return _checker2.closeConnection();
5328
- case 17:
5329
- return _context6.finish(14);
5331
+ if (!checker) {
5332
+ _context6.next = 18;
5333
+ break;
5334
+ }
5335
+ _context6.next = 18;
5336
+ return checker.closeConnection();
5330
5337
  case 18:
5338
+ return _context6.finish(14);
5339
+ case 19:
5331
5340
  case "end":
5332
5341
  return _context6.stop();
5333
5342
  }
5334
- }, _callee6, null, [[4, 11, 14, 18]]);
5343
+ }, _callee6, null, [[4, 11, 14, 19]]);
5335
5344
  })));
5336
5345
  } catch (e) {
5337
5346
  reject({
@@ -5364,7 +5373,7 @@ var isMain = function () {
5364
5373
  }();
5365
5374
  if (isMain) {
5366
5375
  _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
5367
- var _cli, command, config, argv, PORT, _checker3;
5376
+ var _cli, command, config, argv, PORT, checker;
5368
5377
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
5369
5378
  while (1) switch (_context9.prev = _context9.next) {
5370
5379
  case 0:
@@ -5389,16 +5398,16 @@ if (isMain) {
5389
5398
  break;
5390
5399
  case 12:
5391
5400
  // Handle other commands (dump, compare, update) as before
5392
- _checker3 = new DBStructureChecker(config, argv.database);
5393
- _checker3.connection.on('connect', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
5401
+ checker = new DBStructureChecker(config, argv.database);
5402
+ checker.connection.on('connect', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
5394
5403
  var diffs, totalDiffs, _totalDiffs, previousDiffs, runCount, maxRuns, _diffs;
5395
5404
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
5396
5405
  while (1) switch (_context8.prev = _context8.next) {
5397
5406
  case 0:
5398
5407
  console.log('Connected to the database');
5399
- _checker3.targetDatabase = argv.database;
5400
- _checker3.command = command;
5401
- _checker3.options = argv;
5408
+ checker.targetDatabase = argv.database;
5409
+ checker.command = command;
5410
+ checker.options = argv;
5402
5411
  _context8.prev = 4;
5403
5412
  if (!(command === 'dump')) {
5404
5413
  _context8.next = 11;
@@ -5406,7 +5415,7 @@ if (isMain) {
5406
5415
  }
5407
5416
  console.log('Dumping the database structure to files');
5408
5417
  _context8.next = 9;
5409
- return dumpAllDatabases(_checker3.connection, command, argv);
5418
+ return dumpAllDatabases(checker.connection, command, argv);
5410
5419
  case 9:
5411
5420
  _context8.next = 42;
5412
5421
  break;
@@ -5417,7 +5426,7 @@ if (isMain) {
5417
5426
  }
5418
5427
  console.log('Comparing the database structure with JSON dumps (dry run)');
5419
5428
  _context8.next = 15;
5420
- return compareAllDatabases(_checker3.connection, argv.output, false, command, argv);
5429
+ return compareAllDatabases(checker.connection, argv.output, false, command, argv);
5421
5430
  case 15:
5422
5431
  diffs = _context8.sent;
5423
5432
  // Dry run
@@ -5445,7 +5454,7 @@ if (isMain) {
5445
5454
  }
5446
5455
  console.log('Running update command. Run count:', runCount);
5447
5456
  _context8.next = 31;
5448
- return compareAllDatabases(_checker3.connection, argv.output, true, command, argv);
5457
+ return compareAllDatabases(checker.connection, argv.output, true, command, argv);
5449
5458
  case 31:
5450
5459
  _diffs = _context8.sent;
5451
5460
  // Apply updates
@@ -5477,7 +5486,7 @@ if (isMain) {
5477
5486
  case 47:
5478
5487
  _context8.prev = 47;
5479
5488
  _context8.next = 50;
5480
- return _checker3.closeConnection();
5489
+ return checker.closeConnection();
5481
5490
  case 50:
5482
5491
  return _context8.finish(47);
5483
5492
  case 51:
package/dist/index.js CHANGED
@@ -5211,19 +5211,19 @@ var compare = /*#__PURE__*/function () {
5211
5211
  case 0:
5212
5212
  return _context5.abrupt("return", new Promise(/*#__PURE__*/function () {
5213
5213
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(resolve, reject) {
5214
- var _checker;
5214
+ var checker;
5215
5215
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
5216
5216
  while (1) switch (_context4.prev = _context4.next) {
5217
5217
  case 0:
5218
5218
  _context4.prev = 0;
5219
- _checker = new DBStructureChecker(config);
5220
- _checker.connection.on('connect', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
5219
+ checker = new DBStructureChecker(config);
5220
+ checker.connection.on('connect', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
5221
5221
  var diffs;
5222
5222
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
5223
5223
  while (1) switch (_context3.prev = _context3.next) {
5224
5224
  case 0:
5225
5225
  _context3.next = 2;
5226
- return compareAllDatabases(_checker.connection, output, false, 'compare', {
5226
+ return compareAllDatabases(checker.connection, output, false, 'compare', {
5227
5227
  output: output
5228
5228
  });
5229
5229
  case 2:
@@ -5249,15 +5249,19 @@ var compare = /*#__PURE__*/function () {
5249
5249
  });
5250
5250
  case 8:
5251
5251
  _context4.prev = 8;
5252
- _context4.next = 11;
5252
+ if (!checker) {
5253
+ _context4.next = 12;
5254
+ break;
5255
+ }
5256
+ _context4.next = 12;
5253
5257
  return checker.closeConnection();
5254
- case 11:
5255
- return _context4.finish(8);
5256
5258
  case 12:
5259
+ return _context4.finish(8);
5260
+ case 13:
5257
5261
  case "end":
5258
5262
  return _context4.stop();
5259
5263
  }
5260
- }, _callee4, null, [[0, 5, 8, 12]]);
5264
+ }, _callee4, null, [[0, 5, 8, 13]]);
5261
5265
  }));
5262
5266
  return function (_x3, _x4) {
5263
5267
  return _ref2.apply(this, arguments);
@@ -5279,23 +5283,24 @@ var apply = /*#__PURE__*/function () {
5279
5283
  while (1) switch (_context7.prev = _context7.next) {
5280
5284
  case 0:
5281
5285
  return _context7.abrupt("return", new Promise(function (resolve, reject) {
5286
+ var checker;
5282
5287
  try {
5283
- var _checker2 = new DBStructureChecker(config, database);
5284
- _checker2.connection.on('error', function (err) {
5288
+ checker = new DBStructureChecker(config, database);
5289
+ checker.connection.on('error', function (err) {
5285
5290
  console.error('Database connection error in route apply:', err);
5286
5291
  reject({
5287
5292
  type: 'error',
5288
5293
  error: err.message
5289
5294
  });
5290
5295
  });
5291
- _checker2.connection.on('connect', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
5296
+ checker.connection.on('connect', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
5292
5297
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
5293
5298
  while (1) switch (_context6.prev = _context6.next) {
5294
5299
  case 0:
5295
5300
  console.log('Connected to the database');
5296
- _checker2.targetDatabase = database;
5297
- _checker2.command = 'apply';
5298
- _checker2.options = {
5301
+ checker.targetDatabase = database;
5302
+ checker.command = 'apply';
5303
+ checker.options = {
5299
5304
  config: config,
5300
5305
  database: database,
5301
5306
  diffs: diffs
@@ -5303,7 +5308,7 @@ var apply = /*#__PURE__*/function () {
5303
5308
  _context6.prev = 4;
5304
5309
  console.log('Applying the database structure based on JSON dumps');
5305
5310
  _context6.next = 8;
5306
- return applyDifferences(_checker2.connection, database, diffs);
5311
+ return applyDifferences(checker.connection, database, diffs);
5307
5312
  case 8:
5308
5313
  resolve({
5309
5314
  type: 'success',
@@ -5320,15 +5325,19 @@ var apply = /*#__PURE__*/function () {
5320
5325
  });
5321
5326
  case 14:
5322
5327
  _context6.prev = 14;
5323
- _context6.next = 17;
5324
- return _checker2.closeConnection();
5325
- case 17:
5326
- return _context6.finish(14);
5328
+ if (!checker) {
5329
+ _context6.next = 18;
5330
+ break;
5331
+ }
5332
+ _context6.next = 18;
5333
+ return checker.closeConnection();
5327
5334
  case 18:
5335
+ return _context6.finish(14);
5336
+ case 19:
5328
5337
  case "end":
5329
5338
  return _context6.stop();
5330
5339
  }
5331
- }, _callee6, null, [[4, 11, 14, 18]]);
5340
+ }, _callee6, null, [[4, 11, 14, 19]]);
5332
5341
  })));
5333
5342
  } catch (e) {
5334
5343
  reject({
@@ -5361,7 +5370,7 @@ var isMain = function () {
5361
5370
  }();
5362
5371
  if (isMain) {
5363
5372
  _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
5364
- var _cli, command, config, argv, PORT, _checker3;
5373
+ var _cli, command, config, argv, PORT, checker;
5365
5374
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
5366
5375
  while (1) switch (_context9.prev = _context9.next) {
5367
5376
  case 0:
@@ -5386,16 +5395,16 @@ if (isMain) {
5386
5395
  break;
5387
5396
  case 12:
5388
5397
  // Handle other commands (dump, compare, update) as before
5389
- _checker3 = new DBStructureChecker(config, argv.database);
5390
- _checker3.connection.on('connect', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
5398
+ checker = new DBStructureChecker(config, argv.database);
5399
+ checker.connection.on('connect', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
5391
5400
  var diffs, totalDiffs, _totalDiffs, previousDiffs, runCount, maxRuns, _diffs;
5392
5401
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
5393
5402
  while (1) switch (_context8.prev = _context8.next) {
5394
5403
  case 0:
5395
5404
  console.log('Connected to the database');
5396
- _checker3.targetDatabase = argv.database;
5397
- _checker3.command = command;
5398
- _checker3.options = argv;
5405
+ checker.targetDatabase = argv.database;
5406
+ checker.command = command;
5407
+ checker.options = argv;
5399
5408
  _context8.prev = 4;
5400
5409
  if (!(command === 'dump')) {
5401
5410
  _context8.next = 11;
@@ -5403,7 +5412,7 @@ if (isMain) {
5403
5412
  }
5404
5413
  console.log('Dumping the database structure to files');
5405
5414
  _context8.next = 9;
5406
- return dumpAllDatabases(_checker3.connection, command, argv);
5415
+ return dumpAllDatabases(checker.connection, command, argv);
5407
5416
  case 9:
5408
5417
  _context8.next = 42;
5409
5418
  break;
@@ -5414,7 +5423,7 @@ if (isMain) {
5414
5423
  }
5415
5424
  console.log('Comparing the database structure with JSON dumps (dry run)');
5416
5425
  _context8.next = 15;
5417
- return compareAllDatabases(_checker3.connection, argv.output, false, command, argv);
5426
+ return compareAllDatabases(checker.connection, argv.output, false, command, argv);
5418
5427
  case 15:
5419
5428
  diffs = _context8.sent;
5420
5429
  // Dry run
@@ -5442,7 +5451,7 @@ if (isMain) {
5442
5451
  }
5443
5452
  console.log('Running update command. Run count:', runCount);
5444
5453
  _context8.next = 31;
5445
- return compareAllDatabases(_checker3.connection, argv.output, true, command, argv);
5454
+ return compareAllDatabases(checker.connection, argv.output, true, command, argv);
5446
5455
  case 31:
5447
5456
  _diffs = _context8.sent;
5448
5457
  // Apply updates
@@ -5474,7 +5483,7 @@ if (isMain) {
5474
5483
  case 47:
5475
5484
  _context8.prev = 47;
5476
5485
  _context8.next = 50;
5477
- return _checker3.closeConnection();
5486
+ return checker.closeConnection();
5478
5487
  case 50:
5479
5488
  return _context8.finish(47);
5480
5489
  case 51:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mysqlsyncr",
3
- "version": "1.0.86",
3
+ "version": "1.0.88",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
package/src/index.js CHANGED
@@ -47,8 +47,9 @@ class DBStructureChecker {
47
47
 
48
48
  const compare = async (config, output) => {
49
49
  return new Promise(async (resolve, reject) => {
50
+ let checker
50
51
  try {
51
- const checker = new DBStructureChecker(config);
52
+ checker = new DBStructureChecker(config);
52
53
  checker.connection.on('connect', async () => {
53
54
  const diffs = await compareAllDatabases(checker.connection, output, false, 'compare', { output: output });
54
55
  resolve({ type: 'success', diffs });
@@ -57,15 +58,18 @@ const compare = async (config, output) => {
57
58
  } catch (e) {
58
59
  reject({ type: 'error', error: e.message });
59
60
  } finally {
60
- await checker.closeConnection();
61
+ if (checker) {
62
+ await checker.closeConnection();
63
+ }
61
64
  }
62
65
  });
63
66
  }
64
67
 
65
68
  const apply = async (config, database, diffs) => {
66
69
  return new Promise((resolve, reject) => {
70
+ let checker;
67
71
  try {
68
- const checker = new DBStructureChecker(config, database);
72
+ checker = new DBStructureChecker(config, database);
69
73
 
70
74
  checker.connection.on('error', (err) => {
71
75
  console.error('Database connection error in route apply:', err);
@@ -84,7 +88,9 @@ const apply = async (config, database, diffs) => {
84
88
  } catch (err) {
85
89
  reject({ type: 'error', error: err.message });
86
90
  } finally {
87
- await checker.closeConnection();
91
+ if (checker) {
92
+ await checker.closeConnection();
93
+ }
88
94
  }
89
95
  });
90
96
  } catch (e) {