@hienlh/ppm 0.12.4 → 0.12.6
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/CHANGELOG.md +11 -0
- package/bun.lock +2062 -0
- package/bunfig.toml +2 -0
- package/package.json +1 -1
- package/src/cli/commands/db-cmd.ts +10 -0
- package/src/index.ts +0 -0
package/bunfig.toml
ADDED
package/package.json
CHANGED
|
@@ -168,6 +168,7 @@ export function registerDbCommands(program: Command): void {
|
|
|
168
168
|
if (conn.type === "postgres") {
|
|
169
169
|
const { postgresService } = await import("../../services/postgres.service.ts");
|
|
170
170
|
const result = await postgresService.testConnection(cfg.connectionString!);
|
|
171
|
+
await postgresService.closeAll();
|
|
171
172
|
if (result.ok) {
|
|
172
173
|
console.log(`${C.green}✓${C.reset} Connection successful: ${conn.name}`);
|
|
173
174
|
} else {
|
|
@@ -180,6 +181,7 @@ export function registerDbCommands(program: Command): void {
|
|
|
180
181
|
// Try opening the file
|
|
181
182
|
const { sqliteService } = await import("../../services/sqlite.service.ts");
|
|
182
183
|
sqliteService.getTables(cfg.path!, cfg.path!);
|
|
184
|
+
sqliteService.closeAll();
|
|
183
185
|
console.log(`${C.green}✓${C.reset} SQLite file accessible: ${conn.name}`);
|
|
184
186
|
} else {
|
|
185
187
|
console.error(`${C.red}✗${C.reset} File not found: ${cfg.path}`);
|
|
@@ -208,6 +210,7 @@ export function registerDbCommands(program: Command): void {
|
|
|
208
210
|
if (conn.type === "postgres") {
|
|
209
211
|
const { postgresService } = await import("../../services/postgres.service.ts");
|
|
210
212
|
const tables = await postgresService.getTables(cfg.connectionString!);
|
|
213
|
+
await postgresService.closeAll();
|
|
211
214
|
if (tables.length === 0) {
|
|
212
215
|
console.log(`${C.dim}No tables found.${C.reset}`);
|
|
213
216
|
return;
|
|
@@ -219,6 +222,7 @@ export function registerDbCommands(program: Command): void {
|
|
|
219
222
|
} else {
|
|
220
223
|
const { sqliteService } = await import("../../services/sqlite.service.ts");
|
|
221
224
|
const tables = sqliteService.getTables(cfg.path!, cfg.path!);
|
|
225
|
+
sqliteService.closeAll();
|
|
222
226
|
if (tables.length === 0) {
|
|
223
227
|
console.log(`${C.dim}No tables found.${C.reset}`);
|
|
224
228
|
return;
|
|
@@ -251,6 +255,7 @@ export function registerDbCommands(program: Command): void {
|
|
|
251
255
|
if (conn.type === "postgres") {
|
|
252
256
|
const { postgresService } = await import("../../services/postgres.service.ts");
|
|
253
257
|
const cols = await postgresService.getTableSchema(cfg.connectionString!, table, options.schema);
|
|
258
|
+
await postgresService.closeAll();
|
|
254
259
|
printTable(
|
|
255
260
|
["Column", "Type", "Nullable", "PK", "Default"],
|
|
256
261
|
cols.map((c) => [c.name, c.type, c.nullable ? "YES" : "NO", c.pk ? "PK" : "", c.defaultValue ?? ""]),
|
|
@@ -258,6 +263,7 @@ export function registerDbCommands(program: Command): void {
|
|
|
258
263
|
} else {
|
|
259
264
|
const { sqliteService } = await import("../../services/sqlite.service.ts");
|
|
260
265
|
const cols = sqliteService.getTableSchema(cfg.path!, cfg.path!, table);
|
|
266
|
+
sqliteService.closeAll();
|
|
261
267
|
printTable(
|
|
262
268
|
["Column", "Type", "Not Null", "PK", "Default"],
|
|
263
269
|
cols.map((c) => [c.name, c.type, c.notnull ? "YES" : "NO", c.pk ? "PK" : "", c.dflt_value ?? ""]),
|
|
@@ -295,6 +301,7 @@ export function registerDbCommands(program: Command): void {
|
|
|
295
301
|
const result = await postgresService.getTableData(
|
|
296
302
|
cfg.connectionString!, table, options.schema, page, limit, options.order, orderDir,
|
|
297
303
|
);
|
|
304
|
+
await postgresService.closeAll();
|
|
298
305
|
console.log(`${C.cyan}${table}${C.reset} — page ${result.page}, ${result.total} total rows\n`);
|
|
299
306
|
formatRows(result.columns, result.rows, limit);
|
|
300
307
|
} else {
|
|
@@ -302,6 +309,7 @@ export function registerDbCommands(program: Command): void {
|
|
|
302
309
|
const result = sqliteService.getTableData(
|
|
303
310
|
cfg.path!, cfg.path!, table, page, limit, options.order, orderDir,
|
|
304
311
|
);
|
|
312
|
+
sqliteService.closeAll();
|
|
305
313
|
console.log(`${C.cyan}${table}${C.reset} — page ${result.page}, ${result.total} total rows\n`);
|
|
306
314
|
formatRows(result.columns, result.rows, limit);
|
|
307
315
|
}
|
|
@@ -334,6 +342,7 @@ export function registerDbCommands(program: Command): void {
|
|
|
334
342
|
if (conn.type === "postgres") {
|
|
335
343
|
const { postgresService } = await import("../../services/postgres.service.ts");
|
|
336
344
|
const result = await postgresService.executeQuery(cfg.connectionString!, sql);
|
|
345
|
+
await postgresService.closeAll();
|
|
337
346
|
if (result.changeType === "select") {
|
|
338
347
|
formatRows(result.columns, result.rows);
|
|
339
348
|
} else {
|
|
@@ -342,6 +351,7 @@ export function registerDbCommands(program: Command): void {
|
|
|
342
351
|
} else {
|
|
343
352
|
const { sqliteService } = await import("../../services/sqlite.service.ts");
|
|
344
353
|
const result = sqliteService.executeQuery(cfg.path!, cfg.path!, sql);
|
|
354
|
+
sqliteService.closeAll();
|
|
345
355
|
if (result.changeType === "select") {
|
|
346
356
|
formatRows(result.columns, result.rows);
|
|
347
357
|
} else {
|
package/src/index.ts
CHANGED
|
File without changes
|