Compare commits
49 Commits
242d5b7582
...
4-make-ser
| Author | SHA1 | Date | |
|---|---|---|---|
| 2df54930bb | |||
| f7a1f84730 | |||
| bb82dad4cf | |||
| 303309fff9 | |||
| 6d2f76eb72 | |||
| 451015d2f2 | |||
| 1a009bac61 | |||
| cc65ce3e7c | |||
| 926944e8dd | |||
| 78e2acb325 | |||
| 958856dcc0 | |||
| deb30aacea | |||
| 9075b34ca3 | |||
| 7325e3a0c9 | |||
| 34e8ad4eb4 | |||
| 8a6dacf1c8 | |||
|
|
8a65a5e596 | ||
| 47996b81bc | |||
| a2f9622aaa | |||
| 5b3ef929c4 | |||
| d706ba9f56 | |||
| bb4b2ad3f5 | |||
| bd77f0daff | |||
| cd439006bb | |||
| 77eda0841b | |||
| 21b6434145 | |||
| ff4b237651 | |||
| 4b11b0ada2 | |||
| 7e40620df6 | |||
| 4025bf9c7f | |||
| d7a387cf45 | |||
| e56a9fc1b5 | |||
| 948df90006 | |||
| 161ce02042 | |||
| 97ab59a424 | |||
| c3761464ee | |||
| fb32fcfdb1 | |||
| 89d921299e | |||
| 9591ead7ea | |||
| 7a47b73d08 | |||
| a5005d777f | |||
| 961fe4ce56 | |||
| fe8e3e3e63 | |||
| 9945b45aa9 | |||
| 0713ec0c80 | |||
| 96d200888a | |||
| 13e56f057b | |||
| bb098ce77e | |||
| 4a2f852f30 |
@@ -1 +0,0 @@
|
|||||||
**
|
|
||||||
|
Before Width: | Height: | Size: 18 MiB After Width: | Height: | Size: 18 MiB |
40
.github/workflows/docker_deploy.yml
vendored
Normal file
40
.github/workflows/docker_deploy.yml
vendored
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
name: Deploy Docker Image to Github Container Registry
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["main"]
|
||||||
|
paths:
|
||||||
|
- "Cargo.toml"
|
||||||
|
|
||||||
|
env:
|
||||||
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
|
contents: read
|
||||||
|
attestations: write
|
||||||
|
id-token: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: hustcer/setup-nu@v3
|
||||||
|
- uses: cachix/install-nix-action@v31
|
||||||
|
with:
|
||||||
|
nix_path: nixpkgs=channel:nixos-unstable
|
||||||
|
|
||||||
|
- run: nix build .#docker
|
||||||
|
|
||||||
|
- run: |
|
||||||
|
export CARGO_VERSION=$(nu -c "cargo metadata --format-version=1 --no-deps | from json | get packages | first | get version")
|
||||||
|
echo "CARGO_VERSION=$CARGO_VERSION" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- run: docker load -i result
|
||||||
|
- name: Log in to registry
|
||||||
|
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
||||||
|
- run: docker tag docki:latest "ghcr.io/quirinecker/docki:$CARGO_VERSION"
|
||||||
|
- run: docker tag docki:latest "ghcr.io/quirinecker/docki:latest"
|
||||||
|
- run: docker push ghcr.io/quirinecker/docki:$CARGO_VERSION
|
||||||
|
- run: docker push ghcr.io/quirinecker/docki:latest
|
||||||
26
.github/workflows/rust_deploy.yml
vendored
Normal file
26
.github/workflows/rust_deploy.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
name: Deploy Rust to Crates.io
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["main"]
|
||||||
|
paths:
|
||||||
|
- "Cargo.toml"
|
||||||
|
|
||||||
|
env:
|
||||||
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Build
|
||||||
|
run: cargo build --verbose
|
||||||
|
- name: Run tests
|
||||||
|
run: cargo test --verbose
|
||||||
|
- name: Publish to crates.io
|
||||||
|
env:
|
||||||
|
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
|
||||||
|
run: |
|
||||||
|
cargo publish --verbose
|
||||||
24
.github/workflows/rust_test.yml
vendored
Normal file
24
.github/workflows/rust_test.yml
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
name: Test Rust
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["main", "develop"]
|
||||||
|
paths:
|
||||||
|
- "./src/**"
|
||||||
|
- "./Cargo.toml"
|
||||||
|
pull_request:
|
||||||
|
branches: ["main", "develop"]
|
||||||
|
|
||||||
|
env:
|
||||||
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Build
|
||||||
|
run: cargo build --verbose
|
||||||
|
- name: Run tests
|
||||||
|
run: cargo test --verbose
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@ dist
|
|||||||
/docs
|
/docs
|
||||||
res/test/docs/slides/revealjs
|
res/test/docs/slides/revealjs
|
||||||
res/test/result
|
res/test/result
|
||||||
|
result
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
workflow:
|
|
||||||
rules:
|
|
||||||
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"'
|
|
||||||
|
|
||||||
default:
|
|
||||||
image: 'quirinecker/rust-openssl'
|
|
||||||
|
|
||||||
build:
|
|
||||||
script:
|
|
||||||
- cargo build
|
|
||||||
|
|
||||||
test:
|
|
||||||
script:
|
|
||||||
- cargo test
|
|
||||||
|
|
||||||
# publish:
|
|
||||||
# script:
|
|
||||||
# - export CARGO_REGISTRY_TOKEN=$CARGO_TOKEN
|
|
||||||
# - cargo publish
|
|
||||||
|
|
||||||
41
Cargo.lock
generated
41
Cargo.lock
generated
@@ -1,6 +1,6 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "adler"
|
name = "adler"
|
||||||
@@ -630,17 +630,6 @@ dependencies = [
|
|||||||
"unicode-width",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "colored"
|
|
||||||
version = "2.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd"
|
|
||||||
dependencies = [
|
|
||||||
"atty",
|
|
||||||
"lazy_static",
|
|
||||||
"winapi 0.3.9",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "concurrent-queue"
|
name = "concurrent-queue"
|
||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
@@ -859,16 +848,16 @@ checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "docki"
|
name = "docki"
|
||||||
version = "1.1.0"
|
version = "1.2.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"clap 4.1.8",
|
"clap 4.1.8",
|
||||||
"clap_complete",
|
"clap_complete",
|
||||||
"colored",
|
|
||||||
"futures",
|
"futures",
|
||||||
"home",
|
"home",
|
||||||
"live-server",
|
"live-server",
|
||||||
"notify 5.1.0",
|
"notify 5.1.0",
|
||||||
|
"nu-ansi-term",
|
||||||
"regex",
|
"regex",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"text_io",
|
"text_io",
|
||||||
@@ -1872,6 +1861,15 @@ dependencies = [
|
|||||||
"windows-sys 0.42.0",
|
"windows-sys 0.42.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nu-ansi-term"
|
||||||
|
version = "0.50.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
|
||||||
|
dependencies = [
|
||||||
|
"windows-sys 0.61.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-integer"
|
name = "num-integer"
|
||||||
version = "0.1.45"
|
version = "0.1.45"
|
||||||
@@ -3206,6 +3204,12 @@ version = "0.4.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-link"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-sys"
|
name = "windows-sys"
|
||||||
version = "0.42.0"
|
version = "0.42.0"
|
||||||
@@ -3230,6 +3234,15 @@ dependencies = [
|
|||||||
"windows-targets",
|
"windows-targets",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.61.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
||||||
|
dependencies = [
|
||||||
|
"windows-link",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-targets"
|
name = "windows-targets"
|
||||||
version = "0.42.1"
|
version = "0.42.1"
|
||||||
|
|||||||
12
Cargo.toml
12
Cargo.toml
@@ -1,20 +1,17 @@
|
|||||||
# Cargo.toml
|
|
||||||
build = "build.rs"
|
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "docki"
|
name = "docki"
|
||||||
version = "1.1.0"
|
version = "1.2.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "cli for building and publishing documentation using asciidoctor"
|
description = "cli for building and publishing documentation using asciidoctor"
|
||||||
license-file = "LICENSE.txt"
|
license-file = "LICENSE.txt"
|
||||||
authors = ["Quirin Ecker"]
|
authors = ["Quirin Ecker"]
|
||||||
|
exclude = [".gitlab", ".github"]
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bytes = "1.4.0"
|
bytes = "1.4.0"
|
||||||
clap = { version = "4.1.8", features = ["derive"] }
|
clap = { version = "4.1.8", features = ["derive"] }
|
||||||
colored = "2.0.0"
|
|
||||||
futures = "0.3.26"
|
futures = "0.3.26"
|
||||||
home = "0.5.4"
|
home = "0.5.4"
|
||||||
live-server = "0.6.0"
|
live-server = "0.6.0"
|
||||||
@@ -24,8 +21,5 @@ reqwest = { version = "0.11.14", features = ["blocking"] }
|
|||||||
text_io = "0.1.12"
|
text_io = "0.1.12"
|
||||||
tokio = { version = "1.26.0", features = ["full"] }
|
tokio = { version = "1.26.0", features = ["full"] }
|
||||||
zip-extract = "0.1.1"
|
zip-extract = "0.1.1"
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
clap = { version = "4.1.8", features = ["derive"] }
|
|
||||||
clap_complete = "4.1.4"
|
clap_complete = "4.1.4"
|
||||||
|
nu-ansi-term = "0.50.3"
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
FROM rust:slim
|
|
||||||
|
|
||||||
WORKDIR /opt/rust
|
|
||||||
|
|
||||||
RUN apt update \
|
|
||||||
&& apt-get -y upgrade \
|
|
||||||
&& apt-get -y install libssl-dev pkg-config
|
|
||||||
126
README.md
126
README.md
@@ -1,42 +1,138 @@
|
|||||||
# Docki
|
# Docki
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> This project is under renovations. While installing it right now might work, it is not guaranteed
|
> This project is under renovations. It can be used, but it might not be completely stable yet.
|
||||||
|
|
||||||
|
|
||||||
## Preview
|
## Preview
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Docki is cli for converting asciidoctor files into html files. You can build your documentation with `docki build` and write documenation using the live server with `docki serve`.
|
Docki is cli for converting asciidoctor files into html files.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> This works in a directory with a directory called `docs`, which contains the asciidoctor documentation.
|
||||||
|
|
||||||
|
### Building the documentation
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docki build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Serving the documentation on a live server
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docki serve
|
||||||
|
```
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
### Nix
|
|
||||||
|
|
||||||
This installation method is recommended, becuase it is the most maintained due to me using nix in development.
|
|
||||||
|
|
||||||
Note: This is the most basic installation. If you are already more experienced, you might want to add it to your shell or home manager configuration.
|
|
||||||
|
|
||||||
```nix
|
|
||||||
nix profile install github:quirinecker/docki
|
|
||||||
```
|
|
||||||
|
|
||||||
### Homebrew
|
### Homebrew
|
||||||
|
|
||||||
```
|
```shell
|
||||||
brew tap quirinecker/docki-homebrew https://gitlab.com/quirinecker/docki-homebrew
|
brew tap quirinecker/homebrew-docki https://github.com/quirinecker/homebrew-docki
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
brew install docki
|
brew install docki
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Nix
|
||||||
|
|
||||||
|
If you just want to try it out real quick and the nix package manager is available on your system you can use the following command.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
nix develop github:quirinecker/docki#preview
|
||||||
|
```
|
||||||
|
|
||||||
|
This will open a shell evnironment with docki installed. If you want to install it permanently with nix, i would recommend following the instructions in the [Nix (Advanced, Flake)](#nix-advanced-flake) section.
|
||||||
|
|
||||||
### Cargo
|
### Cargo
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> This is the most basic installation. It will not include asciidoctor_revealjs and asciidoctor itself. Installing asciidoctor has to be done manually, while installing asciidoctor_revealjs can be done with `docki install-reveal`
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
cargo install docki
|
cargo install docki
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Docker
|
||||||
|
|
||||||
|
There is also a docker image available to use. It is primarily used for the gh actions.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker pull ghcr.io/quirinecker/docki:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also build it yourself with nix.
|
||||||
|
|
||||||
|
```
|
||||||
|
nix build .#docker && docker load -i result
|
||||||
|
```
|
||||||
|
|
||||||
|
### Nix (Advanced, Flake)
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> There are multiple ways to install docki with nix. This is the way I installed it on my machine.
|
||||||
|
|
||||||
|
1. Add it to the flake inputs
|
||||||
|
|
||||||
|
```nix
|
||||||
|
docki = {
|
||||||
|
url = "github:quirinecker/docki";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Add `@inputs` at the end of the outputs (if you haven't already)
|
||||||
|
|
||||||
|
```nix
|
||||||
|
outputs = {
|
||||||
|
nixpkgs
|
||||||
|
...
|
||||||
|
}@inputs:
|
||||||
|
...Rest of your flake...
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Add the input to your system packages (system configuration) or home packages (home manager configuration)
|
||||||
|
|
||||||
|
```nix
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
inputs.docki.packages.${system}.default
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
```nix
|
||||||
|
home.packages = with pkgs; [
|
||||||
|
inputs.docki.packages.${system}.default
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
### Running it
|
||||||
|
|
||||||
|
If you just want to run it, you can use the `nix run` command. This will install all the build dependencies, build the binary and run it.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
nix run
|
||||||
|
```
|
||||||
|
|
||||||
|
### Development Shell
|
||||||
|
|
||||||
|
You can also use the development shell with the command below. In this shell all dependencies for building and running the project are installed.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
nix develop
|
||||||
|
```
|
||||||
|
|
||||||
|
Afterwards it can be built and run with cargo
|
||||||
|
|
||||||
|
```shell
|
||||||
|
cargo run -- <args>
|
||||||
|
```
|
||||||
|
|
||||||
|
|||||||
23
build.rs
23
build.rs
@@ -1,23 +0,0 @@
|
|||||||
use std::io::Error;
|
|
||||||
|
|
||||||
use clap::CommandFactory;
|
|
||||||
use clap_complete::{generate_to, shells::{Bash, Zsh, Fish}};
|
|
||||||
|
|
||||||
include!("src/app/args/structure.rs");
|
|
||||||
include!("src/app/fs_util/mod.rs");
|
|
||||||
|
|
||||||
fn main() -> Result<(), Error> {
|
|
||||||
generate_completions()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn generate_completions() -> Result<(), Error> {
|
|
||||||
let mut command = Args::command();
|
|
||||||
let home_path = env::var("HOME").expect("could not get home path");
|
|
||||||
let out_dir = format!("{}/.docki/completions/", home_path);
|
|
||||||
create_dir_recursive(&out_dir);
|
|
||||||
generate_to(Bash, &mut command, "docki", &out_dir)?;
|
|
||||||
generate_to(Zsh, &mut command, "docki", &out_dir)?;
|
|
||||||
generate_to(Fish, &mut command, "docki", &out_dir)?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
77
flake.lock
generated
77
flake.lock
generated
@@ -1,6 +1,63 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"fenix": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"naersk",
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"rust-analyzer-src": "rust-analyzer-src"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1752475459,
|
||||||
|
"narHash": "sha256-z6QEu4ZFuHiqdOPbYss4/Q8B0BFhacR8ts6jO/F/aOU=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "fenix",
|
||||||
|
"rev": "bf0d6f70f4c9a9cf8845f992105652173f4b617f",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "fenix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"naersk": {
|
||||||
|
"inputs": {
|
||||||
|
"fenix": "fenix",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1752689277,
|
||||||
|
"narHash": "sha256-uldUBFkZe/E7qbvxa3mH1ItrWZyT6w1dBKJQF/3ZSsc=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "naersk",
|
||||||
|
"rev": "0e72363d0938b0208d6c646d10649164c43f4d64",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "naersk",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1752077645,
|
||||||
|
"narHash": "sha256-HM791ZQtXV93xtCY+ZxG1REzhQenSQO020cu6rHtAPk=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "be9e214982e20b8310878ac2baa063a961c1bdf6",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixpkgs-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1760934318,
|
"lastModified": 1760934318,
|
||||||
"narHash": "sha256-/oUYsC0lUCBory65VK+UHqCCsCspbL1Vgfcf1KUYqVw=",
|
"narHash": "sha256-/oUYsC0lUCBory65VK+UHqCCsCspbL1Vgfcf1KUYqVw=",
|
||||||
@@ -18,10 +75,28 @@
|
|||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": "nixpkgs",
|
"naersk": "naersk",
|
||||||
|
"nixpkgs": "nixpkgs_2",
|
||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"rust-analyzer-src": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1752428706,
|
||||||
|
"narHash": "sha256-EJcdxw3aXfP8Ex1Nm3s0awyH9egQvB2Gu+QEnJn2Sfg=",
|
||||||
|
"owner": "rust-lang",
|
||||||
|
"repo": "rust-analyzer",
|
||||||
|
"rev": "591e3b7624be97e4443ea7b5542c191311aa141d",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "rust-lang",
|
||||||
|
"ref": "nightly",
|
||||||
|
"repo": "rust-analyzer",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"systems": {
|
"systems": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1681028828,
|
"lastModified": 1681028828,
|
||||||
|
|||||||
129
flake.nix
129
flake.nix
@@ -12,29 +12,71 @@
|
|||||||
nixpkgs,
|
nixpkgs,
|
||||||
systems,
|
systems,
|
||||||
naersk,
|
naersk,
|
||||||
|
self,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
eachSystem = f: nixpkgs.lib.genAttrs (import systems) (system: f nixpkgs.legacyPackages.${system});
|
eachSystem = f: nixpkgs.lib.genAttrs (import systems) (system: f nixpkgs.legacyPackages.${system});
|
||||||
build_asciidoctor_revealjs = pkgs: pkgs.buildRubyGem {
|
build_asciidoctor_revealjs =
|
||||||
gemName = "asciidoctor-revealjs";
|
pkgs:
|
||||||
version = "5.2.0";
|
pkgs.buildRubyGem {
|
||||||
source = {
|
gemName = "asciidoctor-revealjs";
|
||||||
type = "git";
|
version = "5.2.0";
|
||||||
url = "https://rubygems.org/downloads/asciidoctor-revealjs-5.2.0.gem";
|
source = {
|
||||||
sha256 = "sha256-NQSl5+ryyR3jf5YYkxT/sea/lNrZ1kbVyaJMZpG/auI=";
|
type = "git";
|
||||||
|
url = "https://rubygems.org/downloads/asciidoctor-revealjs-5.2.0.gem";
|
||||||
|
sha256 = "sha256-NQSl5+ryyR3jf5YYkxT/sea/lNrZ1kbVyaJMZpG/auI=";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
build_asciidoctor = pkgs: pkgs.buildRubyGem {
|
build_asciidoctor =
|
||||||
gemName = "asciidoctor";
|
pkgs:
|
||||||
version = "2.0.25";
|
pkgs.buildRubyGem {
|
||||||
source = {
|
gemName = "asciidoctor";
|
||||||
type = "git";
|
version = "2.0.25";
|
||||||
url = "https://rubygems.org/downloads/asciidoctor-2.0.25.gem";
|
source = {
|
||||||
sha256 = "sha256-sG/oIrCRDU4l6g9WL+z8eUjpRuIi79lJSEnSfaQmfRk=";
|
type = "git";
|
||||||
|
url = "https://rubygems.org/downloads/asciidoctor-2.0.25.gem";
|
||||||
|
sha256 = "sha256-sG/oIrCRDU4l6g9WL+z8eUjpRuIi79lJSEnSfaQmfRk=";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
build_docki =
|
||||||
|
{ naerskLib, pkgs }:
|
||||||
|
let
|
||||||
|
runtimeDeps = with pkgs; [
|
||||||
|
(ruby.withPackages (
|
||||||
|
p: with p; [
|
||||||
|
(build_asciidoctor_revealjs pkgs)
|
||||||
|
(build_asciidoctor pkgs)
|
||||||
|
bundler
|
||||||
|
]
|
||||||
|
))
|
||||||
|
];
|
||||||
|
in
|
||||||
|
naerskLib.buildPackage {
|
||||||
|
src = ./.;
|
||||||
|
buildInputs = [
|
||||||
|
];
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
pkg-config
|
||||||
|
openssl.dev
|
||||||
|
libiconv
|
||||||
|
makeWrapper
|
||||||
|
];
|
||||||
|
postInstall = ''
|
||||||
|
mkdir -p $out/share/bash-completion/completions
|
||||||
|
mkdir -p $out/share/zsh/site-functions
|
||||||
|
mkdir -p $out/share/fish/vendor_completions.d
|
||||||
|
|
||||||
|
$out/bin/docki completions bash > $out/share/bash-completion/completions/docki
|
||||||
|
$out/bin/docki completions zsh > $out/share/zsh/site-functions/_docki
|
||||||
|
$out/bin/docki completions fish > $out/share/fish/vendor_completions.d/docki.fish
|
||||||
|
|
||||||
|
wrapProgram $out/bin/docki --prefix PATH : ${pkgs.lib.makeBinPath runtimeDeps}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
devShells = eachSystem (pkgs: {
|
devShells = eachSystem (pkgs: {
|
||||||
@@ -56,36 +98,47 @@
|
|||||||
))
|
))
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
preview = pkgs.mkShell {
|
||||||
|
name = "docki-preview";
|
||||||
|
buildInputs = [
|
||||||
|
pkgs.zsh
|
||||||
|
pkgs.fish
|
||||||
|
pkgs.bash
|
||||||
|
self.packages.${pkgs.system}.default
|
||||||
|
];
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
packages = eachSystem (
|
packages = eachSystem (
|
||||||
pkgs:
|
pkgs:
|
||||||
let
|
let
|
||||||
naerskLib = pkgs.callPackage naersk { };
|
naerskLib = pkgs.callPackage naersk { };
|
||||||
runtimeDeps = with pkgs; [
|
|
||||||
(ruby.withPackages (
|
|
||||||
p: with p; [
|
|
||||||
(build_asciidoctor_revealjs pkgs)
|
|
||||||
(build_asciidoctor pkgs)
|
|
||||||
bundler
|
|
||||||
]
|
|
||||||
))
|
|
||||||
];
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
default = naerskLib.buildPackage {
|
default = build_docki {
|
||||||
src = ./.;
|
naerskLib = naerskLib;
|
||||||
buildInputs =[
|
pkgs = pkgs;
|
||||||
];
|
};
|
||||||
nativeBuildInputs = with pkgs; [
|
|
||||||
pkg-config
|
docker = pkgs.dockerTools.buildImage {
|
||||||
openssl.dev
|
name = "docki";
|
||||||
libiconv
|
tag = "latest";
|
||||||
makeWrapper
|
config = {
|
||||||
];
|
WorkingDir = "/app";
|
||||||
postInstall = ''
|
};
|
||||||
wrapProgram $out/bin/docki --prefix PATH : ${pkgs.lib.makeBinPath runtimeDeps}
|
copyToRoot = pkgs.buildEnv {
|
||||||
'';
|
name = "docki-docker";
|
||||||
|
paths = [
|
||||||
|
pkgs.coreutils
|
||||||
|
pkgs.bash
|
||||||
|
pkgs.cacert
|
||||||
|
(build_docki {
|
||||||
|
naerskLib = naerskLib;
|
||||||
|
pkgs = pkgs;
|
||||||
|
})
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
11
res/test/docs/slides/index.adoc
Normal file
11
res/test/docs/slides/index.adoc
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
= My cool presentation
|
||||||
|
:author: John Doe
|
||||||
|
:email: john@doe.com
|
||||||
|
|
||||||
|
== First slide
|
||||||
|
|
||||||
|
Content
|
||||||
|
|
||||||
|
== Second slide
|
||||||
|
|
||||||
|
Content
|
||||||
@@ -3,23 +3,38 @@ use clap::{Parser, Subcommand};
|
|||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
pub command: CommandArg
|
pub command: CommandArg,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subcommand)]
|
||||||
|
pub enum ShellArg {
|
||||||
|
Bash,
|
||||||
|
Fish,
|
||||||
|
Zsh,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
pub enum CommandArg {
|
pub enum CommandArg {
|
||||||
/// Builds the documentation into a dist folder
|
/// Builds the documentation into a dist folder
|
||||||
Build,
|
Build {
|
||||||
|
/// When set to true, docki will download revealjs before building the documentation.
|
||||||
|
/// Otherwise it will use the cdn for revealjs
|
||||||
|
#[arg(short, long)]
|
||||||
|
offline_reveal: bool,
|
||||||
|
},
|
||||||
/// Checks if everything required for docki is installed
|
/// Checks if everything required for docki is installed
|
||||||
Health,
|
Health,
|
||||||
/// Helper command for installing asciidoctor-reveal-js
|
/// Deprecated: Helper command for installing asciidoctor-reveal-js
|
||||||
InstallReveal,
|
InstallReveal,
|
||||||
/// Starts a Webserver with the live preview of the Documentation
|
/// Starts a Webserver with the live preview of the Documentation
|
||||||
Serve {
|
Serve {
|
||||||
/// Port for the Live Server
|
/// Port for the Live Server
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
port: Option<u16>
|
port: Option<u16>,
|
||||||
|
},
|
||||||
|
/// Generates completions for the desired shell
|
||||||
|
Completions {
|
||||||
|
#[command(subcommand)]
|
||||||
|
shell: ShellArg,
|
||||||
},
|
},
|
||||||
/// Information about the completions
|
|
||||||
Completions
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use std::process;
|
|
||||||
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
use std::process;
|
||||||
|
|
||||||
fn exec_command(command: &mut process::Command) -> Result<(), String> {
|
fn exec_command(command: &mut process::Command) -> Result<(), String> {
|
||||||
let result = command.output();
|
let result = command.output();
|
||||||
@@ -29,10 +28,14 @@ fn asciidoctor_docs(in_path: &str, out_path: &str) -> process::Command {
|
|||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn asciidoctor_slides(in_path: &str, out_path: &str) -> process::Command {
|
fn asciidoctor_slides(in_path: &str, out_path: &str, offline_reveal: bool) -> process::Command {
|
||||||
let mut command = process::Command::new(format!("asciidoctor-revealjs"));
|
let mut command = process::Command::new(format!("asciidoctor-revealjs"));
|
||||||
let out_dir = parent_path(out_path);
|
let out_dir = parent_path(out_path);
|
||||||
let revealjs_path = "/slides/revealjs";
|
let revealjs_path = if offline_reveal {
|
||||||
|
path_between(out_dir.to_string(), "./dist/slides/revealjs".to_string())
|
||||||
|
} else {
|
||||||
|
"https://cdn.jsdelivr.net/npm/reveal.js@5.2.1".to_string()
|
||||||
|
};
|
||||||
|
|
||||||
command
|
command
|
||||||
.arg(format!("{in_path}"))
|
.arg(format!("{in_path}"))
|
||||||
@@ -102,8 +105,8 @@ pub fn build_doc(in_path: &str, out_path: &str) -> Result<(), String> {
|
|||||||
return exec_command(&mut command);
|
return exec_command(&mut command);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_slide(in_path: &str, out_path: &str) -> Result<(), String> {
|
pub fn build_slide(in_path: &str, out_path: &str, offline_reveal: bool) -> Result<(), String> {
|
||||||
let mut command = asciidoctor_slides(in_path, out_path);
|
let mut command = asciidoctor_slides(in_path, out_path, offline_reveal);
|
||||||
return exec_command(&mut command);
|
return exec_command(&mut command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,16 +6,12 @@ use super::fs_util;
|
|||||||
|
|
||||||
pub mod asciidoctor;
|
pub mod asciidoctor;
|
||||||
|
|
||||||
pub trait Builder {
|
pub fn docki_build(in_path: &str, offline_reveal: bool) -> DockiBuildResult {
|
||||||
fn build(&self, in_path: &str, out_path: &str) -> Result<(), String>;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn docki_build(in_path: &str) -> DockiBuildResult {
|
|
||||||
let out_path = in_path.replace("/docs/", "/dist/");
|
let out_path = in_path.replace("/docs/", "/dist/");
|
||||||
let convert_out_path = out_path.replace(".adoc", ".html");
|
let convert_out_path = out_path.replace(".adoc", ".html");
|
||||||
|
|
||||||
if in_path.starts_with("./docs/slides/") && in_path.ends_with(".adoc") {
|
if in_path.starts_with("./docs/slides/") && in_path.ends_with(".adoc") {
|
||||||
if let Err(err) = build_slide(&in_path, &convert_out_path) {
|
if let Err(err) = build_slide(&in_path, &convert_out_path, offline_reveal) {
|
||||||
return DockiBuildResult::Err(err);
|
return DockiBuildResult::Err(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,6 +23,10 @@ pub fn docki_build(in_path: &str) -> DockiBuildResult {
|
|||||||
|
|
||||||
DockiBuildResult::Doc(convert_out_path)
|
DockiBuildResult::Doc(convert_out_path)
|
||||||
} else {
|
} else {
|
||||||
|
if in_path.starts_with("./docs/slides/revealjs") && !offline_reveal {
|
||||||
|
return DockiBuildResult::Silent;
|
||||||
|
}
|
||||||
|
|
||||||
if let Err(err) = copy(&in_path, &out_path) {
|
if let Err(err) = copy(&in_path, &out_path) {
|
||||||
return DockiBuildResult::Err(err);
|
return DockiBuildResult::Err(err);
|
||||||
}
|
}
|
||||||
@@ -35,11 +35,11 @@ pub fn docki_build(in_path: &str) -> DockiBuildResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn copy(in_path: &str, out_path: &str) -> Result<(), String> {
|
fn copy(in_path: &str, out_path: &str) -> Result<(), String> {
|
||||||
fs_util::create_parent_dir_recursive(out_path);
|
fs_util::create_parent_dir_recursive(out_path);
|
||||||
|
|
||||||
if let Err(err) = fs::copy(in_path, out_path) {
|
if let Err(err) = fs::copy(in_path, out_path) {
|
||||||
return Err(err.to_string())
|
return Err(err.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -50,4 +50,5 @@ pub enum DockiBuildResult {
|
|||||||
Doc(String),
|
Doc(String),
|
||||||
Copy(String),
|
Copy(String),
|
||||||
Err(String),
|
Err(String),
|
||||||
|
Silent,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use super::executions::build_execution::BuildExecution;
|
use super::executions::build_execution::BuildExecution;
|
||||||
|
|
||||||
pub async fn build() -> () {
|
pub async fn build(offline_reveal: bool) -> () {
|
||||||
let mut build_execution = BuildExecution::new();
|
let mut build_execution = BuildExecution::new();
|
||||||
build_execution.execute().await.expect("build failed")
|
build_execution.execute(offline_reveal).await.expect("build failed")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,16 @@
|
|||||||
use colored::Colorize;
|
use std::io;
|
||||||
|
|
||||||
const INFO: &str = "
|
use clap::CommandFactory;
|
||||||
You can add completions for docki with the following methods. If you want the completions to be persistent add
|
use clap_complete::{generate, shells::{Bash, Fish, Zsh}};
|
||||||
them to a init file e.g. ~/.zshrc, ~/.bashrc, ~/.config/fish/config.fish.
|
|
||||||
|
|
||||||
Get Fish Completions
|
use crate::app::args::structure::{Args, ShellArg};
|
||||||
source ~/.docki/completions/docki.fish
|
|
||||||
|
|
||||||
Get Zsh Completions
|
pub fn completions(shell: ShellArg) {
|
||||||
source ~/.docki/completions/_docki
|
let mut command = Args::command();
|
||||||
|
|
||||||
Get Bash Completions
|
match shell {
|
||||||
source ~/.docki/completions/docki.bash
|
ShellArg::Bash => generate(Bash, &mut command, "docki", &mut io::stdout()),
|
||||||
";
|
ShellArg::Fish => generate(Fish, &mut command, "docki", &mut io::stdout()),
|
||||||
|
ShellArg::Zsh => generate(Zsh, &mut command, "docki", &mut io::stdout()),
|
||||||
pub fn completions() {
|
}
|
||||||
println!();
|
|
||||||
println!("{}", "Completions".blue().bold());
|
|
||||||
println!("{}", INFO.bright_black());
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ impl BuildExecution {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn execute(&mut self) -> Result<(), String> {
|
pub async fn execute(&mut self, offline_reveal: bool) -> Result<(), String> {
|
||||||
let path = "./docs/".to_string();
|
let path = "./docs/".to_string();
|
||||||
|
|
||||||
if !fs_util::directory_exists(&path) {
|
if !fs_util::directory_exists(&path) {
|
||||||
@@ -30,20 +30,25 @@ impl BuildExecution {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(error) = Self::prepare().await {
|
if let Err(error) = Self::prepare(offline_reveal).await {
|
||||||
return Err(error);
|
return Err(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.build_dir(&path);
|
return self.build_dir(&path, offline_reveal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async fn prepare() -> Result<(), String> {
|
async fn prepare(offline_reveal: bool) -> Result<(), String> {
|
||||||
let reveal_version = "3.9.2";
|
if !offline_reveal {
|
||||||
|
return Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
let reveal_version = "5.2.1";
|
||||||
let target = format!("https://github.com/hakimel/reveal.js/archive/{reveal_version}.zip");
|
let target = format!("https://github.com/hakimel/reveal.js/archive/{reveal_version}.zip");
|
||||||
|
|
||||||
create_dir_recursive("./docs/slides");
|
create_dir_recursive("./docs/slides");
|
||||||
|
|
||||||
|
reqwest::get(target.clone()).await.unwrap();
|
||||||
let Ok(response) = reqwest::get(target).await else {
|
let Ok(response) = reqwest::get(target).await else {
|
||||||
return Err("could not downlaod revealjs".to_string())
|
return Err("could not downlaod revealjs".to_string())
|
||||||
};
|
};
|
||||||
@@ -61,7 +66,7 @@ impl BuildExecution {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_dir(&mut self, path: &str) -> Result<(), String> {
|
fn build_dir(&mut self, path: &str, offline_reveal: bool) -> Result<(), String> {
|
||||||
let result = fs_util::fetch_paths_recursive(&path);
|
let result = fs_util::fetch_paths_recursive(&path);
|
||||||
|
|
||||||
let Ok(paths) = result else {
|
let Ok(paths) = result else {
|
||||||
@@ -71,7 +76,7 @@ impl BuildExecution {
|
|||||||
for (index, in_path) in paths.iter().enumerate() {
|
for (index, in_path) in paths.iter().enumerate() {
|
||||||
self.progress = index + 1;
|
self.progress = index + 1;
|
||||||
self.goal = paths.len();
|
self.goal = paths.len();
|
||||||
let result = docki_build(&in_path);
|
let result = docki_build(&in_path, offline_reveal);
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
DockiBuildResult::Err(err) => {
|
DockiBuildResult::Err(err) => {
|
||||||
@@ -80,7 +85,8 @@ impl BuildExecution {
|
|||||||
},
|
},
|
||||||
DockiBuildResult::Copy(out_path) => self.display_building_status("Copy", &in_path, &out_path),
|
DockiBuildResult::Copy(out_path) => self.display_building_status("Copy", &in_path, &out_path),
|
||||||
DockiBuildResult::Slide(out_path) => self.display_building_status("Slide", &in_path, &out_path),
|
DockiBuildResult::Slide(out_path) => self.display_building_status("Slide", &in_path, &out_path),
|
||||||
DockiBuildResult::Doc(out_path) => self.display_building_status("Doc", &in_path, &out_path)
|
DockiBuildResult::Doc(out_path) => self.display_building_status("Doc", &in_path, &out_path),
|
||||||
|
DockiBuildResult::Silent => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use std::{process::Command, io::ErrorKind};
|
use nu_ansi_term::Color::{LightGray, LightGreen, LightRed};
|
||||||
use colored::Colorize;
|
use std::{io::ErrorKind, process::Command};
|
||||||
|
|
||||||
const INFO_ASCIIDOC: &str = "
|
const INFO_ASCIIDOC: &str = "
|
||||||
Install the binary with your package manager!
|
Install the binary with your package manager!
|
||||||
@@ -37,7 +37,7 @@ fn check_reveal() -> () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn reveal_is_installed() -> bool {
|
fn reveal_is_installed() -> bool {
|
||||||
return check_command("asciidoctor-revealjs")
|
return check_command("asciidoctor-revealjs");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_asciidoc() -> () {
|
fn check_asciidoc() -> () {
|
||||||
@@ -49,23 +49,21 @@ fn check_asciidoc() -> () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn asciidoc_is_installed() -> bool {
|
fn asciidoc_is_installed() -> bool {
|
||||||
return check_command("asciidoctor")
|
return check_command("asciidoctor");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_command(command: &str) -> bool {
|
fn check_command(command: &str) -> bool {
|
||||||
return match Command::new(command)
|
return match Command::new(command).output() {
|
||||||
.output() {
|
|
||||||
Ok(_) => true,
|
Ok(_) => true,
|
||||||
Err(e) => ErrorKind::NotFound != e.kind()
|
Err(e) => ErrorKind::NotFound != e.kind(),
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_health_ok(name: &str) {
|
fn print_health_ok(name: &str) {
|
||||||
println!("- ✔️ {}", name.bright_green());
|
println!("- ✔️ {}", LightGreen.paint(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_health_not_ok(name: &str, info: &str) {
|
fn print_health_not_ok(name: &str, info: &str) {
|
||||||
println!("- ❗{}", name.bright_red());
|
println!("- ❗{}", LightRed.paint(name));
|
||||||
println!("{}", info.bright_black())
|
println!("{}", LightGray.paint(info))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use colored::Colorize;
|
use nu_ansi_term::Color::Green;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use live_server::listen;
|
use live_server::listen;
|
||||||
use notify::{
|
use notify::{
|
||||||
@@ -11,7 +11,7 @@ use crate::app::{ watcher::watcher, build::{docki_build, DockiBuildResult}, comm
|
|||||||
|
|
||||||
|
|
||||||
pub async fn serve(port: Option<u16>) {
|
pub async fn serve(port: Option<u16>) {
|
||||||
build().await;
|
build(false).await;
|
||||||
tokio::join!(watch_and_build(), start_server(port));
|
tokio::join!(watch_and_build(), start_server(port));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,15 +21,18 @@ async fn watch_and_build() {
|
|||||||
.expect("something went wrong")
|
.expect("something went wrong")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async fn start_server(port: Option<u16>) {
|
async fn start_server(port: Option<u16>) {
|
||||||
let unwrapped_port = port.unwrap_or(8080);
|
let port = port.unwrap_or(8080);
|
||||||
|
let link = &format!("http://localhost:{}", port);
|
||||||
|
let hyperlink = Green.paint(link).hyperlink(link);
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"\nServing at {}{} ",
|
"\nServing at {}",
|
||||||
"http://localhost:".bold(),
|
hyperlink
|
||||||
unwrapped_port.to_string().bold()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let Ok(()) = listen("localhost", port.unwrap_or(8080), "./dist").await else {
|
let Ok(()) = listen("localhost", port, "./dist").await else {
|
||||||
panic!("could not start server")
|
panic!("could not start server")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -59,13 +62,13 @@ fn build_file(paths: Vec<std::path::PathBuf>) {
|
|||||||
let in_path = paths
|
let in_path = paths
|
||||||
.first()
|
.first()
|
||||||
.expect(invalid_path_message)
|
.expect(invalid_path_message)
|
||||||
|
.strip_prefix(¤t_dir())
|
||||||
|
.expect(invalid_path_message)
|
||||||
.to_str()
|
.to_str()
|
||||||
.expect(invalid_path_message)
|
.expect(invalid_path_message);
|
||||||
.replace(¤t_dir(), "")
|
|
||||||
.replace("/./", "./");
|
|
||||||
|
|
||||||
|
let in_path = format!("./{}", in_path);
|
||||||
let result = docki_build(&in_path);
|
let result = docki_build(&in_path, false);
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
DockiBuildResult::Slide(out_path) => display_rebuilding_status("Slide", &in_path, &out_path),
|
DockiBuildResult::Slide(out_path) => display_rebuilding_status("Slide", &in_path, &out_path),
|
||||||
@@ -75,6 +78,7 @@ fn build_file(paths: Vec<std::path::PathBuf>) {
|
|||||||
display_rebuilding_status("Error", &in_path, "");
|
display_rebuilding_status("Error", &in_path, "");
|
||||||
println!("{}", err);
|
println!("{}", err);
|
||||||
},
|
},
|
||||||
|
DockiBuildResult::Silent => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,19 @@
|
|||||||
use colored::Colorize;
|
use nu_ansi_term::Color::LightGreen;
|
||||||
|
use nu_ansi_term::Color::LightRed;
|
||||||
|
use nu_ansi_term::Style;
|
||||||
|
|
||||||
pub fn display_status(context1: &str, context2: &str, in_path: &str, out_path: &str) {
|
pub fn display_status(context1: &str, context2: &str, in_path: &str, out_path: &str) {
|
||||||
let colored_context = color_context(context2);
|
let colored_context = if context2 == "Error" {
|
||||||
|
LightRed.paint(context2)
|
||||||
|
} else {
|
||||||
|
LightGreen.paint(context2)
|
||||||
|
};
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"({}) [{}] {} -> {}",
|
"({}) [{}] {} -> {}",
|
||||||
context1.bold(),
|
Style::new().paint(context1),
|
||||||
colored_context,
|
colored_context,
|
||||||
in_path,
|
in_path,
|
||||||
out_path
|
out_path
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn color_context(context: &str) -> colored::ColoredString {
|
|
||||||
if context == "Error" {
|
|
||||||
return context.bright_red()
|
|
||||||
} else {
|
|
||||||
return context.bright_green()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ impl App {
|
|||||||
Self::setup_environment_variables();
|
Self::setup_environment_variables();
|
||||||
|
|
||||||
match args.command {
|
match args.command {
|
||||||
CommandArg::Build => build().await,
|
CommandArg::Build { offline_reveal } => build(offline_reveal).await,
|
||||||
CommandArg::Health => health(),
|
CommandArg::Health => health(),
|
||||||
CommandArg::InstallReveal => install_reveal().await,
|
CommandArg::InstallReveal => install_reveal().await,
|
||||||
CommandArg::Serve { port } => serve(port).await,
|
CommandArg::Serve { port } => serve(port).await,
|
||||||
CommandArg::Completions => completions()
|
CommandArg::Completions { shell } => completions(shell)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
use crate::app::build::asciidoctor;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn last_matching_index_0() {
|
|
||||||
let vec1 = vec!["dings", "dings", "dingens"].iter().map(|s| s.to_string()).collect();
|
|
||||||
let vec2 = vec!["dings", "dings", "dings"].iter().map(|s| s.to_string()).collect();
|
|
||||||
|
|
||||||
let last_maching = asciidoctor::matching_from_start(&vec1, &vec2);
|
|
||||||
assert_eq!(last_maching, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn last_matching_index_1() {
|
|
||||||
let vec1 = vec!["dings", "dings", "dingens", "dings", "dingens"].iter().map(|s| s.to_string()).collect();
|
|
||||||
let vec2 = vec!["dings", "dings", "dingens", "dings"].iter().map(|s| s.to_string()).collect();
|
|
||||||
|
|
||||||
let last_maching = asciidoctor::matching_from_start(&vec1, &vec2);
|
|
||||||
assert_eq!(last_maching, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn path_between_0() {
|
|
||||||
let path1 = "./docs/dings";
|
|
||||||
let path2 = "./dist/dings";
|
|
||||||
|
|
||||||
let path_between = asciidoctor::path_between(path1.to_string(), path2.to_string());
|
|
||||||
assert_eq!(path_between, "../../dist/dings");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn path_between_1() {
|
|
||||||
let path1 = "./dist/slides/core/";
|
|
||||||
let path2 = "./dist/slides/revealjs";
|
|
||||||
|
|
||||||
let path_between = asciidoctor::path_between(path1.to_string(), path2.to_string());
|
|
||||||
assert_eq!(path_between, "../revealjs")
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,5 +5,5 @@ fn test_fetch_asciidoctor_paths_recursive() {
|
|||||||
let paths = fs_util::fetch_paths_recursive("res/test/docs").unwrap();
|
let paths = fs_util::fetch_paths_recursive("res/test/docs").unwrap();
|
||||||
let len = paths.len();
|
let len = paths.len();
|
||||||
dbg!(paths);
|
dbg!(paths);
|
||||||
assert_eq!(len, 5);
|
assert_eq!(len, 6);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user