diff --git a/.changes/config-removed.md b/.changes/config-removed.md new file mode 100644 index 00000000..4d78674e --- /dev/null +++ b/.changes/config-removed.md @@ -0,0 +1,5 @@ +--- +"cargo-packager": "minor" +--- + +Remove the deprecated `cargo-packager-config` dependency. diff --git a/.changes/config.json b/.changes/config.json index 1eb3eb58..5069f7ad 100644 --- a/.changes/config.json +++ b/.changes/config.json @@ -34,16 +34,6 @@ } }, "packages": { - "cargo-packager-config": { - "path": "./crates/config", - "manager": "rust", - "assets": [ - { - "path": "${ pkg.path }/target/package/cargo-packager-config-${ pkgFile.version }.crate", - "name": "${ pkg.pkg }-${ pkgFile.version }.crate" - } - ] - }, "cargo-packager": { "path": "./crates/packager", "manager": "rust", diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index c015cd23..17e2a14a 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -21,32 +21,38 @@ concurrency: cancel-in-progress: true jobs: - clippy: + fmt: runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + - name: Check formatting + run: cargo fmt --all -- --check + + clippy: + strategy: + fail-fast: false + matrix: + platform: [ubuntu-latest, macos-latest, windows-latest] + + runs-on: ${{ matrix.platform }} + steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: components: clippy - name: install webkit2gtk + if: matrix.platform == 'ubuntu-latest' run: | sudo apt-get update sudo apt-get install -y webkit2gtk-4.1 libayatana-appindicator3-dev - uses: Swatinem/rust-cache@v2 - run: cargo clippy --workspace --all-targets --all-features -- -D warnings - fmt: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - components: rustfmt - - name: Check formatting - run: cargo fmt --all -- --check - test: strategy: fail-fast: false diff --git a/Cargo.lock b/Cargo.lock index cd80f140..72b37c9d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -744,7 +744,6 @@ version = "0.1.2" dependencies = [ "ar", "base64 0.21.4", - "cargo-packager-config", "cargo_metadata", "clap", "dirs", @@ -762,11 +761,13 @@ dependencies = [ "plist", "regex", "relative-path", + "schemars", "semver", "serde", "serde_json", "sha1", "sha2", + "strsim", "tar", "tauri-icns", "tempfile", @@ -783,21 +784,11 @@ dependencies = [ "zip", ] -[[package]] -name = "cargo-packager-config" -version = "0.2.0" -dependencies = [ - "clap", - "schemars", - "serde", - "strsim", -] - [[package]] name = "cargo-packager-config-schema-generator" version = "0.0.0" dependencies = [ - "cargo-packager-config", + "cargo-packager", "schemars", "serde_json", ] diff --git a/crates/config-schema-generator/Cargo.toml b/crates/config-schema-generator/Cargo.toml index 80b991e6..160afb43 100644 --- a/crates/config-schema-generator/Cargo.toml +++ b/crates/config-schema-generator/Cargo.toml @@ -8,6 +8,6 @@ license.workspace = true repository.workspace = true [build-dependencies] -cargo-packager-config = { path = "../config" } +cargo-packager = { path = "../packager", features = ["schema"] } serde_json = { workspace = true } schemars = { workspace = true } diff --git a/crates/config-schema-generator/build.rs b/crates/config-schema-generator/build.rs index 0801faf3..5cd0734c 100644 --- a/crates/config-schema-generator/build.rs +++ b/crates/config-schema-generator/build.rs @@ -10,12 +10,10 @@ use std::{ }; pub fn main() -> Result<(), Box> { - let schema = schemars::schema_for!(cargo_packager_config::Config); + let schema = schemars::schema_for!(cargo_packager::Config); let schema_str = serde_json::to_string_pretty(&schema).unwrap(); let crate_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR")?); - for file in ["../packager/schema.json", "../config/schema.json"] { - let mut schema_file = BufWriter::new(File::create(crate_dir.join(file))?); - write!(schema_file, "{schema_str}")?; - } + let mut schema_file = BufWriter::new(File::create(crate_dir.join("../packager/schema.json"))?); + write!(schema_file, "{schema_str}")?; Ok(()) } diff --git a/crates/config/CHANGELOG.md b/crates/config/CHANGELOG.md deleted file mode 100644 index 95d17a7d..00000000 --- a/crates/config/CHANGELOG.md +++ /dev/null @@ -1,5 +0,0 @@ -# Changelog - -## \[0.2.0] - -- [`1809f10`](https://www.github.com/crabnebula-dev/cargo-packager/commit/1809f10b4fd1720fd740196f67c3c980ade0a6bd) Add `Config.enabled` field control whether this config is enabled or not diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml deleted file mode 100644 index 3cae3c0b..00000000 --- a/crates/config/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "cargo-packager-config" -version = "0.2.0" -description = "Config types for cargo-packager." -authors = [ - "CrabNebula Ltd.", - "Tauri Programme within The Commons Conservancy", - "George Burton " -] -edition.workspace = true -license.workspace = true -repository.workspace = true - -[features] -clap = [ "dep:clap" ] - -[dependencies] -serde = { workspace = true } -schemars = { workspace = true } -clap = { workspace = true, optional = true } -strsim = "0.10" diff --git a/crates/config/LICENSE_APACHE-2.0 b/crates/config/LICENSE_APACHE-2.0 deleted file mode 100644 index f433b1a5..00000000 --- a/crates/config/LICENSE_APACHE-2.0 +++ /dev/null @@ -1,177 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS diff --git a/crates/config/LICENSE_MIT b/crates/config/LICENSE_MIT deleted file mode 100644 index 89dcaaa5..00000000 --- a/crates/config/LICENSE_MIT +++ /dev/null @@ -1,23 +0,0 @@ -MIT License - -Copyright (c) 2023 - Present CrabNebula Ltd. -Copyright (c) 2019 - 2023 Tauri Programme within The Commons Conservancy -Copyright (c) 2017 - 2019 Cargo-Bundle developers - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/crates/config/README.md b/crates/config/README.md deleted file mode 100644 index a0e08dea..00000000 --- a/crates/config/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# cargo-packager-config - -Config types for [`cargo-packager`](../packager/). - -## Licenses - -MIT or MIT/Apache 2.0 where applicable. diff --git a/crates/config/schema.json b/crates/config/schema.json deleted file mode 100644 index ca081c24..00000000 --- a/crates/config/schema.json +++ /dev/null @@ -1,1077 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Config", - "description": "The packaging config.", - "type": "object", - "properties": { - "enabled": { - "description": "Whether this config is enabled or not. Defaults to `true`.", - "default": true, - "type": "boolean" - }, - "$schema": { - "description": "The JSON schema for the config.\n\nSetting this field has no effect, this just exists so we can parse the JSON correct when it has `$schema` field set.", - "type": [ - "string", - "null" - ] - }, - "name": { - "description": "The app name, this is just an identifier that could be used to filter which app to package using `--pacakges` cli arg when there is multiple apps in the workspace or in the same config.\n\nThis field resembles, the `name` field in `Cargo.toml` and `package.json`\n\nIf `unset`, the CLI will try to auto-detect it from `Cargo.toml` or `package.json` otherwise, it will keep it as null.", - "type": [ - "string", - "null" - ] - }, - "beforePackagingCommand": { - "description": "Specify a command to run before starting to package an application.\n\nThis runs only once.", - "default": null, - "anyOf": [ - { - "$ref": "#/definitions/HookCommand" - }, - { - "type": "null" - } - ] - }, - "beforeEachPackageCommand": { - "description": "Specify a command to run before packaging each format for an application.\n\nThis will run multiple times depending on the formats specifed.", - "default": null, - "anyOf": [ - { - "$ref": "#/definitions/HookCommand" - }, - { - "type": "null" - } - ] - }, - "logLevel": { - "description": "The log level.", - "anyOf": [ - { - "$ref": "#/definitions/LogLevel" - }, - { - "type": "null" - } - ] - }, - "formats": { - "description": "The package types we're creating.\n\nif not present, we'll use the PackageType list for the target OS.", - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/PackageFormat" - } - }, - "outDir": { - "description": "The directory where the `binaries` exist and where the packages will be placed.", - "default": "", - "type": "string" - }, - "targetTriple": { - "description": "The target triple. Defaults to the current OS target triple.", - "type": [ - "string", - "null" - ] - }, - "productName": { - "description": "the package's product name, for example \"My Awesome App\".", - "default": "", - "type": "string" - }, - "version": { - "description": "the package's version.", - "default": "", - "type": "string" - }, - "description": { - "description": "the package's description.", - "type": [ - "string", - "null" - ] - }, - "longDescription": { - "description": "the app's long description.", - "type": [ - "string", - "null" - ] - }, - "homepage": { - "description": "the package's homepage.", - "type": [ - "string", - "null" - ] - }, - "authors": { - "description": "the package's authors.", - "default": [], - "type": "array", - "items": { - "type": "string" - } - }, - "identifier": { - "description": "the application identifier in reverse domain name notation (e.g. `com.packager.example`). This string must be unique across applications since it is used in some system configurations. This string must contain only alphanumeric characters (A–Z, a–z, and 0–9), hyphens (-), and periods (.).", - "type": [ - "string", - "null" - ], - "pattern": "^[a-zA-Z0-9-\\.]*$" - }, - "publisher": { - "description": "The app's publisher. Defaults to the second element in the identifier string. Currently maps to the Manufacturer property of the Windows Installer.", - "type": [ - "string", - "null" - ] - }, - "licenseFile": { - "description": "A path to the license file.", - "type": [ - "string", - "null" - ] - }, - "copyright": { - "description": "the app's copyright.", - "type": [ - "string", - "null" - ] - }, - "category": { - "description": "the app's category.", - "anyOf": [ - { - "$ref": "#/definitions/AppCategory" - }, - { - "type": "null" - } - ] - }, - "icons": { - "description": "the app's icon list.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "binaries": { - "description": "the binaries to package.", - "default": [], - "type": "array", - "items": { - "$ref": "#/definitions/Binary" - } - }, - "fileAssociations": { - "description": "the file associations", - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/FileAssociation" - } - }, - "resources": { - "description": "The app's resources to package. This a list of either a glob pattern, path to a file, path to a directory or an object of `src` and `target` paths. In the case of using an object, the `src` could be either a glob pattern, path to a file, path to a directory, and the `target` is a path inside the final resources folder in the installed package.\n\n## Format-specific:\n\n- **[PackageFormat::Nsis] / [PackageFormat::Wix]**: The resources are placed next to the executable in the root of the packager. - **[PackageFormat::Deb]**: The resources are placed in `usr/lib` of the package.", - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/Resource" - } - }, - "externalBinaries": { - "description": "External binaries to add to the package.\n\nNote that each binary name should have the target platform's target triple appended, as well as `.exe` for Windows. For example, if you're packaging a sidecar called `sqlite3`, the packager expects a binary named `sqlite3-x86_64-unknown-linux-gnu` on linux, and `sqlite3-x86_64-pc-windows-gnu.exe` on windows.\n\nIf you are building a universal binary for MacOS, the packager expects your external binary to also be universal, and named after the target triple, e.g. `sqlite3-universal-apple-darwin`. See ", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "deb": { - "description": "Debian-specific settings.", - "anyOf": [ - { - "$ref": "#/definitions/DebianConfig" - }, - { - "type": "null" - } - ] - }, - "appimage": { - "description": "Debian-specific settings.", - "anyOf": [ - { - "$ref": "#/definitions/AppImageConfig" - }, - { - "type": "null" - } - ] - }, - "wix": { - "description": "WiX configuration.", - "anyOf": [ - { - "$ref": "#/definitions/WixConfig" - }, - { - "type": "null" - } - ] - }, - "nsis": { - "description": "Nsis configuration.", - "anyOf": [ - { - "$ref": "#/definitions/NsisConfig" - }, - { - "type": "null" - } - ] - }, - "macos": { - "description": "MacOS-specific settings.", - "anyOf": [ - { - "$ref": "#/definitions/MacOsConfig" - }, - { - "type": "null" - } - ] - }, - "windows": { - "description": "Windows-specific settings.", - "anyOf": [ - { - "$ref": "#/definitions/WindowsConfig" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false, - "definitions": { - "HookCommand": { - "description": "Describes a shell command to be executed when a CLI hook is triggered.", - "anyOf": [ - { - "description": "Run the given script with the default options.", - "type": "string" - }, - { - "description": "Run the given script with custom options.", - "type": "object", - "required": [ - "script" - ], - "properties": { - "script": { - "description": "The script to execute.", - "type": "string" - }, - "dir": { - "description": "The working directory.", - "type": [ - "string", - "null" - ] - } - } - } - ] - }, - "LogLevel": { - "description": "An enum representing the available verbosity levels of the logger.", - "oneOf": [ - { - "description": "The \"error\" level.\n\nDesignates very serious errors.", - "type": "string", - "enum": [ - "error" - ] - }, - { - "description": "The \"warn\" level.\n\nDesignates hazardous situations.", - "type": "string", - "enum": [ - "warn" - ] - }, - { - "description": "The \"info\" level.\n\nDesignates useful information.", - "type": "string", - "enum": [ - "info" - ] - }, - { - "description": "The \"debug\" level.\n\nDesignates lower priority information.", - "type": "string", - "enum": [ - "debug" - ] - }, - { - "description": "The \"trace\" level.\n\nDesignates very low priority, often extremely verbose, information.", - "type": "string", - "enum": [ - "trace" - ] - } - ] - }, - "PackageFormat": { - "description": "The type of the package we're packaging.", - "oneOf": [ - { - "description": "All available package formats for the current platform.\n\nSee [`PackageFormat::platform_all`]", - "type": "string", - "enum": [ - "all" - ] - }, - { - "description": "The default list of package formats for the current platform.\n\nSee [`PackageFormat::platform_default`]", - "type": "string", - "enum": [ - "default" - ] - }, - { - "description": "The macOS application bundle (.app).", - "type": "string", - "enum": [ - "app" - ] - }, - { - "description": "The macOS DMG package (.dmg).", - "type": "string", - "enum": [ - "dmg" - ] - }, - { - "description": "The Microsoft Software Installer (.msi) through WiX Toolset.", - "type": "string", - "enum": [ - "wix" - ] - }, - { - "description": "The NSIS installer (.exe).", - "type": "string", - "enum": [ - "nsis" - ] - }, - { - "description": "The Linux Debian package (.deb).", - "type": "string", - "enum": [ - "deb" - ] - }, - { - "description": "The Linux AppImage package (.AppImage).", - "type": "string", - "enum": [ - "appimage" - ] - } - ] - }, - "AppCategory": { - "description": "The possible app categories. Corresponds to `LSApplicationCategoryType` on macOS and the GNOME desktop categories on Debian.", - "type": "string", - "enum": [ - "Business", - "DeveloperTool", - "Education", - "Entertainment", - "Finance", - "Game", - "ActionGame", - "AdventureGame", - "ArcadeGame", - "BoardGame", - "CardGame", - "CasinoGame", - "DiceGame", - "EducationalGame", - "FamilyGame", - "KidsGame", - "MusicGame", - "PuzzleGame", - "RacingGame", - "RolePlayingGame", - "SimulationGame", - "SportsGame", - "StrategyGame", - "TriviaGame", - "WordGame", - "GraphicsAndDesign", - "HealthcareAndFitness", - "Lifestyle", - "Medical", - "Music", - "News", - "Photography", - "Productivity", - "Reference", - "SocialNetworking", - "Sports", - "Travel", - "Utility", - "Video", - "Weather" - ] - }, - "Binary": { - "description": "A binary to package within the final package.", - "type": "object", - "required": [ - "filename" - ], - "properties": { - "filename": { - "description": "File name and without `.exe` on Windows", - "type": "string" - }, - "main": { - "description": "Whether this is the main binary or not", - "default": false, - "type": "boolean" - } - }, - "additionalProperties": false - }, - "FileAssociation": { - "description": "A file association configuration.", - "type": "object", - "required": [ - "ext" - ], - "properties": { - "ext": { - "description": "File extensions to associate with this app. e.g. 'png'", - "type": "array", - "items": { - "type": "string" - } - }, - "name": { - "description": "The name. Maps to `CFBundleTypeName` on macOS. Default to the first item in `ext`", - "type": [ - "string", - "null" - ] - }, - "description": { - "description": "The association description. **Windows-only**. It is displayed on the `Type` column on Windows Explorer.", - "type": [ - "string", - "null" - ] - }, - "role": { - "description": "The app’s role with respect to the type. Maps to `CFBundleTypeRole` on macOS.", - "default": "editor", - "allOf": [ - { - "$ref": "#/definitions/BundleTypeRole" - } - ] - }, - "mimeType": { - "description": "The mime-type e.g. 'image/png' or 'text/plain'. Linux-only.", - "type": [ - "string", - "null" - ] - } - }, - "additionalProperties": false - }, - "BundleTypeRole": { - "description": "*macOS-only**. Corresponds to CFBundleTypeRole", - "oneOf": [ - { - "description": "CFBundleTypeRole.Editor. Files can be read and edited.", - "type": "string", - "enum": [ - "editor" - ] - }, - { - "description": "CFBundleTypeRole.Viewer. Files can be read.", - "type": "string", - "enum": [ - "viewer" - ] - }, - { - "description": "CFBundleTypeRole.Shell", - "type": "string", - "enum": [ - "shell" - ] - }, - { - "description": "CFBundleTypeRole.QLGenerator", - "type": "string", - "enum": [ - "qLGenerator" - ] - }, - { - "description": "CFBundleTypeRole.None", - "type": "string", - "enum": [ - "none" - ] - } - ] - }, - "Resource": { - "description": "A path to a resource (with optional glob pattern) or an object of `src` and `target` paths.", - "anyOf": [ - { - "description": "Supports glob patterns", - "type": "string" - }, - { - "description": "An object descriping the src file or directory and its target location in the final package.", - "type": "object", - "required": [ - "src", - "target" - ], - "properties": { - "src": { - "description": "The src file or directory, supports glob patterns.", - "type": "string" - }, - "target": { - "description": "A relative path from the root of the final package.\n\nIf `src` is a glob, this will always be treated as a directory where all globbed files will be placed under.", - "type": "string" - } - } - } - ] - }, - "DebianConfig": { - "description": "The Linux debian configuration.", - "type": "object", - "properties": { - "depends": { - "description": "the list of debian dependencies.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "desktopTemplate": { - "description": "Path to a custom desktop file Handlebars template.\n\nAvailable variables: `categories`, `comment` (optional), `exec`, `icon` and `name`.\n\nDefault file contents: ```text [Desktop Entry] Categories={{categories}} {{#if comment}} Comment={{comment}} {{/if}} Exec={{exec}} Icon={{icon}} Name={{name}} Terminal=false Type=Application {{#if mime_type}} MimeType={{mime_type}} {{/if}} ```", - "type": [ - "string", - "null" - ] - }, - "files": { - "description": "List of custom files to add to the deb package. Maps a dir/file to a dir/file inside the debian package.", - "type": [ - "object", - "null" - ], - "additionalProperties": { - "type": "string" - } - } - }, - "additionalProperties": false - }, - "AppImageConfig": { - "description": "The Linux AppImage configuration.", - "type": "object", - "properties": { - "libs": { - "description": "List of libs that exist in `/usr/lib*` to be include in the final AppImage. The libs will be searched for using the command `find -L /usr/lib* -name `", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "bins": { - "description": "List of binary paths to include in the final AppImage. For example, if you want `xdg-open`, you'd specify `/usr/bin/xdg-open`", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "linuxdeployPlugins": { - "description": "Hashmap of [`linuxdeploy`](https://github.com/linuxdeploy/linuxdeploy) plugin name and its URL to be downloaded and executed while packaing the appimage. For example, if you want to use the [`gtk`](https://raw.githubusercontent.com/linuxdeploy/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh) plugin, you'd specify `gtk` as the key and its url as the value.", - "type": [ - "object", - "null" - ], - "additionalProperties": { - "type": "string" - } - } - }, - "additionalProperties": false - }, - "WixConfig": { - "description": "The wix format configuration", - "type": "object", - "properties": { - "languages": { - "description": "The app languages to build. See .", - "default": [ - [ - "en-US", - { - "localePath": null - } - ] - ], - "allOf": [ - { - "$ref": "#/definitions/WixLanguages" - } - ] - }, - "template": { - "description": "By default, the packager uses an internal template. This option allows you to define your own wix file.", - "type": [ - "string", - "null" - ] - }, - "mergeModules": { - "description": "List of merge modules to include in your installer. For example, if you want to include [C++ Redis merge modules]\n\n[C++ Redis merge modules]: https://wixtoolset.org/docs/v3/howtos/redistributables_and_install_checks/install_vcredist/", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "fragmentPaths": { - "description": "A list of paths to .wxs files with WiX fragments to use.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "fragments": { - "description": "List of WiX fragments as strings. This is similar to `config.wix.fragments_paths` but is a string so you can define it inline in your config.\n\n```text ```", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "componentGroupRefs": { - "description": "The ComponentGroup element ids you want to reference from the fragments.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "componentRefs": { - "description": "The Component element ids you want to reference from the fragments.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "customActionRefs": { - "description": "The CustomAction element ids you want to reference from the fragments.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "featureGroupRefs": { - "description": "The FeatureGroup element ids you want to reference from the fragments.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "featureRefs": { - "description": "The Feature element ids you want to reference from the fragments.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "mergeRefs": { - "description": "The Merge element ids you want to reference from the fragments.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "bannerPath": { - "description": "Path to a bitmap file to use as the installation user interface banner. This bitmap will appear at the top of all but the first page of the installer.\n\nThe required dimensions are 493px × 58px.", - "type": [ - "string", - "null" - ] - }, - "dialogImagePath": { - "description": "Path to a bitmap file to use on the installation user interface dialogs. It is used on the welcome and completion dialogs. The required dimensions are 493px × 312px.", - "type": [ - "string", - "null" - ] - }, - "fipsCompliant": { - "description": "Enables FIPS compliant algorithms.", - "default": false, - "type": "boolean" - } - }, - "additionalProperties": false - }, - "WixLanguages": { - "description": "The languages to build using WiX.", - "type": "array", - "items": { - "type": "array", - "items": [ - { - "type": "string" - }, - { - "$ref": "#/definitions/WixLanguageConfig" - } - ], - "maxItems": 2, - "minItems": 2 - } - }, - "WixLanguageConfig": { - "description": "Configuration for a target language for the WiX build.", - "type": "object", - "properties": { - "localePath": { - "description": "The path to a locale (`.wxl`) file. See .", - "type": [ - "string", - "null" - ] - } - }, - "additionalProperties": false - }, - "NsisConfig": { - "description": "The NSIS format configuration.", - "type": "object", - "properties": { - "compression": { - "description": "Set the compression algorithm used to compress files in the installer.\n\nSee ", - "anyOf": [ - { - "$ref": "#/definitions/NsisCompression" - }, - { - "type": "null" - } - ] - }, - "template": { - "description": "A custom `.nsi` template to use.\n\nSee the default template here ", - "type": [ - "string", - "null" - ] - }, - "preinstallSection": { - "description": "Logic of an NSIS section that will be ran before the install section.\n\nSee the available libraries, dlls and global variables here \n\n### Example ```toml [package.metadata.packager.nsis] preinstall-section = \"\"\" ; Setup custom messages LangString webview2AbortError ${LANG_ENGLISH} \"Failed to install WebView2! The app can't run without it. Try restarting the installer.\" LangString webview2DownloadError ${LANG_ARABIC} \"خطأ: فشل تنزيل WebView2 - $0\"\n\nSection PreInstall ;
SectionEnd\n\nSection AnotherPreInstall ;
SectionEnd \"\"\" ```", - "type": [ - "string", - "null" - ] - }, - "headerImage": { - "description": "The path to a bitmap file to display on the header of installers pages.\n\nThe recommended dimensions are 150px x 57px.", - "type": [ - "string", - "null" - ] - }, - "sidebarImage": { - "description": "The path to a bitmap file for the Welcome page and the Finish page.\n\nThe recommended dimensions are 164px x 314px.", - "type": [ - "string", - "null" - ] - }, - "installerIcon": { - "description": "The path to an icon file used as the installer icon.", - "type": [ - "string", - "null" - ] - }, - "installMode": { - "description": "Whether the installation will be for all users or just the current user.", - "default": "currentUser", - "allOf": [ - { - "$ref": "#/definitions/NSISInstallerMode" - } - ] - }, - "languages": { - "description": "A list of installer languages. By default the OS language is used. If the OS language is not in the list of languages, the first language will be used. To allow the user to select the language, set `display_language_selector` to `true`.\n\nSee for the complete list of languages.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "customLanguageFiles": { - "description": "An key-value pair where the key is the language and the value is the path to a custom `.nsi` file that holds the translated text for cargo-packager's custom messages.\n\nSee for an example `.nsi` file.\n\n**Note**: the key must be a valid NSIS language and it must be added to [`NsisConfig`]languages array,", - "type": [ - "object", - "null" - ], - "additionalProperties": { - "type": "string" - } - }, - "displayLanguageSelector": { - "description": "Whether to display a language selector dialog before the installer and uninstaller windows are rendered or not. By default the OS language is selected, with a fallback to the first language in the `languages` array.", - "default": false, - "type": "boolean" - }, - "appdataPaths": { - "description": "List of paths where your app stores data. This options tells the uninstaller to provide the user with an option (disabled by default) whether they want to rmeove your app data or keep it.\n\nThe path should use a constant from in addition to `$IDENTIFIER`, `$PUBLISHER` and `$PRODUCTNAME`, for example, if you store your app data in `C:\\\\Users\\\\\\\\AppData\\\\Local\\\\\\\\` you'd need to specify ```toml [package.metadata.packager.nsis] appdata-paths = [\"$LOCALAPPDATA/$PUBLISHER/$PRODUCTNAME\"] ```", - "default": null, - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - } - }, - "additionalProperties": false - }, - "NsisCompression": { - "description": "Compression algorithms used in the NSIS installer.\n\nSee ", - "oneOf": [ - { - "description": "ZLIB uses the deflate algorithm, it is a quick and simple method. With the default compression level it uses about 300 KB of memory.", - "type": "string", - "enum": [ - "zlib" - ] - }, - { - "description": "BZIP2 usually gives better compression ratios than ZLIB, but it is a bit slower and uses more memory. With the default compression level it uses about 4 MB of memory.", - "type": "string", - "enum": [ - "bzip2" - ] - }, - { - "description": "LZMA (default) is a new compression method that gives very good compression ratios. The decompression speed is high (10-20 MB/s on a 2 GHz CPU), the compression speed is lower. The memory size that will be used for decompression is the dictionary size plus a few KBs, the default is 8 MB.", - "type": "string", - "enum": [ - "lzma" - ] - } - ] - }, - "NSISInstallerMode": { - "description": "Install Modes for the NSIS installer.", - "oneOf": [ - { - "description": "Default mode for the installer.\n\nInstall the app by default in a directory that doesn't require Administrator access.\n\nInstaller metadata will be saved under the `HKCU` registry path.", - "type": "string", - "enum": [ - "currentUser" - ] - }, - { - "description": "Install the app by default in the `Program Files` folder directory requires Administrator access for the installation.\n\nInstaller metadata will be saved under the `HKLM` registry path.", - "type": "string", - "enum": [ - "perMachine" - ] - }, - { - "description": "Combines both modes and allows the user to choose at install time whether to install for the current user or per machine. Note that this mode will require Administrator access even if the user wants to install it for the current user only.\n\nInstaller metadata will be saved under the `HKLM` or `HKCU` registry path based on the user's choice.", - "type": "string", - "enum": [ - "both" - ] - } - ] - }, - "MacOsConfig": { - "description": "The macOS configuration.", - "type": "object", - "properties": { - "frameworks": { - "description": "MacOS frameworks that need to be packaged with the app.\n\nEach string can either be the name of a framework (without the `.framework` extension, e.g. `\"SDL2\"`), in which case we will search for that framework in the standard install locations (`~/Library/Frameworks/`, `/Library/Frameworks/`, and `/Network/Library/Frameworks/`), or a path to a specific framework bundle (e.g. `./data/frameworks/SDL2.framework`). Note that this setting just makes cargo-packager copy the specified frameworks into the OS X app bundle (under `Foobar.app/Contents/Frameworks/`); you are still responsible for:\n\n- arranging for the compiled binary to link against those frameworks (e.g. by emitting lines like `cargo:rustc-link-lib=framework=SDL2` from your `build.rs` script)\n\n- embedding the correct rpath in your binary (e.g. by running `install_name_tool -add_rpath \"@executable_path/../Frameworks\" path/to/binary` after compiling)", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "minimumSystemVersion": { - "description": "A version string indicating the minimum MacOS version that the packaged app supports (e.g. `\"10.11\"`). If you are using this config field, you may also want have your `build.rs` script emit `cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=10.11`.", - "type": [ - "string", - "null" - ] - }, - "exceptionDomain": { - "description": "The exception domain to use on the macOS .app package.\n\nThis allows communication to the outside world e.g. a web server you're shipping.", - "type": [ - "string", - "null" - ] - }, - "signingIdentity": { - "description": "Code signing identity.", - "type": [ - "string", - "null" - ] - }, - "providerShortName": { - "description": "Provider short name for notarization.", - "type": [ - "string", - "null" - ] - }, - "entitlements": { - "description": "Path to the entitlements.plist file.", - "type": [ - "string", - "null" - ] - }, - "infoPlistPath": { - "description": "Path to the Info.plist file for the package.", - "type": [ - "string", - "null" - ] - } - }, - "additionalProperties": false - }, - "WindowsConfig": { - "description": "The Windows configuration.", - "type": "object", - "properties": { - "digestAlgorithm": { - "description": "The file digest algorithm to use for creating file signatures. Required for code signing. SHA-256 is recommended.", - "type": [ - "string", - "null" - ] - }, - "certificateThumbprint": { - "description": "The SHA1 hash of the signing certificate.", - "type": [ - "string", - "null" - ] - }, - "timestampUrl": { - "description": "Server to use during timestamping.", - "type": [ - "string", - "null" - ] - }, - "tsp": { - "description": "Whether to use Time-Stamp Protocol (TSP, a.k.a. RFC 3161) for the timestamp server. Your code signing provider may use a TSP timestamp server, like e.g. SSL.com does. If so, enable TSP by setting to true.", - "default": false, - "type": "boolean" - }, - "allowDowngrades": { - "description": "Validates a second app installation, blocking the user from installing an older version if set to `false`.\n\nFor instance, if `1.2.1` is installed, the user won't be able to install app version `1.2.0` or `1.1.5`.\n\nThe default value of this flag is `true`.", - "default": true, - "type": "boolean" - } - }, - "additionalProperties": false - } - } -} \ No newline at end of file diff --git a/crates/packager/Cargo.toml b/crates/packager/Cargo.toml index b954a601..747a48eb 100644 --- a/crates/packager/Cargo.toml +++ b/crates/packager/Cargo.toml @@ -30,10 +30,10 @@ targets = [ [features] default = [ "cli" ] -cli = [ "clap", "cargo-packager-config/clap", "tracing-subscriber" ] +cli = [ "clap", "tracing-subscriber" ] +schema = ["schemars"] [dependencies] -cargo-packager-config = { path = "../config", version = "0.2.0" } thiserror = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } @@ -59,6 +59,8 @@ os_pipe = "1" minisign = "0.7" tar = "0.4" libflate = "2.0" +strsim = "0.10" +schemars = { workspace = true, optional = true } [target."cfg(target_os = \"windows\")".dependencies] winreg = "0.51" diff --git a/crates/packager/src/codesign/macos.rs b/crates/packager/src/codesign/macos.rs index d4bb97ac..0d959e0b 100644 --- a/crates/packager/src/codesign/macos.rs +++ b/crates/packager/src/codesign/macos.rs @@ -11,10 +11,9 @@ use std::{ process::Command, }; -use cargo_packager_config::Config; use serde::Deserialize; -use crate::{config::ConfigExt, shell::CommandExt, Error}; +use crate::{shell::CommandExt, Config, Error}; const KEYCHAIN_ID: &str = "cargo-packager.keychain"; const KEYCHAIN_PWD: &str = "cargo-packager"; diff --git a/crates/packager/src/codesign/windows.rs b/crates/packager/src/codesign/windows.rs index 7bec88db..33827fe7 100644 --- a/crates/packager/src/codesign/windows.rs +++ b/crates/packager/src/codesign/windows.rs @@ -18,7 +18,7 @@ use winreg::{ }; use crate::{ - config::{Config, ConfigExt}, + config::Config, shell::CommandExt, util::{self, display_path, Bitness}, }; diff --git a/crates/packager/src/config.rs b/crates/packager/src/config.rs deleted file mode 100644 index eaeaabf4..00000000 --- a/crates/packager/src/config.rs +++ /dev/null @@ -1,268 +0,0 @@ -// Copyright 2023-2023 CrabNebula Ltd. -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -//! Configuration type and associated utilities. - -use std::path::{Path, PathBuf}; - -pub use cargo_packager_config::*; -use relative_path::PathExt; - -use crate::util; - -#[derive(Debug, Clone)] -pub(crate) struct IResource { - pub src: PathBuf, - pub target: PathBuf, -} - -/// [Config] extenstion trait -pub trait ConfigExt { - /// Returns the windows specific configuration - fn windows(&self) -> Option<&WindowsConfig>; - /// Returns the nsis specific configuration - fn nsis(&self) -> Option<&NsisConfig>; - /// Returns the wix specific configuration - fn wix(&self) -> Option<&WixConfig>; - /// Returns the debian specific configuration - fn deb(&self) -> Option<&DebianConfig>; - /// Returns the macos specific configuration - fn macos(&self) -> Option<&MacOsConfig>; - /// Returns the appimage specific configuration - fn appimage(&self) -> Option<&AppImageConfig>; - /// Returns the target triple for the package to be built (e.g. "aarch64-unknown-linux-gnu"). - fn target_triple(&self) -> String; - /// Returns the architecture for the package to be built (e.g. "arm", "x86" or "x86_64"). - fn target_arch(&self) -> crate::Result<&str>; - /// Returns the path to the specified binary. - fn binary_path(&self, binary: &Binary) -> PathBuf; - /// Returns the package identifier - fn identifier(&self) -> &str; - /// Returns the package publisher - fn publisher(&self) -> String; - /// Returns the out dir - fn out_dir(&self) -> PathBuf; -} - -impl ConfigExt for Config { - fn windows(&self) -> Option<&WindowsConfig> { - self.windows.as_ref() - } - - fn macos(&self) -> Option<&MacOsConfig> { - self.macos.as_ref() - } - - fn nsis(&self) -> Option<&NsisConfig> { - self.nsis.as_ref() - } - - fn wix(&self) -> Option<&WixConfig> { - self.wix.as_ref() - } - - fn deb(&self) -> Option<&DebianConfig> { - self.deb.as_ref() - } - - fn appimage(&self) -> Option<&AppImageConfig> { - self.appimage.as_ref() - } - - fn target_triple(&self) -> String { - self.target_triple.clone().unwrap_or_else(|| { - util::target_triple().expect("Failed to detect current target triple") - }) - } - - fn target_arch(&self) -> crate::Result<&str> { - let target = self.target_triple(); - Ok(if target.starts_with("x86_64") { - "x86_64" - } else if target.starts_with('i') { - "x86" - } else if target.starts_with("arm") { - "arm" - } else if target.starts_with("aarch64") { - "aarch64" - } else if target.starts_with("universal") { - "universal" - } else { - return Err(crate::Error::UnexpectedTargetTriple(target)); - }) - } - - fn binary_path(&self, binary: &Binary) -> PathBuf { - self.out_dir().join(&binary.filename) - } - - fn identifier(&self) -> &str { - self.identifier.as_deref().unwrap_or("") - } - - fn publisher(&self) -> String { - let identifier = self.identifier(); - self.publisher - .clone() - .unwrap_or_else(|| identifier.split('.').nth(1).unwrap_or(identifier).into()) - } - - fn out_dir(&self) -> PathBuf { - dunce::canonicalize(&self.out_dir).unwrap_or_else(|_| self.out_dir.clone()) - } -} - -pub(crate) trait ConfigExtInternal { - fn main_binary(&self) -> crate::Result<&Binary>; - fn main_binary_name(&self) -> crate::Result<&String>; - fn resources_from_dir(src_dir: &Path, target_dir: &Path) -> crate::Result>; - fn resources_from_glob(glob: &str) -> crate::Result>; - fn resources(&self) -> crate::Result>; - fn find_ico(&self) -> Option; - fn copy_resources(&self, path: &Path) -> crate::Result<()>; - fn copy_external_binaries(&self, path: &Path) -> crate::Result<()>; -} - -impl ConfigExtInternal for Config { - fn main_binary(&self) -> crate::Result<&Binary> { - self.binaries - .iter() - .find(|bin| bin.main) - .ok_or_else(|| crate::Error::MainBinaryNotFound) - } - - fn main_binary_name(&self) -> crate::Result<&String> { - self.binaries - .iter() - .find(|bin| bin.main) - .map(|b| &b.filename) - .ok_or_else(|| crate::Error::MainBinaryNotFound) - } - - #[inline] - fn resources_from_dir(src_dir: &Path, target_dir: &Path) -> crate::Result> { - let mut out = Vec::new(); - for entry in walkdir::WalkDir::new(src_dir) { - let entry = entry?; - let path = entry.path(); - if path.is_file() { - let relative = path.relative_to(src_dir)?.to_path(""); - let resource = IResource { - src: dunce::canonicalize(path)?, - target: target_dir.join(relative), - }; - out.push(resource); - } - } - Ok(out) - } - - #[inline] - fn resources_from_glob(glob: &str) -> crate::Result> { - let mut out = Vec::new(); - for src in glob::glob(glob)? { - let src = dunce::canonicalize(src?)?; - let target = PathBuf::from(src.file_name().unwrap_or_default()); - out.push(IResource { src, target }) - } - Ok(out) - } - - fn resources(&self) -> crate::Result> { - if let Some(resources) = &self.resources { - let mut out = Vec::new(); - for r in resources { - match r { - Resource::Single(src) => { - let src_dir = PathBuf::from(src); - if src_dir.is_dir() { - let target_dir = Path::new(src_dir.file_name().unwrap_or_default()); - out.extend(Self::resources_from_dir(&src_dir, target_dir)?); - } else { - out.extend(Self::resources_from_glob(src)?); - } - } - Resource::Mapped { src, target } => { - let src_path = PathBuf::from(src); - let target_dir = sanitize_path(target); - if src_path.is_dir() { - out.extend(Self::resources_from_dir(&src_path, &target_dir)?); - } else if src_path.is_file() { - out.push(IResource { - src: dunce::canonicalize(src_path)?, - target: sanitize_path(target), - }); - } else { - let globbed_res = Self::resources_from_glob(src)?; - let retargetd_res = globbed_res.into_iter().map(|mut r| { - r.target = target_dir.join(r.target); - r - }); - out.extend(retargetd_res); - } - } - } - } - - Ok(out) - } else { - Ok(vec![]) - } - } - - fn find_ico(&self) -> Option { - self.icons - .as_ref() - .and_then(|icons| { - icons - .iter() - .find(|i| PathBuf::from(i).extension().and_then(|s| s.to_str()) == Some("ico")) - .or_else(|| { - icons.iter().find(|i| { - PathBuf::from(i).extension().and_then(|s| s.to_str()) == Some("png") - }) - }) - }) - .map(PathBuf::from) - } - - fn copy_resources(&self, path: &Path) -> crate::Result<()> { - for resource in self.resources()? { - let dest = path.join(resource.target); - std::fs::create_dir_all( - dest.parent() - .ok_or_else(|| crate::Error::ParentDirNotFound(dest.to_path_buf()))?, - )?; - std::fs::copy(resource.src, dest)?; - } - Ok(()) - } - - fn copy_external_binaries(&self, path: &Path) -> crate::Result<()> { - if let Some(external_binaries) = &self.external_binaries { - for src in external_binaries { - let src = dunce::canonicalize(PathBuf::from(src))?; - let file_name_no_triple = src - .file_name() - .ok_or_else(|| crate::Error::FailedToExtractFilename(src.clone()))? - .to_string_lossy() - .replace(&format!("-{}", self.target_triple()), ""); - let dest = path.join(file_name_no_triple); - std::fs::copy(src, dest)?; - } - } - - Ok(()) - } -} - -fn sanitize_path>(path: P) -> PathBuf { - let mut dest = PathBuf::new(); - for c in path.as_ref().components() { - if let std::path::Component::Normal(s) = c { - dest.push(s) - } - } - dest -} diff --git a/crates/config/src/category.rs b/crates/packager/src/config/category.rs similarity index 99% rename from crates/config/src/category.rs rename to crates/packager/src/config/category.rs index 99cbd553..70210c28 100644 --- a/crates/config/src/category.rs +++ b/crates/packager/src/config/category.rs @@ -6,7 +6,6 @@ use std::{fmt, str::FromStr}; -use schemars::JsonSchema; use serde::Serialize; const CONFIDENCE_THRESHOLD: f64 = 0.8; @@ -16,7 +15,8 @@ const MACOS_APP_CATEGORY_PREFIX: &str = "public.app-category."; /// The possible app categories. /// Corresponds to `LSApplicationCategoryType` on macOS and the GNOME desktop categories on Debian. #[allow(missing_docs)] -#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, JsonSchema)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[non_exhaustive] pub enum AppCategory { Business, diff --git a/crates/config/src/lib.rs b/crates/packager/src/config/mod.rs similarity index 76% rename from crates/config/src/lib.rs rename to crates/packager/src/config/mod.rs index 858e3ec1..af330bee 100644 --- a/crates/config/src/lib.rs +++ b/crates/packager/src/config/mod.rs @@ -1,28 +1,27 @@ -// Copyright 2016-2019 Cargo-Bundle developers -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy // Copyright 2023-2023 CrabNebula Ltd. // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -//! Config types for [`cargo-packager`](https://docs.rs/cargo-packager). - -#![deny(missing_docs)] +//! Configuration type and associated utilities. use std::{ collections::HashMap, fmt::{self, Display}, - path::PathBuf, + path::{Path, PathBuf}, }; -use schemars::JsonSchema; +use relative_path::PathExt; use serde::{Deserialize, Serialize}; +use crate::util; + mod category; pub use category::AppCategory; /// The type of the package we're packaging. #[non_exhaustive] -#[derive(Clone, Copy, Debug, Eq, PartialEq, Deserialize, Serialize, JsonSchema)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[cfg_attr(feature = "clap", derive(clap::ValueEnum))] #[cfg_attr(feature = "clap", value(rename_all = "lowercase"))] #[serde(rename_all = "lowercase")] @@ -172,7 +171,8 @@ impl PackageFormat { } /// **macOS-only**. Corresponds to CFBundleTypeRole -#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize, JsonSchema)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub enum BundleTypeRole { /// CFBundleTypeRole.Editor. Files can be read and edited. @@ -206,7 +206,8 @@ impl Display for BundleTypeRole { } /// A file association configuration. -#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize, JsonSchema)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct FileAssociation { /// File extensions to associate with this app. e.g. 'png' @@ -224,7 +225,8 @@ pub struct FileAssociation { } /// The Linux debian configuration. -#[derive(Clone, Debug, Default, Deserialize, Serialize, JsonSchema)] +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct DebianConfig { /// the list of debian dependencies. @@ -257,7 +259,8 @@ pub struct DebianConfig { } /// The Linux AppImage configuration. -#[derive(Clone, Debug, Default, Deserialize, Serialize, JsonSchema)] +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct AppImageConfig { /// List of libs that exist in `/usr/lib*` to be include in the final AppImage. @@ -277,7 +280,8 @@ pub struct AppImageConfig { } /// The macOS configuration. -#[derive(Clone, Debug, Default, Deserialize, Serialize, JsonSchema)] +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct MacOsConfig { /// MacOS frameworks that need to be packaged with the app. @@ -314,7 +318,8 @@ pub struct MacOsConfig { } /// Configuration for a target language for the WiX build. -#[derive(Debug, Clone, Default, Deserialize, Serialize, JsonSchema)] +#[derive(Debug, Clone, Default, Deserialize, Serialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct WixLanguageConfig { /// The path to a locale (`.wxl`) file. See . @@ -323,7 +328,8 @@ pub struct WixLanguageConfig { } /// The languages to build using WiX. -#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)] +#[derive(Debug, Clone, Deserialize, Serialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] pub struct WixLanguages(pub Vec<(String, WixLanguageConfig)>); impl Default for WixLanguages { @@ -333,7 +339,8 @@ impl Default for WixLanguages { } /// The wix format configuration -#[derive(Clone, Debug, Default, Deserialize, Serialize, JsonSchema)] +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct WixConfig { /// The app languages to build. See . @@ -401,7 +408,8 @@ pub struct WixConfig { } /// Install Modes for the NSIS installer. -#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize, JsonSchema)] +#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub enum NSISInstallerMode { /// Default mode for the installer. @@ -432,7 +440,8 @@ impl Default for NSISInstallerMode { /// Compression algorithms used in the NSIS installer. /// /// See -#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize, JsonSchema)] +#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(rename_all = "camelCase")] pub enum NsisCompression { /// ZLIB uses the deflate algorithm, it is a quick and simple method. With the default compression level it uses about 300 KB of memory. @@ -444,7 +453,8 @@ pub enum NsisCompression { } /// The NSIS format configuration. -#[derive(Clone, Debug, Default, Deserialize, Serialize, JsonSchema)] +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct NsisConfig { /// Set the compression algorithm used to compress files in the installer. @@ -535,7 +545,8 @@ pub struct NsisConfig { } /// The Windows configuration. -#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)] +#[derive(Clone, Debug, Deserialize, Serialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct WindowsConfig { /// The file digest algorithm to use for creating file signatures. Required for code signing. SHA-256 is recommended. @@ -583,7 +594,8 @@ impl Default for WindowsConfig { /// An enum representing the available verbosity levels of the logger. #[derive(Deserialize, Serialize)] #[repr(usize)] -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash, JsonSchema)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub enum LogLevel { /// The "error" level. @@ -615,7 +627,8 @@ impl Default for LogLevel { } /// A binary to package within the final package. -#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)] +#[derive(Debug, Clone, Deserialize, Serialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct Binary { /// File name and without `.exe` on Windows @@ -627,7 +640,8 @@ pub struct Binary { /// A path to a resource (with optional glob pattern) /// or an object of `src` and `target` paths. -#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)] +#[derive(Debug, Clone, Deserialize, Serialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(untagged)] pub enum Resource { /// Supports glob patterns @@ -646,7 +660,8 @@ pub enum Resource { } /// Describes a shell command to be executed when a CLI hook is triggered. -#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)] +#[derive(Debug, Clone, Deserialize, Serialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(untagged)] pub enum HookCommand { /// Run the given script with the default options. @@ -661,7 +676,8 @@ pub enum HookCommand { } /// The packaging config. -#[derive(Deserialize, Serialize, Default, Debug, Clone, JsonSchema)] +#[derive(Deserialize, Serialize, Default, Debug, Clone)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct Config { /// Whether this config is enabled or not. Defaults to `true`. @@ -733,7 +749,7 @@ pub struct Config { /// This string must be unique across applications since it is used in some system configurations. /// This string must contain only alphanumeric characters (A–Z, a–z, and 0–9), hyphens (-), /// and periods (.). - #[schemars(regex(pattern = r"^[a-zA-Z0-9-\.]*$"))] + #[cfg_attr(feature = "schema", schemars(regex(pattern = r"^[a-zA-Z0-9-\.]*$")))] pub identifier: Option, /// The app's publisher. Defaults to the second element in the identifier string. /// Currently maps to the Manufacturer property of the Windows Installer. @@ -790,3 +806,240 @@ pub struct Config { /// Windows-specific settings. pub windows: Option, } + +#[derive(Debug, Clone)] +pub(crate) struct IResource { + pub src: PathBuf, + pub target: PathBuf, +} + +impl Config { + /// Returns the windows specific configuration + pub fn windows(&self) -> Option<&WindowsConfig> { + self.windows.as_ref() + } + + /// Returns the macos specific configuration + pub fn macos(&self) -> Option<&MacOsConfig> { + self.macos.as_ref() + } + + /// Returns the nsis specific configuration + pub fn nsis(&self) -> Option<&NsisConfig> { + self.nsis.as_ref() + } + + /// Returns the wix specific configuration + pub fn wix(&self) -> Option<&WixConfig> { + self.wix.as_ref() + } + + /// Returns the debian specific configuration + pub fn deb(&self) -> Option<&DebianConfig> { + self.deb.as_ref() + } + + /// Returns the appimage specific configuration + pub fn appimage(&self) -> Option<&AppImageConfig> { + self.appimage.as_ref() + } + + /// Returns the target triple for the package to be built (e.g. "aarch64-unknown-linux-gnu"). + pub fn target_triple(&self) -> String { + self.target_triple.clone().unwrap_or_else(|| { + util::target_triple().expect("Failed to detect current target triple") + }) + } + + /// Returns the architecture for the package to be built (e.g. "arm", "x86" or "x86_64"). + pub fn target_arch(&self) -> crate::Result<&str> { + let target = self.target_triple(); + Ok(if target.starts_with("x86_64") { + "x86_64" + } else if target.starts_with('i') { + "x86" + } else if target.starts_with("arm") { + "arm" + } else if target.starts_with("aarch64") { + "aarch64" + } else if target.starts_with("universal") { + "universal" + } else { + return Err(crate::Error::UnexpectedTargetTriple(target)); + }) + } + + /// Returns the path to the specified binary. + pub fn binary_path(&self, binary: &Binary) -> PathBuf { + self.out_dir().join(&binary.filename) + } + + /// Returns the package identifier + pub fn identifier(&self) -> &str { + self.identifier.as_deref().unwrap_or("") + } + + /// Returns the package publisher + pub fn publisher(&self) -> String { + let identifier = self.identifier(); + self.publisher + .clone() + .unwrap_or_else(|| identifier.split('.').nth(1).unwrap_or(identifier).into()) + } + + /// Returns the out dir + pub fn out_dir(&self) -> PathBuf { + dunce::canonicalize(&self.out_dir).unwrap_or_else(|_| self.out_dir.clone()) + } + + /// Returns the main binary + pub fn main_binary(&self) -> crate::Result<&Binary> { + self.binaries + .iter() + .find(|bin| bin.main) + .ok_or_else(|| crate::Error::MainBinaryNotFound) + } + + /// Returns the main binary name + pub fn main_binary_name(&self) -> crate::Result<&String> { + self.binaries + .iter() + .find(|bin| bin.main) + .map(|b| &b.filename) + .ok_or_else(|| crate::Error::MainBinaryNotFound) + } +} + +impl Config { + #[inline] + pub(crate) fn resources_from_dir( + src_dir: &Path, + target_dir: &Path, + ) -> crate::Result> { + let mut out = Vec::new(); + for entry in walkdir::WalkDir::new(src_dir) { + let entry = entry?; + let path = entry.path(); + if path.is_file() { + let relative = path.relative_to(src_dir)?.to_path(""); + let resource = IResource { + src: dunce::canonicalize(path)?, + target: target_dir.join(relative), + }; + out.push(resource); + } + } + Ok(out) + } + + #[inline] + pub(crate) fn resources_from_glob(glob: &str) -> crate::Result> { + let mut out = Vec::new(); + for src in glob::glob(glob)? { + let src = dunce::canonicalize(src?)?; + let target = PathBuf::from(src.file_name().unwrap_or_default()); + out.push(IResource { src, target }) + } + Ok(out) + } + + pub(crate) fn resources(&self) -> crate::Result> { + if let Some(resources) = &self.resources { + let mut out = Vec::new(); + for r in resources { + match r { + Resource::Single(src) => { + let src_dir = PathBuf::from(src); + if src_dir.is_dir() { + let target_dir = Path::new(src_dir.file_name().unwrap_or_default()); + out.extend(Self::resources_from_dir(&src_dir, target_dir)?); + } else { + out.extend(Self::resources_from_glob(src)?); + } + } + Resource::Mapped { src, target } => { + let src_path = PathBuf::from(src); + let target_dir = sanitize_path(target); + if src_path.is_dir() { + out.extend(Self::resources_from_dir(&src_path, &target_dir)?); + } else if src_path.is_file() { + out.push(IResource { + src: dunce::canonicalize(src_path)?, + target: sanitize_path(target), + }); + } else { + let globbed_res = Self::resources_from_glob(src)?; + let retargetd_res = globbed_res.into_iter().map(|mut r| { + r.target = target_dir.join(r.target); + r + }); + out.extend(retargetd_res); + } + } + } + } + + Ok(out) + } else { + Ok(vec![]) + } + } + + #[allow(unused)] + pub(crate) fn find_ico(&self) -> Option { + self.icons + .as_ref() + .and_then(|icons| { + icons + .iter() + .find(|i| PathBuf::from(i).extension().and_then(|s| s.to_str()) == Some("ico")) + .or_else(|| { + icons.iter().find(|i| { + PathBuf::from(i).extension().and_then(|s| s.to_str()) == Some("png") + }) + }) + }) + .map(PathBuf::from) + } + + #[allow(unused)] + pub(crate) fn copy_resources(&self, path: &Path) -> crate::Result<()> { + for resource in self.resources()? { + let dest = path.join(resource.target); + std::fs::create_dir_all( + dest.parent() + .ok_or_else(|| crate::Error::ParentDirNotFound(dest.to_path_buf()))?, + )?; + std::fs::copy(resource.src, dest)?; + } + Ok(()) + } + + #[allow(unused)] + pub(crate) fn copy_external_binaries(&self, path: &Path) -> crate::Result<()> { + if let Some(external_binaries) = &self.external_binaries { + for src in external_binaries { + let src = dunce::canonicalize(PathBuf::from(src))?; + let file_name_no_triple = src + .file_name() + .ok_or_else(|| crate::Error::FailedToExtractFilename(src.clone()))? + .to_string_lossy() + .replace(&format!("-{}", self.target_triple()), ""); + let dest = path.join(file_name_no_triple); + std::fs::copy(src, dest)?; + } + } + + Ok(()) + } +} + +fn sanitize_path>(path: P) -> PathBuf { + let mut dest = PathBuf::new(); + for c in path.as_ref().components() { + if let std::path::Component::Normal(s) = c { + dest.push(s) + } + } + dest +} diff --git a/crates/packager/src/package/app/mod.rs b/crates/packager/src/package/app/mod.rs index f17bef47..a9be16a0 100644 --- a/crates/packager/src/package/app/mod.rs +++ b/crates/packager/src/package/app/mod.rs @@ -7,11 +7,7 @@ use std::path::{Path, PathBuf}; use super::Context; -use crate::{ - codesign, - config::{Config, ConfigExt, ConfigExtInternal}, - util, -}; +use crate::{codesign, config::Config, util}; #[tracing::instrument(level = "trace")] pub(crate) fn package(ctx: &Context) -> crate::Result> { diff --git a/crates/packager/src/package/appimage/mod.rs b/crates/packager/src/package/appimage/mod.rs index beb64075..5166f8aa 100644 --- a/crates/packager/src/package/appimage/mod.rs +++ b/crates/packager/src/package/appimage/mod.rs @@ -13,11 +13,7 @@ use std::{ use handlebars::{to_json, Handlebars}; use super::Context; -use crate::{ - config::{ConfigExt, ConfigExtInternal}, - shell::CommandExt, - util, -}; +use crate::{shell::CommandExt, util}; #[tracing::instrument(level = "trace")] fn donwload_dependencies( diff --git a/crates/packager/src/package/context.rs b/crates/packager/src/package/context.rs index 86d64be6..de51ee91 100644 --- a/crates/packager/src/package/context.rs +++ b/crates/packager/src/package/context.rs @@ -4,7 +4,7 @@ use std::path::PathBuf; -use crate::{config::ConfigExt, util, Config}; +use crate::{util, Config}; /// The packaging context info #[derive(Debug)] diff --git a/crates/packager/src/package/deb/mod.rs b/crates/packager/src/package/deb/mod.rs index d10fa268..c5b5dac0 100644 --- a/crates/packager/src/package/deb/mod.rs +++ b/crates/packager/src/package/deb/mod.rs @@ -20,10 +20,7 @@ use serde::Serialize; use walkdir::WalkDir; use super::Context; -use crate::{ - config::{Config, ConfigExt, ConfigExtInternal}, - util, -}; +use crate::{config::Config, util}; #[derive(PartialEq, Eq, PartialOrd, Ord)] pub struct DebIcon { diff --git a/crates/packager/src/package/dmg/mod.rs b/crates/packager/src/package/dmg/mod.rs index f442e527..a053263c 100644 --- a/crates/packager/src/package/dmg/mod.rs +++ b/crates/packager/src/package/dmg/mod.rs @@ -8,7 +8,6 @@ use std::{os::unix::fs::PermissionsExt, path::PathBuf, process::Command}; use super::Context; use crate::{ codesign, - config::ConfigExt, shell::CommandExt, util::{self, download}, }; diff --git a/crates/packager/src/package/mod.rs b/crates/packager/src/package/mod.rs index cde2db15..75335141 100644 --- a/crates/packager/src/package/mod.rs +++ b/crates/packager/src/package/mod.rs @@ -4,7 +4,7 @@ use std::path::PathBuf; -use crate::{shell::CommandExt, util, Config, PackageFormat}; +use crate::{config, shell::CommandExt, util, Config, PackageFormat}; use self::context::Context; @@ -164,11 +164,11 @@ fn run_before_each_packaging_command_hook( ) -> crate::Result<()> { if let Some(hook) = &config.before_each_package_command { let (mut cmd, script) = match hook { - cargo_packager_config::HookCommand::Script(script) => { + config::HookCommand::Script(script) => { let cmd = util::cross_command(script); (cmd, script) } - cargo_packager_config::HookCommand::ScriptWithOptions { script, dir } => { + config::HookCommand::ScriptWithOptions { script, dir } => { let mut cmd = util::cross_command(script); if let Some(dir) = dir { cmd.current_dir(dir); @@ -208,11 +208,11 @@ fn run_before_packaging_command_hook( ) -> crate::Result<()> { if let Some(hook) = &config.before_packaging_command { let (mut cmd, script) = match hook { - cargo_packager_config::HookCommand::Script(script) => { + config::HookCommand::Script(script) => { let cmd = util::cross_command(script); (cmd, script) } - cargo_packager_config::HookCommand::ScriptWithOptions { script, dir } => { + config::HookCommand::ScriptWithOptions { script, dir } => { let mut cmd = util::cross_command(script); if let Some(dir) = dir { cmd.current_dir(dir); diff --git a/crates/packager/src/package/nsis/mod.rs b/crates/packager/src/package/nsis/mod.rs index c477d098..5d5478a3 100644 --- a/crates/packager/src/package/nsis/mod.rs +++ b/crates/packager/src/package/nsis/mod.rs @@ -10,14 +10,13 @@ use std::{ process::Command, }; -use cargo_packager_config::NsisCompression; use handlebars::{to_json, Handlebars}; use super::Context; #[cfg(windows)] use crate::codesign; use crate::{ - config::{Config, ConfigExt, ConfigExtInternal, LogLevel, NSISInstallerMode}, + config::{Config, LogLevel, NSISInstallerMode, NsisCompression}, shell::CommandExt, util::{self, download, download_and_verify, extract_zip, HashAlgorithm}, }; diff --git a/crates/packager/src/package/wix/mod.rs b/crates/packager/src/package/wix/mod.rs index ae4783fe..a813e08b 100644 --- a/crates/packager/src/package/wix/mod.rs +++ b/crates/packager/src/package/wix/mod.rs @@ -11,7 +11,6 @@ use std::{ process::Command, }; -use cargo_packager_config::LogLevel; use handlebars::{to_json, Handlebars}; use regex::Regex; use serde::{Deserialize, Serialize}; @@ -20,7 +19,7 @@ use uuid::Uuid; use super::Context; use crate::{ codesign, - config::{Config, ConfigExt, ConfigExtInternal}, + config::{Config, LogLevel}, shell::CommandExt, util::{self, download_and_verify, extract_zip, HashAlgorithm}, };