File tree Expand file tree Collapse file tree 7 files changed +25
-14
lines changed Expand file tree Collapse file tree 7 files changed +25
-14
lines changed Original file line number Diff line number Diff line change 11{:deps
22 {logseq/graph-parser
33 {:git/url " https://github.com/logseq/logseq"
4- :git/sha " 0c4198c824489ddec0a510d1168c932bde36fa81 "
5- :git/tag " 0.8.14 "
4+ :git/sha " 82cf4d3c65acbf230a3170640fe271dd74095067 "
5+ :git/tag " 0.9.8 "
66 :deps/root " deps/graph-parser" }
77 #_{:local/root " ../../../logseq/deps/graph-parser" }}}
Original file line number Diff line number Diff line change @@ -17,9 +17,9 @@ The following sections describe Node.js scripts that call Logseq's graph-parser
1717in ClojureScript and then return control to Javascript to process the result.
1818These scripts use a specific version of Logseq as specified in ` nbb.edn ` .
1919
20- ### query.js
20+ ### query.mjs
2121
22- [ query.js ] ( query.js ) converts the given graph directory into a database and
22+ [ query.mjs ] ( query.mjs ) converts the given graph directory into a database and
2323then runs the given query on that database. This script is able to run any
2424Datalog query the Logseq app can, but from the commandline. Here's how to use
2525this script:
@@ -29,14 +29,14 @@ this script:
2929$ git clone https://github.com/logseq/docs && cd docs
3030
3131# Print all the page names in the graph
32- $ node query.js . ' [:find ?n :where [?b :block/name ?n]]'
32+ $ node query.mjs . ' [:find ?n :where [?b :block/name ?n]]'
3333Parsing 269 files...
3434[
3535 " setting___enable journals" ,
3636...
3737
3838# Print all the tasks' contents
39- $ node query.js . ' [:find (pull ?b [:block/content]) :where (task ?b #{"TODO"})]'
39+ $ node query.mjs . ' [:find (pull ?b [:block/content]) :where (task ?b #{"TODO"})]'
4040Parsing 269 files...
4141[
4242 {
Original file line number Diff line number Diff line change 11{:deps
22 {logseq/graph-parser
33 {:git/url " https://github.com/logseq/logseq"
4- :git/sha " 0c4198c824489ddec0a510d1168c932bde36fa81 "
5- :git/tag " 0.8.14 "
4+ :git/sha " 82cf4d3c65acbf230a3170640fe271dd74095067 "
5+ :git/tag " 0.9.8 "
66 :deps/root " deps/graph-parser" }
77 #_{:local/root " ../../../logseq/deps/graph-parser" }}}
Original file line number Diff line number Diff line change 11import { loadString } from '@logseq/nbb-logseq'
22import { exit } from 'process' ;
33
4- // Expects to be called as `node query.js ...`
4+ // Expects to be called as `node query.mjs ...`
55const args = process . argv . slice ( 2 ) ;
66if ( args . length < 2 ) {
77 console . log ( "Usage: $0 GRAPH-DIR QUERY" ) ;
Original file line number Diff line number Diff line change 11{:deps
22 {logseq/graph-parser
33 {:git/url " https://github.com/logseq/logseq"
4- :git/sha " 090d25b5e845e98ec2f003279f91ff34e4393cc6"
4+ :git/sha " 82cf4d3c65acbf230a3170640fe271dd74095067"
5+ :git/tag " 0.9.8"
56 :deps/root " deps/graph-parser" }
67 #_{:local/root " ../../logseq/deps/graph-parser" }
78
Original file line number Diff line number Diff line change 99 [datascript.transit :as dt]
1010 [clojure.pprint :as pprint]
1111 [clojure.edn :as edn]
12- [" fs" :as fs]))
12+ [" fs" :as fs]
13+ [" child_process" :as child-process]))
14+
15+ (defn- sh
16+ " Run shell cmd synchronously and print to inherited streams by default. Aims
17+ to be similar to babashka.tasks/shell
18+ TODO: Fail fast when process exits 1"
19+ [cmd opts]
20+ (child-process/spawnSync (first cmd)
21+ (clj->js (rest cmd))
22+ (clj->js (merge {:stdio " inherit" } opts))))
1323
1424(defn- clone-graphs
1525 [graph-urls]
1626 (map (fn [graph-url]
1727 (let [graph-dir (str " graphs/" (re-find #"[^/]+$" graph-url))]
1828 (if (fs/existsSync graph-dir)
1929 (println " Graph" graph-url " is already cloned" )
20- (gp-cli/ sh [" git" " clone" graph-url graph-dir] {}))
30+ (sh [" git" " clone" graph-url graph-dir] {}))
2131 graph-dir))
2232 graph-urls))
2333
Original file line number Diff line number Diff line change 11{:deps
22 {logseq/graph-parser
33 {:git/url " https://github.com/logseq/logseq"
4- :git/sha " 0c4198c824489ddec0a510d1168c932bde36fa81 "
5- :git/tag " 0.8.14 "
4+ :git/sha " 82cf4d3c65acbf230a3170640fe271dd74095067 "
5+ :git/tag " 0.9.8 "
66 :deps/root " deps/graph-parser" }
77 #_{:local/root " ../../../logseq/deps/graph-parser" }}}
You can’t perform that action at this time.
0 commit comments