@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.cjs +40 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +46 -46
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -465,9 +465,6 @@ var Binary = class {
|
|
|
465
465
|
if (!fs2.existsSync(dir)) {
|
|
466
466
|
fs2.mkdirSync(dir, { recursive: true });
|
|
467
467
|
}
|
|
468
|
-
if (dir.includes(path2.resolve(process.cwd(), ".dbcube"))) {
|
|
469
|
-
this.ensureGitIgnore(path2.resolve(process.cwd(), ".dbcube"));
|
|
470
|
-
}
|
|
471
468
|
return dir;
|
|
472
469
|
} catch {
|
|
473
470
|
continue;
|
|
@@ -477,21 +474,6 @@ var Binary = class {
|
|
|
477
474
|
fs2.mkdirSync(tempDir, { recursive: true });
|
|
478
475
|
return tempDir;
|
|
479
476
|
}
|
|
480
|
-
static ensureGitIgnore(dbcubeDir) {
|
|
481
|
-
try {
|
|
482
|
-
const gitignorePath = path2.join(dbcubeDir, ".gitignore");
|
|
483
|
-
if (!fs2.existsSync(gitignorePath)) {
|
|
484
|
-
const gitignoreContent = `# DBCube binaries
|
|
485
|
-
bin/
|
|
486
|
-
*.exe
|
|
487
|
-
*.log
|
|
488
|
-
*.tmp
|
|
489
|
-
`;
|
|
490
|
-
fs2.writeFileSync(gitignorePath, gitignoreContent);
|
|
491
|
-
}
|
|
492
|
-
} catch {
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
477
|
static async get() {
|
|
496
478
|
await this.ensureBinariesExist();
|
|
497
479
|
const arch2 = new Arquitecture();
|
|
@@ -751,6 +733,7 @@ var Engine = class {
|
|
|
751
733
|
// src/lib/SqliteExecutor.ts
|
|
752
734
|
var import_child_process2 = require("child_process");
|
|
753
735
|
var path4 = __toESM(require("path"));
|
|
736
|
+
var fs3 = __toESM(require("fs"));
|
|
754
737
|
var import_util = require("util");
|
|
755
738
|
var execAsync = (0, import_util.promisify)(import_child_process2.exec);
|
|
756
739
|
var SqliteExecutor = class {
|
|
@@ -761,11 +744,28 @@ var SqliteExecutor = class {
|
|
|
761
744
|
this.binaryPath = this.getBinaryPath();
|
|
762
745
|
}
|
|
763
746
|
getBinaryPath() {
|
|
764
|
-
const
|
|
747
|
+
const possibleDirs = [
|
|
748
|
+
path4.resolve(process.cwd(), ".dbcube", "bin"),
|
|
749
|
+
path4.resolve(process.cwd(), "node_modules", ".dbcube", "bin"),
|
|
750
|
+
path4.resolve(__dirname, "..", "bin")
|
|
751
|
+
];
|
|
765
752
|
const platform2 = process.platform;
|
|
766
753
|
const extension = platform2 === "win32" ? ".exe" : "";
|
|
767
|
-
const binaryName = `sqlite-engine${extension}`;
|
|
768
|
-
|
|
754
|
+
const binaryName = `sqlite-engine-${platform2 === "win32" ? "windows" : platform2 === "darwin" ? "macos" : "linux"}-x64${extension}`;
|
|
755
|
+
for (const dir of possibleDirs) {
|
|
756
|
+
const fullPath = path4.join(dir, binaryName);
|
|
757
|
+
if (fs3.existsSync(fullPath)) {
|
|
758
|
+
return fullPath;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
const fallbackName = `sqlite-engine${extension}`;
|
|
762
|
+
for (const dir of possibleDirs) {
|
|
763
|
+
const fullPath = path4.join(dir, fallbackName);
|
|
764
|
+
if (fs3.existsSync(fullPath)) {
|
|
765
|
+
return fullPath;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
return path4.join(possibleDirs[0], binaryName);
|
|
769
769
|
}
|
|
770
770
|
async executeBinary(args) {
|
|
771
771
|
const command = `"${this.binaryPath}" ${args.map((arg) => `"${arg}"`).join(" ")}`;
|
|
@@ -1122,7 +1122,7 @@ var DbConfig = new SQLite({ DATABASE: "config" });
|
|
|
1122
1122
|
var DbConfig_default = DbConfig;
|
|
1123
1123
|
|
|
1124
1124
|
// src/lib/FileLogger.ts
|
|
1125
|
-
var
|
|
1125
|
+
var fs5 = __toESM(require("fs"));
|
|
1126
1126
|
var path6 = __toESM(require("path"));
|
|
1127
1127
|
var import_events = require("events");
|
|
1128
1128
|
var FileLogger = class _FileLogger extends import_events.EventEmitter {
|
|
@@ -1139,8 +1139,8 @@ var FileLogger = class _FileLogger extends import_events.EventEmitter {
|
|
|
1139
1139
|
static async write(filePath, message, level = "INFO", append = true) {
|
|
1140
1140
|
try {
|
|
1141
1141
|
const dir = path6.dirname(filePath);
|
|
1142
|
-
if (!
|
|
1143
|
-
|
|
1142
|
+
if (!fs5.existsSync(dir)) {
|
|
1143
|
+
fs5.mkdirSync(dir, { recursive: true });
|
|
1144
1144
|
}
|
|
1145
1145
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
1146
1146
|
const formattedMessage = `[${timestamp}] [${level}] ${message}
|
|
@@ -1150,9 +1150,9 @@ var FileLogger = class _FileLogger extends import_events.EventEmitter {
|
|
|
1150
1150
|
return true;
|
|
1151
1151
|
}
|
|
1152
1152
|
if (append) {
|
|
1153
|
-
await
|
|
1153
|
+
await fs5.promises.appendFile(filePath, formattedMessage, "utf8");
|
|
1154
1154
|
} else {
|
|
1155
|
-
await
|
|
1155
|
+
await fs5.promises.writeFile(filePath, formattedMessage, "utf8");
|
|
1156
1156
|
}
|
|
1157
1157
|
return true;
|
|
1158
1158
|
} catch (error) {
|
|
@@ -1178,11 +1178,11 @@ var FileLogger = class _FileLogger extends import_events.EventEmitter {
|
|
|
1178
1178
|
if (buffer && buffer.length > 0) {
|
|
1179
1179
|
try {
|
|
1180
1180
|
const dir = path6.dirname(filePath);
|
|
1181
|
-
if (!
|
|
1182
|
-
|
|
1181
|
+
if (!fs5.existsSync(dir)) {
|
|
1182
|
+
fs5.mkdirSync(dir, { recursive: true });
|
|
1183
1183
|
}
|
|
1184
1184
|
const content = buffer.join("");
|
|
1185
|
-
await
|
|
1185
|
+
await fs5.promises.appendFile(filePath, content, "utf8");
|
|
1186
1186
|
_FileLogger.buffers.delete(filePath);
|
|
1187
1187
|
return true;
|
|
1188
1188
|
} catch (error) {
|
|
@@ -1318,10 +1318,10 @@ var FileLogger = class _FileLogger extends import_events.EventEmitter {
|
|
|
1318
1318
|
// Si debe retornar como array de líneas
|
|
1319
1319
|
} = options;
|
|
1320
1320
|
try {
|
|
1321
|
-
if (!
|
|
1321
|
+
if (!fs5.existsSync(filePath)) {
|
|
1322
1322
|
return asArray ? [] : "";
|
|
1323
1323
|
}
|
|
1324
|
-
let content = await
|
|
1324
|
+
let content = await fs5.promises.readFile(filePath, "utf8");
|
|
1325
1325
|
if (asArray) {
|
|
1326
1326
|
let linesArray = content.split("\n").filter((line) => line.trim() !== "");
|
|
1327
1327
|
if (lines !== null) {
|
|
@@ -1364,15 +1364,15 @@ var FileLogger = class _FileLogger extends import_events.EventEmitter {
|
|
|
1364
1364
|
} = options;
|
|
1365
1365
|
let lastSize = 0;
|
|
1366
1366
|
let lastPosition = 0;
|
|
1367
|
-
if (
|
|
1368
|
-
const stats =
|
|
1367
|
+
if (fs5.existsSync(filePath)) {
|
|
1368
|
+
const stats = fs5.statSync(filePath);
|
|
1369
1369
|
lastSize = stats.size;
|
|
1370
1370
|
lastPosition = fromEnd ? stats.size : 0;
|
|
1371
1371
|
}
|
|
1372
1372
|
const listener = async (curr, prev) => {
|
|
1373
1373
|
try {
|
|
1374
1374
|
if (curr.size > lastSize) {
|
|
1375
|
-
const stream =
|
|
1375
|
+
const stream = fs5.createReadStream(filePath, {
|
|
1376
1376
|
start: lastPosition,
|
|
1377
1377
|
end: curr.size - 1,
|
|
1378
1378
|
encoding: "utf8"
|
|
@@ -1400,7 +1400,7 @@ var FileLogger = class _FileLogger extends import_events.EventEmitter {
|
|
|
1400
1400
|
console.error("Error en watcher:", error);
|
|
1401
1401
|
}
|
|
1402
1402
|
};
|
|
1403
|
-
|
|
1403
|
+
fs5.watchFile(filePath, { persistent, interval }, listener);
|
|
1404
1404
|
const watcherId = `${filePath}_${Date.now()}`;
|
|
1405
1405
|
_FileLogger.watchers.set(watcherId, listener);
|
|
1406
1406
|
return {
|
|
@@ -1408,7 +1408,7 @@ var FileLogger = class _FileLogger extends import_events.EventEmitter {
|
|
|
1408
1408
|
stop: () => {
|
|
1409
1409
|
const storedListener = _FileLogger.watchers.get(watcherId);
|
|
1410
1410
|
if (storedListener) {
|
|
1411
|
-
|
|
1411
|
+
fs5.unwatchFile(filePath, storedListener);
|
|
1412
1412
|
_FileLogger.watchers.delete(watcherId);
|
|
1413
1413
|
}
|
|
1414
1414
|
},
|
|
@@ -1421,7 +1421,7 @@ var FileLogger = class _FileLogger extends import_events.EventEmitter {
|
|
|
1421
1421
|
static stopAllWatchers() {
|
|
1422
1422
|
for (const [watcherId] of _FileLogger.watchers) {
|
|
1423
1423
|
const filePath = watcherId.split("_")[0];
|
|
1424
|
-
|
|
1424
|
+
fs5.unwatchFile(filePath);
|
|
1425
1425
|
}
|
|
1426
1426
|
_FileLogger.watchers.clear();
|
|
1427
1427
|
}
|
|
@@ -1451,7 +1451,7 @@ var FileLogger = class _FileLogger extends import_events.EventEmitter {
|
|
|
1451
1451
|
if (lines.length > maxLines) {
|
|
1452
1452
|
const keepLines = lines.slice(-maxLines);
|
|
1453
1453
|
const content = keepLines.join("\n") + "\n";
|
|
1454
|
-
await
|
|
1454
|
+
await fs5.promises.writeFile(filePath, content, "utf8");
|
|
1455
1455
|
return lines.length - maxLines;
|
|
1456
1456
|
}
|
|
1457
1457
|
return 0;
|
|
@@ -1466,8 +1466,8 @@ var FileLogger = class _FileLogger extends import_events.EventEmitter {
|
|
|
1466
1466
|
*/
|
|
1467
1467
|
static async deleteLogFile(filePath) {
|
|
1468
1468
|
try {
|
|
1469
|
-
if (
|
|
1470
|
-
await
|
|
1469
|
+
if (fs5.existsSync(filePath)) {
|
|
1470
|
+
await fs5.promises.unlink(filePath);
|
|
1471
1471
|
return true;
|
|
1472
1472
|
}
|
|
1473
1473
|
return false;
|