@event-driven-io/pongo 0.17.0-beta.2 → 0.17.0-beta.21
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/{chunk-ECQ2CKZE.cjs → chunk-A4DCNQJR.cjs} +45 -43
- package/dist/chunk-A4DCNQJR.cjs.map +1 -0
- package/dist/{chunk-4BL6YWLW.cjs → chunk-BZRKCNRY.cjs} +105 -72
- package/dist/chunk-BZRKCNRY.cjs.map +1 -0
- package/dist/{chunk-NCNRRYVE.js → chunk-H637RRXS.js} +85 -52
- package/dist/chunk-H637RRXS.js.map +1 -0
- package/dist/{chunk-Y7LRKJLJ.js → chunk-TTZGGAZV.js} +40 -38
- package/dist/chunk-TTZGGAZV.js.map +1 -0
- package/dist/cli.cjs +43 -37
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +34 -28
- package/dist/cli.js.map +1 -1
- package/dist/cloudflare.cjs +53 -0
- package/dist/cloudflare.cjs.map +1 -0
- package/dist/cloudflare.d.cts +11 -0
- package/dist/cloudflare.d.ts +11 -0
- package/dist/{d1.js → cloudflare.js} +19 -20
- package/dist/cloudflare.js.map +1 -0
- package/dist/{index-BJopB-em.d.cts → index-BAiq0hu3.d.cts} +3 -2
- package/dist/{index-G5DECNb_.d.ts → index-DF5J9nRH.d.ts} +3 -2
- package/dist/index.cjs +27 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -9
- package/dist/index.d.ts +17 -9
- package/dist/index.js +30 -6
- package/dist/index.js.map +1 -1
- package/dist/pg.cjs +344 -4
- package/dist/pg.cjs.map +1 -1
- package/dist/pg.d.cts +10 -9
- package/dist/pg.d.ts +10 -9
- package/dist/pg.js +350 -10
- package/dist/pg.js.map +1 -1
- package/dist/{pongoCollectionSchemaComponent-t_e9n2Wc.d.ts → pongoCollectionSchemaComponent-BhsINgDe.d.cts} +44 -34
- package/dist/{pongoCollectionSchemaComponent-t_e9n2Wc.d.cts → pongoCollectionSchemaComponent-BhsINgDe.d.ts} +44 -34
- package/dist/shim.cjs +12 -14
- package/dist/shim.cjs.map +1 -1
- package/dist/shim.d.cts +4 -4
- package/dist/shim.d.ts +4 -4
- package/dist/shim.js +7 -9
- package/dist/shim.js.map +1 -1
- package/dist/sqlite3.cjs +21 -26
- package/dist/sqlite3.cjs.map +1 -1
- package/dist/sqlite3.d.cts +6 -6
- package/dist/sqlite3.d.ts +6 -6
- package/dist/sqlite3.js +20 -25
- package/dist/sqlite3.js.map +1 -1
- package/package.json +50 -36
- package/dist/chunk-4BL6YWLW.cjs.map +0 -1
- package/dist/chunk-ECQ2CKZE.cjs.map +0 -1
- package/dist/chunk-EYQDS752.js +0 -364
- package/dist/chunk-EYQDS752.js.map +0 -1
- package/dist/chunk-NCNRRYVE.js.map +0 -1
- package/dist/chunk-WH26IXHN.js +0 -10
- package/dist/chunk-WH26IXHN.js.map +0 -1
- package/dist/chunk-WKW4LGF6.cjs +0 -10
- package/dist/chunk-WKW4LGF6.cjs.map +0 -1
- package/dist/chunk-Y7LRKJLJ.js.map +0 -1
- package/dist/chunk-ZPWKWNK2.cjs +0 -364
- package/dist/chunk-ZPWKWNK2.cjs.map +0 -1
- package/dist/d1.cjs +0 -54
- package/dist/d1.cjs.map +0 -1
- package/dist/d1.d.cts +0 -11
- package/dist/d1.d.ts +0 -11
- package/dist/d1.js.map +0 -1
- package/dist/pg-73DOKU64.js +0 -11
- package/dist/pg-73DOKU64.js.map +0 -1
- package/dist/pg-I267A7IL.cjs +0 -11
- package/dist/pg-I267A7IL.cjs.map +0 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
var _chunk4BL6YWLWcjs = require('./chunk-4BL6YWLW.cjs');
|
|
8
|
+
var _chunkBZRKCNRYcjs = require('./chunk-BZRKCNRY.cjs');
|
|
10
9
|
|
|
11
10
|
// src/cli.ts
|
|
12
11
|
var _commander = require('commander');
|
|
@@ -93,7 +92,7 @@ var parseDefaultDbSchema = (imported) => {
|
|
|
93
92
|
if (!imported.default.schema.dbs) {
|
|
94
93
|
return missingDbs;
|
|
95
94
|
}
|
|
96
|
-
const dbs =
|
|
95
|
+
const dbs = _chunkBZRKCNRYcjs.objectEntries.call(void 0, imported.default.schema.dbs).map((db) => db[1]);
|
|
97
96
|
const defaultDb = dbs.find((db) => db.name === void 0);
|
|
98
97
|
if (!defaultDb) {
|
|
99
98
|
return missingDefaultDb;
|
|
@@ -101,17 +100,17 @@ var parseDefaultDbSchema = (imported) => {
|
|
|
101
100
|
if (!defaultDb.collections) {
|
|
102
101
|
return missingCollections;
|
|
103
102
|
}
|
|
104
|
-
const collections =
|
|
103
|
+
const collections = _chunkBZRKCNRYcjs.objectEntries.call(void 0, defaultDb.collections).map((col) => col[1]);
|
|
105
104
|
if (collections.length === 0) {
|
|
106
105
|
return missingCollections;
|
|
107
106
|
}
|
|
108
|
-
return
|
|
107
|
+
return _chunkBZRKCNRYcjs.toDbSchemaMetadata.call(void 0, defaultDb);
|
|
109
108
|
};
|
|
110
109
|
var configCommand = new (0, _commander.Command)("config").description(
|
|
111
110
|
"Manage Pongo configuration"
|
|
112
111
|
);
|
|
113
112
|
configCommand.command("sample").description("Generate or print sample configuration").option(
|
|
114
|
-
"
|
|
113
|
+
"--col, --collection <name>",
|
|
115
114
|
"Specify the collection name",
|
|
116
115
|
(value, previous) => {
|
|
117
116
|
return previous.concat([value]);
|
|
@@ -147,34 +146,39 @@ configCommand.command("sample").description("Generate or print sample configurat
|
|
|
147
146
|
|
|
148
147
|
|
|
149
148
|
|
|
149
|
+
|
|
150
150
|
var _dumbo = require('@event-driven-io/dumbo');
|
|
151
151
|
|
|
152
152
|
var migrateCommand = new (0, _commander.Command)("migrate").description(
|
|
153
153
|
"Manage database migrations"
|
|
154
154
|
);
|
|
155
155
|
migrateCommand.command("run").description("Run database migrations").option(
|
|
156
|
-
"
|
|
156
|
+
"--dbt, --database-type <string>",
|
|
157
157
|
"Database type that should be used for connection (e.g., PostgreSQL or SQLite)",
|
|
158
158
|
void 0
|
|
159
159
|
).option(
|
|
160
|
-
"
|
|
160
|
+
"--drv, --database-driver <string>",
|
|
161
161
|
'Database driver that should be used for connection (e.g., "pg" for PostgreSQL, "sqlite3" for SQLite)'
|
|
162
162
|
).option(
|
|
163
|
-
"
|
|
163
|
+
"--dbn, --database-name <string>",
|
|
164
164
|
"Database name to connect to",
|
|
165
165
|
void 0
|
|
166
166
|
).option(
|
|
167
|
-
"
|
|
167
|
+
"--cs, --connection-string <string>",
|
|
168
168
|
"Connection string for the database"
|
|
169
169
|
).option(
|
|
170
|
-
"
|
|
170
|
+
"--col, --collection <name>",
|
|
171
171
|
"Specify the collection name",
|
|
172
172
|
(value, previous) => {
|
|
173
173
|
return previous.concat([value]);
|
|
174
174
|
},
|
|
175
175
|
[]
|
|
176
|
-
).option("-f, --config <path>", "Path to configuration file with Pongo config").option("
|
|
177
|
-
|
|
176
|
+
).option("-f, --config <path>", "Path to configuration file with Pongo config").option("--dr, --dryRun", "Perform dry run without commiting changes", false).option(
|
|
177
|
+
"--t, --timeout <ms>",
|
|
178
|
+
"Set the migration timeout in milliseconds",
|
|
179
|
+
parseInt
|
|
180
|
+
).action(async (options) => {
|
|
181
|
+
const { collection, dryRun, databaseName, databaseDriver, timeoutMs } = options;
|
|
178
182
|
const connectionString = _nullishCoalesce(options.connectionString, () => ( process.env.DB_CONNECTION_STRING));
|
|
179
183
|
const databaseType = _nullishCoalesce(options.databaseType, () => ( _dumbo.parseConnectionString.call(void 0, connectionString).databaseType));
|
|
180
184
|
let collectionNames;
|
|
@@ -204,21 +208,22 @@ migrateCommand.command("run").description("Run database migrations").option(
|
|
|
204
208
|
});
|
|
205
209
|
const pool = _dumbo.dumbo.call(void 0, { connectionString, driverType });
|
|
206
210
|
await _dumbo.runSQLMigrations.call(void 0, pool, migrations, {
|
|
207
|
-
dryRun
|
|
211
|
+
dryRun,
|
|
212
|
+
migrationTimeoutMs: timeoutMs
|
|
208
213
|
});
|
|
209
214
|
});
|
|
210
215
|
migrateCommand.command("sql").description("Generate SQL for database migration").option(
|
|
211
|
-
"
|
|
216
|
+
"--dbt, --database-type <string>",
|
|
212
217
|
"Database type that should be used for connection (e.g., PostgreSQL or SQLite)"
|
|
213
218
|
).option(
|
|
214
|
-
"
|
|
219
|
+
"--drv, --database-driver <string>",
|
|
215
220
|
'Database driver that should be used for connection (e.g., "pg" for PostgreSQL, "sqlite3" for SQLite)'
|
|
216
221
|
).option(
|
|
217
|
-
"
|
|
222
|
+
"--dbn, --database-name <string>",
|
|
218
223
|
"Database name to connect to",
|
|
219
224
|
void 0
|
|
220
225
|
).option(
|
|
221
|
-
"
|
|
226
|
+
"--col, --collection <name>",
|
|
222
227
|
"Specify the collection name",
|
|
223
228
|
(value, previous) => {
|
|
224
229
|
return previous.concat([value]);
|
|
@@ -254,19 +259,20 @@ var getMigrations = ({
|
|
|
254
259
|
databaseName,
|
|
255
260
|
collectionNames
|
|
256
261
|
}) => {
|
|
257
|
-
const driver =
|
|
262
|
+
const driver = _chunkBZRKCNRYcjs.pongoDriverRegistry.tryGet(driverType);
|
|
258
263
|
if (driver === null) {
|
|
259
264
|
console.error(
|
|
260
265
|
`Error: No database driver found for driver type "${driverType}". Make sure the driver is registered and the connection string is correct.`
|
|
261
266
|
);
|
|
262
267
|
process.exit(1);
|
|
263
268
|
}
|
|
264
|
-
const dbDefinition =
|
|
269
|
+
const dbDefinition = _chunkBZRKCNRYcjs.pongoSchema.db.from(databaseName, collectionNames);
|
|
265
270
|
const driverOptions = {
|
|
266
|
-
schema: { definition: dbDefinition }
|
|
271
|
+
schema: { definition: dbDefinition },
|
|
272
|
+
serializer: _dumbo.JSONSerializer
|
|
267
273
|
};
|
|
268
274
|
const customOptions = {
|
|
269
|
-
connectionString
|
|
275
|
+
connectionString,
|
|
270
276
|
databaseName
|
|
271
277
|
};
|
|
272
278
|
const db = driver.databaseFactory({ ...driverOptions, ...customOptions });
|
|
@@ -354,7 +360,7 @@ var prettifyLogs = (logLevel) => {
|
|
|
354
360
|
var startRepl = async (options) => {
|
|
355
361
|
setLogLevel(_nullishCoalesce(process.env.DUMBO_LOG_LEVEL, () => ( options.logging.logLevel)));
|
|
356
362
|
setLogStyle(_nullishCoalesce(process.env.DUMBO_LOG_STYLE, () => ( options.logging.logStyle)));
|
|
357
|
-
console.log(_dumbo.color.green("Starting Pongo Shell (version: 0.17.0-beta.
|
|
363
|
+
console.log(_dumbo.color.green("Starting Pongo Shell (version: 0.17.0-beta.21)"));
|
|
358
364
|
if (options.logging.printOptions) {
|
|
359
365
|
console.log(_dumbo.color.green("With Options:"));
|
|
360
366
|
console.log(_dumbo.prettyJson.call(void 0, options));
|
|
@@ -369,7 +375,7 @@ var startRepl = async (options) => {
|
|
|
369
375
|
}
|
|
370
376
|
const { databaseType } = _dumbo.parseConnectionString.call(void 0, connectionString);
|
|
371
377
|
const driverType = `${databaseType}:${options.databaseDriver}`;
|
|
372
|
-
const driver =
|
|
378
|
+
const driver = _chunkBZRKCNRYcjs.pongoDriverRegistry.tryGet(driverType);
|
|
373
379
|
if (driver === null) {
|
|
374
380
|
console.error(
|
|
375
381
|
`Error: No database driver found for driver type "${driverType}". Make sure the driver is installed and the connection string is correct.`
|
|
@@ -408,10 +414,10 @@ var startRepl = async (options) => {
|
|
|
408
414
|
if (options.schema.collections.length > 0) {
|
|
409
415
|
const collectionsSchema = {};
|
|
410
416
|
for (const collectionName of options.schema.collections) {
|
|
411
|
-
collectionsSchema[collectionName] =
|
|
417
|
+
collectionsSchema[collectionName] = _chunkBZRKCNRYcjs.pongoSchema.collection(collectionName);
|
|
412
418
|
}
|
|
413
|
-
const schema =
|
|
414
|
-
database:
|
|
419
|
+
const schema = _chunkBZRKCNRYcjs.pongoSchema.client({
|
|
420
|
+
database: _chunkBZRKCNRYcjs.pongoSchema.db(options.schema.database, collectionsSchema)
|
|
415
421
|
});
|
|
416
422
|
const driverOptions = {
|
|
417
423
|
driver,
|
|
@@ -423,7 +429,7 @@ var startRepl = async (options) => {
|
|
|
423
429
|
const customOptions = {
|
|
424
430
|
connectionString
|
|
425
431
|
};
|
|
426
|
-
const typedClient =
|
|
432
|
+
const typedClient = _chunkBZRKCNRYcjs.pongoClient.call(void 0, {
|
|
427
433
|
...driverOptions,
|
|
428
434
|
...customOptions
|
|
429
435
|
});
|
|
@@ -442,7 +448,7 @@ var startRepl = async (options) => {
|
|
|
442
448
|
const customOptions = {
|
|
443
449
|
connectionString
|
|
444
450
|
};
|
|
445
|
-
pongo =
|
|
451
|
+
pongo = _chunkBZRKCNRYcjs.pongoClient.call(void 0, {
|
|
446
452
|
...driverOptions,
|
|
447
453
|
...customOptions
|
|
448
454
|
});
|
|
@@ -473,27 +479,27 @@ var teardown = async () => {
|
|
|
473
479
|
process.on("uncaughtException", teardown);
|
|
474
480
|
process.on("SIGINT", teardown);
|
|
475
481
|
var shellCommand = new (0, _commander.Command)("shell").description("Start an interactive Pongo shell").option(
|
|
476
|
-
"
|
|
482
|
+
"--drv, --database-driver <string>",
|
|
477
483
|
'Database driver that should be used for connection (e.g., "pg" for PostgreSQL, "sqlite3" for SQLite)',
|
|
478
484
|
"pg"
|
|
479
485
|
).option(
|
|
480
|
-
"
|
|
486
|
+
"--cs, --connectionString <string>",
|
|
481
487
|
"Connection string for the database"
|
|
482
|
-
).option("
|
|
483
|
-
"
|
|
488
|
+
).option("--db, --database <string>", "Database name to connect", "postgres").option(
|
|
489
|
+
"--col, --collection <name>",
|
|
484
490
|
"Specify the collection name",
|
|
485
491
|
(value, previous) => {
|
|
486
492
|
return previous.concat([value]);
|
|
487
493
|
},
|
|
488
494
|
[]
|
|
489
495
|
).option(
|
|
490
|
-
"
|
|
496
|
+
"--no-migrations, --disable-auto-migrations",
|
|
491
497
|
"Disable automatic migrations"
|
|
492
498
|
).option("-o, --print-options", "Print shell options").option(
|
|
493
|
-
"
|
|
499
|
+
"--ll, --log-level <logLevel>",
|
|
494
500
|
"Log level: DISABLED, INFO, LOG, WARN, ERROR",
|
|
495
501
|
"DISABLED"
|
|
496
|
-
).option("
|
|
502
|
+
).option("--ls, --log-style", "Log style: RAW, PRETTY", "RAW").option("-p, --pretty-log", "Turn on logging with prettified output").action(async (options) => {
|
|
497
503
|
const { collection, database } = options;
|
|
498
504
|
const connectionString = options.connectionString;
|
|
499
505
|
await startRepl({
|
package/dist/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/pongo/dist/cli.cjs","../src/cli.ts","../src/commandLine/configFile.ts","../src/commandLine/migrate.ts","../src/commandLine/shell.ts"],"names":[],"mappings":"AAAA;AACA,+jBAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACTA,sCAAwB;ADWxB;AACA;AEbA;AACA,gEAAe;AAQf,IAAM,eAAA,EAAi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,MAAA;AACF,IAAA;AAGM,IAAA;AACJ,MAAA;AACF,IAAA;AAEM,IAAA;AACD,MAAA;AACA,MAAA;AACJ,IAAA;AAEI,IAAA;AAEM,IAAA;AACH,MAAA;AACR,IAAA;AAEQ,IAAA;AACH,EAAA;AACC,IAAA;AACJ,MAAA;AACQ,MAAA;AACN,QAAA;AACF,MAAA;AACF,IAAA;AAGM,IAAA;AACJ,MAAA;AACF,IAAA;AAEQ,IAAA;AACH,MAAA;AACA,MAAA;AACJ,IAAA;AAEU,IAAA;AACb,EAAA;AAEc,EAAA;AACA,EAAA;AAGA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AAGL,EAAA;AACD,IAAA;AACO,IAAA;AACd,EAAA;AAEQ,EAAA;AACD,IAAA;AACO,IAAA;AACd,EAAA;AACH;AAEiB;AACH,EAAA;AACA,EAAA;AACd;AAEW;AACA;AAcL;AAGF,EAAA;AACA,EAAA;AACA,EAAA;AAED;AACC,EAAA;AACA,EAAA;AAEM;AAEN,EAAA;AACA,EAAA;AACgB,EAAA;AAEP,IAAA;AACT,EAAA;AACC,EAAA;AAEF;AACC,EAAA;AACA,EAAA;AAEM;AAEN,EAAA;AACA,EAAA;AACA,EAAA;AAEM;AAGE,EAAA;AACF,EAAA;AAEA,EAAA;AACK,IAAA;AACP,MAAA;AACU,MAAA;AAGA,MAAA;AAKZ,IAAA;AACQ,IAAA;AACN,MAAA;AACA,MAAA;AACA,MAAA;AAGF,IAAA;AACA,IAAA;AACA,IAAA;AACD,EAAA;AACF;AJ4Jc;AACA;AC5fD;AAEH;AAEL;AACA;AACA;AAEM;AAEP;AD0fU;AACA;AACA","file":"/home/runner/work/Pongo/Pongo/src/packages/pongo/dist/cli.cjs","sourcesContent":[null,"#!/usr/bin/env node\nimport { Command } from 'commander';\nimport { configCommand, migrateCommand, shellCommand } from './commandLine';\n\nexport * from './storage/all';\n\nconst program = new Command();\n\nprogram.name('pongo').description('CLI tool for Pongo');\n\nprogram.addCommand(configCommand);\nprogram.addCommand(migrateCommand);\nprogram.addCommand(shellCommand);\n\nprogram.parse(process.argv);\n\nexport default program;\n","import { Command } from 'commander';\nimport fs from 'node:fs';\nimport {\n objectEntries,\n toDbSchemaMetadata,\n type PongoDbSchemaMetadata,\n type PongoSchemaConfig,\n} from '../core';\n\nconst formatTypeName = (input: string): string => {\n if (input.length === 0) {\n return input;\n }\n\n let formatted = input.charAt(0).toUpperCase() + input.slice(1);\n\n if (formatted.endsWith('s')) {\n formatted = formatted.slice(0, -1);\n }\n\n return formatted;\n};\n\nconst sampleConfig = (collectionNames: string[] = ['users']) => {\n const types = collectionNames\n .map(\n (name) =>\n `export type ${formatTypeName(name)} = { name: string; description: string; date: Date }`,\n )\n .join('\\n');\n\n const collections = collectionNames\n .map(\n (name) =>\n ` ${name}: pongoSchema.collection<${formatTypeName(name)}>('${name}'),`,\n )\n .join('\\n');\n\n return `import { pongoSchema } from '@event-driven-io/pongo';\n\n${types}\n\nexport default {\n schema: pongoSchema.client({\n database: pongoSchema.db({\n${collections}\n }),\n }),\n};`;\n};\n\nconst missingDefaultExport = `Error: Config should contain default export, e.g.\\n\\n${sampleConfig()}`;\nconst missingSchema = `Error: Config should contain schema property, e.g.\\n\\n${sampleConfig()}`;\nconst missingDbs = `Error: Config should have at least a single database defined, e.g.\\n\\n${sampleConfig()}`;\nconst missingDefaultDb = `Error: Config should have a default database defined (without name or or with default database name), e.g.\\n\\n${sampleConfig()}`;\nconst missingCollections = `Error: Database should have defined at least one collection, e.g.\\n\\n${sampleConfig()}`;\n\nexport const loadConfigFile = async (\n configPath: string,\n): Promise<PongoDbSchemaMetadata> => {\n const configUrl = new URL(configPath, `file://${process.cwd()}/`);\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const imported: Partial<{ default: PongoSchemaConfig }> = await import(\n configUrl.href\n );\n\n const parsed = parseDefaultDbSchema(imported);\n\n if (typeof parsed === 'string') {\n console.error(parsed);\n process.exit(1);\n }\n\n return parsed;\n } catch {\n console.error(`Error: Couldn't load file: ${configUrl.href}`);\n process.exit(1);\n }\n};\n\nexport const generateConfigFile = (\n configPath: string,\n collectionNames: string[],\n): void => {\n try {\n fs.writeFileSync(configPath, sampleConfig(collectionNames), 'utf8');\n console.log(`Configuration file stored at: ${configPath}`);\n } catch (error) {\n console.error(`Error: Couldn't store config file: ${configPath}!`);\n console.error(error);\n process.exit(1);\n }\n};\n\nexport const parseDefaultDbSchema = (\n imported: Partial<{ default: PongoSchemaConfig }>,\n): PongoDbSchemaMetadata | string => {\n if (!imported.default) {\n return missingDefaultExport;\n }\n\n if (!imported.default.schema) {\n return missingSchema;\n }\n\n if (!imported.default.schema.dbs) {\n return missingDbs;\n }\n\n const dbs = objectEntries(imported.default.schema.dbs).map((db) => db[1]);\n\n const defaultDb = dbs.find((db) => db.name === undefined);\n\n if (!defaultDb) {\n return missingDefaultDb;\n }\n\n if (!defaultDb.collections) {\n return missingCollections;\n }\n\n const collections = objectEntries(defaultDb.collections).map((col) => col[1]);\n\n if (collections.length === 0) {\n return missingCollections;\n }\n\n return toDbSchemaMetadata(defaultDb);\n};\n\ntype SampleConfigOptions =\n | {\n collection: string[];\n print?: boolean;\n }\n | {\n collection: string[];\n generate?: boolean;\n file?: string;\n };\n\nexport const configCommand = new Command('config').description(\n 'Manage Pongo configuration',\n);\n\nconfigCommand\n .command('sample')\n .description('Generate or print sample configuration')\n .option(\n '-col, --collection <name>',\n 'Specify the collection name',\n (value: string, previous: string[]) => {\n // Accumulate collection names into an array (explicitly typing `previous` as `string[]`)\n return previous.concat([value]);\n },\n [] as string[],\n )\n .option(\n '-f, --file <path>',\n 'Path to configuration file with collection list',\n )\n .option('-g, --generate', 'Generate sample config file')\n .option('-p, --print', 'Print sample config file')\n .action((options: SampleConfigOptions) => {\n const collectionNames =\n options.collection.length > 0 ? options.collection : ['users'];\n\n if (!('print' in options) && !('generate' in options)) {\n console.error(\n 'Error: Please provide either:\\n--print param to print sample config or\\n--generate to generate sample config file',\n );\n process.exit(1);\n }\n\n if ('print' in options) {\n console.log(`${sampleConfig(collectionNames)}`);\n } else if ('generate' in options) {\n if (!options.file) {\n console.error(\n 'Error: You need to provide a config file through a --file',\n );\n process.exit(1);\n }\n\n generateConfigFile(options.file, collectionNames);\n }\n });\n","import {\n combineMigrations,\n dumbo,\n parseConnectionString,\n runSQLMigrations,\n type DatabaseDriverType,\n} from '@event-driven-io/dumbo';\nimport { Command } from 'commander';\nimport {\n pongoDatabaseDriverRegistry,\n pongoSchema,\n type AnyPongoDatabaseDriverOptions,\n type PongoCollectionSchema,\n type PongoDatabaseFactoryOptions,\n type PongoDocument,\n} from '../core';\nimport { loadConfigFile } from './configFile';\n\ninterface MigrateRunOptions {\n collection: string[];\n connectionString: string;\n databaseType?: string;\n databaseName?: string | undefined;\n databaseDriver: string;\n config?: string;\n dryRun?: boolean;\n}\n\ninterface MigrateSqlOptions {\n print?: boolean;\n write?: string;\n databaseType: string;\n databaseName?: string | undefined;\n databaseDriver: string;\n config?: string;\n collection: string[];\n}\n\nexport const migrateCommand = new Command('migrate').description(\n 'Manage database migrations',\n);\n\nmigrateCommand\n .command('run')\n .description('Run database migrations')\n .option(\n '-dbt, --database-type <string>',\n 'Database type that should be used for connection (e.g., PostgreSQL or SQLite)',\n undefined,\n )\n .option(\n '-drv, --database-driver <string>',\n 'Database driver that should be used for connection (e.g., \"pg\" for PostgreSQL, \"sqlite3\" for SQLite)',\n )\n .option(\n '-dbn, --database-name <string>',\n 'Database name to connect to',\n undefined,\n )\n .option(\n '-cs, --connection-string <string>',\n 'Connection string for the database',\n )\n .option(\n '-col, --collection <name>',\n 'Specify the collection name',\n (value: string, previous: string[]) => {\n // Accumulate collection names into an array (explicitly typing `previous` as `string[]`)\n return previous.concat([value]);\n },\n [] as string[],\n )\n .option('-f, --config <path>', 'Path to configuration file with Pongo config')\n .option('-dr, --dryRun', 'Perform dry run without commiting changes', false)\n .action(async (options: MigrateRunOptions) => {\n const { collection, dryRun, databaseName, databaseDriver } = options;\n const connectionString =\n options.connectionString ?? process.env.DB_CONNECTION_STRING;\n\n const databaseType =\n options.databaseType ??\n parseConnectionString(connectionString).databaseType;\n\n let collectionNames: string[];\n\n if (!connectionString) {\n console.error(\n 'Error: Connection string is required. Provide it either as a \"--connection-string\" parameter or through the DB_CONNECTION_STRING environment variable.' +\n '\\nFor instance: --connection-string postgresql://postgres:postgres@localhost:5432/postgres',\n );\n process.exit(1);\n }\n\n if (options.config) {\n const config = await loadConfigFile(options.config);\n\n collectionNames = config.collections.map((c) => c.name);\n } else if (collection) {\n collectionNames = collection;\n } else {\n console.error(\n 'Error: You need to provide at least one collection name. Provide it either through \"--config\" file or as a \"--collection\" parameter.',\n );\n process.exit(1);\n }\n\n const driverType = `${databaseType}:${databaseDriver}` as const;\n\n const migrations = getMigrations({\n driverType,\n connectionString,\n databaseName,\n collectionNames,\n });\n\n const pool = dumbo({ connectionString, driverType });\n\n await runSQLMigrations(pool, migrations, {\n dryRun,\n });\n });\n\nmigrateCommand\n .command('sql')\n .description('Generate SQL for database migration')\n .option(\n '-dbt, --database-type <string>',\n 'Database type that should be used for connection (e.g., PostgreSQL or SQLite)',\n )\n .option(\n '-drv, --database-driver <string>',\n 'Database driver that should be used for connection (e.g., \"pg\" for PostgreSQL, \"sqlite3\" for SQLite)',\n )\n .option(\n '-dbn, --database-name <string>',\n 'Database name to connect to',\n undefined,\n )\n .option(\n '-col, --collection <name>',\n 'Specify the collection name',\n (value: string, previous: string[]) => {\n // Accumulate collection names into an array (explicitly typing `previous` as `string[]`)\n return previous.concat([value]);\n },\n [] as string[],\n )\n .option('-f, --config <path>', 'Path to configuration file with Pongo config')\n .option('--print', 'Print the SQL to the console (default)', true)\n //.option('--write <filename>', 'Write the SQL to a specified file')\n .action(async (options: MigrateSqlOptions) => {\n const { collection, databaseName, databaseType, databaseDriver } = options;\n\n let collectionNames: string[];\n\n if (options.config) {\n const config = await loadConfigFile(options.config);\n\n collectionNames = config.collections.map((c) => c.name);\n } else if (collection) {\n collectionNames = collection;\n } else {\n console.error(\n 'Error: You need to provide at least one collection name. Provide it either through \"--config\" file or as a \"--collection\" parameter.',\n );\n process.exit(1);\n }\n\n const driverType = `${databaseType}:${databaseDriver}` as const;\n\n const migrations = getMigrations({\n driverType,\n connectionString: undefined,\n databaseName,\n collectionNames,\n });\n\n console.log('Printing SQL:');\n console.log(combineMigrations(...migrations));\n });\n\nconst getMigrations = ({\n driverType,\n connectionString,\n databaseName,\n collectionNames,\n}: {\n driverType: DatabaseDriverType;\n connectionString: string | undefined;\n databaseName: string | undefined;\n collectionNames: string[];\n}) => {\n const driver = pongoDatabaseDriverRegistry.tryGet(driverType);\n\n if (driver === null) {\n console.error(\n `Error: No database driver found for driver type \"${driverType}\". Make sure the driver is registered and the connection string is correct.`,\n );\n process.exit(1);\n }\n\n const dbDefinition = pongoSchema.db.from(databaseName, collectionNames);\n\n const driverOptions: PongoDatabaseFactoryOptions<\n Record<string, PongoCollectionSchema<PongoDocument>>,\n AnyPongoDatabaseDriverOptions\n > = {\n schema: { definition: dbDefinition },\n };\n\n const customOptions = {\n connectionString: connectionString ?? driver.defaultConnectionString,\n databaseName,\n };\n\n const db = driver.databaseFactory({ ...driverOptions, ...customOptions });\n\n return db.schema.component.migrations;\n};\n","import {\n color,\n LogLevel,\n LogStyle,\n parseConnectionString,\n prettyJson,\n SQL,\n type MigrationStyle,\n} from '@event-driven-io/dumbo';\nimport { checkConnection } from '@event-driven-io/dumbo/pg';\nimport Table from 'cli-table3';\nimport { Command } from 'commander';\nimport repl from 'node:repl';\nimport {\n pongoClient,\n pongoDatabaseDriverRegistry,\n pongoSchema,\n type PongoClient,\n type PongoClientOptions,\n type PongoCollectionSchema,\n type PongoDb,\n} from '../core';\n\nlet pongo: PongoClient;\n\nconst calculateColumnWidths = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n results: any[],\n columnNames: string[],\n): number[] => {\n const columnWidths = columnNames.map((col) => {\n const maxWidth = Math.max(\n col.length, // Header size\n ...results.map((result) =>\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n result[col] ? String(result[col]).length : 0,\n ),\n );\n return maxWidth + 2; // Add padding\n });\n return columnWidths;\n};\n\nlet shouldDisplayResultsAsTable = false;\n\nconst printResultsAsTable = (print?: boolean) =>\n (shouldDisplayResultsAsTable = print === undefined || print === true);\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst printOutput = (obj: any): string =>\n Array.isArray(obj) && shouldDisplayResultsAsTable\n ? displayResultsAsTable(obj)\n : prettyJson(obj);\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst displayResultsAsTable = (results: any[]): string => {\n if (results.length === 0) {\n return color.yellow('No documents found.');\n }\n\n const columnNames = results\n\n .flatMap((result) =>\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n typeof result === 'object' ? Object.keys(result) : typeof result,\n )\n .filter((value, index, array) => array.indexOf(value) === index);\n\n const columnWidths = calculateColumnWidths(results, columnNames);\n\n const table = new Table({\n head: columnNames.map((col) => color.cyan(col)),\n colWidths: columnWidths,\n });\n\n results.forEach((result) => {\n table.push(\n columnNames.map((col) =>\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n result[col] !== undefined\n ? // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n Array.isArray(result[col])\n ? // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n displayResultsAsTable(result[col])\n : // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n prettyJson(result[col])\n : typeof result === 'object'\n ? ''\n : result != undefined && result != undefined\n ? prettyJson(result)\n : '',\n ),\n );\n });\n\n return table.toString();\n};\n\nconst setLogLevel = (logLevel: string) => {\n process.env.DUMBO_LOG_LEVEL = logLevel;\n};\n\nconst setLogStyle = (logLevel: string) => {\n process.env.DUMBO_LOG_STYLE = logLevel;\n};\n\nconst prettifyLogs = (logLevel?: string) => {\n if (logLevel !== undefined) setLogLevel(logLevel);\n setLogStyle(LogStyle.PRETTY);\n};\n\nconst startRepl = async (options: {\n logging: {\n printOptions: boolean;\n logLevel: LogLevel;\n logStyle: LogStyle;\n };\n schema: {\n database: string;\n collections: string[];\n autoMigration: MigrationStyle;\n };\n connectionString: string | undefined;\n databaseDriver: string;\n}) => {\n // TODO: This will change when we have proper tracing and logging config\n // For now, that's enough\n setLogLevel(process.env.DUMBO_LOG_LEVEL ?? options.logging.logLevel);\n setLogStyle(process.env.DUMBO_LOG_STYLE ?? options.logging.logStyle);\n\n console.log(color.green('Starting Pongo Shell (version: 0.17.0-beta.2)'));\n\n if (options.logging.printOptions) {\n console.log(color.green('With Options:'));\n console.log(prettyJson(options));\n }\n\n const connectionString =\n options.connectionString ??\n process.env.DB_CONNECTION_STRING ??\n 'postgresql://postgres:postgres@localhost:5432/postgres';\n\n if (!(options.connectionString ?? process.env.DB_CONNECTION_STRING)) {\n console.log(\n color.yellow(\n `No connection string provided, using: 'postgresql://postgres:postgres@localhost:5432/postgres'`,\n ),\n );\n }\n\n const { databaseType } = parseConnectionString(connectionString);\n const driverType = `${databaseType}:${options.databaseDriver}` as const;\n\n const driver = pongoDatabaseDriverRegistry.tryGet(driverType);\n\n if (driver === null) {\n console.error(\n `Error: No database driver found for driver type \"${driverType}\". Make sure the driver is installed and the connection string is correct.`,\n );\n process.exit(1);\n }\n\n const connectionCheck = await checkConnection(connectionString);\n\n if (!connectionCheck.successful) {\n if (connectionCheck.errorType === 'ConnectionRefused') {\n console.error(\n color.red(\n `Connection was refused. Check if the PostgreSQL server is running and accessible.`,\n ),\n );\n } else if (connectionCheck.errorType === 'Authentication') {\n console.error(\n color.red(\n `Authentication failed. Check the username and password in the connection string.`,\n ),\n );\n } else {\n console.error(color.red('Error connecting to PostgreSQL server'));\n }\n console.log(color.red('Exiting Pongo Shell...'));\n process.exit();\n }\n\n console.log(color.green(`Successfully connected`));\n console.log(color.green('Use db.<collection>.<method>() to query.'));\n\n const shell = repl.start({\n prompt: color.green('pongo> '),\n useGlobal: true,\n breakEvalOnSigint: true,\n writer: printOutput,\n });\n\n let db: PongoDb;\n\n if (options.schema.collections.length > 0) {\n const collectionsSchema: Record<string, PongoCollectionSchema> = {};\n\n for (const collectionName of options.schema.collections) {\n collectionsSchema[collectionName] =\n pongoSchema.collection(collectionName);\n }\n\n const schema = pongoSchema.client({\n database: pongoSchema.db(options.schema.database, collectionsSchema),\n });\n\n const driverOptions: PongoClientOptions = {\n driver,\n schema: {\n definition: schema,\n autoMigration: options.schema.autoMigration,\n },\n };\n\n // TODO: Find a better way to pass custom driver settings\n const customOptions = {\n connectionString,\n };\n\n const typedClient = pongoClient({\n ...driverOptions,\n ...customOptions,\n });\n\n db = typedClient.database!;\n\n for (const collectionName of options.schema.collections) {\n shell.context[collectionName] = typedClient.database![collectionName];\n }\n\n pongo = typedClient;\n } else {\n const driverOptions: PongoClientOptions = {\n driver,\n schema: {\n autoMigration: options.schema.autoMigration,\n },\n };\n\n // TODO: Find a better way to pass custom driver settings\n const customOptions = {\n connectionString,\n };\n\n pongo = pongoClient({\n ...driverOptions,\n ...customOptions,\n });\n\n db = pongo.db(options.schema.database);\n }\n\n shell.context.pongo = pongo;\n shell.context.db = db;\n\n // helpers\n shell.context.SQL = SQL;\n shell.context.setLogLevel = setLogLevel;\n shell.context.setLogStyle = setLogStyle;\n shell.context.prettifyLogs = prettifyLogs;\n shell.context.printResultsAsTable = printResultsAsTable;\n shell.context.LogStyle = LogStyle;\n shell.context.LogLevel = LogLevel;\n\n // Intercept REPL output to display results as a table if they are arrays\n shell.on('exit', async () => {\n await teardown();\n process.exit();\n });\n\n shell.on('SIGINT', async () => {\n await teardown();\n process.exit();\n });\n};\n\nconst teardown = async () => {\n console.log(color.yellow('Exiting Pongo Shell...'));\n await pongo.close();\n};\n\nprocess.on('uncaughtException', teardown);\nprocess.on('SIGINT', teardown);\n\ninterface ShellOptions {\n database: string;\n collection: string[];\n databaseDriver: string;\n connectionString?: string;\n disableAutoMigrations: boolean;\n logStyle?: string;\n logLevel?: string;\n prettyLog?: boolean;\n printOptions?: boolean;\n}\n\nconst shellCommand = new Command('shell')\n .description('Start an interactive Pongo shell')\n .option(\n '-drv, --database-driver <string>',\n 'Database driver that should be used for connection (e.g., \"pg\" for PostgreSQL, \"sqlite3\" for SQLite)',\n 'pg',\n )\n .option(\n '-cs, --connectionString <string>',\n 'Connection string for the database',\n )\n .option('-db, --database <string>', 'Database name to connect', 'postgres')\n .option(\n '-col, --collection <name>',\n 'Specify the collection name',\n (value: string, previous: string[]) => {\n // Accumulate collection names into an array (explicitly typing `previous` as `string[]`)\n return previous.concat([value]);\n },\n [] as string[],\n )\n .option(\n '-no-migrations, --disable-auto-migrations',\n 'Disable automatic migrations',\n )\n .option('-o, --print-options', 'Print shell options')\n .option(\n '-ll, --log-level <logLevel>',\n 'Log level: DISABLED, INFO, LOG, WARN, ERROR',\n 'DISABLED',\n )\n .option('-ls, --log-style', 'Log style: RAW, PRETTY', 'RAW')\n .option('-p, --pretty-log', 'Turn on logging with prettified output')\n .action(async (options: ShellOptions) => {\n const { collection, database } = options;\n const connectionString = options.connectionString;\n\n await startRepl({\n logging: {\n printOptions: options.printOptions === true,\n logStyle: options.prettyLog\n ? LogStyle.PRETTY\n : ((options.logStyle as LogStyle | undefined) ?? LogStyle.RAW),\n logLevel: options.logLevel\n ? (options.logLevel as LogLevel)\n : options.prettyLog\n ? LogLevel.INFO\n : LogLevel.DISABLED,\n },\n schema: {\n collections: collection,\n database,\n autoMigration: options.disableAutoMigrations\n ? 'None'\n : 'CreateOrUpdate',\n },\n connectionString,\n databaseDriver: options.databaseDriver,\n });\n });\n\nexport { shellCommand };\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/pongo/dist/cli.cjs","../src/cli.ts","../src/commandLine/configFile.ts","../src/commandLine/migrate.ts","../src/commandLine/shell.ts"],"names":[],"mappings":"AAAA;AACA;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;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s","sourcesContent":[null,"#!/usr/bin/env node\nimport { Command } from 'commander';\nimport { configCommand, migrateCommand, shellCommand } from './commandLine';\n\nconst program = new Command();\n\nprogram.name('pongo').description('CLI tool for Pongo');\n\nprogram.addCommand(configCommand);\nprogram.addCommand(migrateCommand);\nprogram.addCommand(shellCommand);\n\nprogram.parse(process.argv);\n\nexport default program;\n","import { Command } from 'commander';\nimport fs from 'node:fs';\nimport {\n objectEntries,\n toDbSchemaMetadata,\n type PongoDbSchemaMetadata,\n type PongoSchemaConfig,\n} from '../core';\n\nconst formatTypeName = (input: string): string => {\n if (input.length === 0) {\n return input;\n }\n\n let formatted = input.charAt(0).toUpperCase() + input.slice(1);\n\n if (formatted.endsWith('s')) {\n formatted = formatted.slice(0, -1);\n }\n\n return formatted;\n};\n\nconst sampleConfig = (collectionNames: string[] = ['users']) => {\n const types = collectionNames\n .map(\n (name) =>\n `export type ${formatTypeName(name)} = { name: string; description: string; date: Date }`,\n )\n .join('\\n');\n\n const collections = collectionNames\n .map(\n (name) =>\n ` ${name}: pongoSchema.collection<${formatTypeName(name)}>('${name}'),`,\n )\n .join('\\n');\n\n return `import { pongoSchema } from '@event-driven-io/pongo';\n\n${types}\n\nexport default {\n schema: pongoSchema.client({\n database: pongoSchema.db({\n${collections}\n }),\n }),\n};`;\n};\n\nconst missingDefaultExport = `Error: Config should contain default export, e.g.\\n\\n${sampleConfig()}`;\nconst missingSchema = `Error: Config should contain schema property, e.g.\\n\\n${sampleConfig()}`;\nconst missingDbs = `Error: Config should have at least a single database defined, e.g.\\n\\n${sampleConfig()}`;\nconst missingDefaultDb = `Error: Config should have a default database defined (without name or or with default database name), e.g.\\n\\n${sampleConfig()}`;\nconst missingCollections = `Error: Database should have defined at least one collection, e.g.\\n\\n${sampleConfig()}`;\n\nexport const loadConfigFile = async (\n configPath: string,\n): Promise<PongoDbSchemaMetadata> => {\n const configUrl = new URL(configPath, `file://${process.cwd()}/`);\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const imported: Partial<{ default: PongoSchemaConfig }> = await import(\n configUrl.href\n );\n\n const parsed = parseDefaultDbSchema(imported);\n\n if (typeof parsed === 'string') {\n console.error(parsed);\n process.exit(1);\n }\n\n return parsed;\n } catch {\n console.error(`Error: Couldn't load file: ${configUrl.href}`);\n process.exit(1);\n }\n};\n\nexport const generateConfigFile = (\n configPath: string,\n collectionNames: string[],\n): void => {\n try {\n fs.writeFileSync(configPath, sampleConfig(collectionNames), 'utf8');\n console.log(`Configuration file stored at: ${configPath}`);\n } catch (error) {\n console.error(`Error: Couldn't store config file: ${configPath}!`);\n console.error(error);\n process.exit(1);\n }\n};\n\nexport const parseDefaultDbSchema = (\n imported: Partial<{ default: PongoSchemaConfig }>,\n): PongoDbSchemaMetadata | string => {\n if (!imported.default) {\n return missingDefaultExport;\n }\n\n if (!imported.default.schema) {\n return missingSchema;\n }\n\n if (!imported.default.schema.dbs) {\n return missingDbs;\n }\n\n const dbs = objectEntries(imported.default.schema.dbs).map((db) => db[1]);\n\n const defaultDb = dbs.find((db) => db.name === undefined);\n\n if (!defaultDb) {\n return missingDefaultDb;\n }\n\n if (!defaultDb.collections) {\n return missingCollections;\n }\n\n const collections = objectEntries(defaultDb.collections).map((col) => col[1]);\n\n if (collections.length === 0) {\n return missingCollections;\n }\n\n return toDbSchemaMetadata(defaultDb);\n};\n\ntype SampleConfigOptions =\n | {\n collection: string[];\n print?: boolean;\n }\n | {\n collection: string[];\n generate?: boolean;\n file?: string;\n };\n\nexport const configCommand = new Command('config').description(\n 'Manage Pongo configuration',\n);\n\nconfigCommand\n .command('sample')\n .description('Generate or print sample configuration')\n .option(\n '--col, --collection <name>',\n 'Specify the collection name',\n (value: string, previous: string[]) => {\n // Accumulate collection names into an array (explicitly typing `previous` as `string[]`)\n return previous.concat([value]);\n },\n [] as string[],\n )\n .option(\n '-f, --file <path>',\n 'Path to configuration file with collection list',\n )\n .option('-g, --generate', 'Generate sample config file')\n .option('-p, --print', 'Print sample config file')\n .action((options: SampleConfigOptions) => {\n const collectionNames =\n options.collection.length > 0 ? options.collection : ['users'];\n\n if (!('print' in options) && !('generate' in options)) {\n console.error(\n 'Error: Please provide either:\\n--print param to print sample config or\\n--generate to generate sample config file',\n );\n process.exit(1);\n }\n\n if ('print' in options) {\n console.log(`${sampleConfig(collectionNames)}`);\n } else if ('generate' in options) {\n if (!options.file) {\n console.error(\n 'Error: You need to provide a config file through a --file',\n );\n process.exit(1);\n }\n\n generateConfigFile(options.file, collectionNames);\n }\n });\n","import {\n combineMigrations,\n dumbo,\n JSONSerializer,\n parseConnectionString,\n runSQLMigrations,\n type DatabaseDriverType,\n} from '@event-driven-io/dumbo';\nimport { Command } from 'commander';\nimport {\n pongoDriverRegistry,\n pongoSchema,\n type AnyPongoDriverOptions,\n type PongoCollectionSchema,\n type PongoDatabaseFactoryOptions,\n type PongoDocument,\n} from '../core';\nimport { loadConfigFile } from './configFile';\n\ninterface MigrateRunOptions {\n collection: string[];\n connectionString: string;\n databaseType?: string;\n databaseName?: string | undefined;\n databaseDriver: string;\n config?: string;\n dryRun?: boolean;\n timeoutMs?: number;\n}\n\ninterface MigrateSqlOptions {\n print?: boolean;\n write?: string;\n databaseType: string;\n databaseName?: string | undefined;\n databaseDriver: string;\n config?: string;\n collection: string[];\n}\n\nexport const migrateCommand = new Command('migrate').description(\n 'Manage database migrations',\n);\n\nmigrateCommand\n .command('run')\n .description('Run database migrations')\n .option(\n '--dbt, --database-type <string>',\n 'Database type that should be used for connection (e.g., PostgreSQL or SQLite)',\n undefined,\n )\n .option(\n '--drv, --database-driver <string>',\n 'Database driver that should be used for connection (e.g., \"pg\" for PostgreSQL, \"sqlite3\" for SQLite)',\n )\n .option(\n '--dbn, --database-name <string>',\n 'Database name to connect to',\n undefined,\n )\n .option(\n '--cs, --connection-string <string>',\n 'Connection string for the database',\n )\n .option(\n '--col, --collection <name>',\n 'Specify the collection name',\n (value: string, previous: string[]) => {\n // Accumulate collection names into an array (explicitly typing `previous` as `string[]`)\n return previous.concat([value]);\n },\n [] as string[],\n )\n .option('-f, --config <path>', 'Path to configuration file with Pongo config')\n .option('--dr, --dryRun', 'Perform dry run without commiting changes', false)\n .option(\n '--t, --timeout <ms>',\n 'Set the migration timeout in milliseconds',\n parseInt,\n )\n .action(async (options: MigrateRunOptions) => {\n const { collection, dryRun, databaseName, databaseDriver, timeoutMs } =\n options;\n const connectionString =\n options.connectionString ?? process.env.DB_CONNECTION_STRING;\n\n const databaseType =\n options.databaseType ??\n parseConnectionString(connectionString).databaseType;\n\n let collectionNames: string[];\n\n if (!connectionString) {\n console.error(\n 'Error: Connection string is required. Provide it either as a \"--connection-string\" parameter or through the DB_CONNECTION_STRING environment variable.' +\n '\\nFor instance: --connection-string postgresql://postgres:postgres@localhost:5432/postgres',\n );\n process.exit(1);\n }\n\n if (options.config) {\n const config = await loadConfigFile(options.config);\n\n collectionNames = config.collections.map((c) => c.name);\n } else if (collection) {\n collectionNames = collection;\n } else {\n console.error(\n 'Error: You need to provide at least one collection name. Provide it either through \"--config\" file or as a \"--collection\" parameter.',\n );\n process.exit(1);\n }\n\n const driverType = `${databaseType}:${databaseDriver}` as const;\n\n const migrations = getMigrations({\n driverType,\n connectionString,\n databaseName,\n collectionNames,\n });\n\n const pool = dumbo({ connectionString, driverType });\n\n await runSQLMigrations(pool, migrations, {\n dryRun,\n migrationTimeoutMs: timeoutMs,\n });\n });\n\nmigrateCommand\n .command('sql')\n .description('Generate SQL for database migration')\n .option(\n '--dbt, --database-type <string>',\n 'Database type that should be used for connection (e.g., PostgreSQL or SQLite)',\n )\n .option(\n '--drv, --database-driver <string>',\n 'Database driver that should be used for connection (e.g., \"pg\" for PostgreSQL, \"sqlite3\" for SQLite)',\n )\n .option(\n '--dbn, --database-name <string>',\n 'Database name to connect to',\n undefined,\n )\n .option(\n '--col, --collection <name>',\n 'Specify the collection name',\n (value: string, previous: string[]) => {\n // Accumulate collection names into an array (explicitly typing `previous` as `string[]`)\n return previous.concat([value]);\n },\n [] as string[],\n )\n .option('-f, --config <path>', 'Path to configuration file with Pongo config')\n .option('--print', 'Print the SQL to the console (default)', true)\n //.option('--write <filename>', 'Write the SQL to a specified file')\n .action(async (options: MigrateSqlOptions) => {\n const { collection, databaseName, databaseType, databaseDriver } = options;\n\n let collectionNames: string[];\n\n if (options.config) {\n const config = await loadConfigFile(options.config);\n\n collectionNames = config.collections.map((c) => c.name);\n } else if (collection) {\n collectionNames = collection;\n } else {\n console.error(\n 'Error: You need to provide at least one collection name. Provide it either through \"--config\" file or as a \"--collection\" parameter.',\n );\n process.exit(1);\n }\n\n const driverType = `${databaseType}:${databaseDriver}` as const;\n\n const migrations = getMigrations({\n driverType,\n connectionString: undefined,\n databaseName,\n collectionNames,\n });\n\n console.log('Printing SQL:');\n console.log(combineMigrations(...migrations));\n });\n\nconst getMigrations = ({\n driverType,\n connectionString,\n databaseName,\n collectionNames,\n}: {\n driverType: DatabaseDriverType;\n connectionString: string | undefined;\n databaseName: string | undefined;\n collectionNames: string[];\n}) => {\n const driver = pongoDriverRegistry.tryGet(driverType);\n\n if (driver === null) {\n console.error(\n `Error: No database driver found for driver type \"${driverType}\". Make sure the driver is registered and the connection string is correct.`,\n );\n process.exit(1);\n }\n\n const dbDefinition = pongoSchema.db.from(databaseName, collectionNames);\n\n const driverOptions: PongoDatabaseFactoryOptions<\n Record<string, PongoCollectionSchema<PongoDocument>>,\n AnyPongoDriverOptions\n > = {\n schema: { definition: dbDefinition },\n serializer: JSONSerializer,\n };\n\n const customOptions = {\n connectionString,\n databaseName,\n };\n\n const db = driver.databaseFactory({ ...driverOptions, ...customOptions });\n\n return db.schema.component.migrations;\n};\n","import {\n color,\n LogLevel,\n LogStyle,\n parseConnectionString,\n prettyJson,\n SQL,\n type MigrationStyle,\n} from '@event-driven-io/dumbo';\nimport { checkConnection } from '@event-driven-io/dumbo/pg';\nimport Table from 'cli-table3';\nimport { Command } from 'commander';\nimport repl from 'node:repl';\nimport {\n pongoClient,\n pongoDriverRegistry,\n pongoSchema,\n type PongoClient,\n type PongoClientOptions,\n type PongoCollectionSchema,\n type PongoDb,\n} from '../core';\n\nlet pongo: PongoClient;\n\nconst calculateColumnWidths = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n results: any[],\n columnNames: string[],\n): number[] => {\n const columnWidths = columnNames.map((col) => {\n const maxWidth = Math.max(\n col.length, // Header size\n ...results.map((result) =>\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n result[col] ? String(result[col]).length : 0,\n ),\n );\n return maxWidth + 2; // Add padding\n });\n return columnWidths;\n};\n\nlet shouldDisplayResultsAsTable = false;\n\nconst printResultsAsTable = (print?: boolean) =>\n (shouldDisplayResultsAsTable = print === undefined || print === true);\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst printOutput = (obj: any): string =>\n Array.isArray(obj) && shouldDisplayResultsAsTable\n ? displayResultsAsTable(obj)\n : prettyJson(obj);\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst displayResultsAsTable = (results: any[]): string => {\n if (results.length === 0) {\n return color.yellow('No documents found.');\n }\n\n const columnNames = results\n\n .flatMap((result) =>\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n typeof result === 'object' ? Object.keys(result) : typeof result,\n )\n .filter((value, index, array) => array.indexOf(value) === index);\n\n const columnWidths = calculateColumnWidths(results, columnNames);\n\n const table = new Table({\n head: columnNames.map((col) => color.cyan(col)),\n colWidths: columnWidths,\n });\n\n results.forEach((result) => {\n table.push(\n columnNames.map((col) =>\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n result[col] !== undefined\n ? // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n Array.isArray(result[col])\n ? // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n displayResultsAsTable(result[col])\n : // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n prettyJson(result[col])\n : typeof result === 'object'\n ? ''\n : result != undefined && result != undefined\n ? prettyJson(result)\n : '',\n ),\n );\n });\n\n return table.toString();\n};\n\nconst setLogLevel = (logLevel: string) => {\n process.env.DUMBO_LOG_LEVEL = logLevel;\n};\n\nconst setLogStyle = (logLevel: string) => {\n process.env.DUMBO_LOG_STYLE = logLevel;\n};\n\nconst prettifyLogs = (logLevel?: string) => {\n if (logLevel !== undefined) setLogLevel(logLevel);\n setLogStyle(LogStyle.PRETTY);\n};\n\nconst startRepl = async (options: {\n logging: {\n printOptions: boolean;\n logLevel: LogLevel;\n logStyle: LogStyle;\n };\n schema: {\n database: string;\n collections: string[];\n autoMigration: MigrationStyle;\n };\n connectionString: string | undefined;\n databaseDriver: string;\n}) => {\n // TODO: This will change when we have proper tracing and logging config\n // For now, that's enough\n setLogLevel(process.env.DUMBO_LOG_LEVEL ?? options.logging.logLevel);\n setLogStyle(process.env.DUMBO_LOG_STYLE ?? options.logging.logStyle);\n\n console.log(color.green('Starting Pongo Shell (version: 0.17.0-beta.21)'));\n\n if (options.logging.printOptions) {\n console.log(color.green('With Options:'));\n console.log(prettyJson(options));\n }\n\n const connectionString =\n options.connectionString ??\n process.env.DB_CONNECTION_STRING ??\n 'postgresql://postgres:postgres@localhost:5432/postgres';\n\n if (!(options.connectionString ?? process.env.DB_CONNECTION_STRING)) {\n console.log(\n color.yellow(\n `No connection string provided, using: 'postgresql://postgres:postgres@localhost:5432/postgres'`,\n ),\n );\n }\n\n const { databaseType } = parseConnectionString(connectionString);\n const driverType = `${databaseType}:${options.databaseDriver}` as const;\n\n const driver = pongoDriverRegistry.tryGet(driverType);\n\n if (driver === null) {\n console.error(\n `Error: No database driver found for driver type \"${driverType}\". Make sure the driver is installed and the connection string is correct.`,\n );\n process.exit(1);\n }\n\n const connectionCheck = await checkConnection(connectionString);\n\n if (!connectionCheck.successful) {\n if (connectionCheck.errorType === 'ConnectionRefused') {\n console.error(\n color.red(\n `Connection was refused. Check if the PostgreSQL server is running and accessible.`,\n ),\n );\n } else if (connectionCheck.errorType === 'Authentication') {\n console.error(\n color.red(\n `Authentication failed. Check the username and password in the connection string.`,\n ),\n );\n } else {\n console.error(color.red('Error connecting to PostgreSQL server'));\n }\n console.log(color.red('Exiting Pongo Shell...'));\n process.exit();\n }\n\n console.log(color.green(`Successfully connected`));\n console.log(color.green('Use db.<collection>.<method>() to query.'));\n\n const shell = repl.start({\n prompt: color.green('pongo> '),\n useGlobal: true,\n breakEvalOnSigint: true,\n writer: printOutput,\n });\n\n let db: PongoDb;\n\n if (options.schema.collections.length > 0) {\n const collectionsSchema: Record<string, PongoCollectionSchema> = {};\n\n for (const collectionName of options.schema.collections) {\n collectionsSchema[collectionName] =\n pongoSchema.collection(collectionName);\n }\n\n const schema = pongoSchema.client({\n database: pongoSchema.db(options.schema.database, collectionsSchema),\n });\n\n const driverOptions: PongoClientOptions = {\n driver,\n schema: {\n definition: schema,\n autoMigration: options.schema.autoMigration,\n },\n };\n\n // TODO: Find a better way to pass custom driver settings\n const customOptions = {\n connectionString,\n };\n\n const typedClient = pongoClient({\n ...driverOptions,\n ...customOptions,\n });\n\n db = typedClient.database!;\n\n for (const collectionName of options.schema.collections) {\n shell.context[collectionName] = typedClient.database![collectionName];\n }\n\n pongo = typedClient;\n } else {\n const driverOptions: PongoClientOptions = {\n driver,\n schema: {\n autoMigration: options.schema.autoMigration,\n },\n };\n\n // TODO: Find a better way to pass custom driver settings\n const customOptions = {\n connectionString,\n };\n\n pongo = pongoClient({\n ...driverOptions,\n ...customOptions,\n });\n\n db = pongo.db(options.schema.database);\n }\n\n shell.context.pongo = pongo;\n shell.context.db = db;\n\n // helpers\n shell.context.SQL = SQL;\n shell.context.setLogLevel = setLogLevel;\n shell.context.setLogStyle = setLogStyle;\n shell.context.prettifyLogs = prettifyLogs;\n shell.context.printResultsAsTable = printResultsAsTable;\n shell.context.LogStyle = LogStyle;\n shell.context.LogLevel = LogLevel;\n\n // Intercept REPL output to display results as a table if they are arrays\n shell.on('exit', async () => {\n await teardown();\n process.exit();\n });\n\n shell.on('SIGINT', async () => {\n await teardown();\n process.exit();\n });\n};\n\nconst teardown = async () => {\n console.log(color.yellow('Exiting Pongo Shell...'));\n await pongo.close();\n};\n\nprocess.on('uncaughtException', teardown);\nprocess.on('SIGINT', teardown);\n\ninterface ShellOptions {\n database: string;\n collection: string[];\n databaseDriver: string;\n connectionString?: string;\n disableAutoMigrations: boolean;\n logStyle?: string;\n logLevel?: string;\n prettyLog?: boolean;\n printOptions?: boolean;\n}\n\nconst shellCommand = new Command('shell')\n .description('Start an interactive Pongo shell')\n .option(\n '--drv, --database-driver <string>',\n 'Database driver that should be used for connection (e.g., \"pg\" for PostgreSQL, \"sqlite3\" for SQLite)',\n 'pg',\n )\n .option(\n '--cs, --connectionString <string>',\n 'Connection string for the database',\n )\n .option('--db, --database <string>', 'Database name to connect', 'postgres')\n .option(\n '--col, --collection <name>',\n 'Specify the collection name',\n (value: string, previous: string[]) => {\n // Accumulate collection names into an array (explicitly typing `previous` as `string[]`)\n return previous.concat([value]);\n },\n [] as string[],\n )\n .option(\n '--no-migrations, --disable-auto-migrations',\n 'Disable automatic migrations',\n )\n .option('-o, --print-options', 'Print shell options')\n .option(\n '--ll, --log-level <logLevel>',\n 'Log level: DISABLED, INFO, LOG, WARN, ERROR',\n 'DISABLED',\n )\n .option('--ls, --log-style', 'Log style: RAW, PRETTY', 'RAW')\n .option('-p, --pretty-log', 'Turn on logging with prettified output')\n .action(async (options: ShellOptions) => {\n const { collection, database } = options;\n const connectionString = options.connectionString;\n\n await startRepl({\n logging: {\n printOptions: options.printOptions === true,\n logStyle: options.prettyLog\n ? LogStyle.PRETTY\n : ((options.logStyle as LogStyle | undefined) ?? LogStyle.RAW),\n logLevel: options.logLevel\n ? (options.logLevel as LogLevel)\n : options.prettyLog\n ? LogLevel.INFO\n : LogLevel.DISABLED,\n },\n schema: {\n collections: collection,\n database,\n autoMigration: options.disableAutoMigrations\n ? 'None'\n : 'CreateOrUpdate',\n },\n connectionString,\n databaseDriver: options.databaseDriver,\n });\n });\n\nexport { shellCommand };\n"]}
|
package/dist/cli.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import "./chunk-WH26IXHN.js";
|
|
3
2
|
import {
|
|
4
3
|
objectEntries,
|
|
5
4
|
pongoClient,
|
|
6
|
-
|
|
5
|
+
pongoDriverRegistry,
|
|
7
6
|
pongoSchema,
|
|
8
7
|
toDbSchemaMetadata
|
|
9
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-H637RRXS.js";
|
|
10
9
|
|
|
11
10
|
// src/cli.ts
|
|
12
11
|
import { Command as Command4 } from "commander";
|
|
@@ -111,7 +110,7 @@ var configCommand = new Command("config").description(
|
|
|
111
110
|
"Manage Pongo configuration"
|
|
112
111
|
);
|
|
113
112
|
configCommand.command("sample").description("Generate or print sample configuration").option(
|
|
114
|
-
"
|
|
113
|
+
"--col, --collection <name>",
|
|
115
114
|
"Specify the collection name",
|
|
116
115
|
(value, previous) => {
|
|
117
116
|
return previous.concat([value]);
|
|
@@ -145,6 +144,7 @@ configCommand.command("sample").description("Generate or print sample configurat
|
|
|
145
144
|
import {
|
|
146
145
|
combineMigrations,
|
|
147
146
|
dumbo,
|
|
147
|
+
JSONSerializer,
|
|
148
148
|
parseConnectionString,
|
|
149
149
|
runSQLMigrations
|
|
150
150
|
} from "@event-driven-io/dumbo";
|
|
@@ -153,28 +153,32 @@ var migrateCommand = new Command2("migrate").description(
|
|
|
153
153
|
"Manage database migrations"
|
|
154
154
|
);
|
|
155
155
|
migrateCommand.command("run").description("Run database migrations").option(
|
|
156
|
-
"
|
|
156
|
+
"--dbt, --database-type <string>",
|
|
157
157
|
"Database type that should be used for connection (e.g., PostgreSQL or SQLite)",
|
|
158
158
|
void 0
|
|
159
159
|
).option(
|
|
160
|
-
"
|
|
160
|
+
"--drv, --database-driver <string>",
|
|
161
161
|
'Database driver that should be used for connection (e.g., "pg" for PostgreSQL, "sqlite3" for SQLite)'
|
|
162
162
|
).option(
|
|
163
|
-
"
|
|
163
|
+
"--dbn, --database-name <string>",
|
|
164
164
|
"Database name to connect to",
|
|
165
165
|
void 0
|
|
166
166
|
).option(
|
|
167
|
-
"
|
|
167
|
+
"--cs, --connection-string <string>",
|
|
168
168
|
"Connection string for the database"
|
|
169
169
|
).option(
|
|
170
|
-
"
|
|
170
|
+
"--col, --collection <name>",
|
|
171
171
|
"Specify the collection name",
|
|
172
172
|
(value, previous) => {
|
|
173
173
|
return previous.concat([value]);
|
|
174
174
|
},
|
|
175
175
|
[]
|
|
176
|
-
).option("-f, --config <path>", "Path to configuration file with Pongo config").option("
|
|
177
|
-
|
|
176
|
+
).option("-f, --config <path>", "Path to configuration file with Pongo config").option("--dr, --dryRun", "Perform dry run without commiting changes", false).option(
|
|
177
|
+
"--t, --timeout <ms>",
|
|
178
|
+
"Set the migration timeout in milliseconds",
|
|
179
|
+
parseInt
|
|
180
|
+
).action(async (options) => {
|
|
181
|
+
const { collection, dryRun, databaseName, databaseDriver, timeoutMs } = options;
|
|
178
182
|
const connectionString = options.connectionString ?? process.env.DB_CONNECTION_STRING;
|
|
179
183
|
const databaseType = options.databaseType ?? parseConnectionString(connectionString).databaseType;
|
|
180
184
|
let collectionNames;
|
|
@@ -204,21 +208,22 @@ migrateCommand.command("run").description("Run database migrations").option(
|
|
|
204
208
|
});
|
|
205
209
|
const pool = dumbo({ connectionString, driverType });
|
|
206
210
|
await runSQLMigrations(pool, migrations, {
|
|
207
|
-
dryRun
|
|
211
|
+
dryRun,
|
|
212
|
+
migrationTimeoutMs: timeoutMs
|
|
208
213
|
});
|
|
209
214
|
});
|
|
210
215
|
migrateCommand.command("sql").description("Generate SQL for database migration").option(
|
|
211
|
-
"
|
|
216
|
+
"--dbt, --database-type <string>",
|
|
212
217
|
"Database type that should be used for connection (e.g., PostgreSQL or SQLite)"
|
|
213
218
|
).option(
|
|
214
|
-
"
|
|
219
|
+
"--drv, --database-driver <string>",
|
|
215
220
|
'Database driver that should be used for connection (e.g., "pg" for PostgreSQL, "sqlite3" for SQLite)'
|
|
216
221
|
).option(
|
|
217
|
-
"
|
|
222
|
+
"--dbn, --database-name <string>",
|
|
218
223
|
"Database name to connect to",
|
|
219
224
|
void 0
|
|
220
225
|
).option(
|
|
221
|
-
"
|
|
226
|
+
"--col, --collection <name>",
|
|
222
227
|
"Specify the collection name",
|
|
223
228
|
(value, previous) => {
|
|
224
229
|
return previous.concat([value]);
|
|
@@ -254,7 +259,7 @@ var getMigrations = ({
|
|
|
254
259
|
databaseName,
|
|
255
260
|
collectionNames
|
|
256
261
|
}) => {
|
|
257
|
-
const driver =
|
|
262
|
+
const driver = pongoDriverRegistry.tryGet(driverType);
|
|
258
263
|
if (driver === null) {
|
|
259
264
|
console.error(
|
|
260
265
|
`Error: No database driver found for driver type "${driverType}". Make sure the driver is registered and the connection string is correct.`
|
|
@@ -263,10 +268,11 @@ var getMigrations = ({
|
|
|
263
268
|
}
|
|
264
269
|
const dbDefinition = pongoSchema.db.from(databaseName, collectionNames);
|
|
265
270
|
const driverOptions = {
|
|
266
|
-
schema: { definition: dbDefinition }
|
|
271
|
+
schema: { definition: dbDefinition },
|
|
272
|
+
serializer: JSONSerializer
|
|
267
273
|
};
|
|
268
274
|
const customOptions = {
|
|
269
|
-
connectionString
|
|
275
|
+
connectionString,
|
|
270
276
|
databaseName
|
|
271
277
|
};
|
|
272
278
|
const db = driver.databaseFactory({ ...driverOptions, ...customOptions });
|
|
@@ -354,7 +360,7 @@ var prettifyLogs = (logLevel) => {
|
|
|
354
360
|
var startRepl = async (options) => {
|
|
355
361
|
setLogLevel(process.env.DUMBO_LOG_LEVEL ?? options.logging.logLevel);
|
|
356
362
|
setLogStyle(process.env.DUMBO_LOG_STYLE ?? options.logging.logStyle);
|
|
357
|
-
console.log(color.green("Starting Pongo Shell (version: 0.17.0-beta.
|
|
363
|
+
console.log(color.green("Starting Pongo Shell (version: 0.17.0-beta.21)"));
|
|
358
364
|
if (options.logging.printOptions) {
|
|
359
365
|
console.log(color.green("With Options:"));
|
|
360
366
|
console.log(prettyJson(options));
|
|
@@ -369,7 +375,7 @@ var startRepl = async (options) => {
|
|
|
369
375
|
}
|
|
370
376
|
const { databaseType } = parseConnectionString2(connectionString);
|
|
371
377
|
const driverType = `${databaseType}:${options.databaseDriver}`;
|
|
372
|
-
const driver =
|
|
378
|
+
const driver = pongoDriverRegistry.tryGet(driverType);
|
|
373
379
|
if (driver === null) {
|
|
374
380
|
console.error(
|
|
375
381
|
`Error: No database driver found for driver type "${driverType}". Make sure the driver is installed and the connection string is correct.`
|
|
@@ -473,27 +479,27 @@ var teardown = async () => {
|
|
|
473
479
|
process.on("uncaughtException", teardown);
|
|
474
480
|
process.on("SIGINT", teardown);
|
|
475
481
|
var shellCommand = new Command3("shell").description("Start an interactive Pongo shell").option(
|
|
476
|
-
"
|
|
482
|
+
"--drv, --database-driver <string>",
|
|
477
483
|
'Database driver that should be used for connection (e.g., "pg" for PostgreSQL, "sqlite3" for SQLite)',
|
|
478
484
|
"pg"
|
|
479
485
|
).option(
|
|
480
|
-
"
|
|
486
|
+
"--cs, --connectionString <string>",
|
|
481
487
|
"Connection string for the database"
|
|
482
|
-
).option("
|
|
483
|
-
"
|
|
488
|
+
).option("--db, --database <string>", "Database name to connect", "postgres").option(
|
|
489
|
+
"--col, --collection <name>",
|
|
484
490
|
"Specify the collection name",
|
|
485
491
|
(value, previous) => {
|
|
486
492
|
return previous.concat([value]);
|
|
487
493
|
},
|
|
488
494
|
[]
|
|
489
495
|
).option(
|
|
490
|
-
"
|
|
496
|
+
"--no-migrations, --disable-auto-migrations",
|
|
491
497
|
"Disable automatic migrations"
|
|
492
498
|
).option("-o, --print-options", "Print shell options").option(
|
|
493
|
-
"
|
|
499
|
+
"--ll, --log-level <logLevel>",
|
|
494
500
|
"Log level: DISABLED, INFO, LOG, WARN, ERROR",
|
|
495
501
|
"DISABLED"
|
|
496
|
-
).option("
|
|
502
|
+
).option("--ls, --log-style", "Log style: RAW, PRETTY", "RAW").option("-p, --pretty-log", "Turn on logging with prettified output").action(async (options) => {
|
|
497
503
|
const { collection, database } = options;
|
|
498
504
|
const connectionString = options.connectionString;
|
|
499
505
|
await startRepl({
|