tauri-docs icon indicating copy to clipboard operation
tauri-docs copied to clipboard

[docs] Unprepared to answer tauri init questions

Open bronson opened this issue 5 years ago • 13 comments

While reading your setup docs, I feel unprepared for the questions tauri init asks.

I wanted to play around with Tauri so I went to set up a new app. Had smooth sailing until "Initialize Tauri in Your App" on https://tauri.studio/en/docs/development/integration

I'm told to run yarn tauri init. Sounds sensible.

It asks Where are your web assets (HTML/CSS/JS) located, relative to the "<current dir>/src-tauri" folder that will be created?

Huh? I don't have any assets. Why won't it accept a blank answer? Fine, let's try asdf. Seems to be acceptable.

Then it asks What is the url of your dev server?

Again, huh? I don't have a dev server. Tauri is supposed to create apps isn't it? I suppose https://127.0.0.1 seems safe.

Then Do you want to install @tauri-apps/api?

No idea. What sort of an API are we talking about? This time I can just hit return. But what did I just do?

And it finishes.

It seems unlikely my guesses are correct. I'd appreciate it if the docs provided some guidance on how to answer these questions.

image

bronson avatar May 02 '21 04:05 bronson

Hey there @bronson , thanks for your feedback! Seems like you are creating an app from scratch, while this guide assumes you already have a web source code. We're currently working on a scaffolding project: create-tauri-app, that directly addresses your problem. We'll provide a guide as well when it's ready. :D You may track this issue, which is pretty much the same problematic.

Laegel avatar May 02 '21 12:05 Laegel

@bronson your questions are REALLY valid. Thankyou for bringing it to our attention. One thing that we hope, is that as we polish off this release candidate, such inconsistencies in the developer experience fade to the edges. Maybe one thing to do here may be to hook the create-tauri-app directly from the init entry point. @jbolda - what do you think?

nothingismagick avatar May 02 '21 14:05 nothingismagick

@nothingismagick I'm not quite certain what you mean. If I'm understanding correctly, we do that already and set these specific values for each framework.

jbolda avatar May 02 '21 15:05 jbolda

No, I am suggesting we offer to hook out to CTA here:

https://github.com/tauri-apps/tauri/blob/dev/tooling/cli.rs/src/init.rs

nothingismagick avatar May 02 '21 15:05 nothingismagick

Not sure to understand either: isn't create-tauri-app supposed to run init once everything is scaffolded?

Laegel avatar May 02 '21 16:05 Laegel

Other way around. Let's ask them on init if they want to create first.

nothingismagick avatar May 02 '21 16:05 nothingismagick

Oh interesting. We can always open with the description of what init is expecting to have in place and what it will do / ask. In there we can mention CTA as an alternative if they are just interested in kicking the tires. 👍 I like the idea. We can do the reverse in CTA. I need to link out to setup steps and such for people using it for the first time anyways.

jbolda avatar May 04 '21 14:05 jbolda

I have had the same Huh?s as @bronson.

I think it would be useful for newbies like me to give some sample answers in the guide for the main frameworks. I have used Svelte and my answers have been these (it seems correct):

Where are your web assets (HTML/CSS/JS) located, relative to the "<current dir>/src-tauri" folder that will be created?: ../public
What is the url of your dev server?: http://localhost:50540
[NPM]: "Do you want to install @tauri-apps/api?" y

onaxon avatar May 21 '21 11:05 onaxon

Also the output example in the guide looks like it is not from Beta version but an older version. This is the output that has been produced on my system:

> [email protected] tauri
> tauri "info"

 app:spawn Running "/Users/pmd/CodeHD/Other/Learn/Tauri/lab1/node_modules/@tauri-apps/cli/bin/tauri-cli tauri info" +0ms


Operating System - Mac OS, version 10.15.6 X64

Node.js environment
  Node.js - 16.0.0
  @tauri-apps/cli - 1.0.0-beta.1 (outdated, latest: 1.0.0-beta.2)
  @tauri-apps/api - 1.0.0-beta.1

Global packages
  npm - 7.5.2
  yarn - 1.13.0

Rust environment
  rustc - 1.52.1
  cargo - 1.52.0

App directory structure
/node_modules
/public
/scripts
/src-tauri
/src

App
  tauri.rs - 1.0.0-beta.1
build-type - bundle
CSP - default-src blob: data: filesystem: ws: http: https: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
distDir - ../public
devPath - http://localhost:50540
framework - Svelte
bundler - Rollup

onaxon avatar May 21 '21 11:05 onaxon

Tauri works with several frameworks. The thing that had been the most confusing to me is that the documentation to "create a tauri app" is essentially, create a new , go into its directory, then run the steps. This didn't become apparent to me until i stumbled upon a "tauri-react" package.

i.e.

npx create-react-app <myapp>

cd <myapp>

tauri init

then things make sense (except for the api question :)

Autodetect would be nice, but it's much more apparent what's going on now that i know i can just create an empty app and "convert" it to a tauri app.

jonmadison avatar Jun 07 '21 21:06 jonmadison

I am new to tauri and "tauri init" process confusing for me too.

Where are your web assets (HTML/CSS/JS) located, relative to the "<current dir>/src-tauri" folder that will be created?: there aren't any... I have nothing yet. just created a tauri project. what should I do?

What is the url of your dev server?: should it include port or not? or includes http at the start? http://127.0.0.1, http://127.0.0.1:5000, etc..

as a result unable to make it work yet. :/ 2021-07-24 22-44-33 ekran görüntüsü

WAIT: figured it out from this talk.

I created a folder at top level named "dist" and put an "index.html" in it.

and;

# src-tauri/tauri.conf.json

...
  "build": {
    "distDir": "../dist",
    "devPath": "../dist",
    "beforeDevCommand": "",
    "beforeBuildCommand": ""
  },
...

I think you should ask for "path" instead of "url". and "dev server" for what? thank you.

ulvido avatar Jul 24 '21 20:07 ulvido

I am new to tauri and "tauri init" process confusing for me too.

Where are your web assets (HTML/CSS/JS) located, relative to the "<current dir>/src-tauri" folder that will be created?: there aren't any... I have nothing yet. just created a tauri project. what should I do?

What is the url of your dev server?: should it include port or not? or includes http at the start? http://127.0.0.1, http://127.0.0.1:5000, etc..

as a result unable to make it work yet. :/ 2021-07-24 22-44-33 ekran görüntüsü

WAIT: figured it out from this talk.

I created a folder at top level named "dist" and put an "index.html" in it.

and;

src-tauri/tauri.conf.json

...
  "build": {
    "distDir": "../dist",
    "devPath": "../dist",
    "beforeDevCommand": "",
    "beforeBuildCommand": ""
  },
...

I think you should ask for "path" instead of "url". and "dev server" for what? thank you.

I second this, the use of "path" vs "url" makes more sense in this context. While it is technically a URL, it can be confusing to some.

MrManiacc avatar Jul 25 '21 19:07 MrManiacc

Closing this out with the recent updates we've had to our guides https://tauri.app/v1/guides/getting-started/setup/html-css-js

lorenzolewis avatar Jun 19 '22 15:06 lorenzolewis