Skip to content

Commit

Permalink
chore: 🎨 better docs + public release (soon)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelrcamargo committed Jun 28, 2023
1 parent 7e65d59 commit 49860fa
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ Cargo.lock
**/Cargo.lock

*-lock.yaml

example/
.DS_Store
63 changes: 58 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ qx link <FLAGS>
<details>
<summary>🖥️ Windows</summary>

> **Warn**: Tested on version `0`.0.0`, newer versions are expected to work, but not covered.
> **Warn**: Tested on version `0.0.0`, newer versions are expected to work, but not covered.
```powershell
Invoke-WebRequest -Uri https://raw.githubusercontent.com/rafaelrcamargo/quix/main/release/add_to_path.ps1?token=GHSAT0AAAAAABQRQIGNWZVRGJSTIAH46OLAYZYP4VQ -OutFile install.ps1; .\install.ps1
git clone https://github.com/rafaelrcamargo/quix
cd quix
cargo run # OR cargo build --release
```

</details>
Expand All @@ -74,18 +77,24 @@ Invoke-WebRequest -Uri https://raw.githubusercontent.com/rafaelrcamargo/quix/mai
<summary>🍎 MacOS</summary>

```bash
curl -s https://raw.githubusercontent.com/rafaelrcamargo/quix/main/release/add_to_path.sh?token=GHSAT0AAAAAABQRQIGMIQULFXTTFIS76DDQYZYP5GA | bash
git clone https://github.com/rafaelrcamargo/quix
cd quix

cargo run # OR cargo build --release
```

</details>

<details>
<summary>🐧 Linux</summary>

> **Warn**: Tested on version `0`.0.0`, newer versions are expected to work, but not covered.
> **Warn**: Tested on version `0.0.0`, newer versions are expected to work, but not covered.
```bash
curl -s https://raw.githubusercontent.com/rafaelrcamargo/quix/main/release/add_to_path.sh?token=GHSAT0AAAAAABQRQIGMIQULFXTTFIS76DDQYZYP5GA | bash
git clone https://github.com/rafaelrcamargo/quix
cd quix

cargo run # OR cargo build --release
```

</details>
Expand All @@ -109,6 +118,48 @@ One of the main focuses of this project is performance. We have implemented and

</details>

<summary>

### ⚖️ Release + Compression

</summary>

<br>

With the search for a small and efficient binary, we have implemented a release script that uses the common `cargo` commands to build the binary, and then compress it using the [UPX](https://upx.github.io/) tool with reduced the final binary size by **~40%** (On Mac).

```sh
File size Ratio Format Name
-------------------- ------ ----------- -----------
1990232 -> 786448 39.52% macho/arm64 quix
```

With this we finish with a binary that weights **~750K**, wich is a great improvement from the original **~1.2M**, it's a known fact that the Rust compiler generates binaries with a bigger size, but with this we can reduce the size of the binary to a more reasonable size.

```sh
-rwxr-xr-x@ 1 .... staff 768K ... .. ..:.. ./quix
```

<a name="results">

## 📊 Results

</a>

The following results were obtained using the `time` utils on Mac OS on a MacBook Air M1.

> Time can sound as a weird choice based on the modern standards, but as both of the CLI's keep running in watch mode, the test's were made based on the first sight of the `Linked successfully` message.
![banner.png](./assets/banner.png)

<div align="center">
On the left, the original VTEX CLI, and on the right, the Quix CLI. <i>(Between tests, the cache was cleared and all apps we're unlinked)</i>
</div>

<br />

> **Note**: The results may vary depending on the machine and the project.
<a name="known-issues">

# 🕵️ Known issues
Expand Down Expand Up @@ -141,6 +192,8 @@ This will enable the GPU acceleration for the terminal, and it will fix the rend

Contributions to this project are welcome! If you have any suggestions or improvements, please open an issue or pull request.

> **Warn**: The `/release` & `/scripts` are now deprecated, and will be removed in the future.
<a name="license">

# ⚠️ License
Expand Down
Binary file added assets/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion release/add_to_path.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export PATH=$PATH:$(pwd) && echo "export PATH=\$PATH:$(pwd)" >> ~/.bashrc && echo "" && echo "✓ Quix successfully added to PATH :D"
export PATH=$PATH:$(pwd) && echo "export PATH=\$PATH:$(pwd)" >> ~/.zshrc && echo "" && echo "✓ Quix successfully added to PATH :D"
Binary file added release/quix
Binary file not shown.
Binary file removed release/quix.exe
Binary file not shown.
5 changes: 3 additions & 2 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ echo "Starting release script!"
echo ""
echo "> Building..."
echo ""
cargo +nightly build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target x86_64-pc-windows-msvc --release
# Windows: cargo +nightly build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target x86_64-pc-windows-msvc --release
# Mac M1: cargo +nightly build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target aarch64-apple-darwin --release
echo ""
echo "> Moving..."
mv ./target/x86_64-pc-windows-msvc/release/quix.exe ./release/quix.exe
Expand All @@ -12,4 +13,4 @@ echo ""
upx --best --lzma ./release/quix.exe
echo ""
echo "Release complete!"
echo ""
echo ""
24 changes: 11 additions & 13 deletions src/cli/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//! This function will panic if the entered command does not follow any of the available.
// ? CLI
use clap::{Arg, ArgAction, ArgMatches, ColorChoice, Command}; // CLI Argument parser
use clap::{arg, Arg, ArgAction, ArgMatches, ColorChoice, Command}; // CLI Argument parser

pub fn matches() -> ArgMatches {
// ? CLI Setup
Expand Down Expand Up @@ -47,21 +47,19 @@ pub fn matches() -> ArgMatches {
Command::new("link")
.about("Link a app or store to a project.")
.arg(
Arg::new("clean")
.conflicts_with("quicker")
.short('c')
.long("clean")
.required(false)
.action(ArgAction::SetTrue)
.help("Clean the project before linking."),
arg!(--clean "Clean the project before linking.")
.short('c')
.long("clean")
.required(false)
.conflicts_with("quicker")
.help("Clean the project before linking."),
)
.arg(
Arg::new("quicker")
arg!(--quicker "Ignores some validations and links the app faster.")
.short('q')
.long("quicker")
.required(false)
.conflicts_with("clean")
.short('q')
.long("quicker")
.required(false)
.action(ArgAction::SetTrue)
.help("Ignores some validations and links the app faster."),
),
)
Expand Down
12 changes: 7 additions & 5 deletions src/commands/link/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,12 @@ pub fn link(args: &ArgMatches) {
}
};

fn has_arg(args: &ArgMatches, id: &str) -> bool {
args.get_one::<bool>(id).is_some_and(|x| *x == true)
}

// ? Args parsing.
if args.contains_id("clean") {
if has_arg(args, "clean") {
warn!("This feature can cause the CLI to run slower ⌛️, only use when really necessary.");
trace!("🧹 Cleaning project cache...\n");

Expand All @@ -86,10 +90,8 @@ pub fn link(args: &ArgMatches) {
error!("Error cleaning project cache: {}", e);
}
}
} else if args.contains_id("quicker") {
warn!(
"This feature still under development, and can cause some issues 💣. Use it carefully."
);
} else if has_arg(args, "quicker") {
warn!("This feature still under development, and can cause some issues 💣.");
trace!("⚗️ Linking your project quicker...\n");
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/b64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! use b64::encode(path); // Encode a file into a Base64 string.
//! ```
use base64::{Engine as _, engine::{general_purpose}};
use base64::{engine::general_purpose, Engine as _};

use std::{
fs::File,
Expand Down

0 comments on commit 49860fa

Please sign in to comment.