diff --git a/.changes/tauri-info-framework-bundler.md b/.changes/tauri-info-framework-bundler.md new file mode 100644 index 000000000..f0e191f41 --- /dev/null +++ b/.changes/tauri-info-framework-bundler.md @@ -0,0 +1,5 @@ +--- +"cli.rs": patch +--- + +Show `framework` and `bundler` on the `info` command by reading the `package.json` file and matching known dependencies. diff --git a/tooling/cli.rs/src/info.rs b/tooling/cli.rs/src/info.rs index 54c9031f8..36c20dcd7 100644 --- a/tooling/cli.rs/src/info.rs +++ b/tooling/cli.rs/src/info.rs @@ -525,6 +525,43 @@ impl Info { .value(config.build.dev_path.clone()) .display(); } + if let Ok(package_json) = read_to_string(app_dir.join("package.json")) { + let framework_map = [ + ("svelte", "Svelte", None), + ("@angular", "Angular", Some("Webpack")), + (r#""next""#, "React (Next.js)", Some("Webpack")), + ("gatsby", "React (Gatsby)", Some("Webpack")), + ("react", "React", None), + ("nuxt", "Vue.js (Nuxt)", Some("Webpack")), + ("quasar", "Vue.js (Quasar)", Some("Webpack")), + ("@vue/cli", "Vue.js (Vue CLI)", Some("Webpack")), + ("vue", "Vue.js", None), + ]; + let bundler_map = [("webpack", "Webpack"), ("rollup", "Rollup")]; + + let (framework, framework_bundler) = framework_map + .iter() + .find(|(keyword, _, _)| package_json.contains(keyword)) + .map(|(_, framework, bundler)| { + (Some(framework.to_string()), bundler.map(|b| b.to_string())) + }) + .unwrap_or((None, None)); + + let bundler = bundler_map + .iter() + .find(|(keyword, _)| package_json.contains(keyword)) + .map(|(_, bundler)| bundler.to_string()) + .or(framework_bundler); + + if let Some(framework) = framework { + InfoBlock::new("framework").value(framework).display(); + } + if let Some(bundler) = bundler { + InfoBlock::new("bundler").value(bundler).display(); + } + } else { + println!("package.json not found"); + } } Ok(())