Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved commands sub-system #168

Merged
merged 2 commits into from
Aug 1, 2023
Merged

Conversation

aperepel
Copy link
Collaborator

Reworked the command subsystem. Commands are now implemented as traits with default
template methods and just need to fill out the customized parts (vs duplicating most of the code).

Improved the user feedback, made the output consistent across commands.
Fixed error handling so any download and binary executable resolution problems are exposed (vs being silently swallowed).

Some Highlights:

  • cargo leptos will now check (once a day) for new versions of tools like sass,
    tailwindcss, wasm-ops via the GitHub release API and inform the user of a newer available version. This happens lazily
    for commands when they are used, but only once on startup and no more frequently than once a day.
  • As part of the above exercise, improved the version recognition, so all kinds of variants like 1.0, version_112, v3.3.1, etc are consistently handled and compared. This lays the foundation for the semver style version requests.
  • As prompted by the command, a user can quickly try out the new version by overriding the env var, e.g. LEPTOS_TAILWIND_VERSION=v3.3.3 cargo leptos watch --hot-reload -vv. The binary will
    be downloaded transparently and cached. Switching between tool versions has never been easier!
  • Naturally, downgrades are now trivial as well (just pin the version via the env var).

Added the following env vars:

LEPTOS_CARGO_GENERATE_VERSION
LEPTOS_TAILWIND_VERSION
LEPTOS_SASS_VERSION
LEPTOS_WASM_OPT_VERSION

Things I'd Like to Do:

  • Switch to the semver style requests, so e.g. a patch-compatible version can be declared as desired and the updates are happening easily and transparently.
  • Related to the above, remove the need for a hardcoded default version for every tool (do the best thing OOTB). Leveraging semver will ensure we pick up only compatible upgrades, unless instructed otherwise by the user.

P.S.: I'm not claiming to have extensive idiomatic Rust knowledge, feel free to propose all kinds of improvements to the code style.

* Improvements in the cargo leptos command infra

Can now override versions and debug-report tool versions used on startup.
Added ability to override any tool version via an env var.
Use the current latest tailwindcss version v3.3.3, still hardcoded for now.
Properly handle tool download errors and halt.
Report the binary command cache dir location on startup (once).
Addressed Cippy linter suggestions and suppressed where applicable.

* Don't emit warnings for LEPTOS_XXX_VERSION new env vars.
Providing feedback when compiling WASM, otherwise there's a weird delay with no updates on startup.

* Groundwork and test cases for semantic version handling of tool deps.

* Groundwork and test cases for semantic version handling of tool deps.

* Made things agree with the Tokio runtime and not blow up anymore. WIP.

* if/else -> match, cleanup

* Messages cleanup for consistency

* Simplified - AtomicBoolean no longer required after async rework. Simplified the tokio spawn call.

* Refactored the commands into async trait objects. Moved most of the logic into the default trait methods with commands being the templates (to avoid duplication). This version compiles and works, further cleanup coming up.

* Working impl of the tailwindcss command

* Moved WASM opt logic into the trait

* Lifted the WASM compilation start message to the info level

* Finished SASS and Cargo Generate commands. Cleaned up and updated tests.
Addressed the review comments to move helper methods out of the trait.
@aperepel aperepel merged commit b8e4fe5 into leptos-rs:main Aug 1, 2023
3 checks passed
@aperepel aperepel deleted the pr-commands branch August 2, 2023 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant