Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): allow setting product name and version on tauri.conf.json #1358

Merged
merged 7 commits into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(config): allow setting product name and version on tauri.conf.json
  • Loading branch information
lucasfernog committed Mar 15, 2021
commit 561d7ab2cb8c2ff8beb5fe765e13874ed07d9c3e
6 changes: 6 additions & 0 deletions .changes/package-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri": minor
"tauri-cli": minor
---

Adds `productName` and `version` configs on `tauri.conf.json > package`.
1 change: 1 addition & 0 deletions cli/core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions cli/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ serde_with = "1.6"

[target."cfg(target_os = \"windows\")".dependencies]
which = "4.0"

[target."cfg(target_os = \"linux\")".dependencies]
heck = "0.3"
15 changes: 13 additions & 2 deletions cli/core/config_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ pub struct OsxConfig {
pub use_bootstrapper: bool,
}

#[skip_serializing_none]
#[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct PackageConfig {
/// App name. Automatically converted to kebab-case on Linux.
pub product_name: Option<String>,
/// App version.
pub version: Option<String>,
}

#[skip_serializing_none]
#[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
Expand All @@ -43,12 +53,10 @@ pub struct BundleConfig {
pub active: bool,
/// The bundle targets, currently supports ["deb", "osx", "msi", "appimage", "dmg"] or "all"
pub targets: Option<BundleTarget>,
pub name: Option<String>,
/// The app's identifier
pub identifier: Option<String>,
/// The app's icons
pub icon: Option<Vec<String>>,
pub version: Option<String>,
/// App resources to bundle.
/// Each resource is a path to a file or directory.
/// Glob patterns are supported.
Expand Down Expand Up @@ -540,6 +548,9 @@ type JsonObject = HashMap<String, JsonValue>;
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct Config {
/// Package settings.
#[serde(default)]
pub package: PackageConfig,
/// The Tauri configuration.
#[serde(default)]
pub tauri: TauriConfig,
Expand Down
41 changes: 29 additions & 12 deletions cli/core/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
}
]
},
"package": {
"description": "Package settings.",
"default": {},
"allOf": [
{
"$ref": "#/definitions/PackageConfig"
}
]
},
"plugins": {
"description": "The plugins config.",
"default": {},
Expand Down Expand Up @@ -287,12 +296,6 @@
"null"
]
},
"name": {
"type": [
"string",
"null"
]
},
"osx": {
"default": {
"useBootstrapper": false
Expand Down Expand Up @@ -335,12 +338,6 @@
"type": "null"
}
]
},
"version": {
"type": [
"string",
"null"
]
}
},
"additionalProperties": false
Expand Down Expand Up @@ -773,6 +770,26 @@
},
"additionalProperties": false
},
"PackageConfig": {
"type": "object",
"properties": {
"productName": {
"description": "App name. Automatically converted to kebab-case on Linux.",
"type": [
"string",
"null"
]
},
"version": {
"description": "App version.",
"type": [
"string",
"null"
]
}
},
"additionalProperties": false
},
"SecurityConfig": {
"type": "object",
"properties": {
Expand Down
27 changes: 21 additions & 6 deletions cli/core/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ use crate::helpers::{
Logger, TauriScript,
};

use std::{env::set_current_dir, fs::File, io::Write, path::PathBuf, process::Command};
use std::{
env::set_current_dir,
fs::{rename, File},
io::Write,
path::PathBuf,
process::Command,
};

mod rust;

Expand Down Expand Up @@ -98,13 +104,22 @@ impl Build {

rust::build_project(self.debug)?;

let app_settings = rust::AppSettings::new(&config_)?;

let out_dir = app_settings.get_out_dir(self.debug)?;
if let Some(product_name) = config_.package.product_name.clone() {
rename(
out_dir.join(app_settings.cargo_package_settings().name.clone()),
out_dir.join(product_name),
)?;
}

if config_.tauri.bundle.active {
let bundler_settings = rust::get_bundler_settings(&config_, self.debug)?;
let mut settings_builder = SettingsBuilder::new()
.package_settings(bundler_settings.package_settings)
.bundle_settings(bundler_settings.bundle_settings)
.binaries(bundler_settings.binaries)
.project_out_directory(bundler_settings.out_dir);
.package_settings(app_settings.get_package_settings())
.bundle_settings(app_settings.get_bundle_settings(&config_)?)
.binaries(app_settings.get_binaries(&config_)?)
.project_out_directory(out_dir);

if self.verbose {
settings_builder = settings_builder.verbose();
Expand Down
Loading