Deno does away with the
package.json of the Node.js era, and introduces version control by putting the version number directly into the URL.
According to the style guide, it is recommended to load modules into a file called
deps.ts and import them indirectly from there in the project.
Here is a tool, UDD, to help you manage the module version.
It seems that UDD stands for Update Deno Dependencies.
By the way, why does the Sauropod of the main image (↓) have a cow-like atmosphere?
Raising and lowering its long neck to eat grass that grows directly on the ground is obviously useless, so I think the survival of the species is in jeopardy...
It is available at
deno.land/x. Let's install it with
❯ deno install -A -f -n udd https://email@example.com/main.ts (logs...) ✅ Successfully installed udd /Users/kawarimidoll/.deno/bin/udd
The default installation directory is
~/.deno/bin. Make sure that your
PATH includes this directory.
If you run it with no arguments, you can see help.
❯ udd usage: udd [-h] [--dry-run] [--test TEST] file [file ...] udd: Update Deno Dependencies Positional arguments: file files to update dependencies Optional arguments: -h, --help show this help text --dry-run test what dependencies can be updated --test TEST command to run after each dependency update e.g. "deno test"
udd checks the version of the modules in the file, and updates them all at once.
❯ # basic ❯ udd deps.ts ❯ # just check ❯ udd deps.ts --dry-run ❯ # multiple files ❯ udd main.ts util.ts ❯ # bulk ❯ udd *.ts
Modules that do not contain a version number in the
import URL will be skipped.
If you add the
--test option, it will update the file after making sure that the test passes.
❯ udd deps.ts --test="deno test"
Basically, you can run it without any configuration, so you can try it right away.
Another advantage is that if you no longer use this tool, there is no debt associated with it.
At the time of writing, the following registries have been updated.
Most of the commonly used ones in Deno are supported.
As mentioned above, no configuration is required for the basic operation, but there are a few useful settings that can be found here.
package.json in Node.js, you can fix the major version by adding a token.
This is specified in the hash of the module URL. This is a very interesting idea.
^Fix the major version
- If the major version is 0, fix the minor version.
~Fix major and minor versions
- If the major version is 0, the minor version will be updated.
<[version]Fix to a lower version (in semver) than the specified version.
=Do not update.
< requires you to specify the upper version limit, others refer to the version specification contained in the URL.
This is a personal preference, but I like to use Velociraptor for all the commands used in the Deno project.
Add a configuration like this to
scripts: deps: desc: Update dependencies with ensuring pass tests cmd: udd deps.ts --test="deno test -Ar"
Now you can use
vr deps to update the module while checking that the test passes.
This configuration is included in my template.
This will allow us to "test and update" and reduce the psychological and work load of updating modules.
As a result, the life of the project will be extended.
This is a translation of the following article.
Please leave comments if there are any mistakes in the translation.