Skip to content

Commit

Permalink
refactor: ♻️ rewrote showcase example to use cli
Browse files Browse the repository at this point in the history
It was getting very outdated and useless.
  • Loading branch information
arctic-hen7 committed Sep 9, 2021
1 parent 8d70599 commit c2f1091
Show file tree
Hide file tree
Showing 33 changed files with 204 additions and 337 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"packages/perseus-actix-web",
"packages/perseus-cli",
# TODO remake showcase app for CLI
"examples/showcase",
# "examples/showcase/app",
# "examples/showcase/server-actix-web",
"examples/cli",
Expand Down
17 changes: 2 additions & 15 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,7 @@ This folder contains examples for Perseus, which are used to test the project an

These examples are all fully self-contained, and do not serve as examples in the traditional Cargo way, they are each indepedent crates to enable the use of build tools such as `wasm-pack`.

## Workspaces??

A Perseus setup is composed of an app and a server, which would normally be in a workspace project. However, examples with their own `Cargo.toml` manifests aren't detected by RLS, and so we need to make them part of the super-workspace at the root. The problem with that is that then we'd have nested workspaces, which are currently impossible. The solution used is to have each example be atomic (i.e. app OR server), but they're still listed together under the same parent directory. If you want to clone one of these to run locally without the rest of the repo, you'll need to get the appropriate directory with both an app and a server, and then add a new `Cargo.toml` at the root of that with the following contents:

```toml
[workspace]
members = [
"app",
"server"
]
```

All (non-CLI) examples should have both an `app` and a `server` directory.

- Showcase -- an app that demonstrates all the different features of Perseus, including SSR, SSG, and ISR (this example is actively used for testing)
- Showcase -- an app that demonstrates all the different features of Perseus, including SSR, SSG, and ISR (this example is actively used for testing/development)
- Basic -- a simple app that uses the Perseus CLI (symlinks to CLI example)
- CLI -- same as basic, but includes the CLI subcrates (actively used for testing/development)
- i18n -- a simple app that showcases internationalization in particular
4 changes: 2 additions & 2 deletions examples/basic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ edition = "2018"

[dependencies]
perseus = { path = "../../packages/perseus" }
sycamore = { version = "0.5.1", features = ["ssr"] }
sycamore-router = "0.5.1"
sycamore = { version = "0.5", features = ["ssr"] }
sycamore-router = "0.5"
serde = { version = "1", features = ["derive"] }
serde_json = "1" # Possibly don't need?

Expand Down
4 changes: 2 additions & 2 deletions examples/cli/.perseus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ edition = "2018"
app = { package = "perseus-example-cli", path = "../" }

perseus = { path = "../../../packages/perseus" }
sycamore = { version = "0.5.1", features = ["ssr"] }
sycamore-router = "0.5.1"
sycamore = { version = "0.5", features = ["ssr"] }
sycamore-router = "0.5"
web-sys = { version = "0.3", features = ["Headers", "Request", "RequestInit", "RequestMode", "Response", "ReadableStream", "Window"] }
wasm-bindgen = { version = "0.2", features = ["serde-serialize"] }
serde = { version = "1", features = ["derive"] }
Expand Down
4 changes: 2 additions & 2 deletions examples/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ edition = "2018"

[dependencies]
perseus = { path = "../../packages/perseus" }
sycamore = { version = "0.5.1", features = ["ssr"] }
sycamore-router = "0.5.1"
sycamore = { version = "0.5", features = ["ssr"] }
sycamore-router = "0.5"
serde = { version = "1", features = ["derive"] }
serde_json = "1" # Possibly don't need?

Expand Down
4 changes: 2 additions & 2 deletions examples/i18n/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ edition = "2018"
# Perseus itself, which we (amazingly) need for a Perseus app
perseus = { path = "../../packages/perseus" }
# Sycamore, the library Perseus depends on for lower-leve reactivity primitivity
sycamore = { version = "0.5.1", features = ["ssr"] }
sycamore-router = "0.5.1"
sycamore = { version = "0.5", features = ["ssr"] }
sycamore-router = "0.5"
# Serde, which lets you work with representations of data, like JSON
serde = { version = "1", features = ["derive"] }
serde_json = "1"
Expand Down
7 changes: 3 additions & 4 deletions examples/showcase/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
target/
Cargo.lock
dist/
pkg/
/target

.perseus/
18 changes: 18 additions & 0 deletions examples/showcase/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "perseus-example-showcase"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
# Perseus itself, which we (amazingly) need for a Perseus app
perseus = { path = "../../packages/perseus" }
# Sycamore, the library Perseus depends on for lower-leve reactivity primitivity
sycamore = { version = "0.5", features = ["ssr"] }
sycamore-router = "0.5"
# Serde, which lets you work with representations of data, like JSON
serde = { version = "1", features = ["derive"] }
serde_json = "1"

urlencoding = "2.1"
26 changes: 0 additions & 26 deletions examples/showcase/app/Cargo.toml

This file was deleted.

6 changes: 0 additions & 6 deletions examples/showcase/app/main.js

This file was deleted.

25 changes: 0 additions & 25 deletions examples/showcase/app/src/bin/build.rs

This file was deleted.

127 changes: 0 additions & 127 deletions examples/showcase/app/src/lib.rs

This file was deleted.

26 changes: 0 additions & 26 deletions examples/showcase/app/src/pages/mod.rs

This file was deleted.

19 changes: 0 additions & 19 deletions examples/showcase/bonnie.toml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Perseus Starter App</title>
<title>Perseus Showcase App</title>
<!-- Importing this runs Perseus -->
<script src="/.perseus/bundle.js" defer></script>
</head>
<body>
<div id="_perseus_root"></div>
<div id="root"></div>
</body>
</html>
17 changes: 0 additions & 17 deletions examples/showcase/server-actix-web/Cargo.toml

This file was deleted.

23 changes: 0 additions & 23 deletions examples/showcase/server-actix-web/src/main.rs

This file was deleted.

Loading

0 comments on commit c2f1091

Please sign in to comment.