Skip to content

Commit

Permalink
Merge branch 'master' into dev/malli-schema&kondo-config
Browse files Browse the repository at this point in the history
  • Loading branch information
cnrpman authored Jan 12, 2023
2 parents 3305844 + 193677b commit 414fef6
Show file tree
Hide file tree
Showing 53 changed files with 1,264 additions and 723 deletions.
4 changes: 3 additions & 1 deletion .clj-kondo/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
frontend.util/node-path.dirname
frontend.util/node-path.join
frontend.util/node-path.extname
frontend.util/node-path.name]}
frontend.util/node-path.name
;; frontend.pubsub/def-mult-or-pub generate vars clj-kondo cannot resolve
frontend.pubsub]}

:consistent-alias
{:aliases {cljs.reader reader
Expand Down
13 changes: 0 additions & 13 deletions .github/workflows/stale-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@ jobs:
Thanks for your contributions to Logseq! If you have any other [**issues**](https://github.com/logseq/logseq/issues/new/choose) or [**feature requests**](https://discuss.logseq.com/c/feature-requests/), please don't hesitate to [let us know](https://github.com/logseq/logseq/issues/new/choose). We always welcome pull requests too!
- name: 'Print outputs'
run: |
for key in steps.stale_issues.outputs
do
printf '%s: %s\n' "${key}" "${steps.stale_issues.outputs[key]}"
done
- name: '🧹 Close stale awaiting response issues'
id: awaiting_issues
uses: actions/stale@6f05e4244c9a0b2ed3401882b05d701dd0a7289b # v7
Expand Down Expand Up @@ -83,9 +76,3 @@ jobs:
Thanks for your contributions to Logseq! If you have any other [**issues**](https://github.com/logseq/logseq/issues/new/choose) or [**feature requests**](https://discuss.logseq.com/c/feature-requests/), please don't hesitate to [let us know](https://github.com/logseq/logseq/issues/new/choose). We always welcome pull requests too!
- name: 'Print outputs'
run: |
for key in steps.awaiting_issues.outputs
do
printf '%s: %s\n' "${key}" "${steps.awaiting_issues.outputs[key]}"
done
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ android/app/src/main/assets/capacitor.config.json

*.sublime-*
/public/static
.yarn/
.yarnrc.yml
140 changes: 132 additions & 8 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,140 @@
# Code of Conduct

## Purpose
## Our Pledge

In the interest of fostering a safe and welcoming environment, we as
the Logseq team pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community. Logseq is not merely a note-taking tool, but can potentially become a community for collaboration and learning.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or advances of
any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address,
without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Logseq team is responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Logseq team has the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.


Logseq aims to be a project inclusive to the largest number of people. It is also not merely a note-taking tool, but can potentially become a community for collaboration and learning. As such, we are committed to providing a friendly, safe and welcoming environment for all, regardless of gender, sexual orientation, ability, ethnicity, socioeconomic status and religion (or lack thereof).

## Scope

This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
This Code of Conduct applies to all Logseq communication channels - online or in person,
and it also applies when an individual is representing the project or its community in
public spaces. Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by by contacting the moderators on the [Forum](https://discuss.logseq.com), [Discord](https://discord.gg/KpN4eHY) channel, Tienson Qin (@tiensonqin) on GitHub, or the official [Twitter](https://twitter.com/logseq). We will work with you to resolve the issue promptly. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The Logseq team
will maintain confidentiality with regard to the reporter of an incident.
Enforcement may result in an indefinite ban from all official Logseq communication
channels, or other actions as deemed appropriate by the Logseq team.

Logseq maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Enforcement Guidelines

Logseq team and community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of
actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the
community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.1, available at
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].

Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].

## Policy
For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
[https://www.contributor-covenant.org/translations][translations].

- Please respect each other. Do not dismiss, abuse, harass, attack, insult, or discriminate against others.
- Likewise, any spamming, trolling, flaming, baiting or other attention-stealing behavior is not welcome.
- Respect that people have differences of opinion and that every design or implementation choice carries a trade-off and numerous costs. There is seldom a right answer.
- If you feel being harassed or made uncomfortable by a community member, please report the incident(s) either by contacting the moderators on the [Forum](https://discuss.logseq.com), [Discord](https://discord.gg/KpN4eHY) channel, Tienson Qin (@tiensonqin) on GitHub, or the official [Twitter](https://twitter.com/logseq). We will work with you to resolve the issue promptly.
[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ There are more guides in [docs/](docs/), e.g. the [Guide for contributing to tra
## How to contribute with a PR
If you would like to contribute by solving an open issue, please fork this repository and then create a branch for the fix.

Once you push your code to your fork, you'll be able to open a PR into Logseq repository. For more info you can follow this guide from [GitHub docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork)
Once you push your code to your fork, you'll be able to open a PR into Logseq repository. For more info you can follow this guide from [GitHub docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork).

Enabling "allow edits from maintainers" for PR is highly appreciated!

There's a nice [project board](https://github.com/orgs/logseq/projects/5/views/1?pane=info
) listing items that easy for contributors to catch-up

And here a list of some [good first issues](https://github.com/logseq/logseq/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)!

Expand Down
3 changes: 2 additions & 1 deletion deps.edn
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@

:aliases {:cljs {:extra-paths ["src/dev-cljs/" "src/test/" "src/electron/"]
:extra-deps {org.clojure/clojurescript {:mvn/version "1.11.54"}
cider/cider-nrepl {:mvn/version "0.28.4"}
org.clojure/tools.namespace {:mvn/version "0.2.11"}
cider/cider-nrepl {:mvn/version "0.29.0"}
org.clojars.knubie/cljs-run-test {:mvn/version "1.0.1"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}

Expand Down
4 changes: 4 additions & 0 deletions deps/graph-parser/.carve/ignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ logseq.graph-parser/get-blocks-to-delete
logseq.graph-parser.property/colons-org
;; API
logseq.graph-parser.util.db/resolve-input
;; TODO: use fast-remove-nils instead
logseq.graph-parser.util/remove-nils
;; API
logseq.graph-parser.text/get-file-basename
2 changes: 1 addition & 1 deletion deps/graph-parser/src/logseq/graph_parser.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Options available:
new?
;; TODO: use file system timestamp?
(assoc :file/created-at (date-time-util/time-ms)))])
tx' (gp-util/remove-nils tx)
tx' (gp-util/fast-remove-nils tx)
result (if skip-db-transact?
tx'
(d/transact! conn tx' (select-keys options [:new-graph? :from-disk?])))]
Expand Down
2 changes: 1 addition & 1 deletion deps/graph-parser/src/logseq/graph_parser/block.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@
[blocks]
(map (fn [block]
(if (map? block)
(block-keywordize (gp-util/remove-nils block))
(block-keywordize (gp-util/remove-nils-non-nested block))
block))
blocks))

Expand Down
2 changes: 1 addition & 1 deletion deps/graph-parser/src/logseq/graph_parser/extract.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
invalid-properties (set (->> (map (comp name first) *invalid-properties)
(concat invalid-properties)))
page-m (->
(gp-util/remove-nils
(gp-util/remove-nils-non-nested
(assoc
(gp-block/page-name->map page false db true date-formatter
:from-page from-page)
Expand Down
10 changes: 8 additions & 2 deletions deps/graph-parser/src/logseq/graph_parser/text.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@
[logseq.graph-parser.util.page-ref :as page-ref]))

(defn get-file-basename
"Returns the basename of a file path. e.g. /a/b/c.md -> c.md"
[path]
(when-not (string/blank? path)
(.-base (path/parse (string/replace path "+" "/")))))

(defn get-file-rootname
"Returns the rootname of a file path. e.g. /a/b/c.md -> c"
[path]
(when-not (string/blank? path)
;; Same as util/node-path.name
(.-name (path/parse (string/replace path "+" "/")))))

(def page-ref-re-0 #"\[\[(.*)\]\]")
Expand All @@ -28,7 +34,7 @@
(or (when-let [[_ label _path] (re-matches markdown-page-ref-re s)]
(string/trim label))
(when-let [[_ path _label] (re-matches org-page-ref-re s)]
(some-> (get-file-basename path)
(some-> (get-file-rootname path)
(string/replace "." "/")))
(-> (re-matches page-ref-re-0 s)
second))))
Expand Down
13 changes: 12 additions & 1 deletion deps/graph-parser/src/logseq/graph_parser/util.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
(.normalize s "NFC"))

(defn remove-nils
"remove pairs of key-value that has nil value from a (possibly nested) map."
"remove pairs of key-value that has nil value from a (possibly nested) map or
coll of maps."
[nm]
(walk/postwalk
(fn [el]
Expand All @@ -37,6 +38,16 @@
el))
nm))

(defn remove-nils-non-nested
"remove pairs of key-value that has nil value from a map (nested not supported)."
[nm]
(into {} (remove (comp nil? second)) nm))

(defn fast-remove-nils
"remove pairs of key-value that has nil value from a coll of maps."
[nm]
(keep (fn [m] (if (map? m) (remove-nils-non-nested m) m)) nm))

(defn split-first [pattern s]
(when-let [first-index (string/index-of s pattern)]
[(subs s 0 first-index)
Expand Down
34 changes: 26 additions & 8 deletions docs/dev-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ this section, run `bb dev:lint`.
### Clojure code

To lint:
```
clojure -M:clj-kondo --lint src
```sh
clojure -M:clj-kondo --parallel --lint src --cache false
```

We lint our Clojure(Script) code with https://github.com/clj-kondo/clj-kondo/. If you need to configure specific linters, see [this documentation](https://github.com/clj-kondo/clj-kondo/blob/master/doc/linters.md). Where possible, a global linting configuration is used and namespace specific configuration is avoided.
Expand All @@ -27,15 +27,15 @@ There are outstanding linting items that are currently ignored to allow linting
We use https://github.com/borkdude/carve to detect unused vars in our codebase.

To run this linter:
```
```sh
bb lint:carve
```

By default, the script runs in CI mode which prints unused vars if they are
found. The script can be run in an interactive mode which prompts for keeping
(ignoring) an unused var or removing it. Run this mode with:

```
```sh
bb lint:carve '{:interactive true}'
```

Expand All @@ -46,7 +46,7 @@ why a var is ignored to help others understand why it's unused.

Large vars have a lot of complexity and make it hard for the team to maintain
and understand them. To run this linter:
```
```sh
bb lint:large-vars
```

Expand All @@ -55,7 +55,7 @@ To configure the linter, see the `[:tasks/config :large-vars]` path of bb.edn.
### Document namespaces

Documentation helps teams share their knowledge and enables more individuals to contribute to the codebase. Documenting our namespaces is a good first step to improving our documentation. To run this linter:
```
```sh
bb lint:ns-docstrings
```

Expand Down Expand Up @@ -83,16 +83,17 @@ We have unit and end to end tests.

To run end to end tests

``` bash
```sh
yarn electron-watch
# in another shell
yarn e2e-test # or npx playwright test
```

If e2e failed after first running:
- `rm -rdf ~/.logseq`
- `rm -rdf ~/.config/Logseq`
- `rm -rdf <repo dir>/tmp/`
- `rm -rdf <appData dir>/Electron` (Reference: https://www.electronjs.org/de/docs/latest/api/app#appgetpathname)
- Windows: `rmdir /s %APPDATA%/Electron` (Reference: https://www.electronjs.org/de/docs/latest/api/app#appgetpathname)

If e2e tests fail, they can be debugged by examining a trace dump with [the
playwright trace
Expand Down Expand Up @@ -212,3 +213,20 @@ Currently the codebase is not formatted/indented consistently. We loosely follow
There are some babashka tasks under `nbb:` which are useful for inspecting
database changes in realtime. See [these
docs](https://github.com/logseq/bb-tasks#logseqbb-tasksnbbwatch) for more info.

## FAQ

If dev app launch failed after electron upgrade:
```sh
yarn
yarn watch
```
In another window:
```sh
cd static
yarn
cd ..
yarn dev-electron-app
```
and kill all electron process
Then a normal start happens via `yarn dev-electron-app`
Loading

0 comments on commit 414fef6

Please sign in to comment.