mysqlsyncr 1.0.70 → 1.0.74

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
@@ -3259,49 +3259,53 @@ var findDifferences = function findDifferences(expected, current) {
3259
3259
  _step2;
3260
3260
  try {
3261
3261
  var _loop = function _loop() {
3262
- var field = _step2.value;
3263
- var currentField = current.tables[_tableName].columns.find(function (f) {
3264
- return f.Field === field.Field;
3265
- });
3266
- if (!currentField) {
3267
- console.error('Current field not found for', field.Field, 'in table', _tableName);
3268
- differences.push({
3269
- type: 'missing_field',
3270
- tableName: _tableName,
3271
- field: field
3272
- });
3273
- return 1; // continue
3274
- }
3275
- if (field.Type !== currentField.Type) {
3276
- differences.push({
3277
- type: 'mismatched_field',
3278
- info: "Type",
3279
- tableName: _tableName,
3280
- field: field,
3281
- currentField: currentField
3282
- });
3283
- }
3284
- if (field.Null !== currentField.Null) {
3285
- differences.push({
3286
- type: 'mismatched_field',
3287
- info: "Null",
3288
- tableName: _tableName,
3289
- field: field,
3290
- currentField: currentField
3291
- });
3292
- }
3293
- if (field.Default !== currentField.Default) {
3294
- differences.push({
3295
- type: 'mismatched_field',
3296
- info: "Default",
3297
- tableName: _tableName,
3298
- field: field,
3299
- currentField: currentField
3262
+ var field = _step2.value;
3263
+ var currentField = current.tables[_tableName].columns.find(function (f) {
3264
+ return f.Field === field.Field;
3300
3265
  });
3301
- }
3302
- };
3266
+ if (!currentField) {
3267
+ console.error('Current field not found for', field.Field, 'in table', _tableName);
3268
+ differences.push({
3269
+ type: 'missing_field',
3270
+ tableName: _tableName,
3271
+ field: field
3272
+ });
3273
+ return 0; // continue
3274
+ }
3275
+ if (field.Null !== currentField.Null) {
3276
+ differences.push({
3277
+ type: 'mismatched_field',
3278
+ info: "Null",
3279
+ tableName: _tableName,
3280
+ field: field,
3281
+ currentField: currentField
3282
+ });
3283
+ }
3284
+ if (field.Default !== currentField.Default) {
3285
+ differences.push({
3286
+ type: 'mismatched_field',
3287
+ info: "Default",
3288
+ tableName: _tableName,
3289
+ field: field,
3290
+ currentField: currentField
3291
+ });
3292
+ }
3293
+ if (field.Type !== currentField.Type) {
3294
+ if (field.Type == 'int' && currentField.Type == 'int(11)') return 0; // continue
3295
+ // int(11) is the default for int and used on older versions of mysql
3296
+ differences.push({
3297
+ type: 'mismatched_field',
3298
+ info: "Type",
3299
+ tableName: _tableName,
3300
+ field: field,
3301
+ currentField: currentField
3302
+ });
3303
+ }
3304
+ },
3305
+ _ret;
3303
3306
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
3304
- if (_loop()) continue;
3307
+ _ret = _loop();
3308
+ if (_ret === 0) continue;
3305
3309
  }
3306
3310
 
3307
3311
  // verify indexes
@@ -3457,7 +3461,7 @@ var findDifferences = function findDifferences(expected, current) {
3457
3461
 
3458
3462
  // Compare stored procedures
3459
3463
  if (!expected.procedures) {
3460
- console.log('No procedures found in expected for database', current.database);
3464
+ console.log('No procedures found in expected');
3461
3465
  } else {
3462
3466
  var _loop6 = function _loop6() {
3463
3467
  var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i3], 2);
@@ -4252,6 +4256,22 @@ var setConfig = function setConfig(config, argv) {
4252
4256
  }
4253
4257
  return config;
4254
4258
  };
4259
+
4260
+ // Create a function to get the package root directory that works in both ESM and CJS
4261
+ var getPackageRoot = function getPackageRoot() {
4262
+ if (typeof __dirname$2 !== 'undefined') {
4263
+ // CommonJS
4264
+ return path.join(__dirname$2, '..');
4265
+ } else {
4266
+ // ESM
4267
+ var _filename = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4268
+ var _dirname = path.dirname(_filename);
4269
+ return path.join(_dirname, '..');
4270
+ }
4271
+ };
4272
+
4273
+ // Use the function to get the root path
4274
+ var packageRoot = getPackageRoot();
4255
4275
  var startApiServer = function startApiServer(port, argv) {
4256
4276
  var app = express();
4257
4277
  app.use(cors({
@@ -4265,8 +4285,8 @@ var startApiServer = function startApiServer(port, argv) {
4265
4285
  limit: '50mb',
4266
4286
  extended: true
4267
4287
  }));
4268
- console.log("Serving UI from ".concat(path.join(__dirname$2, '../ui/dist/spa')));
4269
- app.use(express["static"](path.join(__dirname$2, '../ui/dist/spa')));
4288
+ console.log("Serving UI from ".concat(path.join(packageRoot, 'ui/dist/spa')));
4289
+ app.use(express["static"](path.join(packageRoot, 'ui/dist/spa')));
4270
4290
  app.post('/api/getDatabasesFromExistingDumps', /*#__PURE__*/function () {
4271
4291
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(req, res) {
4272
4292
  var config, databases;
@@ -4493,7 +4513,7 @@ var startApiServer = function startApiServer(port, argv) {
4493
4513
  while (1) switch (_context8.prev = _context8.next) {
4494
4514
  case 0:
4495
4515
  _context8.prev = 0;
4496
- _req$body$currentPath = req.body.currentPath, currentPath = _req$body$currentPath === undefined ? __dirname$2 : _req$body$currentPath;
4516
+ _req$body$currentPath = req.body.currentPath, currentPath = _req$body$currentPath === undefined ? packageRoot : _req$body$currentPath;
4497
4517
  console.log('Browsing folder:', currentPath);
4498
4518
  resolvedPath = currentPath.startsWith('/') || currentPath.match(/^[A-Z]:\\/) ? path.resolve(currentPath) : path.resolve(currentPath);
4499
4519
  console.log('Resolved path:', resolvedPath);
@@ -4557,7 +4577,7 @@ var startApiServer = function startApiServer(port, argv) {
4557
4577
  _context9.prev = 0;
4558
4578
  folderPath = req.body.folderPath;
4559
4579
  console.log('Creating folder:', folderPath);
4560
- resolvedPath = folderPath.startsWith('/') || folderPath.match(/^[A-Z]:\\/) ? path.resolve(folderPath) : path.resolve(__dirname$2, folderPath);
4580
+ resolvedPath = folderPath.startsWith('/') || folderPath.match(/^[A-Z]:\\/) ? path.resolve(folderPath) : path.resolve(packageRoot, folderPath);
4561
4581
  _context9.next = 6;
4562
4582
  return fs$1.mkdir(resolvedPath, {
4563
4583
  recursive: true
package/dist/index.js CHANGED
@@ -3256,49 +3256,53 @@ var findDifferences = function findDifferences(expected, current) {
3256
3256
  _step2;
3257
3257
  try {
3258
3258
  var _loop = function _loop() {
3259
- var field = _step2.value;
3260
- var currentField = current.tables[_tableName].columns.find(function (f) {
3261
- return f.Field === field.Field;
3262
- });
3263
- if (!currentField) {
3264
- console.error('Current field not found for', field.Field, 'in table', _tableName);
3265
- differences.push({
3266
- type: 'missing_field',
3267
- tableName: _tableName,
3268
- field: field
3269
- });
3270
- return 1; // continue
3271
- }
3272
- if (field.Type !== currentField.Type) {
3273
- differences.push({
3274
- type: 'mismatched_field',
3275
- info: "Type",
3276
- tableName: _tableName,
3277
- field: field,
3278
- currentField: currentField
3279
- });
3280
- }
3281
- if (field.Null !== currentField.Null) {
3282
- differences.push({
3283
- type: 'mismatched_field',
3284
- info: "Null",
3285
- tableName: _tableName,
3286
- field: field,
3287
- currentField: currentField
3288
- });
3289
- }
3290
- if (field.Default !== currentField.Default) {
3291
- differences.push({
3292
- type: 'mismatched_field',
3293
- info: "Default",
3294
- tableName: _tableName,
3295
- field: field,
3296
- currentField: currentField
3259
+ var field = _step2.value;
3260
+ var currentField = current.tables[_tableName].columns.find(function (f) {
3261
+ return f.Field === field.Field;
3297
3262
  });
3298
- }
3299
- };
3263
+ if (!currentField) {
3264
+ console.error('Current field not found for', field.Field, 'in table', _tableName);
3265
+ differences.push({
3266
+ type: 'missing_field',
3267
+ tableName: _tableName,
3268
+ field: field
3269
+ });
3270
+ return 0; // continue
3271
+ }
3272
+ if (field.Null !== currentField.Null) {
3273
+ differences.push({
3274
+ type: 'mismatched_field',
3275
+ info: "Null",
3276
+ tableName: _tableName,
3277
+ field: field,
3278
+ currentField: currentField
3279
+ });
3280
+ }
3281
+ if (field.Default !== currentField.Default) {
3282
+ differences.push({
3283
+ type: 'mismatched_field',
3284
+ info: "Default",
3285
+ tableName: _tableName,
3286
+ field: field,
3287
+ currentField: currentField
3288
+ });
3289
+ }
3290
+ if (field.Type !== currentField.Type) {
3291
+ if (field.Type == 'int' && currentField.Type == 'int(11)') return 0; // continue
3292
+ // int(11) is the default for int and used on older versions of mysql
3293
+ differences.push({
3294
+ type: 'mismatched_field',
3295
+ info: "Type",
3296
+ tableName: _tableName,
3297
+ field: field,
3298
+ currentField: currentField
3299
+ });
3300
+ }
3301
+ },
3302
+ _ret;
3300
3303
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
3301
- if (_loop()) continue;
3304
+ _ret = _loop();
3305
+ if (_ret === 0) continue;
3302
3306
  }
3303
3307
 
3304
3308
  // verify indexes
@@ -3454,7 +3458,7 @@ var findDifferences = function findDifferences(expected, current) {
3454
3458
 
3455
3459
  // Compare stored procedures
3456
3460
  if (!expected.procedures) {
3457
- console.log('No procedures found in expected for database', current.database);
3461
+ console.log('No procedures found in expected');
3458
3462
  } else {
3459
3463
  var _loop6 = function _loop6() {
3460
3464
  var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i3], 2);
@@ -4249,6 +4253,22 @@ var setConfig = function setConfig(config, argv) {
4249
4253
  }
4250
4254
  return config;
4251
4255
  };
4256
+
4257
+ // Create a function to get the package root directory that works in both ESM and CJS
4258
+ var getPackageRoot = function getPackageRoot() {
4259
+ if (typeof __dirname$2 !== 'undefined') {
4260
+ // CommonJS
4261
+ return join(__dirname$2, '..');
4262
+ } else {
4263
+ // ESM
4264
+ var _filename = fileURLToPath(import.meta.url);
4265
+ var _dirname = dirname(_filename);
4266
+ return join(_dirname, '..');
4267
+ }
4268
+ };
4269
+
4270
+ // Use the function to get the root path
4271
+ var packageRoot = getPackageRoot();
4252
4272
  var startApiServer = function startApiServer(port, argv) {
4253
4273
  var app = express();
4254
4274
  app.use(cors({
@@ -4262,8 +4282,8 @@ var startApiServer = function startApiServer(port, argv) {
4262
4282
  limit: '50mb',
4263
4283
  extended: true
4264
4284
  }));
4265
- console.log("Serving UI from ".concat(join(__dirname$2, '../ui/dist/spa')));
4266
- app.use(express["static"](join(__dirname$2, '../ui/dist/spa')));
4285
+ console.log("Serving UI from ".concat(join(packageRoot, 'ui/dist/spa')));
4286
+ app.use(express["static"](join(packageRoot, 'ui/dist/spa')));
4267
4287
  app.post('/api/getDatabasesFromExistingDumps', /*#__PURE__*/function () {
4268
4288
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(req, res) {
4269
4289
  var config, databases;
@@ -4490,7 +4510,7 @@ var startApiServer = function startApiServer(port, argv) {
4490
4510
  while (1) switch (_context8.prev = _context8.next) {
4491
4511
  case 0:
4492
4512
  _context8.prev = 0;
4493
- _req$body$currentPath = req.body.currentPath, currentPath = _req$body$currentPath === undefined ? __dirname$2 : _req$body$currentPath;
4513
+ _req$body$currentPath = req.body.currentPath, currentPath = _req$body$currentPath === undefined ? packageRoot : _req$body$currentPath;
4494
4514
  console.log('Browsing folder:', currentPath);
4495
4515
  resolvedPath = currentPath.startsWith('/') || currentPath.match(/^[A-Z]:\\/) ? resolve(currentPath) : resolve(currentPath);
4496
4516
  console.log('Resolved path:', resolvedPath);
@@ -4554,7 +4574,7 @@ var startApiServer = function startApiServer(port, argv) {
4554
4574
  _context9.prev = 0;
4555
4575
  folderPath = req.body.folderPath;
4556
4576
  console.log('Creating folder:', folderPath);
4557
- resolvedPath = folderPath.startsWith('/') || folderPath.match(/^[A-Z]:\\/) ? resolve(folderPath) : resolve(__dirname$2, folderPath);
4577
+ resolvedPath = folderPath.startsWith('/') || folderPath.match(/^[A-Z]:\\/) ? resolve(folderPath) : resolve(packageRoot, folderPath);
4558
4578
  _context9.next = 6;
4559
4579
  return mkdir(resolvedPath, {
4560
4580
  recursive: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mysqlsyncr",
3
- "version": "1.0.70",
3
+ "version": "1.0.74",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -63,15 +63,16 @@ export const findDifferences = (expected, current) => {
63
63
  differences.push({ type: 'missing_field', tableName, field });
64
64
  continue;
65
65
  }
66
- if (field.Type !== currentField.Type) {
67
- differences.push({ type: 'mismatched_field', info: "Type", tableName, field, currentField });
68
- }
69
66
  if (field.Null !== currentField.Null) {
70
67
  differences.push({ type: 'mismatched_field', info: "Null", tableName, field, currentField });
71
68
  }
72
69
  if (field.Default !== currentField.Default) {
73
70
  differences.push({ type: 'mismatched_field', info: "Default", tableName, field, currentField });
74
71
  }
72
+ if (field.Type !== currentField.Type) {
73
+ if(field.Type == 'int' && currentField.Type == 'int(11)') continue; // int(11) is the default for int and used on older versions of mysql
74
+ differences.push({ type: 'mismatched_field', info: "Type", tableName, field, currentField });
75
+ }
75
76
  }
76
77
 
77
78
  // verify indexes
@@ -135,7 +136,7 @@ export const findDifferences = (expected, current) => {
135
136
 
136
137
  // Compare stored procedures
137
138
  if (!expected.procedures) {
138
- console.log('No procedures found in expected for database', current.database);
139
+ console.log('No procedures found in expected');
139
140
  } else {
140
141
  for (const [position, contents] of Object.entries(expected.procedures)) {
141
142
  let procName = contents.Name;
@@ -33,6 +33,22 @@ const setConfig = (config, argv) => {
33
33
  return config;
34
34
  }
35
35
 
36
+ // Create a function to get the package root directory that works in both ESM and CJS
37
+ const getPackageRoot = () => {
38
+ if (typeof __dirname !== 'undefined') {
39
+ // CommonJS
40
+ return join(__dirname, '..');
41
+ } else {
42
+ // ESM
43
+ const __filename = fileURLToPath(import.meta.url);
44
+ const __dirname = dirname(__filename);
45
+ return join(__dirname, '..');
46
+ }
47
+ };
48
+
49
+ // Use the function to get the root path
50
+ const packageRoot = getPackageRoot();
51
+
36
52
  export const startApiServer = (port, argv) => {
37
53
  const app = express();
38
54
  app.use(cors({ origin: '*' }));
@@ -40,8 +56,8 @@ export const startApiServer = (port, argv) => {
40
56
  app.use(express.json({ limit: '50mb' }));
41
57
  app.use(express.urlencoded({ limit: '50mb', extended: true }));
42
58
 
43
- console.log(`Serving UI from ${join(__dirname, '../ui/dist/spa')}`);
44
- app.use(express.static(join(__dirname, '../ui/dist/spa')));
59
+ console.log(`Serving UI from ${join(packageRoot, 'ui/dist/spa')}`);
60
+ app.use(express.static(join(packageRoot, 'ui/dist/spa')));
45
61
 
46
62
  app.post('/api/getDatabasesFromExistingDumps', async (req, res) => {
47
63
  let { config } = req.body;
@@ -141,7 +157,7 @@ export const startApiServer = (port, argv) => {
141
157
 
142
158
  app.post('/api/browse-folders', async (req, res) => {
143
159
  try {
144
- const { currentPath = __dirname } = req.body;
160
+ const { currentPath = packageRoot } = req.body;
145
161
  console.log('Browsing folder:', currentPath);
146
162
 
147
163
  const resolvedPath = currentPath.startsWith('/') || currentPath.match(/^[A-Z]:\\/)
@@ -194,7 +210,7 @@ export const startApiServer = (port, argv) => {
194
210
 
195
211
  const resolvedPath = folderPath.startsWith('/') || folderPath.match(/^[A-Z]:\\/)
196
212
  ? resolve(folderPath)
197
- : resolve(__dirname, folderPath);
213
+ : resolve(packageRoot, folderPath);
198
214
 
199
215
  await mkdir(resolvedPath, { recursive: true });
200
216