Skip to content

Commit 228e5df

Browse files
authored
Major refactor of codebase (#208)
- The binary component and library component are separated as two packages in the same workspace. - `lychee` is the binary component, in `lychee-bin/*`. - `lychee-lib` is the library component, in `lychee-lib/*`. - Users can now install only the `lychee-lib`, instead of both components, that would require fewer dependencies and faster compilation. - Dependencies for each component are adjusted and updated. E.g., no CLI dependencies for `lychee-lib`. - CLI tests are only moved to `lychee`, as it has nothing to do with the library component. - `Status::Error` is refactored to contain dedicated error enum, `ErrorKind`. - The motivation is to delay the formatting of errors to strings. Note that `e.to_string()` is not necessarily cheap (though trivial in many cases). The formatting is no delayed until the error is needed to be displayed to users. So in some cases, if the error is never used, it means that it won't be formatted at all. - Replaced `regex` based matching with one of the following: - Simple string equality test in the case of 'false positivie'. - URL parsing based test, in the case of extracting repository and user name for GitHub links. - Either cases would be much more efficient than `regex` based matching. First, there's no need to construct a state machine for regex. Second, URL is already verified and parsed on its creation, and extracting its components is fairly cheap. Also, this removes the dependency on `lazy-static` in `lychee-lib`. - `types` module now has a sub-directory, and its components are now separated into their own modules (in that sub-directory). - `lychee-lib::test_utils` module is only compiled for tests. - `wiremock` is moved to `dev-dependency` as it's only needed for `test` modules. - Dependencies are listed in alphabetical order. - Imports are organized in the following fashion: - Imports from `std` - Imports from 3rd-party crates, and `lychee-lib`. - Imports from `crate::*` or `super::*`. - No glob import. - I followed suggestion from `cargo clippy`, with `clippy::all` and `clippy:pedantic`. Co-authored-by: Lucius Hu <lebensterben@users.noreply.github.com>
1 parent a3f62fc commit 228e5df

40 files changed

+2879
-2194
lines changed

.github/workflows/rust.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,16 @@ jobs:
5353
uses: actions-rs/cargo@v1
5454
with:
5555
command: fetch
56-
- name: cargo publish check
56+
- name: cargo publish check lychee-lib
5757
uses: actions-rs/cargo@v1
5858
with:
5959
command: publish
60-
args: --dry-run
60+
args: --dry-run --manifest-path lychee-lib/Cargo.toml
61+
- name: cargo publish check lychee
62+
uses: actions-rs/cargo@v1
63+
with:
64+
command: publish
65+
args: --dry-run --manifest-path lychee-bin/Cargo.toml
6166

6267
publish:
6368
if: startsWith(github.ref, 'refs/tags/')
@@ -72,9 +77,17 @@ jobs:
7277
uses: actions-rs/cargo@v1
7378
with:
7479
command: fetch
75-
- name: cargo publish
80+
- name: cargo publish lychee-lib
81+
uses: actions-rs/cargo@v1
82+
env:
83+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
84+
with:
85+
command: publish
86+
args: --manifest-path lychee-lib/Cargo.toml
87+
- name: cargo publish lychee
7688
uses: actions-rs/cargo@v1
7789
env:
7890
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
7991
with:
8092
command: publish
93+
args: --manifest-path lychee-bin/Cargo.toml

Cargo.lock

Lines changed: 71 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)