### Package Slint Example App Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/examples/slint/README.md Use this command to package the Slint example application in release mode. ```sh cargo r -p cargo-packager -- -p slint-example --release ``` -------------------------------- ### Install dioxus-cli Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/examples/dioxus/README.md Installs the dioxus-cli tool. Ensure you have Rust and Cargo installed. ```sh cargo install dioxus-cli --locked ``` -------------------------------- ### Install wails CLI Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/examples/wails/README.md Installs the wails command-line interface tool. Ensure Go is installed first. ```sh go install github.com/wailsapp/wails/v2/cmd/wails@latest ``` -------------------------------- ### Package WRY Example App Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/examples/wry/README.md Use this command to package the WRY example application for release. Ensure you are in the correct project directory. ```sh cargo r -p cargo-packager -- -p wry-example --release ``` -------------------------------- ### Package EGUI Example App Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/examples/egui/README.md Use this command to package the 'egui-example' application for release builds. Ensure you are in the project root directory. ```sh cargo r -p cargo-packager -- -p egui-example --release ``` -------------------------------- ### Package Deno App with Cargo Packager Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/examples/deno/README.md Use this command to package your Deno application for release. Ensure you have deno installed and have completed the initial setup. ```sh cargo r -p cargo-packager -- -p deno-example --release ``` -------------------------------- ### Install @crabnebula/packager CLI Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/bindings/packager/nodejs/README.md Install the packager as a development dependency using your preferred package manager. ```sh # pnpm pnpm add -D @crabnebula/packager ``` ```sh # yarn yarn add -D @crabnebula/packager ``` ```sh # npm npm i -D @crabnebula/packager ``` -------------------------------- ### Install Cargo-Packager CLI Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/README.md Install the cargo-packager as a cargo subcommand. Ensure to use the --locked flag for reproducible builds. ```sh cargo install cargo-packager --locked ``` -------------------------------- ### Install Tauri CLI Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/examples/tauri/README.md Install the tauri-cli tool to manage Tauri projects. Ensure you use the specified version for compatibility. ```sh cargo install tauri-cli --version "2.0.0-rc.10" --locked ``` -------------------------------- ### Install and Run Cargo Packager CLI Source: https://context7.com/crabnebula-dev/cargo-packager/llms.txt Install the packager globally or locally using npm and run it from the command line. Supports specifying package formats. ```bash # Install the packager npm install -D @crabnebula/packager # Run the packager npx packager # With specific formats npx packager --formats deb,appimage,nsis ``` -------------------------------- ### Run Cargo-Packager CLI Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/README.md Execute the cargo-packager CLI to generate installers or app bundles. Use the --release flag if your application is built in release mode. ```sh cargo packager --release ``` -------------------------------- ### Check for Updates with Basic Configuration Source: https://context7.com/crabnebula-dev/cargo-packager/llms.txt Use `check_update` for a straightforward update check. Configure endpoints, public key, and Windows-specific installation options. The function returns an `Update` object if an update is available, which can then be downloaded and installed. ```rust use cargo_packager_updater::{ check_update, Config, WindowsConfig, WindowsUpdateInstallMode, }; use std::collections::HashMap; fn main() -> cargo_packager_updater::Result<()> { // Configure the updater let config = Config { endpoints: vec![ // Supports {{target}}, {{arch}}, {{current_version}} placeholders "https://releases.example.com/{{target}}/{{arch}}/{{current_version}}" .parse() .unwrap(), // Fallback endpoint "https://api.example.com/updates".parse().unwrap(), ], // Public key from generate_key() pubkey: "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbm...".into(), windows: Some(WindowsConfig { install_mode: WindowsUpdateInstallMode::Passive, installer_args: Some(vec!["--silent".into()]), }), ..Default::default() }; // Check for available update let current_version = "1.0.0".parse().unwrap(); match check_update(current_version, config)? { Some(update) => { println!("Update available: {} -> {}", update.current_version, update.version); println!("Download URL: {}", update.download_url); if let Some(notes) = &update.body { println!("Release notes:\n{}", notes); } // Download and install the update update.download_and_install()?; println!("Update installed successfully!"); } None => { println!("No updates available, you're on the latest version!"); } } Ok(()) } ``` -------------------------------- ### Package Dioxus App with Cargo-Packager Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/examples/dioxus/README.md Packages a Dioxus example project named 'dioxus-example' in release mode using cargo-packager. ```sh cargo r -p cargo-packager -- -p dioxus-example --release ``` -------------------------------- ### Install @crabnebula/updater Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/bindings/updater/nodejs/README.md Install the @crabnebula/updater package using your preferred package manager (pnpm, yarn, or npm). ```sh # pnpm pnpm add @crabnebula/updater # yarn yarn add @crabnebula/updater # npm npm i @crabnebula/updater ``` -------------------------------- ### Package Wails App with cargo-packager Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/examples/wails/README.md Packages the Wails example application using cargo-packager. Use the --release flag for a release build. ```sh cargo r -p cargo-packager -- -p wails-example --release ``` -------------------------------- ### Endpoint URL Formatting Example Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/bindings/updater/nodejs/README.md Endpoint URLs can include variables like `{{arch}}`, `{{target}}`, and `{{current_version}}` which are automatically replaced with the appropriate values. ```text https://releases.myapp.com/{{target}}/{{arch}}/{{current_version}} ``` ```text https://releases.myapp.com/windows/x86_64/0.1.0 ``` -------------------------------- ### Get Resource Directory Path Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/bindings/resource-resolver/nodejs/README.md Import and use the `resourcesDir` function with the desired `PackageFormat` to get the path to the resources directory. Ensure necessary imports are included. ```typescript import { resourcesDir, PackageFormat, } from "@crabnebula/packager-resource-resolver"; const dir = resourcesDir(PackageFormat.Nsis); ``` -------------------------------- ### Check for Updates Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/crates/updater/README.md Use the `check_update` function to check for available updates for your application. Provide the current version and a `Config` object specifying update endpoints and the public key for signature verification. If an update is found, it can be downloaded and installed. ```rust use cargo_packager_updater::{check_update, Config}; let config = Config { endpoints: vec!["http://myserver.com/updates".parse().unwrap()], pubkey: "".into(), ..Default::default() }; if let Some(update) = check_update("0.1.0".parse().unwrap(), config).expect("failed while checking for update") { update.download_and_install().expect("failed to download and install update"); } else { // there is no updates } ``` -------------------------------- ### Get Resource Path for NSIS Package Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/crates/resource-resolver/README.md Use this function to get the resource directory path when the package format is known, such as NSIS. Ensure the `cargo-packager-resource-resolver` crate is included in your dependencies. ```rust use cargo_packager_resource_resolver::{resources_dir, PackageFormat}; let resource_path = resources_dir(PackageFormat::Nsis).unwrap(); ``` -------------------------------- ### Access Bundled Resources in Rust Source: https://context7.com/crabnebula-dev/cargo-packager/llms.txt Use the `resources_dir` function to get the path to bundled resources. Supports explicit format specification or auto-detection with the `auto-detect-format` feature. ```rust use cargo_packager_resource_resolver::{resources_dir, PackageFormat}; use std::path::PathBuf; use std::fs; fn main() -> Result<(), Box> { // Explicitly specify the package format let resources = resources_dir(PackageFormat::Nsis)?; println!("Resources directory: {}", resources.display()); // Load a configuration file from resources let config_path = resources.join("config.json"); let config_content = fs::read_to_string(&config_path)?; println!("Loaded config: {}", config_content); // Load an asset let icon_path = resources.join("icons/app-icon.png"); let icon_data = fs::read(&icon_path)?; println!("Loaded icon: {} bytes", icon_data.len()); Ok(()) } // With auto-detect feature (requires before_each_package_command) #[cfg(feature = "auto-detect-format")] fn auto_detect_resources() -> Result> { use cargo_packager_resource_resolver::current_format; let format = current_format()?; let resources = resources_dir(format)?; Ok(resources) } ``` -------------------------------- ### Check for Updates with Node.js Updater API Source: https://context7.com/crabnebula-dev/cargo-packager/llms.txt Use this function to check for available updates. Configure endpoints, authentication, and installation behavior. Requires the '@crabnebula/updater' package. ```typescript import { checkUpdate, Update, WindowsUpdateInstallMode, type Options } from '@crabnebula/updater'; async function checkForUpdates(): Promise { const options: Options = { endpoints: [ 'https://releases.example.com/updates/{{target}}/{{arch}}' ], pubkey: 'dW50cnVzdGVkIGNvbW1lbnQ6IG1pbm...', windows: { installMode: WindowsUpdateInstallMode.Passive, installerArgs: ['--silent'] }, headers: { 'Authorization': 'Bearer my-api-token' }, timeout: 30000 }; const update: Update | null = await checkUpdate('1.0.0', options); if (update) { console.log(`Update available: ${update.currentVersion} -> ${update.version}`); console.log(`Download URL: ${update.downloadUrl}`); if (update.body) { console.log(`Release notes: ${update.body}`); } // Download with progress tracking const buffer = await update.download( (chunkLength, contentLength) => { if (contentLength) { const progress = (chunkLength / contentLength) * 100; console.log(`Download progress: ${progress.toFixed(1)}%`); } }, () => console.log('Download finished!') ); // Install the update await update.install(buffer); console.log('Update installed, restart required.'); // Or download and install in one step // await update.downloadAndInstall(); } else { console.log('No updates available.'); } } ``` -------------------------------- ### Use Custom Configuration File Source: https://context7.com/crabnebula-dev/cargo-packager/llms.txt Provide a custom configuration file using the --config flag. This allows for detailed project-specific packaging settings. ```bash cargo packager --release --config ./my-config.toml ``` -------------------------------- ### Run the packager CLI Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/bindings/packager/nodejs/README.md Execute the packager CLI after configuring your application. This command initiates the packaging process. ```sh # pnpm pnpm packager ``` ```sh # yarn yarn packager ``` ```sh # npm npx packager ``` -------------------------------- ### Configure Packaging Metadata in Cargo.toml Source: https://context7.com/crabnebula-dev/cargo-packager/llms.txt Embed packaging configurations like commands, product names, resources, and platform-specific settings directly in your project's Cargo.toml file. ```toml [package] name = "my-rust-app" version = "1.0.0" description = "My Rust Application" edition = "2021" [package.metadata.packager] before-packaging-command = "cargo build --release" product-name = "My Rust App" identifier = "com.example.myrustapp" resources = [ "Cargo.toml", "README.md", "assets/*", { src = "config", target = "config" } ] icons = [ "icons/32x32.png", "icons/128x128.png", "icons/icon.icns", "icons/icon.ico" ] [package.metadata.packager.deb] depends = ["libgtk-3-0", "libwebkit2gtk-4.1-0", "libayatana-appindicator3-1"] section = "rust" [package.metadata.packager.appimage] bins = ["/usr/bin/xdg-open"] libs = [ "WebKitNetworkProcess", "WebKitWebProcess", "libwebkit2gtkinjectedbundle.so" ] [package.metadata.packager.nsis] appdata-paths = ["$LOCALAPPDATA/$IDENTIFIER"] ``` -------------------------------- ### Node.js Library API: Basic Packaging Source: https://context7.com/crabnebula-dev/cargo-packager/llms.txt Programmatically package an application using the `packageApp` function. Requires a `Config` object specifying application details and packaging options. ```typescript import { packageApp, packageAndSignApp, cli, type Config, type SigningConfig } from '@crabnebula/packager'; // Basic packaging async function buildPackage() { const config: Config = { productName: 'My App', version: '1.0.0', identifier: 'com.example.myapp', outDir: './dist', binaries: [{ path: 'my-app', main: true }], resources: ['assets/*'], icons: ['icons/icon.png'], formats: ['deb', 'appimage', 'nsis'], deb: { depends: ['libgtk-3-0'] } }; await packageApp(config, { verbosity: 1 }); console.log('Packaging complete!'); } ``` -------------------------------- ### Package Tauri App with Cargo Packager Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/examples/tauri/README.md Package a Tauri application using cargo-packager. This command builds the release version of the 'tauri-example' application, using a dummy private key and an empty password. ```sh cargo r -p cargo-packager -- -p tauri-example --release --private-key dummy.key --password "" ``` -------------------------------- ### Programmatically Package Application using Rust API Source: https://context7.com/crabnebula-dev/cargo-packager/llms.txt Utilize the `cargo_packager` Rust library to build package configurations and initiate the packaging process. This method offers dynamic control over packaging options. ```rust use cargo_packager::{ config::{ Binary, Config, ConfigBuilder, DebianConfig, NsisConfig, Resource, FileAssociation, DeepLinkProtocol, PackageFormat }, package, PackageOutput, Result, }; use std::path::PathBuf; fn main() -> Result<()> { // Build configuration using the builder pattern let config = Config::builder() .product_name("My Application") .version("1.0.0") .identifier("com.example.myapp") .description("A cross-platform desktop application") .homepage("https://example.com") .publisher("Example Inc.") .out_dir(PathBuf::from("./target/release")) .binaries(vec![ Binary::new("my-app").main(true), Binary::new("my-app-helper"), ]) .resources(vec![ Resource::Single("assets/*".into()), Resource::Mapped { src: "config.json".into(), target: PathBuf::from("data/config.json"), }, ]) .icons(vec![ "icons/32x32.png".into(), "icons/128x128.png".into(), "icons/icon.icns".into(), "icons/icon.ico".into(), ]) .file_associations(vec![ FileAssociation::new(["myapp", "mya"]) .mime_type("application/x-myapp") .description("My App File"), ]) .deep_link_protocols(vec![ DeepLinkProtocol::new(["myapp"]), ]) .formats(vec![PackageFormat::Deb, PackageFormat::Nsis]) .deb( DebianConfig::new() .depends(["libgtk-3-0", "libwebkit2gtk-4.1-0"]) .section("utils") ) .nsis( NsisConfig::new() .languages(["English", "German"]) .display_language_selector(true) ) .before_packaging_command("cargo build --release") .build()?; // Execute packaging let outputs: Vec = package(&config)?; for output in outputs { println!("Created {:?} package(s):", output.format); for path in &output.paths { println!(" - {}", path.display()); } } Ok(()) } ``` -------------------------------- ### Update Server Response: Single Platform Source: https://context7.com/crabnebula-dev/cargo-packager/llms.txt This JSON format is expected from the update server for a single platform. It includes version, release date, download URL, signature, format, and release notes. ```json // Single platform response { "version": "1.2.0", "pub_date": "2024-01-15T10:30:00Z", "url": "https://releases.example.com/myapp-1.2.0-x64-setup.exe", "signature": "RWTb2Z8J9g...", "format": "nsis", "notes": "## What's New\n- Bug fixes\n- Performance improvements" } ``` -------------------------------- ### Node.js Library API: Package and Sign Source: https://context7.com/crabnebula-dev/cargo-packager/llms.txt Use `packageAndSignApp` to package and sign your application for updates. Requires `Config` and `SigningConfig` objects, with signing credentials potentially loaded from environment variables. ```typescript // Package and sign for updates async function buildAndSign() { const config: Config = { productName: 'My App', version: '1.0.0', identifier: 'com.example.myapp', outDir: './dist', binaries: [{ path: 'my-app', main: true }] }; const signingConfig: SigningConfig = { privateKey: process.env.SIGNING_PRIVATE_KEY!, password: process.env.SIGNING_PASSWORD || '' }; await packageAndSignApp(config, signingConfig, { verbosity: 2 }); console.log('Package created and signed!'); } ``` -------------------------------- ### Specify Output Formats Source: https://context7.com/crabnebula-dev/cargo-packager/llms.txt Control the output formats for your packaged application by specifying them with the --formats flag. Supported formats include deb, appimage, and nsis. ```bash cargo packager --release --formats deb,appimage,nsis ``` -------------------------------- ### Check for Updates with checkUpdate Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/bindings/updater/nodejs/README.md Use the `checkUpdate` function to check for available updates. Provide the current app version and an options object with update endpoints and the public key for signature verification. If an update is found, the returned object has a `downloadAndInstall` method. ```javascript import { checkUpdate } from "@crabnebula/updater"; let update = await checkUpdate("0.1.0", { endpoints: ["http://myserver.com/updates"], pubkey: "", }); if (update !== null) { update.downloadAndInstall(); } else { // there is no updates } ``` -------------------------------- ### Security.txt Configuration Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/SECURITY.md This is a standard security.txt file format. It specifies contact information, expiration, encryption methods, and preferred languages for security vulnerability reporting. ```text Contact: mailto:security@crabnebula.dev Expires: 2025-01-30T06:30:00.000Z Encryption: https://crabnebula.dev/.well-known/pgp.txt Preferred-Languages: en,de,fr Canonical: https://crabnebula.dev/.well-known/security.txt ``` -------------------------------- ### Update Server Response: Multi-Platform Source: https://context7.com/crabnebula-dev/cargo-packager/llms.txt This JSON format is used when the update server provides details for multiple platforms. It includes a top-level version, date, and notes, with a nested 'platforms' object detailing specific download URLs and formats for each target. ```json // Multi-platform response { "version": "1.2.0", "pub_date": "2024-01-15T10:30:00Z", "notes": "## What's New\n- Bug fixes\n- Performance improvements", "platforms": { "windows-x86_64": { "url": "https://releases.example.com/myapp-1.2.0-x64-setup.nsis.zip", "signature": "RWTb2Z8J9g...", "format": "nsis" }, "windows-aarch64": { "url": "https://releases.example.com/myapp-1.2.0-arm64-setup.nsis.zip", "signature": "RWTb2Z8J9g...", "format": "nsis" }, "macos-x86_64": { "url": "https://releases.example.com/myapp-1.2.0-x64.app.tar.gz", "signature": "RWTb2Z8J9g...", "format": "app" }, "macos-aarch64": { "url": "https://releases.example.com/myapp-1.2.0-arm64.app.tar.gz", "signature": "RWTb2Z8J9g...", "format": "app" }, "linux-x86_64": { "url": "https://releases.example.com/myapp-1.2.0-x64.AppImage.tar.gz", "signature": "RWTb2Z8J9g...", "format": "appimage" } } } ``` -------------------------------- ### Automatically Detect Resource Format Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/crates/resource-resolver/README.md This snippet automatically detects the current package format, which is useful for Rust apps built with cargo packager. It requires the `auto-detect-format` feature to be enabled for this crate and the app to be built using the `before_each_package_command` in cargo packager configuration. ```rust use cargo_packager_resource_resolver::{resources_dir, current_format}; let resource_path = resources_dir(current_format().unwrap()).unwrap(); ``` -------------------------------- ### Generate and Manage Signing Keys with Rust API Source: https://context7.com/crabnebula-dev/cargo-packager/llms.txt Use the `cargo_packager::sign` module to generate new cryptographic key pairs, save them to disk, and decode private keys for signing operations. Requires a password for secure key management. ```rust use cargo_packager::sign::{generate_key, save_keypair, decode_private_key, KeyPair}; use std::path::Path; fn main() -> cargo_packager::Result<()> { // Generate a new key pair with password let keypair: KeyPair = generate_key(Some("my-secure-password".into()))?; println!("Public Key: {}", keypair.pk); println!("Secret Key: {}", keypair.sk); // Save keys to disk // Creates: ./keys/myapp.key (secret) and ./keys/myapp.key.pub (public) let (secret_path, public_path) = save_keypair( &keypair, Path::new("./keys/myapp.key"), false // force overwrite )?; println!("Secret key saved to: {}", secret_path.display()); println!("Public key saved to: {}", public_path.display()); // Decode a private key for signing operations let secret_key = decode_private_key( &keypair.sk, Some("my-secure-password") )?; Ok(()) } ``` -------------------------------- ### Comprehensive Packager.toml Configuration Source: https://context7.com/crabnebula-dev/cargo-packager/llms.txt A detailed TOML configuration file for cargo-packager, covering application metadata, binary paths, resource bundling, icons, file associations, deep link protocols, and platform-specific settings for Debian, AppImage, macOS, and Windows (NSIS, WiX). ```toml # Packager.toml name = "my-app" before-packaging-command = "cargo build --release" out-dir = "./target/release" version = "1.0.0" product-name = "My Application" identifier = "com.example.myapp" description = "A cross-platform desktop application" homepage = "https://example.com" publisher = "Example Inc." license-file = "LICENSE" copyright = "Copyright 2024 Example Inc." category = "Utility" # Binary configuration binaries = [{ path = "my-app", main = true }] # Resources to bundle (supports glob patterns) resources = [ "assets/*", "config.json", { src = "icons/*", target = "icons" }, { src = "locales", target = "i18n/locales" } ] # Icon files for different platforms icons = [ "icons/32x32.png", "icons/128x128.png", "icons/icon.icns", "icons/icon.ico" ] # File associations [[file-associations]] extensions = ["myapp", "mya"] mime-type = "application/x-myapp" description = "My Application File" # Deep link protocols [[deep-link-protocols]] schemes = ["myapp", "my-app"] # Debian-specific configuration [deb] depends = ["libgtk-3-0", "libwebkit2gtk-4.1-0"] section = "utils" priority = "optional" # AppImage configuration [appimage] bins = ["/usr/bin/xdg-open"] libs = ["libwebkit2gtkinjectedbundle.so"] [appimage.linuxdeploy-plugins] gtk = "https://raw.githubusercontent.com/tauri-apps/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh" # macOS configuration [macos] minimum-system-version = "10.13" signing-identity = "Developer ID Application: Example Inc. (ABCD1234)" entitlements = "entitlements.plist" frameworks = ["SDL2"] # DMG configuration [dmg] background = "assets/dmg-background.png" [dmg.window-size] width = 660 height = 400 [dmg.app-position] x = 180 y = 170 [dmg.app-folder-position] x = 480 y = 170 # Windows configuration [windows] digest-algorithm = "sha256" certificate-thumbprint = "ABCD1234567890" timestamp-url = "http://timestamp.digicert.com" allow-downgrades = false # NSIS installer configuration [nsis] install-mode = "currentUser" languages = ["English", "German", "French"] display-language-selector = true appdata-paths = ["$LOCALAPPDATA/$IDENTIFIER"] # WiX MSI configuration [wix] languages = [{ identifier = "en-US" }] fips-compliant = false ``` -------------------------------- ### Configure Packager in Cargo.toml Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/README.md Add packager metadata to your Cargo.toml file to configure pre-packaging commands. This snippet specifies a command to build the release version of your application before packaging. ```toml [package.metadata.packager] before-packaging-command = "cargo build --release" ``` -------------------------------- ### Node.js Library API: Programmatic CLI Execution Source: https://context7.com/crabnebula-dev/cargo-packager/llms.txt Execute the packager CLI programmatically using the `cli` function. Pass command-line arguments as an array of strings. ```typescript // Use CLI programmatically async function runCli() { await cli(['--release', '--formats', 'nsis,deb'], 'packager'); } ``` -------------------------------- ### Cargo Packager Configuration in package.json Source: https://context7.com/crabnebula-dev/cargo-packager/llms.txt Configure the packager by defining settings in the `packager` section of your `package.json` file. This includes product details, output directory, resources, icons, and format-specific options. ```json // package.json { "name": "my-electron-app", "version": "1.0.0", "packager": { "productName": "My Electron App", "identifier": "com.example.electronapp", "beforePackagingCommand": "npm run build", "outDir": "./dist", "binaries": [ { "path": "my-electron-app", "main": true } ], "resources": ["assets/*", "config.json"], "icons": ["icons/icon.png", "icons/icon.icns", "icons/icon.ico"], "deb": { "depends": ["libgtk-3-0"] } } } ``` -------------------------------- ### Update Endpoint URL Formatting Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/crates/updater/README.md Endpoint URLs can include placeholders like `{{arch}}`, `{{target}}`, and `{{current_version}}` which are dynamically replaced with the appropriate values before making a request. This allows for version and platform-specific update checks. ```string "https://releases.myapp.com/{{target}}/{{arch}}/{{current_version}}" ``` ```string "https://releases.myapp.com/windows/x86_64/0.1.0" ``` -------------------------------- ### UpdaterBuilder with Progress Callbacks Source: https://context7.com/crabnebula-dev/cargo-packager/llms.txt Use `UpdaterBuilder` for more control, including custom headers, timeouts, and download progress callbacks. This allows for a more interactive update experience, showing download progress and completion messages. ```rust use cargo_packager_updater::{UpdaterBuilder, WindowsConfig, WindowsUpdateInstallMode}; fn main() -> cargo_packager_updater::Result<()> { let updater = UpdaterBuilder::new( "1.0.0".parse().unwrap(), // current version vec![ "https://releases.example.com/updates/{{target}}/{{arch}}" .parse() .unwrap(), ], ) .pubkey("dW50cnVzdGVkIGNvbW1lbnQ6IG1pbm...".into()) .header("Authorization", "Bearer my-api-token")? // Add custom headers .header("X-Custom-Header", "custom-value")? .timeout(std::time::Duration::from_secs(30)) .windows_config(WindowsConfig { install_mode: WindowsUpdateInstallMode::BasicUi, installer_args: None, }) .build()?; if let Some(update) = updater.check()? { println!("Downloading update v{}...", update.version); // Download with progress callback let bytes = update.download( Some(|chunk_len, content_len| { if let Some(total) = content_len { let progress = (chunk_len as f64 / total as f64) * 100.0; println!("Download progress: {:.1}%", progress); } }), Some(|| { println!("Download complete!"); }), )?; // Install the downloaded update update.install(&bytes)?; println!("Update installed, please restart the application."); } Ok(()) } ``` -------------------------------- ### Specify Target Triple for Cross-Compilation Source: https://context7.com/crabnebula-dev/cargo-packager/llms.txt Use the --target flag to specify the target triple for cross-compilation, enabling packaging for different architectures and operating systems. ```bash cargo packager --release --target x86_64-pc-windows-msvc ``` -------------------------------- ### JSON Response for One Platform Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/bindings/updater/nodejs/README.md This JSON structure provides update information for a single, specific platform. It includes version, publication date, URL, signature, format, and optional release notes. ```json { "version": "0.2.0", "pub_date": "2020-09-18T12:29:53+01:00", "url": "https://mycompany.example.com/myapp/releases/myrelease.tar.gz", "signature": "Content of the relevant .sig file", "format": "app or nsis or wix or appimage depending on the release target and the chosen format", "notes": "These are some release notes" } ``` -------------------------------- ### Specify Custom Cargo Profile Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/README.md If your application is built using a custom cargo profile, specify it using the --profile argument when running the packager. ```sh cargo packager --profile custom-release-profile ``` -------------------------------- ### JSON Response for All Platforms Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/bindings/updater/nodejs/README.md This JSON structure represents update information for multiple platforms. It includes version, notes, publication date, and platform-specific details like signature, URL, and format. ```json { "version": "v1.0.0", "notes": "Test version", "pub_date": "2020-06-22T19:25:57Z", "platforms": { "macos-x86_64": { "signature": "Content of app.tar.gz.sig", "url": "https://github.com/username/reponame/releases/download/v1.0.0/app-x86_64.app.tar.gz", "format": "app" }, "macos-aarch64": { "signature": "Content of app.tar.gz.sig", "url": "https://github.com/username/reponame/releases/download/v1.0.0/app-aarch64.app.tar.gz", "format": "app" }, "linux-x86_64": { "signature": "Content of app.AppImage.sig", "url": "https://github.com/username/reponame/releases/download/v1.0.0/app-amd64.AppImage.tar.gz", "format": "appimage" }, "windows-x86_64": { "signature": "Content of app-setup.exe.sig or app.msi.sig, depending on the chosen format", "url": "https://github.com/username/reponame/releases/download/v1.0.0/app-x64-setup.nsis.zip", "format": "nsis or wix depending on the chosen format" } } } ``` -------------------------------- ### Add Cargo-Packager as a Library Source: https://github.com/crabnebula-dev/cargo-packager/blob/main/README.md Integrate cargo-packager as a library into your tooling by adding it as a dependency. Disable default features to avoid including CLI-specific dependencies. ```sh cargo add cargo-packager --no-default-features ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.