Skip to content

Commit

Permalink
change to use templates
Browse files Browse the repository at this point in the history
  • Loading branch information
kaplanelad committed Jun 4, 2024
1 parent ed2e49d commit 8c4fa04
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 60 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#### Loco is strongly inspired by Rails. If you know Rails and Rust, you'll feel at home. If you only know Rails and new to Rust, you'll find Loco refreshing. We do not assume you know Rails.

## Quick Start
<!-- <snip id="quick-installation-command" inject_from="yaml"> -->
<!-- <snip id="quick-installation-command" inject_from="yaml" template="sh"> -->
```sh
cargo install loco-cli
cargo install sea-orm-cli # Only when DB is needed
Expand All @@ -30,7 +30,7 @@ cargo install sea-orm-cli # Only when DB is needed

Now you can create your new app (choose "`SaaS` app").

<!-- <snip id="loco-cli-new-from-template" inject_from="yaml"> -->
<!-- <snip id="loco-cli-new-from-template" inject_from="yaml" template="sh"> -->
```sh
❯ loco new
✔ ❯ App name? · myapp
Expand All @@ -44,21 +44,19 @@ myapp

To configure a database , please run a local postgres database with loco:loco and a db named [insert app]_development.
<!-- <snip id="postgres-run-docker-command" inject_from="yaml"> -->
```sh
docker run -d -p 5432:5432 \
-e POSTGRES_USER=loco \
-e POSTGRES_DB=myapp_development \
-e POSTGRES_PASSWORD="loco" \
postgres:15.3-alpine
```
<!-- </snip> -->


A more advanced set of `docker-compose.yml` and `Dockerfiles` that include Redis and the `mailtutan` mailer are available for [each starter on GitHub](https://github.com/loco-rs/loco/blob/master/starters/saas/.devcontainer/docker-compose.yml).

Now `cd` into your `myapp` and start your app:

<!-- <snip id="starting-the-server-command-with-output" inject_from="yaml"> -->
<!-- <snip id="starting-the-server-command-with-output" inject_from="yaml" template="sh"> -->
```sh
$ cargo loco start

Expand Down
6 changes: 3 additions & 3 deletions docs-site/content/docs/getting-started/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ flair =[]

Create your starter app:

<!-- <snip id="loco-cli-new-from-template" inject_from="yaml"> -->
<!-- <snip id="loco-cli-new-from-template" inject_from="yaml" template="sh"> -->
```sh
❯ loco new
✔ ❯ App name? · myapp
Expand All @@ -29,7 +29,7 @@ myapp

Now `cd` into your app, set up a convenience `rr` alias and try out the various commands:

<!-- <snip id="help-command" inject_from="yaml"> -->
<!-- <snip id="help-command" inject_from="yaml" template="sh"> -->
```sh
cargo loco --help
```
Expand Down Expand Up @@ -80,7 +80,7 @@ $ cargo test

To run you app, run:

<!-- <snip id="starting-the-server-command" inject_from="yaml"> -->
<!-- <snip id="starting-the-server-command" inject_from="yaml" template="sh"> -->
```sh
cargo loco start
```
Expand Down
2 changes: 1 addition & 1 deletion docs-site/content/docs/getting-started/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ config/
```

To run the application using the 'qa' environment, execute the following command:
<!-- <snip id="starting-the-server-command-with-environment-env-var" inject_from="yaml"> -->
<!-- <snip id="starting-the-server-command-with-environment-env-var" inject_from="yaml" template="sh"> -->
```sh
LOCO_ENV=qa cargo loco start
```
Expand Down
4 changes: 2 additions & 2 deletions docs-site/content/docs/getting-started/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Deployment is super simple in Loco, and this is why this guide is super short. A

To deploy, build your production binary for your relevant server architecture:

<!-- <snip id="build-command" inject_from="yaml"> -->
<!-- <snip id="build-command" inject_from="yaml" template="sh"> -->
```sh
cargo build --release
```
Expand Down Expand Up @@ -142,7 +142,7 @@ auth:
Loco offers a deployment template enabling the creation of a deployment infrastructure.
<!-- <snip id="generate-deployment-command" inject_from="yaml"> -->
<!-- <snip id="generate-deployment-command" inject_from="yaml" template="sh"> -->
```sh
cargo loco generate deployment
? ❯ Choose your deployment ›
Expand Down
18 changes: 9 additions & 9 deletions docs-site/content/docs/getting-started/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ You can follow this guide for a step-by-step "bottom up" learning, or you can ju

### Installing

<!-- <snip id="quick-installation-command" inject_from="yaml"> -->
<!-- <snip id="quick-installation-command" inject_from="yaml" template="sh"> -->
```sh
cargo install loco-cli
cargo install sea-orm-cli # Only when DB is needed
Expand All @@ -55,7 +55,7 @@ cargo install sea-orm-cli # Only when DB is needed

Now you can create your new app (choose "SaaS app" for built-in authentication).

<!-- <snip id="loco-cli-new-from-template" inject_from="yaml"> -->
<!-- <snip id="loco-cli-new-from-template" inject_from="yaml" template="sh"> -->
```sh
❯ loco new
✔ ❯ App name? · myapp
Expand Down Expand Up @@ -84,7 +84,7 @@ To configure a database, please run a local postgres database with <code>loco:lo

This docker command start up postgresql database server.

<!-- <snip id="postgres-run-docker-command" inject_from="yaml"> -->
<!-- <snip id="postgres-run-docker-command" inject_from="yaml" template="sh"> -->
```sh
docker run -d -p 5432:5432 \
-e POSTGRES_USER=loco \
Expand All @@ -102,7 +102,7 @@ docker run -p 6379:6379 -d redis redis-server

Use doctor command to check the needed resources:

<!-- <snip id="doctor-command" inject_from="yaml"> -->
<!-- <snip id="doctor-command" inject_from="yaml template="sh"> -->
```sh
$ cargo loco doctor
Finished dev [unoptimized + debuginfo] target(s) in 0.32s
Expand Down Expand Up @@ -138,7 +138,7 @@ Let's get some responses quickly. For this, we need to start up the server.

### Starting the server

<!-- <snip id="starting-the-server-command" inject_from="yaml"> -->
<!-- <snip id="starting-the-server-command" inject_from="yaml" template="sh"> -->
```sh
cargo loco start
```
Expand Down Expand Up @@ -202,7 +202,7 @@ pub fn routes() -> Routes {

Start the server:

<!-- <snip id="starting-the-server-command" inject_from="yaml"> -->
<!-- <snip id="starting-the-server-command" inject_from="yaml" template="sh"> -->
```sh
cargo loco start
```
Expand Down Expand Up @@ -275,7 +275,7 @@ impl Hooks for App {

That's it. Kill the server and bring it up again:

<!-- <snip id="starting-the-server-command" inject_from="yaml"> -->
<!-- <snip id="starting-the-server-command" inject_from="yaml" template="sh"> -->
```sh
cargo loco start
```
Expand Down Expand Up @@ -524,7 +524,7 @@ pub fn routes() -> Routes {
Now, start the app:
<!-- <snip id="starting-the-server-command" inject_from="yaml"> -->
<!-- <snip id="starting-the-server-command" inject_from="yaml" template="sh"> -->
```sh
cargo loco start
```
Expand Down Expand Up @@ -631,7 +631,7 @@ The order of the extractors is important, as changing the order of them can lead
You can now test that it works, start the app:
<!-- <snip id="starting-the-server-command" inject_from="yaml"> -->
<!-- <snip id="starting-the-server-command" inject_from="yaml" template="sh"> -->
```sh
cargo loco start
```
Expand Down
4 changes: 2 additions & 2 deletions docs-site/content/docs/getting-started/starters.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ flair =[]

Simplify your project setup with Loco's predefined boilerplates, designed to make your development journey smoother. To get started, install our CLI and choose the template that suits your needs.

<!-- <snip id="quick-installation-command" inject_from="yaml"> -->
<!-- <snip id="quick-installation-command" inject_from="yaml" template="sh"> -->
```sh
cargo install loco-cli
cargo install sea-orm-cli # Only when DB is needed
Expand All @@ -24,7 +24,7 @@ cargo install sea-orm-cli # Only when DB is needed

Create a starter:

<!-- <snip id="loco-cli-new-from-template" inject_from="yaml"> -->
<!-- <snip id="loco-cli-new-from-template" inject_from="yaml" template="sh"> -->
```sh
❯ loco new
✔ ❯ App name? · myapp
Expand Down
12 changes: 6 additions & 6 deletions docs-site/content/docs/getting-started/tour/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ flair =[]
<br/>
Let's create a blog backend on `loco` in 4 commands. First install `loco-cli` and `sea-orm-cli`:

<!-- <snip id="quick-installation-command" inject_from="yaml"> -->
<!-- <snip id="quick-installation-command" inject_from="yaml" template="sh"> -->
```sh
cargo install loco-cli
cargo install sea-orm-cli # Only when DB is needed
Expand Down Expand Up @@ -52,7 +52,7 @@ cargo install sea-orm-cli # Only when DB is needed
name in the `test.yaml`configuration will be `myapp_test`, and in the
`development.yaml` configuration, it will be `myapp_development`.

<!-- <snip id="postgres-run-docker-command" inject_from="yaml"> -->
<!-- <snip id="postgres-run-docker-command" inject_from="yaml" template="sh"> -->
```sh
docker run -d -p 5432:5432 \
-e POSTGRES_USER=loco \
Expand All @@ -67,7 +67,7 @@ docker run -d -p 5432:5432 \

Now `cd` into your `myapp` and start your app:

<!-- <snip id="starting-the-server-command-with-output" inject_from="yaml"> -->
<!-- <snip id="starting-the-server-command-with-output" inject_from="yaml" template="sh"> -->
```sh
$ cargo loco start

Expand Down Expand Up @@ -120,7 +120,7 @@ injected: "tests/requests/mod.rs"
Your database have been migrated and model, entities, and a full CRUD controller have been generated automatically.

Start your app:
<!-- <snip id="starting-the-server-command-with-output" inject_from="yaml"> -->
<!-- <snip id="starting-the-server-command-with-output" inject_from="yaml" template="sh"> -->
```sh
$ cargo loco start

Expand Down Expand Up @@ -176,15 +176,15 @@ To authenticate, you will need a running redis server.

This docker command starts up a redis server:

<!-- <snip id="redis-run-docker-command" inject_from="yaml"> -->
<!-- <snip id="redis-run-docker-command" inject_from="yaml" template="sh"> -->
```sh
docker run -p 6379:6379 -d redis redis-server
```
<!-- </snip> -->

Use doctor command to check the needed resources:

<!-- <snip id="doctor-command" inject_from="yaml"> -->
<!-- <snip id="doctor-command" inject_from="yaml" template="sh"> -->
```sh
$ cargo loco doctor
Finished dev [unoptimized + debuginfo] target(s) in 0.32s
Expand Down
37 changes: 5 additions & 32 deletions snipdoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,69 +3,47 @@ snippets:
content: 🚂 Loco is Rust on Rails.
path: ./snipdoc.yml
help-command:
content: |-
```sh
cargo loco --help
```
content: cargo loco --help
path: ./snipdoc.yml
exec-help-command:
content: cd ./examples/demo && cargo loco --help
path: ./snipdoc.yml
build-command:
content: |-
```sh
cargo build --release
```
content: cargo build --release
path: ./snipdoc.yml
quick-installation-command:
content: |-
```sh
cargo install loco-cli
cargo install sea-orm-cli # Only when DB is needed
```
path: ./snipdoc.yml
loco-cli-new-from-template:
content: |-
```sh
❯ loco new
✔ ❯ App name? · myapp
✔ ❯ What would you like to build? · SaaS app (with DB and user auth)
🚂 Loco app generated successfully in:
myapp
```
path: ./snipdoc.yml
postgres-run-docker-command:
content: |-
```sh
docker run -d -p 5432:5432 \
-e POSTGRES_USER=loco \
-e POSTGRES_DB=myapp_development \
-e POSTGRES_PASSWORD="loco" \
postgres:15.3-alpine
```
path: ./snipdoc.yml
redis-run-docker-command:
content: |-
```sh
docker run -p 6379:6379 -d redis redis-server
```
content: docker run -p 6379:6379 -d redis redis-server
path: ./snipdoc.yml
starting-the-server-command:
content: |-
```sh
cargo loco start
```
content: cargo loco start
path: ./snipdoc.yml
starting-the-server-command-with-environment-env-var:
content: |-
```sh
LOCO_ENV=qa cargo loco start
```
content: LOCO_ENV=qa cargo loco start
path: ./snipdoc.yml
starting-the-server-command-with-output:
content: |-
```sh
$ cargo loco start
▄ ▀
Expand All @@ -85,22 +63,18 @@ snippets:
https://loco.rs
listening on port 3000
```
path: ./snipdoc.yml
doctor-command:
content: |-
```sh
$ cargo loco doctor
Finished dev [unoptimized + debuginfo] target(s) in 0.32s
Running `target/debug/myapp-cli doctor`
✅ SeaORM CLI is installed
✅ DB connection: success
✅ Redis connection: success
```
path: ./snipdoc.yml
generate-deployment-command:
content: |-
```sh
cargo loco generate deployment
? ❯ Choose your deployment ›
❯ Docker
Expand All @@ -111,5 +85,4 @@ snippets:
✔ ❯ Choose your deployment · Docker
skipped (exists): "dockerfile"
added: ".dockerignore"
```
path: ./snipdoc.yml

0 comments on commit 8c4fa04

Please sign in to comment.