Skip to content

Commit

Permalink
feat: made cli auto-install needed tools and use global flags for con…
Browse files Browse the repository at this point in the history
…fig (#160)

* feat(cli): made cli use `wasm-bindgen` with full binary structure rather than `wasm-pack`

This provides *significant* flexibility for all sorts of brilliant new features!

* refactor: moved target directories into `dist/`

This cleans things up a little, and makes directory structures and
cleaning build artifacts much simpler.

* feat(cli): made `wasm-bindgen` and `wasm-opt` automatically install locally

Perseus now has no dependencies except Rust! This also *dramatically*
reduces bundle sizes for some reason (`wasm-pack` overhead?), by over
50kb in the basic example.

* fix(deployment): fixed deployed binaries not finding artifacts

* fix(deployment): fixed deployment copying GBs of cargo assets

Since we now store `cargo` target directories inside `dist/`, they were
being copied for exporting!

* feat(cli): made `wasm32-unknown-unknown` target auto-install with `rustup` available

* refactor(examples): updated all examples for new binary-only structure

* refactor!: made all cli env var config use global arguments instead (see `perseus --help`)

* fix(cli): prevented tool download in new/init/clean

* refactor: moved env vars for tool version configs into global arguments

* refactor: used more object-oriented style for installation code

This is more longwinded, but fixes a few priority issues, and it's much
more maintainable and extensible.

* feat(cli): added system-wide cache for tools

This will be used preferentially over a local directory if available,
minimizing wait times for creating new projects.

* chore(cli): updated `init` example for new binary-only structure

* test(cli): planned out tests structure for cli

* docs: updated i18n sizes with different translators

Our more advanced optimizations cut bundle sizes with Fluent *substantially*.

* test: fixed placeholder cli tests

* feat(cli): allowed provision of different `cargo`s for browser/engine

This will allow properly using the Cranelift backend.

BREAKING CHANGE: `[lib]`/`[[bin]]` settings no longer required in
`Cargo.toml`, and `lib.rs` should be renamed to `main.rs` (everything is
a binary now)
  • Loading branch information
arctic-hen7 authored Jul 18, 2022
1 parent b5bb075 commit 4682b9d
Show file tree
Hide file tree
Showing 67 changed files with 1,464 additions and 611 deletions.
10 changes: 0 additions & 10 deletions examples/comprehensive/tiny/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,3 @@ 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"
10 changes: 0 additions & 10 deletions examples/comprehensive/tiny/Cargo.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,3 @@ tokio = { version = "1", features = [ "macros", "rt", "rt-multi-thread" ] }
perseus-warp = { version = "=0.4.0-beta.4", features = [ "dflt-server" ] }

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

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

[[bin]]
name = "my-app"
path = "src/lib.rs"
File renamed without changes.
2 changes: 0 additions & 2 deletions examples/core/basic/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
dist/
target_engine/
target_wasm/
13 changes: 0 additions & 13 deletions examples/core/basic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,3 @@ 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-basic"
path = "src/lib.rs"

[package.metadata.wasm-pack.profile.release]
wasm-opt = [ "-Oz" ]
10 changes: 0 additions & 10 deletions examples/core/basic/Cargo.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,3 @@ tokio = { version = "1", features = [ "macros", "rt", "rt-multi-thread" ] }
perseus-warp = { version = "=0.4.0-beta.4", features = [ "dflt-server" ] }

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

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

[[bin]]
name = "my-app"
path = "src/lib.rs"
File renamed without changes.
10 changes: 0 additions & 10 deletions examples/core/custom_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,3 @@ perseus-warp = { path = "../../../packages/perseus-warp", features = [ "dflt-ser
warp = { package = "warp-fix-171", version = "0.3" } # Temporary until Warp #171 is resolved

[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-custom-server"
path = "src/lib.rs"
File renamed without changes.
10 changes: 0 additions & 10 deletions examples/core/freezing_and_thawing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,3 @@ 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-freezing-and-thawing"
path = "src/lib.rs"
10 changes: 0 additions & 10 deletions examples/core/global_state/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,3 @@ 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-global-state"
path = "src/lib.rs"
File renamed without changes.
10 changes: 0 additions & 10 deletions examples/core/i18n/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,3 @@ 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-i18n"
path = "src/lib.rs"
2 changes: 1 addition & 1 deletion examples/core/i18n/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

This example shows a very basic Perseus app using internationalization (abbreviated *i18n*) in three languages: English, French, and Spanish. This shows how to use translations, access them, and how to insert variables into them.

Note that this i18n in this example can use either the [Fluent](https://projectfluent.org) translator or the lightweight translator, so the `translations/` directory has both `.ftl` files (for Fluent), and `.json` files (for the lightweight translator). The optimized produced bundle sizes are 405.3kb and 289.4kb respectively.
Note that this i18n in this example can use either the [Fluent](https://projectfluent.org) translator or the lightweight translator, so the `translations/` directory has both `.ftl` files (for Fluent), and `.json` files (for the lightweight translator). The optimized produced bundle sizes are 336kb and 247.8kb respectively.
File renamed without changes.
10 changes: 0 additions & 10 deletions examples/core/idb_freezing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,3 @@ 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-idb-freezing"
path = "src/lib.rs"
File renamed without changes.
10 changes: 0 additions & 10 deletions examples/core/index_view/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,3 @@ 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-index-view"
path = "src/lib.rs"
File renamed without changes.
2 changes: 0 additions & 2 deletions examples/core/js_interop/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
dist/
target_engine/
target_wasm/
13 changes: 0 additions & 13 deletions examples/core/js_interop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,3 @@ 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-js-interop"
path = "src/lib.rs"

[package.metadata.wasm-pack.profile.release]
wasm-opt = [ "-Oz" ]
28 changes: 0 additions & 28 deletions examples/core/js_interop/Cargo.toml.example

This file was deleted.

File renamed without changes.
10 changes: 0 additions & 10 deletions examples/core/plugins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,3 @@ 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-plugins"
path = "src/lib.rs"
File renamed without changes.
10 changes: 0 additions & 10 deletions examples/core/router_state/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,3 @@ 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-router-state"
path = "src/lib.rs"
File renamed without changes.
10 changes: 0 additions & 10 deletions examples/core/rx_state/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,3 @@ 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-rx-state"
path = "src/lib.rs"
File renamed without changes.
10 changes: 0 additions & 10 deletions examples/core/set_headers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,3 @@ 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-set-headers"
path = "src/lib.rs"
File renamed without changes.
10 changes: 0 additions & 10 deletions examples/core/state_generation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,3 @@ 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-state-generation"
path = "src/lib.rs"
File renamed without changes.
10 changes: 0 additions & 10 deletions examples/core/static_content/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,3 @@ 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-static-content"
path = "src/lib.rs"
File renamed without changes.
10 changes: 0 additions & 10 deletions examples/core/unreactive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,3 @@ 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-unreactive"
path = "src/lib.rs"
File renamed without changes.
10 changes: 0 additions & 10 deletions examples/demos/auth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,5 @@ 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"
# We need the `HtmlDocument` feature to be able to use cookies (which this example does)
web-sys = { version = "0.3", features = [ "Storage" ] }

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

[[bin]]
name = "perseus-example-auth"
path = "src/lib.rs"
File renamed without changes.
10 changes: 0 additions & 10 deletions examples/demos/fetching/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,4 @@ perseus-integration = { path = "../../../packages/perseus-integration", default-
reqwest = "0.11"

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

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

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

This file was deleted.

File renamed without changes.
10 changes: 9 additions & 1 deletion packages/perseus-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,15 @@ ctrlc = { version = "3.0", features = ["termination"] }
notify = "=5.0.0-pre.13"
futures = "0.3"
tokio-stream = "0.1"
ureq = "2"
reqwest = { version = "0.11", features = [ "json", "stream" ] }
tar = "0.4"
flate2 = "1"
home = "0.5"

[dev-dependencies]
assert_cmd = "2"
assert_fs = "1"
predicates = "2"

[lib]
name = "perseus_cli"
Expand Down
Loading

0 comments on commit 4682b9d

Please sign in to comment.