Skip to content

Commit

Permalink
feat: removed .perseus/ (#151)
Browse files Browse the repository at this point in the history
* feat: made the engine code functional in the user's code

No support for serving yet and there's still Wasm binary bloat.

* feat: added support for serving

Still a lot of Wasm binary bloat.

* feat: integrated client-side code

This is untested as yet, I'll update the CLI first.

* feat: updated the cli and brought everything together

This is still untested because of a Cargo dependency unification issue.

* fix: fixed all issues by changing the cargo resolver

This is literally dark magic.

* fix: fixed `HydrateNode`/`DomNode` issues and reformed original structure

* fix: fixed small errors with cli

* fix: fixed some macro and example errors

* style: appeased `clippy`

* chore: updated bonnie checking script

* chore: deleted `.perseus/`!

* feat: added convenience macros

Also changed the `run_dflt_engine` and `run_client` APIs to make them
all take functions that return apps, rather than apps directly, which
makes the Actix Web integration able to work normally (by making
everything else share its quirks).

* feat: added more convenience macros

* refactor: broke out macros under a new features

This feature is the default though.

* feat: added dflt engine system for export-only apps

* test: updated all examples

Except `fetching`, need to merge from `main`.

* test: updated `fetching` example

* style: appeased clippy

* fix: fixed unused code warnings from macros

Just made the user's functions `pub` to stop the compiler whining.

* feat: added `#[main_export]` for apps not using a server

* feat: added support for custom cargo/wasm-pack args to cli

* fix: fixed actix dflt server return type

* test: made all examples work with all integrations

There's now an `EXAMPLE_INTEGRATION` environment variable that controls
this, which is set to `warp` by default in a new `.env` file, which
Bonnie can read.

* fix: fixed i18n translator misreference

* feat: superseded `autoserde` macro

This also adds a `build_paths` macro to make that work with the new systems.

* test: fixed testing script

* chore: updated `bonnie.toml` for new layout

* ci: removed `ci-prep` calls and added `wasm32-unknown-unknown` target for `check` op

* ci: fixed remnant `ci-prep` invocation

* fix: fixed global build state server/client division

* fix: added missing build paths annotation

* test: removed unnecessary test from plugins example

This made it uncompilable because of the silly way I've set that up.
I'll fix that as I rewrite the docs for v0.4.0.

* chore: updated `bn test` command with all core examples

* feat: added `should_revalidate` macro

* fix: fixed imports in headers example

* fix: fixed static content paths in new layout

* fix: fixed imports in state generation example

BREAKING CHANGE: 
    Changed multiple APIs for functional plugin actions related to the builder (they all take the new EngineError type now)
    Restructured exports related to engine functionality (this will get progressively worse as this PR develops!)
    Removed the HOST and PORT environment variables for configuring the server (these are replaced with PERSEUS_HOST and PERSEUS_PORT)
    Substantially refactored exports from Perseus
    Divided client-side and server-side exports (many functions will now need to be target-gated)
    Replaced #[autoserde(...)] macro with macros for each state function (#[build_state], #[build_paths], etc.)
    The #[build_paths] macro must now be applied to all build paths functions (for client/server functionality division)
    #[perseus::main] now takes an argument as the default server to use (server integrations should now be imported and used)
    Made state functions automatically target-gated as #[cfg(not(feature = "wasm32"))]
    The #[should_revalidate] macro must now be applied to all revalidation determination functions (for client/server functionality division)
  • Loading branch information
arctic-hen7 authored Jun 22, 2022
1 parent 3cc247b commit 14f415a
Show file tree
Hide file tree
Showing 170 changed files with 2,304 additions and 1,951 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
EXAMPLE_INTEGRATION=warp
2 changes: 0 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
steps:
- uses: actions/checkout@v2
- run: cargo install bonnie
- run: bonnie ci-prep
- name: Build
run: cargo build --release
working-directory: packages/perseus-cli
Expand All @@ -45,7 +44,6 @@ jobs:
- name: Install musl toolchain
run: rustup target add x86_64-unknown-linux-musl
- run: cargo install bonnie
- run: bonnie ci-prep
- name: Build
run: cargo build --release --target x86_64-unknown-linux-musl
working-directory: packages/perseus-cli
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ jobs:
steps:
- uses: actions/checkout@v2
- run: cargo install bonnie
- run: bonnie ci-prep
- run: rustup target add wasm32-unknown-unknown
- name: Run checks
run: bonnie check
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: cargo install bonnie
- run: bonnie ci-prep
- name: Run traditional tests
run: cargo test --all
# We now have a separate job for each example's E2E testing because they all take a while, we may as well run them in parallel
Expand Down Expand Up @@ -64,6 +63,5 @@ jobs:
- run: sudo apt install firefox firefox-geckodriver
- name: Run Firefox WebDriver
run: geckodriver &
- run: bonnie ci-prep
- name: Run E2E tests for example ${{ matrix.name }} in category ${{ matrix.type }}
run: bonnie test example-all-integrations ${{ matrix.type }} ${{ matrix.name }} --headless
16 changes: 13 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ members = [
"website",
# We have the CLI subcrates as workspace members so we can actively develop on them
# They also can't be a workspace until nested workspaces are supported
"examples/core/basic/.perseus",
"examples/core/basic/.perseus/server",
"examples/core/basic/.perseus/builder"
# "examples/core/basic/.perseus",
# "examples/core/basic/.perseus/server",
# "examples/core/basic/.perseus/builder"
]
resolver = "2"

[patch.crates-io]
sycamore = { git = "https://github.com/arctic-hen7/sycamore" }
sycamore-router = { git = "https://github.com/arctic-hen7/sycamore" }
sycamore-router-macro = { git = "https://github.com/arctic-hen7/sycamore" }
sycamore-macro = { git = "https://github.com/arctic-hen7/sycamore" }
sycamore-core = { git = "https://github.com/arctic-hen7/sycamore" }
sycamore-reactive = { git = "https://github.com/arctic-hen7/sycamore" }
sycamore-web = { git = "https://github.com/arctic-hen7/sycamore" }
37 changes: 15 additions & 22 deletions bonnie.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
version="0.3.2"
env_files = [ ".env" ]

[scripts]
setup.cmd.generic = [
"mkdir -p examples/core/basic/.perseus/dist",
"mkdir -p examples/core/basic/.perseus/dist/static",
"mkdir -p examples/core/basic/.perseus/dist/exported",
"cargo build",
"npm i --prefix ./website",
"echo \"\n\nThe Perseus repository is ready for local development! Type 'bonnie help' to see the available commands you can run here. Also, please ensure that you have 'npx' available and that you've installed 'tailwindcss', `concurrently`, `serve` and 'browser-sync' ('npm i -g tailwindcss concurrently serve browser-sync') if you'll be working with the website or running `bonnie dev export-serve ...`.\""
]
setup.cmd.targets.windows = [
"New-Item -Force -ItemType directory -Path examples\\core\\basic\\.perseus\\dist",
"New-Item -Force -ItemType directory -Path examples\\core\\basic\\.perseus\\dist\\static",
"New-Item -Force -ItemType directory -Path examples\\core\\basic\\.perseus\\dist\\exported",
"cargo build",
"npm i --prefix ./website",
"Write-Host \"\n\nThe Perseus repository is ready for local development! Type 'bonnie help' to see the available commands you can run here. Also, please ensure that you have 'npx' available and that you've installed 'tailwindcss', `concurrently`, `serve` and 'browser-sync' ('npm i -g tailwindcss concurrently serve browser-sync') if you'll be working with the website or running `bonnie dev export-serve ...`.\""
Expand Down Expand Up @@ -40,17 +35,19 @@ dev.subcommands.export-serve-deploy-relative.cmd.targets.windows = [
dev.subcommands.export-serve-deploy-relative.args = [ "category", "example" ]
dev.subcommands.export-serve-deploy-relative.desc = "deploys (exported) and serves the given example at a relative local path"

# TODO Make this not set the integration feature unless a certain file in the example calls for it
dev.subcommands.example.cmd.generic = [
"cd packages/perseus-cli",
# Point this live version of the CLI at the given example
"TEST_EXAMPLE=../../examples/%category/%example cargo run -- %%"
"TEST_EXAMPLE=../../examples/%category/%example PERSEUS_CARGO_ARGS=\"--features \"perseus-integration/%EXAMPLE_INTEGRATION\"\" cargo run -- %%"
]
dev.subcommands.example.cmd.targets.windows = [
"cd packages\\perseus-cli",
# Point this live version of the CLI at the given example
"powershell -Command { $env:TEST_EXAMPLE=\"..\\..\\examples\\%category\\%example\"; cargo run -- %% }"
"powershell -Command { $env:TEST_EXAMPLE=\"..\\..\\examples\\%category\\%example\"; $end:PERSEUS_CARGO_ARGS=\"--features \"perseus-integration/%EXAMPLE_INTEGRATION\"\"; cargo run -- %% }"
]
dev.subcommands.example.args = [ "category", "example" ]
dev.subcommands.example.env_vars = [ "EXAMPLE_INTEGRATION" ] # This will be set automatically to Warp by `.env` unless overridden
dev.subcommands.example.desc = "runs the given example using a live version of the cli"

site.cmd = "concurrently \"bonnie site export\" \"bonnie site build-tailwind\""
Expand Down Expand Up @@ -143,20 +140,13 @@ site.subcommands.run.desc = "runs the website without watching for changes"
check.cmd = [
"cargo check --all",
"cargo fmt --all -- --check",
"cargo clippy --all"
"cargo clippy --all",
# We also have to check the `perseus` package in particular on Wasm (the examples are handled by the E2E tests)
"cd packages/perseus",
"cargo check --target wasm32-unknown-unknown"
]
check.desc = "checks code for formatting errors and the like"

ci-prep.cmd.generic = [
"mkdir -p examples/core/basic/.perseus/dist",
"mkdir -p examples/core/basic/.perseus/dist/static",
]
ci-prep.cmd.targets.windows = [
"New-Item -Force -ItemType directory -Path examples\\core\\basic\\.perseus\\dist",
"New-Item -Force -ItemType directory -Path examples\\core\\basic\\.perseus\\static",
]
ci-prep.desc = "creates empty directories to preserve the file structure that testing expects"

test.cmd = [
"cargo test", # This will ignore Wasm tests
# Run tests for each example
Expand All @@ -169,7 +159,10 @@ test.cmd = [
"bonnie test example-all-integrations core global_state --headless",
"bonnie test example-all-integrations core idb_freezing --headless",
"bonnie test example-all-integrations core router_state --headless",
"bonnie test example-all-integrations core rx_state --headless"
"bonnie test example-all-integrations core rx_state --headless",
"bonnie test example-all-integrations core index_view --headless",
"bonnie test example-all-integrations core set_headers --headless",
"bonnie test example-all-integrations core static_content --headless"
]
test.desc = "runs all tests headlessly (assumes geckodriver running in background)"
test.subcommands.core.cmd = "cargo test"
Expand Down Expand Up @@ -204,7 +197,7 @@ release.desc = "creates a new project release and pushes it to github (cargo ver

# --- COMMANDS FOLLOWING THIS POINT ARE LINUX-ONLY ---

replace-versions.cmd = "find . \\( \\( -name \"*Cargo.toml\" -or -name \"*Cargo.toml.example\" -or \\( -name \"*.md\" -not -name \"*.proj.md\" \\) \\) -not -name \"CHANGELOG.md\" -not -path \"./target/*\" -not -path \"./website/*\" -not -path \"*.perseus*\" -or \\( -name \"*Cargo.toml\" -path \"./examples/core/basic/.perseus/*\" -not -path \"./examples/core/basic/.perseus/dist/*\" \\) \\) -exec sed -i -e 's/%old_version/%new_version/g' {} \\;"
replace-versions.cmd = "find . \\( \\( -name \"*Cargo.toml\" -or -name \"*Cargo.toml.example\" -or \\( -name \"*.md\" -not -name \"*.proj.md\" \\) \\) -not -name \"CHANGELOG.md\" -not -path \"./target/*\" -not -path \"./website/*\" \\) -exec sed -i -e 's/%old_version/%new_version/g' {} \\;"
replace-versions.args = [ "old_version", "new_version" ]
replace-versions.desc = "replaces an old version number with a new one in all relevant files (Linux only)"

Expand All @@ -217,7 +210,7 @@ publish.cmd = [
"cd ../perseus",
"cargo publish %%",
"cd ../perseus-cli",
"cargo publish --allow-dirty %%", # Without this flag, `.perseus` will be a problem because it's not in Git
"cargo publish %%",
# We delay this so that `crates.io` can have time to host the core
"cd ../perseus-actix-web",
"cargo publish %%",
Expand Down
3 changes: 1 addition & 2 deletions examples/comprehensive/tiny/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

.perseus/
dist/
16 changes: 16 additions & 0 deletions examples/comprehensive/tiny/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,19 @@ edition = "2021"
[dependencies]
perseus = { path = "../../../packages/perseus" }
sycamore = "=0.8.0-beta.6"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { version = "1", features = [ "macros", "rt", "rt-multi-thread" ] }
perseus-integration = { path = "../../../packages/perseus-integration", default-features = false }

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = "0.2"

[lib]
name = "lib"
path = "src/lib.rs"
crate-type = [ "cdylib", "rlib" ]

[[bin]]
name = "perseus-example-tiny"
path = "src/lib.rs"
11 changes: 0 additions & 11 deletions examples/comprehensive/tiny/index.html

This file was deleted.

4 changes: 2 additions & 2 deletions examples/comprehensive/tiny/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use perseus::{Html, PerseusApp, Template, ErrorPages};
use perseus::{ErrorPages, Html, PerseusApp, Template};
use sycamore::view;

#[perseus::main]
#[perseus::main(perseus_integration::dflt_server)]
pub fn main<G: Html>() -> PerseusApp<G> {
PerseusApp::new()
.template(|| {
Expand Down
1 change: 1 addition & 0 deletions examples/core/basic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
2 changes: 0 additions & 2 deletions examples/core/basic/.perseus/.gitignore

This file was deleted.

29 changes: 0 additions & 29 deletions examples/core/basic/.perseus/Cargo.toml

This file was deleted.

36 changes: 0 additions & 36 deletions examples/core/basic/.perseus/builder/Cargo.toml

This file was deleted.

93 changes: 0 additions & 93 deletions examples/core/basic/.perseus/builder/src/bin/export_error_page.rs

This file was deleted.

24 changes: 0 additions & 24 deletions examples/core/basic/.perseus/builder/src/bin/tinker.rs

This file was deleted.

Loading

0 comments on commit 14f415a

Please sign in to comment.