mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 22:25:01 +00:00
Add readme, lint and CI for outliner dep
Also got outliner lints passing
This commit is contained in:
104
.github/workflows/outliner.yml
vendored
Normal file
104
.github/workflows/outliner.yml
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
name: logseq/outliner CI
|
||||
|
||||
on:
|
||||
# Path filters ensure jobs only kick off if a change is made to outliner or
|
||||
# its local dependencies
|
||||
push:
|
||||
branches: [master]
|
||||
paths:
|
||||
- 'deps/outliner/**'
|
||||
# db is a local dep that could break functionality in this lib and should trigger this
|
||||
- 'deps/db/**'
|
||||
- '.github/workflows/outliner.yml'
|
||||
- '!deps/outliner/**.md'
|
||||
pull_request:
|
||||
branches: [master]
|
||||
paths:
|
||||
- 'deps/outliner/**'
|
||||
- 'deps/db/**'
|
||||
- '.github/workflows/outliner.yml'
|
||||
- '!deps/outliner/**.md'
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: deps/outliner
|
||||
|
||||
env:
|
||||
CLOJURE_VERSION: '1.10.1.763'
|
||||
# This is the same as 1.8.
|
||||
JAVA_VERSION: '11'
|
||||
# This is the latest node version we can run.
|
||||
NODE_VERSION: '18'
|
||||
BABASHKA_VERSION: '1.0.168'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
cache: 'yarn'
|
||||
cache-dependency-path: deps/outliner/yarn.lock
|
||||
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: ${{ env.JAVA_VERSION }}
|
||||
|
||||
# Clojure needed for bb step
|
||||
- name: Set up Clojure
|
||||
uses: DeLaGuardo/setup-clojure@10.1
|
||||
with:
|
||||
cli: ${{ env.CLOJURE_VERSION }}
|
||||
bb: ${{ env.BABASHKA_VERSION }}
|
||||
|
||||
- name: Fetch yarn deps
|
||||
run: yarn install --frozen-lockfile
|
||||
|
||||
- name: Run nbb-logseq tests
|
||||
run: yarn test
|
||||
|
||||
# In this job because it depends on an npm package
|
||||
- name: Load namespaces into nbb-logseq
|
||||
run: bb test:load-all-namespaces-with-nbb .
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: ${{ env.JAVA_VERSION }}
|
||||
|
||||
- name: Set up Clojure
|
||||
uses: DeLaGuardo/setup-clojure@10.1
|
||||
with:
|
||||
cli: ${{ env.CLOJURE_VERSION }}
|
||||
bb: ${{ env.BABASHKA_VERSION }}
|
||||
|
||||
- name: Run clj-kondo lint
|
||||
run: clojure -M:clj-kondo --lint src test
|
||||
|
||||
- name: Carve lint for unused vars
|
||||
run: bb lint:carve
|
||||
|
||||
- name: Lint for vars that are too large
|
||||
run: bb lint:large-vars
|
||||
|
||||
- name: Lint for namespaces that aren't documented
|
||||
run: bb lint:ns-docstrings
|
||||
|
||||
- name: Lint for public vars that are private based on usage
|
||||
run: bb lint:minimize-public-vars
|
||||
4
deps/outliner/.carve/config.edn
vendored
Normal file
4
deps/outliner/.carve/config.edn
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{:paths ["src"]
|
||||
:api-namespaces [logseq.outliner.datascript-report
|
||||
logseq.outliner.pipeline]
|
||||
:report {:format :ignore}}
|
||||
50
deps/outliner/README.md
vendored
Normal file
50
deps/outliner/README.md
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
## Description
|
||||
|
||||
This library provides outliner operation related functionality. This library is
|
||||
compatible with ClojureScript and with
|
||||
node/[nbb-logseq](https://github.com/logseq/nbb-logseq) to respectively provide
|
||||
frontend and commandline functionality.
|
||||
|
||||
## API
|
||||
|
||||
This library is under the parent namespace `logseq.outliner`. This library
|
||||
provides two main namespaces: `logseq.outliner.datascript-report` and `logseq.outliner.pipeline`.
|
||||
|
||||
## Usage
|
||||
|
||||
See the frontend for cljs usage.
|
||||
|
||||
## Dev
|
||||
|
||||
This follows the practices that [the Logseq frontend
|
||||
follows](/docs/dev-practices.md). Most of the same linters are used, with
|
||||
configurations that are specific to this library. See [this library's CI
|
||||
file](/.github/workflows/outliner.yml) for linting examples.
|
||||
|
||||
### Setup
|
||||
|
||||
To run linters and tests, you'll want to install yarn dependencies once:
|
||||
```
|
||||
yarn install
|
||||
```
|
||||
|
||||
This step is not needed if you're just running the frontend application.
|
||||
|
||||
### Testing
|
||||
|
||||
Testing is done with nbb-logseq and
|
||||
[nbb-test-runner](https://github.com/nextjournal/nbb-test-runner). Some basic
|
||||
usage:
|
||||
|
||||
```
|
||||
# Run all tests
|
||||
$ yarn test
|
||||
# List available options
|
||||
$ yarn test -H
|
||||
# Run tests with :focus metadata flag
|
||||
$ yarn test -i focus
|
||||
```
|
||||
|
||||
### Managing dependencies
|
||||
|
||||
See [standard nbb/cljs library advice in graph-parser](/deps/graph-parser/README.md#managing-dependencies).
|
||||
29
deps/outliner/bb.edn
vendored
Normal file
29
deps/outliner/bb.edn
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
{:min-bb-version "1.0.168"
|
||||
:deps
|
||||
{logseq/bb-tasks
|
||||
#_{:local/root "../../../bb-tasks"}
|
||||
{:git/url "https://github.com/logseq/bb-tasks"
|
||||
:git/sha "70d3edeb287f5cec7192e642549a401f7d6d4263"}}
|
||||
|
||||
:pods
|
||||
{clj-kondo/clj-kondo {:version "2023.05.26"}}
|
||||
|
||||
:tasks
|
||||
{test:load-all-namespaces-with-nbb
|
||||
logseq.bb-tasks.nbb.test/load-all-namespaces
|
||||
|
||||
lint:large-vars
|
||||
logseq.bb-tasks.lint.large-vars/-main
|
||||
|
||||
lint:carve
|
||||
logseq.bb-tasks.lint.carve/-main
|
||||
|
||||
lint:ns-docstrings
|
||||
logseq.bb-tasks.lint.ns-docstrings/-main
|
||||
|
||||
lint:minimize-public-vars
|
||||
logseq.bb-tasks.lint.minimize-public-vars/-main}
|
||||
|
||||
:tasks/config
|
||||
{:large-vars
|
||||
{:max-lines-count 55}}}
|
||||
@@ -1,10 +1,11 @@
|
||||
(ns logseq.outliner.datascript-report
|
||||
"Datascript fns related to getting data from a connection listener's tx-report"
|
||||
(:require [clojure.set :as set]
|
||||
[datascript.core :as d]))
|
||||
|
||||
(def keys-of-deleted-entity 1)
|
||||
(def ^:private keys-of-deleted-entity 1)
|
||||
|
||||
(defn get-entity-from-db-after-or-before
|
||||
(defn- get-entity-from-db-after-or-before
|
||||
"Get the entity from db after if possible; otherwise get entity from db before
|
||||
Useful for fetching deleted elements"
|
||||
[db-before db-after db-id]
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
(:v d)))
|
||||
datoms))
|
||||
|
||||
(defn datom->av-vector
|
||||
(defn- datom->av-vector
|
||||
[db datom]
|
||||
(let [a (:a datom)
|
||||
v (:v datom)
|
||||
@@ -51,7 +51,7 @@
|
||||
(assoc b :block/uuid uuid)))))))
|
||||
|
||||
;; non recursive query
|
||||
(defn get-block-parents
|
||||
(defn ^:api get-block-parents
|
||||
[db block-id {:keys [depth] :or {depth 100}}]
|
||||
(loop [block-id block-id
|
||||
parents (list)
|
||||
@@ -62,7 +62,7 @@
|
||||
(recur (:block/uuid parent) (conj parents parent) (inc d))
|
||||
parents))))
|
||||
|
||||
(defn get-block-children-ids
|
||||
(defn ^:api get-block-children-ids
|
||||
[db block-uuid]
|
||||
(when-let [eid (:db/id (d/entity db [:block/uuid block-uuid]))]
|
||||
(let [seen (volatile! [])]
|
||||
@@ -138,8 +138,7 @@
|
||||
children-maps)]
|
||||
(swap! *computed-ids set/union (set (cons (:block/uuid block) children)))
|
||||
(concat
|
||||
(when (and (seq new-refs)
|
||||
refs-changed?)
|
||||
(when (and (seq new-refs) refs-changed?)
|
||||
[{:db/id (:db/id block)
|
||||
:block/path-refs new-refs}])
|
||||
children-refs))))
|
||||
|
||||
Reference in New Issue
Block a user