Преглед изворни кода

chore(cli.rs): some plugin template fixes

Lucas Nogueira пре 3 година
родитељ
комит
a0bea432b4

+ 8 - 2
tooling/cli.rs/src/init.rs

@@ -101,8 +101,14 @@ impl Init {
         )
       } else {
         (
-          format!(r#"{{ version = "{}" }}"#, metadata.tauri),
-          format!(r#"{{ version = "{}" }}"#, metadata.tauri_build),
+          format!(
+            r#"{{ version = "{}", features = [ "api-all" ] }}"#,
+            metadata.tauri
+          ),
+          format!(
+            r#"{{ version = "{}", features = [ "api-all" ] }}"#,
+            metadata.tauri_build
+          ),
         )
       };
 

+ 8 - 2
tooling/cli.rs/src/plugin.rs

@@ -85,8 +85,14 @@ impl Plugin {
         )
       } else {
         (
-          format!(r#"{{ version = "{}" }}"#, metadata.tauri),
-          format!(r#"{{ version = "{}" }}"#, metadata.tauri_build),
+          format!(
+            r#"{{ version = "{}", features = [ "api-all" ] }}"#,
+            metadata.tauri
+          ),
+          format!(
+            r#"{{ version = "{}", features = [ "api-all" ] }}"#,
+            metadata.tauri_build
+          ),
         )
       };
 

+ 5 - 0
tooling/cli.rs/templates/plugin/backend/.changes/initial-release.md

@@ -0,0 +1,5 @@
+---
+"tauri-plugin-{{ plugin_name }}": "minor"
+---
+
+Initial release.

+ 2 - 1
tooling/cli.rs/templates/plugin/backend/Cargo.crate-manifest

@@ -1,9 +1,10 @@
 [package]
 name = "tauri-plugin-{{ plugin_name }}"
-version = "0.1.0"
+version = "0.0.0"
 authors = [ "You" ]
 description = ""
 edition = "2018"
+exclude = ["/examples"]
 
 [dependencies]
 tauri = {{{  tauri_dep  }}}

+ 5 - 0
tooling/cli.rs/templates/plugin/with-api/.changes/initial-release.md

@@ -0,0 +1,5 @@
+---
+"tauri-plugin-{{ plugin_name }}": "minor"
+---
+
+Initial release.

+ 0 - 1
tooling/cli.rs/templates/plugin/with-api/examples/svelte-app/src-tauri/src/main.rs

@@ -3,7 +3,6 @@
   windows_subsystem = "windows"
 )]
 
-
 fn main() {
   tauri::Builder::default()
     .plugin(tauri_plugin_{{ plugin_name_snake_case }}::YourPlugin::default())

+ 2 - 1
tooling/cli.rs/templates/plugin/with-api/examples/svelte-app/src/App.svelte

@@ -4,7 +4,7 @@
 	let response = ''
 
 	function updateResponse(returnValue) {
-		response += (typeof returnValue === 'string' ? returnValue : JSON.stringify(returnValue)) + '<br>'
+		response += `[${new Date().toLocaleTimeString()}]` + (typeof returnValue === 'string' ? returnValue : JSON.stringify(returnValue)) + '<br>'
 	}
 
 	function _execute() {
@@ -14,4 +14,5 @@
 
 <div>
 	<button on:click="{_execute}">Execute</button>
+	<div>{@html response}</div>
 </div>

+ 1 - 3
tooling/cli.rs/templates/plugin/with-api/src/lib.rs

@@ -17,9 +17,7 @@ impl Serialize for Error {
   where
     S: Serializer,
   {
-    match self {
-      Self::Io(error) => serializer.serialize_str(error.to_string().as_ref()),
-    }
+    serializer.serialize_str(self.to_string().as_ref())
   }
 }