diff --git a/src/apps/cli/.gitignore b/src/apps/cli/.gitignore index 630bad4..9ab466a 100644 --- a/src/apps/cli/.gitignore +++ b/src/apps/cli/.gitignore @@ -1,4 +1,5 @@ .livesync test/* !test/*.sh -node_modules \ No newline at end of file +node_modules +.*.json \ No newline at end of file diff --git a/src/apps/cli/main.ts b/src/apps/cli/main.ts index 6316181..442d9c9 100644 --- a/src/apps/cli/main.ts +++ b/src/apps/cli/main.ts @@ -45,23 +45,6 @@ import { stripAllPrefixes } from "@lib/string_and_binary/path"; const SETTINGS_FILE = ".livesync/settings.json"; defaultLoggerEnv.minLogLevel = LOG_LEVEL_DEBUG; -// DI the log again. -// const recentLogEntries = reactiveSource([]); -// const globalLogFunction = (message: any, level?: number, key?: string) => { -// const messageX = -// message instanceof Error -// ? new LiveSyncError("[Error Logged]: " + message.message, { cause: message }) -// : message; -// const entry = { message: messageX, level, key } as LogEntry; -// recentLogEntries.value = [...recentLogEntries.value, entry]; -// }; - -// setGlobalLogFunction((msg, level) => { -// console.error(`[${level}] ${typeof msg === "string" ? msg : JSON.stringify(msg)}`); -// if (msg instanceof Error) { -// console.error(msg); -// } -// }); function printHelp(): void { console.log(` Self-hosted LiveSync CLI @@ -78,8 +61,8 @@ Commands: p2p-sync Sync with the specified peer-id or peer-name p2p-host Start P2P host mode and wait until interrupted - push Push local file into local database path - pull Pull file from local database into local file + push Push local file into local database path + pull Pull file from local database into local file pull-rev Pull file at specific revision into local file setup Apply setup URI to settings file put Read UTF-8 content from stdin and write to local database path @@ -90,12 +73,12 @@ Commands: rm Mark a file as deleted in local database resolve Resolve conflicts by keeping and deleting others Examples: - livesync-cli ./my-database sync + livesync-cli ./my-database sync livesync-cli ./my-database p2p-peers 5 livesync-cli ./my-database p2p-sync my-peer-name 15 livesync-cli ./my-database p2p-host - livesync-cli ./my-database --settings ./custom-settings.json push ./note.md folder/note.md - livesync-cli ./my-database pull folder/note.md ./exports/note.md + livesync-cli ./my-database --settings ./custom-settings.json push ./note.md folder/note.md + livesync-cli ./my-database pull folder/note.md ./exports/note.md livesync-cli ./my-database pull-rev folder/note.md ./exports/note.old.md 3-abcdef livesync-cli ./my-database setup "obsidian://setuplivesync?settings=..." echo "Hello" | livesync-cli ./my-database put notes/hello.md @@ -106,7 +89,7 @@ Examples: livesync-cli ./my-database rm notes/hello.md livesync-cli ./my-database resolve notes/hello.md 3-abcdef livesync-cli init-settings ./data.json - livesync-cli ./my-database --verbose + livesync-cli ./my-database --verbose `); } @@ -353,7 +336,10 @@ export async function main() { (core: LiveSyncBaseCore, serviceHub: InjectableServiceHub) => { return initialiseServiceModulesCLI(vaultPath, core, serviceHub); }, - (core) => [new ModuleReplicatorP2P(core)], // Register P2P replicator for CLI (useP2PReplicator is not used here) + (core) => [ + // No modules need to be registered for P2P replication in CLI. Directly using Replicators in p2p.ts + // new ModuleReplicatorP2P(core), + ], () => [], // No add-ons (core) => { // Add target filter to prevent internal files are handled diff --git a/src/apps/cli/package.json b/src/apps/cli/package.json index 30029bb..5701ae1 100644 --- a/src/apps/cli/package.json +++ b/src/apps/cli/package.json @@ -22,7 +22,6 @@ "test:e2e:p2p-upload-download-repro": "bash test/test-p2p-upload-download-repro-linux.sh", "test:e2e:p2p-host": "bash test/test-p2p-host-linux.sh", "test:e2e:p2p-sync": "bash test/test-p2p-sync-linux.sh", - "test:e2e:p2p-peers:local-relay": "bash test/test-p2p-peers-local-relay.sh", "test:e2e:mirror": "bash test/test-mirror-linux.sh", "pretest:e2e:all": "npm run build", "test:e2e:all": " export RUN_BUILD=0 && npm run test:e2e:setup-put-cat && npm run test:e2e:push-pull && npm run test:e2e:sync-two-local && npm run test:e2e:p2p && npm run test:e2e:mirror && npm run test:e2e:two-vaults && npm run test:e2e:p2p"