Skip to content

Commit

Permalink
chore: update REAMD and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
amr-crabnebula committed Sep 27, 2023
1 parent d6e8a6d commit fede6bf
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 22 deletions.
69 changes: 62 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,79 @@
# cargo-packager

Rust executable packager, bundler and updater.
Rust executable packager, bundler and updater. A tool and library to generate installers or app bundles for your executables.
It also has a comptabile updater through [cargo-packager-updater](https://docs.rs/cargo-packager-updater).

## Installation
## CLI

```
### Installation

```sh
cargo install cargo-pacakger --locked
```

## Usage
### Usage

```
```sh
cargo pacakger
```

## Configuration
### Supported pacakges

- macOS
- DMG (.dmg)
- Bundle (.app)
- Linux
- Debian package (.deb)
- AppImage (.AppImage)
- Windows
- NSIS (.exe)
- MSI using WiX Toolset (.msi)

### Configuration

By default, `cargo-pacakger` reads configuration from `Packager.toml` or `pacakger.json` if exists, and from `package.metadata.packager` table in `Cargo.toml`.
You can specify a custom configuration file using `-c/--config` flag. All configuration options could be either a single config or array of configs.
You can also specify a custom configuration file using `-c/--config` cli argument.
All configuration options could be either a single config or array of configs.

For full list of configuration options, see https://docs.rs/cargo-packager/latest/cargo-packager/struct.Config.html

You could also use the schema from GitHub releases to validate your configuration or have auto completions in your IDE.

### Building your application before packaging

By default, `cargo-packager` doesn't build your application, it only looks for it inside the directory specified in `config.out_dir` or `--out-dir` cli arg,
However, `cargo-pacakger` has an option to specify a shell command to be executed before packaing your app, `beforePackagingCommand`.

### Cargo profiles

By default, `cargo-packager` looks for binaries built using the `debug` profile, if your `beforePackagingCommand` builds your app using `cargo build --release`, you will also need to
run `cargo-pacakger` in release mode `cargo packager --release`, otherwise, if you have a custom cargo profile, you will need to specify it using `--profile` cli arg `cargo pacakger --profile custom-release-profile`.

For more information, checkout the available [configuration options](https://docs.rs/cargo-packager/latest/cargo-packager/struct.Config.html) and for a list of available CLI
commands and arguments, run `cargo packager --help`.

## Examples

The [`examples`](./examples/) directory contains a number of varying examples, if you want to build them all run `cargo r -p cargo-pacakger -- --release` in the root of this repository. Just make sure to have the tooling for each example installed on your system. You can find what tooling they require by checking the README in each example. The README also contains a command to build this example alone if you wish.

Examples list (non-exhaustive):

- [`tauri`](./examples/tauri/)
- [`wry`](./examples/wry/)
- [`dioxus`](./examples/dioxus/)
- [`egui`](./examples/egui/)
- [`deno`](./examples/deno/)
- [`slint`](./examples/slint/)

## Library

This crate is also published to crates.io as a library that you can integrate into your tooling, just make sure to disable the default-feature flags.

```sh
cargo add cargo-packager --no-default-features
```

#### Feature flags

- **`cli`**: Enables the CLI specifc features and dependencies. Enabled by default.
- **`tracing`**: Enables `tracing` crate integration.
1 change: 1 addition & 0 deletions crates/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.0.0"
description = "Config types for cargo-packager."
edition = "2021"
license = "Apache-2.0 OR MIT"
repository = "https://github.com/crabnebula-dev/cargo-packager"

[features]
clap = ["dep:clap"]
Expand Down
11 changes: 10 additions & 1 deletion crates/packager/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
[package]
name = "cargo-packager"
version = "0.0.0"
description = "Rust executable packager and bundler."
description = "Rust executable packager and bundler CLI and library."
edition = "2021"
license = "Apache-2.0 OR MIT"
keywords = ["bundle", "package", "cargo"]
categories = [
"command-line-interface",
"command-line-utilities",
"development-tools::cargo-plugins",
"development-tools::build-utils",
"os",
]
repository = "https://github.com/crabnebula-dev/cargo-packager"

[features]
default = ["cli"]
Expand Down
69 changes: 61 additions & 8 deletions crates/packager/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,77 @@
# cargo-packager
Rust executable packager, bundler and updater. A tool and library to generate installers or app bundles for your executables.
It also has a comptabile updater through [cargo-packager-updater](https://docs.rs/cargo-packager-updater).

Rust executable packager and bundler CLI and library.
## CLI

## Installation
### Installation

```
```sh
cargo install cargo-pacakger --locked
```

## Usage
### Usage

```
```sh
cargo pacakger
```

## Configuration
### Supported pacakges

- macOS
- DMG (.dmg)
- Bundle (.app)
- Linux
- Debian package (.deb)
- AppImage (.AppImage)
- Windows
- NSIS (.exe)
- MSI using WiX Toolset (.msi)

### Configuration

By default, `cargo-pacakger` reads configuration from `Packager.toml` or `pacakger.json` if exists, and from `package.metadata.packager` table in `Cargo.toml`.
You can specify a custom configuration file using `-c/--config` flag.
You can also specify a custom configuration file using `-c/--config` cli argument.
All configuration options could be either a single config or array of configs.

For full list of configuration options, see https://docs.rs/cargo-packager/latest/cargo-packager/struct.Config.html

You could also use the schema from GitHub releases to validate your configuration or have auto completions in your IDE.

### Building your application before packaging

By default, `cargo-packager` doesn't build your application, it only looks for it inside the directory specified in `config.out_dir` or `--out-dir` cli arg,
However, `cargo-pacakger` has an option to specify a shell command to be executed before packaing your app, `beforePackagingCommand`.

### Cargo profiles

By default, `cargo-packager` looks for binaries built using the `debug` profile, if your `beforePackagingCommand` builds your app using `cargo build --release`, you will also need to
run `cargo-pacakger` in release mode `cargo packager --release`, otherwise, if you have a custom cargo profile, you will need to specify it using `--profile` cli arg `cargo pacakger --profile custom-release-profile`.

For more information, checkout the available [configuration options](https://docs.rs/cargo-packager/latest/cargo-packager/struct.Config.html) and for a list of available CLI
commands and arguments, run `cargo packager --help`.

## Examples

The [`examples`](../../examples/) directory contains a number of varying examples, if you want to build them all run `cargo r -p cargo-pacakger -- --release` in the root of this repository. Just make sure to have the tooling for each example installed on your system. You can find what tooling they require by checking the README in each example. The README also contains a command to build this example alone if you wish.

Examples list (non-exhaustive):

- [`tauri`](../../examples/tauri/)
- [`wry`](../../examples/wry/)
- [`dioxus`](../../examples/dioxus/)
- [`egui`](../../examples/egui/)
- [`deno`](../../examples/deno/)
- [`slint`](../../examples/slint/)

## Library

This crate is also published to crates.io as a library that you can integrate into your tooling, just make sure to disable the default-feature flags.

```sh
cargo add cargo-packager --no-default-features
```

#### Feature flags

- **`cli`**: Enables the CLI specifc features and dependencies. Enabled by default.
- **`tracing`**: Enables `tracing` crate integration.
3 changes: 3 additions & 0 deletions crates/packager/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Configuration type and associated utilities.

use std::path::{Path, PathBuf};

pub use cargo_packager_config::*;
Expand All @@ -11,6 +13,7 @@ pub(crate) struct IResource {
pub target: PathBuf,
}

/// [Config] extenstion trait
pub trait ConfigExt {
/// Returns the windows specific configuration
fn windows(&self) -> Option<&WindowsConfig>;
Expand Down
7 changes: 6 additions & 1 deletion crates/packager/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ pub enum Error {
/// Invalid framework.
#[error("Invalid framework {framework}: {reason}")]
InvalidFramework {
/// Framework name
framework: String,
/// Reason why this framework is invalid
reason: &'static str,
},
/// Invalid icons.
Expand All @@ -158,7 +160,10 @@ pub enum Error {
FailedToParseNotarytoolOutput(String),
/// Failed to find API key file.
#[error("Could not find API key file. Please set the APPLE_API_KEY_PATH environment variables to the path to the {filename} file")]
ApiKeyMissing { filename: String },
ApiKeyMissing {
/// Filename of the API key.
filename: String,
},
/// Missing notarize environment variables.
#[error("Could not find APPLE_ID & APPLE_PASSWORD or APPLE_API_KEY & APPLE_API_ISSUER & APPLE_API_KEY_PATH environment variables found")]
MissingNotarizeAuthVars,
Expand Down
61 changes: 57 additions & 4 deletions crates/packager/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,70 @@
//! cargo-packager is a tool that generates installers or app bundles for rust executables.
//! It supports auto updating through [cargo-update-packager](https://docs.rs/cargo-update-packager).
//! `cargo-packager` is a tool and library to generate installers or app bundles for your executables.
//! It also has a comptabile updater through [cargo-packager-updater](https://docs.rs/cargo-packager-updater).
//!
//! ## CLI
//!
//! ### Installation
//!
//! ```sh
//! cargo install cargo-pacakger --locked
//! ```
//!
//! ### Usage
//!
//! ```sh
//! cargo pacakger
//! ```
//!
//! ### Supported pacakges
//!
//! # Platform support
//! - macOS
//! - DMG (.dmg)
//! - Bundle (.app)
//! - Linux
//! - Debian package (.deb)
//! - AppImage (.AppImage)
//! - Windows
//! - MSI using WiX Toolset (.msi)
//! - NSIS (.exe)
//! - MSI using WiX Toolset (.msi)
//!
//! ### Configuration
//!
//! By default, `cargo-pacakger` reads configuration from `Packager.toml` or `pacakger.json` if exists, and from `package.metadata.packager` table in `Cargo.toml`.
//! You can also specify a custom configuration file using `-c/--config` cli argument.
//! All configuration options could be either a single config or array of configs.
//!
//! For full list of configuration options, see [config::Config]
//!
//! You could also use the schema from GitHub releases to validate your configuration or have auto completions in your IDE.
//!
//! ### Building your application before packaging
//!
//! By default, `cargo-packager` doesn't build your application, it only looks for it inside the directory specified in `config.out_dir` or `--out-dir` cli arg,
//! However, `cargo-pacakger` has an option to specify a shell command to be executed before packaing your app, `beforePackagingCommand`.
//!
//! ### Cargo profiles
//!
//! By default, `cargo-packager` looks for binaries built using the `debug` profile, if your `beforePackagingCommand` builds your app using `cargo build --release`, you will also need to
//! run `cargo-pacakger` in release mode `cargo packager --release`, otherwise, if you have a custom cargo profile, you will need to specify it using `--profile` cli arg `cargo pacakger --profile custom-release-profile`.
//!
//! For more information, checkout the available [configuration options](config::Config) and for a list of available CLI
//! commands and arguments, run `cargo packager --help`.
//!
//! ## Library
//!
//! This crate is also published to crates.io as a library that you can integrate into your tooling, just make sure to disable the default-feature flags.
//!
//! ```sh
//! cargo add cargo-packager --no-default-features
//! ```
//!
//! #### Feature flags
//!
//! - **`cli`**: Enables the CLI specifc features and dependencies. Enabled by default.
//! - **`tracing`**: Enables `tracing` crate integration.

#![cfg_attr(doc_cfg, feature(doc_cfg))]
#![deny(missing_docs)]

use std::path::PathBuf;

Expand Down
3 changes: 3 additions & 0 deletions crates/packager/src/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ use minisign::{sign, KeyPair as KP, SecretKey, SecretKeyBox};

use crate::util;

/// A public and secret key pair.
#[derive(Clone, Debug)]
pub struct KeyPair {
/// Publick key
pub pk: String,
/// Secret key
pub sk: String,
}

Expand Down
2 changes: 1 addition & 1 deletion crates/updater/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ version = "0.0.0"
description = "Rust executable updater."
edition = "2021"
license = "Apache-2.0 OR MIT"

repository = "https://github.com/crabnebula-dev/cargo-packager"

[dependencies]

0 comments on commit fede6bf

Please sign in to comment.