From fe3d68176d6f891276c5e5d3acfe895df682a972 Mon Sep 17 00:00:00 2001 From: Gabriel Horner Date: Mon, 2 Mar 2026 18:17:56 -0500 Subject: [PATCH] fix: confusing and incorrect naming for --repo global option Repo refers to internal identifiers that start with 'logseq_db_' and used to start with 'logseq_local_'. The --repo option was not being used in that way and was just a reference to a graph name. While it's reasonable for internal CLIs like db-worker-node.js to use --repo, it is needlessly confusing to introduce repo to users. Almost all of our apps and docs label graphs as 'graph' and not 'repo' --- .../agent-guide/002-logseq-cli-subcommands.md | 12 +- .../003-db-worker-node-cli-orchestration.md | 16 +- .../006-logseq-cli-import-export.md | 12 +- ...logseq-cli-thread-api-and-command-split.md | 15 +- ...logseq-cli-db-graph-default-dir-locking.md | 2 +- .../031-logseq-cli-doctor-command.md | 2 +- ...e-db-prefix-in-user-visible-graph-names.md | 22 +- .../046-logseq-cli-upsert-tag-rename-by-id.md | 2 +- docs/cli/logseq-cli.md | 32 +- src/main/logseq/cli/command/core.cljs | 13 +- src/main/logseq/cli/command/graph.cljs | 4 +- src/main/logseq/cli/command/server.cljs | 2 +- src/main/logseq/cli/commands.cljs | 25 +- src/main/logseq/cli/config.cljs | 6 +- src/main/logseq/cli/format.cljs | 6 +- src/test/logseq/cli/commands_test.cljs | 94 ++-- src/test/logseq/cli/config_test.cljs | 26 +- src/test/logseq/cli/format_test.cljs | 6 +- src/test/logseq/cli/integration_test.cljs | 512 +++++++++--------- 19 files changed, 391 insertions(+), 418 deletions(-) diff --git a/docs/agent-guide/002-logseq-cli-subcommands.md b/docs/agent-guide/002-logseq-cli-subcommands.md index 63f31ef6b9..8e14f38fd0 100644 --- a/docs/agent-guide/002-logseq-cli-subcommands.md +++ b/docs/agent-guide/002-logseq-cli-subcommands.md @@ -57,7 +57,7 @@ Global options apply to all subcommands and are parsed before subcommand options | --help | Show help | Available at top level and per subcommand. | | --version | Show version | Prints build time and revision. | | --config PATH | Config file path | Defaults to ~/logseq/cli.edn. | -| --repo REPO | Graph name | Used as current repo. | +| --graph GRAPH | Graph name | Used as current graph. | | --timeout-ms MS | Request timeout | Integer milliseconds. | | --output FORMAT | Output format | One of human, json, edn. | @@ -66,11 +66,11 @@ Each subcommand uses a nested path and its own options. | Subcommand path | Required args | Options | Notes | | --- | --- | --- | --- | | graph list | none | --output | Lists all graphs. | -| graph create | none | --repo GRAPH, --output | Creates and switches graph. | -| graph switch | none | --repo GRAPH, --output | Switches current graph. | -| graph remove | none | --repo GRAPH, --output | Removes graph. | -| graph validate | none | --repo GRAPH, --output | Validates graph. | -| graph info | none | --repo GRAPH, --output | Shows metadata, defaults to config repo if omitted. | +| graph create | none | --graph GRAPH, --output | Creates and switches graph. | +| graph switch | none | --graph GRAPH, --output | Switches current graph. | +| graph remove | none | --graph GRAPH, --output | Removes graph. | +| graph validate | none | --graph GRAPH, --output | Validates graph. | +| graph info | none | --graph GRAPH, --output | Shows metadata, defaults to config repo if omitted. | | block add | none | --content TEXT, --blocks EDN, --blocks-file PATH, --page PAGE, --parent UUID, --output | Content source is required, with file and text variants. | | block remove | none | --block UUID, --page PAGE, --output | One of block or page is required. | | search | QUERY | --type page|block|tag|property|all, --tag NAME, --case-sensitive, --sort updated-at|created-at, --order asc|desc, --output | Search text is positional and required. Human output columns: ID (db/id), TITLE. Block reference UUIDs in text are resolved recursively up to 10 levels. | diff --git a/docs/agent-guide/003-db-worker-node-cli-orchestration.md b/docs/agent-guide/003-db-worker-node-cli-orchestration.md index eb88386fb9..53fe6268d9 100644 --- a/docs/agent-guide/003-db-worker-node-cli-orchestration.md +++ b/docs/agent-guide/003-db-worker-node-cli-orchestration.md @@ -11,7 +11,7 @@ Goal: Based on the current `logseq-cli` and `db-worker-node` implementations, re ## Requirements 1. Refactor `db-worker-node`: startup must require `--repo`; on startup it must open or create that graph; it must not switch graphs at runtime; it must create a lock file so a graph can be served by only one db-worker-node instance; it only needs to bind to localhost. -2. In `logseq-cli`, all commands requiring `--repo` or any graph operations must connect to or create the corresponding db-worker-node server. +2. In `logseq-cli`, all commands requiring `--graph` or any graph operations must connect to or create the corresponding db-worker-node server. 3. db-worker-node server must not be started manually; logseq-cli is fully responsible. 4. Add `server` subcommand(s) to logseq-cli for managing db-worker-node servers. @@ -59,7 +59,7 @@ Files: - New: `src/main/logseq/cli/server.cljs` (process management + lock handling) Key changes: -- **Repo resolution**: for all graph/content commands, require `--repo` or resolved repo from config; otherwise error. +- **Repo resolution**: for all graph/content commands, require `--graph` or resolved repo from config; otherwise error. - **Ensure server** (new helper `ensure-server!`): 1. Derive data-dir, repo dir, and lock file path from repo. 2. If lock file exists, read port/pid; probe `/healthz` + `/readyz`. @@ -73,12 +73,12 @@ Key changes: Suggested command group: - `server list`: list servers from lock files (repo, pid, port, status). -- `server start --repo `: start server for repo. -- `server stop --repo `: stop server (SIGTERM or `/v1/shutdown`). -- `server restart --repo `: stop + start. +- `server start --graph `: start server for repo. +- `server stop --graph `: stop server (SIGTERM or `/v1/shutdown`). +- `server restart --graph `: stop + start. Implementation notes: -- `start|stop|restart` require `--repo`. +- `start|stop|restart` require `--graph`. - `list` scans data-dir for repo directories, reads lock files, and verifies status. - Consider adding `/v1/shutdown` in db-worker-node for graceful stop. @@ -104,8 +104,8 @@ Implementation notes: ## Open Questions -1. Should `graph list` require `--repo`? If not, define a “global” server or out-of-band access to data-dir. - - Answer: No --repo needed, using 'out-of-band access to data-dir' way +1. Should `graph list` require `--graph`? If not, define a “global” server or out-of-band access to data-dir. + - Answer: No --graph needed, using 'out-of-band access to data-dir' way 2. Lock file format and location: confirm cross-platform expectations (Windows paths/permissions). - lockfile name:`db-worker.lock`, - Location: inside repo dir (e.g. `~/logseq/cli-graphs//db-worker.lock`). diff --git a/docs/agent-guide/006-logseq-cli-import-export.md b/docs/agent-guide/006-logseq-cli-import-export.md index 42df290964..461edee5aa 100644 --- a/docs/agent-guide/006-logseq-cli-import-export.md +++ b/docs/agent-guide/006-logseq-cli-import-export.md @@ -19,14 +19,14 @@ Related: Builds on docs/agent-guide/004-logseq-cli-verb-subcommands.md and docs/ Prefer graph-scoped subcommands to keep import/export with graph management: -- `logseq graph export --type edn --file [--repo ]` -- `logseq graph export --type sqlite --file [--repo ]` -- `logseq graph import --type edn --input --repo ` -- `logseq graph import --type sqlite --input --repo ` +- `logseq graph export --type edn --file [--graph ]` +- `logseq graph export --type sqlite --file [--graph ]` +- `logseq graph import --type edn --input --graph ` +- `logseq graph import --type sqlite --input --graph ` Notes: - `graph import` only supports importing into a new graph name; it must not overwrite an existing graph. -- `--repo` is required for import, and required unless the current graph is set in config for export. +- `--graph` is required for import, and required unless the current graph is set in config for export. ## Current Capabilities (Baseline) @@ -70,7 +70,7 @@ Notes: ## Edge Cases - Large SQLite exports may exceed JSON limits if not base64/transit encoded; ensure streaming-safe or chunked base64 handling. -- Import should fail fast if the repo is missing and `--repo` is not provided, or if input file does not exist. +- Import should fail fast if the repo is missing and `--graph` is not provided, or if input file does not exist. - SQLite import while the repo is open must close/reopen connections to avoid stale datascript state. - EDN import should validate the export shape and surface readable errors when EDN is invalid or incompatible. - Overwrite behavior should be explicit for SQLite imports to prevent accidental data loss. diff --git a/docs/agent-guide/007-logseq-cli-thread-api-and-command-split.md b/docs/agent-guide/007-logseq-cli-thread-api-and-command-split.md index e3b67af23e..0b3a8d77db 100644 --- a/docs/agent-guide/007-logseq-cli-thread-api-and-command-split.md +++ b/docs/agent-guide/007-logseq-cli-thread-api-and-command-split.md @@ -1,6 +1,6 @@ # Logseq CLI Thread API Keywords And Command Split Implementation Plan -Goal: Replace thread-api string usage with keywords, standardize CLI repo option to --repo, and split logseq.cli.commands into per-subcommand namespaces. +Goal: Replace thread-api string usage with keywords, standardize CLI repo/graph option to --graph, and split logseq.cli.commands into per-subcommand namespaces. Architecture: Update transport and db-worker-node boundaries to accept keyword methods while still serializing over HTTP. Refactor CLI command parsing into a shared dispatcher plus per-subcommand namespaces under a new command directory. Keep existing CLI behavior and output stable while updating option naming and error hints. @@ -10,11 +10,11 @@ Related: Builds on docs/agent-guide/004-logseq-cli-verb-subcommands.md, docs/age ## Problem statement -The current CLI and db-worker-node codebase mixes thread-api method strings with keyword-based APIs, which makes it easy to introduce mismatches and reduces consistency with the thread-api macro design. The CLI option naming also has legacy --graph hints and expectations that conflict with the newer --repo naming, which creates confusion for users and tests. The logseq.cli.commands namespace has grown large and mixes parsing, validation, and execution for multiple command groups, which makes maintenance and ownership difficult. +The current CLI and db-worker-node codebase mixes thread-api method strings with keyword-based APIs, which makes it easy to introduce mismatches and reduces consistency with the thread-api macro design. The logseq.cli.commands namespace has grown large and mixes parsing, validation, and execution for multiple command groups, which makes maintenance and ownership difficult. ## Testing Plan -I will add unit tests to ensure all CLI thread-api method invocations use keywords and still serialize correctly through transport when invoking db-worker-node. I will add unit tests to ensure any error hint or help text for missing graph/repo uses --repo and no longer mentions --graph. I will add unit tests for command parsing and action building to cover the new per-subcommand namespaces and ensure summaries and help still match expected output. I will update db-worker-node tests to assert keyword method handling for repo validation and allowed non-repo methods. NOTE: I will write *all* tests before I add any implementation behavior. +I will add unit tests to ensure all CLI thread-api method invocations use keywords and still serialize correctly through transport when invoking db-worker-node. I will add unit tests for command parsing and action building to cover the new per-subcommand namespaces and ensure summaries and help still match expected output. I will update db-worker-node tests to assert keyword method handling for repo validation and allowed non-repo methods. NOTE: I will write *all* tests before I add any implementation behavior. ## Plan @@ -36,7 +36,7 @@ I will add unit tests to ensure all CLI thread-api method invocations use keywor 9. Update any db-worker-node tests in `src/test/frontend/worker/db_worker_node_test.cljs` that assert method strings to use keyword expectations and verify non-repo method handling. -10. Replace any --graph option references in CLI formatting and tests by updating `src/main/logseq/cli/format.cljs` and `src/test/logseq/cli/format_test.cljs` to use --repo. +10. ~~Replace any --graph option references in CLI formatting and tests by updating `src/main/logseq/cli/format.cljs` and `src/test/logseq/cli/format_test.cljs` to use --repo.~~ 11. Search for any `:graph` option wiring in `src/main/logseq/cli/commands.cljs` and remove CLI option parsing for --graph, including any help or usage text, while preserving graph-specific subcommands like `graph create`. @@ -62,15 +62,14 @@ The tests will focus on behavior by asserting that CLI invocations still produce - Normalize thread-api method values at transport and db-worker-node boundaries to accept keywords and serialize as strings over HTTP. - Replace all explicit "thread-api/..." literals in CLI and db-worker-node call sites with :thread-api/... keywords. -- Remove --graph option handling and update error hints to use --repo. -- Preserve graph subcommands and graph naming semantics while standardizing on :repo options. +- Preserve graph subcommands and graph naming semantics while standardizing on :graph options. - Move per-subcommand parsing and execution helpers into `src/main/logseq/cli/command/` namespaces and keep `logseq.cli.commands` as a facade. - Keep action map shapes stable to avoid downstream changes in format or execution. - Update tests to match keyword method expectations and new module layout. -- Ensure public CLI output and behavior remain unchanged aside from --repo messaging. +- Ensure public CLI output and behavior remain unchanged ## Question -Resolved: Remove --graph entirely and fail fast on any --graph usage. +~~Resolved: Remove --graph entirely and fail fast on any --graph usage.~~ --- diff --git a/docs/agent-guide/030-logseq-cli-db-graph-default-dir-locking.md b/docs/agent-guide/030-logseq-cli-db-graph-default-dir-locking.md index 1f139e372d..1384d26901 100644 --- a/docs/agent-guide/030-logseq-cli-db-graph-default-dir-locking.md +++ b/docs/agent-guide/030-logseq-cli-db-graph-default-dir-locking.md @@ -53,7 +53,7 @@ NOTE: I will write *all* tests before I add any implementation behavior. ## Integration sketch ```text -CLI --repo demo +CLI --graph demo -> command-core resolves internal repo: logseq_db_demo -> graph-dir resolver maps repo to graph key: demo -> fs paths use ~/logseq/graphs/demo diff --git a/docs/agent-guide/031-logseq-cli-doctor-command.md b/docs/agent-guide/031-logseq-cli-doctor-command.md index 13cc97b068..4a2872cd3b 100644 --- a/docs/agent-guide/031-logseq-cli-doctor-command.md +++ b/docs/agent-guide/031-logseq-cli-doctor-command.md @@ -178,6 +178,6 @@ Resolved: `doctor` will fail fast on the first failed check. Resolved: `doctor` will treat `:starting` servers as warnings when script and data-dir checks pass. -Resolved: `doctor` will support a future `--repo` scoped deep check that verifies per-graph lock path and repo directory access without starting the daemon. +Resolved: `doctor` will support a future `--graph` scoped deep check that verifies per-graph lock path and repo directory access without starting the daemon. --- diff --git a/docs/agent-guide/040-hide-db-prefix-in-user-visible-graph-names.md b/docs/agent-guide/040-hide-db-prefix-in-user-visible-graph-names.md index 1b338148c3..e26f5a5c23 100644 --- a/docs/agent-guide/040-hide-db-prefix-in-user-visible-graph-names.md +++ b/docs/agent-guide/040-hide-db-prefix-in-user-visible-graph-names.md @@ -59,7 +59,7 @@ I will add RTC tests in `/Users/rcmerci/gh-repos/logseq/src/test/frontend/handle I will extend CLI formatter tests in `/Users/rcmerci/gh-repos/logseq/src/test/logseq/cli/format_test.cljs` to assert user-facing fields strip exactly one prefix and never introduce additional prefixes. -I will extend CLI command tests in `/Users/rcmerci/gh-repos/logseq/src/test/logseq/cli/commands_test.cljs` for `graph list` and server output paths with unprefixed and prefix-like graph names, and assert prefix-like `--repo` values are treated as graph-name content instead of invalid input. +I will extend CLI command tests in `/Users/rcmerci/gh-repos/logseq/src/test/logseq/cli/commands_test.cljs` for `graph list` and server output paths with unprefixed and prefix-like graph names, and assert prefix-like `--graph` values are treated as graph-name content instead of invalid input. I will add legacy graph discovery tests in `/Users/rcmerci/gh-repos/logseq/src/test/logseq/cli/common/graph_test.cljs` to verify old directory names do not produce multi-prefix repo ids. @@ -77,7 +77,7 @@ NOTE: I will write all tests before I add any implementation behavior. 2. Add failing tests in `/Users/rcmerci/gh-repos/logseq/src/test/frontend/db/persist_test.cljs` to verify worker and Electron graph sources are canonicalized to one internal prefix. 3. Add failing tests in `/Users/rcmerci/gh-repos/logseq/src/test/frontend/handler/db_based/rtc_test.cljs` for remote graph mapping and download paths with prefixed and double-prefixed payload names. 4. Extend `/Users/rcmerci/gh-repos/logseq/src/test/logseq/cli/format_test.cljs` with failing cases where `:repo` or `:graph` includes one or two prefixes and output uses one-layer stripping only. -5. Extend `/Users/rcmerci/gh-repos/logseq/src/test/logseq/cli/commands_test.cljs` with failing cases for graph list and server output using unprefixed and prefix-like `--repo` values, and assert prefix-like values are not rejected by argument validation. +5. Extend `/Users/rcmerci/gh-repos/logseq/src/test/logseq/cli/commands_test.cljs` with failing cases for graph list and server output using unprefixed and prefix-like `--graph` values, and assert prefix-like values are not rejected by argument validation. 6. Add failing tests in `/Users/rcmerci/gh-repos/logseq/src/test/logseq/cli/common/graph_test.cljs` for legacy directory names that already contain `logseq_db_`. 7. Run focused tests and confirm failures reflect behavior gaps rather than setup errors. @@ -116,7 +116,7 @@ NOTE: I will write all tests before I add any implementation behavior. 26. Update `/Users/rcmerci/gh-repos/logseq/src/main/logseq/cli/command/core.cljs` so `repo->graph` strips exactly one leading prefix for user-visible output. 27. Verify `/Users/rcmerci/gh-repos/logseq/src/main/logseq/cli/format.cljs` uses one-layer display normalization consistently for human, JSON, and EDN user-facing graph fields. 28. Update `/Users/rcmerci/gh-repos/logseq/deps/cli/src/logseq/cli/commands/graph.cljs` to canonicalize internal repo identifiers before list rendering and server-target resolution. -29. Ensure CLI parsing and command execution treat `--repo` as a graph-name string, so leading `logseq_db_` is interpreted as part of graph name when present and is not rejected by input validation. +29. Ensure CLI parsing and command execution treat `--graph` as a graph-name string, so leading `logseq_db_` is interpreted as part of graph name when present and is not rejected by input validation. ### Phase 7: Verification and release gate. @@ -124,11 +124,11 @@ NOTE: I will write all tests before I add any implementation behavior. 31. Run `bb dev:test -v 'frontend.db.persist-test'` and confirm merged-source canonicalization behavior is stable. 32. Run `bb dev:test -v 'frontend.handler.db-based.rtc-test'` and confirm remote ingestion cannot produce multi-prefix repos. 33. Run `bb dev:test -v 'logseq.cli.format-test'` and confirm CLI display fields apply one-layer strip behavior. -34. Run `bb dev:test -v 'logseq.cli.commands-test'` and confirm graph command behavior remains stable with unprefixed and prefix-like `--repo` input. +34. Run `bb dev:test -v 'logseq.cli.commands-test'` and confirm graph command behavior remains stable with unprefixed and prefix-like `--graph` input. 35. Run `bb dev:test -v 'logseq.cli.common.graph-test'` and confirm legacy graph discovery does not emit double-prefixed repo names. 36. Run `bb dev:lint-and-test` and confirm `0 failures, 0 errors`. 37. Perform a manual graph-list smoke check on web and Electron to confirm normal graphs display without prefix and legacy doubles display with one remaining prefix. -38. Perform a manual CLI smoke check with `logseq graph list`, `logseq server status --repo demo`, and `logseq server status --repo logseq_db_demo` to confirm both inputs are accepted as graph names. +38. Perform a manual CLI smoke check with `logseq graph list`, `logseq server status --graph demo`, and `logseq server status --graph logseq_db_demo` to confirm both inputs are accepted as graph names. ## Edge cases @@ -141,9 +141,9 @@ NOTE: I will write all tests before I add any implementation behavior. | Legacy disk directory is named `logseq_db_logseq_db_demo`. | Discovery canonicalization collapses to internal repo `logseq_db_demo`. | | Remote graph payload returns `graph-name` as `logseq_db_demo`. | RTC mapping keeps internal repo `logseq_db_demo` and user-visible name `demo`. | | Remote graph payload returns `graph-name` as `logseq_db_logseq_db_demo`. | RTC mapping canonicalizes to internal repo `logseq_db_demo`, and user-visible name is `demo` after one-layer display strip. | -| CLI receives `--repo demo`. | Command works and output graph name is `demo`. | -| CLI receives `--repo logseq_db_demo`. | Command treats `logseq_db_` as part of graph name and does not fail argument validation. | -| CLI receives `--repo logseq_db_logseq_db_demo`. | Command treats the full value as graph name content and does not fail argument validation. | +| CLI receives `--graph demo`. | Command works and output graph name is `demo`. | +| CLI receives `--graph logseq_db_demo`. | Command treats `logseq_db_` as part of graph name and does not fail argument validation. | +| CLI receives `--graph logseq_db_logseq_db_demo`. | Command treats the full value as graph name content and does not fail argument validation. | | Non-user-visible fields like `data-testid` include repo id. | Existing selectors remain unchanged unless canonicalization is required to prevent duplicate graph entries. | ## Verification commands and expected outputs @@ -164,7 +164,7 @@ Web and Electron manual checks should show no new multi-prefix repo entries. Web and Electron display should strip one prefix only at render time. -CLI human output should match one-layer strip semantics, and CLI `--repo` should treat prefix-like values as normal graph names. +CLI human output should match one-layer strip semantics, and CLI `--graph` should treat prefix-like values as normal graph names. ## Testing Details @@ -184,7 +184,7 @@ CLI tests assert command behavior and output formatting remain stable for unpref - Reuse shared helpers across frontend, Electron, and CLI. - Preserve `data-testid` compatibility unless canonicalization makes key updates unavoidable. - Avoid one-time metadata migration for existing persisted graphs. -- Treat CLI `--repo` input as raw graph name where `logseq_db_` may be part of the name. +- Treat CLI `--graph` input as raw graph name where `logseq_db_` may be part of the name. - Keep internal thread-api contracts based on prefixed repo ids. - Follow `@test-driven-development` for RED, GREEN, and REFACTOR order. - Validate final patch with `@prompts/review.md` checklist. @@ -197,7 +197,7 @@ Decision: The implementation focus is to identify and fix all paths that can cre Decision: This change does not include a one-time metadata migration for existing persisted legacy values. -Decision: CLI `--repo` option treats leading `logseq_db_` as graph-name content, not as forbidden prefix. +Decision: CLI `--graph` option treats leading `logseq_db_` as graph-name content, not as forbidden prefix. Decision: Treat `data-testid` stability as a strict compatibility requirement for `clj-e2e`. diff --git a/docs/agent-guide/046-logseq-cli-upsert-tag-rename-by-id.md b/docs/agent-guide/046-logseq-cli-upsert-tag-rename-by-id.md index b40caa6ad5..3c8824ad74 100644 --- a/docs/agent-guide/046-logseq-cli-upsert-tag-rename-by-id.md +++ b/docs/agent-guide/046-logseq-cli-upsert-tag-rename-by-id.md @@ -18,7 +18,7 @@ Current update mode in `execute-upsert-tag` only calls `ensure-tag-by-id!` and r Current db-worker-node path already supports page rename through `:thread-api/apply-outliner-ops` with `[:rename-page [page-uuid new-title]]` in `/Users/rcmerci/gh-repos/logseq/src/main/frontend/worker/db_core.cljs`, so rename behavior can be reused without adding new APIs. -The user-visible gap is that a command like `logseq upsert tag --repo --id 180 --name "Project Renamed"` should rename tag `180`, but currently fails at option validation. +The user-visible gap is that a command like `logseq upsert tag --graph --id 180 --name "Project Renamed"` should rename tag `180`, but currently fails at option validation. ## Testing Plan diff --git a/docs/cli/logseq-cli.md b/docs/cli/logseq-cli.md index 6254450d39..725b4b22b1 100644 --- a/docs/cli/logseq-cli.md +++ b/docs/cli/logseq-cli.md @@ -52,7 +52,7 @@ Graph directories on disk are stored as user-facing graph names (for example, `d Migration note: If you previously used `~/.logseq/cli-graphs` or `~/.logseq/cli.edn`, pass `--data-dir` or `--config` to continue using those locations. Supported keys include: -- `:repo` +- `:graph` - `:data-dir` - `:timeout-ms` - `:output-format` (use `:json` or `:edn` for scripting) @@ -67,22 +67,22 @@ Verbose logging: Graph commands: - `graph list` - list all db graphs -- `graph create --repo ` - create a new db graph and switch to it -- `graph switch --repo ` - switch current graph -- `graph remove --repo ` - remove a graph -- `graph validate --repo ` - validate graph data -- `graph info [--repo ]` - show graph metadata (defaults to current graph) -- `graph export --type edn|sqlite --file [--repo ]` - export a graph to EDN or SQLite -- `graph import --type edn|sqlite --input --repo ` - import a graph from EDN or SQLite (new graph only) +- `graph create --graph ` - create a new db graph and switch to it +- `graph switch --graph ` - switch current graph +- `graph remove --graph ` - remove a graph +- `graph validate --graph ` - validate graph data +- `graph info [--graph ]` - show graph metadata (defaults to current graph) +- `graph export --type edn|sqlite --file [--graph ]` - export a graph to EDN or SQLite +- `graph import --type edn|sqlite --input --graph ` - import a graph from EDN or SQLite (new graph only) -For any command that requires `--repo`, if the target graph does not exist, the CLI returns `graph not exists` (except for `graph create`). `graph import` fails if the target graph already exists. +For any command that requires `--graph`, if the target graph does not exist, the CLI returns `graph not exists` (except for `graph create`). `graph import` fails if the target graph already exists. Server commands: - `server list` - list running db-worker-node servers -- `server status --repo ` - show server status for a graph -- `server start --repo ` - start db-worker-node for a graph -- `server stop --repo ` - stop db-worker-node for a graph -- `server restart --repo ` - restart db-worker-node for a graph +- `server status --graph ` - show server status for a graph +- `server start --graph ` - start db-worker-node for a graph +- `server stop --graph ` - stop db-worker-node for a graph +- `server restart --graph ` - restart db-worker-node for a graph - `doctor [--dev-script]` - run runtime diagnostics for `db-worker-node.js`, `data-dir` permissions, and running server readiness (`--dev-script` checks `static/db-worker-node.js` explicitly) Server ownership behavior: @@ -187,9 +187,9 @@ id8 └── b8 Examples: ```bash -node ./dist/logseq.js graph create --repo demo -node ./dist/logseq.js graph export --type edn --file /tmp/demo.edn --repo demo -node ./dist/logseq.js graph import --type edn --input /tmp/demo.edn --repo demo-import +node ./dist/logseq.js graph create --graph demo +node ./dist/logseq.js graph export --type edn --file /tmp/demo.edn --graph demo +node ./dist/logseq.js graph import --type edn --input /tmp/demo.edn --graph demo-import node ./dist/logseq.js upsert block --target-page TestPage --content "hello world" node ./dist/logseq.js move --uuid --target-page TargetPage node ./dist/logseq.js search "hello" diff --git a/src/main/logseq/cli/command/core.cljs b/src/main/logseq/cli/command/core.cljs index 1a99ba6ddf..4c28609237 100644 --- a/src/main/logseq/cli/command/core.cljs +++ b/src/main/logseq/cli/command/core.cljs @@ -12,7 +12,7 @@ :version {:desc "Show version" :coerce :boolean} :config {:desc "Path to cli.edn (default ~/logseq/cli.edn)"} - :repo {:desc "Graph name"} + :graph {:desc "Graph name"} :data-dir {:desc "Path to db-worker data dir (default ~/logseq/graphs)"} :timeout-ms {:desc "Request timeout in ms (default 10000)" :coerce :long} @@ -197,13 +197,6 @@ {:opts opts :args (rest remaining)})) {:opts opts :args remaining}))))) -(defn legacy-graph-opt? - [raw-args] - (some (fn [token] - (or (= token "--graph") - (string/starts-with? token "--graph="))) - raw-args)) - (defn cli-error->result [summary {:keys [msg]}] (invalid-options-result summary (or msg "invalid options"))) @@ -227,5 +220,5 @@ (defn pick-graph [options _command-args config] - (or (:repo options) - (:repo config))) + (or (:graph options) + (:graph config))) diff --git a/src/main/logseq/cli/command/graph.cljs b/src/main/logseq/cli/command/graph.cljs index d5a646274a..6c2a948001 100644 --- a/src/main/logseq/cli/command/graph.cljs +++ b/src/main/logseq/cli/command/graph.cljs @@ -150,7 +150,7 @@ (:direct-pass? action) (:args action))] (when-let [repo (:persist-repo action)] - (cli-config/update-config! config {:repo repo})) + (cli-config/update-config! config {:graph repo})) (if-let [write (:write action)] (let [{:keys [format path]} write] (transport/write-output {:format format :path path :data result}) @@ -167,7 +167,7 @@ :error {:code :graph-not-found :message (str "graph not found: " graph)}} (p/let [_ (cli-server/ensure-server! config (:repo action))] - (cli-config/update-config! config {:repo graph}) + (cli-config/update-config! config {:graph graph}) {:status :ok :data {:message (str "switched to " graph)}}))))) diff --git a/src/main/logseq/cli/command/server.cljs b/src/main/logseq/cli/command/server.cljs index 2d37477988..0cad4f5065 100644 --- a/src/main/logseq/cli/command/server.cljs +++ b/src/main/logseq/cli/command/server.cljs @@ -5,7 +5,7 @@ [promesa.core :as p])) (def ^:private server-spec - {:repo {:desc "Graph name"}}) + {:graph {:desc "Graph name"}}) (def entries [(core/command-entry ["server" "list"] :server-list "List db-worker-node servers" {}) diff --git a/src/main/logseq/cli/commands.cljs b/src/main/logseq/cli/commands.cljs index 685fd98393..894daf4939 100644 --- a/src/main/logseq/cli/commands.cljs +++ b/src/main/logseq/cli/commands.cljs @@ -26,13 +26,6 @@ :message "graph name is required"} :summary summary}) -(defn- missing-repo-result - [summary] - {:ok? false - :error {:code :missing-repo - :message "repo is required"} - :summary summary}) - (defn- missing-content-result [summary] {:ok? false @@ -167,7 +160,7 @@ (let [opts (command-core/normalize-opts opts) args (vec args) cmd-summary (command-core/command-summary {:cmds cmds :spec spec}) - graph (:repo opts) + graph (:graph opts) has-args? (seq args) has-content? (or (seq (:content opts)) (seq (:blocks opts)) @@ -262,8 +255,8 @@ (and (= command :graph-import) (not (seq (:input opts)))) (missing-input-result summary) - (and (= command :graph-import) (not (seq (:repo opts)))) - (missing-repo-result summary) + (and (= command :graph-import) (not (seq (:graph opts)))) + (missing-graph-result summary) (and (= command :graph-import) (not (contains? (graph-command/import-export-types) @@ -271,8 +264,8 @@ (command-core/invalid-options-result summary (str "invalid type: " (:type opts))) (and (#{:server-status :server-start :server-stop :server-restart} command) - (not (seq (:repo opts)))) - (missing-repo-result summary) + (not (seq (:graph opts)))) + (missing-graph-result summary) :else (command-core/ok-result command opts args summary)))) @@ -282,13 +275,9 @@ (defn parse-args [raw-args] (let [summary (command-core/top-level-summary table) - legacy-graph-opt? (command-core/legacy-graph-opt? raw-args) {:keys [opts args]} (command-core/parse-leading-global-opts raw-args) {:keys [args id-from-stdin?]} (inject-stdin-id-arg (vec args))] (cond - legacy-graph-opt? - (command-core/invalid-options-result summary "unknown option: --graph") - (:version opts) (command-core/ok-result :version opts [] summary) @@ -380,7 +369,7 @@ (let [{:keys [command options args]} parsed graph (command-core/pick-graph options args config) repo (command-core/resolve-repo graph) - server-repo (command-core/resolve-repo (:repo options))] + server-repo (command-core/resolve-repo (:graph options))] (case command (:graph-list :graph-create :graph-switch :graph-remove :graph-validate :graph-info) (graph-command/build-graph-action command graph repo) @@ -390,7 +379,7 @@ (graph-command/build-export-action repo export-type (:file options))) :graph-import - (let [import-repo (command-core/resolve-repo (:repo options)) + (let [import-repo (command-core/resolve-repo (:graph options)) import-type (graph-command/normalize-import-export-type (:type options))] (graph-command/build-import-action import-repo import-type (:input options))) diff --git a/src/main/logseq/cli/config.cljs b/src/main/logseq/cli/config.cljs index 11dc5c987f..f27152b557 100644 --- a/src/main/logseq/cli/config.cljs +++ b/src/main/logseq/cli/config.cljs @@ -46,7 +46,7 @@ (let [path (or config-path (default-config-path)) current (or (read-config-file path) {}) filtered-current (dissoc current :auth-token :retries) - filtered-updates (dissoc updates :auth-token :retries) + filtered-updates (dissoc (or updates {}) :auth-token :retries) next (merge filtered-current filtered-updates)] (ensure-config-dir! path) (.writeFileSync fs path (pr-str next)) @@ -56,8 +56,8 @@ [] (let [env (.-env js/process)] (cond-> {} - (seq (gobj/get env "LOGSEQ_CLI_REPO")) - (assoc :repo (gobj/get env "LOGSEQ_CLI_REPO")) + (seq (gobj/get env "LOGSEQ_CLI_GRAPH")) + (assoc :graph (gobj/get env "LOGSEQ_CLI_GRAPH")) (seq (gobj/get env "LOGSEQ_CLI_DATA_DIR")) (assoc :data-dir (gobj/get env "LOGSEQ_CLI_DATA_DIR")) diff --git a/src/main/logseq/cli/format.cljs b/src/main/logseq/cli/format.cljs index ffa017fcb1..cb053a7b73 100644 --- a/src/main/logseq/cli/format.cljs +++ b/src/main/logseq/cli/format.cljs @@ -87,8 +87,8 @@ (defn- error-hint [{:keys [code]}] (case code - :missing-graph "Use --repo " - :missing-repo "Use --repo " + :missing-graph "Use --graph " + :missing-repo "Use --graph " :missing-content "Use --content or pass content as args" :missing-tag-name "Use --name " :missing-query "Use --query " @@ -221,7 +221,7 @@ (defn- format-server-list [servers] (format-counted-table - ["REPO" "STATUS" "HOST" "PORT" "PID" "OWNER"] + ["GRAPH" "STATUS" "HOST" "PORT" "PID" "OWNER"] (mapv (fn [server] [(:repo server) (:status server) diff --git a/src/test/logseq/cli/commands_test.cljs b/src/test/logseq/cli/commands_test.cljs index 97aa3a879a..6d7f0384c9 100644 --- a/src/test/logseq/cli/commands_test.cljs +++ b/src/test/logseq/cli/commands_test.cljs @@ -87,7 +87,7 @@ (is (contains-bold? summary "server list")) (is (contains-bold? summary "server start")) (is (contains-bold? summary "--help")) - (is (contains-bold? summary "--repo")) + (is (contains-bold? summary "--graph")) (is (re-find #"\u001b\[[0-9;]*mCommands\u001b\[[0-9;]*m:" summary)) (is (re-find #"\u001b\[[0-9;]*moptions\u001b\[[0-9;]*m:" summary)))) @@ -317,14 +317,6 @@ (is (false? (:ok? result))) (is (= :unknown-command (get-in result [:error :code])))))) -(deftest test-parse-args-rejects-graph-option - (testing "rejects legacy --graph option" - (let [result (commands/parse-args ["--graph" "demo" "graph" "list"])] - (is (false? (:ok? result))) - (is (= :invalid-options (get-in result [:error :code]))) - (is (= "unknown option: --graph" - (strip-ansi (get-in result [:error :message]))))))) - (deftest test-parse-args-global-options (testing "global output option is accepted" (let [result (commands/parse-args ["--output" "json" "graph" "list"])] @@ -1178,7 +1170,7 @@ (is (= "[\"Hello\"]" (get-in result [:options :inputs])))))) (deftest test-verb-subcommand-parse-graph-import-export - (testing "graph create requires --repo even with positional args" + (testing "graph create requires --graph even with positional args" (let [result (commands/parse-args ["graph" "create" "demo"])] (is (false? (:ok? result))) (is (= :missing-graph (get-in result [:error :code]))))) @@ -1196,12 +1188,12 @@ (let [result (commands/parse-args ["graph" "import" "--type" "sqlite" "--input" "import.sqlite" - "--repo" "demo"])] + "--graph" "demo"])] (is (true? (:ok? result))) (is (= :graph-import (:command result))) (is (= "sqlite" (get-in result [:options :type]))) (is (= "import.sqlite" (get-in result [:options :input]))) - (is (= "demo" (get-in result [:options :repo]))))) + (is (= "demo" (get-in result [:options :graph]))))) (testing "graph export requires type" (let [result (commands/parse-args ["graph" "export" "--file" "export.edn"])] @@ -1218,27 +1210,27 @@ (is (false? (:ok? result))) (is (= :missing-file (get-in result [:error :code]))))) - (testing "graph import requires repo" + (testing "graph import requires graph" (let [result (commands/parse-args ["graph" "import" "--type" "edn" "--input" "import.edn"])] (is (false? (:ok? result))) - (is (= :missing-repo (get-in result [:error :code]))))) + (is (= :missing-graph (get-in result [:error :code]))))) (testing "graph import rejects unknown type" (let [result (commands/parse-args ["graph" "import" "--type" "zip" "--input" "import.zip" - "--repo" "demo"])] + "--graph" "demo"])] (is (false? (:ok? result))) (is (= :invalid-options (get-in result [:error :code]))))) (testing "server status accepts prefix-like repo option values" (let [result (commands/parse-args ["server" "status" - "--repo" "logseq_db_logseq_db_demo"])] + "--graph" "logseq_db_logseq_db_demo"])] (is (true? (:ok? result))) (is (= :server-status (:command result))) - (is (= "logseq_db_logseq_db_demo" (get-in result [:options :repo])))))) + (is (= "logseq_db_logseq_db_demo" (get-in result [:options :graph])))))) (deftest test-verb-subcommand-parse-flags (testing "verb subcommands reject unknown flags" @@ -1271,14 +1263,14 @@ (is (= :missing-graph (get-in result [:error :code]))))) (testing "graph-switch uses graph name" - (let [parsed {:ok? true :command :graph-switch :options {:repo "demo"}} + (let [parsed {:ok? true :command :graph-switch :options {:graph "demo"}} result (commands/build-action parsed {})] (is (true? (:ok? result))) (is (= :graph-switch (get-in result [:action :type]))))) (testing "graph-info defaults to config repo" (let [parsed {:ok? true :command :graph-info :options {}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (true? (:ok? result))) (is (= :graph-info (get-in result [:action :type]))))) @@ -1286,7 +1278,7 @@ (let [parsed {:ok? true :command :graph-export :options {:type "edn" :file "export.edn"}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (true? (:ok? result))) (is (= :graph-export (get-in result [:action :type]))))) @@ -1312,13 +1304,13 @@ (is (= :missing-repo (get-in result [:error :code]))))) (testing "server stop builds action" - (let [parsed {:ok? true :command :server-stop :options {:repo "demo"}} + (let [parsed {:ok? true :command :server-stop :options {:graph "demo"}} result (commands/build-action parsed {})] (is (true? (:ok? result))) (is (= :server-stop (get-in result [:action :type]))))) (testing "server status canonicalizes multi-prefixed repo option" - (let [parsed {:ok? true :command :server-status :options {:repo "logseq_db_logseq_db_demo"}} + (let [parsed {:ok? true :command :server-status :options {:graph "logseq_db_logseq_db_demo"}} result (commands/build-action parsed {})] (is (true? (:ok? result))) (is (= :server-status (get-in result [:action :type]))) @@ -1348,19 +1340,19 @@ (testing "add block requires content" (let [parsed {:ok? true :command :upsert-block :options {}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (false? (:ok? result))) (is (= :missing-content (get-in result [:error :code]))))) (testing "add block builds insert-blocks op" (let [parsed {:ok? true :command :upsert-block :options {:content "hello"}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (true? (:ok? result))) (is (= :upsert-block (get-in result [:action :type]))))) (testing "add page requires name" (let [parsed {:ok? true :command :upsert-page :options {}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (false? (:ok? result))) (is (= :missing-page-name (get-in result [:error :code]))))) @@ -1369,7 +1361,7 @@ :command :upsert-page :options {:id 42 :update-properties "{:logseq.property/publishing-public? true}"}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (true? (:ok? result))) (is (= :update (get-in result [:action :mode]))) (is (= 42 (get-in result [:action :id])))))) @@ -1378,13 +1370,13 @@ (testing "upsert tag requires name" (let [parsed {:ok? true :command :upsert-tag :options {}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (false? (:ok? result))) (is (= :missing-tag-name (get-in result [:error :code]))))) (testing "upsert tag builds normalized action" (let [parsed {:ok? true :command :upsert-tag :options {:name " #Quote "}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (true? (:ok? result))) (is (= {:type :upsert-tag :mode :create @@ -1395,7 +1387,7 @@ (testing "upsert tag by id builds update action" (let [parsed {:ok? true :command :upsert-tag :options {:id 123}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (true? (:ok? result))) (is (= {:type :upsert-tag :mode :update @@ -1406,7 +1398,7 @@ (testing "upsert tag by id with name builds update action" (let [parsed {:ok? true :command :upsert-tag :options {:id 123 :name " #Project Renamed "}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (true? (:ok? result))) (is (= {:type :upsert-tag :mode :update @@ -1418,7 +1410,7 @@ (testing "upsert tag by id rejects blank rename name" (let [parsed {:ok? true :command :upsert-tag :options {:id 123 :name " "}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (false? (:ok? result))) (is (= :invalid-options (get-in result [:error :code]))))) @@ -1430,7 +1422,7 @@ :cardinality "many" :hide true :public false}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (true? (:ok? result))) (is (= {:type :upsert-property :mode :create @@ -1449,7 +1441,7 @@ :options {:id 654 :type "node" :cardinality "many"}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (true? (:ok? result))) (is (= {:type :upsert-property :mode :update @@ -1464,46 +1456,46 @@ (testing "remove block requires target" (let [parsed {:ok? true :command :remove-block :options {}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (false? (:ok? result))) (is (= :missing-target (get-in result [:error :code]))))) (testing "remove block normalizes id vector in build action" (let [parsed {:ok? true :command :remove-block :options {:id "[1 2]"}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (true? (:ok? result))) (is (= :remove-block (get-in result [:action :type]))) (is (= [1 2] (get-in result [:action :ids]))))) (testing "remove page requires name" (let [parsed {:ok? true :command :remove-page :options {}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (false? (:ok? result))) (is (= :missing-page-name (get-in result [:error :code]))))) (testing "remove tag parses by id" (let [parsed {:ok? true :command :remove-tag :options {:id 42}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (true? (:ok? result))) (is (= :remove-tag (get-in result [:action :type]))) (is (= 42 (get-in result [:action :id]))))) (testing "remove property parses by name" (let [parsed {:ok? true :command :remove-property :options {:name "owner"}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (true? (:ok? result))) (is (= :remove-property (get-in result [:action :type]))) (is (= "owner" (get-in result [:action :name]))))) (testing "show requires target" (let [parsed {:ok? true :command :show :options {}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (false? (:ok? result))) (is (= :missing-target (get-in result [:error :code]))))) (testing "show normalizes id vector in build action" (let [parsed {:ok? true :command :show :options {:id "[1 2]"}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (true? (:ok? result))) (is (= :show (get-in result [:action :type]))) (is (= [1 2] (get-in result [:action :ids])))))) @@ -1513,7 +1505,7 @@ (let [parsed (commands/parse-args ["upsert" "block" "--content" "hello" "--update-properties" "{:not/a 1}"]) - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (true? (:ok? result))) (is (= {:not/a 1} (get-in result [:action :update-properties]))))) @@ -1521,7 +1513,7 @@ (let [parsed (commands/parse-args ["upsert" "block" "--content" "hello" "--update-properties" "{\"Publishing Public?\" true}"]) - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (true? (:ok? result))) (is (= :logseq.property/publishing-public? (-> result :action :update-properties keys first))))) @@ -1530,7 +1522,7 @@ (let [parsed (commands/parse-args ["upsert" "block" "--content" "hello" "--update-properties" "{:logseq.property/heading 1}"]) - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (false? (:ok? result))) (is (= :invalid-options (get-in result [:error :code]))))) @@ -1538,7 +1530,7 @@ (let [parsed (commands/parse-args ["upsert" "block" "--content" "hello" "--update-properties" "{:logseq.property/publishing-public? \"nope\"}"]) - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (false? (:ok? result))) (is (= :invalid-options (get-in result [:error :code])))))) @@ -1547,7 +1539,7 @@ (let [parsed (commands/parse-args ["upsert" "block" "--content" "hello" "--update-tags" "[42]"]) - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (true? (:ok? result))) (is (= [42] (get-in result [:action :update-tags])))))) @@ -1562,13 +1554,13 @@ (deftest test-build-action-update (testing "upsert block create mode requires content when source selector is absent" (let [parsed {:ok? true :command :upsert-block :options {:target-id 2}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (false? (:ok? result))) (is (= :missing-content (get-in result [:error :code]))))) (testing "upsert block update mode requires target or update/remove options" (let [parsed {:ok? true :command :upsert-block :options {:id 1}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (false? (:ok? result))) (is (= :invalid-options (get-in result [:error :code]))))) @@ -1576,7 +1568,7 @@ (let [parsed {:ok? true :command :upsert-block :options {:id 1 :update-tags "[\"TagA\"]"}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (true? (:ok? result))) (is (= :upsert-block (get-in result [:action :type]))) (is (= ["TagA"] (get-in result [:action :update-tags]))))) @@ -1585,7 +1577,7 @@ (let [parsed {:ok? true :command :upsert-block :options {:id 1 :update-tags "{:tag \"no\"}"}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (false? (:ok? result))) (is (= :invalid-options (get-in result [:error :code]))))) @@ -1593,7 +1585,7 @@ (let [parsed {:ok? true :command :upsert-block :options {:id 1 :content "hello" :update-tags "[\"TagA\"]"}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (true? (:ok? result))) (is (= :upsert-block (get-in result [:action :type]))) (is (= 1 (get-in result [:action :id]))) @@ -1605,7 +1597,7 @@ :options {:id 1 :update-properties "{:user.property/owner \"alice\"}" :remove-properties "[:user.property/owner]"}} - result (commands/build-action parsed {:repo "demo"})] + result (commands/build-action parsed {:graph "demo"})] (is (true? (:ok? result))) (is (= :upsert-block (get-in result [:action :type]))) (is (= {:user.property/owner "alice"} diff --git a/src/test/logseq/cli/config_test.cljs b/src/test/logseq/cli/config_test.cljs index a20df6fdb9..6c0e91623b 100644 --- a/src/test/logseq/cli/config_test.cljs +++ b/src/test/logseq/cli/config_test.cljs @@ -24,22 +24,22 @@ (let [dir (node-helper/create-tmp-dir) cfg-path (node-path/join dir "cli.edn") _ (fs/writeFileSync cfg-path - (str "{:repo \"file-repo\" " + (str "{:graph \"file-repo\" " ":data-dir \"file-data\" " ":timeout-ms 111 " ":output-format :edn}")) - env {"LOGSEQ_CLI_REPO" "env-repo" + env {"LOGSEQ_CLI_GRAPH" "env-repo" "LOGSEQ_CLI_DATA_DIR" "env-data" "LOGSEQ_CLI_TIMEOUT_MS" "222" "LOGSEQ_CLI_OUTPUT" "json"} opts {:config-path cfg-path - :repo "cli-repo" + :graph "cli-repo" :data-dir "cli-data" :timeout-ms 333 :output-format :human} result (with-env env #(config/resolve-config opts))] (is (= cfg-path (:config-path result))) - (is (= "cli-repo" (:repo result))) + (is (= "cli-repo" (:graph result))) (is (= "cli-data" (:data-dir result))) (is (= 333 (:timeout-ms result))) (is (nil? (:auth-token result))) @@ -49,11 +49,11 @@ (deftest test-env-overrides-file (let [dir (node-helper/create-tmp-dir) cfg-path (node-path/join dir "cli.edn") - _ (fs/writeFileSync cfg-path "{:repo \"file-repo\" :data-dir \"file-data\"}") - env {"LOGSEQ_CLI_REPO" "env-repo" + _ (fs/writeFileSync cfg-path "{:graph \"file-repo\" :data-dir \"file-data\"}") + env {"LOGSEQ_CLI_GRAPH" "env-repo" "LOGSEQ_CLI_DATA_DIR" "env-data"} result (with-env env #(config/resolve-config {:config-path cfg-path}))] - (is (= "env-repo" (:repo result))) + (is (= "env-repo" (:graph result))) (is (= "env-data" (:data-dir result))))) (deftest test-output-format-env-overrides-file @@ -87,22 +87,22 @@ (deftest test-update-config (let [dir (node-helper/create-tmp-dir "cli") cfg-path (node-path/join dir "cli.edn") - _ (fs/writeFileSync cfg-path "{:repo \"old\"}") - _ (config/update-config! {:config-path cfg-path} {:repo "new"}) + _ (fs/writeFileSync cfg-path "{:graph \"old\"}") + _ (config/update-config! {:config-path cfg-path} {:graph "new"}) contents (.toString (fs/readFileSync cfg-path) "utf8") parsed (reader/read-string contents)] - (is (= "new" (:repo parsed))))) + (is (= "new" (:graph parsed))))) (deftest test-update-config-strips-removed-options (let [dir (node-helper/create-tmp-dir "cli") cfg-path (node-path/join dir "cli.edn") - _ (fs/writeFileSync cfg-path "{:repo \"old\"}") + _ (fs/writeFileSync cfg-path "{:graph \"old\"}") _ (config/update-config! {:config-path cfg-path} - {:repo "new" + {:graph "new" :auth-token "secret" :retries 2}) contents (.toString (fs/readFileSync cfg-path) "utf8") parsed (reader/read-string contents)] - (is (= "new" (:repo parsed))) + (is (= "new" (:graph parsed))) (is (not (contains? parsed :auth-token))) (is (not (contains? parsed :retries))))) diff --git a/src/test/logseq/cli/format_test.cljs b/src/test/logseq/cli/format_test.cljs index 11c4695525..bb6e6987ea 100644 --- a/src/test/logseq/cli/format_test.cljs +++ b/src/test/logseq/cli/format_test.cljs @@ -284,7 +284,7 @@ :pid 9876 :owner-source :cli}]}} {:output-format nil})] - (is (= (str "REPO STATUS HOST PORT PID OWNER\n" + (is (= (str "GRAPH STATUS HOST PORT PID OWNER\n" "demo-repo :ready 127.0.0.1 1234 9876 :cli\n" "Count: 1") result)))) @@ -298,7 +298,7 @@ :port 1234 :pid 9876}]}} {:output-format nil})] - (is (= (str "REPO STATUS HOST PORT PID OWNER\n" + (is (= (str "GRAPH STATUS HOST PORT PID OWNER\n" "demo-repo :ready 127.0.0.1 1234 9876 -\n" "Count: 1") result))))) @@ -460,7 +460,7 @@ :message "graph name is required"}} {:output-format nil})] (is (= (str "Error (missing-graph): graph name is required\n" - "Hint: Use --repo ") + "Hint: Use --graph ") result)))) (testing "owner mismatch includes ownership hint" diff --git a/src/test/logseq/cli/integration_test.cljs b/src/test/logseq/cli/integration_test.cljs index 31fb08d9f8..0fca0d4422 100644 --- a/src/test/logseq/cli/integration_test.cljs +++ b/src/test/logseq/cli/integration_test.cljs @@ -128,18 +128,18 @@ [data-dir] (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" "tags-graph"] data-dir cfg-path) - _ (run-cli ["--repo" "tags-graph" "upsert" "page" "--page" "Home"] data-dir cfg-path)] + _ (run-cli ["graph" "create" "--graph" "tags-graph"] data-dir cfg-path) + _ (run-cli ["--graph" "tags-graph" "upsert" "page" "--page" "Home"] data-dir cfg-path)] {:cfg-path cfg-path :repo "tags-graph"})) (defn- stop-repo! [data-dir cfg-path repo] - (p/let [result (run-cli ["server" "stop" "--repo" repo] data-dir cfg-path)] + (p/let [result (run-cli ["server" "stop" "--graph" repo] data-dir cfg-path)] (parse-json-output result))) (defn- run-query [data-dir cfg-path repo query inputs] - (p/let [result (run-cli ["--repo" repo "query" "--query" query "--inputs" inputs] + (p/let [result (run-cli ["--graph" repo "query" "--query" query "--inputs" inputs] data-dir cfg-path)] (parse-json-output result))) @@ -174,7 +174,7 @@ (defn- list-items [data-dir cfg-path repo list-type] - (p/let [result (run-cli ["--repo" repo "list" list-type] data-dir cfg-path)] + (p/let [result (run-cli ["--graph" repo "list" list-type] data-dir cfg-path)] (parse-json-output result))) (defn- find-item-id @@ -229,7 +229,7 @@ (fs/chmodSync repo-dir 365) (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - result (run-cli ["graph" "create" "--repo" repo] data-dir cfg-path) + result (run-cli ["graph" "create" "--graph" repo] data-dir cfg-path) payload (parse-json-output result)] (is (= 1 (:exit-code result))) (is (= "error" (:status payload))) @@ -245,11 +245,11 @@ (let [data-dir (node-helper/create-tmp-dir "db-worker")] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - create-result (run-cli ["graph" "create" "--repo" "demo-graph"] data-dir cfg-path) + create-result (run-cli ["graph" "create" "--graph" "demo-graph"] data-dir cfg-path) create-payload (parse-json-output create-result) info-result (run-cli ["graph" "info"] data-dir cfg-path) info-payload (parse-json-output info-result) - stop-result (run-cli ["server" "stop" "--repo" "demo-graph"] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" "demo-graph"] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= 0 (:exit-code create-result))) (is (= "ok" (:status create-payload))) @@ -268,23 +268,23 @@ (let [data-dir (node-helper/create-tmp-dir "db-worker")] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" "content-graph"] data-dir cfg-path) - add-page-result (run-cli ["--repo" "content-graph" "upsert" "page" "--page" "TestPage"] data-dir cfg-path) + _ (run-cli ["graph" "create" "--graph" "content-graph"] data-dir cfg-path) + add-page-result (run-cli ["--graph" "content-graph" "upsert" "page" "--page" "TestPage"] data-dir cfg-path) add-page-payload (parse-json-output add-page-result) - list-page-result (run-cli ["--repo" "content-graph" "list" "page"] data-dir cfg-path) + list-page-result (run-cli ["--graph" "content-graph" "list" "page"] data-dir cfg-path) list-page-payload (parse-json-output list-page-result) - list-tag-result (run-cli ["--repo" "content-graph" "list" "tag"] data-dir cfg-path) + list-tag-result (run-cli ["--graph" "content-graph" "list" "tag"] data-dir cfg-path) list-tag-payload (parse-json-output list-tag-result) - list-property-result (run-cli ["--repo" "content-graph" "list" "property"] data-dir cfg-path) + list-property-result (run-cli ["--graph" "content-graph" "list" "property"] data-dir cfg-path) list-property-payload (parse-json-output list-property-result) - add-block-result (run-cli ["--repo" "content-graph" "upsert" "block" "--target-page" "TestPage" "--content" "Test block"] data-dir cfg-path) + add-block-result (run-cli ["--graph" "content-graph" "upsert" "block" "--target-page" "TestPage" "--content" "Test block"] data-dir cfg-path) add-block-payload (parse-json-output add-block-result) _ (p/delay 100) - show-result (run-cli ["--repo" "content-graph" "show" "--page" "TestPage"] data-dir cfg-path) + show-result (run-cli ["--graph" "content-graph" "show" "--page" "TestPage"] data-dir cfg-path) show-payload (parse-json-output show-result) - remove-page-result (run-cli ["--repo" "content-graph" "remove" "page" "--name" "TestPage"] data-dir cfg-path) + remove-page-result (run-cli ["--graph" "content-graph" "remove" "page" "--name" "TestPage"] data-dir cfg-path) remove-page-payload (parse-json-output remove-page-result) - stop-result (run-cli ["server" "stop" "--repo" "content-graph"] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" "content-graph"] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= 0 (:exit-code add-page-result))) (is (= "ok" (:status add-page-payload))) @@ -313,8 +313,8 @@ repo "add-page-json-id-graph"] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" repo] data-dir cfg-path) - add-page-result (run-cli ["--repo" repo "upsert" "page" "--page" "Home"] data-dir cfg-path) + _ (run-cli ["graph" "create" "--graph" repo] data-dir cfg-path) + add-page-result (run-cli ["--graph" repo "upsert" "page" "--page" "Home"] data-dir cfg-path) add-page-payload (parse-json-output add-page-result) page-ids (get-in add-page-payload [:data :result]) page-id (first page-ids) @@ -322,7 +322,7 @@ "[:find ?id . :in $ ?page-name :where [?id :block/name ?page-name]]" (pr-str [(common-util/page-name-sanity-lc "Home")])) queried-page-id (get-in query-payload [:data :result]) - stop-result (run-cli ["server" "stop" "--repo" repo] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" repo] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= 0 (:exit-code add-page-result))) (is (= "ok" (:status add-page-payload))) @@ -345,9 +345,9 @@ :block/children [{:block/title "Child"}]} {:block/title "Sibling"}]) _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" repo] data-dir cfg-path) - _ (run-cli ["--repo" repo "upsert" "page" "--page" "Home"] data-dir cfg-path) - add-block-result (run-cli ["--repo" repo + _ (run-cli ["graph" "create" "--graph" repo] data-dir cfg-path) + _ (run-cli ["--graph" repo "upsert" "page" "--page" "Home"] data-dir cfg-path) + add-block-result (run-cli ["--graph" repo "upsert" "block" "--target-page" "Home" "--blocks" blocks-edn] @@ -360,7 +360,7 @@ block-titles (->> (get-in title-query-payload [:data :result]) (map first) set) - stop-result (run-cli ["server" "stop" "--repo" repo] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" repo] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= 0 (:exit-code add-block-result)) (pr-str (:error add-block-payload))) @@ -383,15 +383,15 @@ repo "add-edn-id-graph"] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" repo] data-dir cfg-path) - add-page-result (run-cli ["--repo" repo + _ (run-cli ["graph" "create" "--graph" repo] data-dir cfg-path) + add-page-result (run-cli ["--graph" repo "--output" "edn" "upsert" "page" "--page" "Home"] data-dir cfg-path) add-page-payload (parse-edn-output add-page-result) page-ids (get-in add-page-payload [:data :result]) - add-block-result (run-cli ["--repo" repo + add-block-result (run-cli ["--graph" repo "--output" "edn" "upsert" "block" "--target-page" "Home" @@ -399,7 +399,7 @@ data-dir cfg-path) add-block-payload (parse-edn-output add-block-result) block-ids (get-in add-block-payload [:data :result]) - stop-result (run-cli ["server" "stop" "--repo" repo] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" repo] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= 0 (:exit-code add-page-result))) (is (= :ok (:status add-page-payload))) @@ -423,30 +423,30 @@ repo "add-id-chain-graph"] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" repo] data-dir cfg-path) - add-page-result (run-cli ["--repo" repo "upsert" "page" "--page" "ChainPage"] data-dir cfg-path) + _ (run-cli ["graph" "create" "--graph" repo] data-dir cfg-path) + add-page-result (run-cli ["--graph" repo "upsert" "page" "--page" "ChainPage"] data-dir cfg-path) add-page-payload (parse-json-output add-page-result) page-id (first-result-id add-page-payload) - add-block-result (run-cli ["--repo" repo + add-block-result (run-cli ["--graph" repo "upsert" "block" "--target-id" (str page-id) "--content" "Chain block"] data-dir cfg-path) add-block-payload (parse-json-output add-block-result) block-id (first-result-id add-block-payload) - update-result (run-cli ["--repo" repo + update-result (run-cli ["--graph" repo "upsert" "block" "--id" (str block-id) "--update-properties" "{:logseq.property/publishing-public? true}"] data-dir cfg-path) update-payload (parse-json-output update-result) - remove-result (run-cli ["--repo" repo "remove" "block" "--id" (str block-id)] data-dir cfg-path) + remove-result (run-cli ["--graph" repo "remove" "block" "--id" (str block-id)] data-dir cfg-path) remove-payload (parse-json-output remove-result) query-after-remove (run-query data-dir cfg-path repo "[:find ?e . :in $ ?title :where [?e :block/title ?title]]" (pr-str ["Chain block"])) removed-id (get-in query-after-remove [:data :result]) - stop-result (run-cli ["server" "stop" "--repo" repo] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" repo] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= 0 (:exit-code add-page-result))) (is (= "ok" (:status add-page-payload))) @@ -471,11 +471,11 @@ repo "upsert-page-existing-graph"] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" repo] data-dir cfg-path) - create-result (run-cli ["--repo" repo "upsert" "page" "--page" "Home"] data-dir cfg-path) + _ (run-cli ["graph" "create" "--graph" repo] data-dir cfg-path) + create-result (run-cli ["--graph" repo "upsert" "page" "--page" "Home"] data-dir cfg-path) create-payload (parse-json-output create-result) page-id (first-result-id create-payload) - update-result (run-cli ["--repo" repo + update-result (run-cli ["--graph" repo "upsert" "page" "--page" "Home" "--update-properties" "{:logseq.property/publishing-public? true}"] @@ -484,7 +484,7 @@ update-id (first-result-id update-payload) property-after-update (query-property data-dir cfg-path repo "Home" ":logseq.property/publishing-public?") - remove-result (run-cli ["--repo" repo + remove-result (run-cli ["--graph" repo "upsert" "page" "--page" "Home" "--remove-properties" "[:logseq.property/publishing-public?]"] @@ -493,7 +493,7 @@ remove-id (first-result-id remove-payload) property-after-remove (query-property data-dir cfg-path repo "Home" ":logseq.property/publishing-public?") - stop-result (run-cli ["server" "stop" "--repo" repo] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" repo] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= 0 (:exit-code create-result))) (is (= "ok" (:status create-payload))) @@ -518,20 +518,20 @@ repo "upsert-page-missing-graph"] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" repo] data-dir cfg-path) - missing-tag-result (run-cli ["--repo" repo + _ (run-cli ["graph" "create" "--graph" repo] data-dir cfg-path) + missing-tag-result (run-cli ["--graph" repo "upsert" "page" "--page" "Home" "--update-tags" "[\"MissingTag\"]"] data-dir cfg-path) missing-tag-payload (parse-json-output missing-tag-result) - missing-property-result (run-cli ["--repo" repo + missing-property-result (run-cli ["--graph" repo "upsert" "page" "--page" "Home" "--update-properties" "{:not/a 1}"] data-dir cfg-path) missing-property-payload (parse-json-output missing-property-result) - stop-result (run-cli ["server" "stop" "--repo" repo] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" repo] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= "error" (:status missing-tag-payload))) (is (= :tag-not-found (keyword (get-in missing-tag-payload [:error :code])))) @@ -549,23 +549,23 @@ repo "upsert-id-mode-graph"] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" repo] data-dir cfg-path) - create-page-result (run-cli ["--repo" repo "upsert" "page" "--page" "Home"] data-dir cfg-path) + _ (run-cli ["graph" "create" "--graph" repo] data-dir cfg-path) + create-page-result (run-cli ["--graph" repo "upsert" "page" "--page" "Home"] data-dir cfg-path) create-page-payload (parse-json-output create-page-result) page-id (first-result-id create-page-payload) - update-page-result (run-cli ["--repo" repo + update-page-result (run-cli ["--graph" repo "upsert" "page" "--id" (str page-id) "--update-properties" "{:logseq.property/publishing-public? true}"] data-dir cfg-path) update-page-payload (parse-json-output update-page-result) page-value (query-property data-dir cfg-path repo "Home" ":logseq.property/publishing-public?") - create-tag-result (run-cli ["--repo" repo "upsert" "tag" "--name" "StableTag"] data-dir cfg-path) + create-tag-result (run-cli ["--graph" repo "upsert" "tag" "--name" "StableTag"] data-dir cfg-path) create-tag-payload (parse-json-output create-tag-result) tag-id (first-result-id create-tag-payload) - noop-tag-result (run-cli ["--repo" repo "upsert" "tag" "--id" (str tag-id)] data-dir cfg-path) + noop-tag-result (run-cli ["--graph" repo "upsert" "tag" "--id" (str tag-id)] data-dir cfg-path) noop-tag-payload (parse-json-output noop-tag-result) - create-property-result (run-cli ["--repo" repo + create-property-result (run-cli ["--graph" repo "upsert" "property" "--name" "OwnerProp" "--type" "default"] @@ -573,7 +573,7 @@ create-property-payload (parse-json-output create-property-result) property-id (first-result-id create-property-payload) property-name (common-util/page-name-sanity-lc "OwnerProp") - update-property-result (run-cli ["--repo" repo + update-property-result (run-cli ["--graph" repo "upsert" "property" "--id" (str property-id) "--type" "node" @@ -583,7 +583,7 @@ property-schema (run-query data-dir cfg-path repo "[:find ?type . :in $ ?name :where [?p :block/name ?name] [?p :logseq.property/type ?type]]" (pr-str [property-name])) - stop-result (run-cli ["server" "stop" "--repo" repo] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" repo] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= 0 (:exit-code create-page-result))) (is (= "ok" (:status create-page-payload))) @@ -617,27 +617,27 @@ repo "upsert-legacy-options-graph"] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" repo] data-dir cfg-path) - create-page-result (run-cli ["--repo" repo "upsert" "page" "--page" "Home"] data-dir cfg-path) + _ (run-cli ["graph" "create" "--graph" repo] data-dir cfg-path) + create-page-result (run-cli ["--graph" repo "upsert" "page" "--page" "Home"] data-dir cfg-path) create-page-payload (parse-json-output create-page-result) page-id (first-result-id create-page-payload) - legacy-block-result (run-cli ["--repo" repo + legacy-block-result (run-cli ["--graph" repo "upsert" "block" "--target-page" "Home" "--content" "Legacy block" "--tags" "[\"Quote\"]"] data-dir cfg-path) - legacy-page-result (run-cli ["--repo" repo + legacy-page-result (run-cli ["--graph" repo "upsert" "page" "--page" "Home" "--properties" "{:logseq.property/publishing-public? true}"] data-dir cfg-path) - conflict-result (run-cli ["--repo" repo + conflict-result (run-cli ["--graph" repo "upsert" "page" "--id" (str page-id) "--page" "Home"] data-dir cfg-path) - stop-result (run-cli ["server" "stop" "--repo" repo] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" repo] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= 0 (:exit-code create-page-result))) (is (= "ok" (:status create-page-payload))) @@ -661,16 +661,16 @@ (let [data-dir (node-helper/create-tmp-dir "db-worker-ref-rewrite")] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" "ref-rewrite-graph"] data-dir cfg-path) - _ (run-cli ["--repo" "ref-rewrite-graph" "upsert" "page" "--page" "Home"] data-dir cfg-path) - add-block-result (run-cli ["--repo" "ref-rewrite-graph" + _ (run-cli ["graph" "create" "--graph" "ref-rewrite-graph"] data-dir cfg-path) + _ (run-cli ["--graph" "ref-rewrite-graph" "upsert" "page" "--page" "Home"] data-dir cfg-path) + add-block-result (run-cli ["--graph" "ref-rewrite-graph" "upsert" "block" "--target-page" "Home" "--content" "See [[New Page]]"] data-dir cfg-path) add-block-payload (parse-json-output-safe add-block-result "add-block") _ (p/delay 100) - list-page-result (run-cli ["--repo" "ref-rewrite-graph" "list" "page"] data-dir cfg-path) + list-page-result (run-cli ["--graph" "ref-rewrite-graph" "list" "page"] data-dir cfg-path) list-page-payload (parse-json-output-safe list-page-result "list-page") page-titles (->> (get-in list-page-payload [:data :items]) (map #(or (:block/title %) (:title %))) @@ -686,7 +686,7 @@ titles) ref-value (when ref-title (second (first (re-seq #"\[\[(.*?)\]\]" ref-title)))) - stop-result (run-cli ["server" "stop" "--repo" "ref-rewrite-graph"] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" "ref-rewrite-graph"] data-dir cfg-path) stop-payload (parse-json-output-safe stop-result "server-stop")] (is (= 0 (:exit-code add-block-result))) (is (= "ok" (:status add-block-payload))) @@ -706,9 +706,9 @@ (let [data-dir (node-helper/create-tmp-dir "db-worker-uuid-ref")] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" "uuid-ref-graph"] data-dir cfg-path) - _ (run-cli ["--repo" "uuid-ref-graph" "upsert" "page" "--page" "Home"] data-dir cfg-path) - _ (run-cli ["--repo" "uuid-ref-graph" + _ (run-cli ["graph" "create" "--graph" "uuid-ref-graph"] data-dir cfg-path) + _ (run-cli ["--graph" "uuid-ref-graph" "upsert" "page" "--page" "Home"] data-dir cfg-path) + _ (run-cli ["--graph" "uuid-ref-graph" "upsert" "block" "--target-page" "Home" "--content" "Target block"] @@ -718,14 +718,14 @@ "[:find ?uuid :in $ ?title :where [?b :block/title ?title] [?b :block/uuid ?uuid]]" (pr-str ["Target block"])) target-uuid (first (first (get-in target-query-payload [:data :result]))) - add-block-result (run-cli ["--repo" "uuid-ref-graph" + add-block-result (run-cli ["--graph" "uuid-ref-graph" "upsert" "block" "--target-page" "Home" "--content" (str "See [[" target-uuid "]]")] data-dir cfg-path) add-block-payload (parse-json-output add-block-result) _ (p/delay 100) - list-page-result (run-cli ["--repo" "uuid-ref-graph" "list" "page"] data-dir cfg-path) + list-page-result (run-cli ["--graph" "uuid-ref-graph" "list" "page"] data-dir cfg-path) list-page-payload (parse-json-output list-page-result) page-titles (->> (get-in list-page-payload [:data :items]) (map #(or (:block/title %) (:title %))) @@ -738,7 +738,7 @@ (string/includes? % (str "[[" target-uuid "]]"))) %) titles) - stop-result (run-cli ["server" "stop" "--repo" "uuid-ref-graph"] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" "uuid-ref-graph"] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (string? target-uuid)) (is (= 0 (:exit-code add-block-result))) @@ -757,16 +757,16 @@ (let [data-dir (node-helper/create-tmp-dir "db-worker-missing-uuid-ref")] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" "missing-uuid-ref-graph"] data-dir cfg-path) - _ (run-cli ["--repo" "missing-uuid-ref-graph" "upsert" "page" "--page" "Home"] data-dir cfg-path) + _ (run-cli ["graph" "create" "--graph" "missing-uuid-ref-graph"] data-dir cfg-path) + _ (run-cli ["--graph" "missing-uuid-ref-graph" "upsert" "page" "--page" "Home"] data-dir cfg-path) missing-uuid (str (random-uuid)) - add-block-result (run-cli ["--repo" "missing-uuid-ref-graph" + add-block-result (run-cli ["--graph" "missing-uuid-ref-graph" "upsert" "block" "--target-page" "Home" "--content" (str "See [[" missing-uuid "]]")] data-dir cfg-path) add-block-payload (parse-json-output add-block-result) - stop-result (run-cli ["server" "stop" "--repo" "missing-uuid-ref-graph"] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" "missing-uuid-ref-graph"] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= 1 (:exit-code add-block-result))) (is (= "error" (:status add-block-payload))) @@ -781,14 +781,14 @@ (async done (let [data-dir (node-helper/create-tmp-dir "db-worker-tags")] (-> (p/let [{:keys [cfg-path repo]} (setup-tags-graph data-dir) - add-page-result (run-cli ["--repo" "tags-graph" + add-page-result (run-cli ["--graph" "tags-graph" "upsert" "page" "--page" "TaggedPage" "--update-tags" "[\"Quote\"]" "--update-properties" "{:logseq.property/publishing-public? true}"] data-dir cfg-path) add-page-payload (parse-json-output add-page-result) - add-block-result (run-cli ["--repo" "tags-graph" + add-block-result (run-cli ["--graph" "tags-graph" "upsert" "block" "--target-page" "Home" "--content" "Tagged block" @@ -796,7 +796,7 @@ "--update-properties" "{:logseq.property/deadline \"2026-01-25T12:00:00Z\"}"] data-dir cfg-path) add-block-payload (parse-json-output add-block-result) - add-block-ident-result (run-cli ["--repo" "tags-graph" + add-block-ident-result (run-cli ["--graph" "tags-graph" "upsert" "block" "--target-page" "Home" "--content" "Tagged block ident" @@ -805,13 +805,13 @@ add-block-ident-payload (parse-json-output add-block-ident-result) deadline-prop-title (get-in db-property/built-in-properties [:logseq.property/deadline :title]) publishing-prop-title (get-in db-property/built-in-properties [:logseq.property/publishing-public? :title]) - add-page-title-result (run-cli ["--repo" "tags-graph" + add-page-title-result (run-cli ["--graph" "tags-graph" "upsert" "page" "--page" "TaggedPageTitle" "--update-properties" (str "{\"" publishing-prop-title "\" true}")] data-dir cfg-path) add-page-title-payload (parse-json-output add-page-title-result) - add-block-title-result (run-cli ["--repo" "tags-graph" + add-block-title-result (run-cli ["--graph" "tags-graph" "upsert" "block" "--target-page" "Home" "--content" "Tagged block title" @@ -863,14 +863,14 @@ publishing-title (get-in db-property/built-in-properties [:logseq.property/publishing-public? :title]) deadline-id (find-item-id (get-in list-property-payload [:data :items]) deadline-title) publishing-id (find-item-id (get-in list-property-payload [:data :items]) publishing-title) - add-page-id-result (run-cli ["--repo" repo + add-page-id-result (run-cli ["--graph" repo "upsert" "page" "--page" "TaggedPageId" "--update-tags" (pr-str [quote-tag-id]) "--update-properties" (pr-str {publishing-id true})] data-dir cfg-path) add-page-id-payload (parse-json-output add-page-id-result) - add-block-id-result (run-cli ["--repo" repo + add-block-id-result (run-cli ["--graph" repo "upsert" "block" "--target-page" "Home" "--content" "Tagged block id" @@ -908,7 +908,7 @@ repo-id (command-core/resolve-repo repo)] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" repo] data-dir cfg-path) + _ (run-cli ["graph" "create" "--graph" repo] data-dir cfg-path) cfg (cli-config/resolve-config {:data-dir data-dir :config-path cfg-path :output-format :json}) @@ -965,13 +965,13 @@ repo "verbose-graph"] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" repo] data-dir cfg-path) + _ (run-cli ["graph" "create" "--graph" repo] data-dir cfg-path) {:keys [buffer restore!]} (capture-stderr!) - result (-> (run-cli ["--verbose" "--repo" repo "graph" "info"] data-dir cfg-path) + result (-> (run-cli ["--verbose" "--graph" repo "graph" "info"] data-dir cfg-path) (p/finally (fn [] (restore!)))) payload (parse-json-output-safe result "verbose graph info") stderr-text @buffer - _ (run-cli ["server" "stop" "--repo" repo] data-dir cfg-path)] + _ (run-cli ["server" "stop" "--graph" repo] data-dir cfg-path)] (is (= 0 (:exit-code result))) (is (= "ok" (:status payload))) (is (string/includes? stderr-text ":cli.transport/invoke")) @@ -986,7 +986,7 @@ (-> (p/let [{:keys [cfg-path repo]} (setup-tags-graph data-dir) tag-a-name "Quote" tag-b-name "Math" - add-block-result (run-cli ["--repo" repo + add-block-result (run-cli ["--graph" repo "upsert" "block" "--target-page" "Home" "--content" "Update block" @@ -995,11 +995,11 @@ data-dir cfg-path) add-block-payload (parse-json-output add-block-result) _ (p/delay 100) - show-home (run-cli ["--repo" repo "show" "--page" "Home"] data-dir cfg-path) + show-home (run-cli ["--graph" repo "show" "--page" "Home"] data-dir cfg-path) show-home-payload (parse-json-output show-home) block-node (find-block-by-title (get-in show-home-payload [:data :root]) "Update block") block-id (node-id block-node) - update-result (run-cli ["--repo" repo + update-result (run-cli ["--graph" repo "upsert" "block" "--id" (str block-id) "--update-tags" "[:logseq.class/Math-block]" @@ -1026,24 +1026,24 @@ (async done (let [data-dir (node-helper/create-tmp-dir "db-worker-upsert-block-custom-property")] (-> (p/let [{:keys [cfg-path repo]} (setup-tags-graph data-dir) - upsert-property-result (run-cli ["--repo" repo + upsert-property-result (run-cli ["--graph" repo "upsert" "property" "--name" "owner" "--type" "default"] data-dir cfg-path) upsert-property-payload (parse-json-output upsert-property-result) - add-block-result (run-cli ["--repo" repo + add-block-result (run-cli ["--graph" repo "upsert" "block" "--target-page" "Home" "--content" "Block with custom property"] data-dir cfg-path) add-block-payload (parse-json-output add-block-result) _ (p/delay 100) - show-home (run-cli ["--repo" repo "show" "--page" "Home"] data-dir cfg-path) + show-home (run-cli ["--graph" repo "show" "--page" "Home"] data-dir cfg-path) show-home-payload (parse-json-output show-home) block-node (find-block-by-title (get-in show-home-payload [:data :root]) "Block with custom property") block-id (node-id block-node) - update-result (run-cli ["--repo" repo + update-result (run-cli ["--graph" repo "upsert" "block" "--id" (str block-id) "--update-properties" "{:user.property/owner \"alice\"}"] @@ -1052,7 +1052,7 @@ _ (p/delay 100) property-after-update (query-property data-dir cfg-path repo "Block with custom property" ":user.property/owner") - remove-result (run-cli ["--repo" repo + remove-result (run-cli ["--graph" repo "upsert" "block" "--id" (str block-id) "--remove-properties" "[:user.property/owner]"] @@ -1084,20 +1084,20 @@ (let [data-dir (node-helper/create-tmp-dir "db-worker-tags-missing")] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" "tags-missing-graph"] data-dir cfg-path) - add-block-result (run-cli ["--repo" "tags-missing-graph" + _ (run-cli ["graph" "create" "--graph" "tags-missing-graph"] data-dir cfg-path) + add-block-result (run-cli ["--graph" "tags-missing-graph" "upsert" "block" "--target-page" "Home" "--content" "Block with missing tag" "--update-tags" "[\"MissingTag\"]"] data-dir cfg-path) add-block-payload (parse-json-output add-block-result) - list-tag-result (run-cli ["--repo" "tags-missing-graph" "list" "tag"] data-dir cfg-path) + list-tag-result (run-cli ["--graph" "tags-missing-graph" "list" "tag"] data-dir cfg-path) list-tag-payload (parse-json-output list-tag-result) tag-names (->> (get-in list-tag-payload [:data :items]) (map #(or (:block/title %) (:block/name %))) set) - stop-result (run-cli ["server" "stop" "--repo" "tags-missing-graph"] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" "tags-missing-graph"] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= "error" (:status add-block-payload))) (is (= :tag-not-found (keyword (get-in add-block-payload [:error :code])))) @@ -1114,19 +1114,19 @@ (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") repo "upsert-tag-create-graph" _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" repo] data-dir cfg-path) - _ (run-cli ["--repo" repo "upsert" "page" "--page" "Home"] data-dir cfg-path) - upsert-tag-result (run-cli ["--repo" repo + _ (run-cli ["graph" "create" "--graph" repo] data-dir cfg-path) + _ (run-cli ["--graph" repo "upsert" "page" "--page" "Home"] data-dir cfg-path) + upsert-tag-result (run-cli ["--graph" repo "upsert" "tag" "--name" "CliQuote"] data-dir cfg-path) upsert-tag-payload (parse-json-output upsert-tag-result) - list-tag-result (run-cli ["--repo" repo "list" "tag"] data-dir cfg-path) + list-tag-result (run-cli ["--graph" repo "list" "tag"] data-dir cfg-path) list-tag-payload (parse-json-output list-tag-result) tag-names (->> (get-in list-tag-payload [:data :items]) (map #(or (:block/title %) (:title %) (:name %))) set) - add-block-result (run-cli ["--repo" repo + add-block-result (run-cli ["--graph" repo "upsert" "block" "--target-page" "Home" "--content" "Tagged by upsert tag" @@ -1135,7 +1135,7 @@ add-block-payload (parse-json-output add-block-result) _ (p/delay 100) block-tag-names (query-tags data-dir cfg-path repo "Tagged by upsert tag") - stop-result (run-cli ["server" "stop" "--repo" repo] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" repo] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= 0 (:exit-code upsert-tag-result)) (pr-str (:error upsert-tag-payload))) @@ -1158,19 +1158,19 @@ (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") repo "upsert-tag-conflict-graph" _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" repo] data-dir cfg-path) - _ (run-cli ["--repo" repo "upsert" "page" "--page" "ConflictPage"] data-dir cfg-path) - upsert-tag-result (run-cli ["--repo" repo + _ (run-cli ["graph" "create" "--graph" repo] data-dir cfg-path) + _ (run-cli ["--graph" repo "upsert" "page" "--page" "ConflictPage"] data-dir cfg-path) + upsert-tag-result (run-cli ["--graph" repo "upsert" "tag" "--name" "ConflictPage"] data-dir cfg-path) upsert-tag-payload (parse-json-output upsert-tag-result) - list-tag-result (run-cli ["--repo" repo "list" "tag"] data-dir cfg-path) + list-tag-result (run-cli ["--graph" repo "list" "tag"] data-dir cfg-path) list-tag-payload (parse-json-output list-tag-result) tag-names (->> (get-in list-tag-payload [:data :items]) (map #(or (:block/title %) (:title %) (:name %))) set) - stop-result (run-cli ["server" "stop" "--repo" repo] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" repo] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= 0 (:exit-code upsert-tag-result))) (is (= "error" (:status upsert-tag-payload))) @@ -1189,18 +1189,18 @@ (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") repo "upsert-tag-idempotent-graph" _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" repo] data-dir cfg-path) - first-upsert-result (run-cli ["--repo" repo "upsert" "tag" "--name" "StableTag"] + _ (run-cli ["graph" "create" "--graph" repo] data-dir cfg-path) + first-upsert-result (run-cli ["--graph" repo "upsert" "tag" "--name" "StableTag"] data-dir cfg-path) first-upsert-payload (parse-json-output first-upsert-result) - second-upsert-result (run-cli ["--repo" repo "upsert" "tag" "--name" "StableTag"] + second-upsert-result (run-cli ["--graph" repo "upsert" "tag" "--name" "StableTag"] data-dir cfg-path) second-upsert-payload (parse-json-output second-upsert-result) - list-tag-result (run-cli ["--repo" repo "list" "tag"] data-dir cfg-path) + list-tag-result (run-cli ["--graph" repo "list" "tag"] data-dir cfg-path) list-tag-payload (parse-json-output list-tag-result) stable-tags (->> (get-in list-tag-payload [:data :items]) (filter #(= "StableTag" (or (:block/title %) (:title %) (:name %))))) - stop-result (run-cli ["server" "stop" "--repo" repo] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" repo] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= 0 (:exit-code first-upsert-result))) (is (= "ok" (:status first-upsert-payload))) @@ -1221,18 +1221,18 @@ source-name "CliRenameSource" target-name "CliRenameTarget" _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" repo] data-dir cfg-path) - create-result (run-cli ["--repo" repo "upsert" "tag" "--name" source-name] + _ (run-cli ["graph" "create" "--graph" repo] data-dir cfg-path) + create-result (run-cli ["--graph" repo "upsert" "tag" "--name" source-name] data-dir cfg-path) create-payload (parse-json-output create-result) source-id (first-result-id create-payload) - rename-result (run-cli ["--repo" repo + rename-result (run-cli ["--graph" repo "upsert" "tag" "--id" (str source-id) "--name" target-name] data-dir cfg-path) rename-payload (parse-json-output rename-result) - list-tag-result (run-cli ["--repo" repo "list" "tag"] data-dir cfg-path) + list-tag-result (run-cli ["--graph" repo "list" "tag"] data-dir cfg-path) list-tag-payload (parse-json-output list-tag-result) tags (get-in list-tag-payload [:data :items]) tag-names (->> tags @@ -1240,7 +1240,7 @@ set) target-id (find-item-id tags target-name) source-id-after (find-item-id tags source-name) - stop-result (run-cli ["server" "stop" "--repo" repo] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" repo] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= 0 (:exit-code create-result))) (is (= "ok" (:status create-payload))) @@ -1268,26 +1268,26 @@ source-name "CliRenameConflictSource" existing-name "CliRenameConflictExisting" _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" repo] data-dir cfg-path) - source-upsert-result (run-cli ["--repo" repo "upsert" "tag" "--name" source-name] + _ (run-cli ["graph" "create" "--graph" repo] data-dir cfg-path) + source-upsert-result (run-cli ["--graph" repo "upsert" "tag" "--name" source-name] data-dir cfg-path) source-upsert-payload (parse-json-output source-upsert-result) source-id (first-result-id source-upsert-payload) - existing-upsert-result (run-cli ["--repo" repo "upsert" "tag" "--name" existing-name] + existing-upsert-result (run-cli ["--graph" repo "upsert" "tag" "--name" existing-name] data-dir cfg-path) existing-upsert-payload (parse-json-output existing-upsert-result) - rename-result (run-cli ["--repo" repo + rename-result (run-cli ["--graph" repo "upsert" "tag" "--id" (str source-id) "--name" existing-name] data-dir cfg-path) rename-payload (parse-json-output rename-result) - list-tag-result (run-cli ["--repo" repo "list" "tag"] data-dir cfg-path) + list-tag-result (run-cli ["--graph" repo "list" "tag"] data-dir cfg-path) list-tag-payload (parse-json-output list-tag-result) tag-names (->> (get-in list-tag-payload [:data :items]) (map #(or (:block/title %) (:title %) (:name %))) set) - stop-result (run-cli ["server" "stop" "--repo" repo] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" repo] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= 0 (:exit-code source-upsert-result))) (is (= "ok" (:status source-upsert-payload))) @@ -1314,17 +1314,17 @@ property-name "CliOwnerPropX" property-name-lc (common-util/page-name-sanity-lc property-name) _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" repo] data-dir cfg-path) - upsert-tag-result (run-cli ["--repo" repo "upsert" "tag" "--name" tag-name] data-dir cfg-path) + _ (run-cli ["graph" "create" "--graph" repo] data-dir cfg-path) + upsert-tag-result (run-cli ["--graph" repo "upsert" "tag" "--name" tag-name] data-dir cfg-path) upsert-tag-payload (parse-json-output upsert-tag-result) - upsert-property-result (run-cli ["--repo" repo + upsert-property-result (run-cli ["--graph" repo "upsert" "property" "--name" property-name "--type" "node" "--cardinality" "many"] data-dir cfg-path) upsert-property-payload (parse-json-output upsert-property-result) - update-property-result (run-cli ["--repo" repo + update-property-result (run-cli ["--graph" repo "upsert" "property" "--name" property-name "--type" "node" @@ -1334,13 +1334,13 @@ property-schema-before-remove (run-query data-dir cfg-path repo "[:find ?type ?cardinality :in $ ?name :where [?p :block/name ?name] [?p :logseq.property/type ?type] [?p :db/cardinality ?cardinality]]" (pr-str [property-name-lc])) - remove-tag-result (run-cli ["--repo" repo "remove" "tag" "--name" tag-name] data-dir cfg-path) + remove-tag-result (run-cli ["--graph" repo "remove" "tag" "--name" tag-name] data-dir cfg-path) remove-tag-payload (parse-json-output remove-tag-result) - remove-property-result (run-cli ["--repo" repo "remove" "property" "--name" property-name] data-dir cfg-path) + remove-property-result (run-cli ["--graph" repo "remove" "property" "--name" property-name] data-dir cfg-path) remove-property-payload (parse-json-output remove-property-result) - list-tag-result (run-cli ["--repo" repo "list" "tag"] data-dir cfg-path) + list-tag-result (run-cli ["--graph" repo "list" "tag"] data-dir cfg-path) list-tag-payload (parse-json-output list-tag-result) - list-property-result (run-cli ["--repo" repo "list" "property"] data-dir cfg-path) + list-property-result (run-cli ["--graph" repo "list" "property"] data-dir cfg-path) list-property-payload (parse-json-output list-property-result) tag-names (->> (get-in list-tag-payload [:data :items]) (map #(or (:block/title %) (:title %) (:name %))) @@ -1348,7 +1348,7 @@ property-names (->> (get-in list-property-payload [:data :items]) (map #(or (:block/title %) (:title %) (:name %))) set) - stop-result (run-cli ["server" "stop" "--repo" repo] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" repo] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= 0 (:exit-code upsert-tag-result))) (is (= "ok" (:status upsert-tag-payload))) @@ -1378,26 +1378,26 @@ query-text "[:find ?e :in $ ?title :where [?e :block/title ?title]]"] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - create-result (run-cli ["graph" "create" "--repo" "query-graph"] data-dir cfg-path) + create-result (run-cli ["graph" "create" "--graph" "query-graph"] data-dir cfg-path) create-payload (parse-json-output create-result) - _ (run-cli ["--repo" "query-graph" "upsert" "page" "--page" "QueryPage"] data-dir cfg-path) - _ (run-cli ["--repo" "query-graph" "upsert" "block" + _ (run-cli ["--graph" "query-graph" "upsert" "page" "--page" "QueryPage"] data-dir cfg-path) + _ (run-cli ["--graph" "query-graph" "upsert" "block" "--target-page" "QueryPage" "--content" "Query block"] data-dir cfg-path) - _ (run-cli ["--repo" "query-graph" "upsert" "block" + _ (run-cli ["--graph" "query-graph" "upsert" "block" "--target-page" "QueryPage" "--content" "Query block"] data-dir cfg-path) _ (p/delay 100) - query-result (run-cli ["--repo" "query-graph" + query-result (run-cli ["--graph" "query-graph" "query" "--query" query-text "--inputs" "[\"Query block\"]"] data-dir cfg-path) query-payload (parse-json-output query-result) result (get-in query-payload [:data :result]) - stop-result (run-cli ["server" "stop" "--repo" "query-graph"] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" "query-graph"] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= "ok" (:status create-payload))) (is (= 0 (:exit-code query-result))) @@ -1415,22 +1415,22 @@ (let [data-dir (node-helper/create-tmp-dir "db-worker-task-query")] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - create-result (run-cli ["graph" "create" "--repo" "task-query-graph"] data-dir cfg-path) + create-result (run-cli ["graph" "create" "--graph" "task-query-graph"] data-dir cfg-path) create-payload (parse-json-output create-result) - _ (run-cli ["--repo" "task-query-graph" "upsert" "page" "--page" "Tasks"] data-dir cfg-path) - _ (run-cli ["--repo" "task-query-graph" + _ (run-cli ["--graph" "task-query-graph" "upsert" "page" "--page" "Tasks"] data-dir cfg-path) + _ (run-cli ["--graph" "task-query-graph" "upsert" "block" "--target-page" "Tasks" "--content" "Task one" "--status" "doing"] data-dir cfg-path) - _ (run-cli ["--repo" "task-query-graph" + _ (run-cli ["--graph" "task-query-graph" "upsert" "block" "--target-page" "Tasks" "--content" "Task two" "--status" "doing"] data-dir cfg-path) - _ (run-cli ["--repo" "task-query-graph" + _ (run-cli ["--graph" "task-query-graph" "upsert" "block" "--target-page" "Tasks" "--content" "Task three" @@ -1442,13 +1442,13 @@ task-entry (some (fn [entry] (when (= "task-search" (:name entry)) entry)) (get-in list-payload [:data :queries])) - query-result (run-cli ["--repo" "task-query-graph" + query-result (run-cli ["--graph" "task-query-graph" "query" "--name" "task-search" "--inputs" "[\"doing\"]"] data-dir cfg-path) query-payload (parse-json-output query-result) - query-nil-result (run-cli ["--repo" "task-query-graph" + query-nil-result (run-cli ["--graph" "task-query-graph" "query" "--name" "task-search" "--inputs" "[\"doing\" nil 1]"] @@ -1456,7 +1456,7 @@ query-nil-payload (parse-json-output query-nil-result) result (get-in query-payload [:data :result]) nil-result (get-in query-nil-payload [:data :result]) - stop-result (run-cli ["server" "stop" "--repo" "task-query-graph"] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" "task-query-graph"] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= "ok" (:status create-payload))) (is (= "ok" (:status list-payload))) @@ -1483,25 +1483,25 @@ (let [data-dir (node-helper/create-tmp-dir "db-worker-status-query")] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - create-result (run-cli ["graph" "create" "--repo" "status-query-graph"] data-dir cfg-path) + create-result (run-cli ["graph" "create" "--graph" "status-query-graph"] data-dir cfg-path) create-payload (parse-json-output create-result) _ (p/delay 100) list-result (run-cli ["query" "list"] data-dir cfg-path) list-payload (parse-json-output list-result) names (set (map :name (get-in list-payload [:data :queries]))) - status-result (run-cli ["--repo" "status-query-graph" + status-result (run-cli ["--graph" "status-query-graph" "query" "--name" "list-status"] data-dir cfg-path) status-payload (parse-json-output status-result) status-values (get-in status-payload [:data :result]) - priority-result (run-cli ["--repo" "status-query-graph" + priority-result (run-cli ["--graph" "status-query-graph" "query" "--name" "list-priority"] data-dir cfg-path) priority-payload (parse-json-output priority-result) priority-values (get-in priority-payload [:data :result]) - stop-result (run-cli ["server" "stop" "--repo" "status-query-graph"] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" "status-query-graph"] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= "ok" (:status create-payload))) (is (= "ok" (:status list-payload))) @@ -1536,21 +1536,21 @@ (let [data-dir (node-helper/create-tmp-dir "db-worker-recent-updated")] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" "recent-updated-graph"] data-dir cfg-path) - _ (run-cli ["--repo" "recent-updated-graph" "upsert" "page" "--page" "RecentPage"] data-dir cfg-path) - _ (run-cli ["--repo" "recent-updated-graph" "upsert" "block" + _ (run-cli ["graph" "create" "--graph" "recent-updated-graph"] data-dir cfg-path) + _ (run-cli ["--graph" "recent-updated-graph" "upsert" "page" "--page" "RecentPage"] data-dir cfg-path) + _ (run-cli ["--graph" "recent-updated-graph" "upsert" "block" "--target-page" "RecentPage" "--content" "Recent block"] data-dir cfg-path) _ (p/delay 100) - list-page-result (run-cli ["--repo" "recent-updated-graph" "list" "page" "--expand"] data-dir cfg-path) + list-page-result (run-cli ["--graph" "recent-updated-graph" "list" "page" "--expand"] data-dir cfg-path) list-page-payload (parse-json-output list-page-result) page-item (some (fn [item] (when (= "RecentPage" (or (:block/title item) (:title item))) item)) (get-in list-page-payload [:data :items])) page-id (or (:db/id page-item) (:id page-item)) - show-result (run-cli ["--repo" "recent-updated-graph" + show-result (run-cli ["--graph" "recent-updated-graph" "show" "--page" "RecentPage"] data-dir cfg-path) @@ -1564,7 +1564,7 @@ (when (= "recent-updated" (:name entry)) entry)) (get-in list-payload [:data :queries])) now-ms (js/Date.now) - query-result (run-cli ["--repo" "recent-updated-graph" + query-result (run-cli ["--graph" "recent-updated-graph" "query" "--name" "recent-updated" "--inputs" (pr-str [1 now-ms])] @@ -1572,32 +1572,32 @@ query-payload (parse-json-output query-result) result (get-in query-payload [:data :result]) future-now-ms (+ now-ms (* 10 86400000)) - future-query-result (run-cli ["--repo" "recent-updated-graph" + future-query-result (run-cli ["--graph" "recent-updated-graph" "query" "--name" "recent-updated" "--inputs" (pr-str [1 future-now-ms])] data-dir cfg-path) future-query-payload (parse-json-output future-query-result) future-result (get-in future-query-payload [:data :result]) - zero-result (run-cli ["--repo" "recent-updated-graph" + zero-result (run-cli ["--graph" "recent-updated-graph" "query" "--name" "recent-updated" "--inputs" "[0]"] data-dir cfg-path) zero-payload (parse-json-output zero-result) - nil-result (run-cli ["--repo" "recent-updated-graph" + nil-result (run-cli ["--graph" "recent-updated-graph" "query" "--name" "recent-updated" "--inputs" "[nil]"] data-dir cfg-path) nil-payload (parse-json-output nil-result) - neg-result (run-cli ["--repo" "recent-updated-graph" + neg-result (run-cli ["--graph" "recent-updated-graph" "query" "--name" "recent-updated" "--inputs" "[-1]"] data-dir cfg-path) neg-payload (parse-json-output neg-result) - stop-result (run-cli ["server" "stop" "--repo" "recent-updated-graph"] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" "recent-updated-graph"] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= "ok" (:status list-page-payload))) (is (some? page-id)) @@ -1633,26 +1633,26 @@ (let [data-dir (node-helper/create-tmp-dir "db-worker-nested-refs")] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" "nested-refs"] data-dir cfg-path) - _ (run-cli ["--repo" "nested-refs" "upsert" "page" "--page" "NestedPage"] data-dir cfg-path) - _ (run-cli ["--repo" "nested-refs" "upsert" "block" "--target-page" "NestedPage" "--content" "Inner"] data-dir cfg-path) - show-nested (run-cli ["--repo" "nested-refs" "show" "--page" "NestedPage"] data-dir cfg-path) + _ (run-cli ["graph" "create" "--graph" "nested-refs"] data-dir cfg-path) + _ (run-cli ["--graph" "nested-refs" "upsert" "page" "--page" "NestedPage"] data-dir cfg-path) + _ (run-cli ["--graph" "nested-refs" "upsert" "block" "--target-page" "NestedPage" "--content" "Inner"] data-dir cfg-path) + show-nested (run-cli ["--graph" "nested-refs" "show" "--page" "NestedPage"] data-dir cfg-path) show-nested-payload (parse-json-output show-nested) _inner-node (find-block-by-title (get-in show-nested-payload [:data :root]) "Inner") inner-uuid (query-block-uuid-by-title data-dir cfg-path "nested-refs" "Inner") middle-content (str "See [[" inner-uuid "]]") - _ (run-cli ["--repo" "nested-refs" "upsert" "block" "--target-page" "NestedPage" + _ (run-cli ["--graph" "nested-refs" "upsert" "block" "--target-page" "NestedPage" "--content" middle-content] data-dir cfg-path) - show-middle (run-cli ["--repo" "nested-refs" "show" "--page" "NestedPage"] data-dir cfg-path) + show-middle (run-cli ["--graph" "nested-refs" "show" "--page" "NestedPage"] data-dir cfg-path) show-middle-payload (parse-json-output show-middle) _middle-node (find-block-by-title (get-in show-middle-payload [:data :root]) middle-content) middle-uuid (query-block-uuid-by-title data-dir cfg-path "nested-refs" middle-content) - _ (run-cli ["--repo" "nested-refs" "upsert" "block" "--target-page" "NestedPage" + _ (run-cli ["--graph" "nested-refs" "upsert" "block" "--target-page" "NestedPage" "--content" (str "Outer [[" middle-uuid "]]")] data-dir cfg-path) - show-outer (run-cli ["--repo" "nested-refs" "show" "--page" "NestedPage"] data-dir cfg-path) + show-outer (run-cli ["--graph" "nested-refs" "show" "--page" "NestedPage"] data-dir cfg-path) show-outer-payload (parse-json-output show-outer) outer-node (find-block-by-title (get-in show-outer-payload [:data :root]) "Outer [[See [[Inner]]]]") - stop-result (run-cli ["server" "stop" "--repo" "nested-refs"] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" "nested-refs"] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (some? inner-uuid)) (is (some? middle-uuid)) @@ -1669,22 +1669,22 @@ (let [data-dir (node-helper/create-tmp-dir "db-worker-linked-refs")] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" "linked-refs-graph"] data-dir cfg-path) - _ (run-cli ["--repo" "linked-refs-graph" "upsert" "page" "--page" "TargetPage"] data-dir cfg-path) - _ (run-cli ["--repo" "linked-refs-graph" "upsert" "page" "--page" "SourcePage"] data-dir cfg-path) - target-show (run-cli ["--repo" "linked-refs-graph" "show" "--page" "TargetPage"] data-dir cfg-path) + _ (run-cli ["graph" "create" "--graph" "linked-refs-graph"] data-dir cfg-path) + _ (run-cli ["--graph" "linked-refs-graph" "upsert" "page" "--page" "TargetPage"] data-dir cfg-path) + _ (run-cli ["--graph" "linked-refs-graph" "upsert" "page" "--page" "SourcePage"] data-dir cfg-path) + target-show (run-cli ["--graph" "linked-refs-graph" "show" "--page" "TargetPage"] data-dir cfg-path) _target-show-payload (parse-json-output target-show) target-uuid (query-block-uuid-by-title data-dir cfg-path "linked-refs-graph" "TargetPage") target-title "TargetPage" ref-content (str "See [[" target-uuid "]]") ref-title (str "See [[" target-title "]]") - _ (run-cli ["--repo" "linked-refs-graph" "upsert" "block" "--target-page" "SourcePage" "--content" ref-content] data-dir cfg-path) + _ (run-cli ["--graph" "linked-refs-graph" "upsert" "block" "--target-page" "SourcePage" "--content" ref-content] data-dir cfg-path) _ (p/delay 100) - source-show (run-cli ["--repo" "linked-refs-graph" "show" "--page" "SourcePage"] data-dir cfg-path) + source-show (run-cli ["--graph" "linked-refs-graph" "show" "--page" "SourcePage"] data-dir cfg-path) source-payload (parse-json-output source-show) ref-node (find-block-by-title (get-in source-payload [:data :root]) ref-title) ref-id (or (:db/id ref-node) (:id ref-node)) - target-show (run-cli ["--repo" "linked-refs-graph" "show" "--page" "TargetPage"] data-dir cfg-path) + target-show (run-cli ["--graph" "linked-refs-graph" "show" "--page" "TargetPage"] data-dir cfg-path) target-payload (parse-json-output target-show) linked-refs (get-in target-payload [:data :linked-references]) linked-blocks (:blocks linked-refs) @@ -1695,7 +1695,7 @@ (get-in block [:page :title]) (get-in block [:page :name]))) linked-blocks)) - stop-result (run-cli ["server" "stop" "--repo" "linked-refs-graph"] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" "linked-refs-graph"] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (some? target-uuid)) (is (= "ok" (:status target-payload))) @@ -1713,23 +1713,23 @@ (let [data-dir (node-helper/create-tmp-dir "db-worker-move")] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" "move-graph"] data-dir cfg-path) - _ (run-cli ["--repo" "move-graph" "upsert" "page" "--page" "SourcePage"] data-dir cfg-path) - _ (run-cli ["--repo" "move-graph" "upsert" "page" "--page" "TargetPage"] data-dir cfg-path) - _ (run-cli ["--repo" "move-graph" "upsert" "block" "--target-page" "SourcePage" "--content" "Parent Block"] data-dir cfg-path) + _ (run-cli ["graph" "create" "--graph" "move-graph"] data-dir cfg-path) + _ (run-cli ["--graph" "move-graph" "upsert" "page" "--page" "SourcePage"] data-dir cfg-path) + _ (run-cli ["--graph" "move-graph" "upsert" "page" "--page" "TargetPage"] data-dir cfg-path) + _ (run-cli ["--graph" "move-graph" "upsert" "block" "--target-page" "SourcePage" "--content" "Parent Block"] data-dir cfg-path) _ (p/delay 100) - source-show (run-cli ["--repo" "move-graph" "show" "--page" "SourcePage"] data-dir cfg-path) + source-show (run-cli ["--graph" "move-graph" "show" "--page" "SourcePage"] data-dir cfg-path) source-payload (parse-json-output source-show) parent-node (find-block-by-title (get-in source-payload [:data :root]) "Parent Block") parent-id (node-id parent-node) - _ (run-cli ["--repo" "move-graph" "upsert" "block" "--target-id" (str parent-id) "--content" "Child Block"] data-dir cfg-path) - update-result (run-cli ["--repo" "move-graph" "upsert" "block" "--id" (str parent-id) "--target-page" "TargetPage"] data-dir cfg-path) + _ (run-cli ["--graph" "move-graph" "upsert" "block" "--target-id" (str parent-id) "--content" "Child Block"] data-dir cfg-path) + update-result (run-cli ["--graph" "move-graph" "upsert" "block" "--id" (str parent-id) "--target-page" "TargetPage"] data-dir cfg-path) update-payload (parse-json-output update-result) - target-show (run-cli ["--repo" "move-graph" "show" "--page" "TargetPage"] data-dir cfg-path) + target-show (run-cli ["--graph" "move-graph" "show" "--page" "TargetPage"] data-dir cfg-path) target-payload (parse-json-output target-show) moved-node (find-block-by-title (get-in target-payload [:data :root]) "Parent Block") child-node (find-block-by-title moved-node "Child Block") - stop-result (run-cli ["server" "stop" "--repo" "move-graph"] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" "move-graph"] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= "ok" (:status update-payload))) (is (some? parent-id)) @@ -1746,21 +1746,21 @@ (let [data-dir (node-helper/create-tmp-dir "db-worker-add-pos")] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" "add-pos-graph"] data-dir cfg-path) - _ (run-cli ["--repo" "add-pos-graph" "upsert" "page" "--page" "PosPage"] data-dir cfg-path) - _ (run-cli ["--repo" "add-pos-graph" "upsert" "block" "--target-page" "PosPage" "--content" "Parent"] data-dir cfg-path) + _ (run-cli ["graph" "create" "--graph" "add-pos-graph"] data-dir cfg-path) + _ (run-cli ["--graph" "add-pos-graph" "upsert" "page" "--page" "PosPage"] data-dir cfg-path) + _ (run-cli ["--graph" "add-pos-graph" "upsert" "block" "--target-page" "PosPage" "--content" "Parent"] data-dir cfg-path) _ (p/delay 100) - parent-show (run-cli ["--repo" "add-pos-graph" "show" "--page" "PosPage"] data-dir cfg-path) + parent-show (run-cli ["--graph" "add-pos-graph" "show" "--page" "PosPage"] data-dir cfg-path) parent-payload (parse-json-output parent-show) parent-node (find-block-by-title (get-in parent-payload [:data :root]) "Parent") parent-id (node-id parent-node) - _ (run-cli ["--repo" "add-pos-graph" "upsert" "block" "--target-id" (str parent-id) "--pos" "first-child" "--content" "First"] data-dir cfg-path) - _ (run-cli ["--repo" "add-pos-graph" "upsert" "block" "--target-id" (str parent-id) "--pos" "last-child" "--content" "Last"] data-dir cfg-path) - final-show (run-cli ["--repo" "add-pos-graph" "show" "--page" "PosPage"] data-dir cfg-path) + _ (run-cli ["--graph" "add-pos-graph" "upsert" "block" "--target-id" (str parent-id) "--pos" "first-child" "--content" "First"] data-dir cfg-path) + _ (run-cli ["--graph" "add-pos-graph" "upsert" "block" "--target-id" (str parent-id) "--pos" "last-child" "--content" "Last"] data-dir cfg-path) + final-show (run-cli ["--graph" "add-pos-graph" "show" "--page" "PosPage"] data-dir cfg-path) final-payload (parse-json-output final-show) final-parent (find-block-by-title (get-in final-payload [:data :root]) "Parent") child-titles (map node-title (node-children final-parent)) - stop-result (run-cli ["server" "stop" "--repo" "add-pos-graph"] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" "add-pos-graph"] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (some? parent-id)) (is (= ["First" "Last"] (vec child-titles))) @@ -1794,7 +1794,7 @@ (let [data-dir (node-helper/create-tmp-dir "db-worker")] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" "list-id-graph"] data-dir cfg-path) + _ (run-cli ["graph" "create" "--graph" "list-id-graph"] data-dir cfg-path) _ (run-cli ["upsert" "page" "--page" "TestPage"] data-dir cfg-path) list-page-result (run-cli ["list" "page"] data-dir cfg-path) list-page-payload (parse-json-output list-page-result) @@ -1802,7 +1802,7 @@ list-tag-payload (parse-json-output list-tag-result) list-property-result (run-cli ["list" "property"] data-dir cfg-path) list-property-payload (parse-json-output list-property-result) - stop-result (run-cli ["server" "stop" "--repo" "list-id-graph"] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" "list-id-graph"] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= "ok" (:status list-page-payload))) (is (every? #(contains? % :id) (get-in list-page-payload [:data :items]))) @@ -1821,7 +1821,7 @@ (let [data-dir (node-helper/create-tmp-dir "db-worker")] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" "human-list-graph"] data-dir cfg-path) + _ (run-cli ["graph" "create" "--graph" "human-list-graph"] data-dir cfg-path) _ (run-cli ["upsert" "page" "--page" "TestPage"] data-dir cfg-path) list-page-result (run-cli ["list" "page" "--output" "human"] data-dir cfg-path) output (:output list-page-result)] @@ -1839,7 +1839,7 @@ (let [data-dir (node-helper/create-tmp-dir "db-worker")] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" "show-page-block-graph"] data-dir cfg-path) + _ (run-cli ["graph" "create" "--graph" "show-page-block-graph"] data-dir cfg-path) _ (run-cli ["upsert" "page" "--page" "TestPage"] data-dir cfg-path) list-page-result (run-cli ["list" "page" "--expand"] data-dir cfg-path) list-page-payload (parse-json-output list-page-result) @@ -1853,7 +1853,7 @@ show-by-id-payload (parse-json-output show-by-id-result) show-by-uuid-result (run-cli ["show" "--uuid" (str page-uuid)] data-dir cfg-path) show-by-uuid-payload (parse-json-output show-by-uuid-result) - stop-result (run-cli ["server" "stop" "--repo" "show-page-block-graph"] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" "show-page-block-graph"] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= "ok" (:status list-page-payload))) (is (some? page-item)) @@ -1878,33 +1878,33 @@ (let [data-dir (node-helper/create-tmp-dir "db-worker-multi-id")] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" "show-multi-id-graph"] data-dir cfg-path) - _ (run-cli ["--repo" "show-multi-id-graph" "upsert" "page" "--page" "MultiPage"] + _ (run-cli ["graph" "create" "--graph" "show-multi-id-graph"] data-dir cfg-path) + _ (run-cli ["--graph" "show-multi-id-graph" "upsert" "page" "--page" "MultiPage"] data-dir cfg-path) - _ (run-cli ["--repo" "show-multi-id-graph" "upsert" "block" + _ (run-cli ["--graph" "show-multi-id-graph" "upsert" "block" "--target-page" "MultiPage" "--content" "Multi show one"] data-dir cfg-path) - _ (run-cli ["--repo" "show-multi-id-graph" "upsert" "block" + _ (run-cli ["--graph" "show-multi-id-graph" "upsert" "block" "--target-page" "MultiPage" "--content" "Multi show two"] data-dir cfg-path) _ (p/delay 100) query-text "[:find ?e . :in $ ?title :where [?e :block/title ?title]]" - query-one-result (run-cli ["--repo" "show-multi-id-graph" "query" + query-one-result (run-cli ["--graph" "show-multi-id-graph" "query" "--query" query-text "--inputs" (pr-str ["Multi show one"])] data-dir cfg-path) query-one-payload (parse-json-output query-one-result) block-one-id (get-in query-one-payload [:data :result]) - query-two-result (run-cli ["--repo" "show-multi-id-graph" "query" + query-two-result (run-cli ["--graph" "show-multi-id-graph" "query" "--query" query-text "--inputs" (pr-str ["Multi show two"])] data-dir cfg-path) query-two-payload (parse-json-output query-two-result) block-two-id (get-in query-two-payload [:data :result]) ids-edn (str "[" block-one-id " " block-two-id "]") - show-text-result (run-cli ["--repo" "show-multi-id-graph" "show" + show-text-result (run-cli ["--graph" "show-multi-id-graph" "show" "--id" ids-edn "--output" "human"] @@ -1913,13 +1913,13 @@ idx-one (string/index-of output "Multi show one") idx-two (string/index-of output "Multi show two") idx-delim (string/index-of output "================================================================") - show-json-result (run-cli ["--repo" "show-multi-id-graph" "show" + show-json-result (run-cli ["--graph" "show-multi-id-graph" "show" "--id" ids-edn] data-dir cfg-path) show-json-payload (parse-json-output show-json-result) show-data (:data show-json-payload) root-titles (set (map (comp node-title :root) show-data)) - stop-result (run-cli ["server" "stop" "--repo" "show-multi-id-graph"] + stop-result (run-cli ["server" "stop" "--graph" "show-multi-id-graph"] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= 0 (:exit-code query-one-result))) @@ -1950,25 +1950,25 @@ (let [data-dir (node-helper/create-tmp-dir "db-worker-multi-id-contained")] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" "show-multi-id-contained-graph"] data-dir cfg-path) - _ (run-cli ["--repo" "show-multi-id-contained-graph" "upsert" "page" "--page" "ParentPage"] + _ (run-cli ["graph" "create" "--graph" "show-multi-id-contained-graph"] data-dir cfg-path) + _ (run-cli ["--graph" "show-multi-id-contained-graph" "upsert" "page" "--page" "ParentPage"] data-dir cfg-path) - _ (run-cli ["--repo" "show-multi-id-contained-graph" "upsert" "block" + _ (run-cli ["--graph" "show-multi-id-contained-graph" "upsert" "block" "--target-page" "ParentPage" "--content" "Parent Block"] data-dir cfg-path) - parent-query (run-cli ["--repo" "show-multi-id-contained-graph" "query" + parent-query (run-cli ["--graph" "show-multi-id-contained-graph" "query" "--query" "[:find ?e . :in $ ?title :where [?e :block/title ?title]]" "--inputs" (pr-str ["Parent Block"])] data-dir cfg-path) parent-payload (parse-json-output parent-query) parent-id (get-in parent-payload [:data :result]) - _ (run-cli ["--repo" "show-multi-id-contained-graph" "upsert" "block" + _ (run-cli ["--graph" "show-multi-id-contained-graph" "upsert" "block" "--target-id" (str parent-id) "--content" "Child Block"] data-dir cfg-path) _ (p/delay 100) - show-children (run-cli ["--repo" "show-multi-id-contained-graph" + show-children (run-cli ["--graph" "show-multi-id-contained-graph" "show" "--page" "ParentPage"] data-dir cfg-path) @@ -1976,13 +1976,13 @@ child-node (find-block-by-title (get-in show-children-payload [:data :root]) "Child Block") child-id (or (:db/id child-node) (:id child-node)) ids-edn (str "[" parent-id " " child-id "]") - show-json-result (run-cli ["--repo" "show-multi-id-contained-graph" "show" + show-json-result (run-cli ["--graph" "show-multi-id-contained-graph" "show" "--id" ids-edn] data-dir cfg-path) show-json-payload (parse-json-output show-json-result) show-data (:data show-json-payload) root-titles (set (map (comp node-title :root) show-data)) - stop-result (run-cli ["server" "stop" "--repo" "show-multi-id-contained-graph"] + stop-result (run-cli ["server" "stop" "--graph" "show-multi-id-contained-graph"] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= 0 (:exit-code parent-query))) @@ -2004,14 +2004,14 @@ (let [data-dir (node-helper/create-tmp-dir "db-worker-query-pipe")] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" "query-pipe-graph"] data-dir cfg-path) - _ (run-cli ["--repo" "query-pipe-graph" "upsert" "page" "--page" "PipePage"] + _ (run-cli ["graph" "create" "--graph" "query-pipe-graph"] data-dir cfg-path) + _ (run-cli ["--graph" "query-pipe-graph" "upsert" "page" "--page" "PipePage"] data-dir cfg-path) - _ (run-cli ["--repo" "query-pipe-graph" "upsert" "block" + _ (run-cli ["--graph" "query-pipe-graph" "upsert" "block" "--target-page" "PipePage" "--content" "Pipe One"] data-dir cfg-path) - _ (run-cli ["--repo" "query-pipe-graph" "upsert" "block" + _ (run-cli ["--graph" "query-pipe-graph" "upsert" "block" "--target-page" "PipePage" "--content" "Pipe Two"] data-dir cfg-path) @@ -2021,14 +2021,14 @@ " :where" " [?e :block/title ?title]" " [(clojure.string/includes? ?title ?q)]]") - query-json-result (run-cli ["--repo" "query-pipe-graph" + query-json-result (run-cli ["--graph" "query-pipe-graph" "query" "--query" query-text "--inputs" (pr-str ["Pipe"])] data-dir cfg-path) query-json-payload (parse-json-output query-json-result) query-ids (get-in query-json-payload [:data :result]) - query-human-result (run-cli ["--repo" "query-pipe-graph" + query-human-result (run-cli ["--graph" "query-pipe-graph" "--output" "human" "query" "--query" query-text @@ -2046,7 +2046,7 @@ [node-bin cli-bin "--data-dir" data-arg "--config" cfg-arg - "--repo" repo-arg + "--graph" repo-arg "--output" "human" "query" "--query" query-arg @@ -2055,13 +2055,13 @@ [node-bin cli-bin "--data-dir" data-arg "--config" cfg-arg - "--repo" repo-arg + "--graph" repo-arg "--output" "human" "show" "--id"]) pipeline (str query-cmd " | xargs -I{} " show-cmd " {}") output (run-shell pipeline) - stop-result (run-cli ["server" "stop" "--repo" "query-pipe-graph"] + stop-result (run-cli ["server" "stop" "--graph" "query-pipe-graph"] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= (pr-str query-ids) query-human-output)) @@ -2078,14 +2078,14 @@ (let [data-dir (node-helper/create-tmp-dir "db-worker-query-stdin")] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" "query-stdin-graph"] data-dir cfg-path) - _ (run-cli ["--repo" "query-stdin-graph" "upsert" "page" "--page" "PipePage"] + _ (run-cli ["graph" "create" "--graph" "query-stdin-graph"] data-dir cfg-path) + _ (run-cli ["--graph" "query-stdin-graph" "upsert" "page" "--page" "PipePage"] data-dir cfg-path) - _ (run-cli ["--repo" "query-stdin-graph" "upsert" "block" + _ (run-cli ["--graph" "query-stdin-graph" "upsert" "block" "--target-page" "PipePage" "--content" "Pipe One"] data-dir cfg-path) - _ (run-cli ["--repo" "query-stdin-graph" "upsert" "block" + _ (run-cli ["--graph" "query-stdin-graph" "upsert" "block" "--target-page" "PipePage" "--content" "Pipe Two"] data-dir cfg-path) @@ -2095,14 +2095,14 @@ " :where" " [?e :block/title ?title]" " [(clojure.string/includes? ?title ?q)]]") - query-json-result (run-cli ["--repo" "query-stdin-graph" + query-json-result (run-cli ["--graph" "query-stdin-graph" "query" "--query" query-text "--inputs" (pr-str ["Pipe"])] data-dir cfg-path) query-json-payload (parse-json-output query-json-result) query-ids (get-in query-json-payload [:data :result]) - query-result (run-cli ["--repo" "query-stdin-graph" + query-result (run-cli ["--graph" "query-stdin-graph" "--output" "human" "query" "--query" query-text @@ -2110,7 +2110,7 @@ data-dir cfg-path) ids-text (string/trim (:output query-result)) show-result (with-redefs [show-command/read-stdin (fn [] ids-text)] - (run-cli ["--repo" "query-stdin-graph" + (run-cli ["--graph" "query-stdin-graph" "--output" "json" "show" "--id"] @@ -2121,7 +2121,7 @@ root-titles (set (map (comp node-title :root) show-data)) pipe-one (find-block-by-title root "Pipe One") pipe-two (find-block-by-title root "Pipe Two") - stop-result (run-cli ["server" "stop" "--repo" "query-stdin-graph"] + stop-result (run-cli ["server" "stop" "--graph" "query-stdin-graph"] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= (pr-str query-ids) ids-text)) @@ -2140,10 +2140,10 @@ (let [data-dir (node-helper/create-tmp-dir "db-worker-linked-refs")] (-> (p/let [cfg-path (node-path/join (node-helper/create-tmp-dir "cli") "cli.edn") _ (fs/writeFileSync cfg-path "{:output-format :json}") - _ (run-cli ["graph" "create" "--repo" "linked-refs-graph"] data-dir cfg-path) - _ (run-cli ["--repo" "linked-refs-graph" "upsert" "page" "--page" "TargetPage"] data-dir cfg-path) - _ (run-cli ["--repo" "linked-refs-graph" "upsert" "page" "--page" "SourcePage"] data-dir cfg-path) - list-page-result (run-cli ["--repo" "linked-refs-graph" "list" "page" "--expand"] + _ (run-cli ["graph" "create" "--graph" "linked-refs-graph"] data-dir cfg-path) + _ (run-cli ["--graph" "linked-refs-graph" "upsert" "page" "--page" "TargetPage"] data-dir cfg-path) + _ (run-cli ["--graph" "linked-refs-graph" "upsert" "page" "--page" "SourcePage"] data-dir cfg-path) + list-page-result (run-cli ["--graph" "linked-refs-graph" "list" "page" "--expand"] data-dir cfg-path) list-page-payload (parse-json-output list-page-result) page-item (some (fn [item] @@ -2152,14 +2152,14 @@ (get-in list-page-payload [:data :items])) page-id (or (:db/id page-item) (:id page-item)) blocks-edn (str "[{:block/title \"Ref to TargetPage\" :block/refs [{:db/id " page-id "}]}]") - _ (run-cli ["--repo" "linked-refs-graph" "upsert" "block" "--target-page" "SourcePage" + _ (run-cli ["--graph" "linked-refs-graph" "upsert" "block" "--target-page" "SourcePage" "--blocks" blocks-edn] data-dir cfg-path) - show-result (run-cli ["--repo" "linked-refs-graph" "show" "--page" "TargetPage"] + show-result (run-cli ["--graph" "linked-refs-graph" "show" "--page" "TargetPage"] data-dir cfg-path) show-payload (parse-json-output show-result) linked (get-in show-payload [:data :linked-references]) ref-block (first (:blocks linked)) - stop-result (run-cli ["server" "stop" "--repo" "linked-refs-graph"] data-dir cfg-path) + stop-result (run-cli ["server" "stop" "--graph" "linked-refs-graph"] data-dir cfg-path) stop-payload (parse-json-output stop-result)] (is (= "ok" (:status show-payload))) (is (some? page-id)) @@ -2184,22 +2184,22 @@ export-graph "export-edn-graph" import-graph "import-edn-graph" export-path (node-path/join (node-helper/create-tmp-dir "exports") "graph.edn") - _ (run-cli ["graph" "create" "--repo" export-graph] data-dir cfg-path) - _ (run-cli ["--repo" export-graph "upsert" "page" "--page" "ExportPage"] data-dir cfg-path) - _ (run-cli ["--repo" export-graph "upsert" "block" "--target-page" "ExportPage" "--content" "Export content"] data-dir cfg-path) - export-result (run-cli ["--repo" export-graph + _ (run-cli ["graph" "create" "--graph" export-graph] data-dir cfg-path) + _ (run-cli ["--graph" export-graph "upsert" "page" "--page" "ExportPage"] data-dir cfg-path) + _ (run-cli ["--graph" export-graph "upsert" "block" "--target-page" "ExportPage" "--content" "Export content"] data-dir cfg-path) + export-result (run-cli ["--graph" export-graph "graph" "export" "--type" "edn" "--file" export-path] data-dir cfg-path) export-payload (parse-json-output export-result) - _ (run-cli ["--repo" import-graph + _ (run-cli ["--graph" import-graph "graph" "import" "--type" "edn" "--input" export-path] data-dir cfg-path) - list-result (run-cli ["--repo" import-graph "list" "page"] data-dir cfg-path) + list-result (run-cli ["--graph" import-graph "list" "page"] data-dir cfg-path) list-payload (parse-json-output list-result) - stop-export (run-cli ["server" "stop" "--repo" export-graph] data-dir cfg-path) - stop-import (run-cli ["server" "stop" "--repo" import-graph] data-dir cfg-path)] + stop-export (run-cli ["server" "stop" "--graph" export-graph] data-dir cfg-path) + stop-import (run-cli ["server" "stop" "--graph" import-graph] data-dir cfg-path)] (is (= 0 (:exit-code export-result))) (is (= "ok" (:status export-payload))) (is (fs/existsSync export-path)) @@ -2223,22 +2223,22 @@ export-graph "export-sqlite-graph" import-graph "import-sqlite-graph" export-path (node-path/join (node-helper/create-tmp-dir "exports") "graph.sqlite") - _ (run-cli ["graph" "create" "--repo" export-graph] data-dir cfg-path) - _ (run-cli ["--repo" export-graph "upsert" "page" "--page" "SQLiteExportPage"] data-dir cfg-path) - _ (run-cli ["--repo" export-graph "upsert" "block" "--target-page" "SQLiteExportPage" "--content" "SQLite export content"] data-dir cfg-path) - export-result (run-cli ["--repo" export-graph + _ (run-cli ["graph" "create" "--graph" export-graph] data-dir cfg-path) + _ (run-cli ["--graph" export-graph "upsert" "page" "--page" "SQLiteExportPage"] data-dir cfg-path) + _ (run-cli ["--graph" export-graph "upsert" "block" "--target-page" "SQLiteExportPage" "--content" "SQLite export content"] data-dir cfg-path) + export-result (run-cli ["--graph" export-graph "graph" "export" "--type" "sqlite" "--file" export-path] data-dir cfg-path) export-payload (parse-json-output export-result) - _ (run-cli ["--repo" import-graph + _ (run-cli ["--graph" import-graph "graph" "import" "--type" "sqlite" "--input" export-path] data-dir cfg-path) - list-result (run-cli ["--repo" import-graph "list" "page"] data-dir cfg-path) + list-result (run-cli ["--graph" import-graph "list" "page"] data-dir cfg-path) list-payload (parse-json-output list-result) - stop-export (run-cli ["server" "stop" "--repo" export-graph] data-dir cfg-path) - stop-import (run-cli ["server" "stop" "--repo" import-graph] data-dir cfg-path)] + stop-export (run-cli ["server" "stop" "--graph" export-graph] data-dir cfg-path) + stop-import (run-cli ["server" "stop" "--graph" import-graph] data-dir cfg-path)] (is (= 0 (:exit-code export-result))) (is (= "ok" (:status export-payload))) (is (fs/existsSync export-path))