Browse Source

fix(examples): build error (#1354)

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Noah Klayman 4 years ago
parent
commit
4c9d419eec

+ 3 - 3
.github/CONTRIBUTING.md

@@ -69,7 +69,7 @@ Tauri.js is a CLI tool that houses the `init`, `info`, `icon`, and `deps` comman
 - `lint` runs ESLint to catch linting errors
 - `format` formats code with Prettier to match the style guide
 
-To test your changes, we recommend using the API example app, located in `[Tauri repo root]/tauri/examples/api`. Run `yarn install` to install deps, and then `yarn tauri [COMMAND]` to run a command using your local Tauri.js copy. You will need to rebuild Tauri.js after every change by running `yarn build` in the Tauri.js directory.
+To test your changes, we recommend using the helloworld example app, located in `[Tauri repo root]/examples/helloworld`. Run `yarn tauri [COMMAND]` to run a command using your local Tauri.js copy. You will need to rebuild Tauri.js after every change by running `yarn build` in the Tauri.js directory.
 
 If you want to use your local copy of Tauri.js in another app, we recommend using [Yarn link](https://classic.yarnpkg.com/en/docs/cli/link/). First, make sure you have don't have Tauri.js installed globally by running `npm uninstall -g tauri && yarn global remove tauri`. Then, run `yarn link` in the Tauri.js directory (note that the setup script will do this for you, so you can skip this step if you ran that). Now, you can just run `tauri [COMMAND]` anywhere, and your local copy will be used.
 
@@ -79,11 +79,11 @@ The code for the bundler is located in `[Tauri repo root]/cli/tauri-bundler`, an
 
 ### Developing Tauri Core and Related Components (Rust API, Macros, and Utils)
 
-The code for Tauri Core is located in `[Tauri repo root]/tauri`, and the Rust API, Macros, and Utils are in `[Tauri repo root]/tauri-(api/macros/utils)`. The easiest way to test your changes is to use the `[Tauri repo root]/tauri/examples/helloworld` app. It automatically rebuilds and uses your local copy of the Tauri core packages. Just run `yarn tauri build` or `yarn tauri dev` in the helloworld app directory after making changes to test them out. To use your local changes in another project, edit its `src-tauri/Cargo.toml` file so that the `tauri` key looks like `tauri = { path = "PATH", features = [ "api-all", "cli" ] }`, where `PATH` is the relative path to `[Tauri repo root]/tauri`. Then, your local copy of the Tauri core packages will be rebuilt and used whenever you build that project.
+The code for Tauri Core is located in `[Tauri repo root]/tauri`, and the Rust API, Macros, and Utils are in `[Tauri repo root]/tauri-(api/macros/utils)`. The easiest way to test your changes is to use the `[Tauri repo root]/examples/helloworld` app. It automatically rebuilds and uses your local copy of the Tauri core packages. Just run `yarn tauri build` or `yarn tauri dev` in the helloworld app directory after making changes to test them out. To use your local changes in another project, edit its `src-tauri/Cargo.toml` file so that the `tauri` key looks like `tauri = { path = "PATH", features = [ "api-all", "cli" ] }`, where `PATH` is the relative path to `[Tauri repo root]/tauri`. Then, your local copy of the Tauri core packages will be rebuilt and used whenever you build that project.
 
 ### Developing the JS API
 
-The JS API provides bindings between the developer's JS in the Webview and the builtin Tauri APIs, written in Rust. Its code is located in `[Tauri repo root]/api`. After making changes to the code, run `yarn build` to build it. To test your changes, we recommend using the API example app, located in `[Tauri repo root]/tauri/examples/api`. It will automatically use your local copy of the JS API and provides a helpful UI to test the various commands.
+The JS API provides bindings between the developer's JS in the Webview and the builtin Tauri APIs, written in Rust. Its code is located in `[Tauri repo root]/api`. After making changes to the code, run `yarn build` to build it. To test your changes, we recommend using the API example app, located in `[Tauri repo root]/examples/api`. It will automatically use your local copy of the JS API and provides a helpful UI to test the various commands.
 
 ## Financial Contribution
 

+ 4 - 0
.github/workflows/core-lint-fmt.yml

@@ -4,9 +4,13 @@ on:
   pull_request:
     paths:
       - '.github/workflows/core-lint-fmt.yml'
+      - 'core/**'
+      - 'examples/**'
       - 'tauri/**'
       - 'tauri-utils/**'
       - 'tauri-api/**'
+      - 'tauri-macros/**'
+      - 'tauri-updater/**'
       - 'cli/core/**'
 
 jobs:

+ 6 - 2
.github/workflows/test-core.yml

@@ -4,10 +4,14 @@ on:
   pull_request:
     paths:
       - '.github/workflows/test-core.yml'
-      - 'cli/**'
+      - 'core/**'
+      - 'examples/**'
       - 'tauri/**'
-      - 'tauri-api/**'
       - 'tauri-utils/**'
+      - 'tauri-api/**'
+      - 'tauri-macros/**'
+      - 'tauri-updater/**'
+      - 'cli/**'
 
 env:
   RUST_BACKTRACE: 1

+ 6 - 3
.github/workflows/udeps.yml

@@ -4,11 +4,14 @@ on:
   pull_request:
     paths:
       - '.github/workflows/udeps.yml'
-      - 'cli/tauri-bundler/**'
-      - 'cli/core/**'
+      - 'core/**'
       - 'tauri/**'
-      - 'tauri-api/**'
       - 'tauri-utils/**'
+      - 'tauri-api/**'
+      - 'tauri-macros/**'
+      - 'tauri-updater/**'
+      - 'cli/tauri-bundler/**'
+      - 'cli/core/**'
 
 jobs:
   udeps:

+ 3 - 3
cli/tauri.js/templates/src-tauri/src/main.rs

@@ -4,7 +4,7 @@
 )]
 
 fn main() {
-  let context = tauri::generate_tauri_context!();
-
-  tauri::AppBuilder::default().build(context).run();
+  tauri::AppBuilder::default()
+    .build(tauri::generate_context!())
+    .run();
 }

+ 1 - 3
cli/tauri.js/test/jest/fixtures/app/src-tauri/src/main.rs

@@ -1,8 +1,6 @@
 use tauri::ApplicationDispatcherExt;
 
 fn main() {
-  let context = tauri::generate_tauri_context!();
-
   tauri::AppBuilder::default()
     .setup(|webview_manager| async move {
       let mut webview_manager_ = webview_manager.clone();
@@ -23,6 +21,6 @@ fn main() {
         webview_manager.close().unwrap();
       }
     })
-    .build(context)
+    .build(tauri::generate_context!())
     .run();
 }

+ 1 - 3
examples/api/src-tauri/src/main.rs

@@ -13,8 +13,6 @@ struct Reply {
 }
 
 fn main() {
-  let context = tauri::generate_tauri_context!();
-
   tauri::AppBuilder::default()
     .setup(|webview_manager| async move {
       let dispatcher = webview_manager.current_webview().unwrap();
@@ -34,6 +32,6 @@ fn main() {
       cmd::log_operation,
       cmd::perform_request
     ])
-    .build(context)
+    .build(tauri::generate_context!())
     .run();
 }

+ 1 - 1
examples/helloworld/package.json

@@ -2,6 +2,6 @@
   "name": "hello-world",
   "version": "1.0.0",
   "scripts": {
-    "tauri": "node ../../../cli/tauri.js/bin/tauri"
+    "tauri": "node ../../cli/tauri.js/bin/tauri"
   }
 }

+ 0 - 1
examples/helloworld/src-tauri/build.rs

@@ -1,4 +1,3 @@
 fn main() {
-  tauri_build::CodegenContext::default().build();
   tauri_build::build();
 }

+ 1 - 3
examples/helloworld/src-tauri/src/main.rs

@@ -9,10 +9,8 @@ fn my_custom_command(argument: String) {
 }
 
 fn main() {
-  let context = tauri::generate_tauri_context!();
-
   tauri::AppBuilder::default()
     .invoke_handler(tauri::generate_handler![my_custom_command])
-    .build(context)
+    .build(tauri::generate_context!())
     .run();
 }

+ 1 - 1
examples/multiwindow/package.json

@@ -5,7 +5,7 @@
   "main": "index.js",
   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1",
-    "build": "node ../../../cli/tauri.js/bin/tauri build"
+    "tauri": "node ../../cli/tauri.js/bin/tauri"
   },
   "private": true
 }

+ 1 - 1
examples/multiwindow/src-tauri/Cargo.toml

@@ -5,7 +5,7 @@ description = "An example Tauri Multi-Window Application"
 edition = "2018"
 
 [build-dependencies]
-tauri-build = { path = "../../../core/tauri-build", features = ["codegen"] }
+tauri-build = { path = "../../../core/tauri-build" }
 
 [dependencies]
 tauri = { path = "../../../tauri", features =["api-all"]}

+ 0 - 1
examples/multiwindow/src-tauri/build.rs

@@ -1,4 +1,3 @@
 fn main() {
-  tauri_build::CodegenContext::default().build();
   tauri_build::build();
 }

+ 1 - 3
examples/multiwindow/src-tauri/src/main.rs

@@ -6,8 +6,6 @@
 use tauri::WebviewBuilderExt;
 
 fn main() {
-  let context = tauri::tauri_build_context!();
-
   tauri::AppBuilder::default()
     .setup(|webview_manager| async move {
       if webview_manager.current_window_label() == "Main" {
@@ -26,6 +24,6 @@ fn main() {
       Ok(builder)
     })
     .unwrap()
-    .build(context)
+    .build(tauri::generate_context!())
     .run();
 }

+ 1 - 1
tauri-macros/src/context/mod.rs

@@ -55,7 +55,7 @@ macro_rules! parse_config_path {
   }
 }
 
-pub(crate) fn generate_tauri_context(path: PathBuf) -> TokenStream {
+pub(crate) fn generate_context(path: PathBuf) -> TokenStream {
   let context = get_config(&path)
     .map_err(|e| e.to_string())
     .map(|(config, config_parent)| ContextData {

+ 2 - 2
tauri-macros/src/lib.rs

@@ -34,8 +34,8 @@ pub fn generate_handler(item: TokenStream) -> TokenStream {
 ///
 /// todo: link the [`AsTauriContext`] docs
 #[proc_macro]
-pub fn generate_tauri_context(item: TokenStream) -> TokenStream {
+pub fn generate_context(item: TokenStream) -> TokenStream {
   // this macro is exported from the context module
   let path = parse_config_path!(item);
-  context::generate_tauri_context(path).into()
+  context::generate_context(path).into()
 }

+ 2 - 2
tauri/src/app/utils.rs

@@ -363,11 +363,11 @@ async fn on_message<A: ApplicationExt + 'static>(
 
 #[cfg(test)]
 mod test {
-  use crate::{generate_tauri_context, Context};
+  use crate::{generate_context, Context};
 
   #[test]
   fn check_get_url() {
-    let context = generate_tauri_context!("test/fixture/src-tauri/tauri.conf.json");
+    let context = generate_context!("test/fixture/src-tauri/tauri.conf.json");
     let context = Context::new(context);
     let res = super::get_url(&context);
     #[cfg(custom_protocol)]