refactor(examples) cleanup, add READMEs (#331)

This commit is contained in:
Lucas Fernandes Nogueira
2020-07-12 08:43:56 -03:00
committed by GitHub
parent f112f1bd0b
commit f1ef797c92
30 changed files with 211 additions and 343 deletions

View File

@@ -100,7 +100,7 @@ jobs:
run: yarn build
- name: yarn tauri build
working-directory: ./examples/node/${{ matrix.example.folder }}
run: yarn tauri:source:build
run: yarn tauri:build
- uses: actions/upload-artifact@v1
if: success()
with:

View File

@@ -1,27 +1,31 @@
# Examples
A collection of frameworks used as a suite of smoke-tests for tauri
A collection of examples of Tauri apps using frontends written in Rust or JavaScript.
These examples are a great way to see how Tauri works with a variety of frameworks.
## How to run
Ensure that you have read the readme of the example to check that your first-time setup is done.
Uses the template project of each framework.
The examples assume by default that the main Tauri repo is in the root of your drive ( on windows c:/tauri/)
## How to run
To change an example to be self-contained:
Go to `/%example_path%/src-tauri/cargo.toml`:
and change the dependency
```toml
tauri = { path = "../../../../../tauri", features = [ "edge" ] }
Ensure that you have read the README of the example to check that your first-time setup is done.
The examples assume that this git repository was cloned in the root of the [tauri repo](https://github.com/tauri-apps/tauri) clone on your machine.
The recommended way of running the examples is using [mask](https://github.com/jakedeichert/mask):
```bash
$ cargo install mask
$ git clone https://github.com/tauri-apps/tauri
$ cd tauri
$ mask prepare
$ mask list examples # this will show all the examples names
$ mask run example some-example-name # run an example listed on the previous command
```
to
```toml
tauri = { version = "*", features = [ "edge" ] }
```
## Error reporting
Please report all library errors at https://github.com/tauri-apps/tauri
## License
Everything in this repo is MIT License unless otherwise specified.

3
node/README.md Normal file
View File

@@ -0,0 +1,3 @@
# Node.js examples
This is a list of examples of Tauri apps with frontend related to the Node.js ecosystem (NPM usage or Node.js CLIs).

View File

@@ -1,95 +1,22 @@
## Running Example
Ensure you have setup and installed all the project dependencies.
```
npm install -g tauri
git clone https://github.com/tauri-apps/tauri
cd examples/react/create-react-app
yarn
cargo install tauri-bundler
```
### Development
```
yarn start & tauri dev
```
### Production
```
yarn build
tauri build
```
# Original ReadMe
# React App
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
## Installation
In the project directory, you can run:
```
$ cargo install tauri-bundler
$ yarn
```
### `yarn start`
## Dev
Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
```
$ yarn tauri dev
```
The page will reload if you make edits.<br />
You will also see any lint errors in the console.
## Build
### `yarn test`
Launches the test runner in the interactive watch mode.<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `yarn build`
Builds the app for production to the `build` folder.<br />
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.<br />
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `yarn eject`
**Note: this is a one-way operation. Once you `eject`, you cant go back!**
If you arent satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point youre on your own.
You dont have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldnt feel obligated to use this feature. However we understand that this tool wouldnt be useful if you couldnt customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
### Analyzing the Bundle Size
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
### Making a Progressive Web App
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
### Advanced Configuration
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
### Deployment
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
### `yarn build` fails to minify
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
```
$ yarn tauri build
```

View File

@@ -14,14 +14,9 @@
"start": "craco start",
"build": "craco build",
"test": "craco test",
"tauri:prod": "tauri",
"tauri:source": "node ../../../../cli/tauri.js/bin/tauri",
"tauri:source:init": "yarn tauri:source init --tauriPath ../../../../tauri",
"tauri:prod:init": "yarn tauri:prod init",
"tauri:source:dev": "yarn tauri:source dev",
"tauri:prod:dev": "yarn tauri:prod dev",
"tauri:source:build": "yarn tauri:source build",
"tauri:prod:build": "yarn tauri:prod build"
"tauri:dev": "yarn tauri:source dev",
"tauri:build": "yarn tauri:source build"
},
"eslintConfig": {
"extends": "react-app"

View File

@@ -1,7 +1,9 @@
{
"build": {
"distDir": "../build",
"devPath": "http://localhost:3000"
"devPath": "http://localhost:3000",
"beforeDevCommand": "yarn start",
"beforeBuildCommand": "yarn build"
},
"ctx": {},
"tauri": {

View File

@@ -2,3 +2,22 @@
This is a minimal config required gatsby site created using themes. The intention is to smoke test gatsby and provide an assortment of pages to test tauri response.
This _does_ use an API key to Airtable, but we have made it optional. (Although currently gatsby is rather aggressive in compiling things out of node_modules so `gatsby-config.js` has a hack to rename files so gatsby will ignore them. [insert heavy sigh here])
## Installation
```
$ cargo install tauri-bundler
$ yarn
```
## Dev
```
$ yarn tauri dev
```
## Build
```
$ yarn tauri build
```

View File

@@ -13,14 +13,9 @@
"develop": "gatsby develop",
"dev:hard": "gatsby clean && gatsby develop",
"format": "prettier --write \"**/*.{js,jsx,json,md}\"",
"tauri:prod": "tauri",
"tauri:source": "node ../../../../cli/tauri.js/bin/tauri",
"tauri:source:init": "yarn tauri:source init --tauriPath ../../../../tauri",
"tauri:prod:init": "yarn tauri:prod init",
"tauri:source:dev": "yarn tauri:source dev",
"tauri:prod:dev": "yarn tauri:prod dev",
"tauri:source:build": "yarn tauri:source build",
"tauri:prod:build": "yarn tauri:prod build",
"tauri:dev": "yarn tauri:source dev",
"tauri:build": "yarn tauri:source build",
"test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {

View File

@@ -1,7 +1,9 @@
{
"build": {
"distDir": "../public",
"devPath": "http://localhost:8000"
"devPath": "http://localhost:8000",
"beforeDevCommand": "yarn develop",
"beforeBuildCommand": "yarn build"
},
"ctx": {},
"tauri": {

View File

@@ -1,24 +1,22 @@
## Running Example
# Next.js App
Ensure you have setup and installed all the project dependencies.
This project was bootstrapped with [Create Next App](https://github.com/vercel/create-next-app).
## Installation
```
npm install -g tauri
git clone https://github.com/tauri-apps/tauri
cd examples/react/next.js
yarn
cargo install tauri-bundler
$ cargo install tauri-bundler
$ yarn
```
### Development
## Dev
```
yarn dev & tauri dev
$ yarn tauri dev
```
### Production
## Build
```
yarn build
tauri build
$ yarn tauri build
```

View File

@@ -6,14 +6,9 @@
"dev": "next dev",
"build": "next build && next export",
"start": "next start",
"tauri:prod": "tauri",
"tauri:source": "node ../../../../cli/tauri.js/bin/tauri",
"tauri:source:init": "yarn tauri:source init --tauriPath ../../../../tauri",
"tauri:prod:init": "yarn tauri:prod init",
"tauri:source:dev": "yarn tauri:source dev",
"tauri:prod:dev": "yarn tauri:prod dev",
"tauri:source:build": "yarn tauri:source build",
"tauri:prod:build": "yarn tauri:prod build"
"tauri:dev": "yarn tauri:source dev",
"tauri:build": "yarn tauri:source build"
},
"dependencies": {
"next": "9.4.4",

View File

@@ -1,7 +1,9 @@
{
"build": {
"distDir": "../out",
"devPath": "http://localhost:3000"
"devPath": "http://localhost:3000",
"beforeDevCommand": "yarn dev",
"beforeBuildCommand": "yarn build"
},
"ctx": {},
"tauri": {

View File

@@ -1,120 +1,22 @@
## Running Example
# Svelte App
Ensure you have setup and installed all the project dependencies.
This is the default Svelte template.
## Installation
```
npm install -g tauri
git clone https://github.com/tauri-apps/tauri
cd examples/svelte/svelte-app
yarn
cargo install tauri-bundler
$ cargo install tauri-bundler
$ yarn
```
### Development
## Dev
```
yarn start & tauri dev
$ yarn tauri dev
```
### Production
## Build
```
yarn build
tauri build
```
# Original ReadMe
*Psst — looking for a shareable component template? Go here --> [sveltejs/component-template](https://github.com/sveltejs/component-template)*
---
# svelte app
This is a project template for [Svelte](https://svelte.dev) apps. It lives at https://github.com/sveltejs/template.
To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):
```bash
npx degit sveltejs/template svelte-app
cd svelte-app
```
*Note that you will need to have [Node.js](https://nodejs.org) installed.*
## Get started
Install the dependencies...
```bash
cd svelte-app
npm install
```
...then start [Rollup](https://rollupjs.org):
```bash
npm run dev
```
Navigate to [localhost:5000](http://localhost:5000). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes.
By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`.
## Building and running in production mode
To create an optimised version of the app:
```bash
npm run build
```
You can run the newly built app with `npm run start`. This uses [sirv](https://github.com/lukeed/sirv), which is included in your package.json's `dependencies` so that the app will work when you deploy to platforms like [Heroku](https://heroku.com).
## Single-page app mode
By default, sirv will only respond to requests that match files in `public`. This is to maximise compatibility with static fileservers, allowing you to deploy your app anywhere.
If you're building a single-page app (SPA) with multiple routes, sirv needs to be able to respond to requests for *any* path. You can make it so by editing the `"start"` command in package.json:
```js
"start": "sirv public --single"
```
## Deploying to the web
### With [now](https://zeit.co/now)
Install `now` if you haven't already:
```bash
npm install -g now
```
Then, from within your project folder:
```bash
cd public
now deploy --name my-project
```
As an alternative, use the [Now desktop client](https://zeit.co/download) and simply drag the unzipped project folder to the taskbar icon.
### With [surge](https://surge.sh/)
Install `surge` if you haven't already:
```bash
npm install -g surge
```
Then, from within your project folder:
```bash
npm run build
surge public my-project.surge.sh
$ yarn tauri build
```

View File

@@ -7,14 +7,9 @@
"dev": "rollup -c -w",
"build": "rollup -c",
"test": "echo \"No test specified\" && exit 0",
"tauri:prod": "tauri",
"tauri:source": "node ../../../../cli/tauri.js/bin/tauri",
"tauri:source:init": "yarn tauri:source init --tauriPath ../../../../tauri",
"tauri:prod:init": "yarn tauri:prod init",
"tauri:source:dev": "yarn tauri:source dev",
"tauri:prod:dev": "yarn tauri:prod dev",
"tauri:source:build": "yarn tauri:source build",
"tauri:prod:build": "yarn tauri:prod build"
"tauri:dev": "yarn tauri:source dev",
"tauri:build": "yarn tauri:source build"
},
"devDependencies": {
"@babel/core": "7.10.4",

View File

@@ -1,7 +1,9 @@
{
"build": {
"distDir": "../public",
"devPath": "http://localhost:5000"
"devPath": "http://localhost:5000",
"beforeDevCommand": "yarn dev",
"beforeBuildCommand": "yarn build"
},
"ctx": {},
"tauri": {

View File

@@ -0,0 +1,22 @@
# Monolith Vanilla JavaScript App
A Tauri app that uses Vanilla JavaScript with a monolith index.html.
## Installation
```
$ cargo install tauri-bundler
$ yarn
```
## Dev
```
$ yarn tauri dev
```
## Build
```
$ yarn tauri build
```

View File

@@ -7,14 +7,9 @@
"test": "echo \"Error: no test specified\" && exit 1",
"build": "echo \"No build is necessary for Vanillajs, skipping.\"",
"html:dev": "quasar serve ./dist",
"tauri:prod": "tauri",
"tauri:source": "node ../../../../cli/tauri.js/bin/tauri",
"tauri:source:init": "yarn tauri:source init --tauriPath ../../../../tauri",
"tauri:prod:init": "yarn tauri:prod init",
"tauri:source:dev": "yarn tauri:source dev",
"tauri:prod:dev": "yarn tauri:prod dev",
"tauri:source:build": "yarn tauri:source build",
"tauri:prod:build": "yarn tauri:prod build"
"tauri:dev": "yarn tauri:source dev",
"tauri:build": "yarn tauri:source build"
},
"author": "",
"license": "MIT",

View File

@@ -1,22 +1,22 @@
# nuxt-app
# Nuxt App
> My good Nuxt.js project
This project was bootstrapped with [create-nuxt-app](https://github.com/nuxt/create-nuxt-app/).
## Build Setup
## Installation
``` bash
# install dependencies
$ yarn install
# serve with hot reload at localhost:3000
$ yarn dev
# build for production and launch server
$ yarn build
$ yarn start
# generate static project
$ yarn generate
```
$ cargo install tauri-bundler
$ yarn
```
For detailed explanation on how things work, check out [Nuxt.js docs](https://nuxtjs.org).
## Dev
```
$ yarn tauri dev
```
## Build
```
$ yarn tauri build
```

View File

@@ -9,14 +9,9 @@
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"tauri:prod": "tauri",
"tauri:source": "node ../../../../cli/tauri.js/bin/tauri",
"tauri:source:init": "yarn tauri:source init --tauriPath ../../../../tauri",
"tauri:prod:init": "yarn tauri:prod init",
"tauri:source:dev": "yarn tauri:source dev",
"tauri:prod:dev": "yarn tauri:prod dev",
"tauri:source:build": "yarn tauri:source build",
"tauri:prod:build": "yarn tauri:prod build"
"tauri:dev": "yarn tauri:source dev",
"tauri:build": "yarn tauri:source build"
},
"dependencies": {
"nuxt": "2.13.3"

View File

@@ -1,7 +1,9 @@
{
"build": {
"distDir": "../dist",
"devPath": "http://localhost:4000"
"devPath": "http://localhost:4000",
"beforeDevCommand": "yarn start",
"beforeBuildCommand": "yarn build"
},
"ctx": {},
"tauri": {
@@ -30,4 +32,4 @@
"active": false
}
}
}
}

View File

@@ -1,26 +1,22 @@
# Quasar App (quasar-app)
# Quasar App
A Quasar Framework app
This project was bootstrapped with [Quasar CLI](https://github.com/quasarframework/quasar/).
## Install the dependencies
```bash
yarn
## Installation
```
$ cargo install tauri-bundler
$ yarn
```
### Start the app in development mode (hot-code reloading, error reporting, etc.)
```bash
quasar dev
## Dev
```
$ yarn tauri dev
```
### Lint the files
```bash
yarn run lint
```
## Build
### Build the app for production
```bash
quasar build
```
### Customize the configuration
See [Configuring quasar.conf.js](https://quasar.dev/quasar-cli/quasar-conf-js).
$ yarn tauri build
```

View File

@@ -9,14 +9,9 @@
"lint": "eslint --ext .js,.vue src",
"test": "echo \"No test specified\" && exit 0",
"build": "quasar build",
"tauri:prod": "tauri",
"tauri:source": "node ../../../../cli/tauri.js/bin/tauri",
"tauri:source:init": "yarn tauri:source init --tauriPath ../../../../tauri",
"tauri:prod:init": "yarn tauri:prod init",
"tauri:source:dev": "yarn tauri:source dev",
"tauri:prod:dev": "yarn tauri:prod dev",
"tauri:source:build": "yarn tauri:source build",
"tauri:prod:build": "yarn tauri:prod build"
"tauri:dev": "yarn tauri:source dev",
"tauri:build": "yarn tauri:source build"
},
"dependencies": {
"@quasar/extras": "1.8.2",

View File

@@ -1,7 +1,9 @@
{
"build": {
"distDir": "../dist/spa",
"devPath": "http://localhost:7334"
"devPath": "http://localhost:7334",
"beforeDevCommand": "quasar dev",
"beforeBuildCommand": "quasar build"
},
"ctx": {},
"tauri": {
@@ -10,10 +12,10 @@
},
"bundle": {
"active": true,
"identifier": "com.tauri.dev",
"icon": ["icons/32x32.png", "icons/128x128.png", "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico"],
"resources": ["resources"],
"targets": ["deb", "osx", "msi", "appimage"]
"identifier": "com.tauri.dev",
"icon": ["icons/32x32.png", "icons/128x128.png", "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico"],
"resources": ["resources"],
"targets": ["deb", "osx", "msi", "appimage"]
},
"whitelist": {
"all": true

View File

@@ -1,24 +1,22 @@
# vue-cli-app
# Vue CLI App
This project was bootstrapped with [Vue CLI](https://cli.vuejs.org/).
## Installation
## Project setup
```
yarn install
$ cargo install tauri-bundler
$ yarn
```
### Compiles and hot-reloads for development
## Dev
```
yarn serve
$ yarn tauri:serve
```
### Compiles and minifies for production
```
yarn build
```
## Build
### Lints and fixes files
```
yarn lint
$ yarn tauri:build
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

View File

@@ -7,7 +7,7 @@
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"tauri:build": "vue-cli-service tauri:build",
"tauri:serve": "vue-cli-service tauri:serve"
"tauri:dev": "vue-cli-service tauri:serve"
},
"dependencies": {
"core-js": "3.6.5",

3
rust/README.md Normal file
View File

@@ -0,0 +1,3 @@
# Rust examples
This is a list of examples of Tauri apps with frontend written in Rust.

View File

@@ -1,9 +1,8 @@
[tasks.install]
script = [
"cargo install cargo-web",
"cargo install cargo-web --force",
"yarn install",
"yarn add tauri",
"cargo install tauri-bundler"
"cargo install tauri-bundler --force"
]
[tasks.build-todomvc]

3
tauri/README.md Normal file
View File

@@ -0,0 +1,3 @@
# Tauri examples
This is a list of examples of the Tauri API usage.

View File

@@ -0,0 +1,22 @@
# Communication example
Demonstrates how to communicate between the backend and the frontend.
## Installation
```
$ cargo install tauri-bundler
$ yarn
```
## Dev
```
$ yarn tauri dev
```
## Build
```
$ yarn tauri build
```

View File

@@ -7,14 +7,9 @@
"clean": "bsb -clean-world",
"server": "moduleserve ./ --port 8000",
"bundle": "webpack --config webpack.config.js",
"tauri:prod": "tauri",
"tauri:source": "node ../../../../cli/tauri.js/bin/tauri",
"tauri:source:init": "yarn tauri:source init --tauriPath ../../../../tauri",
"tauri:prod:init": "yarn tauri:prod init",
"tauri:source:dev": "yarn tauri:source dev",
"tauri:prod:dev": "yarn tauri:prod dev",
"tauri:source:build": "yarn tauri:source build",
"tauri:prod:build": "yarn tauri:prod build"
"tauri:dev": "yarn tauri:source dev",
"tauri:build": "yarn tauri:source build"
},
"keywords": [
"BuckleScript",
@@ -36,4 +31,4 @@
"webpack": "^4.42.0",
"webpack-cli": "^3.3.11"
}
}
}