2022-02-19 04:14:20 +00:00
# Develop Logseq
2022-02-22 22:18:23 +00:00
## Requirements
2022-02-19 04:14:20 +00:00
2022-03-17 17:33:31 +00:00
- [Node.js ](https://nodejs.org/en/download/ ) (See [build.yml ](https://github.com/logseq/logseq/blob/master/.github/workflows/build.yml ) for allowed version) & [Yarn ](https://classic.yarnpkg.com/en/docs/install/ )
2022-02-19 04:14:20 +00:00
- [Java & Clojure ](https://clojure.org/guides/getting_started ). (If you run into `Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2). -M:cljs (No such file or directory)` , it means you have a wrong Clojure version installed. Please uninstall it and follow the instructions linked.)
2022-02-22 22:18:23 +00:00
## Clone project
2022-02-19 04:14:20 +00:00
2022-02-23 14:49:41 +00:00
This is a required step before doing any development or production builds.
2022-02-19 04:14:20 +00:00
```bash
git clone https://github.com/logseq/logseq
cd logseq
2022-02-22 22:18:23 +00:00
```
## Browser development
### Development
```bash
2022-02-19 04:14:20 +00:00
yarn
yarn watch
```
2022-02-22 22:18:23 +00:00
Then open the browser < http: / / localhost:3001 > .
2022-02-19 04:14:20 +00:00
2023-02-12 03:51:02 +00:00
### REPL setup
#### VSCode + Calva
2023-02-12 06:24:57 +00:00
With ```yarn watch``` running, it should prints ``shadow-cljs - nREPL server started on port 8701``
You may connect to the nREPL server with:
2023-02-12 03:51:02 +00:00
2023-03-18 13:25:17 +00:00
``cmd + shift + p`` -> ``Calva: Connect to a Running REPL Server in the Project`` -> ``logseq`` -> ``shadow-cljs``->``:app`` ->``localhost:8701``
2023-02-12 03:51:02 +00:00
2023-02-12 06:24:57 +00:00
(change ``:app`` to ``:electron`` if you want to connect to the main thread of the Electron app)
Open a dev environment (Browser dev app on ``localhost:3000`` or Desktop dev app), then you can play REPL on the current editing file:
``cmd + shift + p`` -> ``Calva: Load/Evaluate Current File and its Requires/Dependencies``
2023-02-12 03:51:02 +00:00
2024-01-10 09:28:34 +00:00
#### Connect to the web-worker context
2024-01-10 09:33:30 +00:00
Notice: this works only for the `feat/db` branch for now.
2024-01-10 09:28:34 +00:00
##### Emacs + Cider
2024-01-10 10:39:46 +00:00
When connecting to a CLJ nrepl (NOTE: if you are already in a CLJS nrepl, use `:cljs/quit` to go back to CLJ nrepl),
you may run `(shadow.user/worker-repl)` , or use `(shadow/nrepl-select :app {:runtime-id <id-num>})` to connect to a web-worker context.
> [!TIP]
> you can find the `<id-num>` in http://localhost:9630/runtimes
2024-01-10 09:28:34 +00:00
##### VSCode
;; TODO
2022-07-06 02:24:40 +00:00
### Production Build
2022-02-19 04:14:20 +00:00
```bash
yarn release
```
2022-11-14 08:22:32 +00:00
The released files will be at `static/` directory.
2022-07-06 02:24:40 +00:00
2022-02-19 04:14:20 +00:00
## Desktop app development
2022-02-22 22:18:23 +00:00
### Development
2022-02-19 04:14:20 +00:00
2022-02-22 22:18:23 +00:00
1. Install npm packages for building the desktop app
2022-02-19 04:14:20 +00:00
``` bash
2022-07-04 22:53:19 +00:00
yarn install
2024-04-09 22:41:44 +00:00
cd static
yarn install
cd ..
2022-02-19 04:14:20 +00:00
```
2022-07-06 02:24:40 +00:00
2022-02-22 22:18:23 +00:00
2. Compile to JavaScript and open the dev app
2022-02-19 04:14:20 +00:00
```bash
2022-02-22 22:18:23 +00:00
yarn watch
2022-07-04 22:53:19 +00:00
# Wait until watch reports `Build Completed.` for `:electron` and `:app`.
# Then, run the following command in a different shell.
# If you have opened desktop logseq, you should close it. Otherwise, this command will fail.
2022-02-19 04:14:20 +00:00
yarn dev-electron-app
```
2022-02-23 14:49:41 +00:00
Alternatively, run `bb dev:electron-start` to do this step with one command. To
download bb, see https://github.com/babashka/babashka#installation.
2022-02-22 22:18:23 +00:00
2022-11-15 19:25:24 +00:00
3. (Optional) Update dependencies if `resources/package.json` has changed since
the last time you used dev Logseq.
2022-07-06 02:24:40 +00:00
```bash
# pull new changes
git pull
cd static & & yarn install & & cd ..
```
Here `static/` is generated by `yarn watch` command.
### Production Build
2022-02-22 22:18:23 +00:00
Build a release:
2022-02-19 04:14:20 +00:00
```bash
yarn release-electron
2022-02-22 21:47:04 +00:00
```
2022-07-06 02:24:40 +00:00
The final released binaries or installers will be at `static/out/` .