{"id":23436912,"url":"https://github.com/logseq/bb-tasks","last_synced_at":"2025-04-13T04:41:50.784Z","repository":{"id":43198186,"uuid":"498598721","full_name":"logseq/bb-tasks","owner":"logseq","description":"Reusable babashka tasks used by logseq team","archived":false,"fork":false,"pushed_at":"2025-03-31T14:05:21.000Z","size":53,"stargazers_count":19,"open_issues_count":0,"forks_count":1,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-10T04:28:11.530Z","etag":null,"topics":["babashka","cli"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/logseq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-06-01T05:10:07.000Z","updated_at":"2025-04-04T04:22:13.000Z","dependencies_parsed_at":"2023-01-25T11:45:42.960Z","dependency_job_id":null,"html_url":"https://github.com/logseq/bb-tasks","commit_stats":{"total_commits":32,"total_committers":1,"mean_commits":32.0,"dds":0.0,"last_synced_commit":"70d3edeb287f5cec7192e642549a401f7d6d4263"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logseq%2Fbb-tasks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logseq%2Fbb-tasks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logseq%2Fbb-tasks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logseq%2Fbb-tasks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/logseq","download_url":"https://codeload.github.com/logseq/bb-tasks/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665783,"owners_count":21142123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["babashka","cli"],"created_at":"2024-12-23T13:34:53.355Z","updated_at":"2025-04-13T04:41:50.756Z","avatar_url":"https://github.com/logseq.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Description\n\nLibrary of reusable [babashka](https://github.com/babashka/babashka) tasks\nand [bbin](https://github.com/babashka/bbin) CLIs\n\n## Setup\n\nAdd a git dependency to your `bb.edn`:\n\n```clojure\n:deps\n{logseq/bb-tasks\n {:git/url \"https://github.com/logseq/bb-tasks\"\n  :git/sha \"\u003cLATEST SHA\u003e\"}}\n```\n\nDefine the tasks to import from this library in `bb.edn` e.g.\n\n```clojure\n:tasks\n{nbb:watch\n logseq.bb-tasks.nbb.watch/watch}\n```\n\nSome tasks require bb pods. Babashka doesn't yet support providing them through\na gitlib dependency. This means that you will need to add the necessary `:pods`\nto your `bb.edn`. See `bb.edn` for pods and versions that are known to work.\n\n## Usage\n\nTasks are described by namespace.\n\n### `logseq.bb-tasks.lint.carve`\n\n#### `logseq.bb-tasks.lint.carve/-main`\n\nFinds unused vars with https://github.com/borkdude/carve. Also provides more\nfriendly commandline interface as the default config is preserved when\nadditional options are given.\n\n### `logseq.bb-tasks.lint.datalog`\n\n#### `logseq.bb-tasks.lint.datalog/lint-rules`\n\nLints given datalog rules for valid parse-ability and unbound variables.\n\n### `logseq.bb-tasks.lint.large-vars`\n\n#### `logseq.bb-tasks.lint.large-vars/-main`\n\nLints codebases for large vars. Large vars make it difficult for teams to\nmaintain and understand codebases.\n\n### `logseq.bb-tasks.nbb`\n\nCollection of nbb tasks located\n[here](https://github.com/logseq/bb-tasks/tree/main/src/logseq/bb_tasks/nbb) for use with `nbb-logseq`. Most of them are also be usable with `nbb`.\n\n#### `logseq.bb-tasks.nbb.test`\n\n##### `logseq.bb-tasks.nbb.test/load-all-namespaces`\n\nVerify that all namespaces in a directory can be required by nbb-logseq. Useful\nfor ensuring cljs code continues to be compatible with nbb(-logseq).\n\n#### `logseq.bb-tasks.nbb.cached-db`\n\nEnables bb tasks to call nbb scripts with an up-to-date cached db\nof the current graph directory. The underlying bb task manages a cache like the\none Logseq editor builds in `~/.logseq/graphs/`. If a user git commits the\ncached db, nbb CI processes also benefit from the speed up.\n\nTo set this up in your graph:\n- Create a `script/` directory and copy all the files in [this example's script/](https://github.com/logseq/docs/tree/master/script) to it.\n- `cd script \u0026\u0026 yarn install \u0026\u0026 cd -`\n- Copy [this example's bb.edn](https://github.com/logseq/docs/blob/master/bb.edn) to bb.edn\n- Change the implementation of `script/query.cljs` to queries specific to your graph. Some notes:\n  - `(cached-db/read-db)` is necessary to read the cached db.\n  - `query.cljs` is just an example nbb script. _Any_ script works with the cached db.\n- Run `bb query properties` to call the nbb script to return properties in your graph.\n  - Note the first time takes time as it builds the cache. Subsequent calls are pretty quick.\n\n##### `logseq.bb-tasks.nbb.cached-db/ensure-latest-cached-db`\n\nThis task should be used in the `:depends` of a task calling a nbb script. The\ntask ensures that the transit db is rebuilt if any graph file is detected to be\noutdated by their timestamp. Cache building is slow the first time as all files\nneed to be parsed. Subsequent updates are quick because only files modified\nsince the last cache are re-parsed.\n\n#### `logseq.bb-tasks.nbb.watch`\n\nThese tasks demonstrate that nbb-logseq scripts can run when a graph is saved to\nprovide useful information to a Logseq user. When these scripts use the graph-parser, these scripts\nstart to behave like intelligent assistants as they understand the data in your file as well as the Logseq app does.\n\nTasks in this namespace require installing `nbb-logseq` e.g. `npm install -g\n@logseq/nbb-logseq`. For the examples in this ns, there is a one time setup of\n`cd examples \u0026\u0026 yarn install \u0026\u0026 cd -`.\n\n##### `logseq.bb-tasks.nbb.watch/watch`\n\nGiven a graph directory and an nbb script, the nbb script runs when either the\nscript or a graph file is saved. The run on script save provides a live-editing\nexperience as different queries can be run without restarting this task.\n\nFor an example, run the following:\n\n```\n$ bb nbb:watch /path/to/graph examples/analyze_file.cljs\nWatching /path/to/graph ...\n```\n\nSee [this demo\nclip](https://www.loom.com/share/20debb49fdd64e77ae83056289750b0f) to see it in\naction.\n\n##### `logseq.bb-tasks.nbb.watch/portal-watch`\n\nGiven a graph directory and an nbb script,\n[portal](https://github.com/djblue/portal) renders the edn produced by the nbb\nscript when either the script or a graph file is saved.\n\nFor an example, run the following:\n\n```\n$ bb nbb:portal-watch /path/to/graph examples/print_file_query.cljs\nWatching /path/to/graph ...\n```\n\n### CLIs\n\nTo use the CLIs, first install [bbin](https://github.com/babashka/bbin). Then install\nscripts in this repo:\n\n```sh\nbbin install https://raw.githubusercontent.com/logseq/bb-tasks/main/src/logseq/bb_tasks/bin/logseq_import.clj \u0026\u0026 \\\nbbin install https://raw.githubusercontent.com/logseq/bb-tasks/main/src/logseq/bb_tasks/bin/logseq_export.clj\n```\n\nTo use these scripts:\n\n```sh\n# From any graph directory, export any text files e.g.\n$ logseq-export journals/2022_03_22.md pages/Abraham\\ Lincoln.md \u003e export.edn\n\n# cd to another graph and then import the export.edn\n$ logseq-import ../previous-graph/export.edn\nImported journals/2022_03_22.md\nImported pages/Abraham Lincoln.md\n```\n\n## Contributing\n\nBug reports are welcome. For feature contributions, please discuss\nthem first as this library primarily serves https://github.com/logseq/logseq.\n\n## License\n\nSee LICENSE.md\n\n## Development\n\nTasks are linted with https://github.com/clj-kondo/clj-kondo using `clojure\n-M:clj-kondo --lint src`. Dependencies are kept up to date with\nhttps://github.com/liquidz/antq using `clojure -M:outdated`.\n\n## Additional Links\n* https://github.com/logseq/logseq/blob/master/bb.edn uses this library\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flogseq%2Fbb-tasks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flogseq%2Fbb-tasks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flogseq%2Fbb-tasks/lists"}