@dbcube/core 1.0.34 → 1.0.38

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.d.mts CHANGED
@@ -74,7 +74,6 @@ declare class Binary {
74
74
  static ensureBinariesExist(): Promise<void>;
75
75
  private static downloadBinaries;
76
76
  private static getBinDir;
77
- private static ensureGitIgnore;
78
77
  static get(): Promise<BinaryType>;
79
78
  }
80
79
 
package/dist/index.d.ts CHANGED
@@ -74,7 +74,6 @@ declare class Binary {
74
74
  static ensureBinariesExist(): Promise<void>;
75
75
  private static downloadBinaries;
76
76
  private static getBinDir;
77
- private static ensureGitIgnore;
78
77
  static get(): Promise<BinaryType>;
79
78
  }
80
79
 
package/dist/index.js CHANGED
@@ -428,9 +428,6 @@ var Binary = class {
428
428
  if (!fs2.existsSync(dir)) {
429
429
  fs2.mkdirSync(dir, { recursive: true });
430
430
  }
431
- if (dir.includes(path2.resolve(process.cwd(), ".dbcube"))) {
432
- this.ensureGitIgnore(path2.resolve(process.cwd(), ".dbcube"));
433
- }
434
431
  return dir;
435
432
  } catch {
436
433
  continue;
@@ -440,21 +437,6 @@ var Binary = class {
440
437
  fs2.mkdirSync(tempDir, { recursive: true });
441
438
  return tempDir;
442
439
  }
443
- static ensureGitIgnore(dbcubeDir) {
444
- try {
445
- const gitignorePath = path2.join(dbcubeDir, ".gitignore");
446
- if (!fs2.existsSync(gitignorePath)) {
447
- const gitignoreContent = `# DBCube binaries
448
- bin/
449
- *.exe
450
- *.log
451
- *.tmp
452
- `;
453
- fs2.writeFileSync(gitignorePath, gitignoreContent);
454
- }
455
- } catch {
456
- }
457
- }
458
440
  static async get() {
459
441
  await this.ensureBinariesExist();
460
442
  const arch2 = new Arquitecture();
@@ -714,6 +696,7 @@ var Engine = class {
714
696
  // src/lib/SqliteExecutor.ts
715
697
  import { exec } from "child_process";
716
698
  import * as path4 from "path";
699
+ import * as fs3 from "fs";
717
700
  import { promisify } from "util";
718
701
  var execAsync = promisify(exec);
719
702
  var SqliteExecutor = class {
@@ -724,11 +707,28 @@ var SqliteExecutor = class {
724
707
  this.binaryPath = this.getBinaryPath();
725
708
  }
726
709
  getBinaryPath() {
727
- const binDir = path4.resolve(__dirname, "..", "bin");
710
+ const possibleDirs = [
711
+ path4.resolve(process.cwd(), ".dbcube", "bin"),
712
+ path4.resolve(process.cwd(), "node_modules", ".dbcube", "bin"),
713
+ path4.resolve(__dirname, "..", "bin")
714
+ ];
728
715
  const platform2 = process.platform;
729
716
  const extension = platform2 === "win32" ? ".exe" : "";
730
- const binaryName = `sqlite-engine${extension}`;
731
- return path4.join(binDir, binaryName);
717
+ const binaryName = `sqlite-engine-${platform2 === "win32" ? "windows" : platform2 === "darwin" ? "macos" : "linux"}-x64${extension}`;
718
+ for (const dir of possibleDirs) {
719
+ const fullPath = path4.join(dir, binaryName);
720
+ if (fs3.existsSync(fullPath)) {
721
+ return fullPath;
722
+ }
723
+ }
724
+ const fallbackName = `sqlite-engine${extension}`;
725
+ for (const dir of possibleDirs) {
726
+ const fullPath = path4.join(dir, fallbackName);
727
+ if (fs3.existsSync(fullPath)) {
728
+ return fullPath;
729
+ }
730
+ }
731
+ return path4.join(possibleDirs[0], binaryName);
732
732
  }
733
733
  async executeBinary(args) {
734
734
  const command = `"${this.binaryPath}" ${args.map((arg) => `"${arg}"`).join(" ")}`;
@@ -871,7 +871,7 @@ var SqliteExecutor = class {
871
871
 
872
872
  // src/lib/DbConfig.ts
873
873
  import * as path5 from "path";
874
- import fs3 from "fs";
874
+ import fs4 from "fs";
875
875
  var rootPath = path5.resolve(process.cwd(), ".dbcube");
876
876
  var SQLite = class {
877
877
  executor = null;
@@ -883,10 +883,10 @@ var SQLite = class {
883
883
  if (this.database) {
884
884
  const dbPath = this.database || ":memory:";
885
885
  const configPath = path5.join(rootPath, dbPath + ".db");
886
- if (!fs3.existsSync(rootPath)) {
887
- fs3.mkdirSync(rootPath, { recursive: true });
886
+ if (!fs4.existsSync(rootPath)) {
887
+ fs4.mkdirSync(rootPath, { recursive: true });
888
888
  }
889
- if (fs3.existsSync(configPath)) {
889
+ if (fs4.existsSync(configPath)) {
890
890
  return true;
891
891
  }
892
892
  if (!this.executor) {
@@ -902,8 +902,8 @@ var SQLite = class {
902
902
  if (!this.executor) {
903
903
  const dbPath = this.database || ":memory:";
904
904
  const configPath = path5.join(rootPath, dbPath + ".db");
905
- if (!fs3.existsSync(rootPath)) {
906
- fs3.mkdirSync(rootPath, { recursive: true });
905
+ if (!fs4.existsSync(rootPath)) {
906
+ fs4.mkdirSync(rootPath, { recursive: true });
907
907
  }
908
908
  this.executor = new SqliteExecutor(configPath);
909
909
  const connected = await this.executor.connect();
@@ -1085,7 +1085,7 @@ var DbConfig = new SQLite({ DATABASE: "config" });
1085
1085
  var DbConfig_default = DbConfig;
1086
1086
 
1087
1087
  // src/lib/FileLogger.ts
1088
- import * as fs4 from "fs";
1088
+ import * as fs5 from "fs";
1089
1089
  import * as path6 from "path";
1090
1090
  import { EventEmitter } from "events";
1091
1091
  var FileLogger = class _FileLogger extends EventEmitter {
@@ -1102,8 +1102,8 @@ var FileLogger = class _FileLogger extends EventEmitter {
1102
1102
  static async write(filePath, message, level = "INFO", append = true) {
1103
1103
  try {
1104
1104
  const dir = path6.dirname(filePath);
1105
- if (!fs4.existsSync(dir)) {
1106
- fs4.mkdirSync(dir, { recursive: true });
1105
+ if (!fs5.existsSync(dir)) {
1106
+ fs5.mkdirSync(dir, { recursive: true });
1107
1107
  }
1108
1108
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
1109
1109
  const formattedMessage = `[${timestamp}] [${level}] ${message}
@@ -1113,9 +1113,9 @@ var FileLogger = class _FileLogger extends EventEmitter {
1113
1113
  return true;
1114
1114
  }
1115
1115
  if (append) {
1116
- await fs4.promises.appendFile(filePath, formattedMessage, "utf8");
1116
+ await fs5.promises.appendFile(filePath, formattedMessage, "utf8");
1117
1117
  } else {
1118
- await fs4.promises.writeFile(filePath, formattedMessage, "utf8");
1118
+ await fs5.promises.writeFile(filePath, formattedMessage, "utf8");
1119
1119
  }
1120
1120
  return true;
1121
1121
  } catch (error) {
@@ -1141,11 +1141,11 @@ var FileLogger = class _FileLogger extends EventEmitter {
1141
1141
  if (buffer && buffer.length > 0) {
1142
1142
  try {
1143
1143
  const dir = path6.dirname(filePath);
1144
- if (!fs4.existsSync(dir)) {
1145
- fs4.mkdirSync(dir, { recursive: true });
1144
+ if (!fs5.existsSync(dir)) {
1145
+ fs5.mkdirSync(dir, { recursive: true });
1146
1146
  }
1147
1147
  const content = buffer.join("");
1148
- await fs4.promises.appendFile(filePath, content, "utf8");
1148
+ await fs5.promises.appendFile(filePath, content, "utf8");
1149
1149
  _FileLogger.buffers.delete(filePath);
1150
1150
  return true;
1151
1151
  } catch (error) {
@@ -1281,10 +1281,10 @@ var FileLogger = class _FileLogger extends EventEmitter {
1281
1281
  // Si debe retornar como array de líneas
1282
1282
  } = options;
1283
1283
  try {
1284
- if (!fs4.existsSync(filePath)) {
1284
+ if (!fs5.existsSync(filePath)) {
1285
1285
  return asArray ? [] : "";
1286
1286
  }
1287
- let content = await fs4.promises.readFile(filePath, "utf8");
1287
+ let content = await fs5.promises.readFile(filePath, "utf8");
1288
1288
  if (asArray) {
1289
1289
  let linesArray = content.split("\n").filter((line) => line.trim() !== "");
1290
1290
  if (lines !== null) {
@@ -1327,15 +1327,15 @@ var FileLogger = class _FileLogger extends EventEmitter {
1327
1327
  } = options;
1328
1328
  let lastSize = 0;
1329
1329
  let lastPosition = 0;
1330
- if (fs4.existsSync(filePath)) {
1331
- const stats = fs4.statSync(filePath);
1330
+ if (fs5.existsSync(filePath)) {
1331
+ const stats = fs5.statSync(filePath);
1332
1332
  lastSize = stats.size;
1333
1333
  lastPosition = fromEnd ? stats.size : 0;
1334
1334
  }
1335
1335
  const listener = async (curr, prev) => {
1336
1336
  try {
1337
1337
  if (curr.size > lastSize) {
1338
- const stream = fs4.createReadStream(filePath, {
1338
+ const stream = fs5.createReadStream(filePath, {
1339
1339
  start: lastPosition,
1340
1340
  end: curr.size - 1,
1341
1341
  encoding: "utf8"
@@ -1363,7 +1363,7 @@ var FileLogger = class _FileLogger extends EventEmitter {
1363
1363
  console.error("Error en watcher:", error);
1364
1364
  }
1365
1365
  };
1366
- fs4.watchFile(filePath, { persistent, interval }, listener);
1366
+ fs5.watchFile(filePath, { persistent, interval }, listener);
1367
1367
  const watcherId = `${filePath}_${Date.now()}`;
1368
1368
  _FileLogger.watchers.set(watcherId, listener);
1369
1369
  return {
@@ -1371,7 +1371,7 @@ var FileLogger = class _FileLogger extends EventEmitter {
1371
1371
  stop: () => {
1372
1372
  const storedListener = _FileLogger.watchers.get(watcherId);
1373
1373
  if (storedListener) {
1374
- fs4.unwatchFile(filePath, storedListener);
1374
+ fs5.unwatchFile(filePath, storedListener);
1375
1375
  _FileLogger.watchers.delete(watcherId);
1376
1376
  }
1377
1377
  },
@@ -1384,7 +1384,7 @@ var FileLogger = class _FileLogger extends EventEmitter {
1384
1384
  static stopAllWatchers() {
1385
1385
  for (const [watcherId] of _FileLogger.watchers) {
1386
1386
  const filePath = watcherId.split("_")[0];
1387
- fs4.unwatchFile(filePath);
1387
+ fs5.unwatchFile(filePath);
1388
1388
  }
1389
1389
  _FileLogger.watchers.clear();
1390
1390
  }
@@ -1414,7 +1414,7 @@ var FileLogger = class _FileLogger extends EventEmitter {
1414
1414
  if (lines.length > maxLines) {
1415
1415
  const keepLines = lines.slice(-maxLines);
1416
1416
  const content = keepLines.join("\n") + "\n";
1417
- await fs4.promises.writeFile(filePath, content, "utf8");
1417
+ await fs5.promises.writeFile(filePath, content, "utf8");
1418
1418
  return lines.length - maxLines;
1419
1419
  }
1420
1420
  return 0;
@@ -1429,8 +1429,8 @@ var FileLogger = class _FileLogger extends EventEmitter {
1429
1429
  */
1430
1430
  static async deleteLogFile(filePath) {
1431
1431
  try {
1432
- if (fs4.existsSync(filePath)) {
1433
- await fs4.promises.unlink(filePath);
1432
+ if (fs5.existsSync(filePath)) {
1433
+ await fs5.promises.unlink(filePath);
1434
1434
  return true;
1435
1435
  }
1436
1436
  return false;