mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
first commit (nonfunctional)
This commit is contained in:
parent
8adc87f1d9
commit
9298bf6608
3 changed files with 43 additions and 17 deletions
|
|
@ -48,6 +48,7 @@
|
|||
"@std/streams": "jsr:@std/streams@^0.223.0",
|
||||
"comlink": "npm:comlink@^4.4.1",
|
||||
"comlink-async-generator": "npm:comlink-async-generator@^0.0.1",
|
||||
"commander": "npm:commander@12.1.0",
|
||||
"deno-safe-fetch/load": "https://gitlab.com/soapbox-pub/deno-safe-fetch/-/raw/v1.0.0/load.ts",
|
||||
"deno.json": "./deno.json",
|
||||
"entities": "npm:entities@^4.5.0",
|
||||
|
|
|
|||
6
deno.lock
generated
6
deno.lock
generated
|
|
@ -60,6 +60,7 @@
|
|||
"npm:comlink-async-generator": "npm:comlink-async-generator@0.0.1",
|
||||
"npm:comlink-async-generator@^0.0.1": "npm:comlink-async-generator@0.0.1",
|
||||
"npm:comlink@^4.4.1": "npm:comlink@4.4.1",
|
||||
"npm:commander@12.1.0": "npm:commander@12.1.0",
|
||||
"npm:entities@^4.5.0": "npm:entities@4.5.0",
|
||||
"npm:fast-stable-stringify@^1.0.0": "npm:fast-stable-stringify@1.0.0",
|
||||
"npm:formdata-helper@^0.3.0": "npm:formdata-helper@0.3.0",
|
||||
|
|
@ -543,6 +544,10 @@
|
|||
"integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
|
||||
"dependencies": {}
|
||||
},
|
||||
"commander@12.1.0": {
|
||||
"integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==",
|
||||
"dependencies": {}
|
||||
},
|
||||
"cross-spawn@7.0.3": {
|
||||
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
|
||||
"dependencies": {
|
||||
|
|
@ -1904,6 +1909,7 @@
|
|||
"npm:@scure/base@^1.1.6",
|
||||
"npm:comlink-async-generator@^0.0.1",
|
||||
"npm:comlink@^4.4.1",
|
||||
"npm:commander@12.1.0",
|
||||
"npm:entities@^4.5.0",
|
||||
"npm:fast-stable-stringify@^1.0.0",
|
||||
"npm:formdata-helper@^0.3.0",
|
||||
|
|
|
|||
|
|
@ -1,12 +1,26 @@
|
|||
import { Storages } from '@/storages.ts';
|
||||
import { Command } from 'commander';
|
||||
|
||||
const store = await Storages.db();
|
||||
|
||||
console.warn('Exporting events...');
|
||||
interface ExportFilter {
|
||||
authors: string[];
|
||||
}
|
||||
|
||||
let count = 0;
|
||||
if (import.meta.main) {
|
||||
const exporter = new Command()
|
||||
.name('db:export')
|
||||
.description('Export the specified set of events from the Ditto database.')
|
||||
.version('0.1.0')
|
||||
.showHelpAfterError();
|
||||
|
||||
for await (const msg of store.req([{}])) {
|
||||
exporter
|
||||
// .option('')
|
||||
.action(async (args: ExportFilter) => {
|
||||
console.warn('Exporting events...');
|
||||
let count = 0;
|
||||
|
||||
for await (const msg of store.req([{}])) {
|
||||
if (msg[0] === 'EOSE') {
|
||||
break;
|
||||
}
|
||||
|
|
@ -18,7 +32,12 @@ for await (const msg of store.req([{}])) {
|
|||
console.error('Database closed unexpectedly');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
console.warn(`Exported ${count} events`);
|
||||
});
|
||||
|
||||
exporter.parse(Deno.args, { from: 'user' });
|
||||
}
|
||||
|
||||
console.warn(`Exported ${count} events`);
|
||||
Deno.exit();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue