Support Local Tools #11165
Replies: 2 comments 3 replies
-
Some updates after looking into this more. Deno already supports locally scoped scripts, sort of, by allowing you to specify the directory the script is installed in via I created an installable script to help with this or act as a prototype called scripts: It allows you to create a |
Beta Was this translation helpful? Give feedback.
-
I think you misunderstood the purpose of the |
Beta Was this translation helpful? Give feedback.
-
Description
Deno has some built-in tools:
https://github.com/denoland/deno/tree/main/tools
And deno supports installing user level scripts:
https://deno.land/[email protected]/tools/script_installer
But what if I have one repo that requires this particular version of a script but this other repo requires this other version of the same script? They both require the same command
example
but the two are not compatible... But they're installed at the user level so what am I going to do?In nodejs if you install a dependency non-globally which exports a bin then you can use "npx" to invoke it relative to the current directly. Or add an npm script such as
"compile": "tsc"
which can be run withnpm run compile
and the local bin scripts are in the path and have the correct versions when run from the local directory.Similarly .net core has an arguably better version of this same basic idea called "tools". One can run a command such as:
Which then adds a file to your local repo at
.config/dotnet-tools.json
which looks like this:And can then the tool be invoked via
dotnet tool version
.Both techniques add the ability to have tightly controlled versions of tools for both developers and the CI servers, without any cross pollution between repos on the same machine. Any updates by tools are code reviewable and are automatically updated easily.
Proposal
So therefore I propose that it would be very handy if deno were to support a notion of local tools, so that the versions of said tools could be more strictly relied upon and limited to a given repo. A tool tool, so to speak.
Something like:
Which would subsequently behave similar to the existing install command but it would add it to a subdirectory under the current directory such as
.tools
or.deno
.So now if I just run
example
it won't work automatically. Rather, instead I would invoke a deno command:Which the implementation might be as simple as adding the
.tools
folder to your path and invoking the command.Also it would be nice to have a supported file such as
.config/deno-tools.json
which would maybe look like:And could then be installed and run like this:
The one command would install all of the necessary tools for a given repo and would allow the repo to formally rely on those commands for automation.
Bonus Points
it would be really sweet if tools could be combined also, such as:
Where each line would invoke a tool one at a time such as
deno tool $@
, and would require each tool to return 0 to continue.Beta Was this translation helpful? Give feedback.
All reactions