support Deno auto installation#968
Conversation
- Implement Deno language handler with dependency isolation - Support npm packages via `additional_dependencies` - Add 8 tests covering basic usage, dependencies, and error cases - example config showing deno fmt, lint, and npm eslint hook usage
Implement full-fledged Deno language support with automatic version management, mirroring the installation patterns used for Node.js and Go. - **installer.rs**: New DenoInstaller that downloads and installs Deno versions - Downloads from GitHub releases (https://github.com/denoland/deno/releases) - Searches installed versions in $PREK_HOME/tools/deno - Falls back to system Deno if version matches - Supports all platforms: Linux, macOS, Windows (x86_64, aarch64) - Uses file locking to prevent concurrent installations - Implements proper binary extraction and permission setup - **version.rs**: New DenoVersion and DenoRequest types - Supports version specifications: exact (1.40.0), major (1), major.minor (1.40) - Supports semver ranges: ">= 1.40, < 1.50" - Handles "deno", "deno@version", "latest", "system" formats - Supports local path specifications - Comprehensive unit tests for version parsing - **deno.rs**: Updated to use DenoInstaller - Removed manual system-only detection - Integrated with DenoInstaller for automatic downloads - Simplified installation flow - Proper health checks with version validation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## deno #968 +/- ##
==========================================
+ Coverage 83.58% 89.59% +6.00%
==========================================
Files 67 69 +2
Lines 12352 12680 +328
==========================================
+ Hits 10325 11361 +1036
+ Misses 2027 1319 -708 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
wow! |
* Update language support status * Tweak
📦 Cargo Bloat ComparisonBinary size change: +0.62% (16.1 MiB → 16.2 MiB) Expand for cargo-bloat outputPR Branch ResultsBase Branch Results |
src/languages/deno/deno.rs
Outdated
| fs_err::tokio::copy(repo_deno_json, &deno_json).await?; | ||
| needs_deno_json = false; | ||
| } | ||
| // Deno can run scripts directly from the repo without installation |
There was a problem hiding this comment.
I think we need to cache dependencies from deno.json (by deno install?). The idea is that install should set up everything needed for the hooks to run, so when we call run, it can work completely offline.
There was a problem hiding this comment.
not an expert of deno, just a user. but i think deno maintains it's own global cache of every package that was ever imported in an executed script (be it from NPM, JSR or directly via URL from GitHub)
There was a problem hiding this comment.
i guess we can call deno cache during hook installation. subtle benefit of that:
- with
deno cache: Dependencies are downloaded duringprek install(slower install, faster first run, can detect dependency issues early) - without
deno cache: Dependencies are downloaded on first hook run (faster install, slightly slower first run)
* Fail windows CI when an error occured * Fix tests
tests/languages/deno.rs
Outdated
| "#); | ||
| } | ||
|
|
||
| /// Test that when deno is not available, a helpful error is shown. |
There was a problem hiding this comment.
deno will be installed automatically, right?
src/languages/deno/deno.rs
Outdated
| // Replace "deno" with the actual path to the installed deno binary | ||
| let command = if entry[0] == "deno" { | ||
| deno_bin.as_path() | ||
| } else { | ||
| Path::new(&entry[0]) | ||
| }; |
There was a problem hiding this comment.
How about symlinking the deno executable into the hook env bin dir and prepending that bin dir to PATH, like we did in the node implementation? That might work better than this approach. For example, it would work for cases like entry: ./run_deno.sh.
There was a problem hiding this comment.
If you agree, I can take care of it.
…H resolution - Create bin/ directory in hook environment with symlinked deno executable - Prepend bin/ to PATH during install and run, matching Node implementation - Use entry.resolve() to find commands in PATH instead of manual replacement - Enables shell scripts to call `deno` directly with correct isolated version - add test verifying deno is available in PATH for shell scripts addresses #968 (comment)
- Simplify find_script_to_cache() using functional approach - Fix is_cacheable_script() to only match JS/TS files (prevents caching shell scripts) - Add support for .mjs, .tsx, .jsx extensions - Extract deno_bin variable to reduce duplication - Consolidate PATH setup to single location - Simplify deno.json creation logic - Add deno cache call during install for offline hook execution
|
btw, feel free to make changes as you see fit in this PR. i'm outside my comfort area here and may have made stupid mistakes so everything is up for scrutiny. also, feel free to merge this PR into the |
|
I'm going to merge this into |
* Do not check for `script` subprocess status (#964) * Update README * Allow using system trusted store by `PREK_NATIVE_TLS` (#959) * Fix compatibility with older luarocks (#967) * support isolated hook environments for `language: deno` - Implement Deno language handler with dependency isolation - Support npm packages via `additional_dependencies` - Add 8 tests covering basic usage, dependencies, and error cases - example config showing deno fmt, lint, and npm eslint hook usage * support Deno auto installation Implement full-fledged Deno language support with automatic version management, mirroring the installation patterns used for Node.js and Go. - **installer.rs**: New DenoInstaller that downloads and installs Deno versions - Downloads from GitHub releases (https://github.com/denoland/deno/releases) - Searches installed versions in $PREK_HOME/tools/deno - Falls back to system Deno if version matches - Supports all platforms: Linux, macOS, Windows (x86_64, aarch64) - Uses file locking to prevent concurrent installations - Implements proper binary extraction and permission setup - **version.rs**: New DenoVersion and DenoRequest types - Supports version specifications: exact (1.40.0), major (1), major.minor (1.40) - Supports semver ranges: ">= 1.40, < 1.50" - Handles "deno", "deno@version", "latest", "system" formats - Supports local path specifications - Comprehensive unit tests for version parsing - **deno.rs**: Updated to use DenoInstaller - Removed manual system-only detection - Integrated with DenoInstaller for automatic downloads - Simplified installation flow - Proper health checks with version validation * Update language support status (#970) * Update language support status * Tweak * Fix DenoRequest parsing * Generate cli reference * Fail windows CI when an error occured (#971) * Fail windows CI when an error occured * Fix tests * Use global client * delete outdated test, deno auto-installs after 2nd commit addresses j178/prek#968 (comment) * refactor(deno): symlink deno executable into hook bin dir and use PATH resolution - Create bin/ directory in hook environment with symlinked deno executable - Prepend bin/ to PATH during install and run, matching Node implementation - Use entry.resolve() to find commands in PATH instead of manual replacement - Enables shell scripts to call `deno` directly with correct isolated version - add test verifying deno is available in PATH for shell scripts addresses j178/prek#968 (comment) * refactor(deno): simplify install logic and add dependency caching - Simplify find_script_to_cache() using functional approach - Fix is_cacheable_script() to only match JS/TS files (prevents caching shell scripts) - Add support for .mjs, .tsx, .jsx extensions - Extract deno_bin variable to reduce duplication - Consolidate PATH setup to single location - Simplify deno.json creation logic - Add deno cache call during install for offline hook execution --------- Co-authored-by: Jo <10510431+j178@users.noreply.github.com> Co-authored-by: Steven Taylor <steven@taylormuff.co.uk>
denolanguage support for pre-commit hooks with automatic version management from GitHub releases.Features:
language_version(exact, semver ranges) andadditional_dependencies(npm:, jsr:)DENO_DIRfor dependency cachingChanges:
DenoInstaller,DenoVersion, andDenoRequestfor version managementMirrors Node.js/Go installation patterns for consistency.