Skip to content

Commit

Permalink
fix(cli): duplicated short flag for signer sign, closes #3483 (#3492)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Feb 17, 2022
1 parent 84895a9 commit a975551
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
6 changes: 6 additions & 0 deletions .changes/fix-cli-signer-sign-cmd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"cli.rs": patch
"cli.js": patch
---

Fixes the signature of the `signer sign` command to not have duplicated short flags.
9 changes: 5 additions & 4 deletions examples/api/src-tauri/Cargo.lock

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

10 changes: 4 additions & 6 deletions tooling/cli/src/helpers/updater_signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ where
/// Sign files
pub fn sign_file<P>(
private_key: String,
password: String,
password: Option<String>,
bin_path: P,
) -> crate::Result<(PathBuf, String)>
where
P: AsRef<Path>,
{
let decoded_secret = decode_key(private_key)?;
let sk_box = SecretKeyBox::from_string(&decoded_secret).unwrap();
let sk = sk_box.into_secret_key(Some(password)).unwrap();
let sk = sk_box.into_secret_key(password).unwrap();

// We need to append .sig at the end it's where the signature will be stored
let signature_path_string = format!("{}.sig", bin_path.as_ref().display());
Expand Down Expand Up @@ -146,10 +146,8 @@ where
P: AsRef<Path>,
{
// if no password provided we set empty string
let password_string = match var_os("TAURI_KEY_PASSWORD") {
Some(value) => String::from(value.to_str().unwrap()),
None => "".into(),
};
let password_string =
var_os("TAURI_KEY_PASSWORD").map(|value| value.to_str().unwrap().to_string());
// get the private key
if let Some(private_key) = var_os("TAURI_PRIVATE_KEY") {
// check if this file exist..
Expand Down
17 changes: 7 additions & 10 deletions tooling/cli/src/signer/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ pub struct Options {
#[clap(short, long)]
password: Option<String>,
/// Sign the specified file
#[clap(short, long)]
file: Option<PathBuf>,
file: PathBuf,
}

pub fn command(mut options: Options) -> Result<()> {
Expand All @@ -34,22 +33,20 @@ pub fn command(mut options: Options) -> Result<()> {
} else {
options.private_key
};
if options.private_key.is_none() {
let private_key = if let Some(pk) = options.private_key {
pk
} else {
return Err(anyhow::anyhow!(
"Key generation aborted: Unable to find the private key".to_string(),
));
}
};

if options.password.is_none() {
println!("Signing without password.");
}

let (manifest_dir, signature) = sign_file(
options.private_key.unwrap(),
options.password.unwrap(),
options.file.unwrap(),
)
.with_context(|| "failed to sign file")?;
let (manifest_dir, signature) = sign_file(private_key, options.password, options.file)
.with_context(|| "failed to sign file")?;

println!(
"\nYour file was signed successfully, You can find the signature here:\n{}\n\nPublic signature:\n{}\n\nMake sure to include this into the signature field of your update server.",
Expand Down

0 comments on commit a975551

Please sign in to comment.