ソースを参照

feat(cli): add `--ci` flag to `signer generate`, closes #6089 (#6097)

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Amr Bashir 2 年 前
コミット
8fb1df8aa6
2 ファイル変更15 行追加3 行削除
  1. 6 0
      .changes/cli-sign-non-interactive.md
  2. 9 3
      tooling/cli/src/signer/generate.rs

+ 6 - 0
.changes/cli-sign-non-interactive.md

@@ -0,0 +1,6 @@
+---
+"cli.rs": patch
+"cli.js": patch
+---
+
+Add `--ci` flag and respect the `CI` environment variable on the `signer generate` command. In this case the default password will be an empty string and the CLI will not prompt for a value.

+ 9 - 3
tooling/cli/src/signer/generate.rs

@@ -21,11 +21,17 @@ pub struct Options {
   /// Overwrite private key even if it exists on the specified path
   #[clap(short, long)]
   force: bool,
+  /// Skip prompting for values
+  #[clap(short, long)]
+  ci: bool,
 }
 
-pub fn command(options: Options) -> Result<()> {
-  if options.password.is_none() {
-    println!("Generating new private key without password.")
+pub fn command(mut options: Options) -> Result<()> {
+  options.ci = options.ci || std::env::var("CI").is_ok();
+
+  if options.ci && options.password.is_none() {
+    println!("Generating new private key without password.");
+    options.password.replace("".into());
   }
   let keypair = generate_key(options.password).expect("Failed to generate key");