mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-19 08:31:35 +03:00
feat(cli): add --reinstall-deps
option to ios init
This commit is contained in:
parent
8f3a9c5cf6
commit
5d82357166
@ -26,7 +26,7 @@ use sublime_fuzzy::best_match;
|
||||
|
||||
use super::{
|
||||
ensure_init, get_app,
|
||||
init::{command as init_command, init_dot_cargo, Options as InitOptions},
|
||||
init::{command as init_command, init_dot_cargo},
|
||||
log_finished, read_options, CliOptions, Target as MobileTarget, MIN_DEVICE_MATCH_SCORE,
|
||||
};
|
||||
use crate::{
|
||||
@ -53,6 +53,14 @@ pub struct Cli {
|
||||
command: Commands,
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
#[clap(about = "Initializes a Tauri Android project")]
|
||||
pub struct InitOptions {
|
||||
/// Skip prompting for values
|
||||
#[clap(long)]
|
||||
ci: bool,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum Commands {
|
||||
Init(InitOptions),
|
||||
@ -67,7 +75,7 @@ enum Commands {
|
||||
pub fn command(cli: Cli, verbosity: usize) -> Result<()> {
|
||||
let noise_level = NoiseLevel::from_occurrences(verbosity as u64);
|
||||
match cli.command {
|
||||
Commands::Init(options) => init_command(options, MobileTarget::Android)?,
|
||||
Commands::Init(options) => init_command(MobileTarget::Android, options.ci, false)?,
|
||||
Commands::Open => open::command()?,
|
||||
Commands::Dev(options) => dev::command(options, noise_level)?,
|
||||
Commands::Build(options) => build::command(options, noise_level)?,
|
||||
|
@ -11,31 +11,25 @@ use cargo_mobile::{
|
||||
},
|
||||
config::app::App,
|
||||
dot_cargo,
|
||||
os::code_command,
|
||||
target::TargetTrait as _,
|
||||
util::{
|
||||
self,
|
||||
cli::{Report, TextWrapper},
|
||||
},
|
||||
};
|
||||
use clap::Parser;
|
||||
use handlebars::{Context, Handlebars, Helper, HelperResult, Output, RenderContext, RenderError};
|
||||
|
||||
use std::{env::current_dir, fs, path::PathBuf};
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
#[clap(about = "Initializes a Tauri Android project")]
|
||||
pub struct Options {
|
||||
/// Skip prompting for values
|
||||
#[clap(long)]
|
||||
ci: bool,
|
||||
}
|
||||
|
||||
pub fn command(mut options: Options, target: Target) -> Result<()> {
|
||||
options.ci = options.ci || std::env::var("CI").is_ok();
|
||||
|
||||
pub fn command(target: Target, ci: bool, reinstall_deps: bool) -> Result<()> {
|
||||
let wrapper = TextWrapper::with_splitter(textwrap::termwidth(), textwrap::NoHyphenation);
|
||||
exec(target, &wrapper, options.ci, true, true).map_err(|e| anyhow::anyhow!("{:#}", e))?;
|
||||
exec(
|
||||
target,
|
||||
&wrapper,
|
||||
ci || std::env::var("CI").is_ok(),
|
||||
reinstall_deps,
|
||||
)
|
||||
.map_err(|e| anyhow::anyhow!("{:#}", e))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -69,7 +63,6 @@ pub fn exec(
|
||||
target: Target,
|
||||
wrapper: &TextWrapper,
|
||||
non_interactive: bool,
|
||||
skip_dev_tools: bool,
|
||||
#[allow(unused_variables)] reinstall_deps: bool,
|
||||
) -> Result<App> {
|
||||
let tauri_config = get_tauri_config(None)?;
|
||||
@ -87,14 +80,6 @@ pub fn exec(
|
||||
)
|
||||
})?;
|
||||
}
|
||||
if !skip_dev_tools && util::command_present("code").unwrap_or_default() {
|
||||
let mut command = code_command();
|
||||
command.add_args(&["--install-extension", "vadimcn.vscode-lldb"]);
|
||||
if non_interactive {
|
||||
command.add_arg("--force");
|
||||
}
|
||||
command.run_and_wait()?;
|
||||
}
|
||||
|
||||
let (handlebars, mut map) = handlebars(&app);
|
||||
|
||||
@ -169,7 +154,6 @@ pub fn exec(
|
||||
(handlebars, map),
|
||||
wrapper,
|
||||
non_interactive,
|
||||
skip_dev_tools,
|
||||
reinstall_deps,
|
||||
)?;
|
||||
init_dot_cargo(&app, None)?;
|
||||
|
@ -23,7 +23,7 @@ use sublime_fuzzy::best_match;
|
||||
|
||||
use super::{
|
||||
ensure_init, env, get_app,
|
||||
init::{command as init_command, init_dot_cargo, Options as InitOptions},
|
||||
init::{command as init_command, init_dot_cargo},
|
||||
log_finished, read_options, CliOptions, Target as MobileTarget, MIN_DEVICE_MATCH_SCORE,
|
||||
};
|
||||
use crate::{
|
||||
@ -55,6 +55,17 @@ pub struct Cli {
|
||||
command: Commands,
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
#[clap(about = "Initializes a Tauri iOS project")]
|
||||
pub struct InitOptions {
|
||||
/// Skip prompting for values
|
||||
#[clap(long)]
|
||||
ci: bool,
|
||||
/// Reinstall dependencies
|
||||
#[clap(short, long)]
|
||||
reinstall_deps: bool,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum Commands {
|
||||
Init(InitOptions),
|
||||
@ -68,7 +79,7 @@ enum Commands {
|
||||
pub fn command(cli: Cli, verbosity: usize) -> Result<()> {
|
||||
let noise_level = NoiseLevel::from_occurrences(verbosity as u64);
|
||||
match cli.command {
|
||||
Commands::Init(options) => init_command(options, MobileTarget::Ios)?,
|
||||
Commands::Init(options) => init_command(MobileTarget::Ios, options.ci, options.reinstall_deps)?,
|
||||
Commands::Open => open::command()?,
|
||||
Commands::Dev(options) => dev::command(options, noise_level)?,
|
||||
Commands::Build(options) => build::command(options, noise_level)?,
|
||||
|
@ -32,14 +32,13 @@ pub fn gen(
|
||||
(handlebars, mut map): (Handlebars, template::JsonMap),
|
||||
wrapper: &TextWrapper,
|
||||
non_interactive: bool,
|
||||
skip_dev_tools: bool,
|
||||
reinstall_deps: bool,
|
||||
) -> Result<()> {
|
||||
println!("Installing iOS toolchains...");
|
||||
Target::install_all()?;
|
||||
rust_version_check(wrapper)?;
|
||||
|
||||
deps::install_all(wrapper, non_interactive, skip_dev_tools, reinstall_deps)
|
||||
deps::install_all(wrapper, non_interactive, true, reinstall_deps)
|
||||
.with_context(|| "failed to install Apple dependencies")?;
|
||||
|
||||
let dest = config.project_dir();
|
||||
|
Loading…
Reference in New Issue
Block a user