Skip to content

Commit 582c25a

Browse files
authored
refactor(cli): disable api-all on templates (#5538)
1 parent dc9269b commit 582c25a

File tree

14 files changed

+35
-44
lines changed

14 files changed

+35
-44
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"cli.rs": patch
3+
"cli.js": patch
4+
---
5+
6+
Changed the project template to not enable all APIs by default.

tooling/cli/src/build.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ pub fn command(mut options: Options) -> Result<()> {
6363
} else {
6464
(
6565
Some(
66-
std::fs::read_to_string(&config)
67-
.with_context(|| "failed to read custom configuration")?,
66+
std::fs::read_to_string(config).with_context(|| "failed to read custom configuration")?,
6867
),
6968
Some(config.clone()),
7069
)

tooling/cli/src/dev.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fn command_internal(mut options: Options) -> Result<()> {
7979
Some(if config.starts_with('{') {
8080
config.to_string()
8181
} else {
82-
std::fs::read_to_string(&config).with_context(|| "failed to read custom configuration")?
82+
std::fs::read_to_string(config).with_context(|| "failed to read custom configuration")?
8383
})
8484
} else {
8585
None

tooling/cli/src/helpers/updater_signature.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub struct KeyPair {
2222

2323
fn create_file(path: &Path) -> crate::Result<BufWriter<File>> {
2424
if let Some(parent) = path.parent() {
25-
fs::create_dir_all(&parent)?;
25+
fs::create_dir_all(parent)?;
2626
}
2727
let file = File::create(path)?;
2828
Ok(BufWriter::new(file))
@@ -72,12 +72,12 @@ where
7272
sk_path.display()
7373
));
7474
} else {
75-
std::fs::remove_file(&sk_path)?;
75+
std::fs::remove_file(sk_path)?;
7676
}
7777
}
7878

7979
if pk_path.exists() {
80-
std::fs::remove_file(&pk_path)?;
80+
std::fs::remove_file(pk_path)?;
8181
}
8282

8383
let mut sk_writer = create_file(sk_path)?;
@@ -88,7 +88,7 @@ where
8888
write!(pk_writer, "{:}", pubkey)?;
8989
pk_writer.flush()?;
9090

91-
Ok((fs::canonicalize(&sk_path)?, fs::canonicalize(&pk_path)?))
91+
Ok((fs::canonicalize(sk_path)?, fs::canonicalize(pk_path)?))
9292
}
9393

9494
/// Read key from file

tooling/cli/src/helpers/web_dev_server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ async fn handler<T>(req: Request<T>, state: Arc<State>) -> impl IntoResponse {
9696
uri.strip_prefix('/').unwrap_or(&uri)
9797
};
9898

99-
let file = std::fs::read(state.serve_dir.join(&uri))
99+
let file = std::fs::read(state.serve_dir.join(uri))
100100
.or_else(|_| std::fs::read(state.serve_dir.join(format!("{}.html", &uri))))
101101
.or_else(|_| std::fs::read(state.serve_dir.join(format!("{}/index.html", &uri))))
102102
.or_else(|_| std::fs::read(state.serve_dir.join("index.html")));

tooling/cli/src/info.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ fn npm_latest_version(pm: &PackageManager, name: &str) -> crate::Result<Option<S
159159
let output = cmd
160160
.arg("info")
161161
.arg(name)
162-
.args(&["version", "--json"])
162+
.args(["version", "--json"])
163163
.output()?;
164164
if output.status.success() {
165165
let stdout = String::from_utf8_lossy(&output.stdout);
@@ -219,9 +219,9 @@ fn npm_package_version<P: AsRef<Path>>(
219219
let (output, regex) = match pm {
220220
PackageManager::Yarn => (
221221
cross_command("yarn")
222-
.args(&["list", "--pattern"])
222+
.args(["list", "--pattern"])
223223
.arg(name)
224-
.args(&["--depth", "0"])
224+
.args(["--depth", "0"])
225225
.current_dir(app_dir)
226226
.output()?,
227227
None,
@@ -238,7 +238,7 @@ fn npm_package_version<P: AsRef<Path>>(
238238
cross_command("npm")
239239
.arg("list")
240240
.arg(name)
241-
.args(&["version", "--depth", "0"])
241+
.args(["version", "--depth", "0"])
242242
.current_dir(app_dir)
243243
.output()?,
244244
None,
@@ -247,7 +247,7 @@ fn npm_package_version<P: AsRef<Path>>(
247247
cross_command("pnpm")
248248
.arg("list")
249249
.arg(name)
250-
.args(&["--parseable", "--depth", "0"])
250+
.args(["--parseable", "--depth", "0"])
251251
.current_dir(app_dir)
252252
.output()?,
253253
None,
@@ -273,11 +273,7 @@ fn get_version(command: &str, args: &[&str]) -> crate::Result<Option<String>> {
273273
.arg("--version")
274274
.output()?;
275275
let version = if output.status.success() {
276-
Some(
277-
String::from_utf8_lossy(&output.stdout)
278-
.replace('\n', "")
279-
.replace('\r', ""),
280-
)
276+
Some(String::from_utf8_lossy(&output.stdout).replace(['\n', '\r'], ""))
281277
} else {
282278
None
283279
};
@@ -380,8 +376,7 @@ fn active_rust_toolchain() -> crate::Result<Option<String>> {
380376
let toolchain = if output.status.success() {
381377
Some(
382378
String::from_utf8_lossy(&output.stdout)
383-
.replace('\n', "")
384-
.replace('\r', "")
379+
.replace(['\n', '\r'], "")
385380
.split('(')
386381
.collect::<Vec<&str>>()[0]
387382
.into(),

tooling/cli/src/init.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub fn command(mut options: Options) -> Result<()> {
167167
let (tauri_dep, tauri_build_dep) = if let Some(tauri_path) = options.tauri_path {
168168
(
169169
format!(
170-
r#"{{ path = {:?}, features = [ "api-all" ] }}"#,
170+
r#"{{ path = {:?} }}"#,
171171
resolve_tauri_path(&tauri_path, "core/tauri")
172172
),
173173
format!(
@@ -177,10 +177,7 @@ pub fn command(mut options: Options) -> Result<()> {
177177
)
178178
} else {
179179
(
180-
format!(
181-
r#"{{ version = "{}", features = [ "api-all" ] }}"#,
182-
metadata.tauri
183-
),
180+
format!(r#"{{ version = "{}" }}"#, metadata.tauri),
184181
format!(r#"{{ version = "{}" }}"#, metadata.tauri_build),
185182
)
186183
};

tooling/cli/src/interface/rust.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ impl Rust {
476476
info!(
477477
"File {} changed. Rebuilding application...",
478478
event_path
479-
.strip_prefix(&app_path)
479+
.strip_prefix(app_path)
480480
.unwrap_or(&event_path)
481481
.display()
482482
);
@@ -626,7 +626,7 @@ impl AppSettings for RustAppSettings {
626626
.package_settings
627627
.default_run
628628
.clone()
629-
.unwrap_or_else(|| "".to_string());
629+
.unwrap_or_default();
630630
for binary in bin {
631631
binaries.push(
632632
if Some(&binary.name) == self.cargo_package_settings.name.as_ref()
@@ -759,7 +759,7 @@ impl RustAppSettings {
759759
.target()
760760
.map(|t| t.to_string())
761761
.unwrap_or_else(|| {
762-
let output = Command::new("rustc").args(&["-vV"]).output().unwrap();
762+
let output = Command::new("rustc").args(["-vV"]).output().unwrap();
763763
let stdout = String::from_utf8_lossy(&output.stdout);
764764
stdout
765765
.split('\n')

tooling/cli/src/interface/rust/desktop.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ pub fn build(
9696
}
9797

9898
if options.target == Some("universal-apple-darwin".into()) {
99-
std::fs::create_dir_all(&out_dir).with_context(|| "failed to create project out directory")?;
99+
std::fs::create_dir_all(out_dir).with_context(|| "failed to create project out directory")?;
100100

101101
let mut lipo_cmd = Command::new("lipo");
102102
lipo_cmd
103103
.arg("-create")
104104
.arg("-output")
105-
.arg(out_dir.join(&bin_name));
105+
.arg(out_dir.join(bin_name));
106106
for triple in ["aarch64-apple-darwin", "x86_64-apple-darwin"] {
107107
let mut options = options.clone();
108108
options.target.replace(triple.into());
@@ -114,7 +114,7 @@ pub fn build(
114114
build_production_app(options, available_targets, config_features.clone())
115115
.with_context(|| format!("failed to build {} binary", triple))?;
116116

117-
lipo_cmd.arg(triple_out_dir.join(&bin_name));
117+
lipo_cmd.arg(triple_out_dir.join(bin_name));
118118
}
119119

120120
let lipo_status = lipo_cmd.output_ok()?.status;
@@ -344,7 +344,7 @@ fn rename_app(bin_path: &Path, product_name: Option<&str>) -> crate::Result<Path
344344
.join(&product_name)
345345
.with_extension(bin_path.extension().unwrap_or_default());
346346

347-
rename(&bin_path, &product_path).with_context(|| {
347+
rename(bin_path, &product_path).with_context(|| {
348348
format!(
349349
"failed to rename `{}` to `{}`",
350350
bin_path.display(),

tooling/cli/src/interface/rust/manifest.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,7 @@ fn write_features(
164164
}
165165
Value::String(version) => {
166166
let mut def = InlineTable::default();
167-
def.get_or_insert(
168-
"version",
169-
version.to_string().replace('\"', "").replace(' ', ""),
170-
);
167+
def.get_or_insert("version", version.to_string().replace(['\"', ' '], ""));
171168
def.get_or_insert("features", Value::Array(toml_array(features)));
172169
*dep = Value::InlineTable(def);
173170
}

0 commit comments

Comments
 (0)